stdcxx-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From se...@apache.org
Subject svn commit: r373578 - in /incubator/stdcxx/trunk/etc/config/src: FLOAT.cpp LIMITS.cpp SIG_ATOMIC_T.cpp SIZE_T.cpp WINT_T.cpp types.h
Date Mon, 30 Jan 2006 20:01:48 GMT
Author: sebor
Date: Mon Jan 30 12:01:37 2006
New Revision: 373578

URL: http://svn.apache.org/viewcvs?rev=373578&view=rev
Log:
2006-01-30  Martin Sebor  <sebor@roguewave.com>

	* LIMITS.cpp (type_name): Factored out the helper functions into
	a file of their own (types.h). Moved code computing the properties
	of floating point types to a separate config test (FLOAT.cpp).
	(_RWSTD_PTRDIFF_MIN, _RWSTD_PTRDIFF_MAX, _RWSTD_SIZE_MAX): Moved
	to SIZE_T.cpp.
	(_RWSTD_WINT_MIN, _RWSTD_WINT_MAX): Moved to WINT_T.cpp.
	(_RWSTD_INT8_T, _RWSTD_INT_LEAST8_T, ...): Computed and defined.
	* types.h: New file with the definitions of the type_name() helper
	overloads.
	* FLOAT.cpp: New config test computing the properties of floating
	point types.
	* SIG_ATOMIC_T.cpp (types.h): Included instead of defining own helpers.
	(_RWSTD_SIG_ATOMIC_MIN, _RWSTD_SIG_ATOMIC_MAX): Defined here terms
	of the underlying arithmetic type instead of in LIMITS.cpp.
	* SIZE_T.cpp (types.h): Included instead of defining own helpers.
	(_RWSTD_SIZE_MAX): Defined here terms of the underlying arithmetic
	type instead of in LIMITS.cpp.
	* WINT_T.cpp (types.h): Included instead of defining own helpers.
	(_RWSTD_WINT_MIN, _RWSTD_WINT_MAX): Defined here in terms of the
	underlying arithmetic type instead of LIMITS.cpp.

Added:
    incubator/stdcxx/trunk/etc/config/src/FLOAT.cpp   (with props)
    incubator/stdcxx/trunk/etc/config/src/types.h   (with props)
Modified:
    incubator/stdcxx/trunk/etc/config/src/LIMITS.cpp
    incubator/stdcxx/trunk/etc/config/src/SIG_ATOMIC_T.cpp
    incubator/stdcxx/trunk/etc/config/src/SIZE_T.cpp
    incubator/stdcxx/trunk/etc/config/src/WINT_T.cpp

Added: incubator/stdcxx/trunk/etc/config/src/FLOAT.cpp
URL: http://svn.apache.org/viewcvs/incubator/stdcxx/trunk/etc/config/src/FLOAT.cpp?rev=373578&view=auto
==============================================================================
--- incubator/stdcxx/trunk/etc/config/src/FLOAT.cpp (added)
+++ incubator/stdcxx/trunk/etc/config/src/FLOAT.cpp Mon Jan 30 12:01:37 2006
@@ -0,0 +1,325 @@
+// computing floating point properties
+
+// working around a Compaq C++ headers problem (PR #27459)
+#if defined (__PURE_CNAME)
+#  undef __PURE_CNAME
+#endif // __PURE_CNAME
+
+#if defined (_RWSTD_USE_CONFIG)
+#  include "config.h"
+#endif   // _RWSTD_USE_CONFIG
+
+enum {
+    // the enumerators belo are expected to be hidden by macros #defined
+    // in the <float.h> header #included below; references to macros that
+    // are not #defined in the header will silently use these enumerators
+    // and prevent compilation errors that would result otherwise
+    DBL_DIG         =    15,   // default
+    DBL_MANT_DIG    =    53,
+    DBL_MAX_10_EXP  =   308,
+    DBL_MAX_EXP     =  1024,
+    DBL_MIN_10_EXP  =  -307,
+    DBL_MIN_EXP     = -1021,
+
+    FLT_DIG         =     6,
+    FLT_MANT_DIG    =    24,
+    FLT_MAX_10_EXP  =    38,
+    FLT_MAX_EXP     =   128,
+    FLT_MIN_10_EXP  =   -37,
+    FLT_MIN_EXP     =  -125,
+    FLT_RADIX       =     2,
+
+    LDBL_DIG        = -1,
+    LDBL_MANT_DIG   = -1,
+    LDBL_MAX_10_EXP = -1,
+    LDBL_MAX_EXP    = -1,
+    LDBL_MIN_10_EXP = -1,
+    LDBL_MIN_EXP    = -1
+};
+
+
+#include <errno.h>    // for ERANGE, errno
+#include <stdio.h>    // for printf()
+#include <stdlib.h>   // for strtod()
+
+#ifndef _RWSTD_NO_FLOAT_H
+#  include <float.h>
+
+#  if defined (__EDG__) && defined (__linux__) && !defined (__INTEL_COMPILER)
+
+     // prevent the propriterary gcc __extension__ from
+     // throwing the vanilla EDG demo for a loop
+
+#    undef LDBL_EPSILON
+#    undef LDBL_MIN
+#    undef LDBL_MAX
+
+     // redefine to prevent compilation errors
+#    define LDBL_EPSILON 1.0842021724855044e-19L
+#    define LDBL_MIN     3.3621031431120935e-4932L
+#    define LDBL_MAX     1.1897314953572317e+4932L
+#  endif   // __EDG__ && __linux__ && !__INTEL_COMPILER
+
+#endif   // _RWSTD_NO_FLOAT_H
+
+
+#ifndef _RWSTD_NO_LIBC_EXCEPTION_SPEC
+#  define LIBC_THROWS()   throw ()
+#else
+#  define LIBC_THROWS()   /* empty */
+#endif   // _RWSTD_NO_LIBC_EXCEPTION_SPEC
+
+
+extern "C" {
+
+#ifdef _RWSTD_NO_STRTOF
+#  ifndef _RWSTD_NO_STRTOF_IN_LIBC
+
+#    undef _RWSTD_NO_STRTOF
+
+float strtof (const char*, char**) LIBC_THROWS ();
+
+#  endif   // _RWSTD_NO_STRTOF_IN_LIBC
+#endif   // _RWSTD_NO_STRTOF
+
+#ifdef _RWSTD_NO_STRTOD
+#  ifndef _RWSTD_NO_STRTOD_IN_LIBC
+
+#    undef _RWSTD_NO_STRTOD
+
+double strtod (const char*, char**) LIBC_THROWS ();
+
+#  endif   // _RWSTD_NO_STRTOD_IN_LIBC
+#endif   // _RWSTD_NO_STRTOD
+
+#ifndef _RWSTD_NO_LONG_DOUBLE
+#  ifdef _RWSTD_NO_STRTOLD
+#    ifndef _RWSTD_NO_STRTOLD_IN_LIBC
+
+#      undef _RWSTD_NO_STRTOLD
+
+long double strtold (const char*, char**) LIBC_THROWS ();
+
+#    endif   // _RWSTD_NO_STRTOLD_IN_LIBC
+#  endif   // _RWSTD_NO_STRTOLD
+#endif   // _RWSTD_NO_LONG_DOUBLE
+
+}
+
+
+#ifndef _RWSTD_NO_HONOR_STD
+#  ifdef _RWSTD_NO_STD_TERMINATE
+
+namespace std {
+
+void terminate ()
+{
+    for (; ;) {
+        char *p = 0;
+        *p = 0;        // force a SIGSEGV
+    }
+}
+
+}   // std
+
+
+#  endif   // _RWSTD_NO_STD_TERMINATE
+#endif   // _RWSTD_NO_HONOR_STD
+
+
+// print a floating point number, either as a string (if the stringized
+// constant is a valid number, and not some complex expression), or as
+// a formatted floating point value
+template <class FloatT>
+void print_float (FloatT x, const char *xstr,
+                  const char *macro_name, const char *fmt, int prec)
+{
+    if ('-' == *xstr || '0' <= *xstr && '9' >= *xstr) {
+        printf ("#define _RWSTD_%-16s %s", macro_name, xstr);
+    }
+    else {
+        printf ("#define _RWSTD_%-16s ", macro_name);
+        printf (fmt, prec + 2, x);
+    }
+    puts ("");
+}
+
+#define DO_STRINGIZE(x)  #x
+#define STRINGIZE(x)     DO_STRINGIZE (x)
+
+#define PRINTINT(macro)                                         \
+    if (-1 == (macro))                                          \
+        printf ("%s", "//");                                    \
+    printf ("#define _RWSTD_%-16s %6d\n", #macro, (macro))
+
+#define PRINTFLT(macro, fmt, prec, suffix) \
+    print_float (macro, STRINGIZE (macro), #macro, "%.*" fmt "e" suffix, prec)
+
+
+int main ()
+{
+#if !defined (_RWSTD_USE_CONFIG)
+
+    printf ("/**/\n#undef _RWSTD_FLOAT\n");
+
+#endif   // _RWSTD_USE_CONFIG
+
+    //////////////////////////////////////////////////////////////////
+    // compute floating point limits
+
+#undef LDBL_FMT
+
+#ifdef _RWSTD_LDBL_PRINTF_PREFIX
+#  define LDBL_FMT   _RWSTD_LDBL_PRINTF_PREFIX
+#else
+#  define LDBL_FMT   "L"
+#endif
+
+#if defined (FLT_ROUNDS)
+    printf ("#define _RWSTD_%-16s %6d   /* %s */\n",
+            "FLT_ROUNDS", FLT_ROUNDS,
+               0 == FLT_ROUNDS ? "round toward zero"
+            :  1 == FLT_ROUNDS ? "round to nearest"
+            :  2 == FLT_ROUNDS ? "round toward infinity"
+            :  3 == FLT_ROUNDS ? "round toward negative infinity"
+            :  "indeterminable");
+#endif   // FLT_ROUNDS
+
+    PRINTINT (DBL_DIG);
+    PRINTINT (DBL_MANT_DIG);
+    PRINTINT (DBL_MAX_10_EXP);
+    PRINTINT (DBL_MAX_EXP);
+    PRINTINT (DBL_MIN_10_EXP);
+    PRINTINT (DBL_MIN_EXP);
+
+    PRINTINT (FLT_DIG);
+    PRINTINT (FLT_MANT_DIG);
+    PRINTINT (FLT_MAX_10_EXP);
+    PRINTINT (FLT_MAX_EXP);
+    PRINTINT (FLT_MIN_10_EXP);
+    PRINTINT (FLT_MIN_EXP);
+    PRINTINT (FLT_RADIX);
+
+#ifndef _RWSTD_NO_LONG_DOUBLE
+
+    PRINTINT (LDBL_DIG);
+    PRINTINT (LDBL_MANT_DIG);
+    PRINTINT (LDBL_MAX_10_EXP);
+    PRINTINT (LDBL_MAX_EXP);
+    PRINTINT (LDBL_MIN_10_EXP);
+    PRINTINT (LDBL_MIN_EXP);
+
+#endif   //  _RWSTD_NO_LONG_DOUBLE
+
+
+#if defined (DBL_MAX)
+    PRINTFLT (DBL_MAX, "l", DBL_DIG, "");
+#endif   // DBL_MAX
+
+#if defined (FLT_MAX)
+    PRINTFLT (FLT_MAX, "", FLT_DIG, "F");
+#endif   // FLT_MAX
+
+#ifndef _RWSTD_NO_LONG_DOUBLE
+#  if defined (LDBL_MAX)
+    PRINTFLT (LDBL_MAX, LDBL_FMT, DBL_DIG, "F");
+#  endif   // LDBL_MAX
+#endif   // _RWSTD_NO_LONG_DOUBLE
+
+#if defined (DBL_EPSILON)
+    PRINTFLT (DBL_EPSILON, "l", DBL_DIG, "");
+#endif   // DBL_EPSILON
+
+#if defined (DBL_MIN)
+    PRINTFLT (DBL_MIN, "l", DBL_DIG, "");
+#endif   // DBL_MIN
+
+#if defined (FLT_EPSILON)
+    PRINTFLT (FLT_EPSILON, "", FLT_DIG, "F");
+#endif   // FLT_EPSILON
+
+#if defined (FLT_MIN)
+    PRINTFLT (FLT_MIN, "", FLT_DIG, "F");
+#endif   // FLT_MIN
+
+#ifndef _RWSTD_NO_LONG_DOUBLE
+#  if defined (LDBL_EPSILON)
+    PRINTFLT (LDBL_EPSILON, LDBL_FMT, LDBL_DIG, "L");
+#  endif   // LDBL_EPSILON
+
+#  if defined (LDBL_MIN)
+    PRINTFLT (LDBL_MIN, LDBL_FMT, LDBL_DIG, "L");
+#  endif   // LDBL_MIN
+#endif   // _RWSTD_NO_LONG_DOUBLE
+
+
+#if !defined (ERANGE)
+#  define ERANGE -1
+#endif   // ERANGE
+
+#ifndef _RWSTD_NO_STRTOF
+
+    errno = 0;
+
+    // determine whether strtof() sets errno on underflow
+    const float f = strtof ("1.0e-999", (char**)0);
+
+
+    if (f < 0.0 || f > 1.0 || !errno)
+        printf ("#define _RWSTD_NO_STRTOF_UFLOW\n");
+    else
+        printf ("// #define _RWSTD_NO_STRTOF_UFLOW    // %d%s\n",
+                errno, ERANGE == errno ? " (ERANGE)" : "");
+
+#endif   // _RWSTD_NO_STRTOF
+
+#ifndef _RWSTD_NO_STRTOD
+
+    errno = 0;
+
+    // determine whether strtod() sets errno on underflow
+    const double d = strtod ("1.0e-999", (char**)0);
+
+
+    if (d < 0.0 || d > 1.0 || !errno)
+        printf ("#define _RWSTD_NO_STRTOD_UFLOW\n");
+    else
+        printf ("// #define _RWSTD_NO_STRTOD_UFLOW    // %d%s\n",
+                errno, ERANGE == errno ? " (ERANGE)" : "");
+
+#endif   // _RWSTD_NO_STRTOD
+
+#ifndef _RWSTD_NO_LONG_DOUBLE
+#  ifndef _RWSTD_NO_STRTOLD
+
+    errno = 0;
+
+#    if !defined (__hpux)
+
+    // determine whether strtold() sets errno on underflow
+    const long double ld = strtold ("1.0e-9999", (char**)0);
+
+#    else
+
+    union {
+        long double ld;
+        long_double data;
+    } ldu;
+
+    ldu.data = strtold ("1.0e-9999", (char**)0);
+    const long double ld = ldu.ld;
+
+#    endif   // __hpux
+
+    if (ld < 0.0 || ld > 1.0 || !errno)
+        printf ("#define _RWSTD_NO_STRTOLD_UFLOW\n");
+    else
+        printf ("// #define _RWSTD_NO_STRTOLD_UFLOW   // %d%s\n",
+                errno, ERANGE == errno ? " (ERANGE)" : "");
+
+#  endif   // _RWSTD_NO_STRTOLD
+#endif   // _RWSTD_NO_LONG_DOUBLE
+
+    return 0;
+}
+

Propchange: incubator/stdcxx/trunk/etc/config/src/FLOAT.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/stdcxx/trunk/etc/config/src/FLOAT.cpp
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: incubator/stdcxx/trunk/etc/config/src/LIMITS.cpp
URL: http://svn.apache.org/viewcvs/incubator/stdcxx/trunk/etc/config/src/LIMITS.cpp?rev=373578&r1=373577&r2=373578&view=diff
==============================================================================
--- incubator/stdcxx/trunk/etc/config/src/LIMITS.cpp (original)
+++ incubator/stdcxx/trunk/etc/config/src/LIMITS.cpp Mon Jan 30 12:01:37 2006
@@ -1,10 +1,5 @@
 // computing numerical limits
 
-// Working around a Compaq c++ headers problem (PR#27459)
-#if defined (__PURE_CNAME)
-#  undef __PURE_CNAME
-#endif // __PURE_CNAME
-
 #if defined (_RWSTD_USE_CONFIG)
 #  include "config.h"
 #endif   // _RWSTD_USE_CONFIG
@@ -13,74 +8,19 @@
 #  include <limits.h>
 #endif   // _RWSTD_NO_LIMITS_H
 
-#ifndef _RWSTD_NO_FLOAT_H
-#  include <float.h>
-
-#  if defined (__EDG__) && defined (__linux__) && !defined (__INTEL_COMPILER)
-
-     // prevent the propriterary gcc __extension__ from
-     // throwing the vanilla EDG demo for a loop
-
-#    undef LDBL_EPSILON
-#    undef LDBL_MIN
-#    undef LDBL_MAX
-
-     // redefine to prevent compilation errors
-#    define LDBL_EPSILON 1.0842021724855044e-19L
-#    define LDBL_MIN     3.3621031431120935e-4932L
-#    define LDBL_MAX     1.1897314953572317e+4932L
-#  endif   // __EDG__ && __linux__ && !__INTEL_COMPILER
-
-#endif   // _RWSTD_NO_FLOAT_H
-
-
-#include <errno.h>    // for ERANGE, errno
 #include <stdio.h>    // for printf()
-#include <stdlib.h>   // for strtod()
-
-
-#ifndef _RWSTD_NO_LIBC_EXCEPTION_SPEC
-#  define LIBC_THROWS()   throw ()
-#else
-#  define LIBC_THROWS()   /* empty */
-#endif   // _RWSTD_NO_LIBC_EXCEPTION_SPEC
-
-
-extern "C" {
-
-#ifdef _RWSTD_NO_STRTOF
-#  ifndef _RWSTD_NO_STRTOF_IN_LIBC
-
-#    undef _RWSTD_NO_STRTOF
-
-float strtof (const char*, char**) LIBC_THROWS ();
-
-#  endif   // _RWSTD_NO_STRTOF_IN_LIBC
-#endif   // _RWSTD_NO_STRTOF
 
-#ifdef _RWSTD_NO_STRTOD
-#  ifndef _RWSTD_NO_STRTOD_IN_LIBC
-
-#    undef _RWSTD_NO_STRTOD
-
-double strtod (const char*, char**) LIBC_THROWS ();
-
-#  endif   // _RWSTD_NO_STRTOD_IN_LIBC
-#endif   // _RWSTD_NO_STRTOD
-
-#ifndef _RWSTD_NO_LONG_DOUBLE
-#  ifdef _RWSTD_NO_STRTOLD
-#    ifndef _RWSTD_NO_STRTOLD_IN_LIBC
-
-#      undef _RWSTD_NO_STRTOLD
-
-long double strtold (const char*, char**) LIBC_THROWS ();
-
-#    endif   // _RWSTD_NO_STRTOLD_IN_LIBC
-#  endif   // _RWSTD_NO_STRTOLD
-#endif   // _RWSTD_NO_LONG_DOUBLE
+// establish a dependency on the test for long long
+// and #define the LONG_LONG macro used in "type.h"
+#ifndef _RWSTD_NO_LONG_LONG
+#  define LONG_LONG long long
+#else   // if defined (_RWSTD_NO_LONG_LONG)
+#  if defined (_MSC_VER)
+#    define LONG_LONG   __int64
+#  endif   // _MSC_VER
+#endif   // _RWSTD_NO_LONG_LONG
 
-}
+#include "types.h"   // for type_name()
 
 
 #ifndef _RWSTD_NO_HONOR_STD
@@ -200,26 +140,6 @@
 
 
 template <class T>
-const char* type_name (T) { return "unknown type"; }
-
-const char* type_name (short) { return "short"; }
-const char* type_name (unsigned short) { return "unsigned short"; }
-const char* type_name (int) { return "int"; }
-const char* type_name (unsigned int) { return "unsigned int"; }
-const char* type_name (long) { return "long"; }
-const char* type_name (unsigned long) { return "unsigned long"; }
-
-#ifndef _RWSTD_NO_LONG_LONG
-const char* type_name (long long) { return "long long"; }
-const char* type_name (unsigned long long) { return "unsigned long long"; }
-#else
-#  if defined (_MSC_VER)
-const char* type_name (__int64) { return "__int64"; }
-const char* type_name (unsigned __int64) { return "unsigned __int64"; }
-#  endif   // _MSC_VER
-#endif
-
-template <class T>
 const char* type_suffix (T) { return ""; }
 
 const char* type_suffix (short) { return ""; }
@@ -291,36 +211,12 @@
 
     for (unsigned char c = '\01'; c; c <<= 1, ++bits);
 
-    printf ("#define _RWSTD_CHAR_BIT    %u\n", bits);
+    printf ("#define _RWSTD_CHAR_BIT    %2u\n", bits);
 
     return bits;
 }
 
 
-// print a floating point number, either as a string (if the stringized
-// constant is a valid number, and not some complex expression), or as
-// a formatted floating point value
-template <class FloatT>
-void print_float (FloatT x, const char *xstr,
-                  const char *macro_name, const char *fmt, int prec)
-{
-    if ('-' == *xstr || '0' <= *xstr && '9' >= *xstr) {
-        printf ("#define %s %s", macro_name, xstr);
-    }
-    else {
-        printf ("#define %s ", macro_name);
-        printf (fmt, prec + 2, x);
-    }
-    printf ("\n");
-}
-
-#define DO_STRINGIZE(x)  #x
-#define STRINGIZE(x)     DO_STRINGIZE (x)
-
-#define PRINTFLT(x, fmt, prec, suffix) \
-    print_float (x, STRINGIZE (x), "_RWSTD_" #x, "%.*" fmt "e" suffix, prec)
-
-
 // used to compute the size of a pointer to a member function
 struct EmptyStruct { };
 
@@ -351,39 +247,39 @@
     // compute sizes of fundamental types
 
 #ifndef _RWSTD_NO_BOOL
-    printf ("#define _RWSTD_BOOL_SIZE   %u /* sizeof (bool) */\n",
+    printf ("#define _RWSTD_BOOL_SIZE   %2u /* sizeof (bool) */\n",
             SIZEOF (bool));
 #endif   // _RWSTD_NO_BOOL
 
-    printf ("#define _RWSTD_CHAR_SIZE   %u /* sizeof (char) */\n",
+    printf ("#define _RWSTD_CHAR_SIZE   %2u /* sizeof (char) */\n",
             SIZEOF (char));
-    printf ("#define _RWSTD_SHRT_SIZE   %u /* sizeof (short) */\n",
+    printf ("#define _RWSTD_SHRT_SIZE   %2u /* sizeof (short) */\n",
             SIZEOF (short));
-    printf ("#define _RWSTD_INT_SIZE    %u /* sizeof (int) */\n",
+    printf ("#define _RWSTD_INT_SIZE    %2u /* sizeof (int) */\n",
             SIZEOF (int));
-    printf ("#define _RWSTD_LONG_SIZE   %u /* sizeof (long) */\n",
+    printf ("#define _RWSTD_LONG_SIZE   %2u /* sizeof (long) */\n",
             SIZEOF (long));
 
-    printf ("#define _RWSTD_FLT_SIZE    %u /* sizeof (float) */\n",
+    printf ("#define _RWSTD_FLT_SIZE    %2u /* sizeof (float) */\n",
             SIZEOF (float));
-    printf ("#define _RWSTD_DBL_SIZE    %u /* sizeof (double) */\n",
+    printf ("#define _RWSTD_DBL_SIZE    %2u /* sizeof (double) */\n",
             SIZEOF (double));
 
 #ifndef _RWSTD_NO_LONG_DOUBLE
-    printf ("#define _RWSTD_LDBL_SIZE   %u /* sizeof (long double) */\n",
+    printf ("#define _RWSTD_LDBL_SIZE   %2u /* sizeof (long double) */\n",
             SIZEOF (long double));
 #endif   // _RWSTD_NO_LONG_DOUBLE
 
     // compute the sizes of data and function pointers
-    printf ("#define _RWSTD_PTR_SIZE    %u /* sizeof (void*) */\n",
+    printf ("#define _RWSTD_PTR_SIZE    %2u /* sizeof (void*) */\n",
             SIZEOF (void*));
 
     typedef void (*fun_ptr_t)();
-    printf ("#define _RWSTD_FUNPTR_SIZE %u /* sizeof (void(*)()) */\n",
+    printf ("#define _RWSTD_FUNPTR_SIZE %2u /* sizeof (void(*)()) */\n",
             SIZEOF (fun_ptr_t));
 
     typedef void (EmptyStruct::*memfun_ptr_t)();
-    printf ("#define _RWSTD_MEMPTR_SIZE %u "
+    printf ("#define _RWSTD_MEMPTR_SIZE %2u "
             "/* sizeof (void (struct::*)()) */\n",
             SIZEOF (memfun_ptr_t));
 
@@ -393,7 +289,7 @@
 
 #ifndef _RWSTD_NO_BOOL
 
-    printf ("#define _RWSTD_BOOL_MIN    !!0\n");
+    printf ("#define _RWSTD_BOOL_MIN   !!0\n");
     printf ("#define _RWSTD_BOOL_MAX    !0\n");
 
 #endif   // _RWSTD_NO_BOOL
@@ -422,7 +318,7 @@
 
 #    define LLong long long
 
-    printf ("#define _RWSTD_LLONG_SIZE  %u\n", SIZEOF (LLong));
+    printf ("#define _RWSTD_LLONG_SIZE  %2u\n", SIZEOF (LLong));
 
     const char llong_name[] = "long long";
 
@@ -435,7 +331,7 @@
 
 #    define LLong __int64
 
-    printf ("#define _RWSTD_LLONG_SIZE  %u\n", SIZEOF (LLong));
+    printf ("#define _RWSTD_LLONG_SIZE  %2u\n", SIZEOF (LLong));
 
     const char llong_name[] = "__int64";
 
@@ -455,7 +351,7 @@
 
 #ifndef _RWSTD_NO_WCHAR_T
 
-    printf ("#define _RWSTD_WCHAR_T_SIZE  %u /* sizeof (wchar_t) */\n",
+    printf ("#define _RWSTD_WCHAR_T_SIZE  %2u /* sizeof (wchar_t) */\n",
             SIZEOF (wchar_t));
 
     const char *suffix = "U";
@@ -466,31 +362,10 @@
 
 #endif   // _RWSTD_NO_WCHAR_T
 
-    // compute the maximum and minimum for size_t and ptrdiff_t
-    compute_limits (sizeof (int), "SIZE",
-                    type_suffix (sizeof (int)),
-                    type_name (sizeof (int)));
-
-    compute_limits ((int*)0 - (int*)0, "PTRDIFF",
-                    type_suffix ((int*)0 - (int*)0),
-                    type_name ((int*)0 - (int*)0));
-
-
-#ifndef _RWSTD_NO_WINT_T
-   // establish a dependency on WINT_T.cpp
-#  if defined (_RWSTD_WINT_T)
-
-    // compute the maximum and minimum for wint_t
-    compute_limits ((_RWSTD_WINT_T)0, "WINT",
-                    type_suffix ((_RWSTD_WINT_T)0),
-                    type_name ((_RWSTD_WINT_T)0));
-
-#  endif   // _RWSTD_WINT_T
-#endif   // _RWSTD_NO_WINT_T
-
 #if defined (MB_LEN_MAX)
 
-    printf ("#define _RWSTD_MB_LEN_MAX %d   /* libc value */\n", MB_LEN_MAX);
+    printf ("#define _RWSTD_MB_LEN_MAX    %d   /* libc value */\n",
+            MB_LEN_MAX);
 
 #else   // if !defined (MB_LEN_MAX)
 
@@ -512,326 +387,143 @@
 
 #endif   // MB_LEN_MAX
 
+    //////////////////////////////////////////////////////////////////
+    // #define macros for exact and lest-width integer types
 
-    // #define macros for exact-width integer types
-    int bits = 0;
+    // width_bits will have the corresponding bit set for each exact-width
+    // type already processed (i.e., bit 0 for an 8-bit integer type, bit
+    // 1 for a 16-bit integer, etc)
+    int width_bits = 0;
+
+#define PRINT_SPECIFIC(width, least, type)                              \
+    do {                                                                \
+        /* avoid warnings about expression being constant */            \
+        const char* least_str = least;                                  \
+        if (least_str && *least_str)                                    \
+            printf ("#define _RWSTD_INT_LEAST%d_T  %s  _RWSTD_%s_T\n"   \
+                    "#define _RWSTD_UINT_LEAST%d_T %s  _RWSTD_U%s_T\n", \
+                    width, width < 10 ? " " : "", type,                 \
+                    width, width < 10 ? " " : "", type);                \
+        else                                                            \
+            printf ("#define _RWSTD_INT%d_T %s          %s%s\n"         \
+                    "#define _RWSTD_UINT%d_T %s         unsigned %s\n", \
+                    width, width < 10 ? " " : "",                       \
+                    8 == width && '\xff' < 0 ? "signed " : "", type,    \
+                    width, width < 10 ? " " : "", type);                \
+    } while (0)
 
     if (8 == char_bits) {
-        bits |= 1;
-        printf ("#define _RWSTD_INT8_T   %s\n",
-                '\xff' < 0 ? "char" : "signed char");
-        printf ("#define _RWSTD_UINT8_T  unsigned char\n");
+        width_bits |= 1;
+        PRINT_SPECIFIC (8, "", "char");
     }
     else if (16 == char_bits) {
-        bits |= 2;
-        printf ("#define _RWSTD_INT16_T  %s\n",
-                '\xff' < 0 ? "char" : "signed char");
-        printf ("#define _RWSTD_UINT16_T unsigned char\n");
+        width_bits |= 2;
+        PRINT_SPECIFIC (16, "", "char");
     }
     else if (32 == char_bits) {
-        bits |= 4;
-        printf ("#define _RWSTD_INT32_T  %s\n",
-                '\xff' < 0 ? "char" : "signed char");
-        printf ("#define _RWSTD_UINT32_T unsigned char\n");
+        width_bits |= 4;
+        PRINT_SPECIFIC (32, "", "char");
     }
     else if (64 == char_bits) {
-        bits |= 8;
-        printf ("#define _RWSTD_INT64_T  %s\n",
-                '\xff' < 0 ? "char" : "signed char");
-        printf ("#define _RWSTD_UINT64_T unsigned char\n");
-    }
-
-    if (16 == char_bits * sizeof (short) && !(bits & 2)) {
-        bits |= 2;
-        printf ("#define _RWSTD_INT16_T  short\n");
-        printf ("#define _RWSTD_UINT16_T unsigned short\n");
-    }
-    else if (32 == char_bits * sizeof (short) && !(bits & 4)) {
-        bits |= 4;
-        printf ("#define _RWSTD_INT32_T  short\n");
-        printf ("#define _RWSTD_UINT32_T unsigned short\n");
-    }
-    else if (64 == char_bits * sizeof (short) && !(bits & 8)) {
-        bits |= 8;
-        printf ("#define _RWSTD_INT64_T  short\n");
-        printf ("#define _RWSTD_UINT64_T unsigned short\n");
-    }
-    else if (128 == char_bits * sizeof (short) && !(bits & 16)) {
-        bits |= 16;
-        printf ("#define _RWSTD_INT128_T  short\n");
-        printf ("#define _RWSTD_UINT128_T unsigned short\n");
-    }
-
-    if (32 == char_bits * sizeof (int) && !(bits & 4)) {
-        bits |= 4;
-        printf ("#define _RWSTD_INT32_T  int\n");
-        printf ("#define _RWSTD_UINT32_T unsigned int\n");
-    }
-    else if (64 == char_bits * sizeof (int) && !(bits & 8)) {
-        bits |= 8;
-        printf ("#define _RWSTD_INT64_T  int\n");
-        printf ("#define _RWSTD_UINT64_T unsigned int\n");
-    }
-    else if (128 == char_bits * sizeof (int) && !(bits & 16)) {
-        bits |= 16;
-        printf ("#define _RWSTD_INT64_T  int\n");
-        printf ("#define _RWSTD_UINT64_T unsigned int\n");
-    }
-
-    if (32 == char_bits * sizeof (long) && !(bits & 4)) {
-        bits |= 4;
-        printf ("#define _RWSTD_INT32_T  long\n");
-        printf ("#define _RWSTD_UINT32_T unsigned long\n");
-    }
-    else if (64 == char_bits * sizeof (long) && !(bits & 8)) {
-        bits |= 8;
-        printf ("#define _RWSTD_INT64_T  long\n");
-        printf ("#define _RWSTD_UINT64_T unsigned long\n");
-    }
-    else if (128 == char_bits * sizeof (long) && !(bits & 16)) {
-        bits |= 16;
-        printf ("#define _RWSTD_INT64_T  long\n");
-        printf ("#define _RWSTD_UINT64_T unsigned long\n");
-    }
-
-    if (32 == char_bits * sizeof (LLong) && !(bits & 4)) {
-        bits |= 4;
-        printf ("#define _RWSTD_INT32_T  %s\n", llong_name);
-        printf ("#define _RWSTD_UINT32_T unsigned %s\n", llong_name);
-    }
-    else if (64 == char_bits * sizeof (LLong) && !(bits & 8)) {
-        bits |= 8;
-        printf ("#define _RWSTD_INT64_T  %s\n", llong_name);
-        printf ("#define _RWSTD_UINT64_T unsigned %s\n", llong_name);
-    }
-    else if (128 == char_bits * sizeof (LLong) && !(bits & 16)) {
-        bits |= 16;
-        printf ("#define _RWSTD_INT64_T  %s\n", llong_name);
-        printf ("#define _RWSTD_UINT64_T unsigned %s\n", llong_name);
+        width_bits |= 8;
+        PRINT_SPECIFIC (64, "", "char");
     }
 
-    //////////////////////////////////////////////////////////////////
-    // compute floating point limits
-
-#undef LDBL_FMT
-
-#ifdef _RWSTD_LDBL_PRINTF_PREFIX
-#  define LDBL_FMT   _RWSTD_LDBL_PRINTF_PREFIX
-#else
-#  define LDBL_FMT   "L"
-#endif
-
-#if defined (FLT_ROUNDS)
-    printf ("#define _RWSTD_FLT_ROUNDS %d   /* %s */\n", FLT_ROUNDS,
-               0 == FLT_ROUNDS ? "round toward zero"
-            :  1 == FLT_ROUNDS ? "round to nearest"
-            :  2 == FLT_ROUNDS ? "round toward infinity"
-            :  3 == FLT_ROUNDS ? "round toward negative infinity"
-            :  "indeterminable");
-#endif   // FLT_ROUNDS
-
-#if !defined (DBL_DIG)
-#  define DBL_DIG   15
-#endif   // DBL_DIG
-
-    printf ("#define _RWSTD_DBL_DIG %d\n", DBL_DIG);
-
-
-#if defined (DBL_MANT_DIG)
-    printf ("#define _RWSTD_DBL_MANT_DIG %d\n", DBL_MANT_DIG);
-#endif   // DBL_MANT_DIG
-
-#if defined (DBL_MAX_10_EXP)
-    printf ("#define _RWSTD_DBL_MAX_10_EXP %d\n", DBL_MAX_10_EXP);
-#endif   // DBL_MAX_10_EXP
-
-#if defined (DBL_MAX_EXP)
-    printf ("#define _RWSTD_DBL_MAX_EXP %d\n", DBL_MAX_EXP);
-#endif   // DBL_MAX_EXP
-
-#if defined (DBL_MIN_10_EXP)
-    printf ("#define _RWSTD_DBL_MIN_10_EXP %d\n", DBL_MIN_10_EXP);
-#endif   // DBL_MIN_10_EXP
-
-#if defined (DBL_MIN_EXP)
-    printf ("#define _RWSTD_DBL_MIN_EXP %d\n", DBL_MIN_EXP);
-#endif   // DBL_MIN_EXP
-
-#if defined (DECIMAL_DIG)
-    printf ("#define _RWSTD_DECIMAL_DIG %d\n", DECIMAL_DIG);
-#endif   // DECIMAL_DIG
-
-
-#if !defined (FLT_DIG)
-#  define FLT_DIG   6
-#endif   // FLT_DIG
-
-    printf ("#define _RWSTD_FLT_DIG %d\n", FLT_DIG);
-
-#if defined (FLT_MANT_DIG)
-    printf ("#define _RWSTD_FLT_MANT_DIG %d\n", FLT_MANT_DIG);
-#endif   // FLT_MANT_DIG
-
-#if defined (FLT_MAX_10_EXP)
-    printf ("#define _RWSTD_FLT_MAX_10_EXP %d\n", FLT_MAX_10_EXP);
-#endif   // FLT_MAX_10_EXP
-
-#if defined (FLT_MAX_EXP)
-    printf ("#define _RWSTD_FLT_MAX_EXP %d\n", FLT_MAX_EXP);
-#endif   // FLT_MAX_EXP
-
-#if defined (FLT_MIN_10_EXP)
-    printf ("#define _RWSTD_FLT_MIN_10_EXP %d\n", FLT_MIN_10_EXP);
-#endif   // FLT_MIN_10_EXP
-
-#if defined (FLT_MIN_EXP)
-    printf ("#define _RWSTD_FLT_MIN_EXP %d\n", FLT_MIN_EXP);
-#endif   // FLT_MIN_EXP
-
-#if defined (FLT_RADIX)
-    printf ("#define _RWSTD_FLT_RADIX %d\n", FLT_RADIX);
-#endif   // FLT_RADIX
-
-
-#ifndef _RWSTD_NO_LONG_DOUBLE
-
-#  if !defined (LDBL_DIG)
-#    define LDBL_DIG   31
-#  endif   // LDBL_DIG
-
-    printf ("#define _RWSTD_LDBL_DIG %d\n", LDBL_DIG);
-
-
-#  if defined (LDBL_MANT_DIG)
-    printf ("#define _RWSTD_LDBL_MANT_DIG %d\n", LDBL_MANT_DIG);
-#  endif   // LDBL_MANT_DIG
-
-#  if defined (LDBL_MAX_10_EXP)
-    printf ("#define _RWSTD_LDBL_MAX_10_EXP %d\n", LDBL_MAX_10_EXP);
-#  endif   // LDBL_MAX_10_EXP
-
-#  if defined (LDBL_MAX_EXP)
-    printf ("#define _RWSTD_LDBL_MAX_EXP %d\n", LDBL_MAX_EXP);
-#  endif   // LDBL_MAX_EXP
-
-#  if defined (LDBL_MIN_10_EXP)
-    printf ("#define _RWSTD_LDBL_MIN_10_EXP %d\n", LDBL_MIN_10_EXP);
-#  endif   // LDBL_MIN_10_EXP
-
-#  if defined (LDBL_MIN_EXP)
-    printf ("#define _RWSTD_LDBL_MIN_EXP %d\n", LDBL_MIN_EXP);
-#  endif   // LDBL_MIN_EXP
-
-#endif   //  _RWSTD_NO_LONG_DOUBLE
-
-
-#if defined (DBL_MAX)
-    PRINTFLT (DBL_MAX, "l", DBL_DIG, "");
-#endif   // DBL_MAX
-
-#if defined (FLT_MAX)
-    PRINTFLT (FLT_MAX, "", FLT_DIG, "F");
-#endif   // FLT_MAX
-
-#ifndef _RWSTD_NO_LONG_DOUBLE
-#  if defined (LDBL_MAX)
-    PRINTFLT (LDBL_MAX, LDBL_FMT, DBL_DIG, "F");
-#  endif   // LDBL_MAX
-#endif   // _RWSTD_NO_LONG_DOUBLE
-
-#if defined (DBL_EPSILON)
-    PRINTFLT (DBL_EPSILON, "l", DBL_DIG, "");
-#endif   // DBL_EPSILON
-
-#if defined (DBL_MIN)
-    PRINTFLT (DBL_MIN, "l", DBL_DIG, "");
-#endif   // DBL_MIN
-
-#if defined (FLT_EPSILON)
-    PRINTFLT (FLT_EPSILON, "", FLT_DIG, "F");
-#endif   // FLT_EPSILON
-
-#if defined (FLT_MIN)
-    PRINTFLT (FLT_MIN, "", FLT_DIG, "F");
-#endif   // FLT_MIN
-
-#ifndef _RWSTD_NO_LONG_DOUBLE
-#  if defined (LDBL_EPSILON)
-    PRINTFLT (LDBL_EPSILON, LDBL_FMT, LDBL_DIG, "L");
-#  endif   // LDBL_EPSILON
-
-#  if defined (LDBL_MIN)
-    PRINTFLT (LDBL_MIN, LDBL_FMT, LDBL_DIG, "L");
-#  endif   // LDBL_MIN
-#endif   // _RWSTD_NO_LONG_DOUBLE
-
-
-#if !defined (ERANGE)
-#  define ERANGE -1
-#endif   // ERANGE
-
-#ifndef _RWSTD_NO_STRTOF
-
-    errno = 0;
-
-    // determine whether strtof() sets errno on underflow
-    const float f = strtof ("1.0e-999", (char**)0);
-
-
-    if (f < 0.0 || f > 1.0 || !errno)
-        printf ("#define _RWSTD_NO_STRTOF_UFLOW\n");
-    else
-        printf ("// #define _RWSTD_NO_STRTOF_UFLOW    // %d%s\n",
-                errno, ERANGE == errno ? " (ERANGE)" : "");
-
-#endif   // _RWSTD_NO_STRTOF
-
-#ifndef _RWSTD_NO_STRTOD
-
-    errno = 0;
-
-    // determine whether strtod() sets errno on underflow
-    const double d = strtod ("1.0e-999", (char**)0);
-
-
-    if (d < 0.0 || d > 1.0 || !errno)
-        printf ("#define _RWSTD_NO_STRTOD_UFLOW\n");
-    else
-        printf ("// #define _RWSTD_NO_STRTOD_UFLOW    // %d%s\n",
-                errno, ERANGE == errno ? " (ERANGE)" : "");
-
-#endif   // _RWSTD_NO_STRTOD
+    if (16 == char_bits * sizeof (short) && !(width_bits & 2)) {
+        width_bits |= 2;
+        PRINT_SPECIFIC (16, "", "short");
+    }
+    else if (32 == char_bits * sizeof (short) && !(width_bits & 4)) {
+        width_bits |= 4;
+        PRINT_SPECIFIC (32, "", "short");
+    }
+    else if (64 == char_bits * sizeof (short) && !(width_bits & 8)) {
+        width_bits |= 8;
+        PRINT_SPECIFIC (64, "", "short");
+    }
+    else if (128 == char_bits * sizeof (short) && !(width_bits & 16)) {
+        width_bits |= 16;
+        PRINT_SPECIFIC (128, "", "short");
+    }
 
-#ifndef _RWSTD_NO_LONG_DOUBLE
-#  ifndef _RWSTD_NO_STRTOLD
+    if (32 == char_bits * sizeof (int) && !(width_bits & 4)) {
+        width_bits |= 4;
+        PRINT_SPECIFIC (32, "", "int");
+    }
+    else if (64 == char_bits * sizeof (int) && !(width_bits & 8)) {
+        width_bits |= 8;
+        PRINT_SPECIFIC (64, "", "int");
+    }
+    else if (128 == char_bits * sizeof (int) && !(width_bits & 16)) {
+        width_bits |= 16;
+        PRINT_SPECIFIC (128, "", "int");
+    }
 
-    errno = 0;
+    if (32 == char_bits * sizeof (long) && !(width_bits & 4)) {
+        width_bits |= 4;
+        PRINT_SPECIFIC (32, "", "long");
+    }
+    else if (64 == char_bits * sizeof (long) && !(width_bits & 8)) {
+        width_bits |= 8;
+        PRINT_SPECIFIC (64, "", "long");
+    }
+    else if (128 == char_bits * sizeof (long) && !(width_bits & 16)) {
+        width_bits |= 16;
+        PRINT_SPECIFIC (128, "", "long");
+    }
 
-#    if !defined (__hpux)
+    if (32 == char_bits * sizeof (LLong) && !(width_bits & 4)) {
+        width_bits |= 4;
+        PRINT_SPECIFIC (32, "", llong_name);
+    }
+    else if (64 == char_bits * sizeof (LLong) && !(width_bits & 8)) {
+        width_bits |= 8;
+        PRINT_SPECIFIC (64, "", llong_name);
 
-    // determine whether strtold() sets errno on underflow
-    const long double ld = strtold ("1.0e-9999", (char**)0);
+    }
+    else if (128 == char_bits * sizeof (LLong) && !(width_bits & 16)) {
+        width_bits |= 16;
+        PRINT_SPECIFIC (128, "", llong_name);
+    }
 
-#    else
+    //////////////////////////////////////////////////////////////////
+    // print the names of the width-specific least integer types
+    // i.e., INT_LEAST8_T, INT_LEAST16_T, INT_LEAST32_T, ...
 
-    union {
-        long double ld;
-        long_double data;
-    } ldu;
-
-    ldu.data = strtold ("1.0e-9999", (char**)0);
-    const long double ld = ldu.ld;
-
-#    endif   // __hpux
-
-    if (ld < 0.0 || ld > 1.0 || !errno)
-        printf ("#define _RWSTD_NO_STRTOLD_UFLOW\n");
-    else
-        printf ("// #define _RWSTD_NO_STRTOLD_UFLOW   // %d%s\n",
-                errno, ERANGE == errno ? " (ERANGE)" : "");
+    if (width_bits & (1 << 0))
+        PRINT_SPECIFIC (8, "_LEAST", "INT8");
+    else if (width_bits & (1 << 1))
+        PRINT_SPECIFIC (8, "_LEAST", "INT16");
+    else if (width_bits & (1 << 2))
+        PRINT_SPECIFIC (8, "_LEAST", "INT32");
+    else if (width_bits & (1 << 3))
+        PRINT_SPECIFIC (8, "_LEAST", "INT64");
+    else if (width_bits & (1 << 4))
+        PRINT_SPECIFIC (8, "_LEAST", "INT128");
+
+    if (width_bits & (1 << 1))
+        PRINT_SPECIFIC (16, "_LEAST", "INT16");
+    else if (width_bits & (1 << 2))
+        PRINT_SPECIFIC (16, "_LEAST", "INT32");
+    else if (width_bits & (1 << 3))
+        PRINT_SPECIFIC (16, "_LEAST", "INT64");
+    else if (width_bits & (1 << 4))
+        PRINT_SPECIFIC (16, "_LEAST", "INT128");
+
+    if (width_bits & (1 << 2))
+        PRINT_SPECIFIC (32, "_LEAST", "INT32");
+    else if (width_bits & (1 << 3))
+        PRINT_SPECIFIC (32, "_LEAST", "INT64");
+    else if (width_bits & (1 << 4))
+        PRINT_SPECIFIC (32, "_LEAST", "INT128");
+
+    if (width_bits & (1 << 3))
+        PRINT_SPECIFIC (64, "_LEAST", "INT64");
+    else if (width_bits & (1 << 4))
+        PRINT_SPECIFIC (64, "_LEAST", "INT128");
 
-#  endif   // _RWSTD_NO_STRTOLD
-#endif   // _RWSTD_NO_LONG_DOUBLE
+    if (width_bits & (1 << 4))
+        PRINT_SPECIFIC (128, "_LEAST", "INT128");
 
     return 0;
 }

Modified: incubator/stdcxx/trunk/etc/config/src/SIG_ATOMIC_T.cpp
URL: http://svn.apache.org/viewcvs/incubator/stdcxx/trunk/etc/config/src/SIG_ATOMIC_T.cpp?rev=373578&r1=373577&r2=373578&view=diff
==============================================================================
--- incubator/stdcxx/trunk/etc/config/src/SIG_ATOMIC_T.cpp (original)
+++ incubator/stdcxx/trunk/etc/config/src/SIG_ATOMIC_T.cpp Mon Jan 30 12:01:37 2006
@@ -7,22 +7,18 @@
 #  include "config.h"
 #endif   // _RWSTD_USE_CONFIG
 
-
-const char* foo (char)               { return "char"; }
-const char* foo (short)              { return "short"; }
-const char* foo (unsigned short)     { return "unsigned short"; }
-const char* foo (int)                { return "int"; }
-const char* foo (unsigned int)       { return "unsigned int"; }
-const char* foo (long)               { return "long"; }
-const char* foo (unsigned long)      { return "unsigned long"; }
-
+// establish a dependency on the test for long long
+// and #define the LONG_LONG macro used in "type.h"
 #ifndef _RWSTD_NO_LONG_LONG
-
-const char* foo (long long)          { return "long long"; }
-const char* foo (unsigned long long) { return "unsigned long long"; }
-
+#  define LONG_LONG long long
+#else   // if defined (_RWSTD_NO_LONG_LONG)
+#  if defined (_MSC_VER)
+#    define LONG_LONG   __int64
+#  endif   // _MSC_VER
 #endif   // _RWSTD_NO_LONG_LONG
 
+#include "types.h"   // for type_name()
+
 
 int main ()
 {
@@ -33,43 +29,54 @@
 #endif   // _RWSTD_USE_CONFIG
 
 #ifdef SIG_DFL
-    printf ("#define _RWSTD_SIG_DFL %d\n", SIG_DFL);
+    printf ("#define _RWSTD_SIG_DFL         %2d\n", SIG_DFL);
 #endif   // SIG_DFL
 
 #if defined (SIG_ERR)
-    printf ("#define _RWSTD_SIG_ERR %d\n", SIG_ERR);
+    printf ("#define _RWSTD_SIG_ERR         %2d\n", SIG_ERR);
 #endif   // SIG_ERR
 
 #if defined (SIG_IGN)
-    printf ("#define _RWSTD_SIG_IGN %d\n", SIG_IGN);
+    printf ("#define _RWSTD_SIG_IGN         %2d\n", SIG_IGN);
 #endif   // SIG_IGN
 
 #if defined (SIGABRT)
-    printf ("#define _RWSTD_SIGABRT %d\n", SIGABRT);
+    printf ("#define _RWSTD_SIGABRT         %2d\n", SIGABRT);
 #endif   // SIGABRT
 
 #if defined (SIGFPE)
-    printf ("#define _RWSTD_SIGFPE %d\n", SIGFPE);
+    printf ("#define _RWSTD_SIGFPE          %2d\n", SIGFPE);
 #endif   // SIGFPE
 
 #if defined (SIGILL)
-    printf ("#define _RWSTD_SIGILL %d\n", SIGILL);
+    printf ("#define _RWSTD_SIGILL          %2d\n", SIGILL);
 #endif   // SIGILL
 
 #if defined (SIGINT)
-    printf ("#define _RWSTD_SIGINT %d\n", SIGINT);
+    printf ("#define _RWSTD_SIGINT          %2d\n", SIGINT);
 #endif   // SIGINT
 
 #if defined (SIGSEGV)
-    printf ("#define _RWSTD_SIGSEGV %d\n", SIGSEGV);
+    printf ("#define _RWSTD_SIGSEGV         %2d\n", SIGSEGV);
 #endif   // SIGSEGV
 
 #if defined (SIGTERM)
-    printf ("#define _RWSTD_SIGTERM %d\n", SIGTERM);
+    printf ("#define _RWSTD_SIGTERM         %2d\n", SIGTERM);
 #endif   // SIGTERM
 
+    //////////////////////////////////////////////////////////////////
+    // determine the underlying arithmetic type
+
     sig_atomic_t atomic = 0;
-    printf ("#define _RWSTD_SIG_ATOMIC_T %s\n", foo (atomic));
+    const char* const tname = type_name (atomic);
+    printf ("#define _RWSTD_SIG_ATOMIC_T   %s\n", tname);
+
+    // compute the type's minimum and maximum
+    const char* const symbol = type_name (++atomic);
+
+    printf ("#define _RWSTD_SIG_ATOMIC_MIN _RWSTD_%s_MIN\n"
+            "#define _RWSTD_SIG_ATOMIC_MAX _RWSTD_%s_MAX\n",
+            symbol, symbol);
 
     return 0;
 }

Modified: incubator/stdcxx/trunk/etc/config/src/SIZE_T.cpp
URL: http://svn.apache.org/viewcvs/incubator/stdcxx/trunk/etc/config/src/SIZE_T.cpp?rev=373578&r1=373577&r2=373578&view=diff
==============================================================================
--- incubator/stdcxx/trunk/etc/config/src/SIZE_T.cpp (original)
+++ incubator/stdcxx/trunk/etc/config/src/SIZE_T.cpp Mon Jan 30 12:01:37 2006
@@ -6,41 +6,24 @@
 
 #include <stddef.h>
 #include <stdio.h>
-#include <stdlib.h>
-#include <time.h>
+#include <stdlib.h>   // for RAND_MAX
+#include <time.h>     // for CLOCKS_PER_SEC
 
-#ifndef _RWSTD_NO_WCHAR_H
-#  include <wchar.h>
-#endif   // _RWSTD_NO_WCHAR_H
-
-
-// determine the underlying arithmetic type of a typedef
-#define DEFINE_TYPE_HELPER(T)                       \
-    const char* get_type_name (T) { return # T; }   \
-    typedef void unused_type
-
-
-DEFINE_TYPE_HELPER (char);
-DEFINE_TYPE_HELPER (short);
-DEFINE_TYPE_HELPER (unsigned short);
-DEFINE_TYPE_HELPER (int);
-DEFINE_TYPE_HELPER (unsigned int);
-DEFINE_TYPE_HELPER (long);
-DEFINE_TYPE_HELPER (unsigned long);
+#ifndef _RWSTD_NO_WCTYPE_H
+#  include <wctype.h>   // for WEOF
+#endif   // _RWSTD_NO_WCTYPE_H
 
+// establish a dependency on the test for long long
+// and #define the LONG_LONG macro used in "type.h"
 #ifndef _RWSTD_NO_LONG_LONG
+#  define LONG_LONG long long
+#else   // if defined (_RWSTD_NO_LONG_LONG)
+#  if defined (_MSC_VER)
+#    define LONG_LONG   __int64
+#  endif   // _MSC_VER
+#endif   // _RWSTD_NO_LONG_LONG
 
-DEFINE_TYPE_HELPER (long long);
-DEFINE_TYPE_HELPER (unsigned long long);
-
-#elif defined (_MSC_VER)
-
-DEFINE_TYPE_HELPER (__int64);
-DEFINE_TYPE_HELPER (unsigned __int64);
-
-#endif   // _RWSTD_NO_LONG_LONG, _MSC_VER
-
-const char* get_type_name (...) { return 0; }
+#include "types.h"   // for type_name()
 
 
 void get_type_names (int dummy, ...)
@@ -57,10 +40,21 @@
 
 #endif   // _RWSTD_USE_CONFIG
 
-    printf ("#define _RWSTD_CLOCK_T %s\n", get_type_name (clk));
-    printf ("#define _RWSTD_PTRDIFF_T %s\n", get_type_name (diff));
-    printf ("#define _RWSTD_SIZE_T %s\n", get_type_name (size));
-    printf ("#define _RWSTD_TIME_T %s\n", get_type_name (tim));
+    printf ("#define _RWSTD_CLOCK_T        %s\n", type_name (clk));
+    printf ("#define _RWSTD_PTRDIFF_T      %s\n", type_name (diff));
+    printf ("#define _RWSTD_SIZE_T         %s\n", type_name (size));
+
+    // compute the maximum and minimum for size_t and ptrdiff_t
+    ++size;
+    ++diff;
+    printf ("#define _RWSTD_SIZE_MAX       _RWSTD_%s_MAX\n",
+            type_name (size));
+    printf ("#define _RWSTD_PTRDIFF_MIN    _RWSTD_%s_MIN\n"
+            "#define _RWSTD_PTRDIFF_MAX    _RWSTD_%s_MAX\n",
+            type_name (diff), type_name (diff));
+
+
+    printf ("#define _RWSTD_TIME_T         %s\n", type_name (tim));
 
 #if defined (CLOCKS_PER_SEC)
     printf ("#define _RWSTD_CLOCKS_PER_SEC %d\n", CLOCKS_PER_SEC);
@@ -69,13 +63,13 @@
 #endif   // CLOCKS_PER_SEC
 
 #if defined (RAND_MAX)
-    printf ("#define _RWSTD_RAND_MAX %d\n", RAND_MAX);
+    printf ("#define _RWSTD_RAND_MAX       %d\n", RAND_MAX);
 #else
     printf ("#define _RWSTD_NO_RAND_MAX\n");
 #endif   // RAND_MAX
 
 #if defined (EOF)
-    printf ("#define _RWSTD_EOF %d\n", EOF);
+    printf ("#define _RWSTD_EOF            %d\n", EOF);
 #else
     // define _RWSTD_EOF to the usual value even if WEOF is not #defined
     // to avoid having to #ifdef around wchar_t code that needs the macro
@@ -86,7 +80,7 @@
 #endif   // EOF
 
 #if defined (WEOF)
-    printf ("#define _RWSTD_WEOF %d\n", WEOF);
+    printf ("#define _RWSTD_WEOF           %d\n", WEOF);
 #else
     // define _RWSTD_WEOF to the usual value even if WEOF is not #defined
     // to avoid having to #ifdef around wchar_t code that needs the macro
@@ -97,59 +91,59 @@
 #endif   // WEOF
 
 #if defined (L_tmpnam)
-    printf ("#define _RWSTD_L_TMPNAM %d\n", L_tmpnam);
+    printf ("#define _RWSTD_L_TMPNAM       %d\n", L_tmpnam);
 #else
     printf ("#define _RWSTD_NO_L_TMPNAM\n");
 #endif   // L_tmpnam
 
 #if defined (_IOFBF)
-    printf ("#define _RWSTD_IOFBF %d\n", _IOFBF);
+    printf ("#define _RWSTD_IOFBF          %d\n", _IOFBF);
 #else
     printf ("#define _RWSTD_NO_IOFBF\n");
 #endif   // _IOFBF
 
 #if defined (_IOLBF)
-    printf ("#define _RWSTD_IOLBF %d\n", _IOLBF);
+    printf ("#define _RWSTD_IOLBF          %d\n", _IOLBF);
 #else
     printf ("#define _RWSTD_NO_IOLBF\n");
 #endif   // _IOLBF
 
 #if defined (_IONBF)
-    printf ("#define _RWSTD_IONBF %d\n", _IONBF);
+    printf ("#define _RWSTD_IONBF          %d\n", _IONBF);
 #else
     printf ("#define _RWSTD_NO_IONBF\n");
 #endif   // _IONBF
 
 #if defined (BUFSIZ)
-    printf ("#define _RWSTD_BUFSIZ %d\n", BUFSIZ);
+    printf ("#define _RWSTD_BUFSIZ         %d\n", BUFSIZ);
 #else
     printf ("#define _RWSTD_NO_BUFSIZ\n");
 #endif   // BUFSIZ
 
 #if defined (FOPEN_MAX)
-    printf ("#define _RWSTD_FOPEN_MAX %d\n", FOPEN_MAX);
+    printf ("#define _RWSTD_FOPEN_MAX      %d\n", FOPEN_MAX);
 #else
     printf ("#define _RWSTD_NO_FOPEN_MAX\n");
 #endif   // FOPEN_MAX
 
 #if defined (FILENAME_MAX)
-    printf ("#define _RWSTD_FILENAME_MAX %d\n", FILENAME_MAX);
+    printf ("#define _RWSTD_FILENAME_MAX   %d\n", FILENAME_MAX);
 #else
     printf ("#define _RWSTD_NO_FILENAME_MAX\n");
 #endif   // FILENAME_MAX
 
 #if defined (TMP_MAX)
-    printf ("#define _RWSTD_TMP_MAX %d\n", TMP_MAX);
+    printf ("#define _RWSTD_TMP_MAX        %d\n", TMP_MAX);
 #else
     printf ("#define _RWSTD_NO_TMP_MAX\n");
 #endif   // TMP_MAX
 
-    if (get_type_name (pos))
-        printf ("#define _RWSTD_FPOS_T %s\n", get_type_name (pos));
+    if (type_name (pos))
+        printf ("#define _RWSTD_FPOS_T         %s\n", type_name (pos));
     else {
         printf ("#define _RWSTD_NO_NATIVE_FPOS_T"
                 "/* may be an aggregate */\n");
-        printf ("#define _RWSTD_FPOS_T_SIZE %u\n", sizeof pos);
+        printf ("#define _RWSTD_FPOS_T_SIZE    %u\n", sizeof pos);
     }
 }
 

Modified: incubator/stdcxx/trunk/etc/config/src/WINT_T.cpp
URL: http://svn.apache.org/viewcvs/incubator/stdcxx/trunk/etc/config/src/WINT_T.cpp?rev=373578&r1=373577&r2=373578&view=diff
==============================================================================
--- incubator/stdcxx/trunk/etc/config/src/WINT_T.cpp (original)
+++ incubator/stdcxx/trunk/etc/config/src/WINT_T.cpp Mon Jan 30 12:01:37 2006
@@ -10,40 +10,44 @@
 
 #ifndef _RWSTD_NO_WCTYPE_H
 #  include <wctype.h>
-#endif
+#endif   // _RWSTD_NO_WCTYPE_H
 
 #include <stdio.h>
 
-
-const char* foo (char)               { return "char"; }
-const char* foo (signed char)        { return "signed char"; }
-const char* foo (unsigned char)      { return "unsigned char"; }
-const char* foo (short)              { return "short"; }
-const char* foo (unsigned short)     { return "unsigned short"; }
-const char* foo (int)                { return "int"; }
-const char* foo (unsigned int)       { return "unsigned int"; }
-const char* foo (long)               { return "long"; }
-const char* foo (unsigned long)      { return "unsigned long"; }
-
+// establish a dependency on the test for long long
+// and #define the LONG_LONG macro used in "type.h"
 #ifndef _RWSTD_NO_LONG_LONG
-
-const char* foo (long long)          { return "long long"; }
-const char* foo (unsigned long long) { return "unsigned long long"; }
-
+#  define LONG_LONG long long
+#else   // if defined (_RWSTD_NO_LONG_LONG)
+#  if defined (_MSC_VER)
+#    define LONG_LONG   __int64
+#  endif   // _MSC_VER
 #endif   // _RWSTD_NO_LONG_LONG
 
+#include "types.h"   // for type_name()
+
 
 int main ()
 {
 #if !defined (_RWSTD_USE_CONFIG)
 
-    printf ("#undef _RWSTD_WINT_T\n");
+    printf ("/**/\n#undef _RWSTD_WINT_T\n");
 
 #endif   // _RWSTD_USE_CONFIG
 
+    //////////////////////////////////////////////////////////////////
+    // determine the underlying arithmetic type
+
     wint_t wi = 0;
+    const char* const tname = type_name (wi);
+    printf ("#define _RWSTD_WINT_T   %s\n", tname);
+
+    // compute the type's minimum and maximum
+    const char* const symbol = type_name (++wi);
 
-    printf ("#define _RWSTD_WINT_T %s\n", foo (wi));
+    printf ("#define _RWSTD_WINT_MIN _RWSTD_%s_MIN\n"
+            "#define _RWSTD_WINT_MAX _RWSTD_%s_MAX\n",
+            symbol, symbol);
 
     return 0;
 }

Added: incubator/stdcxx/trunk/etc/config/src/types.h
URL: http://svn.apache.org/viewcvs/incubator/stdcxx/trunk/etc/config/src/types.h?rev=373578&view=auto
==============================================================================
--- incubator/stdcxx/trunk/etc/config/src/types.h (added)
+++ incubator/stdcxx/trunk/etc/config/src/types.h Mon Jan 30 12:01:37 2006
@@ -0,0 +1,32 @@
+// definitions of the type_name() helper overloads
+
+#define STRSTR(symbol)   #symbol
+#define STR(symbol)      STRSTR (symbol)
+#define DEFINE_TYPE_HELPER(T, symbol)                   \
+    const char* type_name (T t) {                       \
+        if (t) return symbol; else return STR (T);      \
+    } typedef void unused_typedef
+
+
+DEFINE_TYPE_HELPER (char, "CHAR");
+DEFINE_TYPE_HELPER (signed char, "SCHAR");
+DEFINE_TYPE_HELPER (unsigned char, "UCHAR");
+
+DEFINE_TYPE_HELPER (short, "SHRT");
+DEFINE_TYPE_HELPER (unsigned short, "USHRT");
+
+DEFINE_TYPE_HELPER (int, "INT");
+DEFINE_TYPE_HELPER (unsigned, "UINT");
+
+DEFINE_TYPE_HELPER (long, "LONG");
+DEFINE_TYPE_HELPER (unsigned long, "ULONG");
+
+#ifdef LONG_LONG
+
+DEFINE_TYPE_HELPER (LONG_LONG, "LLONG");
+DEFINE_TYPE_HELPER (unsigned LONG_LONG, "ULLONG");
+
+#endif   // LONG_LONG
+
+// for any other type
+const char* type_name (...) { return 0; }

Propchange: incubator/stdcxx/trunk/etc/config/src/types.h
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/stdcxx/trunk/etc/config/src/types.h
------------------------------------------------------------------------------
    svn:keywords = Id



Mime
View raw message