Migrating atomic ops to std::atomic where possible and poly.

This commit is contained in:
Ben Vanik
2014-07-12 17:48:54 -07:00
parent bf882714d0
commit 9b78dd977b
18 changed files with 174 additions and 139 deletions

View File

@@ -4020,16 +4020,16 @@ int Translate_UNPACK(TranslationContext& ctx, Instr* i) {
}
uint32_t IntCode_ATOMIC_EXCHANGE_I32(IntCodeState& ics, const IntCode* i) {
auto address = (uint8_t*)ics.rf[i->src1_reg].u64;
auto address = (uint32_t*)ics.rf[i->src1_reg].u64;
auto new_value = ics.rf[i->src2_reg].u32;
auto old_value = xe_atomic_exchange_32(new_value, address);
auto old_value = poly::atomic_exchange(new_value, address);
ics.rf[i->dest_reg].u32 = old_value;
return IA_NEXT;
}
uint32_t IntCode_ATOMIC_EXCHANGE_I64(IntCodeState& ics, const IntCode* i) {
auto address = (uint8_t*)ics.rf[i->src1_reg].u64;
auto address = (uint64_t*)ics.rf[i->src1_reg].u64;
auto new_value = ics.rf[i->src2_reg].u64;
auto old_value = xe_atomic_exchange_64(new_value, address);
auto old_value = poly::atomic_exchange(new_value, address);
ics.rf[i->dest_reg].u64 = old_value;
return IA_NEXT;
}

View File

@@ -11,7 +11,6 @@
#define ALLOY_CORE_H_
// TODO(benvanik): move the common stuff into here?
#include <xenia/atomic.h>
#include <xenia/byte_order.h>
#include <xenia/config.h>
#include <xenia/logging.h>

View File

@@ -9,15 +9,17 @@
#include <alloy/tracing/tracer.h>
#include <atomic>
#include <alloy/tracing/channel.h>
namespace alloy {
namespace tracing {
volatile int next_thread_id_ = 0x10000000;
std::atomic<int> next_thread_id_(0x10000000);
Tracer::Tracer(Channel* channel) : channel_(channel) {
thread_id_ = xe_atomic_inc_32(&next_thread_id_);
thread_id_ = ++next_thread_id_;
}
Tracer::~Tracer() {}