tcc-stupidos/libtcc/include/tcc/state.h
2025-02-14 17:47:45 +01:00

176 lines
No EOL
4.9 KiB
C

#ifndef TCC_STATE_H
# define TCC_STATE_H 1
# include <setjmp.h>
# include <stdint.h>
# include <stdio.h>
# include <tcc/io.h>
# include <tcc/utils/cstring.h>
# define TCC_WARN_ON 1 /** warning is on (-Woption) */
# define TCC_INCLUDE_STACK_SIZE 32
# define TCC_IFDEF_STACK_SIZE 64
# define TCC_CACHED_INCLUDES_HASH_SIZE 32
# define TCC_PACK_STACK_SIZE 8
typedef struct TCCState2 TCCState2;
typedef struct COFFSym COFFSym;
typedef struct CachedInclude CachedInclude;
typedef struct InlineFunc InlineFunc;
typedef struct TCCStrtab {
size_t len;
char *tab;
} TCCStrtab;
typedef struct TCCSymtab {
size_t nsym;
COFFSym *syms;
TCCStrtab strtab;
} TCCSymtab;
typedef struct TCCSection {
uint32_t data_offset;
uint8_t *data;
uint32_t data_allocated;
TCCState2 *state;
char name[8]; /** section name */
int32_t flags;
int16_t secnum;
int16_t addralign;
size_t offset;
} TCCSection;
struct TCCState2 {
uint8_t verbose; /** if 1, display some information during compilation */
uint8_t nostdinc; /** if 1, no standard headers are added */
uint8_t nostdlib; /** if 1, no standard libraries are added */
uint8_t symbolic; /** if 1, resolve symbols in the current module first */
uint8_t filetype; /** file type for compilation (NONE, C, ASM) */
uint8_t optimize; /** only to #define __OPTIMIZE__ */
uint8_t option_pthread; /** -pthread option */
uint32_t cversion; /** suppported C ISO version, 199901 (default), 201112, ... */
/* C language options */
uint8_t char_is_unsigned;
uint8_t leading_underscore;
uint8_t ms_extensions; /** allow nested named struct w/o identifier behave lile unnamed */
uint8_t dollars_in_identifiers; /** allows '$' char in identifiers */
uint8_t ms_bitfields; /** if 1, emulate MS algorithm for aligning bitfields */
uint8_t reverse_funcargs; /** if 1, evaluate last function arg first */
uint8_t gnu89_inline; /** treat 'extern inline' like 'static inline' */
/* warning switches */
uint8_t warn_none;
uint8_t warn_all;
uint8_t warn_error;
uint8_t warn_write_strings;
uint8_t warn_unsupported;
uint8_t warn_implicit_function_declaration;
uint8_t warn_discarded_qualifiers;
uint8_t warn_num; /** temp var for tcc_warning_c() */
uint8_t option_r; /** option -r */
uint8_t do_bench; /** option -bench */
uint8_t just_deps; /** option -M */
uint8_t gen_deps; /** option -MD */
uint8_t include_sys_deps; /** option -MD */
uint8_t gen_phony_deps; /** option -MP */
uint8_t gnu_ext; /** use GNU C extensions */
uint8_t tcc_ext; /** use TinyCC extensions */
uint8_t dflags; /** -dX value */
uint8_t Pflag; /** -P switch (LINE_MACRO_OUTPUT_FORMAT) */
uint8_t has_text_addr;
uint32_t text_addr; /** address of text section */
unsigned section_align; /** section alignment */
char *tcc_lib_path; /** CONFIG_TCCDIR or -B option */
char *entryname; /** "_start" unless set */
int output_type; /** output type, see TCC_OUTPUT_xxx */
int output_format; /** output format, see TCC_OUTPUT_FORMAT_xxx */
/* include paths */
char **include_paths;
int nb_include_paths;
char **sysinclude_paths;
int nb_sysinclude_paths;
/* library paths */
char **library_paths;
int nb_library_paths;
/* crt?.o object path */
char **crt_paths;
int nb_crt_paths;
CString cmdline_defs; /** -D / -U options */
CString cmdline_incl; /** -include options */
/** error handling */
void *error_opaque;
void (*error_func)(void *opaque, const char *msg);
int error_set_jmp_enabled;
jmp_buf error_jmp_buf;
int nb_errors;
FILE *ppfp; /** output file for preprocessing (-E) */
char **target_deps; /** for -MD/-MF: collected dependencies for this compilation */
int nb_target_deps;
/* compilation */
BufferedFile *include_stack[TCC_INCLUDE_STACK_SIZE];
BufferedFile **include_stack_ptr;
int ifdef_stack[TCC_IFDEF_STACK_SIZE];
int *ifdef_stack_ptr;
/* included files enclosed with #ifndef MACRO */
int cached_includes_hash[TCC_CACHED_INCLUDES_HASH_SIZE];
CachedInclude **cached_includes;
int nb_cached_includes;
/* #pragma pack stack */
int pack_stack[TCC_PACK_STACK_SIZE];
int *pack_stack_ptr;
char **pragma_libs;
int nb_pragma_libs;
/* inline functions are stored as token lists and compiled last only if referenced */
InlineFunc **inline_fns;
int nb_inline_fns;
/* sections */
TCCSection **sections;
int nb_sections; /* number of sections, including first dummy section */
/* predefined sections */
TCCSection *text_section;
TCCSection *data_section;
TCCSection *rodata_section;
TCCSection *bss_section;
TCCSection *cur_text_section; /** current section where function code is generated */
/* symbol data */
TCCSymtab *symtab;
/* benchmark info */
int total_idents;
int total_lines;
uint32_t total_bytes;
uint32_t total_output[4];
/* for warnings/errors for object files */
const char *current_filename;
};
#endif /* !TCC_STATE_H */