]>
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
32 #include "unlocked-io.h"
35 # include <sys/types.h>
43 # include <inttypes.h>
50 /* This isn't perfect, but it's good enough for Bison, which needs
51 only to hash pointers. */
52 typedef size_t uintptr_t;
61 /*---------------------.
62 | Missing prototypes. |
63 `---------------------*/
67 /* From lib/basename.c. */
68 char *base_name (char const *name
);
75 /* Use this to suppress gcc's `...may be used before initialized'
78 # define IF_LINT(Code) Code
80 # define IF_LINT(Code) /* empty */
84 /* This feature is available in gcc versions 2.5 and later. */
85 # if !defined (__GNUC__) || __GNUC__ < 2 || \
86 (__GNUC__ == 2 && __GNUC_MINOR__ < 5) || __STRICT_ANSI__
87 # define __attribute__(Spec) /* empty */
91 /* The __-protected variants of `format' and `printf' attributes
92 are accepted by gcc versions 2.6.4 (effectively 2.7) and later. */
93 #if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)
94 # define __format__ format
95 # define __printf__ printf
98 #ifndef ATTRIBUTE_NORETURN
99 # define ATTRIBUTE_NORETURN __attribute__ ((__noreturn__))
102 #ifndef ATTRIBUTE_UNUSED
103 # define ATTRIBUTE_UNUSED __attribute__ ((__unused__))
113 #define _(Msgid) gettext (Msgid)
114 #define N_(Msgid) (Msgid)
117 /*-------------------------------.
118 | Fix broken compilation flags. |
119 `-------------------------------*/
122 # define LOCALEDIR "/usr/local/share/locale"
137 #define obstack_chunk_alloc xmalloc
138 #define obstack_chunk_free free
141 #define obstack_sgrow(Obs, Str) \
142 obstack_grow (Obs, Str, strlen (Str))
144 #define obstack_fgrow1(Obs, Format, Arg1) \
147 sprintf (buf, Format, Arg1); \
148 obstack_grow (Obs, buf, strlen (buf)); \
151 #define obstack_fgrow2(Obs, Format, Arg1, Arg2) \
154 sprintf (buf, Format, Arg1, Arg2); \
155 obstack_grow (Obs, buf, strlen (buf)); \
158 #define obstack_fgrow3(Obs, Format, Arg1, Arg2, Arg3) \
161 sprintf (buf, Format, Arg1, Arg2, Arg3); \
162 obstack_grow (Obs, buf, strlen (buf)); \
165 #define obstack_fgrow4(Obs, Format, Arg1, Arg2, Arg3, Arg4) \
168 sprintf (buf, Format, Arg1, Arg2, Arg3, Arg4); \
169 obstack_grow (Obs, buf, strlen (buf)); \
174 /*-----------------------------------------.
175 | Extensions to use for the output files. |
176 `-----------------------------------------*/
179 # define OUTPUT_EXT ".output"
183 # define TAB_EXT ".tab"
186 #ifndef DEFAULT_TMPDIR
187 # define DEFAULT_TMPDIR "/tmp"
192 /*---------------------.
193 | Free a linked list. |
194 `---------------------*/
196 #define LIST_FREE(Type, List) \
198 Type *_node, *_next; \
199 for (_node = List; _node; _node = _next) \
201 _next = _node->next; \
207 /*---------------------------------------------.
208 | Debugging memory allocation (must be last). |
209 `---------------------------------------------*/
212 # define DMALLOC_FUNC_CHECK
213 # include <dmalloc.h>
214 # endif /* WITH_DMALLOC */
216 #endif /* ! BISON_SYSTEM_H */