diff options
author | Tom Stellard <thomas.stellard@amd.com> | 2015-09-30 15:00:39 +0000 |
---|---|---|
committer | Tom Stellard <thomas.stellard@amd.com> | 2015-10-02 23:19:01 +0000 |
commit | 3219b48ae5a5b1288bf1fc1325ebbc7ac9e236df (patch) | |
tree | a6171fed4b09cdd24adfed17eb9739d9b79f4e7e | |
parent | bf7b6fd3fd6d98305d64ee6224ca9f9e7ba48444 (diff) | |
download | external_mesa3d-3219b48ae5a5b1288bf1fc1325ebbc7ac9e236df.zip external_mesa3d-3219b48ae5a5b1288bf1fc1325ebbc7ac9e236df.tar.gz external_mesa3d-3219b48ae5a5b1288bf1fc1325ebbc7ac9e236df.tar.bz2 |
gallium/radeon: Use call_once() when initailizing LLVM targets
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Mathias Fröhlich <Mathias.Froehlich@web.de>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
CC: "10.6 11.0" <mesa-stable@lists.freedesktop.org>
-rw-r--r-- | src/gallium/drivers/radeon/radeon_llvm_emit.c | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/src/gallium/drivers/radeon/radeon_llvm_emit.c b/src/gallium/drivers/radeon/radeon_llvm_emit.c index 3acbd02..ff30a14 100644 --- a/src/gallium/drivers/radeon/radeon_llvm_emit.c +++ b/src/gallium/drivers/radeon/radeon_llvm_emit.c @@ -25,6 +25,7 @@ */ #include "radeon_llvm_emit.h" #include "radeon_elf_util.h" +#include "c11/threads.h" #include "util/u_memory.h" #include "pipe/p_shader_tokens.h" @@ -86,30 +87,28 @@ void radeon_llvm_shader_type(LLVMValueRef F, unsigned type) static void init_r600_target() { - static unsigned initialized = 0; - if (!initialized) { #if HAVE_LLVM < 0x0307 - LLVMInitializeR600TargetInfo(); - LLVMInitializeR600Target(); - LLVMInitializeR600TargetMC(); - LLVMInitializeR600AsmPrinter(); + LLVMInitializeR600TargetInfo(); + LLVMInitializeR600Target(); + LLVMInitializeR600TargetMC(); + LLVMInitializeR600AsmPrinter(); #else - LLVMInitializeAMDGPUTargetInfo(); - LLVMInitializeAMDGPUTarget(); - LLVMInitializeAMDGPUTargetMC(); - LLVMInitializeAMDGPUAsmPrinter(); + LLVMInitializeAMDGPUTargetInfo(); + LLVMInitializeAMDGPUTarget(); + LLVMInitializeAMDGPUTargetMC(); + LLVMInitializeAMDGPUAsmPrinter(); #endif - initialized = 1; - } } +static once_flag init_r600_target_once_flag = ONCE_FLAG_INIT; + LLVMTargetRef radeon_llvm_get_r600_target(const char *triple) { LLVMTargetRef target = NULL; char *err_message = NULL; - init_r600_target(); + call_once(&init_r600_target_once_flag, init_r600_target); if (LLVMGetTargetFromTriple(triple, &target, &err_message)) { fprintf(stderr, "Cannot find target for triple %s ", triple); |