]>
git.saurik.com Git - bison.git/blob - src/system.h
18b1377992e7b102fcc98f7f7f14a58d0930bf2c
1 /* system-dependent definitions for Bison.
2 Copyright (C) 2000, 2001, 2002 Free Software Foundation, Inc.
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2, or (at your option)
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software Foundation,
16 Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
18 #ifndef BISON_SYSTEM_H
19 #define BISON_SYSTEM_H
25 /* AIX requires this to be the first thing in the file. */
27 # define alloca(Size) __builtin_alloca (Size)
35 # ifndef alloca /* predefined by HP cc +Olibcalls */
50 /* The following test is to work around the gross typo in
51 systems like Sony NEWS-OS Release 4.0C, whereby EXIT_FAILURE
52 is defined to 0, not 1. */
55 # define EXIT_FAILURE 1
59 # define EXIT_SUCCESS 0
66 #if defined(STDC_HEADERS) || defined(HAVE_STRING_H)
68 /* An ANSI string.h and pre-ANSI memory.h might conflict. */
69 # if !defined(STDC_HEADERS) && defined(HAVE_MEMORY_H)
71 # endif /* not STDC_HEADERS and HAVE_MEMORY_H */
72 #else /* not STDC_HEADERS and not HAVE_STRING_H */
74 /* memory.h and strings.h conflict on some systems. */
75 #endif /* not STDC_HEADERS and not HAVE_STRING_H */
83 # if defined PROTOTYPES || defined __STDC__
84 # define PARAMS(Args) Args
86 # define PARAMS(Args) ()
94 # define SHRT_MIN (-32768)
97 # define SHRT_MAX 32767
102 /* From xstrndup.c. */
103 char *xstrndup
PARAMS ((const char *s
, size_t n
));
111 extern int time_report
;
114 /*---------------------.
115 | Missing prototypes. |
116 `---------------------*/
118 #if !HAVE_DECL_STPCPY
119 char *stpcpy
PARAMS ((char *dest
, const char *src
));
122 #if !HAVE_DECL_STRCHR
123 char *strchr(const char *s
, int c
);
126 #if !HAVE_DECL_STRSPN
127 size_t strspn(const char *s
, const char *accept
);
130 #if !HAVE_DECL_STRNLEN
131 size_t strnlen
PARAMS ((const char *s
, size_t maxlen
));
134 #if !HAVE_DECL_MEMCHR
135 void *memchr
PARAMS ((const void *s
, int c
, size_t n
));
138 #if !HAVE_DECL_MEMRCHR
139 void *memrchr
PARAMS ((const void *s
, int c
, size_t n
));
148 #ifndef __attribute__
149 /* This feature is available in gcc versions 2.5 and later. */
150 # if !defined (__GNUC__) || __GNUC__ < 2 || \
151 (__GNUC__ == 2 && __GNUC_MINOR__ < 5) || __STRICT_ANSI__
152 # define __attribute__(Spec) /* empty */
156 /* The __-protected variants of `format' and `printf' attributes
157 are accepted by gcc versions 2.6.4 (effectively 2.7) and later. */
158 #if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)
159 # define __format__ format
160 # define __printf__ printf
163 #ifndef ATTRIBUTE_NORETURN
164 # define ATTRIBUTE_NORETURN __attribute__ ((__noreturn__))
167 #ifndef ATTRIBUTE_UNUSED
168 # define ATTRIBUTE_UNUSED __attribute__ ((__unused__))
178 #ifndef HAVE_SETLOCALE
179 # define setlocale(Category, Locale)
183 #define _(Msgid) gettext (Msgid)
184 #define N_(Msgid) (Msgid)
187 /*-------------------------------.
188 | Fix broken compilation flags. |
189 `-------------------------------*/
192 # define LOCALEDIR "/usr/local/share/locale"
211 # define obstack_chunk_alloc xmalloc
212 # define obstack_chunk_free free
213 # include "obstack.h"
215 #define obstack_sgrow(Obs, Str) \
216 obstack_grow (Obs, Str, strlen (Str))
218 #define obstack_fgrow1(Obs, Format, Arg1) \
221 sprintf (buf, Format, Arg1); \
222 obstack_grow (Obs, buf, strlen (buf)); \
225 #define obstack_fgrow2(Obs, Format, Arg1, Arg2) \
228 sprintf (buf, Format, Arg1, Arg2); \
229 obstack_grow (Obs, buf, strlen (buf)); \
232 #define obstack_fgrow3(Obs, Format, Arg1, Arg2, Arg3) \
235 sprintf (buf, Format, Arg1, Arg2, Arg3); \
236 obstack_grow (Obs, buf, strlen (buf)); \
239 #define obstack_fgrow4(Obs, Format, Arg1, Arg2, Arg3, Arg4) \
242 sprintf (buf, Format, Arg1, Arg2, Arg3, Arg4); \
243 obstack_grow (Obs, buf, strlen (buf)); \
248 /*-----------------------------------------.
249 | Extensions to use for the output files. |
250 `-----------------------------------------*/
254 # define EXT_TAB "_tab"
255 # define EXT_OUTPUT ".output"
259 # define EXT_TAB "_tab"
260 # define EXT_OUTPUT ".out"
263 # define EXT_TAB ".tab"
264 # define EXT_OUTPUT ".output"
265 # endif /* ! MSDOS */
268 #ifndef DEFAULT_TMPDIR
269 # define DEFAULT_TMPDIR "/tmp"
274 /*---------------------.
275 | Free a linked list. |
276 `---------------------*/
278 #define LIST_FREE(Type, List) \
280 Type *_node, *_next; \
281 for (_node = List; _node; _node = _next) \
283 _next = _node->next; \
289 /*---------------------------------------------.
290 | Debugging memory allocation (must be last). |
291 `---------------------------------------------*/
294 # define DMALLOC_FUNC_CHECK
295 # include <dmalloc.h>
296 # endif /* WITH_DMALLOC */
298 #endif /* ! BISON_SYSTEM_H */