mirror of
https://github.com/decompals/wibo.git
synced 2025-12-12 22:56:13 +00:00
Make liburing optional; rewrite CMakeLists.txt and enable LTO
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
#include "common.h"
|
||||
#include "context.h"
|
||||
|
||||
#include <atomic>
|
||||
#include <cstring>
|
||||
|
||||
namespace kernel32 {
|
||||
@@ -10,32 +11,33 @@ namespace kernel32 {
|
||||
LONG WIN_FUNC InterlockedIncrement(LONG volatile *Addend) {
|
||||
HOST_CONTEXT_GUARD();
|
||||
VERBOSE_LOG("InterlockedIncrement(%p)\n", Addend);
|
||||
return ++(*Addend);
|
||||
std::atomic_ref<LONG> a(*const_cast<LONG *>(Addend));
|
||||
return a.fetch_add(1, std::memory_order_seq_cst) + 1;
|
||||
}
|
||||
|
||||
LONG WIN_FUNC InterlockedDecrement(LONG volatile *Addend) {
|
||||
HOST_CONTEXT_GUARD();
|
||||
VERBOSE_LOG("InterlockedDecrement(%p)\n", Addend);
|
||||
return --(*Addend);
|
||||
std::atomic_ref<LONG> a(*const_cast<LONG *>(Addend));
|
||||
return a.fetch_sub(1, std::memory_order_seq_cst) - 1;
|
||||
}
|
||||
|
||||
LONG WIN_FUNC InterlockedExchange(LONG volatile *Target, LONG Value) {
|
||||
HOST_CONTEXT_GUARD();
|
||||
VERBOSE_LOG("InterlockedExchange(%p, %ld)\n", Target, static_cast<long>(Value));
|
||||
LONG initial = *Target;
|
||||
*Target = Value;
|
||||
return initial;
|
||||
std::atomic_ref<LONG> a(*const_cast<LONG *>(Target));
|
||||
return a.exchange(Value, std::memory_order_seq_cst);
|
||||
}
|
||||
|
||||
LONG WIN_FUNC InterlockedCompareExchange(LONG volatile *Destination, LONG Exchange, LONG Comperand) {
|
||||
HOST_CONTEXT_GUARD();
|
||||
VERBOSE_LOG("InterlockedCompareExchange(%p, %ld, %ld)\n", Destination, static_cast<long>(Exchange),
|
||||
static_cast<long>(Comperand));
|
||||
LONG original = *Destination;
|
||||
if (original == Comperand) {
|
||||
*Destination = Exchange;
|
||||
}
|
||||
return original;
|
||||
|
||||
std::atomic_ref<LONG> a(*const_cast<LONG *>(Destination));
|
||||
LONG expected = Comperand;
|
||||
a.compare_exchange_strong(expected, Exchange, std::memory_order_seq_cst);
|
||||
return expected;
|
||||
}
|
||||
|
||||
void WIN_FUNC InitializeSListHead(PSLIST_HEADER ListHead) {
|
||||
|
||||
Reference in New Issue
Block a user