mirror of
https://github.com/thunderbrewhq/squall.git
synced 2025-12-12 02:22:30 +00:00
chore(atomic): use typedef aliases for better cross platform compat
This commit is contained in:
parent
653fa81853
commit
2200aab4c2
3 changed files with 14 additions and 6 deletions
|
|
@ -4,7 +4,7 @@
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int32_t SInterlockedDecrement(int32_t* ptr) {
|
ATOMIC32 SInterlockedDecrement(ATOMIC32* ptr) {
|
||||||
#if defined(WHOA_SYSTEM_WIN)
|
#if defined(WHOA_SYSTEM_WIN)
|
||||||
return InterlockedDecrement(ptr);
|
return InterlockedDecrement(ptr);
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -14,7 +14,7 @@ int32_t SInterlockedDecrement(int32_t* ptr) {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t SInterlockedIncrement(int32_t* ptr) {
|
ATOMIC32 SInterlockedIncrement(ATOMIC32* ptr) {
|
||||||
#if defined(WHOA_SYSTEM_WIN)
|
#if defined(WHOA_SYSTEM_WIN)
|
||||||
return InterlockedIncrement(ptr);
|
return InterlockedIncrement(ptr);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,16 @@
|
||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
|
||||||
int32_t SInterlockedDecrement(int32_t* ptr);
|
#if defined(WHOA_SYSTEM_WIN)
|
||||||
|
typedef long ATOMIC32;
|
||||||
|
#endif
|
||||||
|
|
||||||
int32_t SInterlockedIncrement(int32_t* ptr);
|
#if defined(WHOA_SYSTEM_MAC) || defined(WHOA_SYSTEM_LINUX)
|
||||||
|
typedef int32_t ATOMIC32;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
ATOMIC32 SInterlockedDecrement(ATOMIC32* ptr);
|
||||||
|
|
||||||
|
ATOMIC32 SInterlockedIncrement(ATOMIC32* ptr);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
TEST_CASE("SInterlockedDecrement", "[atomic]") {
|
TEST_CASE("SInterlockedDecrement", "[atomic]") {
|
||||||
SECTION("decrements value") {
|
SECTION("decrements value") {
|
||||||
int32_t value = 1;
|
ATOMIC32 value = 1;
|
||||||
auto decremented = SInterlockedDecrement(&value);
|
auto decremented = SInterlockedDecrement(&value);
|
||||||
CHECK(value == 0);
|
CHECK(value == 0);
|
||||||
CHECK(decremented == 0);
|
CHECK(decremented == 0);
|
||||||
|
|
@ -12,7 +12,7 @@ TEST_CASE("SInterlockedDecrement", "[atomic]") {
|
||||||
|
|
||||||
TEST_CASE("SInterlockedIncrement", "[atomic]") {
|
TEST_CASE("SInterlockedIncrement", "[atomic]") {
|
||||||
SECTION("increments value") {
|
SECTION("increments value") {
|
||||||
int32_t value = { 1 };
|
ATOMIC32 value = 1;
|
||||||
auto incremented = SInterlockedIncrement(&value);
|
auto incremented = SInterlockedIncrement(&value);
|
||||||
CHECK(value == 2);
|
CHECK(value == 2);
|
||||||
CHECK(incremented == 2);
|
CHECK(incremented == 2);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue