X-Git-Url: https://pd.if.org/git/?p=pdclib;a=blobdiff_plain;f=internals%2F_PDCLIB_int.h;h=bd656958d5df7f319ccc7c46831d1ad898947dcd;hp=ab1bc90b777879c03c2a53c25b8aaf323ca93bd9;hb=197791f4a590c4db2d7b667698dbe3f732537b2f;hpb=276f7e69f80ac53bfb5da5cc24072dd393485106 diff --git a/internals/_PDCLIB_int.h b/internals/_PDCLIB_int.h index ab1bc90..bd65695 100644 --- a/internals/_PDCLIB_int.h +++ b/internals/_PDCLIB_int.h @@ -1,19 +1,19 @@ -#ifndef __PDCLIB_INT_H -#define __PDCLIB_INT_H __PDCLIB_INT_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. */ +#ifndef __PDCLIB_INT_H +#define __PDCLIB_INT_H __PDCLIB_INT_H + /* -------------------------------------------------------------------------- */ /* 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). */ /* -------------------------------------------------------------------------- */ -#include <_PDCLIB_config.h> -#include <_PDCLIB_aux.h> +#include "_PDCLIB_config.h" +#include "_PDCLIB_aux.h" /* null pointer constant */ #define _PDCLIB_NULL 0 @@ -111,6 +111,8 @@ #if _PDCLIB_CHAR_BIT == 8 typedef signed char _PDCLIB_int8_t; typedef unsigned char _PDCLIB_uint8_t; +typedef signed char _PDCLIB_int_least8_t; +typedef unsigned char _PDCLIB_uint_least8_t; #define _PDCLIB_INT8_MAX _PDCLIB_CHAR_MAX #define _PDCLIB_INT8_MIN _PDCLIB_CHAR_MIN #define _PDCLIB_UINT8_MAX _PDCLIB_UCHAR_MAX @@ -123,6 +125,8 @@ typedef unsigned char _PDCLIB_uint8_t; #if _PDCLIB_INT_BYTES == 2 typedef signed int _PDCLIB_int16_t; typedef unsigned int _PDCLIB_uint16_t; +typedef signed int _PDCLIB_int_least16_t; +typedef unsigned int _PDCLIB_uint_least16_t; #define _PDCLIB_INT16_MAX _PDCLIB_INT_MAX #define _PDCLIB_INT16_MIN _PDCLIB_INT_MIN #define _PDCLIB_UINT16_MAX _PDCLIB_UINT_MAX @@ -130,6 +134,8 @@ typedef unsigned int _PDCLIB_uint16_t; #elif _PDCLIB_SHRT_BYTES == 2 typedef signed short _PDCLIB_int16_t; typedef unsigned short _PDCLIB_uint16_t; +typedef signed short _PDCLIB_int_least16_t; +typedef unsigned short _PDCLIB_uint_least16_t; #define _PDCLIB_INT16_MAX _PDCLIB_SHRT_MAX #define _PDCLIB_INT16_MIN _PDCLIB_SHRT_MIN #define _PDCLIB_UINT16_MAX _PDCLIB_USHRT_MAX @@ -142,6 +148,8 @@ typedef unsigned short _PDCLIB_uint16_t; #if _PDCLIB_INT_BYTES == 4 typedef signed int _PDCLIB_int32_t; typedef unsigned int _PDCLIB_uint32_t; +typedef signed int _PDCLIB_int_least32_t; +typedef unsigned int _PDCLIB_uint_least32_t; #define _PDCLIB_INT32_MAX _PDCLIB_INT_MAX #define _PDCLIB_INT32_MIN _PDCLIB_INT_MIN #define _PDCLIB_UINT32_MAX _PDCLIB_UINT_MAX @@ -151,6 +159,8 @@ typedef unsigned int _PDCLIB_uint32_t; #elif _PDCLIB_LONG_BYTES == 4 typedef signed long _PDCLIB_int32_t; typedef unsigned long _PDCLIB_uint32_t; +typedef signed long _PDCLIB_int_least32_t; +typedef unsigned long _PDCLIB_uint_least32_t; #define _PDCLIB_INT32_MAX _PDCLIB_LONG_MAX #define _PDCLIB_INT32_MIN _PDCLIB_LONG_MIN #define _PDCLIB_UINT32_MAX _PDCLIB_LONG_MAX @@ -165,6 +175,8 @@ typedef unsigned long _PDCLIB_uint32_t; #if _PDCLIB_LONG_BYTES == 8 && !defined(_PDCLIB_INT64_IS_LLONG) typedef signed long _PDCLIB_int64_t; typedef unsigned long _PDCLIB_uint64_t; +typedef signed long _PDCLIB_int_least64_t; +typedef unsigned long _PDCLIB_uint_least64_t; #define _PDCLIB_INT64_MAX _PDCLIB_LONG_MAX #define _PDCLIB_INT64_MIN _PDCLIB_LONG_MIN #define _PDCLIB_UINT64_MAX _PDCLIB_ULONG_MAX @@ -174,6 +186,8 @@ typedef unsigned long _PDCLIB_uint64_t; #elif _PDCLIB_LLONG_BYTES == 8 typedef signed long long _PDCLIB_int64_t; typedef unsigned long long _PDCLIB_uint64_t; +typedef signed long long _PDCLIB_int_least64_t; +typedef unsigned long long _PDCLIB_uint_least64_t; #define _PDCLIB_INT64_MAX _PDCLIB_LLONG_MAX #define _PDCLIB_INT64_MIN _PDCLIB_LLONG_MIN #define _PDCLIB_UINT64_MAX _PDCLIB_ULLONG_MAX @@ -224,13 +238,11 @@ typedef _PDCLIB_ptrdiff _PDCLIB_ptrdiff_t; #define _PDCLIB_PTRDIFF_MIN _PDCLIB_concat( _PDCLIB_concat( _PDCLIB_, _PDCLIB_PTRDIFF ), _MIN ) #define _PDCLIB_PTRDIFF_MAX _PDCLIB_concat( _PDCLIB_concat( _PDCLIB_, _PDCLIB_PTRDIFF ), _MAX ) -#define _PDCLIB_SIG_ATOMIC_MIN _PDCLIB_concat( _PDCLIB_concat( _PDCLIB_, _PDCLIB_SIG_ATOMIC ), _MIN ) -#define _PDCLIB_SIG_ATOMIC_MAX _PDCLIB_concat( _PDCLIB_concat( _PDCLIB_, _PDCLIB_SIG_ATOMIC ), _MAX ) - typedef _PDCLIB_size _PDCLIB_size_t; #define _PDCLIB_SIZE_MAX _PDCLIB_concat( _PDCLIB_concat( _PDCLIB_, _PDCLIB_SIZE ), _MAX ) typedef _PDCLIB_wint _PDCLIB_wint_t; + #ifndef __cplusplus typedef _PDCLIB_wchar _PDCLIB_wchar_t; #else @@ -239,6 +251,9 @@ typedef _PDCLIB_wint _PDCLIB_wint_t; #define _PDCLIB_WCHAR_MIN _PDCLIB_concat( _PDCLIB_concat( _PDCLIB_, _PDCLIB_WCHAR ), _MIN ) #define _PDCLIB_WCHAR_MAX _PDCLIB_concat( _PDCLIB_concat( _PDCLIB_, _PDCLIB_WCHAR ), _MAX ) +#define _PDCLIB_SIG_ATOMIC_MIN _PDCLIB_concat( _PDCLIB_concat( _PDCLIB_, _PDCLIB_SIG_ATOMIC ), _MIN ) +#define _PDCLIB_SIG_ATOMIC_MAX _PDCLIB_concat( _PDCLIB_concat( _PDCLIB_, _PDCLIB_SIG_ATOMIC ), _MAX ) + typedef _PDCLIB_intptr _PDCLIB_intptr_t; typedef unsigned _PDCLIB_intptr _PDCLIB_uintptr_t; #define _PDCLIB_INTPTR_MIN _PDCLIB_concat( _PDCLIB_concat( _PDCLIB_, _PDCLIB_INTPTR ), _MIN ) @@ -260,29 +275,6 @@ typedef unsigned _PDCLIB_intmax _PDCLIB_uintmax_t; typedef _PDCLIB_time _PDCLIB_time_t; typedef _PDCLIB_clock _PDCLIB_clock_t; -#if !defined(_PDCLIB_DEFINE_STRUCT_TIMESPEC) -#define _PDCLIB_DEFINE_STRUCT_TIMESPEC() \ - struct timespec { \ - time_t tv_sec; \ - long tv_nsec; \ - }; -#endif - -#if !defined(_PDCLIB_DEFINE_STRUCT_TM) -#define _PDCLIB_DEFINE_STRUCT_TM() \ - struct tm { \ - int tm_sec; \ - int tm_min; \ - int tm_hour; \ - int tm_mday; \ - int tm_mon; \ - int tm_year; \ - int tm_wday; \ - int tm_yday; \ - int tm_isdst; \ - }; -#endif - /* -------------------------------------------------------------------------- */ /* Internal data types */ /* -------------------------------------------------------------------------- */ @@ -314,15 +306,19 @@ extern char _PDCLIB_Xdigits[]; /* -------------------------------------------------------------------------- */ #if _PDCLIB_C_VERSION >= 2011 -_Static_assert( sizeof( short ) == _PDCLIB_SHRT_BYTES, "_PDCLIB_SHRT_BYTES incorrectly defined, check _PDCLIB_config.h" ); -_Static_assert( sizeof( int ) == _PDCLIB_INT_BYTES, "_PDCLIB_INT_BYTES incorrectly defined, check _PDCLIB_config.h" ); -_Static_assert( sizeof( long ) == _PDCLIB_LONG_BYTES, "_PDCLIB_LONG_BYTES incorrectly defined, check _PDCLIB_config.h" ); -_Static_assert( sizeof( long long ) == _PDCLIB_LLONG_BYTES, "_PDCLIB_LLONG_BYTES incorrectly defined, check _PDCLIB_config.h" ); -_Static_assert( ( (char)-1 < 0 ) == _PDCLIB_CHAR_SIGNED, "_PDCLIB_CHAR_SIGNED incorrectly defined, check _PDCLIB_config.h" ); -_Static_assert( sizeof( _PDCLIB_wchar ) == sizeof( L'x' ), "_PDCLIB_wchar incorrectly defined, check _PDCLIB_config.h" ); -_Static_assert( sizeof( void * ) == sizeof( _PDCLIB_intptr ), "_PDCLIB_intptr incorrectly defined, check _PDCLIB_config.h" ); -_Static_assert( sizeof( sizeof( 1 ) ) == sizeof( _PDCLIB_size ), "_PDCLIB_size incorrectly defined, check _PDCLIB_config.h" ); -_Static_assert( sizeof( &_PDCLIB_digits[1] - &_PDCLIB_digits[0] ) == sizeof( _PDCLIB_ptrdiff ), "_PDCLIB_ptrdiff incorrectly defined, check _PDCLIB_config.h" ); +_Static_assert( sizeof( short ) == _PDCLIB_SHRT_BYTES, "Compiler disagrees on _PDCLIB_SHRT_BYTES." ); +_Static_assert( sizeof( int ) == _PDCLIB_INT_BYTES, "Compiler disagrees on _PDCLIB_INT_BYTES." ); +_Static_assert( sizeof( long ) == _PDCLIB_LONG_BYTES, "Compiler disagrees on _PDCLIB_LONG_BYTES." ); +_Static_assert( sizeof( long long ) == _PDCLIB_LLONG_BYTES, "Compiler disagrees on _PDCLIB_LLONG_BYTES." ); + +_Static_assert( ( (char)-1 < 0 ) == _PDCLIB_CHAR_SIGNED, "Compiler disagrees on _PDCLIB_CHAR_SIGNED." ); +_Static_assert( sizeof( sizeof( int ) ) == sizeof( _PDCLIB_size ), "Compiler disagrees on _PDCLIB_size." ); + +_Static_assert( sizeof( _PDCLIB_wchar ) == sizeof( L'x' ), "Compiler disagrees on _PDCLIB_wchar." ); + +_Static_assert( sizeof( void * ) == sizeof( _PDCLIB_intptr ), "Compiler disagrees on _PDCLIB_intptr." ); + +_Static_assert( sizeof( &_PDCLIB_digits[1] - &_PDCLIB_digits[0] ) == sizeof( _PDCLIB_ptrdiff ), "Compiler disagrees on _PDCLIB_ptrdiff." ); #endif /* -------------------------------------------------------------------------- */ @@ -372,6 +368,9 @@ typedef struct lconv _PDCLIB_lconv_t; _PDCLIB_size_t _PDCLIB_mb_cur_max( void ); +/* wide-character EOF */ +#define _PDCLIB_WEOF ((wint_t) -1 + /* -------------------------------------------------------------------------- */ /* stdio */ /* -------------------------------------------------------------------------- */