From: solar Date: Sun, 12 Dec 2004 10:26:43 +0000 (+0000) Subject: Excluded *_C macros from first release; cosmetic touches. X-Git-Tag: v0.1~5 X-Git-Url: https://pd.if.org/git/?p=pdclib;a=commitdiff_plain;h=58d8a9b3c029ee73e8b9d019627e2ffebc4fe728 Excluded *_C macros from first release; cosmetic touches. --- diff --git a/_PDCLIB_config.h b/_PDCLIB_config.h index 2b69f07..a8ef2fa 100644 --- a/_PDCLIB_config.h +++ b/_PDCLIB_config.h @@ -1,6 +1,6 @@ /* $Id$ */ -/* Release: $Name$ */ +/* Release $Name$ */ /* Internal PDCLib configuration <_PDCLIB_config.h> (Generic Template) @@ -13,18 +13,20 @@ /* 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 @@ -63,13 +65,11 @@ /* -------------------------------------------------------------------------- */ /* 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 @@ -79,14 +79,20 @@ typedef int _PDCLIB_ptrdiff_t; #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 */ diff --git a/_PDCLIB_int.h b/_PDCLIB_int.h index 3192823..14a2957 100644 --- a/_PDCLIB_int.h +++ b/_PDCLIB_int.h @@ -1,8 +1,8 @@ /* $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. @@ -18,18 +18,14 @@ #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 */ /* -------------------------------------------------------------------------- */ @@ -54,19 +50,19 @@ #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 @@ -114,22 +110,18 @@ #define _PDCLIB_ULLONG_MIN 0 /* -------------------------------------------------------------------------- */ -/* exact-width types, their limits and literals */ +/* 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 */ @@ -215,45 +207,33 @@ typedef unsigned _PDCLIB_fast64 _PDCLIB_uint_fast64_t; #define _PDCLIB_UINT_FAST64_MAX concat( concat( _PDCLIB_U, _PDCLIB_FAST64 ), _MAX ) /* -------------------------------------------------------------------------- */ -/* Various limits */ +/* 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 ) -/* -------------------------------------------------------------------------- */ -/* "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 ) -/* -------------------------------------------------------------------------- */ -/* 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 */ diff --git a/float.h b/float.h index 40e2000..5b878fb 100644 --- a/float.h +++ b/float.h @@ -1,6 +1,6 @@ /* $Id$ */ -/* Release: $Name$ */ +/* Release $Name$ */ /* 7.7 Characteristics of floating types @@ -85,3 +85,4 @@ #define LDBL_MAX_10_EXP 4932 #endif + diff --git a/iso646.h b/iso646.h index a25af3d..48ca809 100644 --- a/iso646.h +++ b/iso646.h @@ -1,8 +1,8 @@ /* $Id$ */ -/* Release: $Name$ */ +/* Release $Name$ */ -/* 7.9 Alternative spellings */ +/* 7.9 Alternative spellings This file is part of the Public Domain C Library (PDCLib). Permission is granted to use, modify, and / or redistribute at will. @@ -24,3 +24,4 @@ #define xor_eq ˆ= #endif + diff --git a/limits.h b/limits.h index 1dfb790..0631bf0 100644 --- a/limits.h +++ b/limits.h @@ -1,6 +1,6 @@ /* $Id$ */ -/* Release: $Name$ */ +/* Release $Name$ */ /* 7.10 Sizes of integer types @@ -40,3 +40,4 @@ #define ULONG_MAX _PDCLIB_ULONG_MAX #endif + diff --git a/stdarg.h b/stdarg.h index cb74be2..7558131 100644 --- a/stdarg.h +++ b/stdarg.h @@ -1,6 +1,6 @@ /* $Id$ */ -/* Release: $Name$ */ +/* Release $Name$ */ /* 7.15 Variable arguments @@ -24,3 +24,4 @@ typedef _PDCLIB_va_list va_list; #define va_start( ap, parmN ) _PDCLIB_va_start( ap, parmN ) #endif + diff --git a/stdbool.h b/stdbool.h index 8e9b7e3..f067e97 100644 --- a/stdbool.h +++ b/stdbool.h @@ -1,6 +1,6 @@ /* $Id$ */ -/* Release: $Name$ */ +/* Release $Name$ */ /* 7.16 Boolean type and values @@ -17,3 +17,4 @@ #define __bool_true_false_are_defined 1 #endif + diff --git a/stddef.h b/stddef.h index b3e848a..d0577d0 100644 --- a/stddef.h +++ b/stddef.h @@ -1,6 +1,6 @@ /* $Id$ */ -/* Release: $Name$ */ +/* Release $Name$ */ /* 7.17 Common definitions @@ -25,3 +25,4 @@ typedef _PDCLIB_wchar_t wchar_t; #define offsetof( type, member ) _PDCLIB_offsetof( type, member ) #endif + diff --git a/stdint.h b/stdint.h index 1f0ebd4..806487b 100644 --- a/stdint.h +++ b/stdint.h @@ -1,6 +1,6 @@ /* $Id$ */ -/* Release: $Name$ */ +/* Release $Name$ */ /* 7.18 Integer types @@ -181,25 +181,33 @@ typedef _PDCLIB_uintmax_t uintmax_t; /* 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