]> pd.if.org Git - pdclib/commitdiff
Sweeping cleanups. Sorry for the massive commit; I got sidetracked once too often.
authorMartin Baute <solar@rootdirectory.de>
Sun, 13 Mar 2016 07:37:59 +0000 (08:37 +0100)
committerMartin Baute <solar@rootdirectory.de>
Sun, 13 Mar 2016 07:37:59 +0000 (08:37 +0100)
47 files changed:
functions/signal/raise.c [moved from platform/example/functions/signal/raise.c with 100% similarity]
functions/signal/signal.c [moved from platform/posix/functions/signal/signal.c with 98% similarity]
includes/assert.h
includes/ctype.h
includes/float.h
includes/inttypes.h
includes/iso646.h
includes/limits.h
includes/locale.h
includes/stdalign.h [new file with mode: 0644]
includes/stdarg.h
includes/stdbool.h
includes/stddef.h
includes/stdint.h
includes/stdio.h
includes/stdlib.h
includes/string.h
includes/threads.h
includes/time.h
includes/uchar.h
includes/wchar.h
includes/wctype.h
internals/_PDCLIB_aux.h
internals/_PDCLIB_encoding.h
internals/_PDCLIB_float.h
internals/_PDCLIB_glue.h
internals/_PDCLIB_int.h
internals/_PDCLIB_io.h
internals/_PDCLIB_locale.h
opt/c_locale/_PDCLIB_clocale.h
opt/nothread/_PDCLIB_threadconfig.h
opt/pthreads/_PDCLIB_threadconfig.h
opt/tss_errno/errno.h
platform/example/functions/signal/signal.c [deleted file]
platform/example/includes/signal.h
platform/gandr/functions/signal/raise.c [deleted file]
platform/gandr/functions/signal/signal.c [deleted file]
platform/gandr/includes/_PDCLIB_config.h
platform/gandr/includes/signal.h
platform/posix/functions/signal/raise.c [deleted file]
platform/posix/includes/signal.h
platform/posix/internals/_PDCLIB_config.h
platform/win32/functions/signal/raise.c [deleted file]
platform/win32/functions/signal/signal.c [deleted file]
platform/win32/includes/signal.h
platform/win32/internals/_PDCLIB_config.h
platform/win32/internals/_PDCLIB_threadconfig.h

similarity index 98%
rename from platform/posix/functions/signal/signal.c
rename to functions/signal/signal.c
index 56aada5e6f8f9e71b1f03c5d9ee8c976306ccebb..e677af540ce4f07e090ac6222bb6459d21fb5939 100644 (file)
@@ -5,10 +5,9 @@
 */
 
 #include <signal.h>
+#include <errno.h>
 
 #ifndef REGTEST
-#include <stdlib.h>
-#include <errno.h>
 
 void (*_PDCLIB_sigabrt)( int ) = SIG_DFL;
 void (*_PDCLIB_sigfpe)( int )  = SIG_DFL;
index 44b30b87b7bdbe98281ad086afed1162fb623a4c..ffb394803e8e4a04d46c81283184357820ccedcd 100644 (file)
@@ -1,4 +1,4 @@
-/* 7.2 Diagnostics <assert.h>
+/* Diagnostics <assert.h>
 
    This file is part of the Public Domain C Library (PDCLib).
    Permission is granted to use, modify, and / or redistribute at will.
      evaluates to true;
    * print an error message and terminates the program if NDEBUG is not set AND
      the parameter expression evaluates to false.
-  The error message contains the parameter expression, name of the source file
+   The error message contains the parameter expression, name of the source file
   (__FILE__), line number (__LINE__), and (from C99 onward) name of the function
   (__func__).
-   The header can be included MULTIPLE times, and redefines the macro depending
+    The header can be included MULTIPLE times, and redefines the macro depending
    on the current setting of NDEBUG.
 */
 
-_PDCLIB_BEGIN_EXTERN_C
-
 #ifndef _PDCLIB_ASSERT_H
 #define _PDCLIB_ASSERT_H _PDCLIB_ASSERT_H
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /* Functions _NOT_ tagged noreturn as this hampers debugging */
 void _PDCLIB_assert99( char const * const, char const * const, char const * const );
 void _PDCLIB_assert89( char const * const );
 
+#ifdef __cplusplus
+}
+#endif
+
 #if _PDCLIB_C_VERSION >= 2011
 #define static_assert _Static_assert
 #else
@@ -54,7 +60,7 @@ void _PDCLIB_assert89( char const * const );
         _PDCLIB_UNREACHABLE; \
       } \
     } while(0)
-    
+
 #else
 #define assert(expression) \
     do { if(!(expression)) { \
@@ -66,5 +72,3 @@ void _PDCLIB_assert89( char const * const );
       } \
     } while(0)
 #endif
-
-_PDCLIB_END_EXTERN_C
index f0accf042cb2c3eb6cb434ae0c6fd40f8fbf2cc6..f55d18b6c1b9db48611a6d93cac704669d13881a 100644 (file)
@@ -1,4 +1,4 @@
-/* 7.4 Character handling <ctype.h>
+/* Character handling <ctype.h>
 
    This file is part of the Public Domain C Library (PDCLib).
    Permission is granted to use, modify, and / or redistribute at will.
@@ -7,7 +7,10 @@
 #ifndef _PDCLIB_CTYPE_H
 #define _PDCLIB_CTYPE_H _PDCLIB_CTYPE_H
 #include <_PDCLIB_int.h>
-_PDCLIB_BEGIN_EXTERN_C
+
+#ifdef __cplusplus
+extern "C" {
+#endif
 
 /* Character classification functions */
 
@@ -90,5 +93,8 @@ int tolower( int c ) _PDCLIB_nothrow;
 */
 int toupper( int c ) _PDCLIB_nothrow;
 
-_PDCLIB_END_EXTERN_C
+#ifdef __cplusplus
+}
+#endif
+
 #endif
index baac7e65418d7d69130afe65935c095fc3b0f830..fb485a4cb4657060c0ea1989e147c8063c2dfb4c 100644 (file)
@@ -1,4 +1,4 @@
-/* 7.7 Characteristics of floating types <float.h>\r
+/* Characteristics of floating types <float.h>\r
 \r
    This file is part of the Public Domain C Library (PDCLib).\r
    Permission is granted to use, modify, and / or redistribute at will.\r
 #define FLT_EVAL_METHOD _PDCLIB_FLT_EVAL_METHOD\r
 #define DECIMAL_DIG     _PDCLIB_DECIMAL_DIG\r
 \r
-   /* Radix of exponent representation */\r
+/* Radix of exponent representation */\r
 #define FLT_RADIX       _PDCLIB_FLT_RADIX\r
-   /* Number of base-FLT_RADIX digits in the significand of a float */\r
+\r
+/* Number of base-FLT_RADIX digits in the significand of a float */\r
 #define FLT_MANT_DIG    _PDCLIB_FLT_MANT_DIG\r
-   /* Number of decimal digits of precision in a float */\r
+\r
+/* Number of decimal digits of precision in a float */\r
 #define FLT_DIG         _PDCLIB_FLT_DIG\r
-   /* Difference between 1.0 and the minimum float greater than 1.0 */\r
+\r
+/* Difference between 1.0 and the minimum float greater than 1.0 */\r
 #define FLT_EPSILON     _PDCLIB_FLT_EPSILON\r
-   /* Minimum int x such that FLT_RADIX**(x-1) is a normalised float */\r
+\r
+/* Minimum int x such that FLT_RADIX**(x-1) is a normalised float */\r
 #define FLT_MIN_EXP     _PDCLIB_FLT_MIN_EXP\r
-   /* Minimum normalised float */\r
+\r
+/* Minimum normalised float */\r
 #define FLT_MIN         _PDCLIB_FLT_MIN\r
-   /* Minimum int x such that 10**x is a normalised float */\r
+\r
+/* Minimum int x such that 10**x is a normalised float */\r
 #define FLT_MIN_10_EXP  _PDCLIB_FLT_MIN_10_EXP\r
-   /* Maximum int x such that FLT_RADIX**(x-1) is a representable float */\r
+\r
+/* Maximum int x such that FLT_RADIX**(x-1) is a representable float */\r
 #define FLT_MAX_EXP     _PDCLIB_FLT_MAX_EXP\r
-   /* Maximum float */\r
+\r
+/* Maximum float */\r
 #define FLT_MAX         _PDCLIB_FLT_MAX\r
-   /* Maximum int x such that 10**x is a representable float */\r
+\r
+/* Maximum int x such that 10**x is a representable float */\r
 #define FLT_MAX_10_EXP  _PDCLIB_FLT_MAX_10_EXP\r
 \r
-   /* Number of base-FLT_RADIX digits in the significand of a double */\r
+\r
+/* Number of base-FLT_RADIX digits in the significand of a double */\r
 #define DBL_MANT_DIG    _PDCLIB_DBL_MANT_DIG\r
-   /* Number of decimal digits of precision in a double */\r
+\r
+/* Number of decimal digits of precision in a double */\r
 #define DBL_DIG         _PDCLIB_DBL_DIG\r
-   /* Difference between 1.0 and the minimum double greater than 1.0 */\r
+\r
+/* Difference between 1.0 and the minimum double greater than 1.0 */\r
 #define DBL_EPSILON     _PDCLIB_DBL_EPSILON\r
-   /* Minimum int x such that FLT_RADIX**(x-1) is a normalised double */\r
+\r
+/* Minimum int x such that FLT_RADIX**(x-1) is a normalised double */\r
 #define DBL_MIN_EXP     _PDCLIB_DBL_MIN_EXP\r
-   /* Minimum normalised double */\r
+\r
+/* Minimum normalised double */\r
 #define DBL_MIN         _PDCLIB_DBL_MIN\r
-   /* Minimum int x such that 10**x is a normalised double */\r
+\r
+/* Minimum int x such that 10**x is a normalised double */\r
 #define DBL_MIN_10_EXP  _PDCLIB_DBL_MIN_10_EXP\r
-   /* Maximum int x such that FLT_RADIX**(x-1) is a representable double */\r
+\r
+/* Maximum int x such that FLT_RADIX**(x-1) is a representable double */\r
 #define DBL_MAX_EXP     _PDCLIB_DBL_MAX_EXP\r
-   /* Maximum double */\r
+\r
+/* Maximum double */\r
 #define DBL_MAX         _PDCLIB_DBL_MAX\r
-   /* Maximum int x such that 10**x is a representable double */\r
+\r
+/* Maximum int x such that 10**x is a representable double */\r
 #define DBL_MAX_10_EXP  _PDCLIB_DBL_MAX_10_EXP\r
 \r
-   /* Number of base-FLT_RADIX digits in the significand of a long double */\r
+\r
+/* Number of base-FLT_RADIX digits in the significand of a long double */\r
 #define LDBL_MANT_DIG   _PDCLIB_LDBL_MANT_DIG\r
-   /* Number of decimal digits of precision in a long double */\r
+\r
+/* Number of decimal digits of precision in a long double */\r
 #define LDBL_DIG        _PDCLIB_LDBL_DIG\r
-   /* Difference between 1.0 and the minimum long double greater than 1.0 */\r
+\r
+/* Difference between 1.0 and the minimum long double greater than 1.0 */\r
 #define LDBL_EPSILON    _PDCLIB_LDBL_EPSILON\r
-   /* Minimum int x such that FLT_RADIX**(x-1) is a normalised long double */\r
+\r
+/* Minimum int x such that FLT_RADIX**(x-1) is a normalised long double */\r
 #define LDBL_MIN_EXP    _PDCLIB_LDBL_MIN_EXP\r
-   /* Minimum normalised long double */\r
+\r
+/* Minimum normalised long double */\r
 #define LDBL_MIN        _PDCLIB_LDBL_MIN\r
-   /* Minimum int x such that 10**x is a normalised long double */\r
+\r
+/* Minimum int x such that 10**x is a normalised long double */\r
 #define LDBL_MIN_10_EXP _PDCLIB_LDBL_MIN_10_EXP\r
-   /* Maximum int x such that FLT_RADIX**(x-1) is a representable long double */\r
+\r
+/* Maximum int x such that FLT_RADIX**(x-1) is a representable long double */\r
 #define LDBL_MAX_EXP    _PDCLIB_LDBL_MAX_EXP\r
-   /* Maximum long double */\r
+\r
+/* Maximum long double */\r
 #define LDBL_MAX        _PDCLIB_LDBL_MAX\r
-   /* Maximum int x such that 10**x is a representable long double */\r
+\r
+/* Maximum int x such that 10**x is a representable long double */\r
 #define LDBL_MAX_10_EXP _PDCLIB_LDBL_MAX_10_EXP\r
 \r
 #endif\r
index 0c6830e6b963bed45279cf9e295c0d7b29716447..f13db1bf8d7b250146be6ecf92a5af6a493e1eae 100644 (file)
@@ -1,4 +1,4 @@
-/* 7.8 Format conversion of integer types <inttypes.h>
+/* Format conversion of integer types <inttypes.h>
 
    This file is part of the Public Domain C Library (PDCLib).
    Permission is granted to use, modify, and / or redistribute at will.
@@ -7,8 +7,15 @@
 #ifndef _PDCLIB_INTTYPES_H
 #define _PDCLIB_INTTYPES_H _PDCLIB_INTTYPES_H
 #include <stdint.h>
-_PDCLIB_BEGIN_EXTERN_C
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* This structure has a member quot and a member rem, of type intmax_t.
+   The order of the members is platform-defined to allow the imaxdiv()
+   function below to be implemented efficiently.
+*/
 typedef struct _PDCLIB_imaxdiv_t imaxdiv_t;
 
 #define PRId8  _PDCLIB_symbol2string( _PDCLIB_concat( _PDCLIB_8_CONV, d ) )
@@ -209,7 +216,7 @@ typedef struct _PDCLIB_imaxdiv_t imaxdiv_t;
 #define SCNxMAX _PDCLIB_symbol2string( _PDCLIB_concat( _PDCLIB_MAX_CONV, x ) )
 #define SCNxPTR _PDCLIB_symbol2string( _PDCLIB_concat( _PDCLIB_PTR_CONV, x ) )
 
-/* 7.8.2 Functions for greatest-width integer types */
+/* Functions for greatest-width integer types */
 
 /* Calculate the absolute value of j */
 intmax_t imaxabs( intmax_t j ) _PDCLIB_nothrow;
@@ -238,14 +245,24 @@ imaxdiv_t imaxdiv( intmax_t numer, intmax_t denom ) _PDCLIB_nothrow;
    respectively, depending on the sign of the integer representation and the
    return type, and errno is set to ERANGE.
 */
-/* This function is equivalent to strtol() / strtoul() in <stdlib.h>, but on
+
+/* These functions are equivalent to strtol() / strtoul() in <stdlib.h>, but on
    the potentially larger type.
 */
 intmax_t strtoimax( const char * _PDCLIB_restrict nptr, char * * _PDCLIB_restrict endptr, int base ) _PDCLIB_nothrow;
 uintmax_t strtoumax( const char * _PDCLIB_restrict nptr, char * * _PDCLIB_restrict endptr, int base ) _PDCLIB_nothrow;
 
-/* TODO: wcstoimax(), wcstoumax() */
+/* These functions are equivalent to wcstol() / wcstoul() in <wchar.h>, but on
+   the potentially larger type.
+*/
+/* TODO: Not _PDCLIB_nothrow? */
+/*
+intmax_t wcstoimax( const _PDCLIB_wchar_t * _PDCLIB_restrict nptr, _PDCLIB_wchar_t * * _PDCLIB_restrict endptr, int base );
+uintmax_t wcstoumax( const _PDCLIB_wchar_t * _PDCLIB_restrict nptr, _PDCLIB_wchar_t * * _PDCLIB_restrict endptr, int base );
+*/
 
-_PDCLIB_END_EXTERN_C
+#ifdef __cplusplus
+}
 #endif
 
+#endif
index 4fd338b383892fccf0c6e912b80cf92f695d87c5..3ad9f5ce484a0f1f1551e9b42ae354769a2df30c 100644 (file)
@@ -1,4 +1,4 @@
-/* 7.9 Alternative spellings <iso646.h>
+/* 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.
@@ -22,4 +22,3 @@
 #endif
 
 #endif
-
index c81ddece55723d928c9566b35b0d5c49bc90830b..e3057051ce87f926b97c50a9fc2ad0dec8492b7c 100644 (file)
@@ -1,4 +1,4 @@
-/* 7.10 Sizes of integer types <limits.h>
+/* 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.
@@ -8,8 +8,13 @@
 #define _PDCLIB_LIMITS_H _PDCLIB_LIMITS_H
 #include <_PDCLIB_int.h>
 
-/* TODO: Defined to 1 as multibyte characters are not supported yet. */
-#define MB_LEN_MAX 1
+/* MSVC 2010 defines this to 5, which is enough for UTF-8 but might rule out
+   stateful encodings (like ISO/IEC 2022). GCC 5.3 defines this to 16, which
+   is meant to ensure future compatibility. For the same reason, we go along
+   with GCC's definition.
+   http://lists.gnu.org/archive/html/bug-gnulib/2015-05/msg00001.html
+*/
+#define MB_LEN_MAX 16
 
 #define LLONG_MIN  _PDCLIB_LLONG_MIN
 #define LLONG_MAX  _PDCLIB_LLONG_MAX
@@ -32,4 +37,3 @@
 #define ULONG_MAX  _PDCLIB_ULONG_MAX
 
 #endif
-
index 351807f4e34b88617a30a40e774a5708c3852137..616e84e948422e0d2f8634e4545eff2b354c90d7 100644 (file)
@@ -1,4 +1,4 @@
-/* 7.11 Localization <locale.h>
+/* Localization <locale.h>
 
    This file is part of the Public Domain C Library (PDCLib).
    Permission is granted to use, modify, and / or redistribute at will.
@@ -7,7 +7,10 @@
 #ifndef _PDCLIB_LOCALE_H
 #define _PDCLIB_LOCALE_H _PDCLIB_LOCALE_H
 #include <_PDCLIB_int.h>
-_PDCLIB_BEGIN_EXTERN_C
+
+#ifdef __cplusplus
+extern "C" {
+#endif
 
 #ifndef _PDCLIB_NULL_DEFINED
 #define _PDCLIB_NULL_DEFINED _PDCLIB_NULL_DEFINED
@@ -95,7 +98,7 @@ struct lconv * localeconv( void ) _PDCLIB_nothrow;
 #define LC_CTYPE_MASK    (1 << LC_CTYPE)
 #define LC_MONETARY_MASK (1 << LC_MONETARY)
 #define LC_NUMERIC_MASK  (1 << LC_NUMERIC)
-#define LC_TIME_MASK     (1 << LC_TIME) 
+#define LC_TIME_MASK     (1 << LC_TIME)
 #define LC_ALL_MASK      (LC_COLLATE_MASK | LC_CTYPE_MASK | LC_MONETARY_MASK | \
                           LC_NUMERIC_MASK | LC_TIME_MASK)
 
@@ -109,30 +112,32 @@ extern struct _PDCLIB_locale _PDCLIB_global_locale;
 
 #ifdef _PDCLIB_LOCALE_METHOD
 
-locale_t newlocale(int category_mask, const char *locale, locale_t base); 
+locale_t newlocale(int category_mask, const char *locale, locale_t base);
 
 /* Set the thread locale to newlocale
  *
  * If newlocale is (locale_t)0, then doesn't change the locale and just returns
  * the existing locale.
  *
- * If newlocale is LC_GLOBAL_LOCALE, resets the thread's locale to use the 
+ * If newlocale is LC_GLOBAL_LOCALE, resets the thread's locale to use the
  * global locale.
  *
- * Returns the previous thread locale. If the thread had no previous locale, 
+ * Returns the previous thread locale. If the thread had no previous locale,
  * returns the global locale.
  */
-locale_t uselocale(locale_t newlocale);
+locale_t uselocale( locale_t newlocale );
 
 /* Returns a copy of loc */
-locale_t duplocale(locale_t loc);
+locale_t duplocale( locale_t loc );
 
 /* Frees the passed locale object */
-void freelocale(locale_t loc);
+void freelocale( locale_t loc );
 #endif
 
 #endif
 
-_PDCLIB_END_EXTERN_C
+#ifdef __cplusplus
+}
 #endif
 
+#endif
diff --git a/includes/stdalign.h b/includes/stdalign.h
new file mode 100644 (file)
index 0000000..0bc20f6
--- /dev/null
@@ -0,0 +1,17 @@
+/* Alignmend <stdalign.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_STDALIGN_H
+#define _PDCLIB_ALIGN_H _PDCLIB_ALIGN_H
+
+#define alignas _Alignas
+#define alignof _Alignof
+
+#define __alignas_is_defined 1
+#define __alignof_is_defined 1
+
+#endif
+
index bbce55ab4360613183143cb3ba4895abd198c81f..cc63123ca5d22076b8d7c363c0539ccffc8ad6cd 100644 (file)
@@ -1,4 +1,4 @@
-/* 7.15 Variable arguments <stdarg.h> 
+/* 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.
@@ -8,7 +8,10 @@
 #define _PDCLIB_STDARG_H _PDCLIB_STDARG_H
 #include <_PDCLIB_aux.h>
 #include <_PDCLIB_config.h>
-_PDCLIB_BEGIN_EXTERN_C
+
+#ifdef __cplusplus
+extern "C" {
+#endif
 
 typedef _PDCLIB_va_list va_list;
 
@@ -17,6 +20,8 @@ typedef _PDCLIB_va_list va_list;
 #define va_end( ap )          _PDCLIB_va_end( ap )
 #define va_start( ap, parmN ) _PDCLIB_va_start( ap, parmN )
 
-_PDCLIB_END_EXTERN_C
+#ifdef __cplusplus
+}
 #endif
 
+#endif
index afe5c74f535808161d58161413654aa476754c5e..daec901e450eb1633cbe183917c5e07918bb62d1 100644 (file)
@@ -1,4 +1,4 @@
-/* 7.16 Boolean type and values <stdbool.h>
+/* 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.
@@ -8,12 +8,11 @@
 #define _PDCLIB_STDBOOL_H _PDCLIB_STDBOOL_H
 
 #ifndef __cplusplus
-#define bool                          _Bool
-#define true                          1
-#define false                         0
+#define bool  _Bool
+#define true  1
+#define false 0
 #endif
 
 #define __bool_true_false_are_defined 1
 
 #endif
-
index d18fcf642a28e36ffe418be5af4529d5efb2617c..f5c91e799f8136e73328091f2d41bd84584a0a46 100644 (file)
@@ -1,4 +1,4 @@
-/* 7.17 Common definitions <stddef.h>
+/* 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.
@@ -8,7 +8,10 @@
 #define _PDCLIB_STDDEF_H _PDCLIB_STDDEF_H
 #include <_PDCLIB_config.h>
 #include <_PDCLIB_int.h>
-_PDCLIB_BEGIN_EXTERN_C
+
+#ifdef __cplusplus
+extern "C" {
+#endif
 
 typedef _PDCLIB_ptrdiff_t ptrdiff_t;
 
@@ -31,6 +34,8 @@ typedef _PDCLIB_wchar_t   wchar_t;
 
 #define offsetof( type, member ) _PDCLIB_offsetof( type, member )
 
-_PDCLIB_END_EXTERN_C
+#ifdef __cplusplus
+}
 #endif
 
+#endif
index 3516b96384637634a80c0e28869a59e0a112ac67..9cb603e4f377af8b3ae102b3e763b1f1b6fde388 100644 (file)
@@ -1,4 +1,4 @@
-/* 7.18 Integer types <stdint.h>
+/* 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.
@@ -8,7 +8,7 @@
 #define _PDCLIB_STDINT_H _PDCLIB_STDINT_H
 #include <_PDCLIB_int.h>
 
-/* 7.18.1.1 Exact-width integer types. */
+/* Exact-width integer types. */
 
 typedef _PDCLIB_int8_t  int8_t;
 typedef _PDCLIB_int16_t int16_t;
@@ -20,24 +20,24 @@ 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 */
+/* Minimum-width integer types */
 
 /* You are allowed to add more types here, e.g. int_least24_t. For the standard
    types, int_leastN_t is equivalent to the corresponding exact type intN_t by
    definition.
 */
 
-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 _PDCLIB_int8_t  int_least8_t;
+typedef _PDCLIB_int16_t int_least16_t;
+typedef _PDCLIB_int32_t int_least32_t;
+typedef _PDCLIB_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;
+typedef _PDCLIB_uint8_t  uint_least8_t;
+typedef _PDCLIB_uint16_t uint_least16_t;
+typedef _PDCLIB_uint32_t uint_least32_t;
+typedef _PDCLIB_uint64_t uint_least64_t;
 
-/* 7.18.1.3 Fastest minimum-width integer types */
+/* Fastest minimum-width integer types */
 
 /* You are allowed to add more types here, e.g. int_fast24_t. */
 
@@ -51,17 +51,17 @@ 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 */
+/* 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 */
+/* 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 */
+/* Limits of specified-width integer types */
 
 #ifdef __cplusplus
 #ifndef __STDC_LIMIT_MACROS
@@ -71,7 +71,7 @@ typedef _PDCLIB_uintmax_t uintmax_t;
 
 #ifndef _PDCLIB_NO_LIMIT_MACROS
 
-/* 7.18.2.1 Limits of exact-width integer types */
+/* Limits of exact-width integer types */
 
 #define INT8_MIN  _PDCLIB_INT8_MIN
 #define INT8_MAX  _PDCLIB_INT8_MAX
@@ -89,7 +89,7 @@ typedef _PDCLIB_uintmax_t uintmax_t;
 #define INT64_MAX  _PDCLIB_INT64_MAX
 #define UINT64_MAX _PDCLIB_UINT64_MAX
 
-/* 7.18.2.2 Limits of minimum-width integer types */
+/* Limits of minimum-width integer types */
 
 /* For the standard widths, least and exact types are equivalent.
    You are allowed to add more types here, e.g. int_least24_t.
@@ -111,7 +111,7 @@ typedef _PDCLIB_uintmax_t uintmax_t;
 #define INT_LEAST64_MAX  INT64_MAX
 #define UINT_LEAST64_MAX UINT64_MAX
 
-/* 7.18.2.3 Limits of fastest minimum-width integer types */
+/* Limits of fastest minimum-width integer types */
 
 #define INT_FAST8_MIN  _PDCLIB_INT_FAST8_MIN
 #define INT_FAST8_MAX  _PDCLIB_INT_FAST8_MAX
@@ -129,19 +129,19 @@ typedef _PDCLIB_uintmax_t uintmax_t;
 #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 */
+/* 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 */
+/* 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 */
+/* Limits of other integer types */
 
 #define PTRDIFF_MIN _PDCLIB_PTRDIFF_MIN
 #define PTRDIFF_MAX _PDCLIB_PTRDIFF_MAX
@@ -162,7 +162,7 @@ typedef _PDCLIB_uintmax_t uintmax_t;
 
 #endif
 
-/* 7.18.4 Macros for integer constants */
+/* Macros for integer constants */
 
 #ifdef __cplusplus
 #ifndef __STDC_CONSTANT_MACROS
@@ -172,7 +172,7 @@ typedef _PDCLIB_uintmax_t uintmax_t;
 
 #ifndef _PDCLIB_NO_CONSTANT_MACROS
 
-/* 7.18.4.1 Macros for minimum-width integer constants */
+/* Macros for minimum-width integer constants */
 
 /* As the minimum-width types - for the required widths of 8, 16, 32, and 64
    bits - are expressed in terms of the exact-width types, the mechanism for
@@ -196,7 +196,7 @@ typedef _PDCLIB_uintmax_t uintmax_t;
 #define UINT32_C( value ) _PDCLIB_concat( value, _PDCLIB_UINT32_LITERAL )
 #define UINT64_C( value ) _PDCLIB_concat( value, _PDCLIB_UINT64_LITERAL )
 
-/* 7.18.4.2 Macros for greatest-width integer constants */
+/* Macros for greatest-width integer constants */
 
 /* Expand to an integer constant of specified value and type intmax_t */
 #define INTMAX_C( value ) _PDCLIB_INTMAX_C( value )
@@ -207,4 +207,3 @@ typedef _PDCLIB_uintmax_t uintmax_t;
 #endif
 
 #endif
-
index 954644bf625d15a8b334181c28809c5dedb2480e..5952ec7087d1e4f3ca19ade4d220416527db1924 100644 (file)
@@ -1,4 +1,4 @@
-/* 7.19 Input/output <stdio.h>
+/* Input/output <stdio.h>
 
    This file is part of the Public Domain C Library (PDCLib).
    Permission is granted to use, modify, and / or redistribute at will.
@@ -7,7 +7,10 @@
 #ifndef _PDCLIB_STDIO_H
 #define _PDCLIB_STDIO_H _PDCLIB_STDIO_H
 #include <_PDCLIB_int.h>
-_PDCLIB_BEGIN_EXTERN_C
+
+#ifdef __cplusplus
+extern "C" {
+#endif
 
 #ifndef _PDCLIB_SIZE_T_DEFINED
 #define _PDCLIB_SIZE_T_DEFINED _PDCLIB_SIZE_T_DEFINED
@@ -886,7 +889,6 @@ void rewind_unlocked( FILE * stream ) _PDCLIB_nothrow;
 int puts_unlocked( const char * s ) _PDCLIB_nothrow;
 int ungetc_unlocked( int c, FILE * stream ) _PDCLIB_nothrow;
 
-
 int printf_unlocked( const char * _PDCLIB_restrict format, ... ) _PDCLIB_nothrow;
 int vprintf_unlocked( const char * _PDCLIB_restrict format, _PDCLIB_va_list arg ) _PDCLIB_nothrow;
 int fprintf_unlocked( FILE * _PDCLIB_restrict stream, const char * _PDCLIB_restrict format, ... ) _PDCLIB_nothrow;
@@ -896,11 +898,13 @@ int vscanf_unlocked( const char * _PDCLIB_restrict format, _PDCLIB_va_list arg )
 int fscanf_unlocked( FILE * _PDCLIB_restrict stream, const char * _PDCLIB_restrict format, ... ) _PDCLIB_nothrow;
 int vfscanf_unlocked( FILE * _PDCLIB_restrict stream, const char * _PDCLIB_restrict format, _PDCLIB_va_list arg ) _PDCLIB_nothrow;
 
-
 // Todo: remove prefix?
 _PDCLIB_uint_fast64_t _PDCLIB_ftell64( FILE * stream ) _PDCLIB_nothrow;
 _PDCLIB_uint_fast64_t _PDCLIB_ftell64_unlocked( FILE * stream ) _PDCLIB_nothrow;
 #endif
 
-_PDCLIB_END_EXTERN_C
+#ifdef __cplusplus
+}
+#endif
+
 #endif
index 9ed464efb237c06d073b88320a34976800c72eab..157ebee3c1c95481f0bfc44ccc0c70c967f73622 100644 (file)
@@ -1,4 +1,4 @@
-/* 7.20 General utilities <stdlib.h>
+/* General utilities <stdlib.h>
 
    This file is part of the Public Domain C Library (PDCLib).
    Permission is granted to use, modify, and / or redistribute at will.
@@ -7,7 +7,10 @@
 #ifndef _PDCLIB_STDLIB_H
 #define _PDCLIB_STDLIB_H _PDCLIB_STDLIB_H
 #include <_PDCLIB_int.h>
-_PDCLIB_BEGIN_EXTERN_C
+
+#ifdef __cplusplus
+extern "C" {
+#endif
 
 #ifndef _PDCLIB_SIZE_T_DEFINED
 #define _PDCLIB_SIZE_T_DEFINED _PDCLIB_SIZE_T_DEFINED
@@ -148,7 +151,7 @@ _PDCLIB_noreturn void abort( void ) _PDCLIB_nothrow;
    reverse order of registration (last-in, first-out).
    Returns zero if registration is successfull, nonzero if it failed.
 */
-int atexit( void (*func)( void ) ) _PDCLIB_nothrow; 
+int atexit( void (*func)( void ) ) _PDCLIB_nothrow;
 
 /* Normal process termination. Functions registered by atexit() (see above) are
    called, streams flushed, files closed and temporary files removed before the
@@ -248,5 +251,8 @@ size_t mbstowcs( wchar_t * _PDCLIB_restrict pwcs, const char * _PDCLIB_restrict
 size_t wcstombs( char * _PDCLIB_restrict s, const wchar_t * _PDCLIB_restrict pwcs, size_t n );
 */
 
-_PDCLIB_END_EXTERN_C
+#ifdef __cplusplus
+}
+#endif
+
 #endif
index fcb1f3dc5cbc7a2e65b91bc40aa877ac0cf15a3e..c0efcaf21738250f937fe97246bea6ee18ff1dca 100644 (file)
@@ -1,4 +1,4 @@
-/* 7.21 String handling <string.h>
+/* String handling <string.h>
 
    This file is part of the Public Domain C Library (PDCLib).
    Permission is granted to use, modify, and / or redistribute at will.
@@ -7,7 +7,10 @@
 #ifndef _PDCLIB_STRING_H
 #define _PDCLIB_STRING_H _PDCLIB_STRING_H
 #include <_PDCLIB_int.h>
-_PDCLIB_BEGIN_EXTERN_C
+
+#ifdef __cplusplus
+extern "C" {
+#endif
 
 #ifndef _PDCLIB_SIZE_T_DEFINED
 #define _PDCLIB_SIZE_T_DEFINED _PDCLIB_SIZE_T_DEFINED
@@ -206,5 +209,8 @@ size_t strlcat(
    size_t _DstSize) _PDCLIB_nothrow;
 #endif
 
-_PDCLIB_END_EXTERN_C
+#ifdef __cplusplus
+}
+#endif
+
 #endif
index 77e39d494f77a579830cd2151ab68a55bf9a31eb..1fd3d1c28fa5eae46bdb2166e0a07ea608ed2691 100644 (file)
-#ifndef _PDCLIB_THREADS_H\r
-#define _PDCLIB_THREADS_H\r
-#include <_PDCLIB_int.h>\r
-#include <_PDCLIB_threadconfig.h>\r
-#include <time.h>\r
-_PDCLIB_BEGIN_EXTERN_C\r
-\r
-#define thread_local _Thread_local\r
-\r
-typedef _PDCLIB_once_flag once_flag;\r
-\r
-enum {\r
-       mtx_plain               = 0,\r
-       mtx_recursive   = (1 << 0),\r
-       mtx_timed               = (1 << 1),\r
-\r
-       _PDCLIB_mtx_valid_mask = mtx_recursive | mtx_timed\r
-};\r
-\r
-enum {\r
-       thrd_success    = 0,\r
-       thrd_timeout    = 1,\r
-       thrd_busy               = 2,\r
-       thrd_error              = 3,\r
-       thrd_nomem              = 4,\r
-};\r
-\r
-#define ONCE_FLAG_INIT _PDCLIB_ONCE_FLAG_INIT\r
-#if defined(_PDCLIB_ONCE_FLAG_IS_DONE)\r
-static inline void call_once(once_flag *flag, void (*func)(void))\r
-{\r
-       if(!_PDCLIB_ONCE_FLAG_IS_DONE(flag)) {\r
-               _PDCLIB_call_once(flag, func);\r
-       }\r
-}\r
-#else\r
-void call_once(once_flag *flag, void (*func)(void));\r
-#endif\r
-\r
-#if defined(_PDCLIB_MTX_T)\r
-typedef _PDCLIB_MTX_T          mtx_t;\r
-void mtx_destroy(mtx_t *mtx) _PDCLIB_nothrow;\r
-int mtx_init(mtx_t *mtx, int type) _PDCLIB_nothrow;\r
-int mtx_lock(mtx_t *mtx) _PDCLIB_nothrow;\r
-int mtx_timedlock(mtx_t *_PDCLIB_restrict mtx, const struct timespec *_PDCLIB_restrict ts) _PDCLIB_nothrow;\r
-int mtx_trylock(mtx_t *mtx) _PDCLIB_nothrow;\r
-int mtx_unlock(mtx_t *mtx) _PDCLIB_nothrow;\r
-#endif\r
-\r
-#if defined(_PDCLIB_CND_T)\r
-typedef _PDCLIB_CND_T          cnd_t;\r
-int cnd_broadcast(cnd_t *cond) _PDCLIB_nothrow;\r
-void cnd_destroy(cnd_t *cond) _PDCLIB_nothrow;\r
-int cnd_init(cnd_t *cond) _PDCLIB_nothrow;\r
-int cnd_signal(cnd_t *cond) _PDCLIB_nothrow;\r
-int cnd_timedwait(cnd_t *_PDCLIB_restrict cond,\r
-       mtx_t *_PDCLIB_restrict mtx,\r
-       const struct timespec *_PDCLIB_restrict ts) _PDCLIB_nothrow;\r
-int cnd_wait(cnd_t *cond, mtx_t *mtx) _PDCLIB_nothrow;\r
-#endif\r
-\r
-#if defined(_PDCLIB_THRD_T)\r
-#define _PDCLIB_THRD_HAVE_MISC\r
-typedef _PDCLIB_THRD_T         thrd_t;\r
-typedef int (*thrd_start_t)(void*);\r
-\r
-int thrd_create(thrd_t *thr, thrd_start_t func, void *arg) _PDCLIB_nothrow;\r
-thrd_t thrd_current(void) _PDCLIB_nothrow;\r
-int thrd_detach(thrd_t thr) _PDCLIB_nothrow;\r
-int thrd_equal(thrd_t thr0, thrd_t thr1) _PDCLIB_nothrow;\r
-\r
-/* Not nothrow: systems may use exceptions at thread exit */\r
-_PDCLIB_noreturn void thrd_exit(int res);\r
-/* Not nothrow: systems may potentially propogate exceptions out of thrd_join?*/\r
-int thrd_join(thrd_t thr, int *res);\r
-#endif\r
-\r
-#if defined(_PDCLIB_THRD_HAVE_MISC)\r
-int thrd_sleep(const struct timespec *duration, struct timespec *remaining) _PDCLIB_nothrow;\r
-void thrd_yield(void) _PDCLIB_nothrow;\r
-#endif\r
-\r
-/* The behaviour of tss_t is woefully underspecified in the C11 standard. In \r
- * particular, it never specifies where/when/<b>if</b> destructors are called.\r
- *\r
- * In lieu of any clarification, we assume the behaviour of POSIX pthread_key_t\r
- */\r
-\r
-#if defined(_PDCLIB_TSS_T)\r
-#define TSS_DTOR_ITERATIONS _PDCLIB_TSS_DTOR_ITERATIONS\r
-\r
-typedef _PDCLIB_TSS_T          tss_t;\r
-typedef void (*tss_dtor_t)(void*);\r
-\r
-int tss_create(tss_t *key, tss_dtor_t dtor) _PDCLIB_nothrow;\r
-void tss_delete(tss_t key) _PDCLIB_nothrow;\r
-void *tss_get(tss_t key) _PDCLIB_nothrow;\r
-int tss_set(tss_t key, void *val) _PDCLIB_nothrow;\r
-#endif\r
-\r
-_PDCLIB_END_EXTERN_C\r
-#endif\r
+/* Threads <threads.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_THREADS_H
+#define _PDCLIB_THREADS_H _PDCLIB_THREADS_H
+#include <_PDCLIB_int.h>
+#include <_PDCLIB_threadconfig.h>
+
+#include <time.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define thread_local _Thread_local
+
+typedef _PDCLIB_once_flag once_flag;
+
+enum
+{
+    mtx_plain       = 0,
+    mtx_recursive   = (1 << 0),
+    mtx_timed       = (1 << 1),
+
+    _PDCLIB_mtx_valid_mask = mtx_recursive | mtx_timed
+};
+
+enum
+{
+    thrd_success    = 0,
+    thrd_timeout    = 1,
+    thrd_busy       = 2,
+    thrd_error      = 3,
+    thrd_nomem      = 4,
+};
+
+#define ONCE_FLAG_INIT _PDCLIB_ONCE_FLAG_INIT
+#ifdef _PDCLIB_ONCE_FLAG_IS_DONE
+static inline void call_once( once_flag * flag, void (*func)( void ) )
+{
+    if ( ! _PDCLIB_ONCE_FLAG_IS_DONE( flag ) )
+    {
+        _PDCLIB_call_once( flag, func );
+    }
+}
+#else
+void call_once( once_flag * flag, void (*func)( void ) );
+#endif
+
+#ifdef _PDCLIB_MTX_T
+typedef _PDCLIB_MTX_T mtx_t;
+void mtx_destroy( mtx_t * mtx ) _PDCLIB_nothrow;
+int mtx_init( mtx_t * mtx, int type ) _PDCLIB_nothrow;
+int mtx_lock( mtx_t * mtx ) _PDCLIB_nothrow;
+int mtx_timedlock( mtx_t * _PDCLIB_restrict mtx, const struct timespec * _PDCLIB_restrict ts ) _PDCLIB_nothrow;
+int mtx_trylock( mtx_t * mtx ) _PDCLIB_nothrow;
+int mtx_unlock( mtx_t * mtx ) _PDCLIB_nothrow;
+#endif
+
+#ifdef _PDCLIB_CND_T
+typedef _PDCLIB_CND_T cnd_t;
+int cnd_broadcast( cnd_t * cond ) _PDCLIB_nothrow;
+void cnd_destroy( cnd_t * cond ) _PDCLIB_nothrow;
+int cnd_init( cnd_t * cond ) _PDCLIB_nothrow;
+int cnd_signal( cnd_t * cond ) _PDCLIB_nothrow;
+int cnd_timedwait( cnd_t *_PDCLIB_restrict cond, mtx_t * _PDCLIB_restrict mtx, const struct timespec * _PDCLIB_restrict ts ) _PDCLIB_nothrow;
+int cnd_wait( cnd_t * cond, mtx_t * mtx ) _PDCLIB_nothrow;
+#endif
+
+#ifdef _PDCLIB_THRD_T
+#define _PDCLIB_THRD_HAVE_MISC
+typedef _PDCLIB_THRD_T thrd_t;
+typedef int (*thrd_start_t)( void * );
+
+int thrd_create( thrd_t * thr, thrd_start_t func, void * arg ) _PDCLIB_nothrow;
+thrd_t thrd_current( void ) _PDCLIB_nothrow;
+int thrd_detach( thrd_t thr ) _PDCLIB_nothrow;
+int thrd_equal( thrd_t thr0, thrd_t thr1 ) _PDCLIB_nothrow;
+
+/* Not nothrow: systems may use exceptions at thread exit */
+_PDCLIB_noreturn void thrd_exit( int res );
+/* Not nothrow: systems may potentially propogate exceptions out of thrd_join? */
+int thrd_join( thrd_t thr, int * res );
+#endif
+
+#ifdef _PDCLIB_THRD_HAVE_MISC
+int thrd_sleep( const struct timespec * duration, struct timespec * remaining ) _PDCLIB_nothrow;
+void thrd_yield( void ) _PDCLIB_nothrow;
+#endif
+
+/* The behaviour of tss_t is woefully underspecified in the C11 standard. In
+   particular, it never specifies where/when/<b>if</b> destructors are called.
+
+   In lieu of any clarification, we assume the behaviour of POSIX pthread_key_t
+*/
+
+#ifdef _PDCLIB_TSS_T
+#define TSS_DTOR_ITERATIONS _PDCLIB_TSS_DTOR_ITERATIONS
+
+typedef _PDCLIB_TSS_T tss_t;
+typedef void (*tss_dtor_t)( void * );
+
+int tss_create( tss_t * key, tss_dtor_t dtor ) _PDCLIB_nothrow;
+void tss_delete( tss_t key ) _PDCLIB_nothrow;
+void * tss_get( tss_t key ) _PDCLIB_nothrow;
+int tss_set( tss_t key, void * val ) _PDCLIB_nothrow;
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
index 41075dbc81c9f71d090db9e878ed9041d24945f1..5d07653e1907ab0deaa881ad000844363c26d860 100644 (file)
@@ -1,36 +1,81 @@
-#ifndef _PDCLIB_TIME_H\r
-#define _PDCLIB_TIME_H\r
-#include <_PDCLIB_aux.h>\r
-#include <_PDCLIB_int.h>\r
-\r
-_PDCLIB_BEGIN_EXTERN_C\r
-#ifndef _PDCLIB_SIZE_T_DEFINED\r
-#define _PDCLIB_SIZE_T_DEFINED _PDCLIB_SIZE_T_DEFINED\r
-typedef _PDCLIB_size_t size_t;\r
-#endif\r
-\r
-#ifndef _PDCLIB_NULL_DEFINED\r
-#define _PDCLIB_NULL_DEFINED _PDCLIB_NULL_DEFINED\r
-#define NULL _PDCLIB_NULL\r
-#endif\r
-\r
-typedef _PDCLIB_time_t  time_t;\r
-typedef _PDCLIB_clock_t clock_t;\r
-\r
-#define TIME_UTC _PDCLIB_TIME_UTC\r
-\r
-#ifndef _PDCLIB_STRUCT_TIMESPEC_DEFINED\r
-#define _PDCLIB_STRUCT_TIMESPEC_DEFINED\r
-_PDCLIB_DEFINE_STRUCT_TIMESPEC()\r
-#endif\r
-\r
-#ifndef _PDCLIB_STRUCT_TM_DEFINED\r
-#define _PDCLIB_STRUCT_TM_DEFINED\r
-_PDCLIB_DEFINE_STRUCT_TM()\r
-#endif\r
-\r
-time_t time( time_t* t ) _PDCLIB_nothrow;\r
-int timespec_get( struct timespec *ts, int base ) _PDCLIB_nothrow;\r
-\r
-_PDCLIB_END_EXTERN_C\r
-#endif\r
+/* Date and time <time.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_TIME_H
+#define _PDCLIB_TIME_H _PDCLIB_TIME_H
+#include <_PDCLIB_aux.h>
+#include <_PDCLIB_int.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef _PDCLIB_SIZE_T_DEFINED
+#define _PDCLIB_SIZE_T_DEFINED _PDCLIB_SIZE_T_DEFINED
+typedef _PDCLIB_size_t size_t;
+#endif
+
+#ifndef _PDCLIB_NULL_DEFINED
+#define _PDCLIB_NULL_DEFINED _PDCLIB_NULL_DEFINED
+#define NULL _PDCLIB_NULL
+#endif
+
+typedef _PDCLIB_time_t  time_t;
+typedef _PDCLIB_clock_t clock_t;
+
+#define CLOCKS_PER_SEC _PDCLIB_CLOCKS_PER_SEC
+#define TIME_UTC _PDCLIB_TIME_UTC
+
+struct timespec
+{
+    time_t tv_sec;
+    long tv_nsec;
+};
+
+struct tm
+{
+    int tm_sec;   /* 0-60 */
+    int tm_min;   /* 0-59 */
+    int tm_hour;  /* 0-23 */
+    int tm_mday;  /* 1-31 */
+    int tm_mon;   /* 0-11 */
+    int tm_year;  /* years since 1900 */
+    int tm_wday;  /* 0-6 */
+    int tm_yday;  /* 0-365 */
+    int tm_isdst; /* >0 DST, 0 no DST, <0 information unavailable */
+};
+
+/* Returns the number of "clocks" in processor time since the invocation
+   of the program. Divide by CLOCKS_PER_SEC to get the value in seconds.
+   Returns -1 if the value cannot be represented in the return type or is
+   not available.
+*/
+clock_t clock( void ) _PDCLIB_nothrow;
+
+/* Returns the difference between two calendar times in seconds. */
+double difftime( time_t time1, time_t time0 ) _PDCLIB_nothrow;
+
+time_t mktime( struct tm * timeptr ) _PDCLIB_nothrow;
+
+time_t time( time_t * timer ) _PDCLIB_nothrow;
+
+int timespec_get( struct timespec * ts, int base ) _PDCLIB_nothrow;
+
+char * asctime( const struct tm * timeptr ) _PDCLIB_nothrow;
+
+char * ctime( const time_t * timer ) _PDCLIB_nothrow;
+
+struct tm * gmtime( const time_t * timer ) _PDCLIB_nothrow;
+
+struct tm * localtime( const time_t * timer ) _PDCLIB_nothrow;
+
+size_t strftime( char * _PDCLIB_restrict s, size_t maxsize, const char * _PDCLIB_restrict format, const struct tm * _PDCLIB_restrict timeptr );
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
index 97210ca61843ef62cbadbc25a82c7c47f0b2f7d5..bcf1eacdc932adbb7a5fa63cbde0ac89d2b399e8 100644 (file)
@@ -1,19 +1,16 @@
-/* 7.28 <uchar.h>
+/* Unicode utilities <uchar.h>
 
  This file is part of the Public Domain C Library (PDCLib).
  Permission is granted to use, modify, and / or redistribute at will.
+ This file is part of the Public Domain C Library (PDCLib).
+ Permission is granted to use, modify, and / or redistribute at will.
 */
 
-
 #ifndef _PDCLIB_UCHAR_H
-#define _PDCLIB_UCHAR_H
+#define _PDCLIB_UCHAR_H _PDCLIB_UCHAR_H
 #include <_PDCLIB_int.h>
-_PDCLIB_BEGIN_EXTERN_C
 
-/* This is mostly a placeholder. for now. This header will be completed by the
- * release of 0.6, but at present merely exposes types needed by the rest of the
- * library
- */
+#ifdef __cplusplus
+extern "C" {
+#endif
 
 #ifndef _PDCLIB_SIZE_T_DEFINED
 #define _PDCLIB_SIZE_T_DEFINED _PDCLIB_SIZE_T_DEFINED
@@ -26,68 +23,46 @@ typedef _PDCLIB_mbstate_t mbstate_t;
 #endif
 
 #ifndef __cplusplus
+
+/* These are built-in types in C++ */
+
 #ifndef _PDCLIB_CHAR16_T_DEFINED
 #define _PDCLIB_CHAR16_T_DEFINED _PDCLIB_CHAR16_T_DEFINED
-typedef _PDCLIB_char16_t char16_t;
+typedef _PDCLIB_uint_least16_t char16_t;
 #endif
 
 #ifndef _PDCLIB_CHAR32_T_DEFINED
 #define _PDCLIB_CHAR32_T_DEFINED _PDCLIB_CHAR32_T_DEFINED
-typedef _PDCLIB_char32_t char32_t;
+typedef _PDCLIB_uint_least32_t char32_t;
 #endif
+
 #endif
 
-size_t mbrtoc16(
-    char16_t    *_PDCLIB_restrict   pc16,
-    const char  *_PDCLIB_restrict   s, 
-    size_t                          n,
-    mbstate_t   *_PDCLIB_restrict   ps);
+size_t mbrtoc16( char16_t * _PDCLIB_restrict pc16, const char * _PDCLIB_restrict s, size_t n, mbstate_t * _PDCLIB_restrict ps );
 
-size_t c16rtomb(
-    char        *_PDCLIB_restrict   s, 
-    char16_t                        c16, 
-    mbstate_t   *_PDCLIB_restrict   ps);
+size_t c16rtomb( char * _PDCLIB_restrict s, char16_t c16, mbstate_t * _PDCLIB_restrict ps );
 
-size_t mbrtoc32(
-    char32_t    *_PDCLIB_restrict   pc32,
-    const char  *_PDCLIB_restrict   s, 
-    size_t                          n,
-    mbstate_t   *_PDCLIB_restrict   ps);
+size_t mbrtoc32( char32_t * _PDCLIB_restrict pc32, const char * _PDCLIB_restrict s, size_t n, mbstate_t * _PDCLIB_restrict ps);
 
-size_t c32rtomb(
-    char        *_PDCLIB_restrict   s, 
-    char32_t                        c32,
-    mbstate_t   *_PDCLIB_restrict   ps);
+size_t c32rtomb( char * _PDCLIB_restrict s, char32_t c32, mbstate_t * _PDCLIB_restrict ps);
 
 #if defined(_PDCLIB_EXTENSIONS)
-/* Analogous to strlen/wcslen */
-size_t _PDCLIB_c16slen(const char16_t * str);
-size_t _PDCLIB_c32slen(const char32_t * str);
+
+/* Analogous to strlen() / wcslen() */
+
+size_t _PDCLIB_c16slen( const char16_t * str );
+
+size_t _PDCLIB_c32slen( const char32_t * str );
 
 /* String generalizations of the above functions */
-size_t _PDCLIB_mbsrtoc16s(
-    char16_t    *_PDCLIB_restrict   dst, 
-    const char **_PDCLIB_restrict   src, 
-    size_t                          len, 
-    mbstate_t   *_PDCLIB_restrict   ps);
-
-size_t _PDCLIB_mbsrtoc32s(
-    char32_t        *_PDCLIB_restrict   dst, 
-    const char     **_PDCLIB_restrict   src, 
-    size_t                              len, 
-    mbstate_t       *_PDCLIB_restrict   ps);
-
-size_t _PDCLIB_c16srtombs(
-    char            *_PDCLIB_restrict   dst, 
-    const char16_t **_PDCLIB_restrict   src, 
-    size_t                              len, 
-    mbstate_t       *_PDCLIB_restrict   ps);
-
-size_t _PDCLIB_c32srtombs(
-    char            *_PDCLIB_restrict   dst, 
-    const char32_t **_PDCLIB_restrict   src, 
-    size_t                              len, 
-    mbstate_t       *_PDCLIB_restrict   ps);
+
+size_t _PDCLIB_mbsrtoc16s( char16_t * _PDCLIB_restrict dst, const char * * _PDCLIB_restrict src, size_t len, mbstate_t * _PDCLIB_restrict ps );
+
+size_t _PDCLIB_mbsrtoc32s( char32_t * _PDCLIB_restrict dst, const char * * _PDCLIB_restrict src, size_t len, mbstate_t * _PDCLIB_restrict ps );
+
+size_t _PDCLIB_c16srtombs( char * _PDCLIB_restrict dst, const char16_t * * _PDCLIB_restrict src, size_t len, mbstate_t * _PDCLIB_restrict ps );
+
+size_t _PDCLIB_c32srtombs( char * _PDCLIB_restrict dst, const char32_t * * _PDCLIB_restrict src, size_t len, mbstate_t * _PDCLIB_restrict ps );
 #endif
 
 #endif
index 83d880b16a9c1091b5dc1c06e3bd127357365eff..ceaf2660c7b54ed252731147a78280785103dd45 100644 (file)
-/* 7. <wchar.h>\r
-\r
-   This file is part of the Public Domain C Library (PDCLib).\r
-   Permission is granted to use, modify, and / or redistribute at will.\r
-*/\r
-\r
-\r
-#ifndef _PDCLIB_WCHAR_H\r
-#define _PDCLIB_WCHAR_H\r
-#include <_PDCLIB_int.h>\r
-_PDCLIB_BEGIN_EXTERN_C\r
-\r
-#ifndef _PDCLIB_SIZE_T_DEFINED\r
-#define _PDCLIB_SIZE_T_DEFINED _PDCLIB_SIZE_T_DEFINED\r
-typedef _PDCLIB_size_t size_t;\r
-#endif\r
-\r
-#ifndef __cplusplus\r
-#ifndef _PDCLIB_WCHAR_T_DEFINED\r
-#define _PDCLIB_WCHAR_T_DEFINED _PDCLIB_WCHAR_T_DEFINED\r
-typedef _PDCLIB_wchar_t wchar_t;\r
-#endif\r
-#endif\r
-\r
-#ifndef _PDCLIB_WINT_T_DEFINED\r
-#define _PDCLIB_WINT_T_DEFINED _PDCLIB_WINT_T_DEFINED\r
-typedef _PDCLIB_wint_t wint_t;\r
-#endif\r
-\r
-#ifndef _PDCLIB_MBSTATE_T_DEFINED\r
-#define _PDCLIB_MBSTATE_T_DEFINED _PDCLIB_MBSTATE_T_DEFINED\r
-typedef _PDCLIB_mbstate_t mbstate_t;\r
-#endif\r
-\r
-struct tm;\r
-\r
-#ifndef _PDCLIB_NULL_DEFINED\r
-#define _PDCLIB_NULL_DEFINED _PDCLIB_NULL_DEFINED\r
-#define NULL _PDCLIB_NULL\r
-#endif\r
-\r
-#ifndef _PDCLIB_WCHAR_MIN_MAX_DEFINED\r
-#define _PDCLIB_WCHAR_MIN_MAX_DEFINED\r
-#define WCHAR_MIN _PDCLIB_WCHAR_MIN\r
-#define WCHAR_MAX _PDCLIB_WCHAR_MAX\r
-#endif\r
-\r
-#ifndef _WEOF\r
-#define WEOF ((wint_t) -1)\r
-#endif\r
-\r
-/* Wide character string handling */\r
-wchar_t *wcscpy(wchar_t *_PDCLIB_restrict s1, const wchar_t *_PDCLIB_restrict s2);\r
-wchar_t *wcsncpy(wchar_t *_PDCLIB_restrict s1, const wchar_t *_PDCLIB_restrict s2, size_t n);\r
-wchar_t *wmemcpy(wchar_t *_PDCLIB_restrict s1, const wchar_t *_PDCLIB_restrict s2, size_t n);\r
-wchar_t *wmemmove(wchar_t *s1, const wchar_t *s2, size_t n);\r
-wchar_t *wcscat(wchar_t *_PDCLIB_restrict s1, const wchar_t *_PDCLIB_restrict s2);\r
-wchar_t *wcsncat(wchar_t *_PDCLIB_restrict s1, const wchar_t *_PDCLIB_restrict s2, size_t n);\r
-int wcscmp(const wchar_t *s1, const wchar_t *s2);\r
-int wcscoll(const wchar_t *s1, const wchar_t *s2);\r
-int wcsncmp(const wchar_t *s1, const wchar_t *s2, size_t n);\r
-size_t wcsxfrm(wchar_t *_PDCLIB_restrict s1, const wchar_t *_PDCLIB_restrict s2, size_t n);\r
-int wmemcmp(const wchar_t *s1, const wchar_t *s2, size_t n);\r
-wchar_t *wcschr(const wchar_t *s, wchar_t c);\r
-size_t wcscspn(const wchar_t *s1, const wchar_t *s2);\r
-wchar_t *wcspbrk(const wchar_t *s1, const wchar_t *s2);\r
-wchar_t *wcsrchr(const wchar_t *s, wchar_t c);\r
-size_t wcsspn(const wchar_t *s1, const wchar_t *s2);\r
-wchar_t *wcsstr(const wchar_t *s1, const wchar_t *s2);\r
-wchar_t *wcstok(wchar_t *_PDCLIB_restrict s1, const wchar_t *_PDCLIB_restrict s2, wchar_t **_PDCLIB_restrict ptr);\r
-wchar_t *wmemchr(const wchar_t *s, wchar_t c, size_t n); \r
-size_t wcslen(const wchar_t *s);\r
-wchar_t *wmemset(wchar_t *s, wchar_t c, size_t n);\r
-\r
-#if 0\r
-size_t wcsftime(wchar_t *_PDCLIB_restrict s, size_t maxsize, const wchar_t *_PDCLIB_restrict format, const struct tm *_PDCLIB_restrict timeptr);\r
-#endif\r
-\r
-/* Wide character I/O */\r
-int fwprintf(_PDCLIB_file_t *_PDCLIB_restrict stream, const wchar_t *_PDCLIB_restrict format, ...);\r
-int fwscanf(_PDCLIB_file_t *_PDCLIB_restrict stream, const wchar_t *_PDCLIB_restrict format, ...);\r
-int swprintf(wchar_t *_PDCLIB_restrict s, size_t n, const wchar_t *_PDCLIB_restrict format, ...);\r
-int swscanf(const wchar_t *_PDCLIB_restrict s, const wchar_t *_PDCLIB_restrict format, ...);\r
-int vfwprintf(_PDCLIB_file_t *_PDCLIB_restrict stream, const wchar_t *_PDCLIB_restrict format, _PDCLIB_va_list arg);\r
-int vfwscanf(_PDCLIB_file_t *_PDCLIB_restrict stream, const wchar_t *_PDCLIB_restrict format, _PDCLIB_va_list arg);\r
-int vswprintf(wchar_t *_PDCLIB_restrict s, size_t n, const wchar_t *_PDCLIB_restrict format, _PDCLIB_va_list arg);\r
-int vswscanf(const wchar_t *_PDCLIB_restrict s, const wchar_t *_PDCLIB_restrict format, _PDCLIB_va_list arg);\r
-int vwprintf(const wchar_t *_PDCLIB_restrict format, _PDCLIB_va_list arg);\r
-int vwscanf(const wchar_t *_PDCLIB_restrict format, _PDCLIB_va_list arg);\r
-int wprintf(const wchar_t *_PDCLIB_restrict format, ...);\r
-int wscanf(const wchar_t *_PDCLIB_restrict format, ...);\r
-wint_t fgetwc(_PDCLIB_file_t *stream);\r
-wchar_t *fgetws(wchar_t *_PDCLIB_restrict s, int n, _PDCLIB_file_t *_PDCLIB_restrict stream);\r
-wint_t fputwc(wchar_t c, _PDCLIB_file_t *stream);\r
-int fputws(const wchar_t *_PDCLIB_restrict s, _PDCLIB_file_t *_PDCLIB_restrict stream);\r
-int fwide(_PDCLIB_file_t *stream, int mode);\r
-wint_t getwc(_PDCLIB_file_t *stream);\r
-wint_t getwchar(void);\r
-wint_t putwc(wchar_t c, _PDCLIB_file_t *stream);\r
-wint_t putwchar(wchar_t c);\r
-wint_t ungetwc(wint_t c, _PDCLIB_file_t *stream);\r
-\r
-#if _PDCLIB_GNU_SOURCE\r
-wint_t getwc_unlocked(_PDCLIB_file_t *stream);\r
-wint_t getwchar_unlocked(void);\r
-wint_t fgetwc_unlocked(_PDCLIB_file_t *stream);\r
-wint_t fputwc_unlocked(wchar_t wc, _PDCLIB_file_t *stream);\r
-wint_t putwc_unlocked(wchar_t wc, _PDCLIB_file_t *stream);\r
-wint_t putwchar_unlocked(wchar_t wc);\r
-wchar_t *fgetws_unlocked(wchar_t *ws, int n, _PDCLIB_file_t *stream);\r
-int fputws_unlocked(const wchar_t *ws, _PDCLIB_file_t *stream);\r
-#endif\r
-\r
-/* Wide character <-> Numeric conversions */\r
-#if 0\r
-double wcstod(const wchar_t *_PDCLIB_restrict nptr, wchar_t **_PDCLIB_restrict endptr);\r
-float wcstof(const wchar_t *_PDCLIB_restrict nptr, wchar_t **_PDCLIB_restrict endptr);\r
-long double wcstold(const wchar_t *_PDCLIB_restrict nptr, wchar_t **_PDCLIB_restrict endptr);\r
-#endif\r
-long int wcstol(const wchar_t *_PDCLIB_restrict nptr, wchar_t **_PDCLIB_restrict endptr, int base);\r
-long long int wcstoll(const wchar_t *_PDCLIB_restrict nptr, wchar_t **_PDCLIB_restrict endptr, int base);\r
-unsigned long int wcstoul(const wchar_t *_PDCLIB_restrict nptr, wchar_t **_PDCLIB_restrict endptr, int base);\r
-unsigned long long int wcstoull(const wchar_t *_PDCLIB_restrict nptr, wchar_t **_PDCLIB_restrict endptr, int base);\r
-\r
-/* Character set conversion */\r
-wint_t btowc(int c);\r
-int wctob(wint_t c);\r
-int mbsinit(const mbstate_t *ps);\r
-size_t mbrlen(const char *_PDCLIB_restrict s, size_t n, mbstate_t *_PDCLIB_restrict ps);\r
-size_t mbrtowc(wchar_t *_PDCLIB_restrict pwc, const char *_PDCLIB_restrict s, size_t n, mbstate_t *_PDCLIB_restrict ps);\r
-size_t wcrtomb(char *_PDCLIB_restrict s, wchar_t wc, mbstate_t *_PDCLIB_restrict ps);\r
-size_t mbsrtowcs(wchar_t *_PDCLIB_restrict dst, const char **_PDCLIB_restrict src, size_t len, mbstate_t *_PDCLIB_restrict ps);\r
-size_t wcsrtombs(char *_PDCLIB_restrict dst, const wchar_t **_PDCLIB_restrict src, size_t len, mbstate_t *_PDCLIB_restrict ps);\r
-\r
-_PDCLIB_END_EXTERN_C\r
-#endif\r
+/* Extended multibyte and wide character utilities <wchar.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_WCHAR_H
+#define _PDCLIB_WCHAR_H _PDCLIB_WCHAR_H
+#include <_PDCLIB_int.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef _PDCLIB_SIZE_T_DEFINED
+#define _PDCLIB_SIZE_T_DEFINED _PDCLIB_SIZE_T_DEFINED
+typedef _PDCLIB_size_t size_t;
+#endif
+
+#ifndef __cplusplus
+
+#ifndef _PDCLIB_WCHAR_T_DEFINED
+#define _PDCLIB_WCHAR_T_DEFINED _PDCLIB_WCHAR_T_DEFINED
+typedef _PDCLIB_wchar_t wchar_t;
+#endif
+
+#endif
+
+#ifndef _PDCLIB_WINT_T_DEFINED
+#define _PDCLIB_WINT_T_DEFINED _PDCLIB_WINT_T_DEFINED
+typedef _PDCLIB_wint_t wint_t;
+#endif
+
+#ifndef _PDCLIB_MBSTATE_T_DEFINED
+#define _PDCLIB_MBSTATE_T_DEFINED _PDCLIB_MBSTATE_T_DEFINED
+typedef _PDCLIB_mbstate_t mbstate_t;
+#endif
+
+struct tm;
+
+#ifndef _PDCLIB_NULL_DEFINED
+#define _PDCLIB_NULL_DEFINED _PDCLIB_NULL_DEFINED
+#define NULL _PDCLIB_NULL
+#endif
+
+#ifndef _PDCLIB_WCHAR_MIN_MAX_DEFINED
+#define _PDCLIB_WCHAR_MIN_MAX_DEFINED _PDCLIB_WCHAR_MIN_MAX_DEFINED
+#define WCHAR_MIN _PDCLIB_WCHAR_MIN
+#define WCHAR_MAX _PDCLIB_WCHAR_MAX
+#endif
+
+#ifndef _PDCLIB_WEOF_DEFINED
+#define _PDCLIB_WEOF_DEFINED _PDCLIB_WEOF_DEFINED
+#define WEOF _PDCLIB_WEOF
+#endif
+
+/* Wide character string handling */
+wchar_t * wcscpy( wchar_t * _PDCLIB_restrict s1, const wchar_t * _PDCLIB_restrict s2 );
+wchar_t * wcsncpy( wchar_t * _PDCLIB_restrict s1, const wchar_t * _PDCLIB_restrict s2, size_t n );
+wchar_t * wmemcpy( wchar_t * _PDCLIB_restrict s1, const wchar_t * _PDCLIB_restrict s2, size_t n );
+wchar_t * wmemmove( wchar_t * s1, const wchar_t * s2, size_t n );
+wchar_t * wcscat( wchar_t * _PDCLIB_restrict s1, const wchar_t * _PDCLIB_restrict s2 );
+wchar_t * wcsncat( wchar_t * _PDCLIB_restrict s1, const wchar_t * _PDCLIB_restrict s2, size_t n );
+int wcscmp( const wchar_t * s1, const wchar_t * s2 );
+int wcscoll( const wchar_t * s1, const wchar_t * s2 );
+int wcsncmp( const wchar_t * s1, const wchar_t * s2, size_t n );
+size_t wcsxfrm( wchar_t * _PDCLIB_restrict s1, const wchar_t * _PDCLIB_restrict s2, size_t n );
+int wmemcmp( const wchar_t * s1, const wchar_t * s2, size_t n );
+wchar_t * wcschr( const wchar_t * s, wchar_t c );
+size_t wcscspn( const wchar_t * s1, const wchar_t * s2 );
+wchar_t * wcspbrk( const wchar_t * s1, const wchar_t * s2 );
+wchar_t * wcsrchr( const wchar_t * s, wchar_t c );
+size_t wcsspn( const wchar_t * s1, const wchar_t * s2 );
+wchar_t * wcsstr( const wchar_t * s1, const wchar_t * s2 );
+wchar_t * wcstok( wchar_t * _PDCLIB_restrict s1, const wchar_t * _PDCLIB_restrict s2, wchar_t * * _PDCLIB_restrict ptr );
+wchar_t * wmemchr( const wchar_t * s, wchar_t c, size_t n );
+size_t wcslen( const wchar_t * s );
+wchar_t * wmemset( wchar_t * s, wchar_t c, size_t n );
+
+#if 0
+size_t wcsftime( wchar_t * _PDCLIB_restrict s, size_t maxsize, const wchar_t * _PDCLIB_restrict format, const struct tm * _PDCLIB_restrict timeptr );
+#endif
+
+/* Wide character I/O */
+int fwprintf( _PDCLIB_file_t * _PDCLIB_restrict stream, const wchar_t * _PDCLIB_restrict format, ... );
+int fwscanf( _PDCLIB_file_t * _PDCLIB_restrict stream, const wchar_t * _PDCLIB_restrict format, ... );
+int swprintf( wchar_t * _PDCLIB_restrict s, size_t n, const wchar_t * _PDCLIB_restrict format, ... );
+int swscanf( const wchar_t * _PDCLIB_restrict s, const wchar_t * _PDCLIB_restrict format, ... );
+int vfwprintf( _PDCLIB_file_t * _PDCLIB_restrict stream, const wchar_t * _PDCLIB_restrict format, _PDCLIB_va_list arg );
+int vfwscanf( _PDCLIB_file_t * _PDCLIB_restrict stream, const wchar_t * _PDCLIB_restrict format, _PDCLIB_va_list arg );
+int vswprintf( wchar_t * _PDCLIB_restrict s, size_t n, const wchar_t * _PDCLIB_restrict format, _PDCLIB_va_list arg );
+int vswscanf( const wchar_t * _PDCLIB_restrict s, const wchar_t * _PDCLIB_restrict format, _PDCLIB_va_list arg );
+int vwprintf( const wchar_t * _PDCLIB_restrict format, _PDCLIB_va_list arg );
+int vwscanf( const wchar_t * _PDCLIB_restrict format, _PDCLIB_va_list arg );
+int wprintf( const wchar_t * _PDCLIB_restrict format, ... );
+int wscanf( const wchar_t * _PDCLIB_restrict format, ... );
+wint_t fgetwc( _PDCLIB_file_t * stream );
+wchar_t * fgetws( wchar_t * _PDCLIB_restrict s, int n, _PDCLIB_file_t * _PDCLIB_restrict stream );
+wint_t fputwc( wchar_t c, _PDCLIB_file_t * stream );
+int fputws( const wchar_t * _PDCLIB_restrict s, _PDCLIB_file_t * _PDCLIB_restrict stream );
+int fwide( _PDCLIB_file_t * stream, int mode );
+wint_t getwc( _PDCLIB_file_t * stream );
+wint_t getwchar( void );
+wint_t putwc( wchar_t c, _PDCLIB_file_t * stream );
+wint_t putwchar( wchar_t c );
+wint_t ungetwc( wint_t c, _PDCLIB_file_t * stream );
+
+#if _PDCLIB_GNU_SOURCE
+wint_t getwc_unlocked( _PDCLIB_file_t * stream );
+wint_t getwchar_unlocked( void );
+wint_t fgetwc_unlocked( _PDCLIB_file_t * stream );
+wint_t fputwc_unlocked( wchar_t wc, _PDCLIB_file_t * stream );
+wint_t putwc_unlocked( wchar_t wc, _PDCLIB_file_t * stream );
+wint_t putwchar_unlocked( wchar_t wc );
+wchar_t * fgetws_unlocked( wchar_t * ws, int n, _PDCLIB_file_t * stream );
+int fputws_unlocked( const wchar_t * ws, _PDCLIB_file_t * stream );
+#endif
+
+/* Wide character <-> Numeric conversions */
+
+/*
+double wcstod( const wchar_t * _PDCLIB_restrict nptr, wchar_t * * _PDCLIB_restrict endptr );
+float wcstof( const wchar_t * _PDCLIB_restrict nptr, wchar_t * * _PDCLIB_restrict endptr );
+long double wcstold( const wchar_t * _PDCLIB_restrict nptr, wchar_t * * _PDCLIB_restrict endptr );
+*/
+
+long int wcstol( const wchar_t * _PDCLIB_restrict nptr, wchar_t * * _PDCLIB_restrict endptr, int base );
+long long int wcstoll( const wchar_t * _PDCLIB_restrict nptr, wchar_t * * _PDCLIB_restrict endptr, int base );
+unsigned long int wcstoul( const wchar_t * _PDCLIB_restrict nptr, wchar_t * * _PDCLIB_restrict endptr, int base );
+unsigned long long int wcstoull( const wchar_t * _PDCLIB_restrict nptr, wchar_t * * _PDCLIB_restrict endptr, int base );
+
+/* Character set conversion */
+wint_t btowc( int c );
+int wctob( wint_t c );
+int mbsinit( const mbstate_t * ps );
+size_t mbrlen( const char * _PDCLIB_restrict s, size_t n, mbstate_t * _PDCLIB_restrict ps );
+size_t mbrtowc( wchar_t * _PDCLIB_restrict pwc, const char * _PDCLIB_restrict s, size_t n, mbstate_t * _PDCLIB_restrict ps );
+size_t wcrtomb( char * _PDCLIB_restrict s, wchar_t wc, mbstate_t * _PDCLIB_restrict ps );
+size_t mbsrtowcs( wchar_t * _PDCLIB_restrict dst, const char * * _PDCLIB_restrict src, size_t len, mbstate_t * _PDCLIB_restrict ps );
+size_t wcsrtombs( char * _PDCLIB_restrict dst, const wchar_t * * _PDCLIB_restrict src, size_t len, mbstate_t * _PDCLIB_restrict ps );
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
index 4d6ed5e2427b63245d3516108bb4b799dbbc8b78..1e4989732e10e67d12dfc9176b6137ff00981323 100644 (file)
@@ -1,47 +1,65 @@
-/* 7.30 Wide Character Classification and Mapping Utilities <wctype.h>\r
-\r
-   This file is part of the Public Domain C Library (PDCLib).\r
-   Permission is granted to use, modify, and / or redistribute at will.\r
-*/\r
-\r
-#ifndef _PDCLIB_WCTYPE_H\r
-#define _PDCLIB_WCTYPE_H _PDCLIB_WCTYPE_H\r
-#include <_PDCLIB_int.h>\r
-_PDCLIB_BEGIN_EXTERN_C\r
-\r
-#ifndef _PDCLIB_WINT_T_DEFINED\r
-#define _PDCLIB_WINT_T_DEFINED _PDCLIB_WINT_T_DEFINED\r
-typedef _PDCLIB_wint_t wint_t;\r
-#endif\r
-\r
-typedef int wctrans_t;\r
-typedef int wctype_t;\r
-\r
-/* 7.30.2.1 Character classification functions */\r
-int iswalnum( wint_t _Wc );\r
-int iswalpha( wint_t _Wc );\r
-int iswblank( wint_t _Wc );\r
-int iswcntrl( wint_t _Wc );\r
-int iswdigit( wint_t _Wc );\r
-int iswgraph( wint_t _Wc );\r
-int iswlower( wint_t _Wc );\r
-int iswprint( wint_t _Wc );\r
-int iswpunct( wint_t _Wc );\r
-int iswspace( wint_t _Wc );\r
-int iswupper( wint_t _Wc );\r
-int iswxdigit( wint_t _Wc );\r
-\r
-/* 7.30.2.2 Extensible character classification functions */\r
-int iswctype( wint_t _Wc, wctype_t _Desc );\r
-wctype_t wctype( const char * _Property );\r
-\r
-/* 7.30.3 Wide character case mapping utilities */\r
-wint_t towlower( wint_t _Wc );\r
-wint_t towupper( wint_t _Wc );\r
-\r
-/* 7.30.3.2 Extensible wide character case mapping functions */\r
-wint_t towctrans( wint_t _Wc, wctrans_t _Desc );\r
-wctrans_t wctrans( const char * _Property );\r
-\r
-_PDCLIB_END_EXTERN_C\r
-#endif // _PDCLIB_WCTYPE_H\r
+/* Wide character classification and mapping utilities <wctype.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_WCTYPE_H
+#define _PDCLIB_WCTYPE_H _PDCLIB_WCTYPE_H
+#include <_PDCLIB_int.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef _PDCLIB_WINT_T_DEFINED
+#define _PDCLIB_WINT_T_DEFINED _PDCLIB_WINT_T_DEFINED
+typedef _PDCLIB_wint_t wint_t;
+#endif
+
+#ifndef _PDCLIB_WEOF_DEFINED
+#define _PDCLIB_WEOF_DEFINED _PDCLIB_WEOF_DEFINED
+#define WEOF _PDCLIB_WEOF
+#endif
+
+/* Scalar type representing locale-specific character mappings */
+typedef int wctrans_t;
+
+/* Scalar type representing locale-specific character classifications */
+typedef int wctype_t;
+
+/* Character classification functions */
+
+int iswalnum( wint_t _Wc );
+int iswalpha( wint_t _Wc );
+int iswblank( wint_t _Wc );
+int iswcntrl( wint_t _Wc );
+int iswdigit( wint_t _Wc );
+int iswgraph( wint_t _Wc );
+int iswlower( wint_t _Wc );
+int iswprint( wint_t _Wc );
+int iswpunct( wint_t _Wc );
+int iswspace( wint_t _Wc );
+int iswupper( wint_t _Wc );
+int iswxdigit( wint_t _Wc );
+
+/* Extensible character classification functions */
+
+int iswctype( wint_t _Wc, wctype_t _Desc );
+wctype_t wctype( const char * _Property );
+
+/* Wide character case mapping utilities */
+
+wint_t towlower( wint_t _Wc );
+wint_t towupper( wint_t _Wc );
+
+/* Extensible wide character case mapping functions */
+
+wint_t towctrans( wint_t _Wc, wctrans_t _Desc );
+wctrans_t wctrans( const char * _Property );
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
index 16e7ed86ce0353b1055da508ed65702eb0125900..8f1cb7fee61dbcbd78ddef3bd7ce3c9e85b3b0b7 100644 (file)
@@ -1,12 +1,12 @@
-#ifndef __PDCLIB_AUX_H
-#define __PDCLIB_AUX_H __PDCLIB_AUX_H
-
 /* 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.
 */
 
+#ifndef __PDCLIB_AUX_H
+#define __PDCLIB_AUX_H __PDCLIB_AUX_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).         */
 #endif
 
 #ifdef __cplusplus
-    #define _PDCLIB_BEGIN_EXTERN_C extern "C" {
-    #define _PDCLIB_END_EXTERN_C }
     typedef bool _PDCLIB_bool;
 #else
-    #define _PDCLIB_BEGIN_EXTERN_C
-    #define _PDCLIB_END_EXTERN_C
     typedef _Bool _PDCLIB_bool;
 #endif
 
index 10f1140c3e73527670d08ab20c246a4ce9572d27..7d893c2d55196f39ab8e7187c5454bb292033f5c 100644 (file)
@@ -6,6 +6,7 @@
 
 #ifndef __PDCLIB_ENCODING_H
 #define __PDCLIB_ENCODING_H __PDCLIB_ENCODING_H
+
 #include <uchar.h>
 
 /* Must be cauued with bufsize >= 1, in != NULL, out != NULL, ps != NULL
index ca34d6566297a09f1cc49c2e93558b0e82c34403..b2944e7cb3d868677d574406a00725b475b69d52 100644 (file)
@@ -1,12 +1,12 @@
-#ifndef __PDCLIB_PDCLIB_FLOAT_H\r
-#define __PDCLIB_PDCLIB_FLOAT_H __PDCLIB_PDCLIB_FLOAT_H\r
-\r
 /* PDCLib internal floating point logic <_PDCLIB_float.h>\r
 \r
    This file is part of the Public Domain C Library (PDCLib).\r
    Permission is granted to use, modify, and / or redistribute at will.\r
 */\r
 \r
+#ifndef __PDCLIB_PDCLIB_FLOAT_H\r
+#define __PDCLIB_PDCLIB_FLOAT_H __PDCLIB_PDCLIB_FLOAT_H\r
+\r
 /* IEEE 754 single precision */\r
 #define _PDCLIB_FP_SINGLE_MIN 1.17549435082228750797e-38\r
 #define _PDCLIB_FP_SINGLE_EPSILON 1.19209289550781250000e-7\r
index 1d978638f8f46cce35c4c188864166b876f61b4f..ef224c70ce5a4c60b996764646fa357c0519b82b 100644 (file)
@@ -1,16 +1,21 @@
-#ifndef __PDCLIB_GLUE_H
-#define __PDCLIB_GLUE_H __PDCLIB_GLUE_H
 /* OS glue functions declaration <_PDCLIB_glue.h>
 
    This file is part of the Public Domain C Library (PDCLib).
    Permission is granted to use, modify, and / or redistribute at will.
 */
 
-#include <_PDCLIB_int.h>
-#include <_PDCLIB_io.h>
+#ifndef __PDCLIB_GLUE_H
+#define __PDCLIB_GLUE_H __PDCLIB_GLUE_H
+
+#include "_PDCLIB_int.h"
+#include "_PDCLIB_io.h"
+
 #include <stdbool.h>
 #include <stddef.h>
-_PDCLIB_BEGIN_EXTERN_C
+
+#ifdef __cplusplus
+extern "C" {
+#endif
 
 /* -------------------------------------------------------------------------- */
 /* OS "glue", part 2                                                          */
@@ -69,5 +74,8 @@ int _PDCLIB_remove( const char * filename );
 */
 int _PDCLIB_rename( const char * old, const char * newn);
 
-_PDCLIB_END_EXTERN_C
+#ifdef __cplusplus
+}
+#endif
+
 #endif
index ab1bc90b777879c03c2a53c25b8aaf323ca93bd9..ecf8f66acc77211a28e12cd05341f6c49e004d23 100644 (file)
@@ -1,12 +1,12 @@
-#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).         */
 #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                                                        */
 /* -------------------------------------------------------------------------- */
@@ -372,6 +364,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                                                                      */
 /* -------------------------------------------------------------------------- */
index 3561b211dcb16d87279ad5c2b6921836f3f4b867..27c33e7dd7a50d360ee58710bacfee8213ed524d 100644 (file)
@@ -1,14 +1,15 @@
-#ifndef __PDCLIB_IO_H\r
-#define __PDCLIB_IO_H __PDCLIB_IO_H\r
-#include "_PDCLIB_int.h"\r
-#include "_PDCLIB_threadconfig.h"\r
-\r
-/* PDCLib internal I/O logic <_PDCLIB_io.h>\r
+/* PDCLib I/O support <_PDCLIB_io.h>\r
 \r
    This file is part of the Public Domain C Library (PDCLib).\r
    Permission is granted to use, modify, and / or redistribute at will.\r
 */\r
 \r
+#ifndef __PDCLIB_IO_H\r
+#define __PDCLIB_IO_H __PDCLIB_IO_H\r
+\r
+#include "_PDCLIB_int.h"\r
+#include "_PDCLIB_threadconfig.h"\r
+\r
 /* Flags for representing mode (see fopen()). Note these must fit the same\r
    status field as the _IO?BF flags in <stdio.h> and the internal flags below.\r
 */\r
index 4595e9b82d5ec074ab1be679a30955c36f9ff28e..da9321eb69f9f07d2fafdd526d744231c96b876d 100644 (file)
@@ -1,6 +1,14 @@
+/* PDCLib locale support <_PDCLIB_locale.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_LOCALE_H
 #define __PDCLIB_LOCALE_H __PDCLIB_LOCALE_H
-#include <_PDCLIB_int.h>
+
+#include "_PDCLIB_int.h"
+
 #include <locale.h>
 #include <wctype.h>
 #include <threads.h>
index ee51d2818246217a11adcc0e258e55b63aba0331..4d13ee5244721daeb21fff7622232887f9bef22b 100644 (file)
@@ -7,9 +7,13 @@
 #ifndef _PDCLIB_CLOCALE_H\r
 #define _PDCLIB_CLOCALE_H _PDCLIB_CLOCALE_H\r
 #include <locale.h>\r
-_PDCLIB_BEGIN_EXTERN_C\r
+#ifdef __cplusplus
+extern "C" {
+#endif\r
 \r
 void _PDCLIB_initclocale( locale_t l );\r
 \r
-_PDCLIB_END_EXTERN_C\r
+#ifdef __cplusplus
+}
+#endif\r
 #endif // _PDCLIB_CLOCALE_H\r
index 3380b5226c989f4b36e8ea0467605a16904a0bc1..516cc360e4eef39725ce3261c72645de6ee3bd80 100644 (file)
@@ -3,7 +3,9 @@
 #include <_PDCLIB_aux.h>\r
 #include <_PDCLIB_config.h>\r
 \r
-_PDCLIB_BEGIN_EXTERN_C\r
+#ifdef __cplusplus
+extern "C" {
+#endif\r
 #define _PDCLIB_ONCE_FLAG_INIT 0\r
 #define _PDCLIB_ONCE_FLAG_IS_DONE(_f) (*(_f) == 1)\r
 typedef char _PDCLIB_once_flag;\r
@@ -20,5 +22,7 @@ struct _PDCLIB_tss {
        void *value;\r
 };\r
 \r
-_PDCLIB_END_EXTERN_C\r
+#ifdef __cplusplus
+}
+#endif\r
 #endif\r
index b855def3d15f14563ae6a2f653af5d815d935b9a..1ca4783a99c4fd81b78e81d5b3d896093a5fc7ab 100644 (file)
@@ -28,5 +28,7 @@ typedef pthread_once_t _PDCLIB_once_flag;
 
 #endif
 
-_PDCLIB_END_EXTERN_C
+#ifdef __cplusplus
+}
+#endif
 #endif
index 3b3feab67ac5b920e76b9f40de4f68901c924b56..ef8f1f64923b728431a0de063806376cb4dbdee9 100644 (file)
@@ -1,4 +1,4 @@
-/* 7.5 Errors <errno.h>
+/* Errors <errno.h>
 
    This file is part of the Public Domain C Library (PDCLib).
    Permission is granted to use, modify, and / or redistribute at will.
@@ -9,7 +9,9 @@
 
 #include <_PDCLIB_int.h>
 
-_PDCLIB_BEGIN_EXTERN_C
+#ifdef __cplusplus
+extern "C" {
+#endif
 
 extern int * _PDCLIB_errno_func( void );
 #define errno (*_PDCLIB_errno_func())
@@ -96,6 +98,8 @@ extern int * _PDCLIB_errno_func( void );
 #define EWOULDBLOCK     _PDCLIB_EWOULDBLOCK
 #define EXDEV           _PDCLIB_EXDEV
 
-_PDCLIB_END_EXTERN_C
+#ifdef __cplusplus
+}
+#endif
 
 #endif
diff --git a/platform/example/functions/signal/signal.c b/platform/example/functions/signal/signal.c
deleted file mode 100644 (file)
index 9d22275..0000000
+++ /dev/null
@@ -1,71 +0,0 @@
-/* signal( int sig, void (*func)( int ) )
-
-   This file is part of the Public Domain C Library (PDCLib).
-   Permission is granted to use, modify, and / or redistribute at will.
-*/
-
-#include <signal.h>
-
-#ifndef REGTEST
-
-#include <stdlib.h>
-#include <errno.h>
-
-void (*_PDCLIB_sigabrt)( int ) = SIG_DFL;
-void (*_PDCLIB_sigfpe)( int )  = SIG_DFL;
-void (*_PDCLIB_sigill)( int )  = SIG_DFL;
-void (*_PDCLIB_sigint)( int )  = SIG_DFL;
-void (*_PDCLIB_sigsegv)( int ) = SIG_DFL;
-void (*_PDCLIB_sigterm)( int ) = SIG_DFL;
-
-void (*signal( int sig, void (*func)( int ) ) )( int )
-{
-    void (*oldhandler)( int );
-    if ( sig <= 0 || func == SIG_ERR )
-    {
-        return SIG_ERR;
-    }
-    switch ( sig )
-    {
-        case SIGABRT:
-            oldhandler = _PDCLIB_sigabrt;
-            _PDCLIB_sigabrt = func;
-            break;
-        case SIGFPE:
-            oldhandler = _PDCLIB_sigfpe;
-            _PDCLIB_sigfpe = func;
-            break;
-        case SIGILL:
-            oldhandler = _PDCLIB_sigill;
-            _PDCLIB_sigill = func;
-            break;
-        case SIGINT:
-            oldhandler = _PDCLIB_sigint;
-            _PDCLIB_sigint = func;
-            break;
-        case SIGSEGV:
-            oldhandler = _PDCLIB_sigsegv;
-            _PDCLIB_sigsegv = func;
-            break;
-        case SIGTERM:
-            oldhandler = _PDCLIB_sigterm;
-            _PDCLIB_sigterm = func;
-            break;
-        default:
-            errno = EINVAL;
-            return SIG_ERR;
-    }
-    return oldhandler;
-}
-
-#endif
-
-#ifdef TEST
-#include <_PDCLIB_test.h>
-
-int main( void )
-{
-    /* Testing covered by raise.c */
-    return TEST_RESULTS;
-}
-#endif
index 2d52993f7a850044da0e10c6a2e1761666c68890..8b30a4fe09053a5deb94a0d4d1a2ad291c016326 100644 (file)
@@ -1,4 +1,4 @@
-/* 7.14 Signal handling <string.h>
+/* Signal handling <string.h>
 
    This file is part of the Public Domain C Library (PDCLib).
    Permission is granted to use, modify, and / or redistribute at will.
diff --git a/platform/gandr/functions/signal/raise.c b/platform/gandr/functions/signal/raise.c
deleted file mode 100644 (file)
index 51c787a..0000000
+++ /dev/null
@@ -1,112 +0,0 @@
-/* raise( int )
-
-   This file is part of the Public Domain C Library (PDCLib).
-   Permission is granted to use, modify, and / or redistribute at will.
-*/
-
-#include <signal.h>
-
-#ifndef REGTEST
-
-#include <stdio.h>
-#include <stdlib.h>
-
-extern void (*_PDCLIB_sigabrt)( int );
-extern void (*_PDCLIB_sigfpe)( int );
-extern void (*_PDCLIB_sigill)( int );
-extern void (*_PDCLIB_sigint)( int );
-extern void (*_PDCLIB_sigsegv)( int );
-extern void (*_PDCLIB_sigterm)( int );
-
-int raise( int sig )
-{
-    void (*sighandler)( int );
-    char const * message;
-    switch ( sig )
-    {
-        case SIGABRT:
-            sighandler = _PDCLIB_sigabrt;
-            message = "Abnormal termination (SIGABRT)";
-            break;
-        case SIGFPE:
-            sighandler = _PDCLIB_sigfpe;
-            message = "Arithmetic exception (SIGFPE)";
-            break;
-        case SIGILL:
-            sighandler = _PDCLIB_sigill;
-            message = "Illegal instruction (SIGILL)";
-            break;
-        case SIGINT:
-            sighandler = _PDCLIB_sigint;
-            message = "Interactive attention signal (SIGINT)";
-            break;
-        case SIGSEGV:
-            sighandler = _PDCLIB_sigsegv;
-            message = "Invalid memory access (SIGSEGV)";
-            break;
-        case SIGTERM:
-            sighandler = _PDCLIB_sigterm;
-            message = "Termination request (SIGTERM)";
-            break;
-        default:
-            fprintf( stderr, "Unknown signal #%d\n", sig );
-            _Exit( EXIT_FAILURE );
-    }
-    if ( sighandler == SIG_DFL )
-    {
-        fputs( message, stderr );
-        _Exit( EXIT_FAILURE );
-    }
-    else if ( sighandler != SIG_IGN )
-    {
-        sighandler = signal( sig, SIG_DFL );
-        sighandler( sig );
-    }
-    return 0;
-}
-
-#endif
-
-#ifdef TEST
-#include <_PDCLIB_test.h>
-
-#include <stdlib.h>
-
-static volatile sig_atomic_t flag = 0;
-
-static int expected_signal = 0;
-
-static void test_handler( int sig )
-{
-    TESTCASE( sig == expected_signal );
-    flag = 1;
-}
-
-int main( void )
-{
-    /* Could be other than SIG_DFL if you changed the implementation. */
-    TESTCASE( signal( SIGABRT, SIG_IGN ) == SIG_DFL );
-    /* Should be ignored. */
-    TESTCASE( raise( SIGABRT ) == 0 );
-    /* Installing test handler, old handler should be returned */
-    TESTCASE( signal( SIGABRT, test_handler ) == SIG_IGN );
-    /* Raising and checking SIGABRT */
-    expected_signal = SIGABRT;
-    TESTCASE( raise( SIGABRT ) == 0 );
-    TESTCASE( flag == 1 );
-    /* Re-installing test handler, should have been reset to default */
-    /* Could be other than SIG_DFL if you changed the implementation. */
-    TESTCASE( signal( SIGABRT, test_handler ) == SIG_DFL );
-    /* Raising and checking SIGABRT */
-    flag = 0;
-    TESTCASE( raise( SIGABRT ) == 0 );
-    TESTCASE( flag == 1 );
-    /* Installing test handler for different signal... */
-    TESTCASE( signal( SIGTERM, test_handler ) == SIG_DFL );
-    /* Raising and checking SIGTERM */
-    expected_signal = SIGTERM;
-    TESTCASE( raise( SIGTERM ) == 0 );
-    TESTCASE( flag == 1 );
-    return TEST_RESULTS;
-}
-#endif
diff --git a/platform/gandr/functions/signal/signal.c b/platform/gandr/functions/signal/signal.c
deleted file mode 100644 (file)
index 9d22275..0000000
+++ /dev/null
@@ -1,71 +0,0 @@
-/* signal( int sig, void (*func)( int ) )
-
-   This file is part of the Public Domain C Library (PDCLib).
-   Permission is granted to use, modify, and / or redistribute at will.
-*/
-
-#include <signal.h>
-
-#ifndef REGTEST
-
-#include <stdlib.h>
-#include <errno.h>
-
-void (*_PDCLIB_sigabrt)( int ) = SIG_DFL;
-void (*_PDCLIB_sigfpe)( int )  = SIG_DFL;
-void (*_PDCLIB_sigill)( int )  = SIG_DFL;
-void (*_PDCLIB_sigint)( int )  = SIG_DFL;
-void (*_PDCLIB_sigsegv)( int ) = SIG_DFL;
-void (*_PDCLIB_sigterm)( int ) = SIG_DFL;
-
-void (*signal( int sig, void (*func)( int ) ) )( int )
-{
-    void (*oldhandler)( int );
-    if ( sig <= 0 || func == SIG_ERR )
-    {
-        return SIG_ERR;
-    }
-    switch ( sig )
-    {
-        case SIGABRT:
-            oldhandler = _PDCLIB_sigabrt;
-            _PDCLIB_sigabrt = func;
-            break;
-        case SIGFPE:
-            oldhandler = _PDCLIB_sigfpe;
-            _PDCLIB_sigfpe = func;
-            break;
-        case SIGILL:
-            oldhandler = _PDCLIB_sigill;
-            _PDCLIB_sigill = func;
-            break;
-        case SIGINT:
-            oldhandler = _PDCLIB_sigint;
-            _PDCLIB_sigint = func;
-            break;
-        case SIGSEGV:
-            oldhandler = _PDCLIB_sigsegv;
-            _PDCLIB_sigsegv = func;
-            break;
-        case SIGTERM:
-            oldhandler = _PDCLIB_sigterm;
-            _PDCLIB_sigterm = func;
-            break;
-        default:
-            errno = EINVAL;
-            return SIG_ERR;
-    }
-    return oldhandler;
-}
-
-#endif
-
-#ifdef TEST
-#include <_PDCLIB_test.h>
-
-int main( void )
-{
-    /* Testing covered by raise.c */
-    return TEST_RESULTS;
-}
-#endif
index bfd17889a9cdfb137e58ba1e3f3504c9c99fd7f6..2f0b6a24dfcc1d0a07734d6f5892933b281ef3aa 100644 (file)
@@ -1,5 +1,6 @@
 #ifndef _PDCLIB_CONFIG_H
 #define _PDCLIB_CONFIG_H
+
 /* Internal PDCLib configuration <_PDCLIB_config.h>
    (Gandr platform)
 
@@ -7,23 +8,41 @@
    Permission is granted to use, modify, and / or redistribute at will.
 */
 
+/* -------------------------------------------------------------------------- */
+/* Misc                                                                       */
+/* -------------------------------------------------------------------------- */
 
-
-/* end of line */
+/* The character (sequence) your platform uses as newline.                    */
 #define _PDCLIB_endl "\n"
 
-/* exit() */
+/* exit() can signal success to the host environment by the value of zero or  */
+/* the constant EXIT_SUCCESS. Failure is signaled by EXIT_FAILURE. Note that  */
+/* any other return value is "implementation-defined", i.e. your environment  */
+/* is not required to handle it gracefully. Set your definitions here.        */
 #define _PDCLIB_SUCCESS 0
 #define _PDCLIB_FAILURE -1
 
-/* trivial memswp */
+/* qsort() in <stdlib.h> requires a function that swaps two memory areas.     */
+/* Below is a naive implementation that can be improved significantly for     */
+/* specific platforms, e.g. by swapping int instead of char.                  */
 #define _PDCLIB_memswp( i, j, size ) char tmp; do { tmp = *i; *i++ = *j; *j++ = tmp; } while ( --size );
 
+/* -------------------------------------------------------------------------- */
+/* 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.                                   */
+/* -------------------------------------------------------------------------- */
 
 #if defined(__arm__)
-  #define _PDCLIB_CHAR_SIGNED 0
+#define _PDCLIB_CHAR_SIGNED 0
 #else
-  #define _PDCLIB_CHAR_SIGNED 1
+#define _PDCLIB_CHAR_SIGNED 1
 #endif
 
 /* Width of the integer types short, int, long, and long long, in bytes.      */
 #define _PDCLIB_SHRT_BYTES  2
 #define _PDCLIB_INT_BYTES 4
 #if defined(__LP64__)
-  #define _PDCLIB_LONG_BYTES 8
+#define _PDCLIB_LONG_BYTES 8
 #else
-  #define _PDCLIB_LONG_BYTES 4
+#define _PDCLIB_LONG_BYTES 4
 #endif
 #define _PDCLIB_LLONG_BYTES 8
 
-/* layout of div_t, ldiv_t, lldiv_t */
-struct _PDCLIB_div_t   { int quot;            int rem; };
-struct _PDCLIB_ldiv_t  { long int quot;       long int rem; };
-struct _PDCLIB_lldiv_t { long long int quot;  long long int rem; };
+/* <stdlib.h> defines the div() function family that allows taking quotient   */
+/* and remainder of an integer division in one operation. Many platforms      */
+/* support this in hardware / opcode, and the standard permits ordering of    */
+/* the return structure in any way to fit the hardware. That is why those     */
+/* structs can be configured here.                                            */
+
+struct _PDCLIB_div_t
+{
+    int quot;
+    int rem;
+};
+
+struct _PDCLIB_ldiv_t
+{
+    long int quot;
+    long int rem;
+};
+
+struct _PDCLIB_lldiv_t
+{
+    long long int quot;
+    long long int rem;
+};
+
+/* -------------------------------------------------------------------------- */
+/* <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).                                          */
+/* The third define is the length modifier used for the type in printf() and  */
+/* scanf() functions (used in <inttypes.h>).                                  */
+/* 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.            */
+/* -------------------------------------------------------------------------- */
 
-/* fast* datatypes. This is a bit of a blunt instrument. */
 #define _PDCLIB_FAST8 CHAR
 #define _PDCLIB_fast8 char
 #define _PDCLIB_FAST8_CONV hh
@@ -60,7 +117,18 @@ struct _PDCLIB_lldiv_t { long long int quot;  long long int rem; };
 #define _PDCLIB_fast64 long long
 #define _PDCLIB_FAST64_CONV ll
 
-/* ptrdiff_t */
+/* -------------------------------------------------------------------------- */
+/* 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 types used for size_t and ptrdiff_t should not have an integer conversion
+   rank greater than that of signed long int unless the implementation supports
+   objects large enough to make this necessary.
+*/
+
+/* Result type of substracting two pointers (must be signed) */
 #define _PDCLIB_ptrdiff long
 #define _PDCLIB_PTRDIFF LONG
 #define _PDCLIB_PTR_CONV l
@@ -69,36 +137,100 @@ struct _PDCLIB_lldiv_t { long long int quot;  long long int rem; };
 #define _PDCLIB_size unsigned long
 #define _PDCLIB_SIZE ULONG
 
-/* intptr_t */
-#define _PDCLIB_intptr long
-#define _PDCLIB_INTPTR LONG
-
-/* sig_atomic_t */
+/* 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 char
 #define _PDCLIB_SIG_ATOMIC CHAR
 
-/* wint_t, wchar_t */
-#define _PDCLIB_wint  signed int
+/* Object type whose alignment is as great as supported by implementation
+   in all contexts.
+*/
+#define _PDCLIB_max_align long double
+
+/* Integer type whose range of values can represent distinct codes for
+   all members of the largest extended character set specified among the
+   supported locales.
+   Note that the definition of this type must agree with the type used
+   by the compiler for L"" string and L'' character literals.
+*/
 #define _PDCLIB_wchar unsigned int
 #define _PDCLIB_WCHAR UINT
 
+/* Each member of the basic character set shall have a code value equal
+   to its value when used as the lone character in an integer character
+   constant. If that is not the case, uncomment the following line.
+#define __STDC_MB_MIGHT_NEQ_WC__
+*/
+
+/* Integer type unchanged by default argument promotions that can hold any
+   value corresponding to characters of the extended character set, as well
+   as at least one value that does not correspond to any member of the
+   extended character set (WEOF).
+*/
+#define _PDCLIB_wint  signed int
+
+#define _PDCLIB_intptr long
+#define _PDCLIB_INTPTR LONG
 
-/* Largest supported integer type */
+/* Largest supported integer type. Implementation note: see _PDCLIB_atomax(). */
 #define _PDCLIB_intmax long long int
 #define _PDCLIB_INTMAX LLONG
 #define _PDCLIB_MAX_CONV ll
+/* You are also required to state the literal suffix for the intmax type      */
 #define _PDCLIB_INTMAX_LITERAL ll
 
-struct _PDCLIB_imaxdiv_t { _PDCLIB_intmax quot; _PDCLIB_intmax rem; };
+/* <inttypes.h> defines imaxdiv(), which is equivalent to the div() function  */
+/* family (see further above) with intmax_t as basis.                         */
 
-/* time_t */
+struct _PDCLIB_imaxdiv_t
+{
+    _PDCLIB_intmax quot;
+    _PDCLIB_intmax rem;
+};
+
+/* <time.h>: time_t
+ * The C standard doesn't define what representation of time is stored in
+ * time_t when returned by time() , but POSIX defines it to be seconds since the
+ * UNIX epoch and most appplications expect that.
+ *
+ * time_t is also used as the tv_sec member of struct timespec, which *is*
+ * defined as a linear count of seconds.
+ *
+ * time_t is defined as a "real type", so may be a floating point type, but with
+ * the presence of the nanosecond accurate struct timespec, and with the lack of
+ * any functions for manipulating more accurate values of time_t, this is
+ * probably not useful.
+ */
 #define _PDCLIB_time  unsigned long long
 
-/* clock_t */
+/* <time.h>: clock_t
+ *
+ * A count of "clock ticks", where the length of a clock tick is unspecified by
+ * the standard. The implementation is required to provide a macro,
+ * CLOCKS_PER_SEC, which is the number of "clock ticks" which corresponds to one
+ * second.
+ *
+ * clock_t may be any real type (i.e. integral or floating), and its type on
+ * various systems differs.
+ *
+ * On XSI systems, CLOCKS_PER_SEC must be defined to 1000000
+ */
 #define _PDCLIB_clock unsigned
 #define _PDCLIB_CLOCKS_PER_SEC 1000000
 
-/* timespec_get */
+/* <time.h>: TIME_UTC
+ *
+ * The TIME_UTC parameter is passed to the timespec_get function in order to get
+ * the system time in UTC since an implementation defined epoch (not necessarily
+ * the same as that used for time_t). That said, on POSIX the obvious
+ * implementation of timespec_get for TIME_UTC is to wrap
+ * clock_gettime(CLOCK_REALTIME, ...), which is defined as time in UTC since the
+ * same epoch.
+ *
+ * This may be any non-zero integer value.
+ */
 #define _PDCLIB_TIME_UTC 1
 
 /* -------------------------------------------------------------------------- */
@@ -139,29 +271,52 @@ struct _PDCLIB_imaxdiv_t { _PDCLIB_intmax quot; _PDCLIB_intmax rem; };
 #define _PDCLIB_FLOAT_TYPE   SINGLE
 #define _PDCLIB_DOUBLE_TYPE  DOUBLE
 #if defined(__i386__) || defined(__amd64__)
-  #define _PDCLIB_LDOUBLE_TYPE EXTENDED
+#define _PDCLIB_LDOUBLE_TYPE EXTENDED
 #else
-  #define _PDCLIB_LDOUBLE_TYPE DOUBLE
+#define _PDCLIB_LDOUBLE_TYPE DOUBLE
 #endif
 
 /* -------------------------------------------------------------------------- */
 /* Platform-dependent macros defined by the standard headers.                 */
 /* -------------------------------------------------------------------------- */
 
-/* offsetof */
+/* 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 ) __builtin_offsetof( type, member )
 
-/* stdarg.h */
+/* 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.
+*/
+
 typedef __builtin_va_list _PDCLIB_va_list;
 #define _PDCLIB_va_arg( ap, type ) (__builtin_va_arg( (ap), type ))
 #define _PDCLIB_va_copy( dest, src ) (__builtin_va_copy( (dest), (src) ))
 #define _PDCLIB_va_end( ap ) (__builtin_va_end( ap ) )
 #define _PDCLIB_va_start( ap, parmN ) (__builtin_va_start( (ap), (parmN) ))
 
-/* "OS glue" */
+/* -------------------------------------------------------------------------- */
+/* OS "glue", part 1                                                          */
+/* These are values and data type definitions that you would have to adapt to */
+/* the capabilities and requirements of your OS.                              */
+/* The actual *functions* of the OS interface are declared in _PDCLIB_glue.h. */
+/* -------------------------------------------------------------------------- */
 
 /* Memory management -------------------------------------------------------- */
 
+/* Set this to the page size of your OS. If your OS does not support paging, set
+   to an appropriate value. (Too small, and malloc() will call the kernel too
+   often. Too large, and you will waste memory.)
+*/
 #define _PDCLIB_MALLOC_PAGESIZE 4096
 #define _PDCLIB_MALLOC_ALIGN 16
 #define _PDCLIB_MALLOC_GRANULARITY 4096
@@ -169,11 +324,13 @@ typedef __builtin_va_list _PDCLIB_va_list;
 #define _PDCLIB_MALLOC_MMAP_THRESHOLD 256*1024
 #define _PDCLIB_MALLOC_RELEASE_CHECK_RATE 4095
 
+/* TODO: Better document these */
+
 /* Locale --------------------------------------------------------------------*/
 
 /* Locale method. See _PDCLIB_locale.h. If undefined, POSIX per-thread locales
* will be disabled
- */
  will be disabled
+*/
 /* #define _PDCLIB_LOCALE_METHOD _PDCLIB_LOCALE_METHOD_TSS */
 
 /* wchar_t encoding */
@@ -201,17 +358,50 @@ typedef __builtin_va_list _PDCLIB_va_list;
 /* Number of distinct file names that can be generated by tmpnam(). */
 #define _PDCLIB_TMP_MAX 50
 
-/* SEEK_SET, CUR, END */
+/* The values of SEEK_SET, SEEK_CUR and SEEK_END, used by fseek().
+   Since at least one platform (POSIX) uses the same symbols for its own "seek"
+   function, we use whatever the host defines (if it does define them).
+*/
 #define _PDCLIB_SEEK_SET 0
 #define _PDCLIB_SEEK_CUR 1
 #define _PDCLIB_SEEK_END 2
 
-/* How much can you ungetc? Not much, thankfully */
+/* The number of characters that can be buffered with ungetc(). The standard
+   guarantees only one (1); anything larger would make applications relying on
+   this capability dependent on implementation-defined behaviour (not good).
+*/
 #define _PDCLIB_UNGETCBUFSIZE 1
 
 /* errno -------------------------------------------------------------------- */
 
-/* errno values as per C++11 */
+/* These are the values that _PDCLIB_errno can be set to by the library.
+
+   By keeping PDCLib's errno in the _PDCLIB_* namespace, the library is capable
+   to "translate" between errno values used by the hosting operating system and
+   those used and passed out by the library.
+
+   Example: In the example platform, the remove() function uses the unlink()
+   system call as backend. Linux sets its errno to EISDIR if you try to unlink()
+   a directory, but POSIX demands EPERM. Within the remove() function, you can
+   catch the 'errno == EISDIR', and set '_PDCLIB_errno = _PDCLIB_EPERM'. Anyone
+   using PDCLib's <errno.h> will "see" EPERM instead of EISDIR (the _PDCLIB_*
+   prefix removed by <errno.h> mechanics).
+
+   If you do not want that kind of translation, you might want to "match" the
+   values used by PDCLib with those used by the host OS, as to avoid confusion.
+
+   The C standard only defines three distinct errno values: ERANGE, EDOM, and
+   EILSEQ. The standard leaves it up to "the implementation" whether there are
+   any more beyond those three.
+
+   However, C++11 introduced the whole list of POSIX errno values into the
+   standard, so PDCLib might as well define those as well.
+
+   Sometimes the standard says to set errno to indicate an error, but does not
+   prescribe a value. We will use a value from the following list. If POSIX
+   defines a value, we use that; otherwise, we use as seems suitable.
+*/
+
 #define _PDCLIB_ERANGE             1
 #define _PDCLIB_EDOM               2
 #define _PDCLIB_EILSEQ             3
index 8e6df09e0fe8b253842509a8684e53d154161cfb..68da2140306e52613be01388d87a236986cc2648 100644 (file)
@@ -1,4 +1,4 @@
-/* 7.14 Signal handling <string.h>
+/* Signal handling <string.h>
 
    This file is part of the Public Domain C Library (PDCLib).
    Permission is granted to use, modify, and / or redistribute at will.
diff --git a/platform/posix/functions/signal/raise.c b/platform/posix/functions/signal/raise.c
deleted file mode 100644 (file)
index 51c787a..0000000
+++ /dev/null
@@ -1,112 +0,0 @@
-/* raise( int )
-
-   This file is part of the Public Domain C Library (PDCLib).
-   Permission is granted to use, modify, and / or redistribute at will.
-*/
-
-#include <signal.h>
-
-#ifndef REGTEST
-
-#include <stdio.h>
-#include <stdlib.h>
-
-extern void (*_PDCLIB_sigabrt)( int );
-extern void (*_PDCLIB_sigfpe)( int );
-extern void (*_PDCLIB_sigill)( int );
-extern void (*_PDCLIB_sigint)( int );
-extern void (*_PDCLIB_sigsegv)( int );
-extern void (*_PDCLIB_sigterm)( int );
-
-int raise( int sig )
-{
-    void (*sighandler)( int );
-    char const * message;
-    switch ( sig )
-    {
-        case SIGABRT:
-            sighandler = _PDCLIB_sigabrt;
-            message = "Abnormal termination (SIGABRT)";
-            break;
-        case SIGFPE:
-            sighandler = _PDCLIB_sigfpe;
-            message = "Arithmetic exception (SIGFPE)";
-            break;
-        case SIGILL:
-            sighandler = _PDCLIB_sigill;
-            message = "Illegal instruction (SIGILL)";
-            break;
-        case SIGINT:
-            sighandler = _PDCLIB_sigint;
-            message = "Interactive attention signal (SIGINT)";
-            break;
-        case SIGSEGV:
-            sighandler = _PDCLIB_sigsegv;
-            message = "Invalid memory access (SIGSEGV)";
-            break;
-        case SIGTERM:
-            sighandler = _PDCLIB_sigterm;
-            message = "Termination request (SIGTERM)";
-            break;
-        default:
-            fprintf( stderr, "Unknown signal #%d\n", sig );
-            _Exit( EXIT_FAILURE );
-    }
-    if ( sighandler == SIG_DFL )
-    {
-        fputs( message, stderr );
-        _Exit( EXIT_FAILURE );
-    }
-    else if ( sighandler != SIG_IGN )
-    {
-        sighandler = signal( sig, SIG_DFL );
-        sighandler( sig );
-    }
-    return 0;
-}
-
-#endif
-
-#ifdef TEST
-#include <_PDCLIB_test.h>
-
-#include <stdlib.h>
-
-static volatile sig_atomic_t flag = 0;
-
-static int expected_signal = 0;
-
-static void test_handler( int sig )
-{
-    TESTCASE( sig == expected_signal );
-    flag = 1;
-}
-
-int main( void )
-{
-    /* Could be other than SIG_DFL if you changed the implementation. */
-    TESTCASE( signal( SIGABRT, SIG_IGN ) == SIG_DFL );
-    /* Should be ignored. */
-    TESTCASE( raise( SIGABRT ) == 0 );
-    /* Installing test handler, old handler should be returned */
-    TESTCASE( signal( SIGABRT, test_handler ) == SIG_IGN );
-    /* Raising and checking SIGABRT */
-    expected_signal = SIGABRT;
-    TESTCASE( raise( SIGABRT ) == 0 );
-    TESTCASE( flag == 1 );
-    /* Re-installing test handler, should have been reset to default */
-    /* Could be other than SIG_DFL if you changed the implementation. */
-    TESTCASE( signal( SIGABRT, test_handler ) == SIG_DFL );
-    /* Raising and checking SIGABRT */
-    flag = 0;
-    TESTCASE( raise( SIGABRT ) == 0 );
-    TESTCASE( flag == 1 );
-    /* Installing test handler for different signal... */
-    TESTCASE( signal( SIGTERM, test_handler ) == SIG_DFL );
-    /* Raising and checking SIGTERM */
-    expected_signal = SIGTERM;
-    TESTCASE( raise( SIGTERM ) == 0 );
-    TESTCASE( flag == 1 );
-    return TEST_RESULTS;
-}
-#endif
index 2d52993f7a850044da0e10c6a2e1761666c68890..8b30a4fe09053a5deb94a0d4d1a2ad291c016326 100644 (file)
@@ -1,4 +1,4 @@
-/* 7.14 Signal handling <string.h>
+/* Signal handling <string.h>
 
    This file is part of the Public Domain C Library (PDCLib).
    Permission is granted to use, modify, and / or redistribute at will.
index 5b71195e33d227db0ceaf2775efb16eff969316b..a9dc26f5036f91387fc3805e1d2614977ddf7531 100644 (file)
@@ -48,9 +48,9 @@
 #define _PDCLIB_SHRT_BYTES  2
 #define _PDCLIB_INT_BYTES   4
 #if defined(_LP64) || defined(__ILP64__)
-    #define _PDCLIB_LONG_BYTES 8
+#define _PDCLIB_LONG_BYTES 8
 #else
-    #define _PDCLIB_LONG_BYTES 4
+#define _PDCLIB_LONG_BYTES 4
 #endif
 #define _PDCLIB_LLONG_BYTES 8
 
@@ -129,11 +129,20 @@ struct _PDCLIB_lldiv_t
 /* defines here are merely "configuration". See above for details.            */
 /* -------------------------------------------------------------------------- */
 
-/* The result type of substracting two pointers */
+/* The types used for size_t and ptrdiff_t should not have an integer conversion
+   rank greater than that of signed long int unless the implementation supports
+   objects large enough to make this necessary.
+*/
+
+/* Result type of substracting two pointers (must be signed) */
 #define _PDCLIB_ptrdiff long
 #define _PDCLIB_PTRDIFF LONG
 #define _PDCLIB_PTR_CONV l
 
+/* Result type of the 'sizeof' operator (must be unsigned) */
+#define _PDCLIB_size unsigned long
+#define _PDCLIB_SIZE ULONG
+
 /* 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.)
@@ -141,16 +150,37 @@ struct _PDCLIB_lldiv_t
 #define _PDCLIB_sig_atomic int
 #define _PDCLIB_SIG_ATOMIC INT
 
-/* Result type of the 'sizeof' operator (must be unsigned) */
-#define _PDCLIB_size unsigned long
-#define _PDCLIB_SIZE ULONG
+/* Object type whose alignment is as great as supported by implementation
+   in all contexts.
+*/
+#define _PDCLIB_max_align long double
 
-/* Large enough an integer to hold all character codes of the largest supported
-   locale.
+/* Integer type whose range of values can represent distinct codes for
+   all members of the largest extended character set specified among the
+   supported locales.
+   Note that the definition of this type must agree with the type used
+   by the compiler for L"" string and L'' character literals.
 */
-#define _PDCLIB_wint  int
+#if defined(_LP64) || defined(__ILP64__)
 #define _PDCLIB_wchar int
 #define _PDCLIB_WCHAR INT
+#else
+#define _PDCLIB_wchar long
+#define _PDCLIB_WCHAR LONG
+#endif
+
+/* Each member of the basic character set shall have a code value equal
+   to its value when used as the lone character in an integer character
+   constant. If that is not the case, uncomment the following line.
+#define __STDC_MB_MIGHT_NEQ_WC__
+*/
+
+/* Integer type unchanged by default argument promotions that can hold any
+   value corresponding to characters of the extended character set, as well
+   as at least one value that does not correspond to any member of the
+   extended character set (WEOF).
+*/
+#define _PDCLIB_wint  int
 
 #define _PDCLIB_intptr long
 #define _PDCLIB_INTPTR LONG
@@ -184,7 +214,7 @@ struct _PDCLIB_imaxdiv_t
  * any functions for manipulating more accurate values of time_t, this is
  * probably not useful.
  */
-#define _PDCLIB_time  long
+#define _PDCLIB_time long
 
 /* <time.h>: clock_t
  *
@@ -268,9 +298,9 @@ struct _PDCLIB_imaxdiv_t
    most compilers.
 */
 #ifdef __GNUC__
-  #define _PDCLIB_offsetof( type, member ) __builtin_offsetof( type, member )
+#define _PDCLIB_offsetof( type, member ) __builtin_offsetof( type, member )
 #else
-  #define _PDCLIB_offsetof( type, member ) ( (size_t) &( ( (type *) 0 )->member ) )
+#define _PDCLIB_offsetof( type, member ) ( (size_t) &( ( (type *) 0 )->member ) )
 #endif
 
 /* Variable Length Parameter List Handling (<stdarg.h>)
@@ -280,22 +310,21 @@ struct _PDCLIB_imaxdiv_t
 */
 
 #ifdef __GNUC__
-  typedef __builtin_va_list _PDCLIB_va_list;
-  #define _PDCLIB_va_arg( ap, type ) (__builtin_va_arg( (ap), type ))
-  #define _PDCLIB_va_copy( dest, src ) (__builtin_va_copy( (dest), (src) ))
-  #define _PDCLIB_va_end( ap ) (__builtin_va_end( ap ) )
-  #define _PDCLIB_va_start( ap, parmN ) (__builtin_va_start( (ap), (parmN) ))
+typedef __builtin_va_list _PDCLIB_va_list;
+#define _PDCLIB_va_arg( ap, type ) (__builtin_va_arg( (ap), type ))
+#define _PDCLIB_va_copy( dest, src ) (__builtin_va_copy( (dest), (src) ))
+#define _PDCLIB_va_end( ap ) (__builtin_va_end( ap ) )
+#define _PDCLIB_va_start( ap, parmN ) (__builtin_va_start( (ap), (parmN) ))
 #elif (defined(__i386__) || defined(__i386) || defined(_M_IX86)) && !(defined(__amd64__) || defined(__x86_64__) || defined(_M_AMD64))
-  /* 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 )
+/* 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 )
 #else
-  #error Compiler/Architecture support please
+#error Compiler/Architecture support please
 #endif
 
 /* -------------------------------------------------------------------------- */
@@ -322,7 +351,9 @@ struct _PDCLIB_imaxdiv_t
 
 /* Locale --------------------------------------------------------------------*/
 
-/* Locale method. See _PDCLIB_locale.h */
+/* Locale method. See _PDCLIB_locale.h. If undefined, POSIX per-thread locales
+   will be disabled.
+*/
 #define _PDCLIB_LOCALE_METHOD _PDCLIB_LOCALE_METHOD_TSS
 
 /* wchar_t encoding */
@@ -379,7 +410,7 @@ struct _PDCLIB_imaxdiv_t
    prefix removed by <errno.h> mechanics).
 
    If you do not want that kind of translation, you might want to "match" the
-   values used by PDCLib with those used by the host OS, to avoid confusion.
+   values used by PDCLib with those used by the host OS, as to avoid confusion.
 
    The C standard only defines three distinct errno values: ERANGE, EDOM, and
    EILSEQ. The standard leaves it up to "the implementation" whether there are
@@ -388,8 +419,8 @@ struct _PDCLIB_imaxdiv_t
    However, C++11 introduced the whole list of POSIX errno values into the
    standard, so PDCLib might as well define those as well.
 
-   Sometimes the standard says to set errno to indicate an error, but does not 
-   prescribe a value. We will use a value from the following list. If POSIX 
+   Sometimes the standard says to set errno to indicate an error, but does not
+   prescribe a value. We will use a value from the following list. If POSIX
    defines a value, we use that; otherwise, we use as seems suitable.
 */
 
diff --git a/platform/win32/functions/signal/raise.c b/platform/win32/functions/signal/raise.c
deleted file mode 100644 (file)
index 51c787a..0000000
+++ /dev/null
@@ -1,112 +0,0 @@
-/* raise( int )
-
-   This file is part of the Public Domain C Library (PDCLib).
-   Permission is granted to use, modify, and / or redistribute at will.
-*/
-
-#include <signal.h>
-
-#ifndef REGTEST
-
-#include <stdio.h>
-#include <stdlib.h>
-
-extern void (*_PDCLIB_sigabrt)( int );
-extern void (*_PDCLIB_sigfpe)( int );
-extern void (*_PDCLIB_sigill)( int );
-extern void (*_PDCLIB_sigint)( int );
-extern void (*_PDCLIB_sigsegv)( int );
-extern void (*_PDCLIB_sigterm)( int );
-
-int raise( int sig )
-{
-    void (*sighandler)( int );
-    char const * message;
-    switch ( sig )
-    {
-        case SIGABRT:
-            sighandler = _PDCLIB_sigabrt;
-            message = "Abnormal termination (SIGABRT)";
-            break;
-        case SIGFPE:
-            sighandler = _PDCLIB_sigfpe;
-            message = "Arithmetic exception (SIGFPE)";
-            break;
-        case SIGILL:
-            sighandler = _PDCLIB_sigill;
-            message = "Illegal instruction (SIGILL)";
-            break;
-        case SIGINT:
-            sighandler = _PDCLIB_sigint;
-            message = "Interactive attention signal (SIGINT)";
-            break;
-        case SIGSEGV:
-            sighandler = _PDCLIB_sigsegv;
-            message = "Invalid memory access (SIGSEGV)";
-            break;
-        case SIGTERM:
-            sighandler = _PDCLIB_sigterm;
-            message = "Termination request (SIGTERM)";
-            break;
-        default:
-            fprintf( stderr, "Unknown signal #%d\n", sig );
-            _Exit( EXIT_FAILURE );
-    }
-    if ( sighandler == SIG_DFL )
-    {
-        fputs( message, stderr );
-        _Exit( EXIT_FAILURE );
-    }
-    else if ( sighandler != SIG_IGN )
-    {
-        sighandler = signal( sig, SIG_DFL );
-        sighandler( sig );
-    }
-    return 0;
-}
-
-#endif
-
-#ifdef TEST
-#include <_PDCLIB_test.h>
-
-#include <stdlib.h>
-
-static volatile sig_atomic_t flag = 0;
-
-static int expected_signal = 0;
-
-static void test_handler( int sig )
-{
-    TESTCASE( sig == expected_signal );
-    flag = 1;
-}
-
-int main( void )
-{
-    /* Could be other than SIG_DFL if you changed the implementation. */
-    TESTCASE( signal( SIGABRT, SIG_IGN ) == SIG_DFL );
-    /* Should be ignored. */
-    TESTCASE( raise( SIGABRT ) == 0 );
-    /* Installing test handler, old handler should be returned */
-    TESTCASE( signal( SIGABRT, test_handler ) == SIG_IGN );
-    /* Raising and checking SIGABRT */
-    expected_signal = SIGABRT;
-    TESTCASE( raise( SIGABRT ) == 0 );
-    TESTCASE( flag == 1 );
-    /* Re-installing test handler, should have been reset to default */
-    /* Could be other than SIG_DFL if you changed the implementation. */
-    TESTCASE( signal( SIGABRT, test_handler ) == SIG_DFL );
-    /* Raising and checking SIGABRT */
-    flag = 0;
-    TESTCASE( raise( SIGABRT ) == 0 );
-    TESTCASE( flag == 1 );
-    /* Installing test handler for different signal... */
-    TESTCASE( signal( SIGTERM, test_handler ) == SIG_DFL );
-    /* Raising and checking SIGTERM */
-    expected_signal = SIGTERM;
-    TESTCASE( raise( SIGTERM ) == 0 );
-    TESTCASE( flag == 1 );
-    return TEST_RESULTS;
-}
-#endif
diff --git a/platform/win32/functions/signal/signal.c b/platform/win32/functions/signal/signal.c
deleted file mode 100644 (file)
index dc0b8ce..0000000
+++ /dev/null
@@ -1,74 +0,0 @@
-/* signal( int sig, void (*func)( int ) )
-
-   This file is part of the Public Domain C Library (PDCLib).
-   Permission is granted to use, modify, and / or redistribute at will.
-*/
-
-#include <signal.h>
-#include <errno.h>
-
-#ifndef REGTEST
-
-#include <stdlib.h>
-
-void (*_PDCLIB_sigabrt)( int ) = SIG_DFL;
-void (*_PDCLIB_sigfpe)( int )  = SIG_DFL;
-void (*_PDCLIB_sigill)( int )  = SIG_DFL;
-void (*_PDCLIB_sigint)( int )  = SIG_DFL;
-void (*_PDCLIB_sigsegv)( int ) = SIG_DFL;
-void (*_PDCLIB_sigterm)( int ) = SIG_DFL;
-
-void (*signal( int sig, void (*func)( int ) ) )( int )
-{
-    void (*oldhandler)( int );
-    if ( sig <= 0 || func == SIG_ERR )
-    {
-        return SIG_ERR;
-    }
-    switch ( sig )
-    {
-        case SIGABRT:
-            oldhandler = _PDCLIB_sigabrt;
-            _PDCLIB_sigabrt = func;
-            break;
-        case SIGFPE:
-            oldhandler = _PDCLIB_sigfpe;
-            _PDCLIB_sigfpe = func;
-            break;
-        case SIGILL:
-            oldhandler = _PDCLIB_sigill;
-            _PDCLIB_sigill = func;
-            break;
-        case SIGINT:
-            oldhandler = _PDCLIB_sigint;
-            _PDCLIB_sigint = func;
-            break;
-        case SIGSEGV:
-            oldhandler = _PDCLIB_sigsegv;
-            _PDCLIB_sigsegv = func;
-            break;
-        case SIGTERM:
-            oldhandler = _PDCLIB_sigterm;
-            _PDCLIB_sigterm = func;
-            break;
-        default:
-            /* The standard calls for an unspecified "positive value". You
-               will probably want to define a specific value for this.
-            */
-            errno = 1;
-            return SIG_ERR;
-    }
-    return oldhandler;
-}
-
-#endif
-
-#ifdef TEST
-#include <_PDCLIB_test.h>
-
-int main( void )
-{
-    /* Testing covered by raise.c */
-    return TEST_RESULTS;
-}
-#endif
index 2d52993f7a850044da0e10c6a2e1761666c68890..8b30a4fe09053a5deb94a0d4d1a2ad291c016326 100644 (file)
@@ -1,4 +1,4 @@
-/* 7.14 Signal handling <string.h>
+/* Signal handling <string.h>
 
    This file is part of the Public Domain C Library (PDCLib).
    Permission is granted to use, modify, and / or redistribute at will.
index da83cbaba00a6a874f18022662fd25c0dd14f510..1c4a3634c7b138e1435b654de15afe555c350734 100644 (file)
@@ -116,15 +116,29 @@ struct _PDCLIB_lldiv_t
 /* defines here are merely "configuration". See above for details.            */
 /* -------------------------------------------------------------------------- */
 
-/* The result type of substracting two pointers */
+/* The types used for size_t and ptrdiff_t should not have an integer conversion
+   rank greater than that of signed long int unless the implementation supports
+   objects large enough to make this necessary.
+*/
+
+/* Result type of substracting two pointers (must be signed) */
+#if defined(__amd64__) || defined(_M_AMD64)
+#define _PDCLIB_ptrdiff long long
+#define _PDCLIB_PTRDIFF LLONG
+#define _PDCLIB_PTR_CONV ll
+#else
+#define _PDCLIB_ptrdiff int
+#define _PDCLIB_PTRDIFF INT
+#define _PDCLIB_PTR_CONV
+#endif
+
+/* Result type of the 'sizeof' operator (must be unsigned) */
 #if defined(__amd64__) || defined(_M_AMD64)
-  #define _PDCLIB_ptrdiff long long
-  #define _PDCLIB_PTRDIFF LLONG
-  #define _PDCLIB_PTR_CONV ll
+#define _PDCLIB_size unsigned long long
+#define _PDCLIB_SIZE ULLONG
 #else
-  #define _PDCLIB_ptrdiff int
-  #define _PDCLIB_PTRDIFF INT
-  #define _PDCLIB_PTR_CONV
+#define _PDCLIB_size unsigned int
+#define _PDCLIB_SIZE UINT
 #endif
 
 /* An integer type that can be accessed as atomic entity (think asynchronous
@@ -134,30 +148,39 @@ struct _PDCLIB_lldiv_t
 #define _PDCLIB_sig_atomic int
 #define _PDCLIB_SIG_ATOMIC INT
 
-/* Result type of the 'sizeof' operator (must be unsigned) */
-#if defined(__amd64__) || defined(_M_AMD64)
-  #define _PDCLIB_size unsigned long long
-  #define _PDCLIB_SIZE ULLONG
-#else
-  #define _PDCLIB_size unsigned int
-  #define _PDCLIB_SIZE UINT
-#endif
+/* Object type whose alignment is as great as supported by implementation
+   in all contexts.
+*/
+#define _PDCLIB_max_align long double
 
-/* Large enough an integer to hold all character codes of the largest supported
-   locale.
+/* Integer type whose range of values can represent distinct codes for
+   all members of the largest extended character set specified among the
+   supported locales.
+   Note that the definition of this type must agree with the type used
+   by the compiler for L"" string and L'' character literals.
+*/
+#define _PDCLIB_wchar unsigned short
+#define _PDCLIB_WCHAR USHRT
 
-   XX: Windows requires wchar_t be an unsigned short, but this is not compliant.
+/* Each member of the basic character set shall have a code value equal
+   to its value when used as the lone character in an integer character
+   constant. If that is not the case, uncomment the following line.
+#define __STDC_MB_MIGHT_NEQ_WC__
+*/
+
+/* Integer type unchanged by default argument promotions that can hold any
+   value corresponding to characters of the extended character set, as well
+   as at least one value that does not correspond to any member of the
+   extended character set (WEOF).
 */
 #define _PDCLIB_wint  signed int
-#define _PDCLIB_wchar unsigned short 
-#define _PDCLIB_WCHAR USHRT
 
 #if defined(__amd64__) || defined(_M_AMD64)
-  #define _PDCLIB_intptr long long
-  #define _PDCLIB_INTPTR LLONG
+#define _PDCLIB_intptr long long
+#define _PDCLIB_INTPTR LLONG
 #else
-  #define _PDCLIB_intptr int
-  #define _PDCLIB_INTPTR INT
+#define _PDCLIB_intptr int
+#define _PDCLIB_INTPTR INT
 #endif
 
 /* Largest supported integer type. Implementation note: see _PDCLIB_atomax(). */
@@ -176,30 +199,30 @@ struct _PDCLIB_imaxdiv_t
     _PDCLIB_intmax rem;
 };
 
-/* <time.h>: time_t 
- * The C standard doesn't define what representation of time is stored in 
+/* <time.h>: time_t
+ * The C standard doesn't define what representation of time is stored in
  * time_t when returned by time() , but POSIX defines it to be seconds since the
- * UNIX epoch and most appplications expect that. 
+ * UNIX epoch and most appplications expect that.
  *
- * time_t is also used as the tv_sec member of struct timespec, which *is* 
+ * time_t is also used as the tv_sec member of struct timespec, which *is*
  * defined as a linear count of seconds.
  *
  * time_t is defined as a "real type", so may be a floating point type, but with
  * the presence of the nanosecond accurate struct timespec, and with the lack of
- * any functions for manipulating more accurate values of time_t, this is 
+ * any functions for manipulating more accurate values of time_t, this is
  * probably not useful.
  */
-#define _PDCLIB_time  unsigned long long
+#define _PDCLIB_time unsigned long long
 
 /* <time.h>: clock_t
  *
  * A count of "clock ticks", where the length of a clock tick is unspecified by
- * the standard. The implementation is required to provide a macro, 
+ * the standard. The implementation is required to provide a macro,
  * CLOCKS_PER_SEC, which is the number of "clock ticks" which corresponds to one
  * second.
  *
  * clock_t may be any real type (i.e. integral or floating), and its type on
- * various systems differs. 
+ * various systems differs.
  *
  * On XSI systems, CLOCKS_PER_SEC must be defined to 1000000
  */
@@ -210,8 +233,8 @@ struct _PDCLIB_imaxdiv_t
  *
  * The TIME_UTC parameter is passed to the timespec_get function in order to get
  * the system time in UTC since an implementation defined epoch (not necessarily
- * the same as that used for time_t). That said, on POSIX the obvious 
- * implementation of timespec_get for TIME_UTC is to wrap 
+ * the same as that used for time_t). That said, on POSIX the obvious
+ * implementation of timespec_get for TIME_UTC is to wrap
  * clock_gettime(CLOCK_REALTIME, ...), which is defined as time in UTC since the
  * same epoch.
  *
@@ -273,9 +296,9 @@ struct _PDCLIB_imaxdiv_t
    most compilers.
 */
 #ifdef __GNUC__
-  #define _PDCLIB_offsetof( type, member ) __builtin_offsetof( type, member )
+#define _PDCLIB_offsetof( type, member ) __builtin_offsetof( type, member )
 #else
-  #define _PDCLIB_offsetof( type, member ) ( (size_t) &( ( (type *) 0 )->member ) )
+#define _PDCLIB_offsetof( type, member ) ( (size_t) &( ( (type *) 0 )->member ) )
 #endif
 
 /* Variable Length Parameter List Handling (<stdarg.h>)
@@ -285,22 +308,21 @@ struct _PDCLIB_imaxdiv_t
 */
 
 #ifdef __GNUC__
-  typedef __builtin_va_list _PDCLIB_va_list;
-  #define _PDCLIB_va_arg( ap, type ) (__builtin_va_arg( (ap), type ))
-  #define _PDCLIB_va_copy( dest, src ) (__builtin_va_copy( (dest), (src) ))
-  #define _PDCLIB_va_end( ap ) (__builtin_va_end( ap ) )
-  #define _PDCLIB_va_start( ap, parmN ) (__builtin_va_start( (ap), (parmN) ))
+typedef __builtin_va_list _PDCLIB_va_list;
+#define _PDCLIB_va_arg( ap, type ) (__builtin_va_arg( (ap), type ))
+#define _PDCLIB_va_copy( dest, src ) (__builtin_va_copy( (dest), (src) ))
+#define _PDCLIB_va_end( ap ) (__builtin_va_end( ap ) )
+#define _PDCLIB_va_start( ap, parmN ) (__builtin_va_start( (ap), (parmN) ))
 #elif (defined(__i386__) || defined(__i386) || defined(_M_IX86)) && !(defined(__amd64__) || defined(__x86_64__) || defined(_M_AMD64))
-  /* 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 )
+/* 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 )
 #else
-  #error Compiler/Architecture support please
+#error Compiler/Architecture support please
 #endif
 
 /* -------------------------------------------------------------------------- */
@@ -328,8 +350,8 @@ struct _PDCLIB_imaxdiv_t
 /* Locale --------------------------------------------------------------------*/
 
 /* Locale method. See _PDCLIB_locale.h. If undefined, POSIX per-thread locales
- * will be disabled
- */
+   will be disabled.
+*/
 #define _PDCLIB_LOCALE_METHOD _PDCLIB_LOCALE_METHOD_TSS
 
 /* wchar_t encoding */
@@ -397,8 +419,8 @@ struct _PDCLIB_imaxdiv_t
    However, C++11 introduced the whole list of POSIX errno values into the
    standard, so PDCLib might as well define those as well.
 
-   Sometimes the standard says to set errno to indicate an error, but does not 
-   prescribe a value. We will use a value from the following list. If POSIX 
+   Sometimes the standard says to set errno to indicate an error, but does not
+   prescribe a value. We will use a value from the following list. If POSIX
    defines a value, we use that; otherwise, we use as seems suitable.
 */
 
index 0f35d294f94e54632cb6235785fa54b81ea75a6f..cca59e1399760d40df4d2f5875950797da8c72d2 100644 (file)
@@ -3,7 +3,9 @@
 #include <_PDCLIB_aux.h>\r
 #include <_PDCLIB_int.h>\r
 \r
-_PDCLIB_BEGIN_EXTERN_C\r
+#ifdef __cplusplus
+extern "C" {
+#endif\r
 #define _PDCLIB_TSS_DTOR_ITERATIONS 3\r
 #define _PDCLIB_ONCE_FLAG_INIT { -1, 0 }\r
 #define _PDCLIB_ONCE_FLAG_IS_DONE( _f ) ((_f)->_State == 0)\r
@@ -32,5 +34,7 @@ struct _PDCLIB_tss {
     unsigned int _Key;\r
 };\r
 \r
-_PDCLIB_END_EXTERN_C\r
+#ifdef __cplusplus
+}
+#endif\r
 #endif\r