@xnetx/tinyc-native-x86_64-w64-mingw32 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,116 +1,125 @@
|
|
|
1
|
-
#ifndef LIBTCC_H
|
|
2
|
-
#define LIBTCC_H
|
|
3
|
-
|
|
4
|
-
#ifndef LIBTCCAPI
|
|
5
|
-
# define LIBTCCAPI
|
|
6
|
-
#endif
|
|
7
|
-
|
|
8
|
-
#ifdef __cplusplus
|
|
9
|
-
extern "C" {
|
|
10
|
-
#endif
|
|
11
|
-
|
|
12
|
-
/*****************************/
|
|
13
|
-
/* set custom allocator for all allocations (optional), NULL for default. */
|
|
14
|
-
typedef void *TCCReallocFunc(void *ptr, unsigned long size);
|
|
15
|
-
LIBTCCAPI void tcc_set_realloc(TCCReallocFunc *my_realloc);
|
|
16
|
-
|
|
17
|
-
/*****************************/
|
|
18
|
-
typedef struct TCCState TCCState;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
LIBTCCAPI
|
|
41
|
-
|
|
42
|
-
/*
|
|
43
|
-
LIBTCCAPI int
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
/*
|
|
49
|
-
LIBTCCAPI
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
/*
|
|
55
|
-
LIBTCCAPI
|
|
56
|
-
|
|
57
|
-
/*
|
|
58
|
-
LIBTCCAPI
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
/*
|
|
67
|
-
LIBTCCAPI int
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
/*
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
LIBTCCAPI
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
/*
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
1
|
+
#ifndef LIBTCC_H
|
|
2
|
+
#define LIBTCC_H
|
|
3
|
+
|
|
4
|
+
#ifndef LIBTCCAPI
|
|
5
|
+
# define LIBTCCAPI
|
|
6
|
+
#endif
|
|
7
|
+
|
|
8
|
+
#ifdef __cplusplus
|
|
9
|
+
extern "C" {
|
|
10
|
+
#endif
|
|
11
|
+
|
|
12
|
+
/*****************************/
|
|
13
|
+
/* set custom allocator for all allocations (optional), NULL for default. */
|
|
14
|
+
typedef void *TCCReallocFunc(void *ptr, unsigned long size);
|
|
15
|
+
LIBTCCAPI void tcc_set_realloc(TCCReallocFunc *my_realloc);
|
|
16
|
+
|
|
17
|
+
/*****************************/
|
|
18
|
+
typedef struct TCCState TCCState;
|
|
19
|
+
typedef struct TCCIO TCCIO;
|
|
20
|
+
|
|
21
|
+
/* create a new TCC compilation context */
|
|
22
|
+
LIBTCCAPI TCCState *tcc_new(void);
|
|
23
|
+
|
|
24
|
+
/* free a TCC compilation context */
|
|
25
|
+
LIBTCCAPI void tcc_delete(TCCState *s);
|
|
26
|
+
|
|
27
|
+
/* set CONFIG_TCCDIR at runtime */
|
|
28
|
+
LIBTCCAPI void tcc_set_lib_path(TCCState *s, const char *path);
|
|
29
|
+
|
|
30
|
+
/* set error/warning callback (optional) */
|
|
31
|
+
typedef void TCCErrorFunc(void *opaque, const char *msg);
|
|
32
|
+
LIBTCCAPI void tcc_set_error_func(TCCState *s, void *error_opaque, TCCErrorFunc *error_func);
|
|
33
|
+
|
|
34
|
+
/* tinyc: install a TCCIO (tinyc_io.h) on a state; NULL restores the
|
|
35
|
+
* stdio default. All of the state's compiler output - diagnostics
|
|
36
|
+
* without an error callback, -E output, run stdio - goes through it. */
|
|
37
|
+
LIBTCCAPI void tcc_set_io(TCCState *s, TCCIO *io);
|
|
38
|
+
/* tinyc: the state's IO, or the stdio singleton when none (or a NULL
|
|
39
|
+
* state) is given. Never returns NULL. */
|
|
40
|
+
LIBTCCAPI TCCIO *tcc_get_io(TCCState *s);
|
|
41
|
+
|
|
42
|
+
/* set options as from command line (multiple supported) */
|
|
43
|
+
LIBTCCAPI int tcc_set_options(TCCState *s, const char *str);
|
|
44
|
+
|
|
45
|
+
/*****************************/
|
|
46
|
+
/* preprocessor */
|
|
47
|
+
|
|
48
|
+
/* add include path */
|
|
49
|
+
LIBTCCAPI int tcc_add_include_path(TCCState *s, const char *pathname);
|
|
50
|
+
|
|
51
|
+
/* add in system include path */
|
|
52
|
+
LIBTCCAPI int tcc_add_sysinclude_path(TCCState *s, const char *pathname);
|
|
53
|
+
|
|
54
|
+
/* define preprocessor symbol 'sym'. value can be NULL, sym can be "sym=val" */
|
|
55
|
+
LIBTCCAPI void tcc_define_symbol(TCCState *s, const char *sym, const char *value);
|
|
56
|
+
|
|
57
|
+
/* undefine preprocess symbol 'sym' */
|
|
58
|
+
LIBTCCAPI void tcc_undefine_symbol(TCCState *s, const char *sym);
|
|
59
|
+
|
|
60
|
+
/*****************************/
|
|
61
|
+
/* compiling */
|
|
62
|
+
|
|
63
|
+
/* add a file (C file, dll, object, library, ld script). Return -1 if error. */
|
|
64
|
+
LIBTCCAPI int tcc_add_file(TCCState *s, const char *filename);
|
|
65
|
+
|
|
66
|
+
/* compile a string containing a C source. Return -1 if error. */
|
|
67
|
+
LIBTCCAPI int tcc_compile_string(TCCState *s, const char *buf);
|
|
68
|
+
|
|
69
|
+
/* Tip: to have more specific errors/warnings from tcc_compile_string(),
|
|
70
|
+
you can prefix the string with "#line <num> \"<filename>\"\n" */
|
|
71
|
+
|
|
72
|
+
/*****************************/
|
|
73
|
+
/* linking commands */
|
|
74
|
+
|
|
75
|
+
/* set output type. MUST BE CALLED before any compilation */
|
|
76
|
+
LIBTCCAPI int tcc_set_output_type(TCCState *s, int output_type);
|
|
77
|
+
#define TCC_OUTPUT_MEMORY 1 /* output will be run in memory */
|
|
78
|
+
#define TCC_OUTPUT_EXE 2 /* executable file */
|
|
79
|
+
#define TCC_OUTPUT_DLL 4 /* dynamic library */
|
|
80
|
+
#define TCC_OUTPUT_OBJ 3 /* object file */
|
|
81
|
+
#define TCC_OUTPUT_PREPROCESS 5 /* only preprocess */
|
|
82
|
+
|
|
83
|
+
/* equivalent to -Lpath option */
|
|
84
|
+
LIBTCCAPI int tcc_add_library_path(TCCState *s, const char *pathname);
|
|
85
|
+
|
|
86
|
+
/* the library name is the same as the argument of the '-l' option */
|
|
87
|
+
LIBTCCAPI int tcc_add_library(TCCState *s, const char *libraryname);
|
|
88
|
+
|
|
89
|
+
/* add a symbol to the compiled program */
|
|
90
|
+
LIBTCCAPI int tcc_add_symbol(TCCState *s, const char *name, const void *val);
|
|
91
|
+
|
|
92
|
+
/* output an executable, library or object file. DO NOT call
|
|
93
|
+
tcc_relocate() before. */
|
|
94
|
+
LIBTCCAPI int tcc_output_file(TCCState *s, const char *filename);
|
|
95
|
+
|
|
96
|
+
/* link and run main() function and return its value. DO NOT call
|
|
97
|
+
tcc_relocate() before. */
|
|
98
|
+
LIBTCCAPI int tcc_run(TCCState *s, int argc, char **argv);
|
|
99
|
+
|
|
100
|
+
/* do all relocations (needed before using tcc_get_symbol()) */
|
|
101
|
+
LIBTCCAPI int tcc_relocate(TCCState *s1);
|
|
102
|
+
|
|
103
|
+
/* return symbol value or NULL if not found */
|
|
104
|
+
LIBTCCAPI void *tcc_get_symbol(TCCState *s, const char *name);
|
|
105
|
+
|
|
106
|
+
/* list all (global) symbols and their values via 'symbol_cb()' */
|
|
107
|
+
LIBTCCAPI void tcc_list_symbols(TCCState *s, void *ctx,
|
|
108
|
+
void (*symbol_cb)(void *ctx, const char *name, const void *val));
|
|
109
|
+
|
|
110
|
+
/* experimental/advanced section (see libtcc_test_mt.c for an example) */
|
|
111
|
+
|
|
112
|
+
/* catch runtime exceptions (optionally limit backtraces at top_func),
|
|
113
|
+
when using tcc_set_options("-bt") and when not using tcc_run() */
|
|
114
|
+
LIBTCCAPI void *_tcc_setjmp(TCCState *s1, void *jmp_buf, void *top_func, void *longjmp);
|
|
115
|
+
#define tcc_setjmp(s1,jb,f) setjmp(_tcc_setjmp(s1, jb, f, longjmp))
|
|
116
|
+
|
|
117
|
+
/* custom error printer for runtime exceptions. Returning 0 stops backtrace */
|
|
118
|
+
typedef int TCCBtFunc(void *udata, void *pc, const char *file, int line, const char* func, const char *msg);
|
|
119
|
+
LIBTCCAPI void tcc_set_backtrace_func(TCCState *s1, void* userdata, TCCBtFunc*);
|
|
120
|
+
|
|
121
|
+
#ifdef __cplusplus
|
|
122
|
+
}
|
|
123
|
+
#endif
|
|
124
|
+
|
|
125
|
+
#endif
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
/* tinyc_io.h - IO abstraction for the TinyC dual-form kernel.
|
|
2
2
|
*
|
|
3
|
-
* All compiler-owned input/output goes through a TCCIO object
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
3
|
+
* All compiler-owned input/output goes through a TCCIO object owned
|
|
4
|
+
* by a TCCState: tcc_set_io (libtcc.h) installs one on a state, and
|
|
5
|
+
* every compiler output path of that state - diagnostics, help,
|
|
6
|
+
* version, -E output, the -run stdio redirect - goes through it.
|
|
7
|
+
* There is no process-wide current IO. A state with no IO installed,
|
|
8
|
+
* and a NULL TCCIO everywhere in this API, mean the stdio
|
|
9
|
+
* implementation: output goes directly to the process's real
|
|
10
|
+
* stdout/stderr and input comes from the real stdin.
|
|
7
11
|
*/
|
|
8
12
|
#ifndef TINYC_IO_H
|
|
9
13
|
#define TINYC_IO_H
|
|
@@ -63,40 +67,40 @@ void tcc_io_free(TCCIO *io);
|
|
|
63
67
|
const char *tcc_io_buffer_data(TCCIO *io, int channel, size_t *len);
|
|
64
68
|
void tcc_io_buffer_clear(TCCIO *io);
|
|
65
69
|
|
|
66
|
-
/* ----
|
|
67
|
-
|
|
68
|
-
/*
|
|
69
|
-
*
|
|
70
|
-
|
|
71
|
-
TCCIO *
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
void
|
|
77
|
-
void
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
void
|
|
81
|
-
|
|
82
|
-
/*
|
|
83
|
-
*
|
|
84
|
-
FILE *tinyc_io_open_out_stream(
|
|
70
|
+
/* ---- write helpers (used by the compiler's own output paths) ------- */
|
|
71
|
+
|
|
72
|
+
/* Each helper takes the IO to write to - a state's IO as returned by
|
|
73
|
+
* tcc_get_io (libtcc.h), or any TCCIO directly. A NULL IO, like a
|
|
74
|
+
* state with nothing installed, resolves to the stdio singleton. */
|
|
75
|
+
int tinyc_io_write_out(TCCIO *io, const char *buf, size_t len);
|
|
76
|
+
int tinyc_io_write_err(TCCIO *io, const char *buf, size_t len);
|
|
77
|
+
void tinyc_io_out_str(TCCIO *io, const char *s);
|
|
78
|
+
void tinyc_io_err_str(TCCIO *io, const char *s);
|
|
79
|
+
void tinyc_io_out_fmt(TCCIO *io, const char *fmt, ...);
|
|
80
|
+
void tinyc_io_err_fmt(TCCIO *io, const char *fmt, ...);
|
|
81
|
+
void tinyc_io_err_line(TCCIO *io, const char *s); /* writes s + "\n" to err */
|
|
82
|
+
/* Flush io; on Windows also delivers any of io's -E stream output
|
|
83
|
+
* still sitting in its temp file (see tinyc_io_open_out_stream). */
|
|
84
|
+
void tinyc_io_flush(TCCIO *io);
|
|
85
|
+
|
|
86
|
+
/* A FILE* whose writes forward to io's out channel, or NULL when io
|
|
87
|
+
* resolves to the stdio default (callers then keep using stdout). */
|
|
88
|
+
FILE *tinyc_io_open_out_stream(TCCIO *io);
|
|
85
89
|
|
|
86
90
|
/* ---- -run stdio redirection ----------------------------------------- */
|
|
87
91
|
|
|
88
|
-
/* Called by tcc_run around the run program's entry point
|
|
89
|
-
*
|
|
90
|
-
* redirected through it for the duration of
|
|
91
|
-
* bytes read_in returns (then EOF), and
|
|
92
|
-
* fd 1/2 is delivered to write_out/
|
|
93
|
-
* run ends. The host's fds are
|
|
94
|
-
*
|
|
95
|
-
* and the run program uses the process's real
|
|
96
|
-
* keep_stdin != 0 leaves fd 0 alone (tcc_run has already
|
|
97
|
-
* stdin from a file for the program). Nested calls are
|
|
98
|
-
* only the outermost pair redirects. */
|
|
99
|
-
void tinyc_run_redirect_begin(int keep_stdin);
|
|
92
|
+
/* Called by tcc_run around the run program's entry point, with the
|
|
93
|
+
* running state's IO. When that IO is a non-stdio TCCIO, the
|
|
94
|
+
* process's fd 0/1/2 are redirected through it for the duration of
|
|
95
|
+
* the run: fd 0 is fed the bytes read_in returns (then EOF), and
|
|
96
|
+
* what the program writes to fd 1/2 is delivered to write_out /
|
|
97
|
+
* write_err, per channel, when the run ends. The host's fds are
|
|
98
|
+
* restored by tinyc_run_redirect_end. With the stdio IO both
|
|
99
|
+
* functions are no-ops and the run program uses the process's real
|
|
100
|
+
* stdio. keep_stdin != 0 leaves fd 0 alone (tcc_run has already
|
|
101
|
+
* reopened stdin from a file for the program). Nested calls are
|
|
102
|
+
* counted: only the outermost pair redirects. */
|
|
103
|
+
void tinyc_run_redirect_begin(TCCIO *io, int keep_stdin);
|
|
100
104
|
void tinyc_run_redirect_end(void);
|
|
101
105
|
|
|
102
106
|
/* ---- run-path diagnostic markers ------------------------------------ */
|
|
@@ -113,8 +117,12 @@ void tinyc_diag_mark_ptr(const char *label, const void *p);
|
|
|
113
117
|
|
|
114
118
|
/* The compiler's real main, exported from the dual-form file. */
|
|
115
119
|
int tinyc_main(int argc, char **argv);
|
|
116
|
-
/* tinyc_main with
|
|
117
|
-
*
|
|
120
|
+
/* tinyc_main with io installed on every state main creates during
|
|
121
|
+
* the call (main builds a fresh state per pass). States created
|
|
122
|
+
* through the tcc_* API are unaffected. */
|
|
123
|
+
int tinyc_main_with_io(int argc, char **argv, TCCIO *io);
|
|
124
|
+
/* tinyc_main_with_io, plus a flush of io once main has returned:
|
|
125
|
+
* the form the packages' CLI capture calls bind. */
|
|
118
126
|
int tinyc_main_io(int argc, char **argv, TCCIO *io);
|
|
119
127
|
|
|
120
128
|
#ifdef __cplusplus
|