-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
OMP symbol mangling nim-lang/Nim#9365 and nim-lang/Nim#9366
- Loading branch information
Showing
1 changed file
with
21 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Copyright (c) 2018 Mamy André-Ratsimbazafy | ||
# Distributed under the Apache v2 License (license terms are at http://www.apache.org/licenses/LICENSE-2.0). | ||
# This file may not be copied, modified, or distributed except according to those terms. | ||
|
||
# Compile-time name mangling for OpenMP thresholds | ||
# Workaround https://github.com/nim-lang/Nim/issues/9365 | ||
# and https://github.com/nim-lang/Nim/issues/9366 | ||
import random | ||
from strutils import toHex | ||
|
||
var mangling_rng {.compileTime.} = initRand(0x1337DEEDBEAF) | ||
var current_suffix {.compileTime.} = "" | ||
|
||
proc omp_suffix*(genNew: static bool = false): static string = | ||
## genNew: | ||
## if false, return the last suffix | ||
## else return a fresh one | ||
|
||
if genNew: | ||
current_suffix = mangling_rng.rand(high(uint32)).toHex | ||
result = current_suffix |