1 /***********************************************************************
3 * This software is part of the ast package *
4 * Copyright (c) 1985-2010 AT&T Intellectual Property *
5 * and is licensed under the *
6 * Common Public License, Version 1.0 *
7 * by AT&T Intellectual Property *
9 * A copy of the License is available at *
10 * http://www.opensource.org/licenses/cpl1.0.txt *
11 * (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
13 * Information and Software Systems Research *
17 * Glenn Fowler <gsf@research.att.com> *
18 * David Korn <dgk@research.att.com> *
19 * Phong Vo <kpv@research.att.com> *
21 ***********************************************************************/
27 * generate limits features
29 * FOPEN_MAX POSIX says ANSI defines it but it's not in ANSI
31 * NOTE: two's complement binary integral representation assumed
34 #if defined(__STDPP__directive) && defined(__STDPP__hide)
35 __STDPP__directive pragma pp
:hide getpagesize getdtablesize
37 #define getpagesize ______getpagesize
38 #define getdtablesize ______getdtablesize
42 * we'd like as many symbols as possible defined
43 * the standards push the vendors the other way
44 * but don't provide guard that lets everything through
45 * so each vendor adds their own guard
46 * many now include something like <standards.h> to
47 * get it straight in one place -- <sys/types.h> should
51 #include "FEATURE/standards"
52 #include "FEATURE/lib"
55 #define _timespec timespec
58 #include <sys/types.h>
70 #include "FEATURE/lib"
71 #include "FEATURE/common"
77 #include "FEATURE/param"
79 #if defined(__STDPP__directive) && defined(__STDPP__hide)
80 __STDPP__directive pragma pp
:nohide getpagesize getdtablesize
100 * <limits.h> with *constant* valued macros
108 while (uc
>>= 1) val
++;
109 printf("#define CHAR_BIT %lu\n", val
);
113 printf("#define MB_LEN_MAX %lu\n", val
);
133 printf("#if defined(__STDC__)\n");
134 printf("#define UCHAR_MAX %luU\n", val
);
136 printf("#define UCHAR_MAX %lu\n", val
);
141 val
= (unsigned char)(uc
>> 1) + 1;
142 printf("#define SCHAR_MIN (-%lu)\n", val
);
146 val
= (unsigned char)(uc
>> 1);
147 printf("#define SCHAR_MAX %lu\n", val
);
153 printf("#define CHAR_MIN SCHAR_MIN\n");
157 printf("#define CHAR_MAX SCHAR_MAX\n");
163 printf("#define CHAR_MIN 0\n");
167 printf("#define CHAR_MAX UCHAR_MAX\n");
173 printf("#if defined(__STDC__)\n");
174 printf("#define USHRT_MAX %luU\n", val
);
176 printf("#define USHRT_MAX %lu\n", val
);
181 val
= (unsigned short)(us
>> 1) + 1;
182 printf("#define SHRT_MIN (-%lu)\n", val
);
186 val
= (unsigned short)(us
>> 1);
187 printf("#define SHRT_MAX %lu\n", val
);
193 printf("#define UINT_MAX USHRT_MAX\n");
197 printf("#define INT_MIN SHRT_MIN\n");
201 printf("#define INT_MAX SHRT_MAX\n");
208 printf("#if defined(__STDC__)\n");
209 printf("#define UINT_MAX %luU\n", val
);
211 printf("#define UINT_MAX %lu\n", val
);
216 val
= (unsigned int)(ui
>> 1) + 1;
217 if (ui
== ul
) printf("#define INT_MIN (-%lu-1)\n", val
- 1);
218 else printf("#define INT_MIN (-%lu)\n", val
);
222 val
= (unsigned int)(ui
>> 1);
223 printf("#define INT_MAX %lu\n", val
);
230 printf("#define ULONG_MAX UINT_MAX\n");
234 printf("#define LONG_MIN INT_MIN\n");
238 printf("#define LONG_MAX INT_MAX\n");
245 printf("#if defined(__STDC__)\n");
246 printf("#define ULONG_MAX %luLU\n", val
);
248 printf("#define ULONG_MAX %lu\n", val
);
253 val
= (unsigned long)(ul
>> 1) + 1;
254 printf("#define LONG_MIN (-%luL-1L)\n", val
- 1);
258 val
= (unsigned long)(ul
>> 1);
259 printf("#define LONG_MAX %luL\n", val
);
263 #if _typ_uint64_t && !_ast_intmax_long
267 printf("#define ULLONG_MAX ULONG_MAX\n");
271 printf("#define LLONG_MIN LONG_MIN\n");
275 printf("#define LLONG_MAX LONG_MAX\n");
282 printf("#ifndef ULLONG_MAX\n");
283 printf("#if defined(__STDC__) && _ast_LL\n");
284 printf("#define ULLONG_MAX %lluULL\n", vll
);
286 printf("#define ULLONG_MAX %llu\n", vll
);
292 vll
= (uint64_t)(ull
>> 1) + 1;
293 printf("#ifndef LLONG_MIN\n");
294 printf("#if defined(__STDC__) && _ast_LL\n");
295 printf("#define LLONG_MIN (-%lluLL-1LL)\n", vll
- 1);
297 printf("#define LLONG_MIN (-%llu-1)\n", vll
- 1);
303 vll
= (uint64_t)(ull
>> 1);
304 printf("#ifndef LLONG_MAX\n");
305 printf("#if defined(__STDC__) && _ast_LL\n");
306 printf("#define LLONG_MAX %lluLL\n", vll
);
308 printf("#define LLONG_MAX %llu\n", vll
);
317 printf("#ifdef _UWIN\n");
318 printf("#ifndef DBL_DIG\n");
319 printf("#define DBL_DIG 15\n");
321 printf("#ifndef DBL_MAX\n");
322 printf("#define DBL_MAX 1.7976931348623158e+308\n");
324 printf("#ifndef FLT_DIG\n");
325 printf("#define FLT_DIG 6\n");
327 printf("#ifndef FLT_MAX\n");
328 printf("#define FLT_MAX 3.402823466e+38F\n");