Add automatically-generated names to threads

This commit is contained in:
RichardG867
2024-01-09 20:13:16 -03:00
parent ce342400eb
commit 67c84f1ae6
9 changed files with 107 additions and 6 deletions

View File

@@ -45,6 +45,9 @@
#include <86box/ui.h>
#include <86box/gdbstub.h>
#define __USE_GNU 1 /* shouldn't be done, yet it is */
#include <pthread.h>
static int first_use = 1;
static uint64_t StartingTime;
static uint64_t Frequency;
@@ -1379,6 +1382,23 @@ plat_get_cpu_string(char *outbuf, uint8_t len) {
strncpy(outbuf, cpu_string, len);
}
void
plat_set_thread_name(void *thread, const char *name)
{
#ifdef __APPLE__
char truncated[64];
#else
char truncated[16];
#endif
strncpy(truncated, name, sizeof(truncated) - 1);
#ifdef __APPLE__
if (!thread)
pthread_setname_np(truncated);
#else
pthread_setname_np(thread ? (pthread_t) thread : pthread_self(), truncated);
#endif
}
/* Converts back the language code to LCID */
void
plat_language_code_r(uint32_t lcid, char *outbuf, int len)