diff options
| author | gingerBill <bill@gingerbill.org> | 2023-01-16 15:09:29 +0000 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2023-01-16 15:09:29 +0000 |
| commit | e488cf460193e213d418efead104d4e0c1afd9c2 (patch) | |
| tree | 357fdd6b62acaa8094772c7cab1c3686a85e2380 /src/llvm_backend.cpp | |
| parent | 5d397804f7c02a2a71a10dd3af2f59a1bb3b4a10 (diff) | |
Enforce atomic on hasher id
Diffstat (limited to 'src/llvm_backend.cpp')
| -rw-r--r-- | src/llvm_backend.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/llvm_backend.cpp b/src/llvm_backend.cpp index b3364b89e..bc8056ec9 100644 --- a/src/llvm_backend.cpp +++ b/src/llvm_backend.cpp @@ -304,10 +304,10 @@ gb_internal lbValue lb_hasher_proc_for_type(lbModule *m, Type *type) { return {(*found)->value, (*found)->type}; } - static u32 proc_index = 0; + static std::atomic<u32> proc_index = 0; char buf[32] = {}; - isize n = gb_snprintf(buf, 32, "__$hasher%u", ++proc_index); + isize n = gb_snprintf(buf, 32, "__$hasher%u", 1+proc_index.fetch_add(1)); char *str = gb_alloc_str_len(permanent_allocator(), buf, n-1); String proc_name = make_string_c(str); |