diff options
| author | Siva Chandra Reddy <sivachandra@google.com> | 2022-08-09 20:40:53 +0000 |
|---|---|---|
| committer | Siva Chandra Reddy <sivachandra@google.com> | 2022-08-12 05:28:40 +0000 |
| commit | 4a738ee8220e02df62b7b43d3fe5b2d6be88c482 (patch) | |
| tree | b438daf6c0eda2be89eaad9c2dce97a073df05d0 /libc/src/threads/tss_create.cpp | |
| parent | 12e1936f64f8739889dafffd17c826526ce4da5e (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/threads/tss_create.cpp')
| -rw-r--r-- | libc/src/threads/tss_create.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/libc/src/threads/tss_create.cpp b/libc/src/threads/tss_create.cpp new file mode 100644 index 000000000000..f384565fbb9d --- /dev/null +++ b/libc/src/threads/tss_create.cpp @@ -0,0 +1,26 @@ +//===-- Implementation of the tss_create ----------------------------------===// +// +// 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 "tss_create.h" + +#include "src/__support/common.h" +#include "src/__support/threads/thread.h" + +#include <threads.h> + +namespace __llvm_libc { + +LLVM_LIBC_FUNCTION(int, tss_create, (tss_t * key, tss_dtor_t dtor)) { + auto k = __llvm_libc::new_tss_key(dtor); + if (!k) + return thrd_error; + *key = *k; + return thrd_success; +} + +} // namespace __llvm_libc |
