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
83 return path;83 return path;
84}84}
85 85
86/* NULL if this is tcc.exe, HINSTANCE if this is libtcc.dll */86#if defined LIBTCC_AS_DLL && !defined CONFIG_TCCDIR
87static HMODULE tcc_module;87static HMODULE tcc_module;
88BOOL 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
88 97
89#ifndef CONFIG_TCCDIR98#ifndef CONFIG_TCCDIR
90/* on win32, we suppose the lib and includes are at the location of 'tcc.exe' */99/* 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
109 tcc_add_library_path(s, normalize_slashes(buf));118 tcc_add_library_path(s, normalize_slashes(buf));
110}119}
111#endif120#endif
112
113#ifdef LIBTCC_AS_DLL
114BOOL 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
121#endif121#endif
122 122
123/********************************************************/123/********************************************************/
@@ -234,6 +234,14 @@ PUB_FUNC char *tcc_fileextension (const char *name) · 110 unmodified lines
234 return e ? e : strchr(b, 0);234 return e ? e : strchr(b, 0);
235}235}
236 236
237ST_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
237/********************************************************/245/********************************************************/
238/* memory management */246/* memory management */
239 247
@@ -1431,6 +1439,7 @@ typedef struct TCCOption { · 1191 unmodified lines
1431} TCCOption;1439} TCCOption;
1432 1440
1433enum {1441enum {
1442 TCC_OPTION_ignored = 0,
1434 TCC_OPTION_HELP,1443 TCC_OPTION_HELP,
1435 TCC_OPTION_HELP2,1444 TCC_OPTION_HELP2,
1436 TCC_OPTION_v,1445 TCC_OPTION_v,
@@ -1455,8 +1464,6 @@ enum { · 18 unmodified lines
1455 TCC_OPTION_soname,1464 TCC_OPTION_soname,
1456 TCC_OPTION_o,1465 TCC_OPTION_o,
1457 TCC_OPTION_r,1466 TCC_OPTION_r,
1458 TCC_OPTION_s,
1459 TCC_OPTION_traditional,
1460 TCC_OPTION_Wl,1467 TCC_OPTION_Wl,
1461 TCC_OPTION_Wp,1468 TCC_OPTION_Wp,
1462 TCC_OPTION_W,1469 TCC_OPTION_W,
@@ -1471,12 +1478,9 @@ enum { · 8 unmodified lines
1471 TCC_OPTION_nostdlib,1478 TCC_OPTION_nostdlib,
1472 TCC_OPTION_print_search_dirs,1479 TCC_OPTION_print_search_dirs,
1473 TCC_OPTION_rdynamic,1480 TCC_OPTION_rdynamic,
1474 TCC_OPTION_param,
1475 TCC_OPTION_pedantic,
1476 TCC_OPTION_pthread,1481 TCC_OPTION_pthread,
1477 TCC_OPTION_run,1482 TCC_OPTION_run,
1478 TCC_OPTION_w,1483 TCC_OPTION_w,
1479 TCC_OPTION_pipe,
1480 TCC_OPTION_E,1484 TCC_OPTION_E,
1481 TCC_OPTION_M,1485 TCC_OPTION_M,
1482 TCC_OPTION_MD,1486 TCC_OPTION_MD,
@@ -1486,8 +1490,6 @@ enum { · 3 unmodified lines
1486 TCC_OPTION_x,1490 TCC_OPTION_x,
1487 TCC_OPTION_ar,1491 TCC_OPTION_ar,
1488 TCC_OPTION_impdef,1492 TCC_OPTION_impdef,
1489 TCC_OPTION_C,
1490 TCC_OPTION_arch
1491};1493};
1492 1494
1493#define TCC_OPTION_HAS_ARG 0x00011495#define TCC_OPTION_HAS_ARG 0x0001
@@ -1523,14 +1525,10 @@ static const TCCOption tcc_options[] = { · 29 unmodified lines
1523 { "shared", TCC_OPTION_shared, 0 },1525 { "shared", TCC_OPTION_shared, 0 },
1524 { "soname", TCC_OPTION_soname, TCC_OPTION_HAS_ARG },1526 { "soname", TCC_OPTION_soname, TCC_OPTION_HAS_ARG },
1525 { "o", TCC_OPTION_o, TCC_OPTION_HAS_ARG },1527 { "o", TCC_OPTION_o, TCC_OPTION_HAS_ARG },
1526 { "-param", TCC_OPTION_param, TCC_OPTION_HAS_ARG },
1527 { "pedantic", TCC_OPTION_pedantic, 0},
1528 { "pthread", TCC_OPTION_pthread, 0},1528 { "pthread", TCC_OPTION_pthread, 0},
1529 { "run", TCC_OPTION_run, TCC_OPTION_HAS_ARG | TCC_OPTION_NOSEP },1529 { "run", TCC_OPTION_run, TCC_OPTION_HAS_ARG | TCC_OPTION_NOSEP },
1530 { "rdynamic", TCC_OPTION_rdynamic, 0 },1530 { "rdynamic", TCC_OPTION_rdynamic, 0 },
1531 { "r", TCC_OPTION_r, 0 },1531 { "r", TCC_OPTION_r, 0 },
1532 { "s", TCC_OPTION_s, 0 },
1533 { "traditional", TCC_OPTION_traditional, 0 },
1534 { "Wl,", TCC_OPTION_Wl, TCC_OPTION_HAS_ARG | TCC_OPTION_NOSEP },1532 { "Wl,", TCC_OPTION_Wl, TCC_OPTION_HAS_ARG | TCC_OPTION_NOSEP },
1535 { "Wp,", TCC_OPTION_Wp, TCC_OPTION_HAS_ARG | TCC_OPTION_NOSEP },1533 { "Wp,", TCC_OPTION_Wp, TCC_OPTION_HAS_ARG | TCC_OPTION_NOSEP },
1536 { "W", TCC_OPTION_W, TCC_OPTION_HAS_ARG | TCC_OPTION_NOSEP },1534 { "W", TCC_OPTION_W, TCC_OPTION_HAS_ARG | TCC_OPTION_NOSEP },
@@ -1546,7 +1544,6 @@ static const TCCOption tcc_options[] = { · 9 unmodified lines
1546 { "nostdlib", TCC_OPTION_nostdlib, 0 },1544 { "nostdlib", TCC_OPTION_nostdlib, 0 },
1547 { "print-search-dirs", TCC_OPTION_print_search_dirs, 0 },1545 { "print-search-dirs", TCC_OPTION_print_search_dirs, 0 },
1548 { "w", TCC_OPTION_w, 0 },1546 { "w", TCC_OPTION_w, 0 },
1549 { "pipe", TCC_OPTION_pipe, 0},
1550 { "E", TCC_OPTION_E, 0},1547 { "E", TCC_OPTION_E, 0},
1551 { "M", TCC_OPTION_M, 0},1548 { "M", TCC_OPTION_M, 0},
1552 { "MD", TCC_OPTION_MD, 0},1549 { "MD", TCC_OPTION_MD, 0},
@@ -1558,10 +1555,14 @@ static const TCCOption tcc_options[] = { · 5 unmodified lines
1558#ifdef TCC_TARGET_PE1555#ifdef TCC_TARGET_PE
1559 { "impdef", TCC_OPTION_impdef, 0},1556 { "impdef", TCC_OPTION_impdef, 0},
1560#endif1557#endif
1561#ifdef TCC_TARGET_MACHO1558 /* ignored (silently, except after -Wunsupported) */
1562 { "arch", TCC_OPTION_arch, TCC_OPTION_HAS_ARG },1559 { "arch", 0, TCC_OPTION_HAS_ARG},
1563#endif1560 { "C", 0, 0 },
1564 { "C", TCC_OPTION_C, 0},1561 { "-param", 0, TCC_OPTION_HAS_ARG },
1562 { "pedantic", 0, 0 },
1563 { "pipe", 0, 0 },
1564 { "s", 0, 0 },
1565 { "traditional", 0, 0 },
1565 { NULL, 0, 0 },1566 { NULL, 0, 0 },
1566};1567};
1567 1568
@@ -1677,14 +1678,6 @@ static int args_parser_make_argv(const char *r, int *argc, char ***argv) · 109 unmodified lines
1677 return ret;1678 return ret;
1678}1679}
1679 1680
1680ST_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
1688/* read list file */1681/* read list file */
1689static void args_parser_listfile(TCCState *s,1682static void args_parser_listfile(TCCState *s,
1690 const char *filename, int optind, int *pargc, char ***pargv)1683 const char *filename, int optind, int *pargc, char ***pargv)
@@ -1991,27 +1984,6 @@ reparse: · 300 unmodified lines
1991 tcc_error("cannot parse %s here", r);1984 tcc_error("cannot parse %s here", r);
1992 tool = x;1985 tool = x;
1993 break;1986 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;
2015 default:1987 default:
2016unsupported_option:1988unsupported_option:
2017 tcc_warning_c(warn_unsupported)("unsupported option '%s'", r);1989 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