From 41ad58ab1953835313ad2b89686931b08b5b47e8 Mon Sep 17 00:00:00 2001 From: ghpzin Date: Tue, 25 Mar 2025 15:26:07 +0300 Subject: [PATCH] Fix thread arg type for pthread_setname_np - change `thread` arg type to `cen64_thread` instead of `cen64_thread *` (`pthread_t` instead of `pthread_t *`) according to definition of `pthread_setname_np` from ``: `int pthread_setname_np(pthread_t thread, const char *name);` fixes gcc14 errors: ``` /build/source/cen64.c:475:24: error: passing argument 1 of 'cen64_thread_setname' makes pointer from integer without a cast [-Wint-conversion] 475 | cen64_thread_setname(thread, "device"); | ^~~~~~ | | | cen64_thread {aka long unsigned int} In file included from /build/source/device/device.h:26, from /build/source/cen64.c:15: /build/source/os/posix/thread.h:59:54: note: expected 'cen64_thread *' {aka 'long unsigned int *'} but argument is of type 'cen64_thread' {aka 'lo> 59 | static inline int cen64_thread_setname(cen64_thread *t, const char *name) { | ~~~~~~~~~~~~~~^ ``` - add cast to `cen64_thread` from NULL where `cen64_thread` is called with it, fixes gcc14 errors: ``` /build/source/gdb/gdb.c:82:24: error: passing argument 1 of 'cen64_thread_setname' makes integer from pointer without a cast [-Wint-conversion] 82 | cen64_thread_setname(NULL, "gdb"); | ^~~~ | | | void * /build/source/os/posix/thread.h:59:53: note: expected 'cen64_thread' {aka 'long unsigned int'} but argument is of type 'void *' 59 | static inline int cen64_thread_setname(cen64_thread t, const char *name) { | ~~~~~~~~~~~~~^ ``` --- cen64.c | 2 +- device/device.c | 4 ++-- gdb/gdb.c | 4 ++-- os/posix/thread.h | 6 +++--- os/winapi/thread.h | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/cen64.c b/cen64.c index 51014a42a..ca6bda19a 100644 --- a/cen64.c +++ b/cen64.c @@ -483,7 +483,7 @@ int run_device(struct cen64_device *device, bool no_video) { } CEN64_THREAD_RETURN_TYPE run_device_thread(void *opaque) { - cen64_thread_setname(NULL, "device"); + cen64_thread_setname((cen64_thread)NULL, "device"); struct cen64_device *device = (struct cen64_device *) opaque; device_run(device); diff --git a/device/device.c b/device/device.c index cd5a046c6..c9158466f 100644 --- a/device/device.c +++ b/device/device.c @@ -224,7 +224,7 @@ CEN64_THREAD_RETURN_TYPE run_rcp_thread(void *opaque) { } CEN64_THREAD_RETURN_TYPE run_vr4300_thread(void *opaque) { - cen64_thread_setname(NULL, "vr4300"); + cen64_thread_setname((cen64_thread)NULL, "vr4300"); struct cen64_device *device = (struct cen64_device *) opaque; while (likely(device->running)) { @@ -351,4 +351,4 @@ int device_debug_spin(struct cen64_device *device) { cen64_cold void device_connect_debugger(struct cen64_device *device, void* break_handler_data, vr4300_debug_break_handler break_handler) { vr4300_connect_debugger(device->vr4300, break_handler_data, break_handler); -} \ No newline at end of file +} diff --git a/gdb/gdb.c b/gdb/gdb.c index 021784d58..0e8d188d8 100644 --- a/gdb/gdb.c +++ b/gdb/gdb.c @@ -79,7 +79,7 @@ bool gdb_parse_packet(const char* input, int len, const char** command_start, co } CEN64_THREAD_RETURN_TYPE gdb_thread(void *opaque) { - cen64_thread_setname(NULL, "gdb"); + cen64_thread_setname((cen64_thread)NULL, "gdb"); struct gdb *gdb = (struct gdb *) opaque; cen64_mutex_lock(&gdb->client_mutex); @@ -257,4 +257,4 @@ cen64_cold void gdb_destroy(struct gdb* gdb) { gdb->device = NULL; free(gdb); -} \ No newline at end of file +} diff --git a/os/posix/thread.h b/os/posix/thread.h index 2a261c654..e8e614495 100644 --- a/os/posix/thread.h +++ b/os/posix/thread.h @@ -45,9 +45,9 @@ static inline int cen64_thread_join(cen64_thread *t) { #ifdef __APPLE__ int pthread_setname_np(const char*); #elif __NETBSD__ -int pthread_setname_np(cen64_thread*, const char*, const char*); +int pthread_setname_np(cen64_thread, const char*, const char*); #else -int pthread_setname_np(cen64_thread*, const char*); +int pthread_setname_np(cen64_thread, const char*); #endif // Sets the name of the thread to a specific value @@ -56,7 +56,7 @@ int pthread_setname_np(cen64_thread*, const char*); // If you call it at the wrong time or your OS doesn't support custom thread names // the return value will be non-zero. // If cen64_thread is not set the name of the current thread will be changed. -static inline int cen64_thread_setname(cen64_thread *t, const char *name) { +static inline int cen64_thread_setname(cen64_thread t, const char *name) { #ifdef __APPLE__ if (t == NULL) return pthread_setname_np(name); diff --git a/os/winapi/thread.h b/os/winapi/thread.h index d7c162a19..128d9354e 100644 --- a/os/winapi/thread.h +++ b/os/winapi/thread.h @@ -57,7 +57,7 @@ static inline int cen64_thread_join(cen64_thread *t) { // // Windows isn't supported for the moment. // -static inline int cen64_thread_setname(cen64_thread *t, const char *name) { +static inline int cen64_thread_setname(cen64_thread t, const char *name) { return ENOSYS; }