mirror of
https://gitlab.os-k.eu/os-k-team/os-k.git
synced 2023-08-25 14:03:10 +02:00
79 lines
2.8 KiB
C
79 lines
2.8 KiB
C
//----------------------------------------------------------------------------//
|
|
// GNU GPL OS/K //
|
|
// //
|
|
// Authors: spectral` //
|
|
// NeoX //
|
|
// //
|
|
// Desc: Kaleid type limits definitions //
|
|
//----------------------------------------------------------------------------//
|
|
|
|
#ifndef _KALBASE_LIMITS_H
|
|
#define _KALBASE_LIMITS_H
|
|
|
|
//------------------------------------------//
|
|
|
|
#define BYTE unsigned char
|
|
#define WORD unsigned short
|
|
#define DWORD unsigned int
|
|
#define QWORD unsigned long
|
|
|
|
#define CHAR_BIT 8
|
|
#define BITS_IN(T) (sizeof(T) * CHAR_BIT)
|
|
|
|
/* XXX find a generic way */
|
|
#define BYTES_TO_WORDS(B) ((B) >> 1)
|
|
#define BYTES_TO_DWORDS(B) ((B) >> 2)
|
|
#define BYTES_TO_QWORDS(B) ((B) >> 3)
|
|
#define WORDS_TO_BYTES(W) ((W) << 1)
|
|
#define WORDS_TO_DWORDS(W) ((W) >> 1)
|
|
#define WORDS_TO_QWORDS(W) ((W) >> 2)
|
|
#define DWORDS_TO_BYTES(D) ((D) << 2)
|
|
#define DWORDS_TO_WORDS(D) ((D) << 1)
|
|
#define DWORDS_TO_QWORDS(D) ((D) >> 1)
|
|
#define QWORDS_TO_BYTES(Q) ((Q) << 3)
|
|
#define QWORDS_TO_WORDS(Q) ((Q) << 2)
|
|
#define QWORDS_TO_DWORDS(Q) ((Q) << 1)
|
|
|
|
//------------------------------------------//
|
|
|
|
/* U/L suffixes on hex numbers look odd */
|
|
#define SCHAR_MAX ((signed char) 0x7F)
|
|
#define SHRT_MAX ((short) 0x7FFF)
|
|
#define INT_MAX ((int) 0x7FFFFFFF)
|
|
#define LONG_MAX ((long) 0x7FFFFFFFFFFFFFFFL)
|
|
#define UCHAR_MAX ((unsigned char) 0xFFU)
|
|
#define USHRT_MAX ((unsigned short) 0xFFFFU)
|
|
#define UINT_MAX ((unsigned int) 0xFFFFFFFFU)
|
|
#define ULONG_MAX ((unsigned long) 0xFFFFFFFFFFFFFFFFUL)
|
|
|
|
#define SCHAR_MIN ((signed char) -SCHAR_MAX - 1)
|
|
#define SHRT_MIN ((short) -SHRT_MAX - 1)
|
|
#define INT_MIN ((int) -INT_MAX - 1)
|
|
#define LONG_MIN ((long) -LONG_MAX - 1L)
|
|
|
|
#ifdef __CHAR_UNSIGNED__
|
|
# define CHAR_MIN ((char)0)
|
|
# define CHAR_MAX ((char)UCHAR_MAX)
|
|
#else
|
|
# define CHAR_MIN ((char)SCHAR_MIN)
|
|
# define CHAR_MAX ((char)SCHAR_MAX)
|
|
#endif
|
|
|
|
#define SSIZE_T_MIN LONG_MIN
|
|
#define SSIZE_T_MAX LONG_MAX
|
|
#define SIZE_T_MAX ULONG_MAX
|
|
|
|
#ifdef NEED_MORE_USELESS_DATA
|
|
# define UCHAR_MIN ((unsigned char)0)
|
|
# define USHRT_MIN ((unsigned short)0)
|
|
# define UINT_MIN ((unsigned int)0)
|
|
# define ULONG_MIN ((unsigned long)0)
|
|
# ifdef STILL_NEED_MORE_USELESS_DATA
|
|
# error "Not enough useless data!"
|
|
# endif
|
|
#endif
|
|
|
|
//------------------------------------------//
|
|
|
|
#endif
|