]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Make isc_tid() a header-only function
authorOndřej Surý <ondrej@isc.org>
Sat, 8 Apr 2023 11:56:13 +0000 (13:56 +0200)
committerOndřej Surý <ondrej@isc.org>
Wed, 12 Apr 2023 12:10:37 +0000 (14:10 +0200)
The isc_tid() function is often called on the hot-path and it's the only
function is to return thread_local variable, make the isc_tid() function
a header-only to save several function calls during query-response
processing.

.gitlab-ci.yml
lib/isc/include/isc/tid.h
lib/isc/tid.c

index fa165f0876c5f6c12346ae61fd7e5dbdd1f7e8d4..4a1ac8cbd08fd245b2cb2b38bd0fb22be603a27d 100644 (file)
@@ -1575,6 +1575,7 @@ gcov:
     - find bin lib -maxdepth 1 -mindepth 1 -type d -exec cp -f lib/isc/include/isc/buffer.h "{}" \;
     - cp -f lib/isc/include/isc/buffer.h lib/isc/netmgr/buffer.h
     - cp -f lib/isc/include/isc/dnsstream.h lib/isc/netmgr/dnsstream.h
+    - cp -f lib/isc/include/isc/tid.h lib/isc/netmgr/tid.h
     # Help gcovr find dlz_dbi.c file
     - for DST in ldap mysql mysqldyn sqlite3 wildcard; do cp contrib/dlz/modules/common/dlz_dbi.c "contrib/dlz/modules/${DST}"; done
     # Generate XML file in the Cobertura XML format suitable for use by GitLab
index 7bb7ca5f981fc4c48ae66ca379ecd0fe6dea0c1b..20bafac59525aa4c9eff3cf6531b1c0e40738c7b 100644 (file)
@@ -16,6 +16,7 @@
 #include <inttypes.h>
 
 #include <isc/lang.h>
+#include <isc/thread.h>
 
 ISC_LANG_BEGINDECLS
 
@@ -27,8 +28,12 @@ isc_tid_count(void);
  * Returns the number of threads.
  */
 
-uint32_t
-isc_tid(void);
+extern thread_local uint32_t tid_local;
+
+static inline uint32_t
+isc_tid(void) {
+       return (tid_local);
+}
 /*%<
  * Returns the thread ID of the currently-running loop.
  */
index 5a278e799ed79adecfa797b163a7bc298ddebec2..397fac1c8fde5f9d4f23422d61f861ddd49ca191 100644 (file)
 /**
  * Private
  */
-
-#define ISC_TID_UNKNOWN UINT32_MAX
-
-static thread_local uint32_t tid_local = ISC_TID_UNKNOWN;
+thread_local uint32_t tid_local = ISC_TID_UNKNOWN;
 
 /*
  * Zero is a better nonsense value in this case than ISC_TID_UNKNOWN;
@@ -54,11 +51,6 @@ isc__tid_initcount(uint32_t count) {
  * Public
  */
 
-uint32_t
-isc_tid(void) {
-       return (tid_local);
-}
-
 uint32_t
 isc_tid_count(void) {
        return (tid_count);