add some more file fns and a Ctrl-C handler
This commit is contained in:
+29
@@ -5,6 +5,7 @@
|
||||
|
||||
static u64 w32_ticks_per_sec = 1;
|
||||
static u32 w32_thread_context_index;
|
||||
global void (*_ctrl_c_handler_fn_ptr)() = NULL;
|
||||
|
||||
void osInit() {
|
||||
LARGE_INTEGER perf_freq = {0};
|
||||
@@ -16,6 +17,19 @@ void osInit() {
|
||||
w32_thread_context_index = TlsAlloc();
|
||||
}
|
||||
|
||||
BOOL WINAPI _osGenericSignalHandler(DWORD event) {
|
||||
if (event == CTRL_C_EVENT && _ctrl_c_handler_fn_ptr != NULL) {
|
||||
_ctrl_c_handler_fn_ptr();
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void osSetCtrlCCallback(void (*handler)()) {
|
||||
_ctrl_c_handler_fn_ptr = handler;
|
||||
SetConsoleCtrlHandler(_osGenericSignalHandler, TRUE);
|
||||
}
|
||||
|
||||
void* osThreadContextGet() {
|
||||
return TlsGetValue(w32_thread_context_index);
|
||||
}
|
||||
@@ -90,6 +104,21 @@ fn bool osFileWrite(String filename, String data) {
|
||||
return result;
|
||||
}
|
||||
|
||||
fn Resulti64 osFileOpenForWriting(String filename) {
|
||||
assert(false && "Not Implemented");
|
||||
return (Resulti64) {};
|
||||
}
|
||||
|
||||
fn Resulti64 osFileClose(Resulti64 handle) {
|
||||
assert(false && "Not Implemented");
|
||||
return (Resulti64) {};
|
||||
}
|
||||
|
||||
fn bool osFileWriteOpenFile(Resulti64 handle, String data) {
|
||||
assert(false && "Not Implemented");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// Misc
|
||||
fn void osDebugPrint(bool debug_mode, const char * format, ... ) {
|
||||
|
||||
Reference in New Issue
Block a user