mirror of
https://github.com/mirror/tinycc.git
synced 2025-02-14 07:10:07 +08:00
- libtcc.c/tccpp.c: fix -U option for multiple input files - libtcc: remove decl of tcc_add_crt() for PE - tcc.h: define __i386__ and __x86_64__ for msvc - tcc.h: undef __attribute__ for __TINYC__ on gnu/linux platforms - tccelf.c: disable prepare_dynamic_rel unless x86/x64 - tccpe.c: construct rather than predefine PE section flags - tccpp.c: (alt.) fix access of dead stack variable after error/longjmp - x86_64-gen.c: fix func_alloca chain for nocode_wanted - tccpp.c/tccgen.c: improve file:line info for inline functions - winapi/winnt.h: correct position for DECLSPEC_ALIGN attribute - win32/lib/crt: simplify top exception handler (needed for signal) - arm64-gen.c: remove dprintf left from VT_CMP commit - tccgen.c: limit binary scan with gcase to > 8 (= smaller code) - tccgen.c: call save_regs(4) in gen_opl for cmp-ops (see test in tcctest.c)
81 lines
2.1 KiB
C
81 lines
2.1 KiB
C
//+---------------------------------------------------------------------------
|
|
|
|
// _UNICODE for tchar.h, UNICODE for API
|
|
#include <tchar.h>
|
|
|
|
#include <windows.h>
|
|
#include <stdlib.h>
|
|
|
|
#define __UNKNOWN_APP 0
|
|
#define __CONSOLE_APP 1
|
|
#define __GUI_APP 2
|
|
void __set_app_type(int);
|
|
void _controlfp(unsigned a, unsigned b);
|
|
|
|
#ifdef _UNICODE
|
|
#define __tgetmainargs __wgetmainargs
|
|
#define _twinstart _wwinstart
|
|
#define _runtwinmain _runwwinmain
|
|
int APIENTRY wWinMain(HINSTANCE, HINSTANCE, LPWSTR, int);
|
|
#else
|
|
#define __tgetmainargs __getmainargs
|
|
#define _twinstart _winstart
|
|
#define _runtwinmain _runwinmain
|
|
#endif
|
|
|
|
typedef struct { int newmode; } _startupinfo;
|
|
int __cdecl __tgetmainargs(int *pargc, _TCHAR ***pargv, _TCHAR ***penv, int globb, _startupinfo*);
|
|
|
|
static int go_winmain(TCHAR *arg1)
|
|
{
|
|
STARTUPINFO si;
|
|
_TCHAR *szCmd, *p;
|
|
int fShow;
|
|
|
|
GetStartupInfo(&si);
|
|
if (si.dwFlags & STARTF_USESHOWWINDOW)
|
|
fShow = si.wShowWindow;
|
|
else
|
|
fShow = SW_SHOWDEFAULT;
|
|
|
|
szCmd = NULL, p = GetCommandLine();
|
|
if (arg1)
|
|
szCmd = _tcsstr(p, arg1);
|
|
if (NULL == szCmd)
|
|
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);
|
|
}
|
|
|
|
static LONG WINAPI catch_sig(EXCEPTION_POINTERS *ex)
|
|
{
|
|
return _XcptFilter(ex->ExceptionRecord->ExceptionCode, ex);
|
|
}
|
|
|
|
int _twinstart(void)
|
|
{
|
|
_startupinfo start_info_con = {0};
|
|
SetUnhandledExceptionFilter(catch_sig);
|
|
__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)
|
|
{
|
|
#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;
|
|
#else
|
|
__argc = argc, __targv = argv;
|
|
#endif
|
|
return go_winmain(__argc > 1 ? __targv[1] : NULL);
|
|
}
|