History

tcc/lib: reduce number of files

271 insertions(+), 292 deletions(-), -21 lines, -5 files Also: - tccdefs.h: WIN32: less (no) __builtins - libtcc.c: simply ignore -arch

grischka committed 5 years ago

Commit 675046b1 parent e53816016 files · +271 −292Browse files

Showing the changes to libtcc.c (1 of 16 files). Show all

Unified · Split

libtcc.c+27−55
@@ -83,8 +83,17 @@ ST_FUNC char *normalize_slashes(char *path) · 82 unmodified lines
8383 return path;
8484 }
8585
86−/* NULL if this is tcc.exe, HINSTANCE if this is libtcc.dll */
86+#if defined LIBTCC_AS_DLL && !defined CONFIG_TCCDIR
8787 static HMODULE tcc_module;
88+BOOL WINAPI DllMain (HINSTANCE hDll, DWORD dwReason, LPVOID lpReserved)
89+{
90+ if (DLL_PROCESS_ATTACH == dwReason)
91+ tcc_module = hDll;
92+ return TRUE;
93+}
94+#else
95+#define tcc_module NULL /* NULL means executable itself */
96+#endif
8897
8998 #ifndef CONFIG_TCCDIR
9099 /* on win32, we suppose the lib and includes are at the location of 'tcc.exe' */
@@ -109,15 +118,6 @@ static void tcc_add_systemdir(TCCState *s) · 18 unmodified lines
109118 tcc_add_library_path(s, normalize_slashes(buf));
110119 }
111120 #endif
112−
113−#ifdef LIBTCC_AS_DLL
114−BOOL WINAPI DllMain (HINSTANCE hDll, DWORD dwReason, LPVOID lpReserved)
115−{
116− if (DLL_PROCESS_ATTACH == dwReason)
117− tcc_module = hDll;
118− return TRUE;
119−}
120−#endif
121121 #endif
122122
123123 /********************************************************/
@@ -234,6 +234,14 @@ PUB_FUNC char *tcc_fileextension (const char *name) · 110 unmodified lines
234234 return e ? e : strchr(b, 0);
235235 }
236236
237+ST_FUNC char *tcc_load_text(int fd)
238+{
239+ int len = lseek(fd, 0, SEEK_END);
240+ char *buf = load_data(fd, 0, len + 1);
241+ buf[len] = 0;
242+ return buf;
243+}
244+
237245 /********************************************************/
238246 /* memory management */
239247
@@ -1431,6 +1439,7 @@ typedef struct TCCOption { · 1191 unmodified lines
14311439 } TCCOption;
14321440
14331441 enum {
1442+ TCC_OPTION_ignored = 0,
14341443 TCC_OPTION_HELP,
14351444 TCC_OPTION_HELP2,
14361445 TCC_OPTION_v,
@@ -1455,8 +1464,6 @@ enum { · 18 unmodified lines
14551464 TCC_OPTION_soname,
14561465 TCC_OPTION_o,
14571466 TCC_OPTION_r,
1458− TCC_OPTION_s,
1459− TCC_OPTION_traditional,
14601467 TCC_OPTION_Wl,
14611468 TCC_OPTION_Wp,
14621469 TCC_OPTION_W,
@@ -1471,12 +1478,9 @@ enum { · 8 unmodified lines
14711478 TCC_OPTION_nostdlib,
14721479 TCC_OPTION_print_search_dirs,
14731480 TCC_OPTION_rdynamic,
1474− TCC_OPTION_param,
1475− TCC_OPTION_pedantic,
14761481 TCC_OPTION_pthread,
14771482 TCC_OPTION_run,
14781483 TCC_OPTION_w,
1479− TCC_OPTION_pipe,
14801484 TCC_OPTION_E,
14811485 TCC_OPTION_M,
14821486 TCC_OPTION_MD,
@@ -1486,8 +1490,6 @@ enum { · 3 unmodified lines
14861490 TCC_OPTION_x,
14871491 TCC_OPTION_ar,
14881492 TCC_OPTION_impdef,
1489− TCC_OPTION_C,
1490− TCC_OPTION_arch
14911493 };
14921494
14931495 #define TCC_OPTION_HAS_ARG 0x0001
@@ -1523,14 +1525,10 @@ static const TCCOption tcc_options[] = { · 29 unmodified lines
15231525 { "shared", TCC_OPTION_shared, 0 },
15241526 { "soname", TCC_OPTION_soname, TCC_OPTION_HAS_ARG },
15251527 { "o", TCC_OPTION_o, TCC_OPTION_HAS_ARG },
1526− { "-param", TCC_OPTION_param, TCC_OPTION_HAS_ARG },
1527− { "pedantic", TCC_OPTION_pedantic, 0},
15281528 { "pthread", TCC_OPTION_pthread, 0},
15291529 { "run", TCC_OPTION_run, TCC_OPTION_HAS_ARG | TCC_OPTION_NOSEP },
15301530 { "rdynamic", TCC_OPTION_rdynamic, 0 },
15311531 { "r", TCC_OPTION_r, 0 },
1532− { "s", TCC_OPTION_s, 0 },
1533− { "traditional", TCC_OPTION_traditional, 0 },
15341532 { "Wl,", TCC_OPTION_Wl, TCC_OPTION_HAS_ARG | TCC_OPTION_NOSEP },
15351533 { "Wp,", TCC_OPTION_Wp, TCC_OPTION_HAS_ARG | TCC_OPTION_NOSEP },
15361534 { "W", TCC_OPTION_W, TCC_OPTION_HAS_ARG | TCC_OPTION_NOSEP },
@@ -1546,7 +1544,6 @@ static const TCCOption tcc_options[] = { · 9 unmodified lines
15461544 { "nostdlib", TCC_OPTION_nostdlib, 0 },
15471545 { "print-search-dirs", TCC_OPTION_print_search_dirs, 0 },
15481546 { "w", TCC_OPTION_w, 0 },
1549− { "pipe", TCC_OPTION_pipe, 0},
15501547 { "E", TCC_OPTION_E, 0},
15511548 { "M", TCC_OPTION_M, 0},
15521549 { "MD", TCC_OPTION_MD, 0},
@@ -1558,10 +1555,14 @@ static const TCCOption tcc_options[] = { · 5 unmodified lines
15581555 #ifdef TCC_TARGET_PE
15591556 { "impdef", TCC_OPTION_impdef, 0},
15601557 #endif
1561−#ifdef TCC_TARGET_MACHO
1562− { "arch", TCC_OPTION_arch, TCC_OPTION_HAS_ARG },
1563−#endif
1564− { "C", TCC_OPTION_C, 0},
1558+ /* ignored (silently, except after -Wunsupported) */
1559+ { "arch", 0, TCC_OPTION_HAS_ARG},
1560+ { "C", 0, 0 },
1561+ { "-param", 0, TCC_OPTION_HAS_ARG },
1562+ { "pedantic", 0, 0 },
1563+ { "pipe", 0, 0 },
1564+ { "s", 0, 0 },
1565+ { "traditional", 0, 0 },
15651566 { NULL, 0, 0 },
15661567 };
15671568
@@ -1677,14 +1678,6 @@ static int args_parser_make_argv(const char *r, int *argc, char ***argv) · 109 unmodified lines
16771678 return ret;
16781679 }
16791680
1680−ST_FUNC char *tcc_load_text(int fd)
1681−{
1682− int len = lseek(fd, 0, SEEK_END);
1683− char *buf = load_data(fd, 0, len + 1);
1684− buf[len] = 0;
1685− return buf;
1686−}
1687−
16881681 /* read list file */
16891682 static void args_parser_listfile(TCCState *s,
16901683 const char *filename, int optind, int *pargc, char ***pargv)
@@ -1991,27 +1984,6 @@ reparse: · 300 unmodified lines
19911984 tcc_error("cannot parse %s here", r);
19921985 tool = x;
19931986 break;
1994−#if defined(TCC_TARGET_MACHO)
1995− case TCC_OPTION_arch:
1996−#if defined(TCC_TARGET_X86_64)
1997− if (strcmp(optarg, "x86_64") == 0)
1998− break; /* Ok, arch matches target */
1999−#endif
2000−#if defined(TCC_TARGET_ARM64)
2001− if (strcmp(optarg, "arm64") == 0)
2002− break; /* Ok, arch matches target */
2003−#endif
2004− tcc_error("this compiler does not support %s", optarg);
2005− /* ignored */
2006− break;
2007−#endif
2008− case TCC_OPTION_traditional:
2009− case TCC_OPTION_pedantic:
2010− case TCC_OPTION_pipe:
2011− case TCC_OPTION_s:
2012− case TCC_OPTION_C:
2013− /* ignored */
2014− break;
20151987 default:
20161988 unsupported_option:
20171989 tcc_warning_c(warn_unsupported)("unsupported option '%s'", r);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t