1 /* 2 * (c) Thomas Pornin 1999 - 2002 3 * (c) Louis P. Santillan 2011 4 * This file is derived from tune.h 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: 9 * 1. Redistributions of source code must retain the above copyright 10 * notice, this list of conditions and the following disclaimer. 11 * 2. Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in the 13 * documentation and/or other materials provided with the distribution. 14 * 4. The name of the authors may not be used to endorse or promote 15 * products derived from this software without specific prior written 16 * permission. 17 * 18 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR 19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 20 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE 22 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 24 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 25 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 26 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 27 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 28 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 * 30 */ 31 32 /* ====================================================================== */ 33 /* 34 * The LOW_MEM macro triggers the use of macro storage which uses less 35 * memory. It actually also improves performance on large, modern machines 36 * (due to less cache pressure). This option implies no limitation (except 37 * on the number of arguments a macro may, which is then limited to 32766) 38 * so it is on by default. Non-LOW_MEM code is considered deprecated. 39 */ 40 #define LOW_MEM 41 42 /* ====================================================================== */ 43 /* 44 * Define AMIGA for systems using "drive letters" at the beginning of 45 * some paths; define MSDOS on systems with drive letters and using 46 * backslashes to seperate directory components. 47 */ 48 /* #define AMIGA */ 49 /* #define MSDOS */ 50 51 /* ====================================================================== */ 52 /* 53 * Define this if your compiler does not know the strftime() function; 54 * TurboC 2.01 under Msdos does not know strftime(). 55 */ 56 /* #define NOSTRFTIME */ 57 58 /* ====================================================================== */ 59 /* 60 * Buffering: there are two levels of buffering on input and output streams: 61 * the standard libc buffering (manageable with setbuf() and setvbuf()) 62 * and some buffering provided by ucpp itself. The ucpp buffering uses 63 * two buffers, of size respectively INPUT_BUF_MEMG and OUTPUT_BUF_MEMG 64 * (as defined below). 65 * You can disable one or both of these bufferings by defining the macros 66 * NO_LIBC_BUF and NO_UCPP_BUF. 67 */ 68 /* #define NO_LIBC_BUF */ 69 /* #define NO_UCPP_BUF */ 70 71 /* 72 * On Unix stations, the system call mmap() might be used on input files. 73 * This option is a subclause of ucpp internal buffering. On one station, 74 * a 10% speed improvement was observed. Do not define this unless the 75 * host architecture has the following characteristics: 76 * -- Posix / Single Unix compliance 77 * -- Text files correspond one to one with memory representation 78 * If a file is not seekable or not mmapable, ucpp will revert to the 79 * standard fread() solution. 80 * 81 * This feature is still considered beta quality. On some systems where 82 * files can be bigger than memory address space (mainly, 32-bit systems 83 * with files bigger than 4 GB), this option makes ucpp fail to operate 84 * on those extremely large files. 85 */ 86 #define UCPP_MMAP 87 88 /* 89 * Performance issues: 90 * -- On memory-starved systems, such as Minix-i86, do not use ucpp 91 * buffering; keep only libc buffering. 92 * -- If you do not use libc buffering, activate the UCPP_MMAP option. 93 * Note that the UCPP_MMAP option is ignored if ucpp buffering is not 94 * activated. 95 * 96 * On an Athlon 1200 running FreeBSD 4.7, the best performances are 97 * achieved when libc buffering is activated and/or UCPP_MMAP is on. 98 */ 99 100 /* ====================================================================== */ 101 /* 102 * Define this if you want ucpp to generate tokenized PRAGMA tokens; 103 * otherwise, it will generate raw string contents. This setting is 104 * irrelevant to the stand-alone version of ucpp. 105 */ 106 #define PRAGMA_TOKENIZE 107 108 /* 109 * Define this to the special character that marks the end of tokens with 110 * a string value inside a tokenized PRAGMA token. The #pragma and _Pragma() 111 * directives which use this character will be a bit more difficult to 112 * decode (but ucpp will not mind). 0 cannot be used. '\n' is fine because 113 * it cannot appear inside a #pragma or _Pragma(), since newlines cannot be 114 * embedded inside tokens, neither directly nor by macro substitution and 115 * stringization. Besides, '\n' is portable. 116 */ 117 #define PRAGMA_TOKEN_END ((unsigned char)'\n') 118 119 /* 120 * Define this if you want ucpp to include encountered #pragma directives 121 * in its output in non-lexer mode; _Pragma() are translated to equivalent 122 * #pragma directives. 123 */ 124 #define PRAGMA_DUMP 125 126 /* 127 * According to my interpretation of the C99 standard, _Pragma() are 128 * evaluated wherever macro expansion could take place. However, Neil Booth, 129 * whose mother language is English (contrary to me) and who is well aware 130 * of the C99 standard (and especially the C preprocessor) told me that 131 * it was unclear whether _Pragma() are evaluated inside directives such 132 * as #if, #include and #line. If you want to disable the evaluation of 133 * _Pragma() inside such directives, define the following macro. 134 */ 135 /* #define NO_PRAGMA_IN_DIRECTIVE */ 136 137 /* 138 * The C99 standard mandates that the operator `##' must yield a single, 139 * valid token, lest undefined behaviour befall upon thy head. Hence, 140 * for instance, `+ ## +=' is forbidden, because `++=' is not a valid 141 * token (although it is a valid list of two tokens, `++' and `='). 142 * However, ucpp only emits a warning for such sin, and unmerges the 143 * tokens (thus emitting `+' then `+=' for that example). When ucpp 144 * produces text output, those two tokens will be separated by a space 145 * character so that the basic rule of text output is preserved: when 146 * parsed again, text output yields the exact same stream of tokens. 147 * That extra space is virtual: it does not count as a true whitespace 148 * token for stringization. 149 * 150 * However, it might be desirable, for some uses other than preprocessing 151 * C source code, not to emit that extra space at all. To make ucpp behave 152 * that way, define the DSHARP_TOKEN_MERGE macro. Please note that this 153 * can trigger spurious token merging. For instance, with that macro 154 * activated, `+ ## +=' will be output as `++=' which, if preprocessed 155 * again, will read as `++' followed by `='. 156 * 157 * All this is irrelevant to lexer mode; and trying to merge incompatible 158 * tokens is a shooting offence, anyway. 159 */ 160 /* #define DSHARP_TOKEN_MERGE */ 161 162 /* ====================================================================== */ 163 /* 164 * Define INMACRO_FLAG to include two flags to the structure lexer_state, 165 * that tell whether tokens come from a macro-replacement, and count those 166 * macro-replacements. 167 */ 168 /* #define INMACRO_FLAG */ 169 170 /* ====================================================================== */ 171 /* 172 * Paths where files are looked for by default, when #include is used. 173 * Typical path is /usr/local/include and /usr/include, in that order. 174 * If you want to set up no path, define the macro to 0. 175 * 176 * For Linux, get gcc includes too, or you will miss things like stddef.h. 177 * The exact path varies much, depending on the distribution. 178 */ 179 #define STD_INCLUDE_PATH "/usr/local/include", "/usr/include" 180 181 /* ====================================================================== */ 182 /* 183 * Arithmetic code for evaluation of #if expressions. Evaluation 184 * uses either a native machine type, or an emulated two's complement 185 * type. Division by 0 and overflow on division are considered as errors 186 * and reported as such. If ARITHMETIC_CHECKS is defined, all other 187 * operations that imply undefined or implementation-defined behaviour 188 * are reported as warnings but otherwise performed nonetheless. 189 * 190 * For native type evaluation, the following macros should be defined: 191 * NATIVE_SIGNED the native signed type 192 * NATIVE_UNSIGNED the native corresponding unsigned type 193 * NATIVE_UNSIGNED_BITS the native unsigned type width, in bits 194 * NATIVE_SIGNED_MIN the native signed type minimum value 195 * NATIVE_SIGNED_MAX the native signed type maximum value 196 * 197 * The code in the arith.c file performs some tricky detection 198 * operations on the native type representation and possible existence 199 * of a trap representation. These operations assume a C99-compliant 200 * compiler; on a C90-only compiler, the operations are valid but may 201 * yield incorrect results. You may force those settings with some 202 * more macros: see the comments in arith.c (look for "ARCH_DEFINED"). 203 * Remember that this is mostly a non-issue, unless you are building 204 * ucpp with a pre-C99 cross-compiler and either the host or target 205 * architecture uses a non-two's complement representation of signed 206 * integers. Such a combination is pretty rare nowadays, so the best 207 * you can do is forgetting completely this paragraph and live in peace. 208 * 209 * 210 * If you do not have a handy native type (for instance, you compile ucpp 211 * with a C90 compiler which lacks the "long long" type, or you compile 212 * ucpp for a cross-compiler which should support an evaluation integer 213 * type of a size that is not available on the host machine), you may use 214 * a simulated type. The type uses two's complement representation and 215 * may have any width from 2 bits to twice the underlying native type 216 * width, inclusive (odd widths are allowed). To use an emulated type, 217 * make sure that NATIVE_SIGNED is not defined, and define the following 218 * macros: 219 * SIMUL_ARITH_SUBTYPE the native underlying type to use 220 * SIMUL_SUBTYPE_BITS the native underlying type width 221 * SIMUL_NUMBITS the emulated type width 222 * 223 * Undefined and implementation-defined behaviours are warned upon, if 224 * ARITHMETIC_CHECKS is defined. Results are truncated to the type 225 * width; shift count for the << and >> operators is reduced modulo the 226 * emulatd type width; right shifting of a signed negative value performs 227 * sign extension (the result is left-padded with bits set to 1). 228 */ 229 230 /* 231 * For native type evaluation with a 64-bit "long long" type. 232 */ 233 #define NATIVE_SIGNED long long 234 #define NATIVE_UNSIGNED unsigned long long 235 #define NATIVE_UNSIGNED_BITS 64 236 #define NATIVE_SIGNED_MIN (-9223372036854775807LL - 1) 237 #define NATIVE_SIGNED_MAX 9223372036854775807LL 238 239 /* 240 * For emulation of a 64-bit type using a native 32-bit "unsigned long" 241 * type. 242 #undef NATIVE_SIGNED 243 #define SIMUL_ARITH_SUBTYPE unsigned long 244 #define SIMUL_SUBTYPE_BITS 32 245 #define SIMUL_NUMBITS 64 246 */ 247 248 /* 249 * Comment out the following line if you want to deactivate arithmetic 250 * checks (warnings upon undefined and implementation-defined 251 * behaviour). Arithmetic checks slow down a bit arithmetic operations, 252 * especially multiplications, but this should not be an issue with 253 * typical C source code. 254 */ 255 #define ARITHMETIC_CHECKS 256 257 /* ====================================================================== */ 258 /* 259 * To force signedness of wide character constants, define WCHAR_SIGNEDNESS 260 * to 0 for unsigned, 1 for signed. By default, wide character constants 261 * are signed if the native `char' type is signed, and unsigned otherwise. 262 #define WCHAR_SIGNEDNESS 0 263 */ 264 265 /* 266 * Standard assertions. They should include one cpu() assertion, one machine() 267 * assertion (identical to cpu()), and one or more system() assertions. 268 * 269 * for Linux/PC: cpu(i386), machine(i386), system(unix), system(linux) 270 * for Linux/Alpha: cpu(alpha), machine(alpha), system(unix), system(linux) 271 * for Sparc/Solaris: cpu(sparc), machine(sparc), system(unix), system(solaris) 272 * 273 * These are only suggestions. On Solaris, machine() should be defined 274 * for i386 or sparc (standard system header use such an assertion). For 275 * cross-compilation, define assertions related to the target architecture. 276 * 277 * If you want no standard assertion, define STD_ASSERT to 0. 278 */ 279 #define STD_ASSERT 0 280 /* 281 #define STD_ASSERT "cpu(i386)", "machine(i386)", "system(unix)", \ 282 "system(freebsd)" 283 */ 284 285 /* ====================================================================== */ 286 /* 287 * System predefined macros. Nothing really mandatory, but some programs 288 * might rely on those. 289 * Each string must be either "name" or "name=token-list". If you want 290 * no predefined macro, define STD_MACROS to 0. 291 */ 292 #define STD_MACROS 0 293 /* 294 #define STD_MACROS "__FreeBSD=4", "__unix", "__i386", \ 295 "__FreeBSD__=4", "__unix__", "__i386__" 296 */ 297 298 /* ====================================================================== */ 299 /* 300 * Default flags; HANDLE_ASSERTIONS is required for Solaris system headers. 301 * See cpp.h for the definition of these flags. 302 */ 303 #define DEFAULT_CPP_FLAGS (DISCARD_COMMENTS | WARN_STANDARD \ 304 | WARN_PRAGMA | FAIL_SHARP | MACRO_VAARG \ 305 | CPLUSPLUS_COMMENTS | LINE_NUM | TEXT_OUTPUT \ 306 | KEEP_OUTPUT | HANDLE_TRIGRAPHS \ 307 | HANDLE_ASSERTIONS) 308 #define DEFAULT_LEXER_FLAGS (DISCARD_COMMENTS | WARN_STANDARD | FAIL_SHARP \ 309 | MACRO_VAARG | CPLUSPLUS_COMMENTS | LEXER \ 310 | HANDLE_TRIGRAPHS | HANDLE_ASSERTIONS) 311 312 /* ====================================================================== */ 313 /* 314 * Define this to use sigsetjmp()/siglongjmp() instead of setjmp()/longjmp(). 315 * This is non-ANSI, but it improves performance on some POSIX system. 316 * On typical C source code, such improvement is completely negligeable. 317 */ 318 /* #define POSIX_JMP */ 319 320 /* ====================================================================== */ 321 /* 322 * Maximum value (plus one) of a character handled by the lexer; 128 is 323 * alright for ASCII native source code, but 256 is needed for EBCDIC. 324 * 256 is safe in both cases; you will have big problems if you set 325 * this value to INT_MAX or above. On Minix-i86 or Msdos (small memory 326 * model), define MAX_CHAR_VAL to 128. 327 * 328 * Set MAX_CHAR_VAL to a power of two to increase lexing speed. Beware 329 * that lexer.c defines a static array of size MSTATE * MAX_CHAR_VAL 330 * values of type int (MSTATE is defined in lexer.c and is about 40). 331 */ 332 #define MAX_CHAR_VAL 128 333 334 /* 335 * If you want some extra character to be considered as whitespace, 336 * define this macro to that space. On ISO-8859-1 machines, 160 is 337 * the code for the unbreakable space. 338 */ 339 /* #define UNBREAKABLE_SPACE 160 */ 340 341 /* 342 * If you want whitespace tokens contents to be recorded (making them 343 * tokens with a string content), define this. The macro STRING_TOKEN 344 * will be adjusted accordingly. 345 * Without this option, whitespace tokens are not even returned by the 346 * lex() function. This is irrelevant for the non-lexer mode (almost -- 347 * it might slow down a bit ucpp, and with this option, comments will be 348 * kept inside #pragma directives). 349 */ 350 /* #define SEMPER_FIDELIS */ 351 352 /* End of options overridable by UCPP_CONFIG and config.h */ 353