git.y1.nz

SameBoy

Accurate GB/GBC emulator
download: https://git.y1.nz/archives/sameboy.tar.gz
README | Files | Log | Refs | LICENSE

Windows/crt.c

      1 #include <windows.h>
      2 #include <stdio.h>
      3 
      4 #ifdef USE_MSVCRT_DLL
      5 /* Stub-out functions imported by VS's msvcrt.lib but are not implemented in msvcrt.dll */
      6 
      7 /* We don't use exceptions, these are used by the uncaught exception handler and can be replaced with aborts */
      8 
      9 void *__current_exception(void)
     10 {
     11     abort();
     12     return NULL;
     13 }
     14 
     15 void *__current_exception_context(void)
     16 {
     17     abort();
     18     return NULL;
     19 }
     20 
     21 /* terminate uses a mangled symbol on msvcrt.dll */
     22 
     23 void msvcrt_terminate(void) __asm__("?terminate@@YAXXZ");
     24 void terminate(void)
     25 {
     26     msvcrt_terminate();
     27 }
     28 
     29 /* We need to redirect these to msvcrt.dll's atexit */
     30 
     31 int _crt_atexit(void (*function)(void))
     32 {
     33     return ((typeof(atexit) *)GetProcAddress(GetModuleHandleA("msvcrt.dll"), "atexit"))(function);
     34 }
     35 
     36 int _register_onexit_function(void *table, void (*function)(void))
     37 {
     38     return ((typeof(atexit) *)GetProcAddress(GetModuleHandleA("msvcrt.dll"), "atexit"))(function);
     39 }
     40 
     41 /* Various imported function we don't need and can nop-out */
     42 
     43 int *__p__commode(void)
     44 {
     45     static int dummy;
     46     return &dummy;
     47 }
     48 
     49 int _configthreadlocale(int flag)
     50 {
     51     return 0;
     52 }
     53 
     54 errno_t _configure_narrow_argv(unsigned mode)
     55 {
     56     return 0;
     57 }
     58 
     59 char *_get_narrow_winmain_command_line(void)
     60 {
     61     return NULL;
     62 }
     63 
     64 int _initialize_narrow_environment()
     65 {
     66     return 0;
     67 }
     68 
     69 int _initialize_onexit_table(void *table)
     70 {
     71     return 0;
     72 }
     73 
     74 void _register_thread_local_exe_atexit_callback(const void *callback)
     75 {
     76 }
     77 
     78 int _seh_filter_exe(unsigned exception_num, void *exception)
     79 {
     80     return 0;
     81 }
     82 
     83 int _seh_filter_dll(unsigned ExceptionNum, struct _EXCEPTION_POINTERS *ExceptionPtr)
     84 {
     85     return 0;
     86 }
     87 
     88 void _set_app_type(unsigned type)
     89 {
     90 }
     91 
     92 int _set_new_mode(int new_mode)
     93 {
     94     return 0;
     95 }
     96 
     97 int _execute_onexit_table(void *Table)
     98 {
     99     return 0;
    100 }
    101 
    102 void __std_type_info_destroy_list(void *const root_node)
    103 {
    104 }
    105 #endif

This webpage is intended to be an accessible preview of this repository. To get a fuller picture, clone it and use the git CLI.