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