Create prof_sys module for reading system thread name
This commit is contained in:
22
src/prof.c
22
src/prof.c
@@ -8,6 +8,7 @@
|
||||
#include "jemalloc/internal/prof_data.h"
|
||||
#include "jemalloc/internal/prof_log.h"
|
||||
#include "jemalloc/internal/prof_recent.h"
|
||||
#include "jemalloc/internal/prof_sys.h"
|
||||
#include "jemalloc/internal/thread_event.h"
|
||||
|
||||
/*
|
||||
@@ -133,27 +134,6 @@ prof_alloc_rollback(tsd_t *tsd, prof_tctx_t *tctx) {
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
prof_sys_thread_name_read_impl(char *buf, size_t limit) {
|
||||
#ifdef JEMALLOC_HAVE_PTHREAD_SETNAME_NP
|
||||
return pthread_getname_np(pthread_self(), buf, limit);
|
||||
#else
|
||||
return ENOSYS;
|
||||
#endif
|
||||
}
|
||||
prof_sys_thread_name_read_t *JET_MUTABLE prof_sys_thread_name_read =
|
||||
prof_sys_thread_name_read_impl;
|
||||
|
||||
static void
|
||||
prof_sys_thread_name_fetch(tsd_t *tsd) {
|
||||
#define THREAD_NAME_MAX_LEN 16
|
||||
char buf[THREAD_NAME_MAX_LEN];
|
||||
if (!prof_sys_thread_name_read(buf, THREAD_NAME_MAX_LEN)) {
|
||||
prof_thread_name_set_impl(tsd, buf);
|
||||
}
|
||||
#undef THREAD_NAME_MAX_LEN
|
||||
}
|
||||
|
||||
void
|
||||
prof_malloc_sample_object(tsd_t *tsd, const void *ptr, size_t size,
|
||||
size_t usize, prof_tctx_t *tctx) {
|
||||
|
27
src/prof_sys.c
Normal file
27
src/prof_sys.c
Normal file
@@ -0,0 +1,27 @@
|
||||
#define JEMALLOC_PROF_SYS_C_
|
||||
#include "jemalloc/internal/jemalloc_preamble.h"
|
||||
#include "jemalloc/internal/jemalloc_internal_includes.h"
|
||||
|
||||
#include "jemalloc/internal/prof_data.h"
|
||||
#include "jemalloc/internal/prof_sys.h"
|
||||
|
||||
static int
|
||||
prof_sys_thread_name_read_impl(char *buf, size_t limit) {
|
||||
#ifdef JEMALLOC_HAVE_PTHREAD_SETNAME_NP
|
||||
return pthread_getname_np(pthread_self(), buf, limit);
|
||||
#else
|
||||
return ENOSYS;
|
||||
#endif
|
||||
}
|
||||
prof_sys_thread_name_read_t *JET_MUTABLE prof_sys_thread_name_read =
|
||||
prof_sys_thread_name_read_impl;
|
||||
|
||||
void
|
||||
prof_sys_thread_name_fetch(tsd_t *tsd) {
|
||||
#define THREAD_NAME_MAX_LEN 16
|
||||
char buf[THREAD_NAME_MAX_LEN];
|
||||
if (!prof_sys_thread_name_read(buf, THREAD_NAME_MAX_LEN)) {
|
||||
prof_thread_name_set_impl(tsd, buf);
|
||||
}
|
||||
#undef THREAD_NAME_MAX_LEN
|
||||
}
|
Reference in New Issue
Block a user