]> git.saurik.com Git - bison.git/blame - src/system.h
(GZIP_ENV): Don't use --rsyncable if gzip doesn't
[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>
deedb0b7
PE
57#define CALLOC(P, N) ((P) = xcalloc (N, sizeof *(P)))
58#define MALLOC(P, N) ((P) = xmalloc ((N) * sizeof *(P)))
59#define REALLOC(P, N) ((P) = xrealloc (P, (N) * sizeof *(P)))
b77b9ee0 60
a4b36db4 61/* From xstrndup.c. */
a737b216 62char *xstrndup (const char *str, size_t size);
a4b36db4 63
273a74fa 64
b77b9ee0
AD
65/*---------------------.
66| Missing prototypes. |
67`---------------------*/
68
56100c60 69#if defined HAVE_DECL_STPCPY && !HAVE_DECL_STPCPY
930393cf 70char *stpcpy (char *dest, const char *src);
b77b9ee0
AD
71#endif
72
56100c60 73#if defined HAVE_DECL_STRNLEN && !HAVE_DECL_STRNLEN
a737b216 74size_t strnlen (const char *str, size_t maxlen);
b77b9ee0
AD
75#endif
76
56100c60 77#if defined HAVE_DECL_MEMRCHR && !HAVE_DECL_MEMRCHR
a737b216 78void *memrchr (const void *str, int ch, size_t size);
ec2da99f
AD
79#endif
80
b77b9ee0
AD
81
82
a0f6b076
AD
83/*-----------------.
84| GCC extensions. |
85`-----------------*/
86
48e28efa
PE
87/* Use this to suppress gcc's `...may be used before initialized'
88 warnings. */
89#ifdef lint
90# define IF_LINT(Code) Code
91#else
92# define IF_LINT(Code) /* empty */
93#endif
94
a0f6b076
AD
95#ifndef __attribute__
96/* This feature is available in gcc versions 2.5 and later. */
44ea3fbd
MA
97# if !defined (__GNUC__) || __GNUC__ < 2 || \
98(__GNUC__ == 2 && __GNUC_MINOR__ < 5) || __STRICT_ANSI__
a0f6b076
AD
99# define __attribute__(Spec) /* empty */
100# endif
e9955c83
AD
101#endif
102
a0f6b076
AD
103/* The __-protected variants of `format' and `printf' attributes
104 are accepted by gcc versions 2.6.4 (effectively 2.7) and later. */
e9955c83
AD
105#if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)
106# define __format__ format
107# define __printf__ printf
a0f6b076
AD
108#endif
109
e9955c83
AD
110#ifndef ATTRIBUTE_NORETURN
111# define ATTRIBUTE_NORETURN __attribute__ ((__noreturn__))
112#endif
113
114#ifndef ATTRIBUTE_UNUSED
115# define ATTRIBUTE_UNUSED __attribute__ ((__unused__))
116#endif
a0f6b076
AD
117
118/*------.
119| NLS. |
120`------*/
121
6e26ca8c 122#include <locale.h>
f2d78a99 123
982cc302 124#include <gettext.h>
e0327bc8
AD
125#define _(Msgid) gettext (Msgid)
126#define N_(Msgid) (Msgid)
f2d78a99 127
a0f6b076
AD
128
129/*-------------------------------.
130| Fix broken compilation flags. |
131`-------------------------------*/
132
8a278a04 133#ifndef LOCALEDIR
a0f6b076 134# define LOCALEDIR "/usr/local/share/locale"
8a278a04 135#endif
d968a24b 136
ceed8467 137
015acc48
AD
138/*-----------.
139| Booleans. |
140`-----------*/
141
f61aad93 142#include <stdbool.h>
8c7ebe49
AD
143
144
145/*-----------.
146| Obstacks. |
147`-----------*/
148
342b8b6e
AD
149# define obstack_chunk_alloc xmalloc
150# define obstack_chunk_free free
982cc302 151# include <obstack.h>
8c7ebe49 152
ff4423cc
AD
153#define obstack_sgrow(Obs, Str) \
154 obstack_grow (Obs, Str, strlen (Str))
8c7ebe49
AD
155
156#define obstack_fgrow1(Obs, Format, Arg1) \
157do { \
158 char buf[4096]; \
159 sprintf (buf, Format, Arg1); \
160 obstack_grow (Obs, buf, strlen (buf)); \
161} while (0)
dd60faec
AD
162
163#define obstack_fgrow2(Obs, Format, Arg1, Arg2) \
164do { \
165 char buf[4096]; \
166 sprintf (buf, Format, Arg1, Arg2); \
167 obstack_grow (Obs, buf, strlen (buf)); \
168} while (0)
896fe5c1
AD
169
170#define obstack_fgrow3(Obs, Format, Arg1, Arg2, Arg3) \
171do { \
172 char buf[4096]; \
173 sprintf (buf, Format, Arg1, Arg2, Arg3); \
174 obstack_grow (Obs, buf, strlen (buf)); \
175} while (0)
7de3329e 176
ff4423cc
AD
177#define obstack_fgrow4(Obs, Format, Arg1, Arg2, Arg3, Arg4) \
178do { \
179 char buf[4096]; \
180 sprintf (buf, Format, Arg1, Arg2, Arg3, Arg4); \
181 obstack_grow (Obs, buf, strlen (buf)); \
182} while (0)
183
7de3329e 184
7de3329e 185
381fb12e
AD
186/*-----------------------------------------.
187| Extensions to use for the output files. |
188`-----------------------------------------*/
7de3329e
AD
189
190#ifdef VMS
191 /* VMS. */
982cc302
PE
192# define TAB_EXT "_tab"
193# define OUTPUT_EXT ".output"
7de3329e
AD
194#else /* ! VMS */
195# ifdef MSDOS
196 /* MS DOS. */
982cc302
PE
197# define TAB_EXT "_tab"
198# define OUTPUT_EXT ".out"
7de3329e
AD
199# else /* ! MSDOS */
200 /* Standard. */
982cc302
PE
201# define TAB_EXT ".tab"
202# define OUTPUT_EXT ".output"
7de3329e
AD
203# endif /* ! MSDOS */
204#endif /* ! VMS */
55b96341 205
381fb12e
AD
206#ifndef DEFAULT_TMPDIR
207# define DEFAULT_TMPDIR "/tmp"
208#endif
209
210
211
381fb12e
AD
212/*---------------------.
213| Free a linked list. |
214`---------------------*/
215
300f275f
AD
216#define LIST_FREE(Type, List) \
217do { \
218 Type *_node, *_next; \
219 for (_node = List; _node; _node = _next) \
220 { \
221 _next = _node->next; \
222 XFREE (_node); \
223 } \
224} while (0)
225
381fb12e
AD
226
227/*---------------------------------------------.
228| Debugging memory allocation (must be last). |
229`---------------------------------------------*/
342b8b6e
AD
230
231# if WITH_DMALLOC
232# define DMALLOC_FUNC_CHECK
233# include <dmalloc.h>
234# endif /* WITH_DMALLOC */
235
a4b36db4 236#endif /* ! BISON_SYSTEM_H */