zoslib
z/OS C/C++ Library
Loading...
Searching...
No Matches
zos-tls.h
Go to the documentation of this file.
1
2// Licensed Materials - Property of IBM
3// ZOSLIB
4// (C) Copyright IBM Corp. 2020. All Rights Reserved.
5// US Government Users Restricted Rights - Use, duplication
6// or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
8
9// TODO(gabylb): zos - revisit when thread_local is implemented.
10// APIs that implement Thread-local storage support.
11
12#ifndef ZOS_TLS_H_
13#define ZOS_TLS_H_
14
15#include "zos-macros.h"
16
17#ifdef __cplusplus
18#include <unistd.h>
19
24__Z_EXPORT void* __tlsPtrFromAnchor(struct __tlsanchor *anchor, const void *);
25
26template <typename T> class __Z_EXPORT __tlssim {
27 struct __tlsanchor *anchor;
28 T v;
29
30public:
31 __tlssim(const T &initvalue) : v(initvalue) {
32 anchor = __tlsvaranchor_create(sizeof(T));
33 }
34 __tlssim() { anchor = __tlsvaranchor_create(sizeof(T)); }
35 ~__tlssim() { __tlsvaranchor_destroy(anchor); }
36 T *access(void) { return static_cast<T *>(__tlsPtrFromAnchor(anchor, &v)); }
37};
38
39#endif // __cplusplus
40#endif // ZOS_TLS_H_
Definition zos-tls.cc:74
size_t sz
Definition zos-tls.cc:77
#define __Z_EXPORT
Definition zos-macros.h:13
void * __tlsPtrFromAnchor(struct __tlsanchor *anchor, const void *initvalue)
Definition zos-tls.cc:93
void __tlsvaranchor_destroy(struct __tlsanchor *anchor)
Definition zos-tls.cc:88
struct __tlsanchor * __tlsvaranchor_create(size_t sz)
Definition zos-tls.cc:80