]> pd.if.org Git - pdclib/commitdiff
Second try. Freestanding only, for now.
authorsolar <unknown>
Sun, 14 Nov 2004 13:10:52 +0000 (13:10 +0000)
committersolar <unknown>
Sun, 14 Nov 2004 13:10:52 +0000 (13:10 +0000)
_PDCLIB_config.h [new file with mode: 0644]
_PDCLIB_int.h [new file with mode: 0644]
float.h [new file with mode: 0644]
iso646.h [new file with mode: 0644]
limits.h [new file with mode: 0644]
stdarg.h [new file with mode: 0644]
stdbool.h [new file with mode: 0644]
stddef.h [new file with mode: 0644]
stdint.h [new file with mode: 0644]

diff --git a/_PDCLIB_config.h b/_PDCLIB_config.h
new file mode 100644 (file)
index 0000000..9585505
--- /dev/null
@@ -0,0 +1,147 @@
+/* $Id$ */
+
+/* Internal PDCLib configuration <_PDCLIB_config.h>
+   (Generic Template)
+
+   This file is part of the Public Domain C Library (PDCLib).
+   Permission is granted to use, modify, and / or redistribute at will.
+*/
+
+/* -------------------------------------------------------------------------- */
+/* 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.                                                         */
+/* 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.                                    */
+/* -------------------------------------------------------------------------- */
+
+/* Comment out (or delete) the line below if your 'char' type is unsigned.    */
+#define _PDCLIB_CHAR_SIGNED _PDCLIB_CHAR_SIGNED
+
+/* Width of the integer types short, int, long, and long long, in bytes.      */
+#define _PDCLIB_SHRT_BYTES  2
+#define _PDCLIB_INT_BYTES   4
+#define _PDCLIB_LONG_BYTES  4
+#define _PDCLIB_LLONG_BYTES 8
+
+/* -------------------------------------------------------------------------- */
+/* <stdint.h> defines a set of integer types that are of a minimum width, and */
+/* "usually fastest" on the system. (If, for example, accessing a single char */
+/* requires the CPU to access a complete int and then mask out the char, the  */
+/* "usually fastest" type of at least 8 bits would be int, not char.)         */
+/* If you do not have information on the relative performance of the types,   */
+/* the standard allows you to define any type that meets minimum width and    */
+/* signedness requirements.                                                   */
+/* The defines below are just configuration for the real typedefs and limit   */
+/* definitions done in <_PDCLIB_int.h>. The uppercase define shall be either  */
+/* SHRT, INT, LONG, or LLONG (telling which values to use for the *_MIN and   */
+/* *_MAX limits); the lowercase define either short, int, long, or long long  */
+/* (telling the actual type to use).                                          */
+/* If you require a non-standard datatype to define the "usually fastest"     */
+/* types, PDCLib as-is doesn't support that. Please contact the author with   */
+/* details on your platform in that case, so support can be added.            */
+/* -------------------------------------------------------------------------- */
+
+#define _PDCLIB_FAST8 INT
+#define _PDCLIB_fast8 int
+
+#define _PDCLIB_FAST16 INT
+#define _PDCLIB_fast16 int
+
+#define _PDCLIB_FAST32 INT
+#define _PDCLIB_fast32 int
+
+#define _PDCLIB_FAST64 LLONG
+#define _PDCLIB_fast64 long long
+
+/* -------------------------------------------------------------------------- */
+/* 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).      */
+/* -------------------------------------------------------------------------- */
+
+/* The result type of substracting two pointers */
+typedef int             _PDCLIB_ptrdiff_t;
+#define _PDCLIB_PTRDIFF INT
+
+/* An integer type that can be accessed as atomic entity (think asynchronous
+   interrupts). The type itself is not defined in a freestanding environment,
+   but its limits are. (Don't ask.)
+*/
+#define _PDCLIB_SIG_ATOMIC INT
+
+/* Result type of the 'sizeof' operator */
+#define _PDCLIB_SIZE UINT
+typedef unsigned int _PDCLIB_size_t;
+
+/* Large enough an integer to hold all character codes of the largest supported
+   locale.
+*/
+#define _PDCLIB_WCHAR  USHRT
+typedef unsigned short _PDCLIB_wchar_t;
+
+/* -------------------------------------------------------------------------- */
+/* Floating Point                                                             */
+/* -------------------------------------------------------------------------- */
+
+/* Whether the implementation rounds toward zero (0), to nearest (1), toward
+   positive infinity (2), or toward negative infinity (3). (-1) signifies
+   indeterminable rounding, any other value implementation-specific rounding.
+*/
+#define _PDCLIB_FLT_ROUNDS -1
+
+/* Whether the implementation uses exact-width precision (0), promotes float
+   to double (1), or promotes float and double to long double (2). (-1)
+   signifies indeterminable behaviour, any other value implementation-specific
+   behaviour.
+*/
+#define _PDCLIB_FLT_EVAL_METHOD -1
+
+/* "Number of the decimal digits (n), such that any floating-point number in the
+   widest supported floating type with p(max) radix (b) digits can be rounded to
+   a floating-point number with (n) decimal digits and back again without change
+   to the value p(max) log(10)b if (b) is a power of 10, [1 + p(max) log(10)b]
+   otherwise."
+   64bit IEC 60559 double format (53bit mantissa) is DECIMAL_DIG 17.
+   80bit IEC 60559 double-extended format (64bit mantissa) is DECIMAL_DIG 21.
+*/
+#define _PDCLIB_DECIMAL_DIG 17
+
+/* -------------------------------------------------------------------------- */
+/* Platform-dependent macros defined by the standard headers.                 */
+/* -------------------------------------------------------------------------- */
+
+/* The offsetof macro
+   Contract: Expand to an integer constant expression of type size_t, which
+   represents the offset in bytes to the structure member from the beginning
+   of the structure. If the specified member is a bitfield, behaviour is
+   undefined.
+   There is no standard-compliant way to do this.
+   This implementation casts an integer zero to 'pointer to type', and then
+   takes the address of member. This is undefined behaviour but should work on
+   most compilers.
+*/
+#define _PDCLIB_offsetof( type, member ) ( (size_t) &( ( (type *) 0 )->member ) )
+
+/* Variable Length Parameter List Handling (<stdarg.h>)
+   The macros defined by <stdarg.h> are highly dependent on the calling
+   conventions used, and you probably have to replace them with builtins of
+   your compiler. The following generic implementation works only for pure
+   stack-based architectures, and only if arguments are aligned to pointer
+   type. Credits to Michael Moody, who contributed this to the Public Domain.
+*/
+
+/* Internal helper macro. va_round is not part of <stdarg.h>. */
+#define _PDCLIB_va_round( type ) ( (sizeof(type) + sizeof(void *) - 1) & ~(sizeof(void *) - 1) )
+
+typedef char * _PDCLIB_va_list;
+#define _PDCLIB_va_arg( ap, type ) ( (ap) += (_PDCLIB_va_round(type)), ( *(type*) ( (ap) - (_PDCLIB_va_round(type)) ) ) )
+#define _PDCLIB_va_copy( dest, src ) ( (dest) = (src), (void)0 )
+#define _PDCLIB_va_end( ap ) ( (ap) = (void *)0, (void)0 )
+#define _PDCLIB_va_start( ap, parmN ) ( (ap) = (char *) &parmN + ( _PDCLIB_va_round(parmN) ), (void)0 )
diff --git a/_PDCLIB_int.h b/_PDCLIB_int.h
new file mode 100644 (file)
index 0000000..af65596
--- /dev/null
@@ -0,0 +1,254 @@
+/* $Id$ */
+
+/* Internal PDCLib logic <_PDCLIB_internal.h>
+
+   This file is part of the Public Domain C Library (PDCLib).
+   Permission is granted to use, modify, and / or redistribute at will.
+*/
+
+/* -------------------------------------------------------------------------- */
+/* You should not have to edit anything in this file; if you DO have to, it   */
+/* would be considered a bug / missing feature: notify the author.            */
+/* -------------------------------------------------------------------------- */
+
+#include <_PDCLIB_config.h>
+
+/* 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                                                 */
+/* -------------------------------------------------------------------------- */
+/* The definition of minimum limits for unsigned datatypes is done because    */
+/* later on we will "construct" limits for other abstract types:              */
+/* USHRT -> _PDCLIB_ + USHRT + _MIN -> _PDCLIB_USHRT_MIN -> 0                 */
+/* INT -> _PDCLIB_ + INT + _MIN -> _PDCLIB_INT_MIN -> ... you get the idea.   */
+/* -------------------------------------------------------------------------- */
+
+/* Setting 'char' limits                                                      */
+#define _PDCLIB_CHAR_BIT    8
+#define _PDCLIB_UCHAR_MIN   0
+#define _PDCLIB_UCHAR_MAX   0xff
+#define _PDCLIB_SCHAR_MIN   (-0x7f - 1)
+#define _PDCLIB_SCHAR_MAX   0x7f
+#ifdef  _PDCLIB_CHAR_SIGNED
+#define _PDCLIB_CHAR_MIN    _PDCLIB_SCHAR_MIN
+#define _PDCLIB_CHAR_MAX    _PDCLIB_SCHAR_MAX
+#else
+#define _PDCLIB_CHAR_MIN    0
+#define _PDCLIB_CHAR_MAX    _PDCLIB_UCHAR_MAX
+#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
+#else
+#error Unsupported width of 'short' (neither 8 nor 16 bit).
+#endif
+#define _PDCLIB_USHRT_MIN 0
+
+/* Setting 'int' limits                                                       */
+#if     _PDCLIB_INT_BYTES == 2
+#define _PDCLIB_INT_MAX   0x7fff
+#define _PDCLIB_INT_MIN   (-0x7fff - 1)
+#define _PDCLIB_UINT_MAX  0xffffU
+#elif   _PDCLIB_INT_BYTES == 4
+#define _PDCLIB_INT_MAX   0x7fffffff
+#define _PDCLIB_INT_MIN   (-0x7fffffff - 1)
+#define _PDCLIB_UINT_MAX  0xffffffffU
+#elif _PDCLIB_INT_BYTES   == 8
+#define _PDCLIB_INT_MAX   0x7fffffffffffffff
+#define _PDCLIB_INT_MIN   (-0x7fffffffffffffff - 1)
+#define _PDCLIB_UINT_MAX  0xffffffffffffffff
+#else
+#error Unsupported width of 'int' (neither 16, 32, nor 64 bit).
+#endif
+#define _PDCLIB_UINT_MIN 0
+
+/* Setting 'long' limits                                                      */
+#if   _PDCLIB_LONG_BYTES   == 4
+#define _PDCLIB_LONG_MAX   0x7fffffffL
+#define _PDCLIB_LONG_MIN   (-0x7fffffffL - 1L)
+#define _PDCLIB_LONG_MAX   0xffffffffUL
+#elif   _PDCLIB_LONG_BYTES == 8
+#define _PDCLIB_LONG_MAX   0x7fffffffffffffffL
+#define _PDCLIB_LONG_MIN   (-0x7fffffffffffffffL - 1L)
+#define _PDCLIB_ULONG_MAX  0xffffffffffffffffUL
+#else
+#error Unsupported width of 'long' (neither 32 nor 64 bit).
+#endif
+#define _PDCLIB_ULONG_MIN 0
+
+/* Setting 'long long' limits                                                 */
+#if _PDCLIB_LLONG_BYTES    == 8
+#define _PDCLIB_LLONG_MAX  0x7fffffffffffffffLL
+#define _PDCLIB_LLONG_MIN  (-0x7fffffffffffffffLL - 1LL)
+#define _PDCLIB_ULLONG_MAX 0xffffffffffffffffULL
+#elif _PDCLIB_LLONG_BYTES  == 16
+#define _PDCLIB_LLONG_MAX  0x7fffffffffffffffffffffffffffffffLL
+#define _PDCLIB_LLONG_MIN  (-0x7fffffffffffffffffffffffffffffffLL - 1LL)
+#define _PDCLIB_ULLONG_MAX 0xffffffffffffffffffffffffffffffffLL
+#else
+#error Unsupported width of 'long long' (neither 64 nor 128 bit).
+#endif
+#define _PDCLIB_ULLONG_MIN 0
+
+/* -------------------------------------------------------------------------- */
+/* <stdint.h> exact-width types, their limits and literals                    */
+/* -------------------------------------------------------------------------- */
+
+/* Setting 'int8_t', its limits, and its literal.                             */
+#if     _PDCLIB_SHRT_BYTES == 1
+typedef signed short       _PDCLIB_int8_t;
+typedef unsigned short     _PDCLIB_int8_t;
+#define _PDCLIB_INT8_MAX   _PDCLIB_SHRT_MAX
+#define _PDCLIB_INT8_MIN   _PDCLIB_SHRT_MIN
+#define _PDCLIB_UINT8_MAX  _PDCLIB_USHRT_MAX
+#else
+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
+#endif
+
+/* Setting 'int16_t', its limits, and its literal                             */
+#if     _PDCLIB_INT_BYTES  == 2
+typedef signed int         _PDCLIB_int16_t;
+typedef unsigned int       _PDCLIB_uint16_t;
+#define _PDCLIB_INT16_MAX  _PDCLIB_INT_MAX
+#define _PDCLIB_INT16_MIN  _PDCLIB_INT_MIN
+#define _PDCLIB_UINT16_MAX _PDCLIB_UINT_MAX
+#elif   _PDCLIB_SHRT_BYTES == 2
+typedef signed short       _PDCLIB_int16_t;
+typedef unsigned short     _PDCLIB_int16_t;
+#define _PDCLIB_INT16_MAX  _PDCLIB_SHRT_MAX
+#define _PDCLIB_INT16_MIN  _PDCLIB_SHRT_MIN
+#define _PDCLIB_UINT16_MAX _PDCLIB_USHRT_MAX
+#else
+#error Neither 'short' nor 'int' are 16-bit.
+#endif
+
+/* Setting 'int32_t', its limits, and its literal                             */
+#if     _PDCLIB_INT_BYTES  == 4
+typedef signed int         _PDCLIB_int32_t;
+typedef unsigned int       _PDCLIB_int32_t;
+#define _PDCLIB_INT32_MAX  _PDCLIB_INT_MAX
+#define _PDCLIB_INT32_MIN  _PDCLIB_INT_MIN
+#define _PDCLIB_UINT32_MAX _PDCLIB_UINT_MAX
+#elif   _PDCLIB_LONG_BYTES == 4
+typedef signed long        _PDCLIB_int32_t;
+typedef unsigned long      _PDCLIB_int32_t;
+#define _PDCLIB_INT32_MAX  _PDCLIB_LONG_MAX
+#define _PDCLIB_INT32_MIN  _PDCLIB_LONG_MIN
+#define _PDCLIB_UINT32_MAX _PDCLIB_LONG_MAX
+#else
+#error Neither 'int' nor 'long' are 32-bit.
+#endif
+
+#if     _PDCLIB_LONG_BYTES == 8
+typedef signed long        _PDCLIB_int64_t;
+typedef unsigned long      _PDCLIB_int64_t;
+#define _PDCLIB_INT64_MAX  _PDCLIB_LONG_MAX
+#define _PDCLIB_INT64_MIN  _PDCLIB_LONG_MIN
+#define _PDCLIB_INT64_MAX  _PDCLIB_ULONG_MAX
+#elif _PDCLIB_LLONG_BYTES  == 8
+typedef signed long long   _PDCLIB_int64_t;
+typedef unsigned long long _PDCLIB_int64_t;
+#define _PDCLIB_INT64_MAX  _PDCLIB_LLONG_MAX
+#define _PDCLIB_INT64_MIN  _PDCLIB_LLONG_MIN
+#define _PDCLIB_INT64_MAX  _PDCLIB_ULLONG_MAX
+#else
+#error Neither 'long' nor 'long long' are 64-bit.
+#endif
+
+/* -------------------------------------------------------------------------- */
+/* <stdint.h> "fastest" types and their limits                                */
+/* -------------------------------------------------------------------------- */
+/* This is, admittedly, butt-ugly. But at least it's ugly where the average   */
+/* user of PDCLib will never see it, and makes <_PDCLIB_config.h> much        */
+/* cleaner.                                                                   */
+/* -------------------------------------------------------------------------- */
+
+typedef _PDCLIB_fast8          _PDCLIB_int_fast8_t;
+typedef unsigned _PDCLIB_fast8 _PDCLIB_uint_fast8_t;
+#define _PDCLIB_INT_FAST8_MIN  concat( concat( _PDCLIB_, _PDCLIB_FAST8 ), _MIN )
+#define _PDCLIB_INT_FAST8_MAX  concat( concat( _PDCLIB_, _PDCLIB_FAST8 ), _MAX )
+#define _PDCLIB_UINT_FAST8_MAX concat( concat( _PDCLIB_U, _PDCLIB_FAST8 ), _MAX )
+
+typedef _PDCLIB_fast16          _PDCLIB_int_fast16_t;
+typedef unsigned _PDCLIB_fast16 _PDCLIB_uint_fast16_t;
+#define _PDCLIB_INT_FAST16_MIN  concat( concat( _PDCLIB_, _PDCLIB_FAST16 ), _MIN )
+#define _PDCLIB_INT_FAST16_MAX  concat( concat( _PDCLIB_, _PDCLIB_FAST16 ), _MAX )
+#define _PDCLIB_UINT_FAST16_MAX concat( concat( _PDCLIB_U, _PDCLIB_FAST16 ), _MAX )
+
+typedef _PDCLIB_fast32          _PDCLIB_int_fast32_t;
+typedef unsigned _PDCLIB_fast32 _PDCLIB_uint_fast32_t;
+#define _PDCLIB_INT_FAST32_MIN  concat( concat( _PDCLIB_, _PDCLIB_FAST32 ), _MIN )
+#define _PDCLIB_INT_FAST32_MAX  concat( concat( _PDCLIB_, _PDCLIB_FAST32 ), _MAX )
+#define _PDCLIB_UINT_FAST32_MAX concat( concat( _PDCLIB_U, _PDCLIB_FAST32 ), _MAX )
+
+typedef _PDCLIB_fast64          _PDCLIB_int_fast64_t;
+typedef unsigned _PDCLIB_fast64 _PDCLIB_uint_fast64_t;
+#define _PDCLIB_INT_FAST64_MIN  concat( concat( _PDCLIB_, _PDCLIB_FAST64 ), _MIN )
+#define _PDCLIB_INT_FAST64_MAX  concat( concat( _PDCLIB_, _PDCLIB_FAST64 ), _MAX )
+#define _PDCLIB_UINT_FAST64_MAX concat( concat( _PDCLIB_U, _PDCLIB_FAST64 ), _MAX )
+
+/* -------------------------------------------------------------------------- */
+/* Various <stddef.h> limits                                                  */
+/* -------------------------------------------------------------------------- */
+
+#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 )
+
+#define _PDCLIB_SIZE_MAX concat( concat( _PDCLIB_, _PDCLIB_SIZE ), _MAX )
+
+#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
+
+/* -------------------------------------------------------------------------- */
+/* <stdint.h> "fast" typedefs                                                 */
+/* -------------------------------------------------------------------------- */
+
+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
diff --git a/float.h b/float.h
new file mode 100644 (file)
index 0000000..7382c3f
--- /dev/null
+++ b/float.h
@@ -0,0 +1,85 @@
+#ifndef _PDCLIB_FLOAT_H
+#define _PDCLIB_FLOAT_H _PDCLIB_FLOAT_H
+
+/* $Id$ */
+
+/* 7.7 Characteristics of floating types <float.h>
+
+   This file is part of the Public Domain C Library (PDCLib).
+   Permission is granted to use, modify, and / or redistribute at will.
+*/
+
+#ifndef _PDCLIB_DEFS_H
+#define _PDCLIB_DEFS_H _PDCLIB_DEFS_H
+#include <_PDCLIB_defs.h>
+#endif
+
+#define FLT_ROUNDS _PDCLIB_FLT_ROUNDS
+#define FLT_EVAL_METHOD _PDCLIB_FLT_EVAL_METHOD
+#define DECIMAL_DIG _PDCLIB_DECIMAL_DIG
+
+/* Produced by enquire version 5.1a, CWI, Amsterdam
+   http://www.cwi.nl/~steven/enquire.html  */
+
+   /* Radix of exponent representation */
+#define FLT_RADIX 2
+   /* Number of base-FLT_RADIX digits in the significand of a float */
+#define FLT_MANT_DIG 24
+   /* Number of decimal digits of precision in a float */
+#define FLT_DIG 6
+   /* Addition rounds to 0: zero, 1: nearest, 2: +inf, 3: -inf, -1: unknown */
+#define FLT_ROUNDS 1
+   /* Difference between 1.0 and the minimum float greater than 1.0 */
+#define FLT_EPSILON 1.19209290e-07F
+   /* Minimum int x such that FLT_RADIX**(x-1) is a normalised float */
+#define FLT_MIN_EXP (-125)
+   /* Minimum normalised float */
+#define FLT_MIN 1.17549435e-38F
+   /* Minimum int x such that 10**x is a normalised float */
+#define FLT_MIN_10_EXP (-37)
+   /* Maximum int x such that FLT_RADIX**(x-1) is a representable float */
+#define FLT_MAX_EXP 128
+   /* Maximum float */
+#define FLT_MAX 3.40282347e+38F
+   /* Maximum int x such that 10**x is a representable float */
+#define FLT_MAX_10_EXP 38
+
+   /* Number of base-FLT_RADIX digits in the significand of a double */
+#define DBL_MANT_DIG 53
+   /* Number of decimal digits of precision in a double */
+#define DBL_DIG 15
+   /* Difference between 1.0 and the minimum double greater than 1.0 */
+#define DBL_EPSILON 2.2204460492503131e-16
+   /* Minimum int x such that FLT_RADIX**(x-1) is a normalised double */
+#define DBL_MIN_EXP (-1021)
+   /* Minimum normalised double */
+#define DBL_MIN 2.2250738585072014e-308
+   /* Minimum int x such that 10**x is a normalised double */
+#define DBL_MIN_10_EXP (-307)
+   /* Maximum int x such that FLT_RADIX**(x-1) is a representable double */
+#define DBL_MAX_EXP 1024
+   /* Maximum double */
+#define DBL_MAX 1.7976931348623157e+308
+   /* Maximum int x such that 10**x is a representable double */
+#define DBL_MAX_10_EXP 308
+
+   /* Number of base-FLT_RADIX digits in the significand of a long double */
+#define LDBL_MANT_DIG 113
+   /* Number of decimal digits of precision in a long double */
+#define LDBL_DIG 33
+   /* Difference between 1.0 and the minimum long double greater than 1.0 */
+#define LDBL_EPSILON 1.92592994438723585305597794258492732e-34L
+   /* Minimum int x such that FLT_RADIX**(x-1) is a normalised long double */
+#define LDBL_MIN_EXP (-16381)
+   /* Minimum normalised long double */
+#define LDBL_MIN 3.36210314311209350626267781732175260e-4932L
+   /* Minimum int x such that 10**x is a normalised long double */
+#define LDBL_MIN_10_EXP (-4931)
+   /* Maximum int x such that FLT_RADIX**(x-1) is a representable long double */
+#define LDBL_MAX_EXP 16384
+   /* Maximum long double */
+#define LDBL_MAX 1.18973149535723176508575932662800702e+4932L
+   /* Maximum int x such that 10**x is a representable long double */
+#define LDBL_MAX_10_EXP 4932
+
+#endif
diff --git a/iso646.h b/iso646.h
new file mode 100644 (file)
index 0000000..33ff897
--- /dev/null
+++ b/iso646.h
@@ -0,0 +1,24 @@
+#ifndef _PDCLIB_ISO646_H
+#define _PDCLIB_ISO646_H _PDCLIB_ISO646_H
+
+/* $Id$ */
+
+/* 7.9 Alternative spellings <iso646.h> */
+
+   This file is part of the Public Domain C Library (PDCLib).
+   Permission is granted to use, modify, and / or redistribute at will.
+*/
+
+#define and &&
+#define and_eq &=
+#define bitand &
+#define bitor |
+#define compl \98
+#define not !
+#define not_eq !=
+#define or ||
+#define or_eq |=
+#define xor \88
+#define xor_eq \88=
+
+#endif
diff --git a/limits.h b/limits.h
new file mode 100644 (file)
index 0000000..65cdae7
--- /dev/null
+++ b/limits.h
@@ -0,0 +1,53 @@
+#ifndef _PDCLIB_LIMITS_H
+#define _PDCLIB_LIMITS_H _PDCLIB_LIMITS_H
+
+/* $Id$ */
+
+/* 7.10 Sizes of integer types <limits.h>
+
+   This file is part of the Public Domain C Library (PDCLib).
+   Permission is granted to use, modify, and / or redistribute at will.
+*/
+
+/* Defined to 1 as multibyte characters are not supported yet. */
+#define MB_LEN_MAX 1
+
+#define LLONG_MIN  (-0x7fffffffffffffff - 1)
+#define LLONG_MAX  0x7fffffffffffffff
+#define ULLONG_MAX 0xffffffffffffffff
+
+/* Produced by enquire version 5.1a, CWI, Amsterdam
+   http://www.cwi.nl/~steven/enquire.html  */
+
+   /* Number of bits in a storage unit */
+#define CHAR_BIT 8
+   /* Maximum char */
+#define CHAR_MAX 127
+   /* Minimum char */
+#define CHAR_MIN (-128)
+   /* Maximum signed char */
+#define SCHAR_MAX 127
+   /* Minimum signed char */
+#define SCHAR_MIN (-128)
+   /* Maximum unsigned char (minimum is always 0) */
+#define UCHAR_MAX 255
+   /* Maximum short */
+#define SHRT_MAX 32767
+   /* Minimum short */
+#define SHRT_MIN (-32768)
+   /* Maximum int */
+#define INT_MAX 2147483647
+   /* Minimum int */
+#define INT_MIN (-2147483647-1)
+   /* Maximum long */
+#define LONG_MAX 2147483647L
+   /* Minimum long */
+#define LONG_MIN (-2147483647L-1L)
+   /* Maximum unsigned short (minimum is always 0) */
+#define USHRT_MAX 65535
+   /* Maximum unsigned int (minimum is always 0) */
+#define UINT_MAX 4294967295U
+   /* Maximum unsigned long (minimum is always 0) */
+#define ULONG_MAX 4294967295UL
+
+#endif
diff --git a/stdarg.h b/stdarg.h
new file mode 100644 (file)
index 0000000..44ad5ac
--- /dev/null
+++ b/stdarg.h
@@ -0,0 +1,24 @@
+#ifndef _PDCLIB_STDARG_H
+#define _PDCLIB_STDARG_H _PDCLIB_STDARG_H
+
+/* $Id$ */
+
+/* 7.15 Variable arguments <stdarg.h> 
+
+   This file is part of the Public Domain C Library (PDCLib).
+   Permission is granted to use, modify, and / or redistribute at will.
+*/
+
+#ifndef _PDCLIB_DEFS_H
+#define _PDCLIB_DEFS_H _PDCLIB_DEFS_H
+#include <_PDCLIB_defs.h>
+#endif
+
+typedef _PDCLIB_va_list va_list;
+
+#define va_arg( ap, type )    _PDCLIB_va_arg( ap, type )
+#define va_copy( dest, src )  _PDCLIB_va_copy( dest, src )
+#define va_end( ap )          _PDCLIB_va_end( ap )
+#define va_start( ap, parmN ) _PDCLIB_va_start( ap, parmN )
+
+#endif
diff --git a/stdbool.h b/stdbool.h
new file mode 100644 (file)
index 0000000..dc93679
--- /dev/null
+++ b/stdbool.h
@@ -0,0 +1,17 @@
+#ifndef _PDCLIB_STDBOOL_H
+#define _PDCLIB_STDBOOL_H _PDCLIB_STDBOOL_H
+
+/* $Id$ */
+
+/* 7.16 Boolean type and values <stdbool.h>
+
+   This file is part of the Public Domain C Library (PDCLib).
+   Permission is granted to use, modify, and / or redistribute at will.
+*/
+
+#define bool _Bool
+#define true 1
+#define false 0
+#define __bool_true_false_are_defined 1
+
+#endif
diff --git a/stddef.h b/stddef.h
new file mode 100644 (file)
index 0000000..babb365
--- /dev/null
+++ b/stddef.h
@@ -0,0 +1,25 @@
+#ifndef _PDCLIB_STDDEF_H
+#define _PDCLIB_STDDEF_H _PDCLIB_STDDEF_H
+
+/* $Id$ */
+
+/* 7.17 Common definitions <stddef.h>
+
+   This file is part of the Public Domain C Library (PDCLib).
+   Permission is granted to use, modify, and / or redistribute at will.
+*/
+
+#ifndef _PDCLIB_DEFS_H
+#define _PDCLIB_DEFS_H _PDCLIB_DEFS_H
+#include <_PDCLIB_defs.h>
+#endif
+
+typedef _PDCLIB_ptrdiff_t ptrdiff_t;
+typedef _PDCLIB_size_t    size_t;
+typedef _PDCLIB_wchar_t   wchar_t;
+
+#define NULL _PDCLIB_NULL
+
+#define offsetof( type, member ) _PDCLIB_offsetof( type, member )
+
+#endif
diff --git a/stdint.h b/stdint.h
new file mode 100644 (file)
index 0000000..d126bcf
--- /dev/null
+++ b/stdint.h
@@ -0,0 +1,195 @@
+#ifndef _PDCLIB_STDINT_H
+#define _PDCLIB_STDINT_H _PDCLIB_STDINT_H
+
+/* $Id$ */
+
+/* 7.18 Integer types <stdint.h>
+
+   This file is part of the Public Domain C Library (PDCLib).
+   Permission is granted to use, modify, and / or redistribute at will.
+*/
+
+#ifndef _PDCLIB_DEFS_H
+#define _PDCLIB_DEFS_H _PDCLIB_DEFS_H
+#include <_PDCLIB_defs.h>
+#endif
+
+/* 7.18.1.1 Exact-width integer types. */
+
+typedef _PDCLIB_int8_t  int8_t;
+typedef _PDCLIB_int16_t int16_t;
+typedef _PDCLIB_int32_t int32_t;
+typedef _PDCLIB_int64_t int64_t;
+
+typedef _PDCLIB_uint8_t  uint8_t;
+typedef _PDCLIB_uint16_t uint16_t;
+typedef _PDCLIB_uint32_t uint32_t;
+typedef _PDCLIB_uint64_t uint64_t;
+
+/* 7.18.1.2 Minimum-width integer types */
+
+typedef int8_t  int_least8_t;
+typedef int16_t int_least16_t;
+typedef int32_t int_least32_t;
+typedef int64_t int_least64_t;
+
+typedef uint8_t  uint_least8_t;
+typedef uint16_t uint_least16_t;
+typedef uint32_t uint_least32_t;
+typedef uint64_t uint_least64_t;
+
+/* 7.18.1.3 Fastest minimum-width integer types */
+
+/* You are allowed to add more types here, e.g. int_fast24_t. */
+
+typedef _PDCLIB_int_fast8_t  int_fast8_t;
+typedef _PDCLIB_int_fast16_t int_fast16_t;
+typedef _PDCLIB_int_fast32_t int_fast32_t;
+typedef _PDCLIB_int_fast64_t int_fast64_t;
+
+typedef _PDCLIB_uint_fast8_t  uint_fast8_t;
+typedef _PDCLIB_uint_fast16_t uint_fast16_t;
+typedef _PDCLIB_uint_fast32_t uint_fast32_t;
+typedef _PDCLIB_uint_fast64_t uint_fast64_t;
+
+/* 7.18.1.4 Integer types capable of holding object pointers */
+
+typedef _PDCLIB_intptr_t  intptr_t;
+typedef _PDCLIB_uintptr_t uintptr_t;
+
+/* 7.18.1.5 Greatest-width integer types */
+
+typedef _PDCLIB_intmax_t  intmax_t;
+typedef _PDCLIB_uintmax_t uintmax_t;
+
+/* 7.18.2 Limits of specified-width integer types */
+
+#ifdef __cplusplus
+#ifndef __STDC_LIMIT_MACROS
+#define _PDCLIB_NO_LIMIT_MACROS
+#endif
+#endif
+
+#ifndef _PDCLIB_NO_LIMIT_MACROS
+
+/* 7.18.2.1 Limits of exact-width integer types */
+
+#define INT8_MIN (-0x7f - 1)
+#define INT8_MAX   0x7f
+#define UINT8_MAX  0xff
+
+#define INT16_MIN (-0x7fff - 1)
+#define INT16_MAX   0x7fff
+#define UINT16_MAX  0xffff
+
+#define INT32_MIN (-0x7fffffff - 1)
+#define INT32_MAX   0x7fffffff
+#define UINT32_MAX  0xffffffff
+
+#define INT64_MIN (-0x7fffffffffffffff - 1)
+#define INT64_MAX   0x7fffffffffffffff
+#define UINT64_MAX  0xffffffffffffffff
+
+/* 7.18.2.2 Limits of minimum-width integer types */
+
+/* See the comment at 7.18.1.2 as to type equivalence. */
+
+#define INT_LEAST8_MIN  INT8_MIN
+#define INT_LEAST8_MAX  INT8_MAX
+#define UINT_LEAST8_MAX UINT8_MAX
+
+#define INT_LEAST16_MIN  INT16_MIN
+#define INT_LEAST16_MAX  INT16_MAX
+#define UINT_LEAST16_MAX UINT16_MAX
+
+#define INT_LEAST32_MIN  INT32_MIN
+#define INT_LEAST32_MAX  INT32_MAX
+#define UINT_LEAST32_MAX UINT32_MAX
+
+#define INT_LEAST64_MIN  INT64_MIN
+#define INT_LEAST64_MAX  INT64_MAX
+#define UINT_LEAST64_MAX UINT64_MAX
+
+/* 7.18.2.3 Limits of fastest minimum-width integer types */
+
+#define INT_FAST8_MIN  _PDCLIB_INT_FAST8_MIN
+#define INT_FAST8_MAX  _PDCLIB_INT_FAST8_MAX
+#define UINT_FAST8_MAX _PDCLIB_UINT_FAST8_MAX
+
+#define INT_FAST16_MIN  _PDCLIB_INT_FAST16_MIN
+#define INT_FAST16_MAX  _PDCLIB_INT_FAST16_MAX
+#define UINT_FAST16_MAX _PDCLIB_UINT_FAST16_MAX
+
+#define INT_FAST32_MIN  _PDCLIB_INT_FAST32_MIN
+#define INT_FAST32_MAX  _PDCLIB_INT_FAST32_MAX
+#define UINT_FAST32_MAX _PDCLIB_UINT_FAST32_MAX
+
+#define INT_FAST64_MIN  _PDCLIB_INT_FAST64_MIN
+#define INT_FAST64_MAX  _PDCLIB_INT_FAST64_MAX
+#define UINT_FAST64_MAX _PDCLIB_UINT_FAST64_MAX
+
+/* 7.18.2.4 Limits of integer types capable of holding object pointers */
+
+#define INTPTR_MIN  _PDCLIB_INTPTR_MIN
+#define INTPTR_MAX  _PDCLIB_INTPTR_MAX
+#define UINTPTR_MAX _PDCLIB_UINTPTR_MAX
+
+/* 7.18.2.5 Limits of greatest-width integer types */
+
+#define INTMAX_MIN  _PDCLIB_INTMAX_MIN
+#define INTMAX_MAX  _PDCLIB_INTMAX_MAX
+#define UINTMAX_MAX _PDCLIB_UINTMAX_MAX
+
+/* 7.18.3 Limits of other integer types */
+
+#define PTRDIFF_MIN _PDCLIB_PTRDIFF_MIN
+#define PTRDIFF_MAX _PDCLIB_PTRDIFF_MAX
+
+#define SIG_ATOMIC_MIN _PDCLIB_SIG_ATOMIC_MIN
+#define SIG_ATOMIC_MAX _PDCLIB_SIG_ATOMIC_MAX
+
+#define SIZE_MAX _PDCLIB_SIZE_MAX
+
+#define WCHAR_MIN _PDCLIB_WCHAR_MIN
+#define WCHAR_MAX _PDCLIB_WCHAR_MAX
+
+#define WINT_MIN _PDCLIB_WINT_MIN
+#define WINT_MAX _PDCLIB_WINT_MAX
+
+#endif
+
+/* 7.18.4 Macros for integer constants */
+
+#ifdef __cplusplus
+#ifndef __STDC_CONSTANT_MACROS
+#define _PDCLIB_NO_CONSTANT_MACROS
+#endif
+#endif
+
+#ifndef _PDCLIB_NO_CONSTANT_MACROS
+
+/* 7.18.4.1 Macros for minimum-width integer constants */
+
+/* Expand to an integer constant of specified value and type int_leastN_t */
+#define INT8_C( value )  _PDCLIB_append( value, _PDCLIB_INT8_LITERAL )
+#define INT16_C( value ) _PDCLIB_append( value, _PDCLIB_INT16_LITERAL )
+#define INT32_C( value ) _PDCLIB_append( value, _PDCLIB_INT32_LITERAL )
+#define INT64_C( value ) _PDCLIB_append( value, _PDCLIB_INT64_LITERAL )
+
+/* Expand to an integer constant of specified value and type uint_leastN_t */
+#define UINT8_C( value )  _PDCLIB_append( value, _PDCLIB_UINT8_LITERAL )
+#define UINT16_C( value ) _PDCLIB_append( value, _PDCLIB_UINT16_LITERAL )
+#define UINT32_C( value ) _PDCLIB_append( value, _PDCLIB_UINT32_LITERAL )
+#define UINT64_C( value ) _PDCLIB_append( value, _PDCLIB_UINT64_LITERAL )
+
+/* 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_append( value, _PDCLIB_INTMAX_LITERAL )
+
+/* Expand to an integer constant of specified value and type uintmax_t */
+#define UINTMAX_C( value ) _PDCLIB_append( value, _PDCLIB_UINTMAX_LITERAL )
+
+#endif
+
+#endif