From ef533e2e3fedbd647726416fa7f36ca543ee13ea Mon Sep 17 00:00:00 2001 From: Bernd Schubert Date: Thu, 24 Apr 2025 13:53:59 +0200 Subject: Add a fuse_set_thread_name() helper Avoid splattering the code with ifdef Signed-off-by: Bernd Schubert --- lib/util.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'lib/util.c') diff --git a/lib/util.c b/lib/util.c index a529d38..00f1e1a 100644 --- a/lib/util.c +++ b/lib/util.c @@ -1,3 +1,12 @@ + +#include "fuse_config.h" + +#ifdef HAVE_PTHREAD_SETNAME_NP +#define _GNU_SOURCE +#include +#endif + +#include #include #include @@ -25,3 +34,13 @@ int libfuse_strtol(const char *str, long *res) *res = val; return 0; } + +void fuse_set_thread_name(unsigned long tid, const char *name) +{ +#ifdef HAVE_PTHREAD_SETNAME_NP + pthread_setname_np(tid, name); +#else + (void)tid; + (void)name; +#endif +} -- cgit v1.2.3