os-k/kaleid/include/common/kallims.h

118 lines
4.0 KiB
C

//----------------------------------------------------------------------------//
// GNU GPL OS/K //
// //
// Authors: spectral` //
// NeoX //
// //
// Desc: Kaleid type limits definitions //
//----------------------------------------------------------------------------//
#ifndef _KALLIMS_H
#define _KALLIMS_H
//------------------------------------------//
// Data sizes blocks //
//------------------------------------------//
#ifndef DATA_SIZE_BLOCK
#define DATA_SIZE_BLOCK
# define BYTE_SIZE sizeof(char)
# define WORD_SIZE sizeof(short)
# define DWORD_SIZE sizeof(int)
# define QWORD_SIZE sizeof(long)
#endif
#ifndef DATA_ALIGN_BLOCK
#define DATA_ALIGN_BLOCK
# define BYTE_ALIGN alignof(char)
# define WORD_ALIGN alignof(short)
# define DWORD_ALIGN alignof(int)
# define QWORD_ALIGN alignof(long)
#endif
#ifndef DATA_BITS_BLOCK
#define DATA_BITS_BLOCK
# define BYTE_BIT 8
# define CHAR_BIT (BYTE_SIZE * BYTE_BIT)
# define WORD_BIT (WORD_SIZE * BYTE_BIT)
# define DWORD_BIT (DWORD_SIZE * BYTE_BIT)
# define QWORD_BIT (QWORD_SIZE * BYTE_BIT)
# define SHORT_BIT WORD_BIT
# define INT_BIT DWORD_BIT
# define LONG_BIT QWORD_BIT
#endif
#ifndef DATA_SHIFTS_BLOCK
#define DATA_SHIFTS_BLOCK
# 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)
#endif
//------------------------------------------//
// Numeric data limits //
//------------------------------------------//
#ifndef DATA_MAX_LIMITS_BLOCK
#define DATA_MAX_LIMITS_BLOCK
# define SCHAR_MAX ((signed char) 0x7F)
# define SHRT_MAX ((short) 0x7FFF)
# define INT_MAX ((int) 0x7FFFFFFF)
# define LONG_MAX ((long) 0x7FFFFFFFFFFFFFFF)
# define UCHAR_MAX ((unsigned char) 0xFF
# define USHRT_MAX ((unsigned short) 0xFFFF)
# define UINT_MAX ((unsigned int) 0xFFFFFFFF)
# define ULONG_MAX ((unsigned long) 0xFFFFFFFFFFFFFFFF)
#endif
#ifndef DATA_MIN_LIMITS_BLOCK
#define DATA_MIN_LIMITS_BLOCK
# 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)
#endif
#ifndef DATA_CHAR_LIMITS_BLOCK
#define DATA_CHAR_LIMITS_BLOCK
# 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
#endif
#ifndef DATA_SPTYPES_LIMITS_BLOCK
#define DATA_SPTYPES_LIMITS_BLOCK
# define SSIZE_T_MIN LONG_MIN
# define SSIZE_T_MAX LONG_MAX
# define SIZE_T_MAX ULONG_MAX
#endif
#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
//------------------------------------------//
// End of header //
//------------------------------------------//
#endif