From 78598fd0195510d0d1338bf8c28e606d67e63359 Mon Sep 17 00:00:00 2001 From: David Lamparter Date: Sun, 11 Apr 2021 03:59:25 +0200 Subject: lib: cache PID & TID in zlog code glibc removed its pid cache a while back, and grabbing this from TLS is faster than repeatedly calling the kernel... Also use `intmax_t` which is more appropriate for both PID & TID. Signed-off-by: David Lamparter --- lib/zlog.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'lib/zlog.h') diff --git a/lib/zlog.h b/lib/zlog.h index 1b03e3fd1..7fd7b0e5c 100644 --- a/lib/zlog.h +++ b/lib/zlog.h @@ -178,6 +178,11 @@ extern size_t zlog_msg_ts(struct zlog_msg *msg, struct fbuf *out, extern size_t zlog_msg_ts_3164(struct zlog_msg *msg, struct fbuf *out, uint32_t flags); +/* currently just returns the current PID/TID since we never write another + * thread's messages + */ +extern void zlog_msg_pid(struct zlog_msg *msg, intmax_t *pid, intmax_t *tid); + /* This list & struct implements the actual logging targets. It is accessed * lock-free from all threads, and thus MUST only be changed atomically, i.e. * RCU. -- cgit v1.2.3