]>
git.saurik.com Git - bison.git/blob - src/system.h
1 /* System-dependent definitions for Bison.
3 Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009
4 Free Software Foundation, Inc.
6 This program is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
11 This program 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
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>. */
19 #ifndef BISON_SYSTEM_H
20 #define BISON_SYSTEM_H
22 /* flex 2.5.31 gratutiously defines macros like INT8_MIN. But this
23 runs afoul of pre-C99 compilers that have <inttypes.h> or
24 <stdint.h>, which are included below if available. It also runs
25 afoul of pre-C99 compilers that define these macros in <limits.h>. */
26 #if ! defined __STDC_VERSION__ || __STDC_VERSION__ < 199901
44 # include <sys/types.h>
51 /* This isn't perfect, but it's good enough for Bison, which needs
52 only to hash pointers. */
53 typedef size_t uintptr_t;
61 #include <unlocked-io.h>
70 /* Use this to suppress gcc's `...may be used before initialized'
73 # define IF_LINT(Code) Code
75 # define IF_LINT(Code) /* empty */
79 /* This feature is available in gcc versions 2.5 and later. */
80 # if (! defined __GNUC__ || __GNUC__ < 2 \
81 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) || __STRICT_ANSI__)
82 # define __attribute__(Spec) /* empty */
86 /* The __-protected variants of `format' and `printf' attributes
87 are accepted by gcc versions 2.6.4 (effectively 2.7) and later. */
88 #if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)
89 # define __format__ format
90 # define __printf__ printf
93 #ifndef ATTRIBUTE_NORETURN
94 # define ATTRIBUTE_NORETURN __attribute__ ((__noreturn__))
97 #ifndef ATTRIBUTE_UNUSED
98 # define ATTRIBUTE_UNUSED __attribute__ ((__unused__))
101 #define FUNCTION_PRINT() fprintf (stderr, "%s: ", __func__)
110 #define _(Msgid) gettext (Msgid)
111 #define N_(Msgid) (Msgid)
126 /* <assert.h>'s assertions are too heavyweight, and can be disabled
127 too easily, so use aver rather than assert. See discussions at
128 <http://lists.gnu.org/archive/html/bison-patches/2006-01/msg00080.html>
129 <http://lists.gnu.org/archive/html/bison-patches/2006-09/msg00111.html>.
132 aver (bool assertion
)
143 #define obstack_chunk_alloc xmalloc
144 #define obstack_chunk_free free
147 #define obstack_sgrow(Obs, Str) \
148 obstack_grow (Obs, Str, strlen (Str))
150 #define obstack_fgrow1(Obs, Format, Arg1) \
153 sprintf (buf, Format, Arg1); \
154 obstack_grow (Obs, buf, strlen (buf)); \
157 #define obstack_fgrow2(Obs, Format, Arg1, Arg2) \
160 sprintf (buf, Format, Arg1, Arg2); \
161 obstack_grow (Obs, buf, strlen (buf)); \
164 #define obstack_fgrow3(Obs, Format, Arg1, Arg2, Arg3) \
167 sprintf (buf, Format, Arg1, Arg2, Arg3); \
168 obstack_grow (Obs, buf, strlen (buf)); \
171 #define obstack_fgrow4(Obs, Format, Arg1, Arg2, Arg3, Arg4) \
174 sprintf (buf, Format, Arg1, Arg2, Arg3, Arg4); \
175 obstack_grow (Obs, buf, strlen (buf)); \
180 /*-----------------------------------------.
181 | Extensions to use for the output files. |
182 `-----------------------------------------*/
185 # define OUTPUT_EXT ".output"
189 # define TAB_EXT ".tab"
192 #ifndef DEFAULT_TMPDIR
193 # define DEFAULT_TMPDIR "/tmp"
198 /*---------------------.
199 | Free a linked list. |
200 `---------------------*/
202 #define LIST_FREE(Type, List) \
204 Type *_node, *_next; \
205 for (_node = List; _node; _node = _next) \
207 _next = _node->next; \
213 /*---------------------------------------------.
214 | Debugging memory allocation (must be last). |
215 `---------------------------------------------*/
218 # define DMALLOC_FUNC_CHECK
219 # include <dmalloc.h>
220 # endif /* WITH_DMALLOC */
222 #endif /* ! BISON_SYSTEM_H */