@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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xnetx/tinyc-native-x86_64-w64-mingw32",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "TinyC native binaries for host x86_64-w64-mingw32 (dual-form TCC builds and target sysroots).",
5
5
  "license": "LGPL-2.1-or-later",
6
6
  "os": [
@@ -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
- /* create a new TCC compilation context */
21
- LIBTCCAPI TCCState *tcc_new(void);
22
-
23
- /* free a TCC compilation context */
24
- LIBTCCAPI void tcc_delete(TCCState *s);
25
-
26
- /* set CONFIG_TCCDIR at runtime */
27
- LIBTCCAPI void tcc_set_lib_path(TCCState *s, const char *path);
28
-
29
- /* set error/warning callback (optional) */
30
- typedef void TCCErrorFunc(void *opaque, const char *msg);
31
- LIBTCCAPI void tcc_set_error_func(TCCState *s, void *error_opaque, TCCErrorFunc *error_func);
32
-
33
- /* set options as from command line (multiple supported) */
34
- LIBTCCAPI int tcc_set_options(TCCState *s, const char *str);
35
-
36
- /*****************************/
37
- /* preprocessor */
38
-
39
- /* add include path */
40
- LIBTCCAPI int tcc_add_include_path(TCCState *s, const char *pathname);
41
-
42
- /* add in system include path */
43
- LIBTCCAPI int tcc_add_sysinclude_path(TCCState *s, const char *pathname);
44
-
45
- /* define preprocessor symbol 'sym'. value can be NULL, sym can be "sym=val" */
46
- LIBTCCAPI void tcc_define_symbol(TCCState *s, const char *sym, const char *value);
47
-
48
- /* undefine preprocess symbol 'sym' */
49
- LIBTCCAPI void tcc_undefine_symbol(TCCState *s, const char *sym);
50
-
51
- /*****************************/
52
- /* compiling */
53
-
54
- /* add a file (C file, dll, object, library, ld script). Return -1 if error. */
55
- LIBTCCAPI int tcc_add_file(TCCState *s, const char *filename);
56
-
57
- /* compile a string containing a C source. Return -1 if error. */
58
- LIBTCCAPI int tcc_compile_string(TCCState *s, const char *buf);
59
-
60
- /* Tip: to have more specific errors/warnings from tcc_compile_string(),
61
- you can prefix the string with "#line <num> \"<filename>\"\n" */
62
-
63
- /*****************************/
64
- /* linking commands */
65
-
66
- /* set output type. MUST BE CALLED before any compilation */
67
- LIBTCCAPI int tcc_set_output_type(TCCState *s, int output_type);
68
- #define TCC_OUTPUT_MEMORY 1 /* output will be run in memory */
69
- #define TCC_OUTPUT_EXE 2 /* executable file */
70
- #define TCC_OUTPUT_DLL 4 /* dynamic library */
71
- #define TCC_OUTPUT_OBJ 3 /* object file */
72
- #define TCC_OUTPUT_PREPROCESS 5 /* only preprocess */
73
-
74
- /* equivalent to -Lpath option */
75
- LIBTCCAPI int tcc_add_library_path(TCCState *s, const char *pathname);
76
-
77
- /* the library name is the same as the argument of the '-l' option */
78
- LIBTCCAPI int tcc_add_library(TCCState *s, const char *libraryname);
79
-
80
- /* add a symbol to the compiled program */
81
- LIBTCCAPI int tcc_add_symbol(TCCState *s, const char *name, const void *val);
82
-
83
- /* output an executable, library or object file. DO NOT call
84
- tcc_relocate() before. */
85
- LIBTCCAPI int tcc_output_file(TCCState *s, const char *filename);
86
-
87
- /* link and run main() function and return its value. DO NOT call
88
- tcc_relocate() before. */
89
- LIBTCCAPI int tcc_run(TCCState *s, int argc, char **argv);
90
-
91
- /* do all relocations (needed before using tcc_get_symbol()) */
92
- LIBTCCAPI int tcc_relocate(TCCState *s1);
93
-
94
- /* return symbol value or NULL if not found */
95
- LIBTCCAPI void *tcc_get_symbol(TCCState *s, const char *name);
96
-
97
- /* list all (global) symbols and their values via 'symbol_cb()' */
98
- LIBTCCAPI void tcc_list_symbols(TCCState *s, void *ctx,
99
- void (*symbol_cb)(void *ctx, const char *name, const void *val));
100
-
101
- /* experimental/advanced section (see libtcc_test_mt.c for an example) */
102
-
103
- /* catch runtime exceptions (optionally limit backtraces at top_func),
104
- when using tcc_set_options("-bt") and when not using tcc_run() */
105
- LIBTCCAPI void *_tcc_setjmp(TCCState *s1, void *jmp_buf, void *top_func, void *longjmp);
106
- #define tcc_setjmp(s1,jb,f) setjmp(_tcc_setjmp(s1, jb, f, longjmp))
107
-
108
- /* custom error printer for runtime exceptions. Returning 0 stops backtrace */
109
- typedef int TCCBtFunc(void *udata, void *pc, const char *file, int line, const char* func, const char *msg);
110
- LIBTCCAPI void tcc_set_backtrace_func(TCCState *s1, void* userdata, TCCBtFunc*);
111
-
112
- #ifdef __cplusplus
113
- }
114
- #endif
115
-
116
- #endif
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
- * A NULL TCCIO everywhere in this API means the stdio implementation:
5
- * output goes directly to the process's real stdout/stderr and input
6
- * comes from the real stdin.
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
- /* ---- current IO (used by the compiler's own output paths) ---------- */
67
-
68
- /* Install io as the current IO for subsequent compiler output.
69
- * NULL restores the stdio default. */
70
- void tinyc_set_io(TCCIO *io);
71
- TCCIO *tinyc_get_io(void);
72
-
73
- /* Write helpers honoring the current IO (stdio when none is set). */
74
- int tinyc_io_write_out(const char *buf, size_t len);
75
- int tinyc_io_write_err(const char *buf, size_t len);
76
- void tinyc_io_out_str(const char *s);
77
- void tinyc_io_err_str(const char *s);
78
- void tinyc_io_out_fmt(const char *fmt, ...);
79
- void tinyc_io_err_line(const char *s); /* writes s + "\n" to err */
80
- void tinyc_io_flush_all(void);
81
-
82
- /* On Linux: a FILE* whose writes forward to the current IO's out
83
- * channel, or NULL when the current IO is the stdio default. */
84
- FILE *tinyc_io_open_out_stream(void);
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. When the
89
- * current IO is a non-stdio TCCIO, the process's fd 0/1/2 are
90
- * redirected through it for the duration of the run: fd 0 is fed the
91
- * bytes read_in returns (then EOF), and what the program writes to
92
- * fd 1/2 is delivered to write_out/write_err, per channel, when the
93
- * run ends. The host's fds are restored by tinyc_run_redirect_end.
94
- * With no IO installed, or the stdio IO, both functions are no-ops
95
- * and the run program uses the process's real stdio.
96
- * keep_stdin != 0 leaves fd 0 alone (tcc_run has already reopened
97
- * stdin from a file for the program). Nested calls are counted:
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 an IO installed for the duration of the call.
117
- * The previous IO is restored before returning. */
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