Skip to content

Commit

Permalink
attempt on linux
Browse files Browse the repository at this point in the history
  • Loading branch information
ziaptos committed May 29, 2024
1 parent 77db831 commit 0a80299
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
1 change: 1 addition & 0 deletions src/binfile_utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <memory>
#include <string>
#include <vector>
#include <cstring>

#include "fileloader.hpp"

Expand Down
2 changes: 2 additions & 0 deletions src/logger.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@

// C++ Header File(s)
#include <fstream>
#include <chrono>
#include <iomanip>
#include <iostream>
#include <sstream>
#include <string>
Expand Down
1 change: 1 addition & 0 deletions src/naf.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once

#include <cstdint>
#include <cstring>

static inline std::uint64_t NAFTable[1024];

Expand Down
12 changes: 6 additions & 6 deletions src/spinlock.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace aptos
class [[nodiscard]] spinlock
{
public:
using lockable_type = std::atomic_flag;
using lockable_type = std::atomic_uint;

[[nodiscard]] constexpr spinlock() noexcept = default;

Expand All @@ -17,23 +17,23 @@ class [[nodiscard]] spinlock

void lock() noexcept
{
while (lockable_.test_and_set(std::memory_order_acquire))
while (lockable_.exchange(1u, std::memory_order_acquire))
{
while (lockable_.test(std::memory_order_relaxed))
while (lockable_.load(std::memory_order_relaxed))
{
}
}
}

bool try_lock() noexcept
{
return lockable_.test_and_set(std::memory_order_acquire);
return lockable_.exchange(1u, std::memory_order_acquire);
}

void unlock() noexcept { lockable_.clear(std::memory_order_release); }
void unlock() noexcept { lockable_.store(0u, std::memory_order_release); }

private:
std::atomic_flag lockable_{};
std::atomic_uint lockable_{0u};
};

} // namespace aptos

0 comments on commit 0a80299

Please sign in to comment.