2.9
[glibc/nacl-glibc.git] / sysdeps / unix / errnos-tmpl.c
blob25d7ec5dbccd932fbfddde70484abbb5ccc8167d
1 /* Copyright (C) 1991, 1993, 1997 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, write to the Free
16 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
17 02111-1307 USA. */
19 #include <errno.h>
21 static char iferrno[] = "#ifdef _ERRNO_H";
22 static char endiferrno[] = "#endif /* <errno.h> included. */";
23 static char ifEmath[] = "#if !defined(__Emath_defined) && \
24 (defined(_ERRNO_H) || defined(__need_Emath))";
25 static char endifEmath[] = "#endif /* Emath not defined and <errno.h> \
26 included or need Emath. */";
28 static int biggest_value = 0;
29 static int done_ENOSYS = 0;
30 static int done_ERANGE = 0, done_EDOM = 0;
32 static void
33 DO(name, value)
34 char *name;
35 int value;
37 int is_ERANGE = !done_ERANGE && !strcmp(name, "ERANGE");
38 int is_EDOM = !done_EDOM && !strcmp(name, "EDOM");
39 int is_Emath = is_ERANGE || is_EDOM;
41 if (is_Emath)
43 puts(endiferrno);
44 puts(ifEmath);
47 if (!strcmp (name, "EWOULDBLOCK"))
49 puts ("#define EWOULDBLOCK EAGAIN /* Translated in glibc. */");
50 name = "EWOULDBLOCK_sys /* Value actually returned by kernel. */";
53 printf ("#define %s %d\n", name, value);
55 if (is_Emath)
57 puts(endifEmath);
58 puts(iferrno);
61 if (value > biggest_value)
62 biggest_value = value;
64 if (is_ERANGE)
65 done_ERANGE = 1;
66 else if (is_EDOM)
67 done_EDOM = 1;
68 else if (!done_ENOSYS && !strcmp(name, "ENOSYS"))
69 done_ENOSYS = 1;
72 int
73 main()
75 puts(iferrno);
77 ERRNOS;
79 if (!done_EDOM || !done_ERANGE)
81 puts(endiferrno);
82 puts(ifEmath);
83 if (!done_EDOM)
84 printf("#define EDOM %d\n", ++biggest_value);
85 if (!done_ERANGE)
86 printf("#define ERANGE %d\n", ++biggest_value);
87 puts(endifEmath);
90 if (!done_ENOSYS)
91 printf("#define ENOSYS %d\n", ++biggest_value);
93 puts(endiferrno);
95 puts("#undef __need_Emath");
96 puts("#ifndef __Emath_defined\n#define __Emath_defined 1\n#endif");
98 exit(0);