Commit 585e661a by Gabriel Dos Reis Committed by Gabriel Dos Reis

c-common.c (builtin_define_type_precision): New function.

gcc/
 2002-08-28  Gabriel Dos Reis  <gdr@integrable-solutions.net>

 * c-common.c (builtin_define_type_precision): New function.
 (cb_register_builtins): Use it.  Define __WCHAR_UNSIGNED__ is
 wchar_t is unsigned in C++.
 * doc/cpp.texi (Common Predefined Macros): Document
 __WCHAR_UNSIGNED__, __CHAR_BIT__, __WCHAR_BIT__, __SHRT_BIT__,
 __INT_BIT__, __LONG_BIT__, __LONG_LONG_BIT__, __FLOAT_BIT__,
 __DOUBLE_BIT__, __LONG_DOUBLE_BIT__.

libstdc++-v3/

2002-08-28  Gabriel Dos Reis  <gdr@integrable-solutions.net>

	    * include/std/std_limits.h (__glibcpp_char_bits,
	    __glibcpp_short_bits, __glibcpp_int_bits,
	    __glibcpp_long_bits,
	    __glibcpp_long_long_bits, __glibcpp_float_bits,
	    __glibcpp_double_bits, __glibcpp_long_double_bits):
	    Remove.  Use
	    compiler predifined macros.
	    (__glibcpp_wchar_t_is_signed): Define based on compiler
	    predefined
	    __WCHAR_UNSIGNED__.

From-SVN: r56646
parent 07ec1151
2002-08-28 Gabriel Dos Reis <gdr@integrable-solutions.net>
* c-common.c (builtin_define_type_precision): New function.
(cb_register_builtins): Use it. Define __WCHAR_UNSIGNED__ is
wchar_t is unsigned in C++.
* doc/cpp.texi (Common Predefined Macros): Document
__WCHAR_UNSIGNED__, __CHAR_BIT__, __WCHAR_BIT__, __SHRT_BIT__,
__INT_BIT__, __LONG_BIT__, __LONG_LONG_BIT__, __FLOAT_BIT__,
__DOUBLE_BIT__, __LONG_DOUBLE_BIT__.
2002-08-28 Sylvain Pion <pion@cs.nyu.edu> 2002-08-28 Sylvain Pion <pion@cs.nyu.edu>
* doc/invoke.texi (-Wreorder): Remove remaining pieces from the generic * doc/invoke.texi (-Wreorder): Remove remaining pieces from the generic
......
...@@ -760,9 +760,10 @@ static bool get_nonnull_operand PARAMS ((tree, ...@@ -760,9 +760,10 @@ static bool get_nonnull_operand PARAMS ((tree,
unsigned HOST_WIDE_INT *)); unsigned HOST_WIDE_INT *));
void builtin_define_std PARAMS ((const char *)); void builtin_define_std PARAMS ((const char *));
static void builtin_define_with_value PARAMS ((const char *, const char *, static void builtin_define_with_value PARAMS ((const char *, const char *,
int)); int));
static void builtin_define_type_max PARAMS ((const char *, tree, int)); static void builtin_define_type_max PARAMS ((const char *, tree, int));
static void cpp_define_data_format PARAMS ((cpp_reader *)); static void cpp_define_data_format PARAMS ((cpp_reader *));
static void builtin_define_type_precision PARAMS ((const char *, tree));
/* Table of machine-independent attributes common to all C-like languages. */ /* Table of machine-independent attributes common to all C-like languages. */
const struct attribute_spec c_common_attribute_table[] = const struct attribute_spec c_common_attribute_table[] =
...@@ -4765,6 +4766,17 @@ cpp_define_data_format (pfile) ...@@ -4765,6 +4766,17 @@ cpp_define_data_format (pfile)
builtin_define_with_value ("__GCC_FLOAT_FORMAT__", format, 0); builtin_define_with_value ("__GCC_FLOAT_FORMAT__", format, 0);
} }
/* Define NAME with value TYPE precision. */
static void
builtin_define_type_precision (name, type)
const char *name;
tree type;
{
char buf[8];
sprintf (buf, "%d", (int) TYPE_PRECISION (type));
builtin_define_with_value (name, buf, 0);
}
/* Hook that registers front end and target-specific built-ins. */ /* Hook that registers front end and target-specific built-ins. */
void void
cb_register_builtins (pfile) cb_register_builtins (pfile)
...@@ -4807,11 +4819,16 @@ cb_register_builtins (pfile) ...@@ -4807,11 +4819,16 @@ cb_register_builtins (pfile)
builtin_define_type_max ("__LONG_MAX__", long_integer_type_node, 1); builtin_define_type_max ("__LONG_MAX__", long_integer_type_node, 1);
builtin_define_type_max ("__LONG_LONG_MAX__", long_long_integer_type_node, 2); builtin_define_type_max ("__LONG_LONG_MAX__", long_long_integer_type_node, 2);
{ builtin_define_type_precision ("__CHAR_BIT__", char_type_node);
char buf[8]; builtin_define_type_precision ("__WCHAR_BIT__", wchar_type_node);
sprintf (buf, "%d", (int) TYPE_PRECISION (signed_char_type_node)); builtin_define_type_precision ("__SHRT_BIT__", short_integer_type_node);
builtin_define_with_value ("__CHAR_BIT__", buf, 0); builtin_define_type_precision ("__INT_BIT__", integer_type_node);
} builtin_define_type_precision ("__LONG_BIT__", long_integer_type_node);
builtin_define_type_precision ("__LONG_LONG_BIT__",
long_long_integer_type_node);
builtin_define_type_precision ("__FLOAT_BIT__", float_type_node);
builtin_define_type_precision ("__DOUBLE_BIT__", double_type_node);
builtin_define_type_precision ("__LONG_DOUBLE_BIT__", long_double_type_node);
/* For use in assembly language. */ /* For use in assembly language. */
builtin_define_with_value ("__REGISTER_PREFIX__", REGISTER_PREFIX, 0); builtin_define_with_value ("__REGISTER_PREFIX__", REGISTER_PREFIX, 0);
...@@ -4849,6 +4866,9 @@ cb_register_builtins (pfile) ...@@ -4849,6 +4866,9 @@ cb_register_builtins (pfile)
if (!flag_signed_char) if (!flag_signed_char)
cpp_define (pfile, "__CHAR_UNSIGNED__"); cpp_define (pfile, "__CHAR_UNSIGNED__");
if (c_language == clk_cplusplus && TREE_UNSIGNED (wchar_type_node))
cpp_define (pfile, "__WCHAR_UNSIGNED__");
cpp_define_data_format (pfile); cpp_define_data_format (pfile);
/* Make the choice of ObjC runtime visible to source code. */ /* Make the choice of ObjC runtime visible to source code. */
......
...@@ -1972,6 +1972,10 @@ unsigned on the target machine. It exists to cause the standard header ...@@ -1972,6 +1972,10 @@ unsigned on the target machine. It exists to cause the standard header
file @file{limits.h} to work correctly. You should not use this macro file @file{limits.h} to work correctly. You should not use this macro
yourself; instead, refer to the standard macros defined in @file{limits.h}. yourself; instead, refer to the standard macros defined in @file{limits.h}.
@item __WCHAR_UNSIGNED__
Like @code{__CHAR_UNSIGNED__}, this macro is defined if and only if the
data type @code{wchar_t} is unsigned and the front-end is in C++ mode.
@item __REGISTER_PREFIX__ @item __REGISTER_PREFIX__
This macro expands to a single token (not a string constant) which is This macro expands to a single token (not a string constant) which is
the prefix applied to CPU register names in assembly language for this the prefix applied to CPU register names in assembly language for this
...@@ -2002,6 +2006,22 @@ typedefs, respectively. They exist to make the standard header files ...@@ -2002,6 +2006,22 @@ typedefs, respectively. They exist to make the standard header files
these macros directly; instead, include the appropriate headers and use these macros directly; instead, include the appropriate headers and use
the typedefs. the typedefs.
@item __CHAR_BIT__
@itemx __WCHAR_BIT__
@itemx __SHRT_BIT__
@itemx __INT_BIT__
@itemx __LONG_BIT__
@itemx __LONG_LONG_BIT__
@itemx __FLOAT_BIT__
@itemx __DOUBLE_BIT__
@itemx __LONG_DOUBLE_BIT__
These macros are defined to the number of bits used in the
representation of the data types @code{char}, @code{wchar_t},
@code{short}, @code{int}, @code{long}, @code{long long}, @code{float},
@code{double} and @code{long double}. They exist to make the standard
header given numerical limits work correctly. You should not use
these macros directly; instead, include the appropriate headers.
@item __USING_SJLJ_EXCEPTIONS__ @item __USING_SJLJ_EXCEPTIONS__
This macro is defined, with value 1, if the compiler uses the old This macro is defined, with value 1, if the compiler uses the old
mechanism based on @code{setjmp} and @code{longjmp} for exception mechanism based on @code{setjmp} and @code{longjmp} for exception
......
2002-08-28 Gabriel Dos Reis <gdr@integrable-solutions.net>
* include/std/std_limits.h (__glibcpp_char_bits,
__glibcpp_short_bits, __glibcpp_int_bits, __glibcpp_long_bits,
__glibcpp_long_long_bits, __glibcpp_float_bits,
__glibcpp_double_bits, __glibcpp_long_double_bits): Remove. Use
compiler predifined macros.
(__glibcpp_wchar_t_is_signed): Define based on compiler predefined
__WCHAR_UNSIGNED__.
2002-08-27 Gabriel Dos Reis <gdr@integrable-solutions.net> 2002-08-27 Gabriel Dos Reis <gdr@integrable-solutions.net>
* include/std/std_limits.h (__glibcpp_f32_infinity_bytes, * include/std/std_limits.h (__glibcpp_f32_infinity_bytes,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment