From da8c62f75d893449e232944fc62566c020b4d010 Mon Sep 17 00:00:00 2001 From: grischka Date: Wed, 11 Oct 2017 18:13:43 +0200 Subject: various stuff win32/Makefile ("for cygwin") removed - On cygwin, the normal ./configure && make can be used with either cygwin's "GCC for Win32 Toolchain" ./configure --cross-prefix=i686-w64-mingw32- or with an existing tcc: ./configure --cc=/tcc.exe tcctest.c: - exclude test_high_clobbers() on _WIN64 (does not work) tests2/95_bitfield.c: - use 'signed char' for ARM (where default 'char' is unsigned) tests: - remove -I "expr" diff option to allow tests with busybox-diff. libtcc.c, tcc.c: - removed -iwithprefix option. It is supposed to be combined with -iprefix which we don't have either. tccgen.c: - fix assignments and return of 'void', as in void f() { void *p, *q; *p = *q: return *p; } This appears to be allowed but should do nothing. tcc.h, libtcc.c, tccpp.c: - Revert "Introduce VIP sysinclude paths which are always searched first" This reverts commit 1d5e386b0a78393ac6b670c209a185849ec798a1. The patch was giving tcc's system includes priority over -I which is not how it should be. tccelf.c: - add DT_TEXTREL tag only if text relocations are actually used (which is likely not the case on x86_64) - prepare_dynamic_rel(): avoid relocation of unresolved (weak) symbols tccrun.c: - for HAVE_SELINUX, use two mappings to the same (real) file. (it was so once except the RX mapping wasn't used at all). tccpe.c: - fix relocation constant used for x86_64 (by Andrei E. Warentin) - #ifndef _WIN32 do "chmod 755 ..." to get runnable exes on cygwin. tccasm.c: - keep forward asm labels static, otherwise they will endup in dynsym eventually. configure, Makefile: - mingw32: respect ./configure options --bindir --docdir --libdir - allow overriding tcc when building libtcc1.a and libtcc.def with make XTCC= - use $(wildcard ...) for install to allow installing just a cross compiler for example make cross-arm make install - use name -libtcc1.a build-tcc.bat: - add options: -clean, -b bindir --- win32/lib/crt1.c | 21 +++++---------- win32/lib/wincrt1.c | 76 ++++++++++++++++++++--------------------------------- 2 files changed, 35 insertions(+), 62 deletions(-) (limited to 'win32/lib') diff --git a/win32/lib/crt1.c b/win32/lib/crt1.c index 53e5545..0e04fc0 100644 --- a/win32/lib/crt1.c +++ b/win32/lib/crt1.c @@ -16,11 +16,6 @@ #define _PC_53 0x00010000 // 53 bits #define _PC_64 0x00000000 // 64 bits -typedef struct -{ - int newmode; -} _startupinfo; - #ifdef _UNICODE #define __tgetmainargs __wgetmainargs #define _tstart _wstart @@ -33,6 +28,7 @@ typedef struct #define _runtmain _runmain #endif +typedef struct { int newmode; } _startupinfo; int __cdecl __tgetmainargs(int *pargc, _TCHAR ***pargv, _TCHAR ***penv, int globb, _startupinfo*); void __cdecl __set_app_type(int apptype); unsigned int __cdecl _controlfp(unsigned int new_value, unsigned int mask); @@ -44,23 +40,19 @@ int _dowildcard; void _tstart(void) { __TRY__ - int ret; - _startupinfo start_info; + _startupinfo start_info = {0}; // Sets the current application type __set_app_type(_CONSOLE_APP); // Set default FP precision to 53 bits (8-byte double) - // _MCW_PC (Precision control) is not supported on - // the ARM and x64 architectures -#ifdef __i386 + // _MCW_PC (Precision control) is not supported on ARM +#if defined __i386__ || defined __x86_64__ _controlfp(_PC_53, _MCW_PC); #endif - start_info.newmode = 0; __tgetmainargs( &__argc, &__targv, &_tenviron, _dowildcard, &start_info); - ret = _tmain(__argc, __targv, _tenviron); - exit(ret); + exit(_tmain(__argc, __targv, _tenviron)); } int _runtmain(int argc, /* as tcc passed in */ char **argv) @@ -78,8 +70,7 @@ int _runtmain(int argc, /* as tcc passed in */ char **argv) __argc = argc; __targv = argv; #endif - -#ifdef __i386 +#if defined __i386__ || defined __x86_64__ _controlfp(_PC_53, _MCW_PC); #endif return _tmain(__argc, __targv, _tenviron); diff --git a/win32/lib/wincrt1.c b/win32/lib/wincrt1.c index 83e2f74..ce3a63f 100644 --- a/win32/lib/wincrt1.c +++ b/win32/lib/wincrt1.c @@ -23,71 +23,53 @@ int APIENTRY wWinMain(HINSTANCE, HINSTANCE, LPWSTR, int); #define _runtwinmain _runwinmain #endif -typedef struct -{ - int newmode; -} _startupinfo; // CLI Vs GUI - +typedef struct { int newmode; } _startupinfo; int __cdecl __tgetmainargs(int *pargc, _TCHAR ***pargv, _TCHAR ***penv, int globb, _startupinfo*); -int _twinstart(void) +static int go_winmain(TCHAR *arg1) { - __TRY__ + STARTUPINFO si; _TCHAR *szCmd, *p; - STARTUPINFO startinfo; - _startupinfo start_info_con = {0}; int fShow; - int ret; - - __set_app_type(__GUI_APP); - _controlfp(0x10000, 0x30000); - start_info_con.newmode = 0; - __tgetmainargs(&__argc, &__targv, &_tenviron, 0, &start_info_con); + GetStartupInfo(&si); + if (si.dwFlags & STARTF_USESHOWWINDOW) + fShow = si.wShowWindow; + else + fShow = SW_SHOWDEFAULT; - p = GetCommandLine(); - if (__argc > 1) - szCmd = _tcsstr(p, __targv[1]); + szCmd = NULL, p = GetCommandLine(); + if (arg1) + szCmd = _tcsstr(p, arg1); if (NULL == szCmd) - szCmd = __T(""); - else if (szCmd > p && szCmd[-1] == __T('\"')) + szCmd = _tcsdup(__T("")); + else if (szCmd > p && szCmd[-1] == __T('"')) --szCmd; +#if defined __i386__ || defined __x86_64__ + _controlfp(0x10000, 0x30000); +#endif + return _tWinMain(GetModuleHandle(NULL), NULL, szCmd, fShow); +} - GetStartupInfo(&startinfo); - fShow = startinfo.wShowWindow; - if (0 == (startinfo.dwFlags & STARTF_USESHOWWINDOW)) - fShow = SW_SHOWDEFAULT; - - ret = _tWinMain(GetModuleHandle(NULL), NULL, szCmd, fShow); - exit(ret); +int _twinstart(void) +{ + __TRY__ + _startupinfo start_info_con = {0}; + __set_app_type(__GUI_APP); + __tgetmainargs(&__argc, &__targv, &_tenviron, 0, &start_info_con); + exit(go_winmain(__argc > 1 ? __targv[1] : NULL)); } int _runtwinmain(int argc, /* as tcc passed in */ char **argv) { - _TCHAR *szCmd, *p; - #ifdef UNICODE _startupinfo start_info = {0}; - __tgetmainargs(&__argc, &__targv, &_tenviron, 0, &start_info); /* may be wrong when tcc has received wildcards (*.c) */ - if (argc < __argc) { - __targv += __argc - argc; - __argc = argc; - } + if (argc < __argc) + __targv += __argc - argc, __argc = argc; #else - __argc = argc; - __targv = argv; + __argc = argc, __targv = argv; #endif - - p = GetCommandLine(); - szCmd = NULL; - if (argc > 1) - szCmd = _tcsstr(p, __targv[1]); - if (NULL == szCmd) - szCmd = __T(""); - else if (szCmd > p && szCmd[-1] == __T('\"')) - --szCmd; - _controlfp(0x10000, 0x30000); - return _tWinMain(GetModuleHandle(NULL), NULL, szCmd, SW_SHOWDEFAULT); + return go_winmain(__argc > 1 ? __targv[1] : NULL); } -- cgit v1.3.1