Mercurial > hg > qcc
comparison tcc.h @ 554:8c020de0af57
Fix earlier options.c break-up by migrating some stuff from tcc.h to tinycc.h.
(This means i386-tinycc can once again rebuild itself without segfaulting.)
author | Rob Landley <rob@landley.net> |
---|---|
date | Thu, 06 Mar 2008 20:53:55 -0600 |
parents | 4533aa54ffcf |
children | 646f1f0972b6 |
comparison
equal
deleted
inserted
replaced
553:4533aa54ffcf | 554:8c020de0af57 |
---|---|
4 * Copyright (c) 2001-2004 Fabrice Bellard | 4 * Copyright (c) 2001-2004 Fabrice Bellard |
5 * Copyright (C) 2006-2007 Rob Landley | 5 * Copyright (C) 2006-2007 Rob Landley |
6 * | 6 * |
7 * Licensed under GPLv2, see file LICENSE in this tarball. | 7 * Licensed under GPLv2, see file LICENSE in this tarball. |
8 */ | 8 */ |
9 #define _GNU_SOURCE | 9 // #define _GNU_SOURCE |
10 | 10 |
11 #ifdef CONFIG_TCCBOOT | 11 #ifdef CONFIG_TCCBOOT |
12 | 12 |
13 #include "tccboot.h" | 13 #include "tccboot.h" |
14 #define CONFIG_TCC_STATIC | 14 #define CONFIG_TCC_STATIC |
291 } CachedInclude; | 291 } CachedInclude; |
292 | 292 |
293 #define CACHED_INCLUDES_HASH_SIZE 512 | 293 #define CACHED_INCLUDES_HASH_SIZE 512 |
294 | 294 |
295 /* additional information about token */ | 295 /* additional information about token */ |
296 #define TOK_FLAG_BOW 0x0001 /* beginning of word before */ | 296 //#define TOK_FLAG_BOW 0x0001 /* beginning of word before */ |
297 #define TOK_FLAG_BOL 0x0002 /* beginning of line before */ | 297 //#define TOK_FLAG_BOL 0x0002 /* beginning of line before */ |
298 #define TOK_FLAG_BOF 0x0004 /* beginning of file before */ | 298 //#define TOK_FLAG_BOF 0x0004 /* beginning of file before */ |
299 #define TOK_FLAG_ENDIF 0x0008 /* a endif was found matching starting #ifdef */ | 299 #define TOK_FLAG_ENDIF 0x0008 /* a endif was found matching starting #ifdef */ |
300 | 300 |
301 #define PARSE_FLAG_PREPROCESS 0x0001 /* activate preprocessing */ | 301 #define PARSE_FLAG_PREPROCESS 0x0001 /* activate preprocessing */ |
302 #define PARSE_FLAG_TOK_NUM 0x0002 /* return numbers instead of TOK_PPNUM */ | 302 #define PARSE_FLAG_TOK_NUM 0x0002 /* return numbers instead of TOK_PPNUM */ |
303 #define PARSE_FLAG_LINEFEED 0x0004 /* line feed is returned as a | 303 #define PARSE_FLAG_LINEFEED 0x0004 /* line feed is returned as a |
305 returned at eof */ | 305 returned at eof */ |
306 #define PARSE_FLAG_ASM_COMMENTS 0x0008 /* '#' can be used for line comment */ | 306 #define PARSE_FLAG_ASM_COMMENTS 0x0008 /* '#' can be used for line comment */ |
307 | 307 |
308 #define SYM_POOL_NB (8192 / sizeof(Sym)) | 308 #define SYM_POOL_NB (8192 / sizeof(Sym)) |
309 | 309 |
310 struct dynarray { | 310 //struct dynarray { |
311 char **data; | 311 // char **data; |
312 int len; | 312 // int len; |
313 }; | 313 //}; |
314 | 314 |
315 struct TCCState { | 315 struct TCCState { |
316 int output_type; | 316 //int output_type; |
317 | 317 |
318 BufferedFile **include_stack_ptr; | 318 BufferedFile **include_stack_ptr; |
319 int *ifdef_stack_ptr; | 319 int *ifdef_stack_ptr; |
320 | 320 |
321 /* include file handling */ | 321 /* include file handling */ |
322 struct dynarray include_paths; | 322 // struct dynarray include_paths; |
323 struct dynarray sysinclude_paths; | 323 struct dynarray sysinclude_paths; |
324 | 324 |
325 //struct dynarray cached_includes; | 325 //struct dynarray cached_includes; |
326 CachedInclude **cached_includes; | 326 CachedInclude **cached_includes; |
327 int nb_cached_includes; | 327 int nb_cached_includes; |
328 | 328 |
329 struct dynarray library_paths; | 329 // struct dynarray library_paths; |
330 | 330 |
331 /* array of all loaded dlls (including those referenced by loaded | 331 /* array of all loaded dlls (including those referenced by loaded |
332 dlls) */ | 332 dlls) */ |
333 //struct dynarray loaded_dlls; | 333 //struct dynarray loaded_dlls; |
334 DLLReference **loaded_dlls; | 334 DLLReference **loaded_dlls; |
351 /* temporary dynamic symbol sections (for dll loading) */ | 351 /* temporary dynamic symbol sections (for dll loading) */ |
352 Section *dynsymtab_section; | 352 Section *dynsymtab_section; |
353 /* exported dynamic symbol section */ | 353 /* exported dynamic symbol section */ |
354 Section *dynsym; | 354 Section *dynsym; |
355 | 355 |
356 int nostdinc; /* if true, no standard headers are added */ | 356 // int nostdinc; /* if true, no standard headers are added */ |
357 int nostdlib; /* if true, no standard libraries are added */ | 357 // int nostdlib; /* if true, no standard libraries are added */ |
358 | 358 |
359 int nocommon; /* if true, do not use common symbols for .bss data */ | 359 //int nocommon; /* if true, do not use common symbols for .bss data */ |
360 | 360 |
361 /* if true, static linking is performed */ | 361 /* if true, static linking is performed */ |
362 int static_link; | 362 // int static_link; |
363 | 363 |
364 /* if true, all symbols are exported */ | 364 /* if true, all symbols are exported */ |
365 int rdynamic; | 365 // int rdynamic; |
366 | 366 |
367 /* if true, describe each room as you enter it, unless it contains a grue */ | 367 /* if true, describe each room as you enter it, unless it contains a grue */ |
368 int verbose; | 368 // int verbose; |
369 | 369 |
370 /* if true, only link in referenced objects from archive */ | 370 /* if true, only link in referenced objects from archive */ |
371 int alacarte_link; | 371 int alacarte_link; |
372 | 372 |
373 /* address of text section */ | 373 /* address of text section */ |
374 unsigned long text_addr; | 374 // unsigned long text_addr; |
375 int has_text_addr; | 375 // int has_text_addr; |
376 | 376 |
377 /* output format, see TCC_OUTPUT_FORMAT_xxx */ | 377 /* output format, see TCC_OUTPUT_FORMAT_xxx */ |
378 int output_format; | 378 // int output_format; |
379 | 379 |
380 /* C language options */ | 380 /* C language options */ |
381 int char_is_unsigned; | 381 //int char_is_unsigned; |
382 int leading_underscore; | 382 //int leading_underscore; |
383 | 383 |
384 /* warning switches */ | 384 /* warning switches */ |
385 int warn_write_strings; | 385 //int warn_write_strings; |
386 int warn_unsupported; | 386 //int warn_unsupported; |
387 int warn_error; | 387 //int warn_error; |
388 int warn_none; | 388 //int warn_none; |
389 int warn_implicit_function_declaration; | 389 //int warn_implicit_function_declaration; |
390 | 390 |
391 /* error handling */ | 391 /* error handling */ |
392 void *error_opaque; | 392 void *error_opaque; |
393 void (*error_func)(void *opaque, char *msg); | 393 void (*error_func)(void *opaque, char *msg); |
394 int error_set_jmp_enabled; | 394 int error_set_jmp_enabled; |
410 /* pack stack */ | 410 /* pack stack */ |
411 int pack_stack[PACK_STACK_SIZE]; | 411 int pack_stack[PACK_STACK_SIZE]; |
412 int *pack_stack_ptr; | 412 int *pack_stack_ptr; |
413 | 413 |
414 /* output file for preprocessing */ | 414 /* output file for preprocessing */ |
415 FILE *outfile; | 415 // FILE *outfile; |
416 }; | 416 }; |
417 | 417 |
418 /* The current value can be: */ | 418 /* The current value can be: */ |
419 #define VT_VALMASK 0x00ff | 419 #define VT_VALMASK 0x00ff |
420 #define VT_CONST 0x00f0 /* constant in vc | 420 #define VT_CONST 0x00f0 /* constant in vc |
534 #define TOK_A_XOR 0xde | 534 #define TOK_A_XOR 0xde |
535 #define TOK_A_OR 0xfc | 535 #define TOK_A_OR 0xfc |
536 #define TOK_A_SHL 0x81 | 536 #define TOK_A_SHL 0x81 |
537 #define TOK_A_SAR 0x82 | 537 #define TOK_A_SAR 0x82 |
538 | 538 |
539 #ifndef offsetof | 539 //#ifndef offsetof |
540 #define offsetof(type, field) ((size_t) &((type *)0)->field) | 540 //#define offsetof(type, field) ((size_t) &((type *)0)->field) |
541 #endif | 541 //#endif |
542 | 542 |
543 #ifndef countof | 543 //#ifndef countof |
544 #define countof(tab) (sizeof(tab) / sizeof((tab)[0])) | 544 //#define countof(tab) (sizeof(tab) / sizeof((tab)[0])) |
545 #endif | 545 //#endif |
546 | 546 |
547 /* WARNING: the content of this string encodes token numbers */ | 547 /* WARNING: the content of this string encodes token numbers */ |
548 static unsigned char tok_two_chars[] = "<=\236>=\235!=\225&&\240||\241++\244--\242==\224<<\1>>\2+=\253-=\255*=\252/=\257%=\245&=\246^=\336|=\374->\313..\250##\266"; | 548 static unsigned char tok_two_chars[] = "<=\236>=\235!=\225&&\240||\241++\244--\242==\224<<\1>>\2+=\253-=\255*=\252/=\257%=\245&=\246^=\336|=\374->\313..\250##\266"; |
549 | 549 |
550 #define TOK_EOF (-1) /* end of file */ | 550 #define TOK_EOF (-1) /* end of file */ |
551 #define TOK_LINEFEED 10 /* line feed */ | 551 #define TOK_LINEFEED 10 /* line feed */ |
552 | 552 |
553 /* all identificators and strings have token above that */ | 553 /* all identificators and strings have token above that */ |
554 #define TOK_IDENT 256 | 554 //#define TOK_IDENT 256 |
555 | 555 |
556 /* only used for i386 asm opcodes definitions */ | 556 /* only used for i386 asm opcodes definitions */ |
557 #define DEF_ASM(x) DEF(TOK_ASM_ ## x, #x) | 557 #define DEF_ASM(x) DEF(TOK_ASM_ ## x, #x) |
558 | 558 |
559 #define DEF_BWL(x) \ | 559 #define DEF_BWL(x) \ |
660 /* XXX: need to define this to use them in non ISOC99 context */ | 660 /* XXX: need to define this to use them in non ISOC99 context */ |
661 extern float strtof (const char *__nptr, char **__endptr); | 661 extern float strtof (const char *__nptr, char **__endptr); |
662 extern long double strtold (const char *__nptr, char **__endptr); | 662 extern long double strtold (const char *__nptr, char **__endptr); |
663 #endif | 663 #endif |
664 | 664 |
665 char *pstrcpy(char *buf, int buf_size, char *s); | 665 //char *pstrcpy(char *buf, int buf_size, char *s); |
666 static char *pstrcat(char *buf, int buf_size, char *s); | 666 static char *pstrcat(char *buf, int buf_size, char *s); |
667 static char *tcc_basename(char *name); | 667 static char *tcc_basename(char *name); |
668 | 668 |
669 static void next(void); | 669 static void next(void); |
670 static void next_nomacro(void); | 670 static void next_nomacro(void); |
752 unsigned long value, Section *sec, int sym_index); | 752 unsigned long value, Section *sec, int sym_index); |
753 static void put_stabn(int type, int other, int desc, int value); | 753 static void put_stabn(int type, int other, int desc, int value); |
754 static void put_stabd(int type, int other, int desc); | 754 static void put_stabd(int type, int other, int desc); |
755 static int tcc_add_dll(TCCState *s, char *filename, int flags); | 755 static int tcc_add_dll(TCCState *s, char *filename, int flags); |
756 | 756 |
757 #define AFF_PRINT_ERROR 0x0001 /* print error if file not found */ | 757 //#define AFF_PRINT_ERROR 0x0001 /* print error if file not found */ |
758 #define AFF_REFERENCED_DLL 0x0002 /* load a referenced dll from another dll */ | 758 #define AFF_REFERENCED_DLL 0x0002 /* load a referenced dll from another dll */ |
759 #define AFF_PREPROCESS 0x0004 /* preprocess file */ | 759 //#define AFF_PREPROCESS 0x0004 /* preprocess file */ |
760 int tcc_add_file_internal(TCCState *s, char *filename, int flags); | 760 //int tcc_add_file_internal(TCCState *s, char *filename, int flags); |
761 | 761 |
762 /* tcccoff.c */ | 762 /* tcccoff.c */ |
763 int tcc_output_coff(TCCState *s1, FILE *f); | 763 int tcc_output_coff(TCCState *s1, FILE *f); |
764 | 764 |
765 /* tccpe.c */ | 765 /* tccpe.c */ |
874 | 874 |
875 #include <dlfcn.h> | 875 #include <dlfcn.h> |
876 | 876 |
877 static inline void *resolve_sym(TCCState *s1, char *sym, int type) | 877 static inline void *resolve_sym(TCCState *s1, char *sym, int type) |
878 { | 878 { |
879 return dlsym(RTLD_DEFAULT, sym); | 879 return dlsym(0, sym); |
880 } | 880 } |
881 | 881 |
882 /* space excluding newline */ | 882 /* space excluding newline */ |
883 static inline int is_space(int ch) | 883 //static inline int is_space(int ch) |
884 { | 884 //{ |
885 return ch == ' ' || ch == '\t' || ch == '\v' || ch == '\f' || ch == '\r'; | 885 // return ch == ' ' || ch == '\t' || ch == '\v' || ch == '\f' || ch == '\r'; |
886 } | 886 //} |
887 | 887 |
888 | 888 |
889 #endif | 889 #endif |