/* $Id$ */
-/* Release: $Name$ */
+/* Release $Name$ */
/* Internal PDCLib configuration <_PDCLIB_config.h>
(Generic Template)
/* Integers */
/* -------------------------------------------------------------------------- */
/* Assuming 8-bit char, two's-complement architecture here. 'short' being */
-/* either 8 or 16 bit, 'int' being either 16, 32 or 64 bit, 'long' being */
-/* either 32 or 64 bit, and 'long long' being 64 bit if 'long' is not, 64 or */
-/* 128 bit otherwise. */
+/* 16 bit, 'int' being either 16, 32 or 64 bit, 'long' being either 32 or 64 */
+/* bit (but 64 bit only if 'int' is 32 bit), and 'long long' being 64 bit if */
+/* 'long' is not, 64 or 128 bit otherwise. */
/* Author is quite willing to support other systems but would like to hear of */
/* interest in such support and details on the to-be-supported architecture */
-/* first before going to lengths about it. */
+/* first, before going to lengths about it. */
/* -------------------------------------------------------------------------- */
/* Comment out (or delete) the line below if your 'char' type is unsigned. */
-#define _PDCLIB_CHAR_SIGNED _PDCLIB_CHAR_SIGNED
+#define _PDCLIB_CHAR_SIGNED 1
/* Width of the integer types short, int, long, and long long, in bytes. */
+/* SHRT == 2, INT >= SHRT, LONG >= INT >= 4, LLONG >= LONG - check your */
+/* compiler manuals. */
#define _PDCLIB_SHRT_BYTES 2
#define _PDCLIB_INT_BYTES 4
#define _PDCLIB_LONG_BYTES 4
/* -------------------------------------------------------------------------- */
/* What follows are a couple of "special" typedefs and their limits. Again, */
/* the actual definition of the limits is done in <_PDCLIB_int.h>, and the */
-/* defines here are merely "configuration". */
-/* Type is defined directly, limits are defined the same way as the "fastest" */
-/* limits above (SHRT, USHRT, INT, UINT, LONG, ULONG, LLONG, or ULLONG). */
+/* defines here are merely "configuration". See above for details. */
/* -------------------------------------------------------------------------- */
/* The result type of substracting two pointers */
-typedef int _PDCLIB_ptrdiff_t;
+#define _PDCLIB_ptrdiff int
#define _PDCLIB_PTRDIFF INT
/* An integer type that can be accessed as atomic entity (think asynchronous
#define _PDCLIB_SIG_ATOMIC INT
/* Result type of the 'sizeof' operator */
-typedef unsigned int _PDCLIB_size_t;
+#define _PDCLIB_size unsigned int
#define _PDCLIB_SIZE UINT
/* Large enough an integer to hold all character codes of the largest supported
locale.
*/
-#define _PDCLIB_WCHAR USHRT
-typedef unsigned short _PDCLIB_wchar_t;
+#define _PDCLIB_wchar unsigned short
+#define _PDCLIB_WCHAR USHRT
+
+#define _PDCLIB_intptr int
+#define _PDCLIB_INTPTR INT
+
+#define _PDCLIB_intmax long long int
+#define _PDCLIB_INTMAX LLINT
/* -------------------------------------------------------------------------- */
/* Floating Point */
/* $Id$ */
-/* Release: $Name$ */
+/* Release $Name$ */
-/* Internal PDCLib logic <_PDCLIB_internal.h>
+/* PDCLib internal integer logic <_PDCLIB_int.h>
This file is part of the Public Domain C Library (PDCLib).
Permission is granted to use, modify, and / or redistribute at will.
#include <_PDCLIB_config.h>
#endif
+#ifndef _PDCLIB_AUX_H
+#define _PDCLIB_AUX_H _PDCLIB_AUX_H
+#include <_PDCLIB_aux.h>
+#endif
+
/* null pointer constant */
#define _PDCLIB_NULL 0
-/* -------------------------------------------------------------------------- */
-/* Helper macros: */
-/* _PDCLIB_cc( x, y ) concatenates two preprocessor tokens without extending */
-/* _PDCLIB_concat( x, y ) concatenates two preprocessor tokens with extending */
-/* -------------------------------------------------------------------------- */
-
-#define _PDCLIB_cc( x, y ) x ## y
-#define _PDCLIB_concat( x, y ) _PDCLIB_cc( x, y )
-
/* -------------------------------------------------------------------------- */
/* Limits of native datatypes */
/* -------------------------------------------------------------------------- */
#endif
/* Setting 'short' limits */
-#if _PDCLIB_SHRT_BYTES == 1
-#define _PDCLIB_SHRT_MAX 0x7f
-#define _PDCLIB_SHRT_MIN (-0x7f - 1)
-#define _PDCLIB_USHRT_MAX 0xff
-#elif _PDCLIB_SHRT_BYTES == 2
-#define _PDCLIB_SHRT_MAX 0x7fff
-#define _PDCLIB_SHRT_MIN (-0x7fff - 1)
-#define _PDCLIB_USHRT_MAX 0xffff
+#if _PDCLIB_SHRT_BYTES == 2
+#define _PDCLIB_SHRT_MAX 0x7fff
+#define _PDCLIB_SHRT_MIN (-0x7fff - 1)
+#define _PDCLIB_USHRT_MAX 0xffff
#else
-#error Unsupported width of 'short' (neither 8 nor 16 bit).
+#error Unsupported width of 'short' (not 16 bit).
#endif
#define _PDCLIB_USHRT_MIN 0
+#if _PDCLIB_INT_BYTES < _PDCLIB_SHRT_BYTES
+#error Bogus setting: short > int? Check _PDCLIB_config.h.
+#endif
+
/* Setting 'int' limits */
#if _PDCLIB_INT_BYTES == 2
#define _PDCLIB_INT_MAX 0x7fff
#define _PDCLIB_ULLONG_MIN 0
/* -------------------------------------------------------------------------- */
-/* <stdint.h> exact-width types, their limits and literals */
+/* <stdint.h> exact-width types and their limits */
/* -------------------------------------------------------------------------- */
/* Setting 'int8_t', its limits, and its literal. */
-#if _PDCLIB_SHRT_BYTES == 1
-typedef signed short _PDCLIB_int8_t;
-typedef unsigned short _PDCLIB_uint8_t;
-#define _PDCLIB_INT8_MAX _PDCLIB_SHRT_MAX
-#define _PDCLIB_INT8_MIN _PDCLIB_SHRT_MIN
-#define _PDCLIB_UINT8_MAX _PDCLIB_USHRT_MAX
-#else
+#if _PDCLIB_CHAR_BIT == 8
typedef signed char _PDCLIB_int8_t;
typedef unsigned char _PDCLIB_uint8_t;
#define _PDCLIB_INT8_MAX _PDCLIB_CHAR_MAX
#define _PDCLIB_INT8_MIN _PDCLIB_CHAR_MIN
#define _PDCLIB_UINT8_MAX _PDCLIB_UCHAR_MAX
+#else
+#error Unsupported width of char (not 8 bits).
#endif
/* Setting 'int16_t', its limits, and its literal */
#define _PDCLIB_UINT_FAST64_MAX concat( concat( _PDCLIB_U, _PDCLIB_FAST64 ), _MAX )
/* -------------------------------------------------------------------------- */
-/* Various <stddef.h> limits */
+/* Various <stddef.h> typedefs and limits */
/* -------------------------------------------------------------------------- */
+typedef _PDCLIB_ptrdiff _PDCLIB_ptrdiff_t
#define _PDCLIB_PTRDIFF_MIN concat( concat( _PDCLIB_, _PDCLIB_PTRDIFF ), _MIN )
#define _PDCLIB_PTRDIFF_MAX concat( concat( _PDCLIB_, _PDCLIB_PTRDIFF ), _MAX )
#define _PDCLIB_SIG_ATOMIC_MIN concat( concat( _PDCLIB_, _PDCLIB_SIG_ATOMIC ), _MIN )
#define _PDCLIB_SIG_ATOMIC_MAX concat( concat( _PDCLIB_, _PDCLIB_SIG_ATOMIC ), _MAX )
+typedef _PDCLIB_size _PDCLIB_size_t
#define _PDCLIB_SIZE_MAX concat( concat( _PDCLIB_, _PDCLIB_SIZE ), _MAX )
+typedef _PDCLIB_wchar _PDCLIB_wchar_t
#define _PDCLIB_WCHAR_MIN concat( concat( _PDCLIB_, _PDCLIB_WCHAR ), _MIN )
#define _PDCLIB_WCHAR_MAX concat( concat( _PDCLIB_, _PDCLIB_WCHAR ), _MAX )
-/* -------------------------------------------------------------------------- */
-/* <stdint.h> "exact width" literal suffixes */
-/* -------------------------------------------------------------------------- */
-
-#define _PDCLIB_INT8_LITERAL c
-#define _PDCLIB_INT16_LITERAL s
-#define _PDCLIB_INT32_LITERAL l
-#define _PDCLIB_INT64_LITERAL ll
-#define _PDCLIB_UINT8_LITERAL uc
-#define _PDCLIB_UINT16_LITERAL us
-#define _PDCLIB_UINT32_LITERAL ul
-#define _PDCLIB_UINT64_LITERAL ull
+typedef _PDCLIB_intptr _PDCLIB_intptr_t;
+typedef unsigned _PDCLIB_intptr _PDCLIB_uintptr_t;
+#define _PDCLIB_INTPTR_MIN concat( concat( _PDCLIB_, _PDCLIB_INTPTR ), _MIN )
+#define _PDCLIB_INTPTR_MAX concat( concat( _PDCLIB_, _PDCLIB_INTPTR ), _MAX )
+#define _PDCLIB_UINTPTR_MAX concat( concat( _PDCLIB_U, _PDCLIB_INTPTR ), _MAX )
-/* -------------------------------------------------------------------------- */
-/* <stdint.h> intptr and intmax typedefs and limits */
-/* -------------------------------------------------------------------------- */
+typedef _PDCLIB_intmax _PDCLIB_intmax_t;
+typedef unsigned _PDCLIB_intmax _PDCLIB_uintmax_t;
+#define _PDCLIB_INTMAX_MIN concat( concat( _PDCLIB_, _PDCLIB_INTMAX ), _MIN )
+#define _PDCLIB_INTMAX_MAX concat( concat( _PDCLIB_, _PDCLIB_INTMAX ), _MAX )
+#define _PDCLIB_UINTMAX_MAX concat( concat( _PDCLIB_U, _PDCLIB_INTMAX ), _MAX )
-typedef int _PDCLIB_intptr_t;
-#define _PDCLIB_INTPTR_MIN (-0x7fffff - 1)
-#define _PDCLIB_INTPTR_MAX 0x7fffff
-typedef unsigned int _PDCLIB_uintptr_t;
-#define _PDCLIB_UINTPTR_MAX 0xffffff
-
-typedef signed long long int _PDCLIB_intmax_t;
-#define _PDCLIB_INTMAX_MIN (-0x7fffffffffffffff - 1)
-#define _PDCLIB_INTMAX_MAX 0x7fffffffffffffff
-typedef unsigned long long int _PDCLIB_uintmax_t;
-#define _PDCLIB_UINTMAX_MAX 0xffffffffffffffff
+/* TODO: INTN_C / UINTN_C */
/* $Id$ */
-/* Release: $Name$ */
+/* Release $Name$ */
/* 7.18 Integer types <stdint.h>
/* Expand to an integer constant of specified value and type int_leastN_t */
-#define INT8_C( value ) _PDCLIB_concat( value, _PDCLIB_INT8_LITERAL )
-#define INT16_C( value ) _PDCLIB_concat( value, _PDCLIB_INT16_LITERAL )
-#define INT32_C( value ) _PDCLIB_concat( value, _PDCLIB_INT32_LITERAL )
-#define INT64_C( value ) _PDCLIB_concat( value, _PDCLIB_INT64_LITERAL )
+/* NOT YET IMPLEMENTED
+#define INT8_C( value )
+#define INT16_C( value )
+#define INT32_C( value )
+#define INT64_C( value )
+*/
/* Expand to an integer constant of specified value and type uint_leastN_t */
-#define UINT8_C( value ) _PDCLIB_concat( value, _PDCLIB_UINT8_LITERAL )
-#define UINT16_C( value ) _PDCLIB_concat( value, _PDCLIB_UINT16_LITERAL )
-#define UINT32_C( value ) _PDCLIB_concat( value, _PDCLIB_UINT32_LITERAL )
-#define UINT64_C( value ) _PDCLIB_concat( value, _PDCLIB_UINT64_LITERAL )
+/* NOT YET IMPLEMENTED
+#define UINT8_C( value )
+#define UINT16_C( value )
+#define UINT32_C( value )
+#define UINT64_C( value )
+*/
/* 7.18.4.2 Macros for greatest-width integer constants */
/* Expand to an integer constant of specified value and type intmax_t */
-#define INTMAX_C( value ) _PDCLIB_concat( value, _PDCLIB_INTMAX_LITERAL )
+/* NOT YET IMPLEMENTED
+#define INTMAX_C( value )
+*/
/* Expand to an integer constant of specified value and type uintmax_t */
-#define UINTMAX_C( value ) _PDCLIB_concat( value, _PDCLIB_UINTMAX_LITERAL )
+/* NOT YET IMPLEMENTED
+#define UINTMAX_C( value )
+*/
#endif