]>
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 Free Software
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 2, or (at your option)
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, write to the Free Software Foundation,
18 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
20 #ifndef BISON_SYSTEM_H
21 #define BISON_SYSTEM_H
33 /* Verify a requirement at compile-time (unlike assert, which is runtime). */
34 #define verify(name, assertion) struct name {char name[(assertion) ? 1 : -1];}
37 # include <sys/types.h>
45 # include <inttypes.h>
52 /* This isn't perfect, but it's good enough for Bison, which needs
53 only to hash pointers. */
54 typedef size_t uintptr_t;
60 /*---------------------.
61 | Missing prototypes. |
62 `---------------------*/
71 /* Use this to suppress gcc's `...may be used before initialized'
74 # define IF_LINT(Code) Code
76 # define IF_LINT(Code) /* empty */
80 /* This feature is available in gcc versions 2.5 and later. */
81 # if !defined (__GNUC__) || __GNUC__ < 2 || \
82 (__GNUC__ == 2 && __GNUC_MINOR__ < 5) || __STRICT_ANSI__
83 # define __attribute__(Spec) /* empty */
87 /* The __-protected variants of `format' and `printf' attributes
88 are accepted by gcc versions 2.6.4 (effectively 2.7) and later. */
89 #if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)
90 # define __format__ format
91 # define __printf__ printf
94 #ifndef ATTRIBUTE_NORETURN
95 # define ATTRIBUTE_NORETURN __attribute__ ((__noreturn__))
98 #ifndef ATTRIBUTE_UNUSED
99 # define ATTRIBUTE_UNUSED __attribute__ ((__unused__))
109 #define _(Msgid) gettext (Msgid)
110 #define N_(Msgid) (Msgid)
113 /*-------------------------------.
114 | Fix broken compilation flags. |
115 `-------------------------------*/
118 # define LOCALEDIR "/usr/local/share/locale"
133 # define obstack_chunk_alloc xmalloc
134 # define obstack_chunk_free free
135 # include <obstack.h>
137 #define obstack_sgrow(Obs, Str) \
138 obstack_grow (Obs, Str, strlen (Str))
140 #define obstack_fgrow1(Obs, Format, Arg1) \
143 sprintf (buf, Format, Arg1); \
144 obstack_grow (Obs, buf, strlen (buf)); \
147 #define obstack_fgrow2(Obs, Format, Arg1, Arg2) \
150 sprintf (buf, Format, Arg1, Arg2); \
151 obstack_grow (Obs, buf, strlen (buf)); \
154 #define obstack_fgrow3(Obs, Format, Arg1, Arg2, Arg3) \
157 sprintf (buf, Format, Arg1, Arg2, Arg3); \
158 obstack_grow (Obs, buf, strlen (buf)); \
161 #define obstack_fgrow4(Obs, Format, Arg1, Arg2, Arg3, Arg4) \
164 sprintf (buf, Format, Arg1, Arg2, Arg3, Arg4); \
165 obstack_grow (Obs, buf, strlen (buf)); \
170 /*-----------------------------------------.
171 | Extensions to use for the output files. |
172 `-----------------------------------------*/
175 # define OUTPUT_EXT ".output"
179 # define TAB_EXT ".tab"
182 #ifndef DEFAULT_TMPDIR
183 # define DEFAULT_TMPDIR "/tmp"
188 /*---------------------.
189 | Free a linked list. |
190 `---------------------*/
192 #define LIST_FREE(Type, List) \
194 Type *_node, *_next; \
195 for (_node = List; _node; _node = _next) \
197 _next = _node->next; \
203 /*---------------------------------------------.
204 | Debugging memory allocation (must be last). |
205 `---------------------------------------------*/
208 # define DMALLOC_FUNC_CHECK
209 # include <dmalloc.h>
210 # endif /* WITH_DMALLOC */
212 #endif /* ! BISON_SYSTEM_H */