maint: run update-copyright for 2014.
[m4/ericb.git] / m4 / system_.h
blob340c987c95b979689434a56b4020d1f6ab2f9116
1 /* GNU m4 -- A simple macro processor
2 Copyright (C) 2000-2001, 2003, 2006-2008, 2010, 2013-2014 Free
3 Software Foundation, Inc.
5 This file is part of GNU M4.
7 GNU M4 is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
12 GNU M4 is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>.
21 /**
22 * @configure_output@
24 * This file is installed, so cannot rely on the contents of config.h.
25 * It works best if included _before_ system headers.
26 **/
28 #ifndef M4_SYSTEM_H
29 #define M4_SYSTEM_H 1
31 #include <gnu/stdlib--.h>
32 #include <gnu/stdio--.h>
33 #include <gnu/unistd--.h>
35 #include <assert.h>
36 #include <ctype.h>
37 #include <errno.h>
38 #include <limits.h>
39 #include <stdint.h>
40 #include <sys/types.h>
41 #include <sys/stat.h>
44 @INCLUDE_ERROR_H@
45 @INCLUDE_OBSTACK_H@
46 @INCLUDE_REGEX_H@
47 @INCLUDE_STDBOOL_H@
49 #include <gnu/xalloc.h>
50 #include <gnu/xprintf.h>
51 #include <gnu/xstrndup.h>
53 /* In addition to EXIT_SUCCESS and EXIT_FAILURE, m4 can fail with version
54 mismatch when trying to load a frozen file produced by a newer m4 than
55 the version doing the reload. */
56 #define EXIT_MISMATCH 63
58 /* This is okay in an installed file, because it will not change the
59 behaviour of the including program whether ENABLE_NLS is defined
60 or not. */
61 #ifndef _
62 # ifdef ENABLE_NLS
63 # include <libintl.h>
64 # define _(Text) gettext (Text)
65 # define N_(Text) gettext_noop (Text)
66 # else
67 # define _(Text) (Text)
68 # define N_(Text) (Text)
69 # endif
70 #endif
73 /* All header files should be inside BEGIN_C_DECLS ... END_C_DECLS, so
74 that the library can be linked into a C++ program. The multi-include
75 guard macros must be outside, as should any #includes -- for simplicity
76 everything else should go inside. */
78 #ifndef BEGIN_C_DECLS
79 # ifdef __cplusplus
80 # define BEGIN_C_DECLS extern "C" {
81 # define END_C_DECLS }
82 # else /* !__cplusplus */
83 # define BEGIN_C_DECLS /* empty */
84 # define END_C_DECLS /* empty */
85 # endif /* __cplusplus */
86 #endif /* !BEGIN_C_DECLS */
88 BEGIN_C_DECLS
92 /* Canonicalize UNIX recognition macros. */
93 #if defined unix || defined __unix || defined __unix__ \
94 || defined _POSIX_VERSION || defined _POSIX2_VERSION \
95 || defined __NetBSD__ || defined __OpenBSD__ \
96 || defined __APPLE__ || defined __APPLE_CC__
97 # define UNIX 1
98 #endif
100 /* Canonicalize Windows recognition macros. */
101 #if (defined _WIN32 || defined __WIN32__) && !defined __CYGWIN__
102 # define W32_NATIVE 1
103 #endif
105 /* Canonicalize OS/2 recognition macro. */
106 #ifdef __EMX__
107 # define OS2 1
108 # undef UNIX
109 #endif
112 /* M4_STMT_START/END are used to create macros which expand to a
113 a single compound statement in a portable way, but crucially in
114 a way sympathetic to the compiler to maximise optimization. */
115 #undef M4_STMT_START
116 #undef M4_STMT_END
117 #if defined __GNUC__ && !defined __STRICT_ANSI__ && !defined __cplusplus
118 # define M4_STMT_START (void)(
119 # define M4_STMT_END )
120 #else
121 # if defined sun || defined __sun__
122 # define M4_STMT_START if (1)
123 # define M4_STMT_END else (void)0
124 # else
125 # define M4_STMT_START do
126 # define M4_STMT_END while (0)
127 # endif
128 #endif
132 /* Take advantage of GNU C compiler source level optimization hints,
133 using portable macros. */
134 #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 6)
135 # define M4_GNUC_ATTRIBUTE(args) __attribute__ (args)
136 #else
137 # define M4_GNUC_ATTRIBUTE(args)
138 #endif /* __GNUC__ */
140 #define M4_GNUC_PRINTF(fmt, arg) \
141 M4_GNUC_ATTRIBUTE ((__format__ (__printf__, fmt, arg)))
142 #define M4_GNUC_SCANF(fmt, arg) \
143 M4_GNUC_ATTRIBUTE ((__format__ (__scanf__, fmt, arg)))
144 #define M4_GNUC_NORETURN M4_GNUC_ATTRIBUTE ((__noreturn__))
145 #define M4_GNUC_CONST M4_GNUC_ATTRIBUTE ((__const__))
146 #define M4_GNUC_UNUSED M4_GNUC_ATTRIBUTE ((__unused__))
147 #define M4_GNUC_PURE M4_GNUC_ATTRIBUTE ((__pure__))
151 #if !defined __PRETTY_FUNCTION__
152 # define __PRETTY_FUNCTION__ "<unknown>"
153 #endif
156 /* Preprocessor token manipulation. */
158 /* The extra indirection to the _STR and _CONC macros is required so that
159 if the arguments to STR() (or CONC()) are themselves macros, they will
160 be expanded before being quoted. */
161 #ifndef STR
162 # define _STR(arg) #arg
163 # define STR(arg) _STR (arg)
164 #endif
166 #ifndef CONC
167 # define _CONC(a, b) a##b
168 # define CONC(a, b) _CONC (a, b)
169 #endif
171 END_C_DECLS
173 #endif /* !M4_SYSTEM_H */