summaryrefslogtreecommitdiff
path: root/m4/system_.h
blob: 01b8e05a7463f2e793b62cc2c6ec891fe76b3a8e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
/* GNU m4 -- A simple macro processor
   Copyright (C) 2000-2001, 2003, 2006-2008, 2010, 2013 Free Software
   Foundation, Inc.

   This file is part of GNU M4.

   GNU M4 is free software: you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation, either version 3 of the License, or
   (at your option) any later version.

   GNU M4 is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

/**
 * @configure_output@
 *
 * This file is installed, so cannot rely on the contents of config.h.
 * It works best if included _before_ system headers.
 **/

#ifndef M4_SYSTEM_H
#define M4_SYSTEM_H 1

#include <gnu/stdlib--.h>
#include <gnu/stdio--.h>
#include <gnu/unistd--.h>

#include <assert.h>
#include <ctype.h>
#include <errno.h>
#include <limits.h>
#include <stdint.h>
#include <sys/types.h>
#include <sys/stat.h>


@INCLUDE_ERROR_H@
@INCLUDE_OBSTACK_H@
@INCLUDE_REGEX_H@
@INCLUDE_STDBOOL_H@

#include <gnu/xalloc.h>
#include <gnu/xprintf.h>
#include <gnu/xstrndup.h>

/* In addition to EXIT_SUCCESS and EXIT_FAILURE, m4 can fail with version
   mismatch when trying to load a frozen file produced by a newer m4 than
   the version doing the reload.  */
#define EXIT_MISMATCH 63

/* This is okay in an installed file, because it will not change the
   behaviour of the including program whether ENABLE_NLS is defined
   or not.  */
#ifndef _
# ifdef ENABLE_NLS
#  include <libintl.h>
#  define _(Text) gettext (Text)
#  define N_(Text) gettext_noop (Text)
# else
#  define _(Text) (Text)
#  define N_(Text) (Text)
# endif
#endif


/* All header files should be inside BEGIN_C_DECLS ... END_C_DECLS, so
   that the library can be linked into a C++ program.  The multi-include
   guard macros must be outside, as should any #includes -- for simplicity
   everything else should go inside.  */

#ifndef BEGIN_C_DECLS
# ifdef __cplusplus
#  define BEGIN_C_DECLS extern "C" {
#  define END_C_DECLS           }
# else /* !__cplusplus */
#  define BEGIN_C_DECLS /* empty */
#  define END_C_DECLS           /* empty */
# endif /* __cplusplus */
#endif /* !BEGIN_C_DECLS */

BEGIN_C_DECLS



/* Canonicalize UNIX recognition macros.  */
#if defined unix || defined __unix || defined __unix__ \
  || defined _POSIX_VERSION || defined _POSIX2_VERSION \
  || defined __NetBSD__ || defined __OpenBSD__ \
  || defined __APPLE__ || defined __APPLE_CC__
# define UNIX 1
#endif

/* Canonicalize Windows recognition macros.  */
#if (defined _WIN32 || defined __WIN32__) && !defined __CYGWIN__
# define W32_NATIVE 1
#endif

/* Canonicalize OS/2 recognition macro.  */
#ifdef __EMX__
# define OS2 1
# undef UNIX
#endif


/* M4_STMT_START/END are used to create macros which expand to a
   a single compound statement in a portable way, but crucially in
   a way sympathetic to the compiler to maximise optimization.  */
#undef M4_STMT_START
#undef M4_STMT_END
#if defined __GNUC__ && !defined __STRICT_ANSI__ && !defined __cplusplus
# define M4_STMT_START        (void)(
# define M4_STMT_END          )
#else
# if defined sun || defined __sun__
#  define M4_STMT_START      if (1)
#  define M4_STMT_END        else (void)0
# else
#  define M4_STMT_START      do
#  define M4_STMT_END        while (0)
# endif
#endif



/* Take advantage of GNU C compiler source level optimization hints,
   using portable macros.  */
#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 6)
# define M4_GNUC_ATTRIBUTE(args)        __attribute__ (args)
#else
# define M4_GNUC_ATTRIBUTE(args)
#endif  /* __GNUC__ */

#define M4_GNUC_PRINTF(fmt, arg)                                \
  M4_GNUC_ATTRIBUTE ((__format__ (__printf__, fmt, arg)))
#define M4_GNUC_SCANF(fmt, arg)                                 \
  M4_GNUC_ATTRIBUTE ((__format__ (__scanf__, fmt, arg)))
#define M4_GNUC_NORETURN        M4_GNUC_ATTRIBUTE ((__noreturn__))
#define M4_GNUC_CONST           M4_GNUC_ATTRIBUTE ((__const__))
#define M4_GNUC_UNUSED          M4_GNUC_ATTRIBUTE ((__unused__))
#define M4_GNUC_PURE            M4_GNUC_ATTRIBUTE ((__pure__))



#if !defined __PRETTY_FUNCTION__
# define __PRETTY_FUNCTION__    "<unknown>"
#endif


/* Preprocessor token manipulation.  */

/* The extra indirection to the _STR and _CONC macros is required so that
   if the arguments to STR() (or CONC()) are themselves macros, they will
   be expanded before being quoted.   */
#ifndef STR
# define _STR(arg)      #arg
# define STR(arg)       _STR (arg)
#endif

#ifndef CONC
# define _CONC(a, b)    a##b
# define CONC(a, b)     _CONC (a, b)
#endif

END_C_DECLS

#endif /* !M4_SYSTEM_H */