Skip to content

Commit

Permalink
linux compile fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
inolen committed Apr 22, 2016
1 parent 54825cc commit 4305af7
Show file tree
Hide file tree
Showing 11 changed files with 97 additions and 23 deletions.
2 changes: 2 additions & 0 deletions src/core/memory.h
@@ -1,6 +1,8 @@
#ifndef REDREAM_MEMORY_H
#define REDREAM_MEMORY_H

#include <string.h>

namespace re {

#if PLATFORM_WINDOWS
Expand Down
14 changes: 14 additions & 0 deletions src/hw/aica/aica.cc
Expand Up @@ -13,8 +13,15 @@ enum {
AICA_CLOCK_FREQ = 22579200,
};

namespace re {
namespace hw {
namespace aica {

template <>
uint32_t AICA::ReadWave(uint32_t addr);
}
}
}

AICA::AICA(Dreamcast &dc)
: Device(dc),
Expand Down Expand Up @@ -94,6 +101,10 @@ T AICA::ReadWave(uint32_t addr) {
return re::load<T>(&wave_ram_[addr]);
}

namespace re {
namespace hw {
namespace aica {

template <>
uint32_t AICA::ReadWave(uint32_t addr) {
// FIXME temp hacks to get Crazy Taxi 1 booting
Expand All @@ -118,6 +129,9 @@ uint32_t AICA::ReadWave(uint32_t addr) {

return re::load<uint32_t>(&wave_ram_[addr]);
}
}
}
}

template <typename T>
void AICA::WriteWave(uint32_t addr, T value) {
Expand Down
42 changes: 42 additions & 0 deletions src/hw/dreamcast.cc
@@ -0,0 +1,42 @@
#include "hw/sh4/sh4.h"
#include "hw/arm7/arm7.h"
#include "hw/aica/aica.h"
#include "hw/gdrom/gdrom.h"
#include "hw/holly/holly.h"
#include "hw/holly/pvr2.h"
#include "hw/holly/tile_accelerator.h"
#include "hw/maple/maple.h"
#include "hw/dreamcast.h"
#include "hw/memory.h"

using namespace re;
using namespace re::hw;
using namespace re::hw::aica;
using namespace re::hw::arm7;
using namespace re::hw::gdrom;
using namespace re::hw::holly;
using namespace re::hw::maple;
using namespace re::hw::sh4;
using namespace re::renderer;

Dreamcast::Dreamcast(renderer::Backend *rb) {
sh4 = new SH4(*this);
arm7 = new ARM7(*this);
aica = new AICA(*this);
holly = new Holly(*this);
gdrom = new GDROM(*this);
maple = new Maple(*this);
pvr = new PVR2(*this);
ta = new TileAccelerator(*this, rb);
}

Dreamcast::~Dreamcast() {
delete sh4;
delete arm7;
delete aica;
delete holly;
delete gdrom;
delete maple;
delete pvr;
delete ta;
}
2 changes: 1 addition & 1 deletion src/hw/sh4/sh4_types.h
Expand Up @@ -76,7 +76,7 @@ union DMAOR_T {
// control register area (0xfe000000 - 0xffffffff) seems to actually only
// represent 64 x 256 byte blocks of memory. the block index is represented
// by bits 17-24 and the block offset by bits 2-7
#define SH4_REG_OFFSET(addr) ((addr & 0x1fe0000) >> 11) | ((addr & 0xfc) >> 2)
#define SH4_REG_OFFSET(addr) (((addr & 0x1fe0000) >> 11) | ((addr & 0xfc) >> 2))

enum {
#define SH4_REG(addr, name, flags, default, reset, sleep, standby, type) \
Expand Down
1 change: 1 addition & 0 deletions src/jit/backend/x64/x64_emitter.cc
@@ -1,4 +1,5 @@
#include <math.h>
#include "core/assert.h"
#include "core/math.h"
#include "core/memory.h"
#include "core/profiler.h"
Expand Down
5 changes: 5 additions & 0 deletions src/jit/ir/ir_reader.cc
Expand Up @@ -154,6 +154,11 @@ bool IRReader::ParseType(IRLexer &lex, IRBuilder &builder, ValueType *type) {
}

bool IRReader::ParseOp(IRLexer &lex, IRBuilder &builder, Op *op) {
if (lex.tok() != TOK_IDENTIFIER) {
LOG_INFO("Unexpected token %d when parsing op");
return false;
}

const char *op_str = lex.val().s;

// match token against opnames
Expand Down
1 change: 1 addition & 0 deletions src/jit/ir/passes/load_store_elimination_pass.cc
@@ -1,3 +1,4 @@
#include "core/memory.h"
#include "jit/ir/passes/load_store_elimination_pass.h"

using namespace re::jit::ir;
Expand Down
44 changes: 25 additions & 19 deletions src/jit/ir/passes/pass_stats.cc
@@ -1,5 +1,5 @@
#include <vector>
#include "core/assert.h"
#include "core/string.h"
#include "jit/ir/passes/pass_stats.h"

using namespace re::jit::ir;
Expand All @@ -10,29 +10,31 @@ namespace jit {
namespace ir {
namespace passes {

static std::vector<const Stat *> *s_stats = nullptr;
static Stat *s_head_stat;

static void RegisterStat(const Stat *stat) {
// lazily initialize to avoid static initialization ordering problems
if (!s_stats) {
s_stats = new std::vector<const Stat *>();
}

s_stats->push_back(stat);
static void RegisterStat(Stat *stat) {
stat->next = s_head_stat;
s_head_stat = stat;
}

static void UnregisterStat(const Stat *stat) {
auto it = std::find(s_stats->begin(), s_stats->end(), stat);
CHECK_NE(it, s_stats->end());
s_stats->erase(it);
static void UnregisterStat(Stat *stat) {
Stat **tmp = &s_head_stat;

while (*tmp) {
Stat **next = &(*tmp)->next;

if (!s_stats->size()) {
delete s_stats;
s_stats = nullptr;
if (*tmp == stat) {
*tmp = *next;
break;
}

tmp = next;
}
}

Stat::Stat(const char *desc) : desc(desc), n(0) { RegisterStat(this); }
Stat::Stat(const char *desc) : desc(desc), n(0), next(nullptr) {
RegisterStat(this);
}

Stat::~Stat() { UnregisterStat(this); }

Expand All @@ -42,13 +44,17 @@ void DumpStats() {
LOG_INFO("===-----------------------------------------------------===");

int w = 0;
for (auto stat : *s_stats) {
Stat *stat = s_head_stat;
while (stat) {
int l = static_cast<int>(strlen(stat->desc));
w = std::max(l, w);
stat = stat->next;
}

for (auto stat : *s_stats) {
stat = s_head_stat;
while (stat) {
LOG_INFO("%-*s %d", w, stat->desc, stat->n);
stat = stat->next;
}
}
}
Expand Down
7 changes: 4 additions & 3 deletions src/jit/ir/passes/pass_stats.h
Expand Up @@ -9,12 +9,13 @@ namespace passes {
#define DEFINE_STAT(name, desc) static Stat name(desc);

struct Stat {
const char *desc;
int n;

Stat(const char *desc);
~Stat();

const char *desc;
int n;
Stat *next;

operator int() const { return n; }

const Stat &operator=(int v) {
Expand Down
1 change: 1 addition & 0 deletions src/renderer/gl_backend.cc
@@ -1,4 +1,5 @@
#include "core/assert.h"
#include "core/memory.h"
#include "core/profiler.h"
#include "renderer/gl_backend.h"

Expand Down
1 change: 1 addition & 0 deletions src/ui/window.cc
@@ -1,6 +1,7 @@
#include <stdlib.h>
#include <SDL.h>
#include "core/assert.h"
#include "core/memory.h"
#include "renderer/gl_backend.h"
#include "ui/imgui_impl.h"
#include "ui/microprofile_impl.h"
Expand Down

0 comments on commit 4305af7

Please sign in to comment.