]>
git.saurik.com Git - bison.git/blob - src/system.h
985bbbeed46349fc647588596e95d03df8418a67
   1 /* System-dependent definitions for Bison. 
   3    Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free 
   4    Software Foundation, Inc. 
   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) 
  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. 
  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, 
  18    Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */ 
  20 #ifndef BISON_SYSTEM_H 
  21 #define BISON_SYSTEM_H 
  23 /* flex 2.5.31 gratutiously defines macros like INT8_MIN.  But this 
  24    runs afoul of pre-C99 compilers that have <inttypes.h> or 
  25    <stdint.h>, which are included below if available.  It also runs 
  26    afoul of pre-C99 compilers that define these macros in <limits.h>.  */ 
  27 #if ! defined __STDC_VERSION__ || __STDC_VERSION__ < 199901 
  45 # include <sys/types.h> 
  52 /* This isn't perfect, but it's good enough for Bison, which needs 
  53    only to hash pointers.  */ 
  54 typedef size_t uintptr_t; 
  62 #include <unlocked-io.h> 
  71 /* Use this to suppress gcc's `...may be used before initialized' 
  74 # define IF_LINT(Code) Code 
  76 # define IF_LINT(Code) /* empty */ 
  80 /* This feature is available in gcc versions 2.5 and later.  */ 
  81 # if (! defined __GNUC__ || __GNUC__ < 2 \ 
  82       || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) || __STRICT_ANSI__) 
  83 #  define __attribute__(Spec) /* empty */ 
  87 /* The __-protected variants of `format' and `printf' attributes 
  88    are accepted by gcc versions 2.6.4 (effectively 2.7) and later.  */ 
  89 #if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7) 
  90 # define __format__ format 
  91 # define __printf__ printf 
  94 #ifndef ATTRIBUTE_NORETURN 
  95 # define ATTRIBUTE_NORETURN __attribute__ ((__noreturn__)) 
  98 #ifndef ATTRIBUTE_UNUSED 
  99 # define ATTRIBUTE_UNUSED __attribute__ ((__unused__)) 
 102 #define FUNCTION_PRINT() fprintf (stderr, "%s: ", __func__) 
 111 #define _(Msgid)  gettext (Msgid) 
 112 #define N_(Msgid) (Msgid) 
 127 /* <assert.h>'s assertions are too heavyweight, and can be disabled 
 128    too easily, so use aver rather than assert.  */ 
 130 aver (bool assertion
) 
 141 #define obstack_chunk_alloc xmalloc 
 142 #define obstack_chunk_free  free 
 145 #define obstack_sgrow(Obs, Str) \ 
 146   obstack_grow (Obs, Str, strlen (Str)) 
 148 #define obstack_fgrow1(Obs, Format, Arg1)       \ 
 151   sprintf (buf, Format, Arg1);                  \ 
 152   obstack_grow (Obs, buf, strlen (buf));        \ 
 155 #define obstack_fgrow2(Obs, Format, Arg1, Arg2) \ 
 158   sprintf (buf, Format, Arg1, Arg2);            \ 
 159   obstack_grow (Obs, buf, strlen (buf));        \ 
 162 #define obstack_fgrow3(Obs, Format, Arg1, Arg2, Arg3)   \ 
 165   sprintf (buf, Format, Arg1, Arg2, Arg3);              \ 
 166   obstack_grow (Obs, buf, strlen (buf));                \ 
 169 #define obstack_fgrow4(Obs, Format, Arg1, Arg2, Arg3, Arg4)     \ 
 172   sprintf (buf, Format, Arg1, Arg2, Arg3, Arg4);                \ 
 173   obstack_grow (Obs, buf, strlen (buf));                        \ 
 178 /*-----------------------------------------. 
 179 | Extensions to use for the output files.  | 
 180 `-----------------------------------------*/ 
 183 # define OUTPUT_EXT ".output" 
 187 # define TAB_EXT ".tab" 
 190 #ifndef DEFAULT_TMPDIR 
 191 # define DEFAULT_TMPDIR "/tmp" 
 196 /*---------------------. 
 197 | Free a linked list.  | 
 198 `---------------------*/ 
 200 #define LIST_FREE(Type, List)                   \ 
 202   Type *_node, *_next;                          \ 
 203   for (_node = List; _node; _node = _next)      \ 
 205       _next = _node->next;                      \ 
 211 /*---------------------------------------------. 
 212 | Debugging memory allocation (must be last).  | 
 213 `---------------------------------------------*/ 
 216 #  define DMALLOC_FUNC_CHECK 
 217 #  include <dmalloc.h> 
 218 # endif /* WITH_DMALLOC */ 
 220 #endif  /* ! BISON_SYSTEM_H */