File: crt.c

package info (click to toggle)
sameboy 1.0.2%2Bds-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 10,632 kB
  • sloc: ansic: 29,954; objc: 22,249; asm: 1,424; pascal: 1,373; makefile: 1,064; xml: 111
file content (105 lines) | stat: -rwxr-xr-x 1,852 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#include <windows.h>
#include <stdio.h>

#ifdef USE_MSVCRT_DLL
/* Stub-out functions imported by VS's msvcrt.lib but are not implemented in msvcrt.dll */

/* We don't use exceptions, these are used by the uncaught exception handler and can be replaced with aborts */

void *__current_exception(void)
{
    abort();
    return NULL;
}

void *__current_exception_context(void)
{
    abort();
    return NULL;
}

/* terminate uses a mangled symbol on msvcrt.dll */

void msvcrt_terminate(void) __asm__("?terminate@@YAXXZ");
void terminate(void)
{
    msvcrt_terminate();
}

/* We need to redirect these to msvcrt.dll's atexit */

int _crt_atexit(void (*function)(void))
{
    return ((typeof(atexit) *)GetProcAddress(GetModuleHandleA("msvcrt.dll"), "atexit"))(function);
}

int _register_onexit_function(void *table, void (*function)(void))
{
    return ((typeof(atexit) *)GetProcAddress(GetModuleHandleA("msvcrt.dll"), "atexit"))(function);
}

/* Various imported function we don't need and can nop-out */

int *__p__commode(void)
{
    static int dummy;
    return &dummy;
}

int _configthreadlocale(int flag)
{
    return 0;
}

errno_t _configure_narrow_argv(unsigned mode)
{
    return 0;
}

char *_get_narrow_winmain_command_line(void)
{
    return NULL;
}

int _initialize_narrow_environment()
{
    return 0;
}

int _initialize_onexit_table(void *table)
{
    return 0;
}

void _register_thread_local_exe_atexit_callback(const void *callback)
{
}

int _seh_filter_exe(unsigned exception_num, void *exception)
{
    return 0;
}

int _seh_filter_dll(unsigned ExceptionNum, struct _EXCEPTION_POINTERS *ExceptionPtr)
{
    return 0;
}

void _set_app_type(unsigned type)
{
}

int _set_new_mode(int new_mode)
{
    return 0;
}

int _execute_onexit_table(void *Table)
{
    return 0;
}

void __std_type_info_destroy_list(void *const root_node)
{
}
#endif