From: solar Date: Sun, 20 Nov 2005 13:04:16 +0000 (+0000) Subject: Added Makefile and moved internal headers into seperate directory (allowing easier... X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=441fa24696970a909e85875230c491bd1e7f3bf9;p=fw%2Fpdclib Added Makefile and moved internal headers into seperate directory (allowing easier _partial_ compilation of PDCLib). git-svn-id: https://srv7.svn-repos.de/dev34/pdclib/trunk@63 546481bc-9713-0410-bf18-d3337bbf4a3e --- diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..9358097 --- /dev/null +++ b/Makefile @@ -0,0 +1,28 @@ +# This is a list of all non-source files that are part of the distribution. +AUXFILES := Makefile Readme.txt + +SRCFILES := $(shell find . -name "*.c" -mindepth 1 -maxdepth 3) +HDRFILES := $(shell find . -name "*.h" -mindepth 1 -maxdepth 3) +OBJFILES := $(patsubst %.c,%.o,$(SRCFILES)) +DEPFILES := $(patsubst %.c,%.d,$(SRCFILES)) +ALLFILES := $(SRCFILES) $(HDRFILES) $(AUXFILES) + +CPPFLAGS := -MMD -MP +CFLAGS := -g -std=c99 -I./internals/ + +.PHONY: all clean dist + +all: $(OBJFILES) + ar r pdclib.a $(OBJFILES) + +-include $(DEPFILES) + +clean: + -@for file in $(OBJFILES) $(DEPFILES) pdclib.a; do if [ -f $$file ]; then rm $$file; fi; done + +dist: + @tar czf pdclib.tgz $(ALLFILES) + +%.o: %.c Makefile + $(CC) $(MODE) -c $(CPPFLAGS) $(CFLAGS) $< -o $@ + diff --git a/functions/string/memcpy.c b/functions/string/memcpy.c index 785b1cd..a5842d3 100644 --- a/functions/string/memcpy.c +++ b/functions/string/memcpy.c @@ -8,6 +8,7 @@ Permission is granted to use, modify, and / or redistribute at will. */ +#include <_PDCLIB_aux.h> #include void * memcpy( void * _PDCLIB_restrict s1, const void * _PDCLIB_restrict s2, size_t n ) diff --git a/functions/string/strncat.c b/functions/string/strncat.c index b33fb7c..44dcb40 100644 --- a/functions/string/strncat.c +++ b/functions/string/strncat.c @@ -8,6 +8,7 @@ Permission is granted to use, modify, and / or redistribute at will. */ +#include <_PDCLIB_aux.h> #include char * strncat( char * _PDCLIB_restrict s1, const char * _PDCLIB_restrict s2, size_t n ) diff --git a/functions/string/strncpy.c b/functions/string/strncpy.c index aafb704..ed5965d 100644 --- a/functions/string/strncpy.c +++ b/functions/string/strncpy.c @@ -8,6 +8,7 @@ Permission is granted to use, modify, and / or redistribute at will. */ +#include <_PDCLIB_aux.h> #include char * strncpy( char * _PDCLIB_restrict s1, const char * _PDCLIB_restrict s2, size_t n ) diff --git a/functions/string/strtok.c b/functions/string/strtok.c index 4d371af..3135920 100644 --- a/functions/string/strtok.c +++ b/functions/string/strtok.c @@ -8,6 +8,7 @@ Permission is granted to use, modify, and / or redistribute at will. */ +#include <_PDCLIB_aux.h> #include char * strtok( char * _PDCLIB_restrict s1, const char * _PDCLIB_restrict s2 ) diff --git a/functions/string/strxfrm.c b/functions/string/strxfrm.c index 578eb4b..5849a0c 100644 --- a/functions/string/strxfrm.c +++ b/functions/string/strxfrm.c @@ -8,6 +8,7 @@ Permission is granted to use, modify, and / or redistribute at will. */ +#include <_PDCLIB_aux.h> #include /* TODO: Dummy function, no locale support yet. */ diff --git a/includes/_PDCLIB_aux.h b/includes/_PDCLIB_aux.h deleted file mode 100644 index 4ef019e..0000000 --- a/includes/_PDCLIB_aux.h +++ /dev/null @@ -1,61 +0,0 @@ -/* $Id$ */ - -/* Release $Name$ */ - -/* Auxiliary PDCLib code <_PDCLIB_aux.h> - - This file is part of the Public Domain C Library (PDCLib). - Permission is granted to use, modify, and / or redistribute at will. -*/ - -/* -------------------------------------------------------------------------- */ -/* Standard Version */ -/* -------------------------------------------------------------------------- */ - -/* Many a compiler gets this wrong, so you might have to hardcode it instead. */ - -#if __STDC__ != 1 -#error Compiler does not define _ _STDC_ _ to 1 (not standard-compliant)! -#endif - -#ifndef __STDC_VERSION__ -#define _PDCLIB_C_VERSION 90 -#define _PDCLIB_restrict -#elif __STDC_VERSION__ == 199409L -#define _PDCLIB_C_VERSION 95 -#define _PDCLIB_restrict -#elif __STDC_VERSION__ == 199901L -#define _PDCLIB_C_VERSION 99 -#define _PDCLIB_restrict restrict -#else -#error Unsupported _ _STDC_VERSION_ _ (__STDC_VERSION__) (supported: ISO/IEC 9899:1990, 9899/AMD1:1995, and 9899:1999). -#endif - -#ifndef __STDC_HOSTED__ -#warning Compiler does not define _ _STDC_HOSTED_ _ (not standard-compliant)! -#elif __STDC_HOSTED__ == 0 -#define _PDCLIB_HOSTED 0 -#elif __STDC_HOSTED__ == 1 -#define _PDCLIB_HOSTED 1 -#else -#error Compiler does not define _ _STDC_HOSTED_ _ to 0 or 1 (not standard-compliant)! -#endif - -#if _PDCLIB_C_VERSION != 99 -#warning Up to and including v1.x, PDCLib is only aiming at ISO/IEC 9899:1999 (C99). -#warning PDCLib might not be fully conforming to either C89 or C95 prior to v2.x. -#endif - -/* -------------------------------------------------------------------------- */ -/* 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 ) - -#define _PDCLIB_symbol2value( x ) #x -#define _PDCLIB_symbol2string( x ) _PDCLIB_symbol2value( x ) -#define _PDCLIB_symbol2identity( x ) x - diff --git a/includes/_PDCLIB_config.h b/includes/_PDCLIB_config.h deleted file mode 100644 index 74eb290..0000000 --- a/includes/_PDCLIB_config.h +++ /dev/null @@ -1,164 +0,0 @@ -/* $Id$ */ - -/* Release $Name$ */ - -/* 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. -*/ - -/* -------------------------------------------------------------------------- */ -/* Misc */ -/* -------------------------------------------------------------------------- */ - -/* The character (sequence) your platform uses as newline. */ -#define _PDCLIB_endl "\n" - -/* -------------------------------------------------------------------------- */ -/* Integers */ -/* -------------------------------------------------------------------------- */ -/* Assuming 8-bit char, two's-complement architecture here. 'short' being */ -/* 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. */ -/* -------------------------------------------------------------------------- */ - -/* Comment out (or delete) the line below if your 'char' type is unsigned. */ -#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 -#define _PDCLIB_LLONG_BYTES 8 - -/* -------------------------------------------------------------------------- */ -/* 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". See above for details. */ -/* -------------------------------------------------------------------------- */ - -/* The result type of substracting two pointers */ -#define _PDCLIB_ptrdiff int -#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 unsigned int -#define _PDCLIB_SIZE UINT - -/* Large enough an integer to hold all character codes of the largest supported - locale. -*/ -#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 -/* You are also required to state the literal suffix for the intmax type */ -#define _PDCLIB_INTMAX_LITERAL ll - -/* -------------------------------------------------------------------------- */ -/* 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 () - The macros defined by 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 . */ -#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/includes/_PDCLIB_int.h b/includes/_PDCLIB_int.h deleted file mode 100644 index 24accb0..0000000 --- a/includes/_PDCLIB_int.h +++ /dev/null @@ -1,253 +0,0 @@ -/* $Id$ */ - -/* Release $Name$ */ - -/* 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. -*/ - -/* -------------------------------------------------------------------------- */ -/* 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(s). */ -/* -------------------------------------------------------------------------- */ - -#ifndef _PDCLIB_CONFIG_H -#define _PDCLIB_CONFIG_H _PDCLIB_CONFIG_H -#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 - -/* -------------------------------------------------------------------------- */ -/* 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 == 2 -#define _PDCLIB_SHRT_MAX 0x7fff -#define _PDCLIB_SHRT_MIN (-0x7fff - 1) -#define _PDCLIB_USHRT_MAX 0xffff -#else -#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_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_ULONG_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 - -/* -------------------------------------------------------------------------- */ -/* exact-width types and their limits */ -/* -------------------------------------------------------------------------- */ - -/* Setting 'int8_t', its limits, and its literal. */ -#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 -#define _PDCLIB_INT8_LITERAL -#define _PDCLIB_UINT8_LITERAL -#else -#error Unsupported width of char (not 8 bits). -#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 -#define _PDCLIB_INT16_LITERAL -#define _PDCLIB_UINT16_LITERAL -#elif _PDCLIB_SHRT_BYTES == 2 -typedef signed short _PDCLIB_int16_t; -typedef unsigned short _PDCLIB_uint16_t; -#define _PDCLIB_INT16_MAX _PDCLIB_SHRT_MAX -#define _PDCLIB_INT16_MIN _PDCLIB_SHRT_MIN -#define _PDCLIB_UINT16_MAX _PDCLIB_USHRT_MAX -#define _PDCLIB_INT16_LITERAL s -#define _PDCLIB_UINT16_LITERAL us -#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_uint32_t; -#define _PDCLIB_INT32_MAX _PDCLIB_INT_MAX -#define _PDCLIB_INT32_MIN _PDCLIB_INT_MIN -#define _PDCLIB_UINT32_MAX _PDCLIB_UINT_MAX -#define _PDCLIB_INT32_LITERAL -#define _PDCLIB_UINT32_LITERAL -#elif _PDCLIB_LONG_BYTES == 4 -typedef signed long _PDCLIB_int32_t; -typedef unsigned long _PDCLIB_uint32_t; -#define _PDCLIB_INT32_MAX _PDCLIB_LONG_MAX -#define _PDCLIB_INT32_MIN _PDCLIB_LONG_MIN -#define _PDCLIB_UINT32_MAX _PDCLIB_LONG_MAX -#define _PDCLIB_INT32_LITERAL l -#define _PDCLIB_UINT32_LITERAL ul -#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_uint64_t; -#define _PDCLIB_INT64_MAX _PDCLIB_LONG_MAX -#define _PDCLIB_INT64_MIN _PDCLIB_LONG_MIN -#define _PDCLIB_UINT64_MAX _PDCLIB_ULONG_MAX -#define _PDCLIB_INT64_LITERAL l -#define _PDCLIB_UINT64_LITERAL ul -#elif _PDCLIB_LLONG_BYTES == 8 -typedef signed long long _PDCLIB_int64_t; -typedef unsigned long long _PDCLIB_uint64_t; -#define _PDCLIB_INT64_MAX _PDCLIB_LLONG_MAX -#define _PDCLIB_INT64_MIN _PDCLIB_LLONG_MIN -#define _PDCLIB_UINT64_MAX _PDCLIB_ULLONG_MAX -#define _PDCLIB_INT64_LITERAL ll -#define _PDCLIB_UINT64_LITERAL ull -#else -#error Neither 'long' nor 'long long' are 64-bit. -#endif - -/* -------------------------------------------------------------------------- */ -/* "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 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 ) - -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 ) - -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 ) -#define _PDCLIB_INTMAX_C( value ) concat( value, _PDCLIB_INTMAX_LITERAL ) -#define _PDCLIB_UINTMAX_C( value ) concat( value, concat( u, _PDCLIB_INTMAX_LITERAL ) ) diff --git a/internals/_PDCLIB_aux.h b/internals/_PDCLIB_aux.h new file mode 100644 index 0000000..4ef019e --- /dev/null +++ b/internals/_PDCLIB_aux.h @@ -0,0 +1,61 @@ +/* $Id$ */ + +/* Release $Name$ */ + +/* Auxiliary PDCLib code <_PDCLIB_aux.h> + + This file is part of the Public Domain C Library (PDCLib). + Permission is granted to use, modify, and / or redistribute at will. +*/ + +/* -------------------------------------------------------------------------- */ +/* Standard Version */ +/* -------------------------------------------------------------------------- */ + +/* Many a compiler gets this wrong, so you might have to hardcode it instead. */ + +#if __STDC__ != 1 +#error Compiler does not define _ _STDC_ _ to 1 (not standard-compliant)! +#endif + +#ifndef __STDC_VERSION__ +#define _PDCLIB_C_VERSION 90 +#define _PDCLIB_restrict +#elif __STDC_VERSION__ == 199409L +#define _PDCLIB_C_VERSION 95 +#define _PDCLIB_restrict +#elif __STDC_VERSION__ == 199901L +#define _PDCLIB_C_VERSION 99 +#define _PDCLIB_restrict restrict +#else +#error Unsupported _ _STDC_VERSION_ _ (__STDC_VERSION__) (supported: ISO/IEC 9899:1990, 9899/AMD1:1995, and 9899:1999). +#endif + +#ifndef __STDC_HOSTED__ +#warning Compiler does not define _ _STDC_HOSTED_ _ (not standard-compliant)! +#elif __STDC_HOSTED__ == 0 +#define _PDCLIB_HOSTED 0 +#elif __STDC_HOSTED__ == 1 +#define _PDCLIB_HOSTED 1 +#else +#error Compiler does not define _ _STDC_HOSTED_ _ to 0 or 1 (not standard-compliant)! +#endif + +#if _PDCLIB_C_VERSION != 99 +#warning Up to and including v1.x, PDCLib is only aiming at ISO/IEC 9899:1999 (C99). +#warning PDCLib might not be fully conforming to either C89 or C95 prior to v2.x. +#endif + +/* -------------------------------------------------------------------------- */ +/* 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 ) + +#define _PDCLIB_symbol2value( x ) #x +#define _PDCLIB_symbol2string( x ) _PDCLIB_symbol2value( x ) +#define _PDCLIB_symbol2identity( x ) x + diff --git a/internals/_PDCLIB_config.h b/internals/_PDCLIB_config.h new file mode 100644 index 0000000..74eb290 --- /dev/null +++ b/internals/_PDCLIB_config.h @@ -0,0 +1,164 @@ +/* $Id$ */ + +/* Release $Name$ */ + +/* 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. +*/ + +/* -------------------------------------------------------------------------- */ +/* Misc */ +/* -------------------------------------------------------------------------- */ + +/* The character (sequence) your platform uses as newline. */ +#define _PDCLIB_endl "\n" + +/* -------------------------------------------------------------------------- */ +/* Integers */ +/* -------------------------------------------------------------------------- */ +/* Assuming 8-bit char, two's-complement architecture here. 'short' being */ +/* 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. */ +/* -------------------------------------------------------------------------- */ + +/* Comment out (or delete) the line below if your 'char' type is unsigned. */ +#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 +#define _PDCLIB_LLONG_BYTES 8 + +/* -------------------------------------------------------------------------- */ +/* 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". See above for details. */ +/* -------------------------------------------------------------------------- */ + +/* The result type of substracting two pointers */ +#define _PDCLIB_ptrdiff int +#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 unsigned int +#define _PDCLIB_SIZE UINT + +/* Large enough an integer to hold all character codes of the largest supported + locale. +*/ +#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 +/* You are also required to state the literal suffix for the intmax type */ +#define _PDCLIB_INTMAX_LITERAL ll + +/* -------------------------------------------------------------------------- */ +/* 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 () + The macros defined by 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 . */ +#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/internals/_PDCLIB_int.h b/internals/_PDCLIB_int.h new file mode 100644 index 0000000..24accb0 --- /dev/null +++ b/internals/_PDCLIB_int.h @@ -0,0 +1,253 @@ +/* $Id$ */ + +/* Release $Name$ */ + +/* 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. +*/ + +/* -------------------------------------------------------------------------- */ +/* 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(s). */ +/* -------------------------------------------------------------------------- */ + +#ifndef _PDCLIB_CONFIG_H +#define _PDCLIB_CONFIG_H _PDCLIB_CONFIG_H +#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 + +/* -------------------------------------------------------------------------- */ +/* 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 == 2 +#define _PDCLIB_SHRT_MAX 0x7fff +#define _PDCLIB_SHRT_MIN (-0x7fff - 1) +#define _PDCLIB_USHRT_MAX 0xffff +#else +#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_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_ULONG_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 + +/* -------------------------------------------------------------------------- */ +/* exact-width types and their limits */ +/* -------------------------------------------------------------------------- */ + +/* Setting 'int8_t', its limits, and its literal. */ +#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 +#define _PDCLIB_INT8_LITERAL +#define _PDCLIB_UINT8_LITERAL +#else +#error Unsupported width of char (not 8 bits). +#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 +#define _PDCLIB_INT16_LITERAL +#define _PDCLIB_UINT16_LITERAL +#elif _PDCLIB_SHRT_BYTES == 2 +typedef signed short _PDCLIB_int16_t; +typedef unsigned short _PDCLIB_uint16_t; +#define _PDCLIB_INT16_MAX _PDCLIB_SHRT_MAX +#define _PDCLIB_INT16_MIN _PDCLIB_SHRT_MIN +#define _PDCLIB_UINT16_MAX _PDCLIB_USHRT_MAX +#define _PDCLIB_INT16_LITERAL s +#define _PDCLIB_UINT16_LITERAL us +#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_uint32_t; +#define _PDCLIB_INT32_MAX _PDCLIB_INT_MAX +#define _PDCLIB_INT32_MIN _PDCLIB_INT_MIN +#define _PDCLIB_UINT32_MAX _PDCLIB_UINT_MAX +#define _PDCLIB_INT32_LITERAL +#define _PDCLIB_UINT32_LITERAL +#elif _PDCLIB_LONG_BYTES == 4 +typedef signed long _PDCLIB_int32_t; +typedef unsigned long _PDCLIB_uint32_t; +#define _PDCLIB_INT32_MAX _PDCLIB_LONG_MAX +#define _PDCLIB_INT32_MIN _PDCLIB_LONG_MIN +#define _PDCLIB_UINT32_MAX _PDCLIB_LONG_MAX +#define _PDCLIB_INT32_LITERAL l +#define _PDCLIB_UINT32_LITERAL ul +#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_uint64_t; +#define _PDCLIB_INT64_MAX _PDCLIB_LONG_MAX +#define _PDCLIB_INT64_MIN _PDCLIB_LONG_MIN +#define _PDCLIB_UINT64_MAX _PDCLIB_ULONG_MAX +#define _PDCLIB_INT64_LITERAL l +#define _PDCLIB_UINT64_LITERAL ul +#elif _PDCLIB_LLONG_BYTES == 8 +typedef signed long long _PDCLIB_int64_t; +typedef unsigned long long _PDCLIB_uint64_t; +#define _PDCLIB_INT64_MAX _PDCLIB_LLONG_MAX +#define _PDCLIB_INT64_MIN _PDCLIB_LLONG_MIN +#define _PDCLIB_UINT64_MAX _PDCLIB_ULLONG_MAX +#define _PDCLIB_INT64_LITERAL ll +#define _PDCLIB_UINT64_LITERAL ull +#else +#error Neither 'long' nor 'long long' are 64-bit. +#endif + +/* -------------------------------------------------------------------------- */ +/* "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 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 ) + +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 ) + +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 ) +#define _PDCLIB_INTMAX_C( value ) concat( value, _PDCLIB_INTMAX_LITERAL ) +#define _PDCLIB_UINTMAX_C( value ) concat( value, concat( u, _PDCLIB_INTMAX_LITERAL ) )