2001-01-17 Peter Schmid <schmid@snake.iap.physik.tu-darmstadt.de>
[official-gcc.git] / libstdc++-v3 / mknumeric_limits
blob589fe24b1f97d6b7d08e94444c52f3127aece567
1 #! /bin/sh
3 # mknumeric_limits: generates
4 # - part of bits/std_limits.h completed by gen-num-limits.cc
5 # - src/limitsMEMBERS.cc that contains the definition of various
6 # static data members of specialization of class template numeric_limits
9 echo "running mknumeric_limits"
11 case `uname` in
12 CYGWIN*)
13 LDFLAGS='-nodefaultlibs -lcygwin -lc -lkernel32 -lgcc' ;;
14 AIX*)
15 case $CXX in
16 *pthread*)
17 LDFLAGS='-nodefaultlibs -lgcc -L/usr/lib/threads -lpthreads -lc_r /usr/lib/libc.a' ;;
19 LDFLAGS='-nodefaultlibs -lgcc -lc' ;;
20 esac
23 LDFLAGS='-nodefaultlibs -lgcc -lc' ;;
24 esac
26 BUILD_DIR=$1
27 if [ ! -d "$BUILD_DIR" ]; then
28 echo "build directory $BUILD_DIR not found, exiting."
29 exit 1
32 if [ ! -d "$BUILD_DIR/include" ]; then
33 mkdir "$BUILD_DIR/include"
36 if [ ! -d "$BUILD_DIR/include/bits" ]; then
37 mkdir "$BUILD_DIR/include/bits"
40 if [ ! -d "$BUILD_DIR/src" ]; then
41 mkdir "$BUILD_DIR/src"
44 OUT_H="$BUILD_DIR/include/bits/std_limits.h"
45 OUT_C="$BUILD_DIR/src/limitsMEMBERS.cc"
47 if [ -f $OUT_C ]; then
48 rm -f $OUT_H $OUT_C $OUT_H-t $OUT_C-t
51 SRC_DIR=$2
52 if [ ! -d "$SRC_DIR" ]; then
53 echo "source directory $SRC_DIR not found, exiting."
54 exit 1
57 XCOMPILE=$3
58 if [ $XCOMPILE -eq 1 ]; then
59 echo "using default values for cross compiles"
60 cp $SRC_DIR/include/bits/limits_generic.h $OUT_H
61 cp $SRC_DIR/src/limits_generic.cc $OUT_C
62 exit 0;
63 fi
65 : ${CXX:="$BUILD_DIR/../../gcc/g++ -B$BUILD_DIR/../../gcc/"}
67 # We output to a temporary file, so that we don't appear to have
68 # succeeded unless we actually do.
69 cat <<EOF > $OUT_H-t
70 // The template and inlines for the -*- C++ -*- numeric_limits classes.
72 // Copyright (C) 1999, 2000 Free Software Foundation, Inc.
74 // This file is part of the GNU ISO C++ Library. This library is free
75 // software; you can redistribute it and/or modify it under the
76 // terms of the GNU General Public License as published by the
77 // Free Software Foundation; either version 2, or (at your option)
78 // any later version.
80 // This library is distributed in the hope that it will be useful,
81 // but WITHOUT ANY WARRANTY; without even the implied warranty of
82 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
83 // GNU General Public License for more details.
85 // You should have received a copy of the GNU General Public License along
86 // with this library; see the file COPYING. If not, write to the Free
87 // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
88 // USA.
90 // As a special exception, you may use this file as part of a free software
91 // library without restriction. Specifically, if other files instantiate
92 // templates or use macros or inline functions from this file, or you compile
93 // this file and link it with other files to produce an executable, this
94 // file does not by itself cause the resulting executable to be covered by
95 // the GNU General Public License. This exception does not however
96 // invalidate any other reasons why the executable file might be covered by
97 // the GNU General Public License.
99 // Note: this is not a conforming implementation.
100 // Written by Gabriel Dos Reis <Gabriel.Dos-Reis@cmla.ens-cachan.fr>
103 // THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT!
107 // ISO 14882:1998
108 // 18.2.1
111 #ifndef _CPP_NUMERIC_LIMITS
112 #define _CPP_NUMERIC_LIMITS 1
114 #include <bits/c++config.h>
115 #include <bits/std_cfloat.h>
117 namespace std {
119 enum float_round_style {
120 round_indeterminate = -1,
121 round_toward_zero = 0,
122 round_to_nearest = 1,
123 round_toward_infinity = 2,
124 round_toward_neg_infinity = 3
127 enum float_denorm_style {
128 denorm_indeterminate = -1,
129 denorm_absent = 0,
130 denorm_present = 1
133 template<typename _Tp> struct numeric_limits {
134 static const bool is_specialized = false;
136 static _Tp min() throw() { return static_cast<_Tp>(0); }
137 static _Tp max() throw() { return static_cast<_Tp>(0); }
139 static const int digits = 0;
140 static const int digits10 = 0;
141 static const bool is_signed = false;
142 static const bool is_integer = false;
143 static const bool is_exact = false;
144 static const int radix = 0;
146 static _Tp epsilon() throw() { return static_cast<_Tp>(0); }
147 static _Tp round_error() throw() { return static_cast<_Tp>(0); }
149 static const int min_exponent = 0;
150 static const int min_exponent10 = 0;
151 static const int max_exponent = 0;
152 static const int max_exponent10 = 0;
154 static const bool has_infinity = false;
155 static const bool has_quiet_NaN = false;
156 static const bool has_signaling_NaN = false;
157 static const float_denorm_style has_denorm = denorm_absent;
158 static const bool has_denorm_loss = false;
160 static _Tp infinity() throw() { return static_cast<_Tp>(0); }
161 static _Tp quiet_NaN() throw() { return static_cast<_Tp>(0); }
162 static _Tp signaling_NaN() throw() { return static_cast<_Tp>(0); }
163 static _Tp denorm_min() throw() { return static_cast<_Tp>(0); }
165 static const bool is_iec559 = false;
166 static const bool is_bounded = false;
167 static const bool is_modulo = false;
169 static const bool traps = false;
170 static const bool tinyness_before = false;
171 static const float_round_style round_style = round_toward_zero;
174 template<typename _Tp> _Tp __limits_infinity();
175 template<typename _Tp> _Tp __limits_quiet_NaN();
176 template<typename _Tp> _Tp __limits_signaling_NaN();
177 template<typename _Tp> _Tp __limits_denorm_min();
181 echo "$CXX $CPPFLAGS -I$BUILD_DIR/include \
182 -o "$BUILD_DIR/src/gen-num-limits" "$SRC_DIR/src/gen-num-limits.cc" \
183 $LDFLAGS"
185 $CXX $CPPFLAGS -I$BUILD_DIR/include \
186 -o "$BUILD_DIR/src/gen-num-limits" "$SRC_DIR/src/gen-num-limits.cc" \
187 $LDFLAGS
189 if [ ! -f "$BUILD_DIR/src/gen-num-limits" ]; then
190 echo "gen-num-limits failed to build, exiting."
191 exit 1
194 "$BUILD_DIR/src/gen-num-limits" >> $OUT_H-t
196 cat <<EOF >> $OUT_H-t
197 } // namespace std
199 #endif // _CPP_NUMERIC_LIMITS
202 trait_name=numeric_limits
204 cat <<EOF > $OUT_C-t
205 // Static data members of -*- C++ -*- numeric_limits classes
207 // Copyright (C) 1999, 2000 Free Software Foundation, Inc.
209 // This file is part of the GNU ISO C++ Library. This library is free
210 // software; you can redistribute it and/or modify it under the
211 // terms of the GNU General Public License as published by the
212 // Free Software Foundation; either version 2, or (at your option)
213 // any later version.
215 // This library is distributed in the hope that it will be useful,
216 // but WITHOUT ANY WARRANTY; without even the implied warranty of
217 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
218 // GNU General Public License for more details.
220 // You should have received a copy of the GNU General Public License along
221 // with this library; see the file COPYING. If not, write to the Free
222 // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
223 // USA.
225 // As a special exception, you may use this file as part of a free software
226 // library without restriction. Specifically, if other files instantiate
227 // templates or use macros or inline functions from this file, or you compile
228 // this file and link it with other files to produce an executable, this
229 // file does not by itself cause the resulting executable to be covered by
230 // the GNU General Public License. This exception does not however
231 // invalidate any other reasons why the executable file might be covered by
232 // the GNU General Public License.
234 // Written by Gabriel Dos Reis <Gabriel.Dos-Reis@cmla.ens-cachan.fr>
237 // ISO C++ 14882:1998
238 // 18.2.1
241 #include <bits/std_limits.h>
242 namespace std {
245 for type_name in bool char 'signed char' 'unsigned char' \
246 short 'unsigned short' int 'unsigned int' \
247 long 'unsigned long' 'long long' 'unsigned long long' \
248 float double 'long double'
250 grep "<$type_name>" $OUT_H-t >/dev/null 2>&1 || continue
251 cat <<EOF >> $OUT_C-t
253 const bool $trait_name<$type_name>::is_specialized;
254 const int $trait_name<$type_name>::digits;
255 const int $trait_name<$type_name>::digits10;
256 const bool $trait_name<$type_name>::is_signed;
257 const bool $trait_name<$type_name>::is_integer;
258 const bool $trait_name<$type_name>::is_exact;
259 const int $trait_name<$type_name>::radix;
260 const int $trait_name<$type_name>::min_exponent;
261 const int $trait_name<$type_name>::min_exponent10;
262 const int $trait_name<$type_name>::max_exponent;
263 const int $trait_name<$type_name>::max_exponent10;
264 const bool $trait_name<$type_name>::has_infinity;
265 const bool $trait_name<$type_name>::has_quiet_NaN;
266 const bool $trait_name<$type_name>::has_signaling_NaN;
267 const float_denorm_style $trait_name<$type_name>::has_denorm;
268 const bool $trait_name<$type_name>::has_denorm_loss;
269 const bool $trait_name<$type_name>::is_iec559;
270 const bool $trait_name<$type_name>::is_bounded;
271 const bool $trait_name<$type_name>::is_modulo;
272 const bool $trait_name<$type_name>::traps;
273 const bool $trait_name<$type_name>::tinyness_before;
274 const float_round_style $trait_name<$type_name>::round_style;
277 done
279 cat <<EOF >> $OUT_C-t
280 } // namespace std
285 mv $OUT_C-t $OUT_C
286 mv $OUT_H-t $OUT_H