1 // =============================================
4 // _UNICODE for tchar.h, UNICODE for API
11 #define _UNKNOWN_APP 0
12 #define _CONSOLE_APP 1
15 #define _MCW_PC 0x00030000 // Precision Control
16 #define _PC_24 0x00020000 // 24 bits
17 #define _PC_53 0x00010000 // 53 bits
18 #define _PC_64 0x00000000 // 64 bits
21 #define __tgetmainargs __wgetmainargs
22 #define _tstart _wstart
24 #define _runtmain _runwmain
26 #define __tgetmainargs __getmainargs
27 #define _tstart _start
29 #define _runtmain _runmain
32 typedef struct { int newmode
; } _startupinfo
;
33 int __cdecl
__tgetmainargs(int *pargc
, _TCHAR
***pargv
, _TCHAR
***penv
, int globb
, _startupinfo
*);
34 void __cdecl
__set_app_type(int apptype
);
35 unsigned int __cdecl
_controlfp(unsigned int new_value
, unsigned int mask
);
36 extern int _tmain(int argc
, _TCHAR
* argv
[], _TCHAR
* env
[]);
40 /* Allow command-line globbing with "int _dowildcard = 1;" in the user source */
43 static LONG WINAPI
catch_sig(EXCEPTION_POINTERS
*ex
)
45 return _XcptFilter(ex
->ExceptionRecord
->ExceptionCode
, ex
);
52 _startupinfo start_info
= {0};
53 SetUnhandledExceptionFilter(catch_sig
);
54 // Sets the current application type
55 __set_app_type(_CONSOLE_APP
);
57 // Set default FP precision to 53 bits (8-byte double)
58 // _MCW_PC (Precision control) is not supported on ARM
59 #if defined __i386__ || defined __x86_64__
60 _controlfp(_PC_53
, _MCW_PC
);
63 __tgetmainargs( &__argc
, &__targv
, &_tenviron
, _dowildcard
, &start_info
);
64 run_ctors(__argc
, __targv
, _tenviron
);
65 ret
= _tmain(__argc
, __targv
, _tenviron
);
70 // =============================================
73 __attribute__((weak
)) extern int __run_on_exit();
75 int _runtmain(int argc
, /* as tcc passed in */ char **argv
)
79 _startupinfo start_info
= {0};
81 __tgetmainargs(&__argc
, &__targv
, &_tenviron
, _dowildcard
, &start_info
);
82 /* may be wrong when tcc has received wildcards (*.c) */
84 __targv
+= __argc
- argc
;
91 #if defined __i386__ || defined __x86_64__
92 _controlfp(_PC_53
, _MCW_PC
);
94 run_ctors(__argc
, __targv
, _tenviron
);
95 ret
= _tmain(__argc
, __targv
, _tenviron
);
101 // =============================================