]>
Commit | Line | Data |
---|---|---|
87aabbff | 1 | /* System-dependent definitions for Bison. |
45aa0550 | 2 | |
deb63d81 PE |
3 | Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005 Free Software |
4 | Foundation, Inc. | |
a0f6b076 AD |
5 | |
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) | |
9 | any later version. | |
10 | ||
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. | |
15 | ||
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, | |
0fb669f9 | 18 | Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ |
a0f6b076 | 19 | |
d968a24b JT |
20 | #ifndef BISON_SYSTEM_H |
21 | #define BISON_SYSTEM_H | |
22 | ||
56100c60 | 23 | #if HAVE_CONFIG_H |
d968a24b JT |
24 | # include <config.h> |
25 | #endif | |
26 | ||
6e26ca8c | 27 | #include <limits.h> |
deedb0b7 | 28 | #include <stddef.h> |
ceed8467 | 29 | #include <stdio.h> |
6e26ca8c PE |
30 | #include <stdlib.h> |
31 | #include <string.h> | |
ceed8467 | 32 | |
27b0ffea AD |
33 | #if HAVE_SYS_TYPES_H |
34 | # include <sys/types.h> | |
35 | #endif | |
36 | ||
499daa50 | 37 | #if HAVE_UNISTD_H |
a0f6b076 | 38 | # include <unistd.h> |
7bb4d914 JT |
39 | #endif |
40 | ||
6e26ca8c PE |
41 | #if HAVE_INTTYPES_H |
42 | # include <inttypes.h> | |
43 | #endif | |
44 | #if HAVE_STDINT_H | |
45 | # include <stdint.h> | |
46 | #endif | |
62a3e4f0 | 47 | |
6e26ca8c | 48 | #if ! HAVE_UINTPTR_T |
deedb0b7 PE |
49 | /* This isn't perfect, but it's good enough for Bison, which needs |
50 | only to hash pointers. */ | |
51 | typedef size_t uintptr_t; | |
52 | #endif | |
53 | ||
8a6f72f3 | 54 | #include <verify.h> |
982cc302 | 55 | #include <xalloc.h> |
a4b36db4 | 56 | |
273a74fa | 57 | |
b77b9ee0 AD |
58 | /*---------------------. |
59 | | Missing prototypes. | | |
60 | `---------------------*/ | |
61 | ||
1f65350a | 62 | #include <stpcpy.h> |
b77b9ee0 AD |
63 | |
64 | ||
a0f6b076 AD |
65 | /*-----------------. |
66 | | GCC extensions. | | |
67 | `-----------------*/ | |
68 | ||
48e28efa PE |
69 | /* Use this to suppress gcc's `...may be used before initialized' |
70 | warnings. */ | |
71 | #ifdef lint | |
72 | # define IF_LINT(Code) Code | |
73 | #else | |
74 | # define IF_LINT(Code) /* empty */ | |
75 | #endif | |
76 | ||
a0f6b076 AD |
77 | #ifndef __attribute__ |
78 | /* This feature is available in gcc versions 2.5 and later. */ | |
44ea3fbd MA |
79 | # if !defined (__GNUC__) || __GNUC__ < 2 || \ |
80 | (__GNUC__ == 2 && __GNUC_MINOR__ < 5) || __STRICT_ANSI__ | |
a0f6b076 AD |
81 | # define __attribute__(Spec) /* empty */ |
82 | # endif | |
e9955c83 AD |
83 | #endif |
84 | ||
a0f6b076 AD |
85 | /* The __-protected variants of `format' and `printf' attributes |
86 | are accepted by gcc versions 2.6.4 (effectively 2.7) and later. */ | |
e9955c83 AD |
87 | #if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7) |
88 | # define __format__ format | |
89 | # define __printf__ printf | |
a0f6b076 AD |
90 | #endif |
91 | ||
e9955c83 AD |
92 | #ifndef ATTRIBUTE_NORETURN |
93 | # define ATTRIBUTE_NORETURN __attribute__ ((__noreturn__)) | |
94 | #endif | |
95 | ||
96 | #ifndef ATTRIBUTE_UNUSED | |
97 | # define ATTRIBUTE_UNUSED __attribute__ ((__unused__)) | |
98 | #endif | |
a0f6b076 AD |
99 | |
100 | /*------. | |
101 | | NLS. | | |
102 | `------*/ | |
103 | ||
6e26ca8c | 104 | #include <locale.h> |
f2d78a99 | 105 | |
982cc302 | 106 | #include <gettext.h> |
e0327bc8 AD |
107 | #define _(Msgid) gettext (Msgid) |
108 | #define N_(Msgid) (Msgid) | |
f2d78a99 | 109 | |
a0f6b076 AD |
110 | |
111 | /*-------------------------------. | |
112 | | Fix broken compilation flags. | | |
113 | `-------------------------------*/ | |
114 | ||
8a278a04 | 115 | #ifndef LOCALEDIR |
a0f6b076 | 116 | # define LOCALEDIR "/usr/local/share/locale" |
8a278a04 | 117 | #endif |
d968a24b | 118 | |
ceed8467 | 119 | |
015acc48 AD |
120 | /*-----------. |
121 | | Booleans. | | |
122 | `-----------*/ | |
123 | ||
f61aad93 | 124 | #include <stdbool.h> |
8c7ebe49 AD |
125 | |
126 | ||
127 | /*-----------. | |
128 | | Obstacks. | | |
129 | `-----------*/ | |
130 | ||
04098407 PE |
131 | #define obstack_chunk_alloc xmalloc |
132 | #define obstack_chunk_free free | |
133 | #include <obstack.h> | |
8c7ebe49 | 134 | |
ff4423cc AD |
135 | #define obstack_sgrow(Obs, Str) \ |
136 | obstack_grow (Obs, Str, strlen (Str)) | |
8c7ebe49 AD |
137 | |
138 | #define obstack_fgrow1(Obs, Format, Arg1) \ | |
139 | do { \ | |
140 | char buf[4096]; \ | |
141 | sprintf (buf, Format, Arg1); \ | |
142 | obstack_grow (Obs, buf, strlen (buf)); \ | |
143 | } while (0) | |
dd60faec AD |
144 | |
145 | #define obstack_fgrow2(Obs, Format, Arg1, Arg2) \ | |
146 | do { \ | |
147 | char buf[4096]; \ | |
148 | sprintf (buf, Format, Arg1, Arg2); \ | |
149 | obstack_grow (Obs, buf, strlen (buf)); \ | |
150 | } while (0) | |
896fe5c1 AD |
151 | |
152 | #define obstack_fgrow3(Obs, Format, Arg1, Arg2, Arg3) \ | |
153 | do { \ | |
154 | char buf[4096]; \ | |
155 | sprintf (buf, Format, Arg1, Arg2, Arg3); \ | |
156 | obstack_grow (Obs, buf, strlen (buf)); \ | |
157 | } while (0) | |
7de3329e | 158 | |
ff4423cc AD |
159 | #define obstack_fgrow4(Obs, Format, Arg1, Arg2, Arg3, Arg4) \ |
160 | do { \ | |
161 | char buf[4096]; \ | |
162 | sprintf (buf, Format, Arg1, Arg2, Arg3, Arg4); \ | |
163 | obstack_grow (Obs, buf, strlen (buf)); \ | |
164 | } while (0) | |
165 | ||
7de3329e | 166 | |
7de3329e | 167 | |
381fb12e AD |
168 | /*-----------------------------------------. |
169 | | Extensions to use for the output files. | | |
170 | `-----------------------------------------*/ | |
7de3329e | 171 | |
deb63d81 PE |
172 | #ifndef OUTPUT_EXT |
173 | # define OUTPUT_EXT ".output" | |
174 | #endif | |
175 | ||
176 | #ifndef TAB_EXT | |
177 | # define TAB_EXT ".tab" | |
178 | #endif | |
55b96341 | 179 | |
381fb12e AD |
180 | #ifndef DEFAULT_TMPDIR |
181 | # define DEFAULT_TMPDIR "/tmp" | |
182 | #endif | |
183 | ||
184 | ||
185 | ||
381fb12e AD |
186 | /*---------------------. |
187 | | Free a linked list. | | |
188 | `---------------------*/ | |
189 | ||
300f275f AD |
190 | #define LIST_FREE(Type, List) \ |
191 | do { \ | |
192 | Type *_node, *_next; \ | |
193 | for (_node = List; _node; _node = _next) \ | |
194 | { \ | |
195 | _next = _node->next; \ | |
afbb696d | 196 | free (_node); \ |
300f275f AD |
197 | } \ |
198 | } while (0) | |
199 | ||
381fb12e AD |
200 | |
201 | /*---------------------------------------------. | |
202 | | Debugging memory allocation (must be last). | | |
203 | `---------------------------------------------*/ | |
342b8b6e AD |
204 | |
205 | # if WITH_DMALLOC | |
206 | # define DMALLOC_FUNC_CHECK | |
207 | # include <dmalloc.h> | |
208 | # endif /* WITH_DMALLOC */ | |
209 | ||
a4b36db4 | 210 | #endif /* ! BISON_SYSTEM_H */ |