This is an automated email from the ASF dual-hosted git repository.

pnoltes pushed a commit to branch feature/769-make-tss-internal
in repository https://gitbox.apache.org/repos/asf/celix.git

commit adca626bcb9e9c24f225ac48dc2c524aa37bcf81
Author: Pepijn Noltes <[email protected]>
AuthorDate: Tue Apr 7 21:39:26 2026 +0200

    gh-769: Remove celix_tss abstraction
---
 libs/utils/gtest/src/ThreadsTestSuite.cc | 17 -----------------
 libs/utils/src/celix_err.c               | 21 +++++++++++----------
 libs/utils/src/celix_threads.c           | 16 ----------------
 3 files changed, 11 insertions(+), 43 deletions(-)

diff --git a/libs/utils/gtest/src/ThreadsTestSuite.cc 
b/libs/utils/gtest/src/ThreadsTestSuite.cc
index 2a52ba15e..dac4fc09f 100644
--- a/libs/utils/gtest/src/ThreadsTestSuite.cc
+++ b/libs/utils/gtest/src/ThreadsTestSuite.cc
@@ -371,23 +371,6 @@ TEST_F(ThreadsTestSuite, RwLockAttrTest) {
     celixThreadRwlockAttr_destroy(&attr);
 }
 
-TEST_F(ThreadsTestSuite, TssTest) {
-    celix_tss_key_t key;
-    celix_status_t status = celix_tss_create(&key, [](void* ptr) { free(ptr); 
});
-    EXPECT_EQ(CELIX_SUCCESS, status);
-
-    int* value = (int*)malloc(sizeof(int));
-    *value = 123;
-    status = celix_tss_set(key, value);
-    EXPECT_EQ(CELIX_SUCCESS, status);
-
-    value = (int*)celix_tss_get(key);
-    EXPECT_EQ(123, *value);
-
-    status = celix_tss_delete(key);
-    EXPECT_EQ(CELIX_SUCCESS, status);
-}
-
 static void * thread_test_func_create(void * arg) {
     char ** test_str = (char**) arg;
     *test_str = strdup("SUCCESS");
diff --git a/libs/utils/src/celix_err.c b/libs/utils/src/celix_err.c
index 747dcf3fd..344d98df6 100644
--- a/libs/utils/src/celix_err.c
+++ b/libs/utils/src/celix_err.c
@@ -23,8 +23,9 @@
 #include <stdio.h>
 #include <string.h>
 #include <stdlib.h>
+#include <pthread.h>
 
-#include "celix_threads.h"
+#include "celix_errno.h"
 
 typedef struct celix_err {
     char buffer[CELIX_ERR_BUFFER_SIZE];
@@ -32,7 +33,7 @@ typedef struct celix_err {
 } celix_err_t;
 
 
-celix_tss_key_t celix_err_tssKey;
+pthread_key_t celix_err_tssKey;
 bool celix_err_tssKeyInitialized = false;
 
 static void celix_err_destroyTssErr(void* data) {
@@ -47,7 +48,7 @@ static celix_err_t* celix_err_getRawTssErr() {
     if (!celix_err_tssKeyInitialized) {
         return NULL;
     }
-    return celix_tss_get(celix_err_tssKey);
+    return pthread_getspecific(celix_err_tssKey);
 }
 
 
@@ -57,7 +58,7 @@ celix_err_t* celix_err_getTssErr() {
         return NULL;
     }
 
-    celix_err_t* err = celix_tss_get(celix_err_tssKey);
+    celix_err_t* err = pthread_getspecific(celix_err_tssKey);
     if (err) {
         return err;
     }
@@ -65,8 +66,8 @@ celix_err_t* celix_err_getTssErr() {
     err = malloc(sizeof(*err));
     if (err) {
         err->pos = 0; //no entry
-        celix_status_t status = celix_tss_set(celix_err_tssKey, err);
-        if (status != CELIX_SUCCESS) {
+        int rc = pthread_setspecific(celix_err_tssKey, err);
+        if (rc != 0) {
             fprintf(stderr, "Failed to set thread specific storage for 
celix_err\n");
             free(err);
             err = NULL;
@@ -78,8 +79,8 @@ celix_err_t* celix_err_getTssErr() {
 }
 
 __attribute__((constructor)) void celix_err_initThreadSpecificStorageKey() {
-    celix_status_t status = celix_tss_create(&celix_err_tssKey, 
celix_err_destroyTssErr);
-    if (status == CELIX_SUCCESS) {
+    int rc = pthread_key_create(&celix_err_tssKey, celix_err_destroyTssErr);
+    if (rc == 0) {
         celix_err_tssKeyInitialized = true;
     } else {
         fprintf(stderr,"Failed to create thread specific storage key for 
celix_err\n");
@@ -92,8 +93,8 @@ __attribute__((destructor)) void 
celix_err_deinitThreadSpecificStorageKey() {
         return;
     }
 
-    celix_status_t status = celix_tss_delete(celix_err_tssKey);
-    if (status != CELIX_SUCCESS) {
+    int rc = pthread_key_delete(celix_err_tssKey);
+    if (rc != 0) {
         fprintf(stderr,"Failed to delete thread specific storage key for 
celix_err\n");
     }
 }
diff --git a/libs/utils/src/celix_threads.c b/libs/utils/src/celix_threads.c
index 19e64bec1..226e8d53e 100644
--- a/libs/utils/src/celix_threads.c
+++ b/libs/utils/src/celix_threads.c
@@ -267,19 +267,3 @@ celix_status_t 
celixThreadRwlockAttr_destroy(celix_thread_rwlockattr_t *attr) {
 celix_status_t celixThread_once(celix_thread_once_t *once_control, void 
(*init_routine)(void)) {
     return pthread_once(once_control, init_routine);
 }
-
-celix_status_t celix_tss_create(celix_tss_key_t* key, void 
(*destroyFunction)(void*)) {
-    return pthread_key_create(key, destroyFunction);
-}
-
-celix_status_t celix_tss_delete(celix_tss_key_t key) {
-    return pthread_key_delete(key);
-}
-
-celix_status_t celix_tss_set(celix_tss_key_t key, void* value) {
-    return pthread_setspecific(key, value);
-}
-
-void* celix_tss_get(celix_tss_key_t key) {
-    return pthread_getspecific(key);
-}

Reply via email to