[ARM] Rejig MVE load store tests. NFC
[llvm-core.git] / lib / Support / ThreadLocal.cpp
blob44e6223cf17b690f2985d7de26d8479817af760a
1 //===- ThreadLocal.cpp - 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 llvm::sys::ThreadLocal class.
11 //===----------------------------------------------------------------------===//
13 #include "llvm/Support/ThreadLocal.h"
14 #include "llvm/Config/llvm-config.h"
15 #include "llvm/Support/Compiler.h"
17 //===----------------------------------------------------------------------===//
18 //=== WARNING: Implementation here must contain only TRULY operating system
19 //=== independent code.
20 //===----------------------------------------------------------------------===//
22 #if !defined(LLVM_ENABLE_THREADS) || LLVM_ENABLE_THREADS == 0
23 // Define all methods as no-ops if threading is explicitly disabled
24 namespace llvm {
25 using namespace sys;
26 ThreadLocalImpl::ThreadLocalImpl() : data() { }
27 ThreadLocalImpl::~ThreadLocalImpl() { }
28 void ThreadLocalImpl::setInstance(const void* d) {
29 static_assert(sizeof(d) <= sizeof(data), "size too big");
30 void **pd = reinterpret_cast<void**>(&data);
31 *pd = const_cast<void*>(d);
33 void *ThreadLocalImpl::getInstance() {
34 void **pd = reinterpret_cast<void**>(&data);
35 return *pd;
37 void ThreadLocalImpl::removeInstance() {
38 setInstance(nullptr);
41 #elif defined(LLVM_ON_UNIX)
42 #include "Unix/ThreadLocal.inc"
43 #elif defined( _WIN32)
44 #include "Windows/ThreadLocal.inc"
45 #else
46 #warning Neither LLVM_ON_UNIX nor _WIN32 set in Support/ThreadLocal.cpp
47 #endif