diff options
author | crupest <crupest@outlook.com> | 2021-06-10 11:43:47 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2021-06-10 11:43:47 +0800 |
commit | fcf8662eba1813e372706f02d6f30e66d04a121d (patch) | |
tree | 5226c122907762b98e81b24a1bba5585532f4433 /works/life | |
parent | bfd0f33af41ac2d5f26d597eac80070911c945a5 (diff) | |
parent | 91ec864a9c8e023f9f87d1c079a1cd8024844a7a (diff) | |
download | crupest-fcf8662eba1813e372706f02d6f30e66d04a121d.tar.gz crupest-fcf8662eba1813e372706f02d6f30e66d04a121d.tar.bz2 crupest-fcf8662eba1813e372706f02d6f30e66d04a121d.zip |
import(life): Merge branch 'main' of https://github.com/crupest/life
Diffstat (limited to 'works/life')
-rw-r--r-- | works/life/operating-system-experiment/CMakeLists.txt | 2 | ||||
-rw-r--r-- | works/life/operating-system-experiment/Interlocked.cpp | 16 | ||||
-rw-r--r-- | works/life/operating-system-experiment/Interlocked.hpp | 10 |
3 files changed, 27 insertions, 1 deletions
diff --git a/works/life/operating-system-experiment/CMakeLists.txt b/works/life/operating-system-experiment/CMakeLists.txt index 139d2ba..bd50319 100644 --- a/works/life/operating-system-experiment/CMakeLists.txt +++ b/works/life/operating-system-experiment/CMakeLists.txt @@ -9,7 +9,7 @@ set(CMAKE_CXX_STANDARD 17) find_package(fmt CONFIG REQUIRED)
find_package(Microsoft.GSL CONFIG REQUIRED)
-add_library(cru_system SHARED Thread.cpp Mutex.cpp)
+add_library(cru_system SHARED Thread.cpp Mutex.cpp Interlocked.cpp)
target_link_libraries(cru_system PUBLIC Microsoft.GSL::GSL fmt::fmt)
target_compile_definitions(cru_system PUBLIC CRU_EXPORT_API)
if(UNIX)
diff --git a/works/life/operating-system-experiment/Interlocked.cpp b/works/life/operating-system-experiment/Interlocked.cpp new file mode 100644 index 0000000..4f224e4 --- /dev/null +++ b/works/life/operating-system-experiment/Interlocked.cpp @@ -0,0 +1,16 @@ +#include "Interlocked.hpp"
+
+#ifdef CRU_WINDOWS
+#include <Windows.h>
+#else
+#endif
+
+namespace cru {
+void InterlockedIncrease(volatile long long *v) {
+#ifdef CRU_WINDOWS
+ InterlockedIncrement64(v);
+#else
+
+#endif
+}
+} // namespace cru
diff --git a/works/life/operating-system-experiment/Interlocked.hpp b/works/life/operating-system-experiment/Interlocked.hpp new file mode 100644 index 0000000..1151e39 --- /dev/null +++ b/works/life/operating-system-experiment/Interlocked.hpp @@ -0,0 +1,10 @@ +#ifndef HRADER_INTERLOCKED_H
+#define HRADER_INTERLOCKED_H
+
+#include "Base.h"
+
+namespace cru {
+CRU_API void InterlockedIncrease(volatile long long *v);
+}
+
+#endif
|