Mercurial > hg > qcc
annotate tinycc.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 | |
children |
rev | line source |
---|---|
554
8c020de0af57
Fix earlier options.c break-up by migrating some stuff from tcc.h to tinycc.h.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
1 #include "libtinycc.h" |
8c020de0af57
Fix earlier options.c break-up by migrating some stuff from tcc.h to tinycc.h.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
2 |
8c020de0af57
Fix earlier options.c break-up by migrating some stuff from tcc.h to tinycc.h.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
3 #include <stdint.h> |
8c020de0af57
Fix earlier options.c break-up by migrating some stuff from tcc.h to tinycc.h.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
4 #include <stdio.h> |
8c020de0af57
Fix earlier options.c break-up by migrating some stuff from tcc.h to tinycc.h.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
5 #include <stdlib.h> |
8c020de0af57
Fix earlier options.c break-up by migrating some stuff from tcc.h to tinycc.h.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
6 #include <string.h> |
8c020de0af57
Fix earlier options.c break-up by migrating some stuff from tcc.h to tinycc.h.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
7 #include <sys/types.h> |
8c020de0af57
Fix earlier options.c break-up by migrating some stuff from tcc.h to tinycc.h.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
8 #include <sys/time.h> |
8c020de0af57
Fix earlier options.c break-up by migrating some stuff from tcc.h to tinycc.h.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
9 #include <time.h> |
8c020de0af57
Fix earlier options.c break-up by migrating some stuff from tcc.h to tinycc.h.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
10 |
8c020de0af57
Fix earlier options.c break-up by migrating some stuff from tcc.h to tinycc.h.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
11 // Data type for dynamic resizeable arrays |
8c020de0af57
Fix earlier options.c break-up by migrating some stuff from tcc.h to tinycc.h.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
12 struct dynarray { |
8c020de0af57
Fix earlier options.c break-up by migrating some stuff from tcc.h to tinycc.h.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
13 char **data; |
8c020de0af57
Fix earlier options.c break-up by migrating some stuff from tcc.h to tinycc.h.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
14 int len; |
8c020de0af57
Fix earlier options.c break-up by migrating some stuff from tcc.h to tinycc.h.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
15 }; |
8c020de0af57
Fix earlier options.c break-up by migrating some stuff from tcc.h to tinycc.h.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
16 |
8c020de0af57
Fix earlier options.c break-up by migrating some stuff from tcc.h to tinycc.h.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
17 // All these tccg_ things can be grouped into a structure, but not until after |
8c020de0af57
Fix earlier options.c break-up by migrating some stuff from tcc.h to tinycc.h.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
18 // they're broken out of TCCState and moved over. |
8c020de0af57
Fix earlier options.c break-up by migrating some stuff from tcc.h to tinycc.h.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
19 |
8c020de0af57
Fix earlier options.c break-up by migrating some stuff from tcc.h to tinycc.h.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
20 // Warning switches |
8c020de0af57
Fix earlier options.c break-up by migrating some stuff from tcc.h to tinycc.h.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
21 |
8c020de0af57
Fix earlier options.c break-up by migrating some stuff from tcc.h to tinycc.h.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
22 int tccg_warn_unsupported; |
8c020de0af57
Fix earlier options.c break-up by migrating some stuff from tcc.h to tinycc.h.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
23 int tccg_warn_write_strings; |
8c020de0af57
Fix earlier options.c break-up by migrating some stuff from tcc.h to tinycc.h.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
24 int tccg_warn_error; |
8c020de0af57
Fix earlier options.c break-up by migrating some stuff from tcc.h to tinycc.h.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
25 int tccg_warn_implicit_function_declaration; |
8c020de0af57
Fix earlier options.c break-up by migrating some stuff from tcc.h to tinycc.h.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
26 int tccg_warn_none; |
8c020de0af57
Fix earlier options.c break-up by migrating some stuff from tcc.h to tinycc.h.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
27 |
8c020de0af57
Fix earlier options.c break-up by migrating some stuff from tcc.h to tinycc.h.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
28 // C language options |
8c020de0af57
Fix earlier options.c break-up by migrating some stuff from tcc.h to tinycc.h.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
29 |
8c020de0af57
Fix earlier options.c break-up by migrating some stuff from tcc.h to tinycc.h.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
30 int tccg_char_is_unsigned; |
8c020de0af57
Fix earlier options.c break-up by migrating some stuff from tcc.h to tinycc.h.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
31 int tccg_leading_underscore; |
8c020de0af57
Fix earlier options.c break-up by migrating some stuff from tcc.h to tinycc.h.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
32 |
8c020de0af57
Fix earlier options.c break-up by migrating some stuff from tcc.h to tinycc.h.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
33 // Don't merge identical symbols in .bss segment, error instead. |
8c020de0af57
Fix earlier options.c break-up by migrating some stuff from tcc.h to tinycc.h.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
34 int tccg_nocommon; |
8c020de0af57
Fix earlier options.c break-up by migrating some stuff from tcc.h to tinycc.h.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
35 |
8c020de0af57
Fix earlier options.c break-up by migrating some stuff from tcc.h to tinycc.h.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
36 // if true, describe each room as you enter it, unless it contains a grue |
8c020de0af57
Fix earlier options.c break-up by migrating some stuff from tcc.h to tinycc.h.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
37 int tccg_verbose; |
8c020de0af57
Fix earlier options.c break-up by migrating some stuff from tcc.h to tinycc.h.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
38 |
8c020de0af57
Fix earlier options.c break-up by migrating some stuff from tcc.h to tinycc.h.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
39 // Include file handling |
8c020de0af57
Fix earlier options.c break-up by migrating some stuff from tcc.h to tinycc.h.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
40 struct dynarray tccg_include_paths; |
8c020de0af57
Fix earlier options.c break-up by migrating some stuff from tcc.h to tinycc.h.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
41 struct dynarray tccg_library_paths; |
8c020de0af57
Fix earlier options.c break-up by migrating some stuff from tcc.h to tinycc.h.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
42 |
8c020de0af57
Fix earlier options.c break-up by migrating some stuff from tcc.h to tinycc.h.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
43 int tccg_output_type; |
8c020de0af57
Fix earlier options.c break-up by migrating some stuff from tcc.h to tinycc.h.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
44 int tccg_output_format;// TCC_OUTPUT_FORMAT_xxx |
8c020de0af57
Fix earlier options.c break-up by migrating some stuff from tcc.h to tinycc.h.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
45 int tccg_static_link; // Perform static linking? |
8c020de0af57
Fix earlier options.c break-up by migrating some stuff from tcc.h to tinycc.h.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
46 int tccg_nostdinc; // If true, no standard headers are added. |
8c020de0af57
Fix earlier options.c break-up by migrating some stuff from tcc.h to tinycc.h.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
47 int tccg_nostdlib; // If true, no standard libraries are added. |
8c020de0af57
Fix earlier options.c break-up by migrating some stuff from tcc.h to tinycc.h.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
48 int tccg_rdynamic; // Export all symbols. |
8c020de0af57
Fix earlier options.c break-up by migrating some stuff from tcc.h to tinycc.h.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
49 |
8c020de0af57
Fix earlier options.c break-up by migrating some stuff from tcc.h to tinycc.h.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
50 unsigned long tccg_text_addr; // Address of text section. |
8c020de0af57
Fix earlier options.c break-up by migrating some stuff from tcc.h to tinycc.h.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
51 int tccg_has_text_addr; |
8c020de0af57
Fix earlier options.c break-up by migrating some stuff from tcc.h to tinycc.h.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
52 |
8c020de0af57
Fix earlier options.c break-up by migrating some stuff from tcc.h to tinycc.h.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
53 FILE *tccg_outfile; // Output file for preprocessing. |
8c020de0af57
Fix earlier options.c break-up by migrating some stuff from tcc.h to tinycc.h.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
54 |
8c020de0af57
Fix earlier options.c break-up by migrating some stuff from tcc.h to tinycc.h.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
55 // Functions from elsewhere. |
8c020de0af57
Fix earlier options.c break-up by migrating some stuff from tcc.h to tinycc.h.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
56 |
8c020de0af57
Fix earlier options.c break-up by migrating some stuff from tcc.h to tinycc.h.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
57 void error(char *fmt, ...); |
8c020de0af57
Fix earlier options.c break-up by migrating some stuff from tcc.h to tinycc.h.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
58 void *xmalloc(unsigned long size); |
8c020de0af57
Fix earlier options.c break-up by migrating some stuff from tcc.h to tinycc.h.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
59 void dynarray_add(void ***ptab, int *nb_ptr, void *data); |
8c020de0af57
Fix earlier options.c break-up by migrating some stuff from tcc.h to tinycc.h.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
60 void add_dynarray_path(TCCState *s, char *pathname, struct dynarray *dd); |
8c020de0af57
Fix earlier options.c break-up by migrating some stuff from tcc.h to tinycc.h.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
61 int strstart(char *str, char *val, char **ptr); |
8c020de0af57
Fix earlier options.c break-up by migrating some stuff from tcc.h to tinycc.h.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
62 void warning(char *fmt, ...); |
8c020de0af57
Fix earlier options.c break-up by migrating some stuff from tcc.h to tinycc.h.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
63 int init_output_type(TCCState *s); |
8c020de0af57
Fix earlier options.c break-up by migrating some stuff from tcc.h to tinycc.h.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
64 char *pstrcpy(char *buf, int buf_size, char *s); |
8c020de0af57
Fix earlier options.c break-up by migrating some stuff from tcc.h to tinycc.h.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
65 int tcc_add_file_internal(TCCState *s, char *filename, int flags); |
8c020de0af57
Fix earlier options.c break-up by migrating some stuff from tcc.h to tinycc.h.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
66 |
8c020de0af57
Fix earlier options.c break-up by migrating some stuff from tcc.h to tinycc.h.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
67 extern char *tinycc_path; |
8c020de0af57
Fix earlier options.c break-up by migrating some stuff from tcc.h to tinycc.h.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
68 |
8c020de0af57
Fix earlier options.c break-up by migrating some stuff from tcc.h to tinycc.h.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
69 #ifndef offsetof |
8c020de0af57
Fix earlier options.c break-up by migrating some stuff from tcc.h to tinycc.h.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
70 #define offsetof(type, field) ((size_t) &((type *)0)->field) |
8c020de0af57
Fix earlier options.c break-up by migrating some stuff from tcc.h to tinycc.h.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
71 #endif |
8c020de0af57
Fix earlier options.c break-up by migrating some stuff from tcc.h to tinycc.h.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
72 |
8c020de0af57
Fix earlier options.c break-up by migrating some stuff from tcc.h to tinycc.h.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
73 #ifndef countof |
8c020de0af57
Fix earlier options.c break-up by migrating some stuff from tcc.h to tinycc.h.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
74 #define countof(tab) (sizeof(tab) / sizeof((tab)[0])) |
8c020de0af57
Fix earlier options.c break-up by migrating some stuff from tcc.h to tinycc.h.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
75 #endif |
8c020de0af57
Fix earlier options.c break-up by migrating some stuff from tcc.h to tinycc.h.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
76 |
8c020de0af57
Fix earlier options.c break-up by migrating some stuff from tcc.h to tinycc.h.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
77 // This token begins a word/line/file |
8c020de0af57
Fix earlier options.c break-up by migrating some stuff from tcc.h to tinycc.h.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
78 #define TOK_FLAG_BOW 0x0001 |
8c020de0af57
Fix earlier options.c break-up by migrating some stuff from tcc.h to tinycc.h.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
79 #define TOK_FLAG_BOL 0x0002 |
8c020de0af57
Fix earlier options.c break-up by migrating some stuff from tcc.h to tinycc.h.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
80 #define TOK_FLAG_BOF 0x0004 |
8c020de0af57
Fix earlier options.c break-up by migrating some stuff from tcc.h to tinycc.h.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
81 |
8c020de0af57
Fix earlier options.c break-up by migrating some stuff from tcc.h to tinycc.h.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
82 // Add file flags (passed to tcc_add_file_internal()) |
8c020de0af57
Fix earlier options.c break-up by migrating some stuff from tcc.h to tinycc.h.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
83 #define AFF_PRINT_ERROR 0x0001 // print error if file not found |
8c020de0af57
Fix earlier options.c break-up by migrating some stuff from tcc.h to tinycc.h.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
84 #define AFF_PREPROCESS 0x0004 // preprocess file |
8c020de0af57
Fix earlier options.c break-up by migrating some stuff from tcc.h to tinycc.h.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
85 |
8c020de0af57
Fix earlier options.c break-up by migrating some stuff from tcc.h to tinycc.h.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
86 // First identifier token |
8c020de0af57
Fix earlier options.c break-up by migrating some stuff from tcc.h to tinycc.h.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
87 #define TOK_IDENT 256 // First identifier/string token. |
8c020de0af57
Fix earlier options.c break-up by migrating some stuff from tcc.h to tinycc.h.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
88 |
8c020de0af57
Fix earlier options.c break-up by migrating some stuff from tcc.h to tinycc.h.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
89 // This should come from dlfcn.h but doesn't unless you claim to be written |
8c020de0af57
Fix earlier options.c break-up by migrating some stuff from tcc.h to tinycc.h.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
90 // by the fsf, which we aren't. |
8c020de0af57
Fix earlier options.c break-up by migrating some stuff from tcc.h to tinycc.h.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
91 #define RTLD_DEFAULT 0 |
8c020de0af57
Fix earlier options.c break-up by migrating some stuff from tcc.h to tinycc.h.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
92 |
8c020de0af57
Fix earlier options.c break-up by migrating some stuff from tcc.h to tinycc.h.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
93 int is_space(int ch); |