]> git.saurik.com Git - bison.git/blame - src/system.h
* data/glr.c: Fix yyerror_range usage.
[bison.git] / src / system.h
CommitLineData
87aabbff 1/* System-dependent definitions for Bison.
45aa0550 2
6e26ca8c 3 Copyright (C) 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
a0f6b076
AD
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2, or (at your option)
8 any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software Foundation,
17 Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
18
d968a24b
JT
19#ifndef BISON_SYSTEM_H
20#define BISON_SYSTEM_H
21
56100c60 22#if HAVE_CONFIG_H
d968a24b
JT
23# include <config.h>
24#endif
25
6e26ca8c 26#include <limits.h>
deedb0b7 27#include <stddef.h>
ceed8467 28#include <stdio.h>
6e26ca8c
PE
29#include <stdlib.h>
30#include <string.h>
ceed8467 31
87aabbff
PE
32/* Verify a requirement at compile-time (unlike assert, which is runtime). */
33#define verify(name, assertion) struct name {char name[(assertion) ? 1 : -1];}
340ef489 34
27b0ffea
AD
35#if HAVE_SYS_TYPES_H
36# include <sys/types.h>
37#endif
38
499daa50 39#if HAVE_UNISTD_H
a0f6b076 40# include <unistd.h>
7bb4d914
JT
41#endif
42
6e26ca8c
PE
43#if HAVE_INTTYPES_H
44# include <inttypes.h>
45#endif
46#if HAVE_STDINT_H
47# include <stdint.h>
48#endif
62a3e4f0 49
6e26ca8c 50#if ! HAVE_UINTPTR_T
deedb0b7
PE
51/* This isn't perfect, but it's good enough for Bison, which needs
52 only to hash pointers. */
53typedef size_t uintptr_t;
54#endif
55
982cc302 56#include <xalloc.h>
a4b36db4 57
273a74fa 58
b77b9ee0
AD
59/*---------------------.
60| Missing prototypes. |
61`---------------------*/
62
1f65350a 63#include <stpcpy.h>
b77b9ee0
AD
64
65
a0f6b076
AD
66/*-----------------.
67| GCC extensions. |
68`-----------------*/
69
48e28efa
PE
70/* Use this to suppress gcc's `...may be used before initialized'
71 warnings. */
72#ifdef lint
73# define IF_LINT(Code) Code
74#else
75# define IF_LINT(Code) /* empty */
76#endif
77
a0f6b076
AD
78#ifndef __attribute__
79/* This feature is available in gcc versions 2.5 and later. */
44ea3fbd
MA
80# if !defined (__GNUC__) || __GNUC__ < 2 || \
81(__GNUC__ == 2 && __GNUC_MINOR__ < 5) || __STRICT_ANSI__
a0f6b076
AD
82# define __attribute__(Spec) /* empty */
83# endif
e9955c83
AD
84#endif
85
a0f6b076
AD
86/* The __-protected variants of `format' and `printf' attributes
87 are accepted by gcc versions 2.6.4 (effectively 2.7) and later. */
e9955c83
AD
88#if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)
89# define __format__ format
90# define __printf__ printf
a0f6b076
AD
91#endif
92
e9955c83
AD
93#ifndef ATTRIBUTE_NORETURN
94# define ATTRIBUTE_NORETURN __attribute__ ((__noreturn__))
95#endif
96
97#ifndef ATTRIBUTE_UNUSED
98# define ATTRIBUTE_UNUSED __attribute__ ((__unused__))
99#endif
a0f6b076
AD
100
101/*------.
102| NLS. |
103`------*/
104
6e26ca8c 105#include <locale.h>
f2d78a99 106
982cc302 107#include <gettext.h>
e0327bc8
AD
108#define _(Msgid) gettext (Msgid)
109#define N_(Msgid) (Msgid)
f2d78a99 110
a0f6b076
AD
111
112/*-------------------------------.
113| Fix broken compilation flags. |
114`-------------------------------*/
115
8a278a04 116#ifndef LOCALEDIR
a0f6b076 117# define LOCALEDIR "/usr/local/share/locale"
8a278a04 118#endif
d968a24b 119
ceed8467 120
015acc48
AD
121/*-----------.
122| Booleans. |
123`-----------*/
124
f61aad93 125#include <stdbool.h>
8c7ebe49
AD
126
127
128/*-----------.
129| Obstacks. |
130`-----------*/
131
342b8b6e
AD
132# define obstack_chunk_alloc xmalloc
133# define obstack_chunk_free free
982cc302 134# include <obstack.h>
8c7ebe49 135
ff4423cc
AD
136#define obstack_sgrow(Obs, Str) \
137 obstack_grow (Obs, Str, strlen (Str))
8c7ebe49
AD
138
139#define obstack_fgrow1(Obs, Format, Arg1) \
140do { \
141 char buf[4096]; \
142 sprintf (buf, Format, Arg1); \
143 obstack_grow (Obs, buf, strlen (buf)); \
144} while (0)
dd60faec
AD
145
146#define obstack_fgrow2(Obs, Format, Arg1, Arg2) \
147do { \
148 char buf[4096]; \
149 sprintf (buf, Format, Arg1, Arg2); \
150 obstack_grow (Obs, buf, strlen (buf)); \
151} while (0)
896fe5c1
AD
152
153#define obstack_fgrow3(Obs, Format, Arg1, Arg2, Arg3) \
154do { \
155 char buf[4096]; \
156 sprintf (buf, Format, Arg1, Arg2, Arg3); \
157 obstack_grow (Obs, buf, strlen (buf)); \
158} while (0)
7de3329e 159
ff4423cc
AD
160#define obstack_fgrow4(Obs, Format, Arg1, Arg2, Arg3, Arg4) \
161do { \
162 char buf[4096]; \
163 sprintf (buf, Format, Arg1, Arg2, Arg3, Arg4); \
164 obstack_grow (Obs, buf, strlen (buf)); \
165} while (0)
166
7de3329e 167
7de3329e 168
381fb12e
AD
169/*-----------------------------------------.
170| Extensions to use for the output files. |
171`-----------------------------------------*/
7de3329e
AD
172
173#ifdef VMS
174 /* VMS. */
982cc302
PE
175# define TAB_EXT "_tab"
176# define OUTPUT_EXT ".output"
7de3329e
AD
177#else /* ! VMS */
178# ifdef MSDOS
179 /* MS DOS. */
982cc302
PE
180# define TAB_EXT "_tab"
181# define OUTPUT_EXT ".out"
7de3329e
AD
182# else /* ! MSDOS */
183 /* Standard. */
982cc302
PE
184# define TAB_EXT ".tab"
185# define OUTPUT_EXT ".output"
7de3329e
AD
186# endif /* ! MSDOS */
187#endif /* ! VMS */
55b96341 188
381fb12e
AD
189#ifndef DEFAULT_TMPDIR
190# define DEFAULT_TMPDIR "/tmp"
191#endif
192
193
194
381fb12e
AD
195/*---------------------.
196| Free a linked list. |
197`---------------------*/
198
300f275f
AD
199#define LIST_FREE(Type, List) \
200do { \
201 Type *_node, *_next; \
202 for (_node = List; _node; _node = _next) \
203 { \
204 _next = _node->next; \
afbb696d 205 free (_node); \
300f275f
AD
206 } \
207} while (0)
208
381fb12e
AD
209
210/*---------------------------------------------.
211| Debugging memory allocation (must be last). |
212`---------------------------------------------*/
342b8b6e
AD
213
214# if WITH_DMALLOC
215# define DMALLOC_FUNC_CHECK
216# include <dmalloc.h>
217# endif /* WITH_DMALLOC */
218
a4b36db4 219#endif /* ! BISON_SYSTEM_H */