OSDN Git Service

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