LLVM  15.0.0git
ThreadLocal.inc
Go to the documentation of this file.
1 //=== llvm/Support/Unix/ThreadLocal.inc - Unix Thread Local Data -*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file implements the Unix specific (non-pthread) ThreadLocal class.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 //===----------------------------------------------------------------------===//
14 //=== WARNING: Implementation here must contain only generic UNIX code that
15 //=== is guaranteed to work on *all* UNIX variants.
16 //===----------------------------------------------------------------------===//
17 
18 #include "llvm/Config/config.h"
19 
20 #include <cassert>
21 #include <pthread.h>
22 #include <stdlib.h>
23 
24 namespace llvm {
25 using namespace sys;
26 
28  static_assert(sizeof(pthread_key_t) <= sizeof(data), "size too big");
29  pthread_key_t* key = reinterpret_cast<pthread_key_t*>(&data);
30  int errorcode = pthread_key_create(key, nullptr);
31  assert(errorcode == 0);
32  (void) errorcode;
33 }
34 
36  pthread_key_t* key = reinterpret_cast<pthread_key_t*>(&data);
37  int errorcode = pthread_key_delete(*key);
38  assert(errorcode == 0);
39  (void) errorcode;
40 }
41 
42 void ThreadLocalImpl::setInstance(const void* d) {
43  pthread_key_t* key = reinterpret_cast<pthread_key_t*>(&data);
44  int errorcode = pthread_setspecific(*key, d);
45  assert(errorcode == 0);
46  (void) errorcode;
47 }
48 
50  pthread_key_t* key = reinterpret_cast<pthread_key_t*>(&data);
51  return pthread_getspecific(*key);
52 }
53 
55  setInstance(nullptr);
56 }
57 
58 }
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:17
llvm::sys::ThreadLocalImpl::removeInstance
void removeInstance()
llvm::sys::ThreadLocalImpl::getInstance
void * getInstance()
llvm::sys::ThreadLocalImpl::ThreadLocalImpl
ThreadLocalImpl()
llvm::sys::ThreadLocalImpl::setInstance
void setInstance(const void *d)
llvm::sys::ThreadLocalImpl::~ThreadLocalImpl
virtual ~ThreadLocalImpl()
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
d
the resulting code requires compare and branches when and if the revised code is with conditional branches instead of More there is a byte word extend before each where there should be only and the condition codes are not remembered when the same two values are compared twice More LSR enhancements i8 and i32 load store addressing modes are identical int int int d
Definition: README.txt:418
llvm::sys::ThreadLocalImpl::data
char data[sizeof(ThreadLocalDataTy)]
Definition: ThreadLocal.h:31