Debian Codegraph @

texk/kpathsea/c-std.h

raw
1 /* c-std.h: the first header files.
2
3 Copyright 1992, 1993, 1994, 1995, 1996, 1997, 2008, 2012 Karl Berry.
4 Copyright 1999, 2005 Olaf Weber.
5
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
10
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public License
17 along with this library; if not, see <http://www.gnu.org/licenses/>. */
18
19 #ifndef KPATHSEA_C_STD_H
20 #define KPATHSEA_C_STD_H
21
22 /* Header files that essentially all of our sources need, and
23 that all implementations have. We include these first, to help with
24 NULL being defined multiple times. */
25 /* Workaround against a <math.h> MSVC bug : it can't be declared
26 extern "C" in a c++ source file. */
27 #ifndef __cplusplus
28 #include <math.h>
29 /* apparently M_PI isn't defined by <math.h> under older VC */
30 #ifndef M_PI
31 #define M_PI 3.14159265358979323846
32 #endif
33 #endif
34 #include <stdio.h>
35 #include <stdarg.h>
36
37 /* Be sure we have constants from <unistd.h>. */
38 #include <kpathsea/c-unistd.h>
39
40 #ifdef HAVE_STDLIB_H
41 #include <stdlib.h>
42 /* Include <stdlib.h> before <stddef.h>, to help avoid NULL
43 redefinitions on some systems. (We don't include <stddef.h>
44 ourselves any more, but FYI.) */
45 #else
46 /* We used to declare char *getenv() here, but since C23 decided to break
47 historical () declarations, and evince (et al.?) have decided not to
48 check for <stdlib.h> any more, that caused errors, e.g.:
49 https://tug.org/pipermail/tex-live/2025-July/051609.html
50 So eliding the declaration and hoping for the best. */
51 /* extern char *getenv (); */
52 #endif /* not HAVE_STDLIB_H */
53
54 #ifdef WIN32
55 #include <malloc.h>
56 #else
57 /* As with above getenv, don't try to declare the alloc fns. */
58 /* #ifndef STDC_HEADERS */
59 /* #ifndef ALLOC_RETURN_TYPE */
60 /* #define ALLOC_RETURN_TYPE void */
61 /* #endif */ /* not ALLOC_RETURN_TYPE */
62 /* extern ALLOC_RETURN_TYPE *calloc (), *malloc (), *realloc (); */
63 /* #endif */ /* not STDC_HEADERS */
64 #endif /* not WIN32 */
65
66 /* SunOS 4.1.1 gets STDC_HEADERS defined, but it doesn't provide
67 EXIT_FAILURE. So far no system has defined one of EXIT_FAILURE and
68 EXIT_SUCCESS without the other. */
69 #ifndef EXIT_SUCCESS
70 #ifdef VMS
71 #define EXIT_SUCCESS 1
72 #define EXIT_FAILURE 0
73 #else
74 #define EXIT_SUCCESS 0
75 #define EXIT_FAILURE 1
76 #endif
77 #endif /* not EXIT_SUCCESS */
78
79 /* strchr vs. index, memcpy vs. bcopy, etc. */
80 #include <kpathsea/c-memstr.h>
81
82 /* Error numbers and errno declaration. */
83 #include <kpathsea/c-errno.h>
84
85 /* Numeric minima and maxima. */
86 #include <kpathsea/c-minmax.h>
87
88 /* Assertions are too useful to not make generally available. */
89 #ifdef HAVE_ASSERT_H
90 #include <assert.h>
91 #else
92 #define assert(expr) /* as nothing */
93 #endif
94
95 #ifdef VMS
96 #include <unixlib.h>
97 #include <unixio.h>
98 #endif /* not VMS */
99
100 #endif /* not KPATHSEA_C_STD_H */