-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
37 additions
and
29 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 |
---|---|---|
@@ -1,22 +1,29 @@ | ||
from atomics import MemoryOrder | ||
from std/atomics import MemoryOrder | ||
|
||
{.push stackTrace:off.} | ||
when defined(cpp): | ||
{.emit: "#include <atomic>".} | ||
proc atomic_load_explicit*[T](location: ptr T; order: MemoryOrder): T {.inline.} = | ||
{.emit: ["return std::atomic_load_explicit(reinterpret_cast<const std::atomic<", T, "> *>(", location, "), ", order, ");"].} | ||
proc atomic_store_explicit*[T](location: ptr T; desired: T; order: MemoryOrder) {.inline.} = | ||
{.emit: ["std::atomic_store_explicit(reinterpret_cast<std::atomic<", T, "> *>(", location, "), ", desired, ", ", order, ");"].} | ||
proc atomic_thread_fence*(order: MemoryOrder) {.inline.} = | ||
{.emit: ["std::atomic_thread_fence(", order, ");"].} | ||
when defined(isNimSkull): | ||
{.push, header: "<stdatomic.h>".} | ||
proc atomic_load_explicit*[T](location: ptr T; order: MemoryOrder): T {.importc.} | ||
proc atomic_store_explicit*[T](location: ptr T; desired: T; order: MemoryOrder = moSequentiallyConsistent) {.importc.} | ||
proc atomic_thread_fence*(order: MemoryOrder) {.importc: "atomic_thread_fence".} | ||
{.pop.} | ||
else: | ||
{.emit: "#include <stdatomic.h>".} | ||
proc atomic_load_explicit*[T](location: ptr T; order: MemoryOrder): T {.inline.} = | ||
{.emit: "return atomic_load_explicit((_Atomic `T` *)(`location`), `order`);".} | ||
proc atomic_store_explicit*[T](location: ptr T; desired: T; order: MemoryOrder) {.inline.} = | ||
{.emit: ["atomic_store_explicit((_Atomic ", T, " *)(", location, "), ", desired, ", ", order, ");"].} | ||
proc atomic_thread_fence*(order: MemoryOrder) {.inline.} = | ||
{.emit: ["atomic_thread_fence(", order, ");"].} | ||
{.pop.} | ||
{.push stackTrace:off.} | ||
when defined(cpp): | ||
{.emit: "#include <atomic>".} | ||
proc atomic_load_explicit*[T](location: ptr T; order: MemoryOrder): T {.inline.} = | ||
{.emit: ["return std::atomic_load_explicit(reinterpret_cast<const std::atomic<", T, "> *>(", location, "), ", order, ");"].} | ||
proc atomic_store_explicit*[T](location: ptr T; desired: T; order: MemoryOrder) {.inline.} = | ||
{.emit: ["std::atomic_store_explicit(reinterpret_cast<std::atomic<", T, "> *>(", location, "), ", desired, ", ", order, ");"].} | ||
proc atomic_thread_fence*(order: MemoryOrder) {.inline.} = | ||
{.emit: ["std::atomic_thread_fence(", order, ");"].} | ||
else: | ||
{.emit: "#include <stdatomic.h>".} | ||
proc atomic_load_explicit*[T](location: ptr T; order: MemoryOrder): T {.inline.} = | ||
{.emit: "return atomic_load_explicit((_Atomic `T` *)(`location`), `order`);".} | ||
proc atomic_store_explicit*[T](location: ptr T; desired: T; order: MemoryOrder) {.inline.} = | ||
{.emit: ["atomic_store_explicit((_Atomic ", T, " *)(", location, "), ", desired, ", ", order, ");"].} | ||
proc atomic_thread_fence*(order: MemoryOrder) {.inline.} = | ||
{.emit: ["atomic_thread_fence(", order, ");"].} | ||
{.pop.} | ||
|
||
export MemoryOrder |
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
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 |
---|---|---|
@@ -1,6 +1,5 @@ | ||
discard """ | ||
exitcode: 1 | ||
""" | ||
import balls | ||
import nimuring | ||
|
||
discard newQueue(3) | ||
expect NimuringError: | ||
discard newQueue(3) |
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 |
---|---|---|
@@ -1,6 +1,5 @@ | ||
discard """ | ||
exitcode: 1 | ||
""" | ||
import balls | ||
import nimuring | ||
|
||
discard newQueue(0) | ||
expect NimuringError: | ||
discard newQueue(0) |