]> git.saurik.com Git - bison.git/blob - src/system.h
* src/output.c (token_actions): Introduce a temporary array,
[bison.git] / src / system.h
1 /* system-dependent definitions for Bison.
2 Copyright (C) 2000 Free Software Foundation, Inc.
3
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)
7 any later version.
8
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.
13
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. */
17
18 #ifndef BISON_SYSTEM_H
19 #define BISON_SYSTEM_H
20
21 #ifdef HAVE_CONFIG_H
22 # include <config.h>
23 #endif
24
25 #include <stdio.h>
26
27 #ifdef MSDOS
28 # include <io.h>
29 #endif
30
31 #ifdef _MSC_VER
32 # include <stdlib.h>
33 # include <process.h>
34 # define getpid _getpid
35 #endif
36
37 #if HAVE_STDLIB_H
38 # include <stdlib.h>
39 #endif
40
41 #if HAVE_UNISTD_H
42 # include <unistd.h>
43 #endif
44
45 #if defined(STDC_HEADERS) || defined(HAVE_STRING_H)
46 # include <string.h>
47 /* An ANSI string.h and pre-ANSI memory.h might conflict. */
48 # if !defined(STDC_HEADERS) && defined(HAVE_MEMORY_H)
49 # include <memory.h>
50 # endif /* not STDC_HEADERS and HAVE_MEMORY_H */
51 # ifndef bcopy
52 # define bcopy(src, dst, num) memcpy((dst), (src), (num))
53 # endif
54 #else /* not STDC_HEADERS and not HAVE_STRING_H */
55 # include <strings.h>
56 /* memory.h and strings.h conflict on some systems. */
57 #endif /* not STDC_HEADERS and not HAVE_STRING_H */
58
59 #if defined(STDC_HEADERS) || defined(HAVE_CTYPE_H)
60 # include <ctype.h>
61 #endif
62
63 #include <errno.h>
64 #ifndef errno
65 extern int errno;
66 #endif
67
68 #if PROTOTYPES
69 # define PARAMS(p) p
70 #else
71 # define PARAMS(p) ()
72 #endif
73
74 /*-----------------.
75 | GCC extensions. |
76 `-----------------*/
77
78 #ifndef __attribute__
79 /* This feature is available in gcc versions 2.5 and later. */
80 # if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) || __STRICT_ANSI__
81 # define __attribute__(Spec) /* empty */
82 # endif
83 /* The __-protected variants of `format' and `printf' attributes
84 are accepted by gcc versions 2.6.4 (effectively 2.7) and later. */
85 # if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)
86 # define __format__ format
87 # define __printf__ printf
88 # endif
89 #endif
90
91
92 /*------.
93 | NLS. |
94 `------*/
95
96 #ifdef HAVE_LOCALE_H
97 # include <locale.h>
98 #endif
99 #ifndef HAVE_SETLOCALE
100 # define setlocale(Category, Locale)
101 #endif
102
103 #ifdef ENABLE_NLS
104 # include <libintl.h>
105 # define _(Text) gettext (Text)
106 #else
107 # undef bindtextdomain
108 # define bindtextdomain(Domain, Directory)
109 # undef textdomain
110 # define textdomain(Domain)
111 # define _(Text) Text
112 #endif
113 #define N_(Text) Text
114
115
116 /*-------------------------------.
117 | Fix broken compilation flags. |
118 `-------------------------------*/
119
120 #ifndef LOCALEDIR
121 # define LOCALEDIR "/usr/local/share/locale"
122 #endif
123
124 #endif /* BISON_SYSTEM_H */
125
126
127 /*---------------------------------.
128 | Machine-dependencies for Bison. |
129 `---------------------------------*/
130
131 #ifdef eta10
132 # define MAXSHORT 2147483647
133 # define MINSHORT -2147483648
134 #else
135 # define MAXSHORT 32767
136 # define MINSHORT -32768
137 #endif
138
139 #if defined (MSDOS) && !defined (__GO32__)
140 # define BITS_PER_WORD 16
141 # define MAXTABLE 16383
142 #else
143 # define BITS_PER_WORD 32
144 # define MAXTABLE 32767
145 #endif
146
147 #define WORDSIZE(n) (((n) + BITS_PER_WORD - 1) / BITS_PER_WORD)
148 #define SETBIT(x, i) ((x)[(i)/BITS_PER_WORD] |= (1<<((i) % BITS_PER_WORD)))
149 #define RESETBIT(x, i) ((x)[(i)/BITS_PER_WORD] &= ~(1<<((i) % BITS_PER_WORD)))
150 #define BITISSET(x, i) (((x)[(i)/BITS_PER_WORD] & (1<<((i) % BITS_PER_WORD))) != 0)