give app its own thread

This commit is contained in:
jacob 2024-04-03 01:48:32 -05:00
parent 13d927e752
commit c3d395a44e
2 changed files with 16 additions and 8 deletions

View File

@ -201,11 +201,7 @@ struct sys_file_map {
struct sys_file_map sys_file_map_open_read(struct sys_file file);
void sys_file_map_close(struct sys_file_map map);
INLINE struct buffer sys_file_map_data(struct sys_file_map map)
{
return map.mapped_memory;
}
struct buffer sys_file_map_data(struct sys_file_map map);
/* ========================== *
* Dir iter
@ -392,7 +388,7 @@ struct tls_table *sys_thread_get_tls(void);
* Threads
* ========================== */
#define SYS_THREAD_STACK_SIZE MEGABYTE(1)
#define SYS_THREAD_STACK_SIZE MEGABYTE(2)
#define SYS_THREAD_FUNC_DEF(name, arg_name) void name(void *arg_name)
typedef SYS_THREAD_FUNC_DEF(sys_thread_func, data);

View File

@ -440,6 +440,11 @@ void sys_file_map_close(struct sys_file_map map)
CloseHandle((HANDLE)map.handle);
}
struct buffer sys_file_map_data(struct sys_file_map map)
{
return map.mapped_memory;
}
/* ========================== *
* Dir iter
* ========================== */
@ -1766,6 +1771,12 @@ void sys_sleep(f64 seconds)
* Entry point
* ========================== */
INTERNAL SYS_THREAD_FUNC_DEF(app_thread_entry_point, arg)
{
(UNUSED)arg;
app_entry_point();
}
int CALLBACK WinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev_instance, _In_ LPSTR command_line, _In_ int show_code)
{
(UNUSED)instance;
@ -1867,8 +1878,9 @@ error:
return 1;
}
/* App */
app_entry_point();
/* Create app thread & wait for return */
struct sys_thread app_thread = sys_thread_init(&app_thread_entry_point, NULL, STR("[P9] App thread"));
sys_thread_join(&app_thread);
win32_tls_release(&main_thread_tls);