]> gcc.gnu.org Git - gcc.git/blob - libstdc++-v3/mknumeric_limits
[multiple changes]
[gcc.git] / libstdc++-v3 / mknumeric_limits
1 #! /bin/sh
2
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
7 #
8
9 echo "running mknumeric_limits"
10
11 : ${CXX:=g++}
12
13 case `uname` in
14 CYGWIN*)
15 LDFLAGS='-nodefaultlibs -lcygwin -lc -lkernel32 -lgcc' ;;
16 *)
17 LDFLAGS='-nodefaultlibs -lgcc -lc' ;;
18 esac
19
20 BUILD_DIR=$1
21 if [ ! -d "$BUILD_DIR" ]; then
22 echo "build directory $BUILD_DIR not found, exiting."
23 exit 1
24 fi
25
26 if [ ! -d "$BUILD_DIR/bits" ]; then
27 mkdir "$BUILD_DIR/bits"
28 fi
29 if [ ! -d "$BUILD_DIR/src" ]; then
30 mkdir "$BUILD_DIR/src"
31 fi
32
33 OUT_H="$BUILD_DIR/bits/std_limits.h"
34 OUT_C="$BUILD_DIR/src/limitsMEMBERS.cc"
35
36 if [ -f $OUT_C ]; then
37 rm -f $OUT_H OUT_C
38 fi
39
40 SRC_DIR=$2
41 if [ ! -d "$SRC_DIR" ]; then
42 echo "source directory $SRC_DIR not found, exiting."
43 exit 1
44 fi
45
46 XCOMPILE=$3
47 if [ $XCOMPILE -eq 1 ]; then
48 echo "using default values for cross compiles"
49 cp $SRC_DIR/bits/limits_generic.h $OUT_H
50 cp $SRC_DIR/src/limits_generic.cc $OUT_C
51 exit 0;
52 fi
53
54 cat <<EOF > $OUT_H
55 // The template and inlines for the -*- C++ -*- numeric_limits classes.
56
57 // Copyright (C) 1999, 2000 Free Software Foundation, Inc.
58 //
59 // This file is part of the GNU ISO C++ Library. This library is free
60 // software; you can redistribute it and/or modify it under the
61 // terms of the GNU General Public License as published by the
62 // Free Software Foundation; either version 2, or (at your option)
63 // any later version.
64
65 // This library is distributed in the hope that it will be useful,
66 // but WITHOUT ANY WARRANTY; without even the implied warranty of
67 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
68 // GNU General Public License for more details.
69
70 // You should have received a copy of the GNU General Public License along
71 // with this library; see the file COPYING. If not, write to the Free
72 // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
73 // USA.
74
75 // As a special exception, you may use this file as part of a free software
76 // library without restriction. Specifically, if other files instantiate
77 // templates or use macros or inline functions from this file, or you compile
78 // this file and link it with other files to produce an executable, this
79 // file does not by itself cause the resulting executable to be covered by
80 // the GNU General Public License. This exception does not however
81 // invalidate any other reasons why the executable file might be covered by
82 // the GNU General Public License.
83
84 // Note: this is not a conforming implementation.
85 // Written by Gabriel Dos Reis <Gabriel.Dos-Reis@cmla.ens-cachan.fr>
86
87 //
88 // THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT!
89 //
90
91 //
92 // ISO 14882:1998
93 // 18.2.1
94 //
95
96 #ifndef _CPP_NUMERIC_LIMITS
97 #define _CPP_NUMERIC_LIMITS 1
98
99 #include <bits/c++config.h>
100 #include <bits/std_cfloat.h>
101
102 namespace std {
103
104 enum float_round_style {
105 round_indeterminate = -1,
106 round_toward_zero = 0,
107 round_to_nearest = 1,
108 round_toward_infinity = 2,
109 round_toward_neg_infinity = 3
110 };
111
112 enum float_denorm_style {
113 denorm_indeterminate = -1,
114 denorm_absent = 0,
115 denorm_present = 1
116 };
117
118 template<typename _Tp> struct numeric_limits {
119 static const bool is_specialized = false;
120
121 static _Tp min() throw() { return static_cast<_Tp>(0); }
122 static _Tp max() throw() { return static_cast<_Tp>(0); }
123
124 static const int digits = 0;
125 static const int digits10 = 0;
126 static const bool is_signed = false;
127 static const bool is_integer = false;
128 static const bool is_exact = false;
129 static const int radix = 0;
130
131 static _Tp epsilon() throw() { return static_cast<_Tp>(0); }
132 static _Tp round_error() throw() { return static_cast<_Tp>(0); }
133
134 static const int min_exponent = 0;
135 static const int min_exponent10 = 0;
136 static const int max_exponent = 0;
137 static const int max_exponent10 = 0;
138
139 static const bool has_infinity = false;
140 static const bool has_quiet_NaN = false;
141 static const bool has_signaling_NaN = false;
142 static const float_denorm_style has_denorm = denorm_absent;
143 static const bool has_denorm_loss = false;
144
145 static _Tp infinity() throw() { return static_cast<_Tp>(0); }
146 static _Tp quiet_NaN() throw() { return static_cast<_Tp>(0); }
147 static _Tp signaling_NaN() throw() { return static_cast<_Tp>(0); }
148 static _Tp denorm_min() throw() { return static_cast<_Tp>(0); }
149
150 static const bool is_iec559 = false;
151 static const bool is_bounded = false;
152 static const bool is_modulo = false;
153
154 static const bool traps = false;
155 static const bool tinyness_before = false;
156 static const float_round_style round_style = round_toward_zero;
157 };
158
159 template<typename _Tp> _Tp __limits_infinity();
160 template<typename _Tp> _Tp __limits_quiet_NaN();
161 template<typename _Tp> _Tp __limits_signaling_NaN();
162 template<typename _Tp> _Tp __limits_denorm_min();
163
164 EOF
165
166 echo "$CXX $CPPFLAGS -I$BUILD_DIR \
167 -o "$BUILD_DIR/src/gen-num-limits" "$SRC_DIR/src/gen-num-limits.cc" \
168 $LDFLAGS"
169
170 $CXX $CPPFLAGS -I$BUILD_DIR \
171 -o "$BUILD_DIR/src/gen-num-limits" "$SRC_DIR/src/gen-num-limits.cc" \
172 $LDFLAGS
173
174 if [ ! -f "$BUILD_DIR/src/gen-num-limits" ]; then
175 echo "gen-num-limits failed to build, exiting."
176 exit 1
177 fi
178
179 "$BUILD_DIR/src/gen-num-limits" >> $OUT_H
180
181 cat <<EOF >> $OUT_H
182 } // namespace std
183
184 #endif // _CPP_NUMERIC_LIMITS
185 EOF
186
187 trait_name=numeric_limits
188
189 cat <<EOF > $OUT_C
190 // Static data members of -*- C++ -*- numeric_limits classes
191
192 // Copyright (C) 1999, 2000 Free Software Foundation, Inc.
193 //
194 // This file is part of the GNU ISO C++ Library. This library is free
195 // software; you can redistribute it and/or modify it under the
196 // terms of the GNU General Public License as published by the
197 // Free Software Foundation; either version 2, or (at your option)
198 // any later version.
199
200 // This library is distributed in the hope that it will be useful,
201 // but WITHOUT ANY WARRANTY; without even the implied warranty of
202 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
203 // GNU General Public License for more details.
204
205 // You should have received a copy of the GNU General Public License along
206 // with this library; see the file COPYING. If not, write to the Free
207 // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
208 // USA.
209
210 // As a special exception, you may use this file as part of a free software
211 // library without restriction. Specifically, if other files instantiate
212 // templates or use macros or inline functions from this file, or you compile
213 // this file and link it with other files to produce an executable, this
214 // file does not by itself cause the resulting executable to be covered by
215 // the GNU General Public License. This exception does not however
216 // invalidate any other reasons why the executable file might be covered by
217 // the GNU General Public License.
218
219 // Written by Gabriel Dos Reis <Gabriel.Dos-Reis@cmla.ens-cachan.fr>
220
221 //
222 // ISO C++ 14882:1998
223 // 18.2.1
224 //
225
226 #include <bits/std_limits.h>
227 namespace std {
228 EOF
229
230 for type_name in bool char 'signed char' 'unsigned char' \
231 short 'unsigned short' int 'unsigned int' \
232 long 'unsigned long' 'long long' 'unsigned long long' \
233 float double 'long double'
234 do
235 grep "<$type_name>" $OUT_H >/dev/null 2>&1 || continue
236 cat <<EOF >> $OUT_C
237
238 const bool $trait_name<$type_name>::is_specialized;
239 const int $trait_name<$type_name>::digits;
240 const int $trait_name<$type_name>::digits10;
241 const bool $trait_name<$type_name>::is_signed;
242 const bool $trait_name<$type_name>::is_integer;
243 const bool $trait_name<$type_name>::is_exact;
244 const int $trait_name<$type_name>::radix;
245 const int $trait_name<$type_name>::min_exponent;
246 const int $trait_name<$type_name>::min_exponent10;
247 const int $trait_name<$type_name>::max_exponent;
248 const int $trait_name<$type_name>::max_exponent10;
249 const bool $trait_name<$type_name>::has_infinity;
250 const bool $trait_name<$type_name>::has_quiet_NaN;
251 const bool $trait_name<$type_name>::has_signaling_NaN;
252 const float_denorm_style $trait_name<$type_name>::has_denorm;
253 const bool $trait_name<$type_name>::has_denorm_loss;
254 const bool $trait_name<$type_name>::is_iec559;
255 const bool $trait_name<$type_name>::is_bounded;
256 const bool $trait_name<$type_name>::is_modulo;
257 const bool $trait_name<$type_name>::traps;
258 const bool $trait_name<$type_name>::tinyness_before;
259 const float_round_style $trait_name<$type_name>::round_style;
260 EOF
261
262 done
263
264 cat <<EOF >> $OUT_C
265 } // namespace std
266
267
268 EOF
This page took 0.047783 seconds and 5 git commands to generate.