summaryrefslogtreecommitdiff
path: root/libc/src/pthread/pthread_getspecific.cpp
diff options
context:
space:
mode:
authorSiva Chandra Reddy <sivachandra@google.com>2022-08-09 20:40:53 +0000
committerSiva Chandra Reddy <sivachandra@google.com>2022-08-12 05:28:40 +0000
commit4a738ee8220e02df62b7b43d3fe5b2d6be88c482 (patch)
treeb438daf6c0eda2be89eaad9c2dce97a073df05d0 /libc/src/pthread/pthread_getspecific.cpp
parent12e1936f64f8739889dafffd17c826526ce4da5e (diff)
[libc] Add implemementations of thread specific data related API.
Specifically, POSIX functions pthread_key_create, pthread_key_delete, pthread_setspecific and pthread_getspecific have been added. The C standard equivalents tss_create, tss_delete, tss_set and tss_get have also been added. Reviewed By: lntue, michaelrj Differential Revision: https://reviews.llvm.org/D131647
Diffstat (limited to 'libc/src/pthread/pthread_getspecific.cpp')
-rw-r--r--libc/src/pthread/pthread_getspecific.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/libc/src/pthread/pthread_getspecific.cpp b/libc/src/pthread/pthread_getspecific.cpp
new file mode 100644
index 000000000000..02545564a8cc
--- /dev/null
+++ b/libc/src/pthread/pthread_getspecific.cpp
@@ -0,0 +1,23 @@
+//===-- Linux implementation of the pthread_getspecific function ----------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "pthread_getspecific.h"
+
+#include "src/__support/common.h"
+#include "src/__support/threads/thread.h"
+
+#include <pthread.h>
+#include <stddef.h>
+
+namespace __llvm_libc {
+
+LLVM_LIBC_FUNCTION(void *, pthread_getspecific, (pthread_key_t key)) {
+ return get_tss_value(key);
+}
+
+} // namespace __llvm_libc