OSDN Git Service

cb33463511347606fedede7c70aeb60dce7bc59d
[pf3gnuchains/gcc-fork.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 BUILD_DIR=$1
12 if [ ! -d "$BUILD_DIR" ]; then
13   echo "build directory $BUILD_DIR not found, exiting."
14   exit 1
15 fi
16
17 if [ ! -d "$BUILD_DIR/include" ]; then
18   mkdir  "$BUILD_DIR/include"
19 fi
20
21 if [ ! -d "$BUILD_DIR/include/bits" ]; then
22   mkdir  "$BUILD_DIR/include/bits"
23 fi
24
25 if [ ! -d "$BUILD_DIR/src" ]; then
26   mkdir  "$BUILD_DIR/src"
27 fi
28
29 OUT_H="$BUILD_DIR/include/bits/std_limits.h"
30 OUT_C="$BUILD_DIR/src/limitsMEMBERS.cc"
31
32 if [ -f $OUT_C ]; then
33     rm -f $OUT_H $OUT_C $OUT_H-t $OUT_C-t
34 fi
35
36 SRC_DIR=$2
37 if [ ! -d "$SRC_DIR" ]; then
38   echo "source directory $SRC_DIR not found, exiting."
39   exit 1
40 fi
41
42 XCOMPILE=$3
43 if [ $XCOMPILE -eq 1 ]; then
44   echo "using default values for cross compiles"
45   cp $SRC_DIR/include/bits/limits_generic.h $OUT_H
46   cp $SRC_DIR/src/limits_generic.cc $OUT_C
47   exit 0;
48 fi   
49
50 CC=${CC="$BUILD_DIR/../../gcc/xgcc -B$BUILD_DIR/../../gcc/"}
51
52 # We output to a temporary file, so that we don't appear to have
53 # succeeded unless we actually do.
54 cat <<EOF > $OUT_H-t
55 // The template and inlines for the -*- C++ -*- numeric_limits classes.
56
57 // Copyright (C) 1999-2001 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   {
106     round_indeterminate       = -1,
107     round_toward_zero         = 0,
108     round_to_nearest          = 1,
109     round_toward_infinity     = 2,
110     round_toward_neg_infinity = 3
111   };
112
113   enum float_denorm_style 
114   {
115     denorm_indeterminate = -1,
116     denorm_absent        = 0,
117     denorm_present       = 1
118   };
119
120   template<typename _Tp> 
121     struct numeric_limits 
122     {
123       static const bool is_specialized = false;
124
125       static _Tp min() throw() { return static_cast<_Tp>(0); }
126       static _Tp max() throw() { return static_cast<_Tp>(0); }
127
128       static const int digits = 0;
129       static const int digits10 = 0;
130       static const bool is_signed = false;
131       static const bool is_integer = false;
132       static const bool is_exact = false;
133       static const int radix = 0;
134
135       static _Tp epsilon() throw() { return static_cast<_Tp>(0); }
136       static _Tp round_error() throw() { return static_cast<_Tp>(0); }
137
138       static const int min_exponent = 0;
139       static const int min_exponent10 = 0;
140       static const int max_exponent = 0;
141       static const int max_exponent10 = 0;
142
143       static const bool has_infinity = false;
144       static const bool has_quiet_NaN = false;
145       static const bool has_signaling_NaN = false;
146       static const float_denorm_style has_denorm = denorm_absent;
147       static const bool has_denorm_loss = false;
148
149       static _Tp infinity() throw()  { return static_cast<_Tp>(0); }
150       static _Tp quiet_NaN() throw() { return static_cast<_Tp>(0); }
151       static _Tp signaling_NaN() throw() { return static_cast<_Tp>(0); }
152       static _Tp denorm_min() throw() { return static_cast<_Tp>(0); }
153
154       static const bool is_iec559 = false;
155       static const bool is_bounded = false;
156       static const bool is_modulo = false;
157
158       static const bool traps = false;
159       static const bool tinyness_before = false;
160       static const float_round_style round_style = round_toward_zero;
161     };
162
163   template<typename _Tp> 
164     const bool
165     numeric_limits<_Tp>::is_specialized;
166
167   template<typename _Tp> 
168     const int
169     numeric_limits<_Tp>::digits;
170
171   template<typename _Tp> 
172     const int
173     numeric_limits<_Tp>::digits10;
174
175   template<typename _Tp> 
176     const bool
177     numeric_limits<_Tp>::is_signed;
178
179   template<typename _Tp> 
180     const bool
181     numeric_limits<_Tp>::is_integer;
182
183   template<typename _Tp> 
184     const bool
185     numeric_limits<_Tp>::is_exact;
186
187   template<typename _Tp> 
188     const int
189     numeric_limits<_Tp>::radix;
190
191   template<typename _Tp> 
192     const int
193     numeric_limits<_Tp>::min_exponent;
194
195   template<typename _Tp> 
196     const int
197     numeric_limits<_Tp>::min_exponent10;
198
199   template<typename _Tp> 
200     const int
201     numeric_limits<_Tp>::max_exponent;
202
203   template<typename _Tp> 
204     const int
205     numeric_limits<_Tp>::max_exponent10;
206
207   template<typename _Tp> 
208     const bool
209     numeric_limits<_Tp>::has_infinity;
210
211   template<typename _Tp> 
212     const bool
213     numeric_limits<_Tp>::has_quiet_NaN;
214
215   template<typename _Tp> 
216     const bool
217     numeric_limits<_Tp>::has_signaling_NaN;
218
219   template<typename _Tp> 
220     const float_denorm_style
221     numeric_limits<_Tp>::has_denorm;
222
223   template<typename _Tp> 
224     const bool
225     numeric_limits<_Tp>::has_denorm_loss;
226
227   template<typename _Tp> 
228     const bool
229     numeric_limits<_Tp>::is_iec559;
230
231   template<typename _Tp> 
232     const bool
233     numeric_limits<_Tp>::is_bounded;
234
235   template<typename _Tp> 
236     const bool
237     numeric_limits<_Tp>::is_modulo;
238
239   template<typename _Tp> 
240     const bool
241     numeric_limits<_Tp>::traps;
242
243   template<typename _Tp> 
244     const bool
245     numeric_limits<_Tp>::tinyness_before;
246
247   template<typename _Tp> 
248     const float_round_style
249     numeric_limits<_Tp>::round_style;
250
251   template<typename _Tp> _Tp __limits_infinity();
252   template<typename _Tp> _Tp __limits_quiet_NaN();
253   template<typename _Tp> _Tp __limits_signaling_NaN();
254   template<typename _Tp> _Tp __limits_denorm_min();
255
256 EOF
257
258 # Must turn off exceptions, because the C++ exception handling support
259 # routines have not been built yet.
260 echo "$CC -I$BUILD_DIR -fno-exceptions \
261     -o $BUILD_DIR/src/gen-num-limits $SRC_DIR/src/gen-num-limits.cc"
262
263 { $CC -I$BUILD_DIR -fno-exceptions \
264     -o "$BUILD_DIR/src/gen-num-limits" "$SRC_DIR/src/gen-num-limits.cc"
265 } || {
266   echo "gen-num-limits failed to build, exiting."
267   exit 1
268 }
269
270 "$BUILD_DIR/src/gen-num-limits" >> $OUT_H-t || {
271   echo "gen-num-limits failed to execute, exiting."
272   exit 1
273 }
274
275 cat <<EOF >> $OUT_H-t
276 } // namespace std
277
278 #endif // _CPP_NUMERIC_LIMITS
279 EOF
280
281 trait_name=numeric_limits
282
283 cat <<EOF > $OUT_C-t
284 // Static data members of -*- C++ -*- numeric_limits classes
285
286 // Copyright (C) 1999, 2000 Free Software Foundation, Inc.
287 //
288 // This file is part of the GNU ISO C++ Library.  This library is free
289 // software; you can redistribute it and/or modify it under the
290 // terms of the GNU General Public License as published by the
291 // Free Software Foundation; either version 2, or (at your option)
292 // any later version.
293
294 // This library is distributed in the hope that it will be useful,
295 // but WITHOUT ANY WARRANTY; without even the implied warranty of
296 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
297 // GNU General Public License for more details.
298
299 // You should have received a copy of the GNU General Public License along
300 // with this library; see the file COPYING.  If not, write to the Free
301 // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
302 // USA.
303
304 // As a special exception, you may use this file as part of a free software
305 // library without restriction.  Specifically, if other files instantiate
306 // templates or use macros or inline functions from this file, or you compile
307 // this file and link it with other files to produce an executable, this
308 // file does not by itself cause the resulting executable to be covered by
309 // the GNU General Public License.  This exception does not however
310 // invalidate any other reasons why the executable file might be covered by
311 // the GNU General Public License.
312
313 // Written by Gabriel Dos Reis <Gabriel.Dos-Reis@cmla.ens-cachan.fr>
314
315 //
316 // ISO C++ 14882:1998
317 // 18.2.1
318 //
319
320 #include <bits/std_limits.h>
321 namespace std {
322 EOF
323
324 for type_name in bool char 'signed char' 'unsigned char' \
325             short 'unsigned short' int 'unsigned int' \
326             long 'unsigned long' 'long long' 'unsigned long long' \
327             float double 'long double'
328     do
329      grep "<$type_name>" $OUT_H-t >/dev/null 2>&1 || continue
330      cat <<EOF >> $OUT_C-t
331
332     const bool $trait_name<$type_name>::is_specialized;
333     const int  $trait_name<$type_name>::digits;
334     const int  $trait_name<$type_name>::digits10;
335     const bool $trait_name<$type_name>::is_signed;
336     const bool $trait_name<$type_name>::is_integer;
337     const bool $trait_name<$type_name>::is_exact;
338     const int  $trait_name<$type_name>::radix;
339     const int  $trait_name<$type_name>::min_exponent;
340     const int  $trait_name<$type_name>::min_exponent10;
341     const int  $trait_name<$type_name>::max_exponent;
342     const int  $trait_name<$type_name>::max_exponent10;
343     const bool $trait_name<$type_name>::has_infinity;
344     const bool $trait_name<$type_name>::has_quiet_NaN;
345     const bool $trait_name<$type_name>::has_signaling_NaN;
346     const float_denorm_style $trait_name<$type_name>::has_denorm;
347     const bool $trait_name<$type_name>::has_denorm_loss;
348     const bool $trait_name<$type_name>::is_iec559;
349     const bool $trait_name<$type_name>::is_bounded;
350     const bool $trait_name<$type_name>::is_modulo;
351     const bool $trait_name<$type_name>::traps;
352     const bool $trait_name<$type_name>::tinyness_before;
353     const float_round_style $trait_name<$type_name>::round_style;
354 EOF
355
356 done
357
358 cat <<EOF >> $OUT_C-t
359 } // namespace std
360
361
362 EOF
363
364 mv $OUT_C-t $OUT_C
365 mv $OUT_H-t $OUT_H
366
367