This commit is contained in:
snarmph 2025-10-24 10:58:09 +02:00
parent 5e165c1fad
commit c7291ead23
3 changed files with 19 additions and 8 deletions

View file

@ -184,6 +184,16 @@ void os__win_free_entity(os_entity_t *entity) {
list_push(w32_data.entity_free, entity);
}
HANDLE os__win_get_handle(oshandle_t handle) {
os_entity_t *e = (os_entity_t *)handle.data;
switch (e->kind) {
case OS_KIND_THREAD:
return e->thread.handle;
default:
return e;
}
}
void os_init(void) {
SetConsoleOutputCP(CP_UTF8);
@ -288,7 +298,7 @@ os_wait_t os_wait_on_handles(oshandle_t *handles, int count, bool wait_all, u32
colla_assert(count < COLLA_OS_MAX_WAITABLE_HANDLES);
for (int i = 0; i < count; ++i) {
win_handles[i] = (HANDLE)(handles[i].data);
win_handles[i] = os__win_get_handle(handles[i]);
}
DWORD result = WaitForMultipleObjects(count, win_handles, wait_all, milliseconds);
@ -720,7 +730,7 @@ oshandle_t os_run_cmd_async(arena_t scratch, os_cmd_t *cmd, os_cmd_options_t *op
for (int i = 0; i < cur->count; ++i) {
strview_t arg = cur->items[i];
if (strv_contains(arg, ' ')) {
ostr_print(&cmdline, "%v", arg);
ostr_print(&cmdline, "\"%v\"", arg);
}
else {
ostr_puts(&cmdline, arg);
@ -1195,7 +1205,7 @@ http_res_t http_request_cb(http_request_desc_t *req, http_request_callback_fn ca
strview_t chunk = strv(read_buffer, read);
if (callback) {
callback(chunk, userdata);
callback(res.headers, chunk, userdata);
}
ostr_puts(&body, chunk);
}