summaryrefslogtreecommitdiff
path: root/Source/DSPSpy/Stubs.cpp
blob: 83f1bc1444ec010607a4742e89d18b3e6d8e7933 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
// Copyright 2003 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.

// Stubs to make DSPCore compile as part of DSPSpy.

/*
#include <stdio.h>
#include <stdlib.h>

#include <string>

#include "Thread.h"

void *AllocateMemoryPages(size_t size)
{
	return malloc(size);
}

void FreeMemoryPages(void *pages, size_t size)
{
	free(pages);
}

void WriteProtectMemory(void* ptr, size_t size, bool allowExecute)
{
}

void UnWriteProtectMemory(void* ptr, size_t size, bool allowExecute)
{
}

bool DSPHost_OnThread()
{
	return false;
}

// Well, it's just RAM right? :)
u8 DSPHost_ReadHostMemory(u32 address)
{
	u8 *ptr = (u8*)address;
	return *ptr;
}

void DSPHost_WriteHostMemory(u8 value, u32 addr) {}


void DSPHost_CodeLoaded(const u8 *code, int size)
{
}


namespace Common
{

CriticalSection::CriticalSection(int)
{
}
CriticalSection::~CriticalSection()
{
}

void CriticalSection::Enter()
{
}

void CriticalSection::Leave()
{
}

}  // namespace

namespace File
{

bool WriteStringToFile(bool text_file, const std::string &str, const char *filename)
{
	FILE *f = fopen(filename, text_file ? "w" : "wb");
	if (!f)
		return false;
	size_t len = str.size();
	if (len != fwrite(str.data(), 1, str.size(), f))
	{
		fclose(f);
		return false;
	}
	fclose(f);
	return true;
}

bool ReadFileToString(bool text_file, const char *filename, std::string &str)
{
	FILE *f = fopen(filename, text_file ? "r" : "rb");
	if (!f)
		return false;
	fseeko(f, 0, SEEK_END);
	size_t len = ftello(f);
	fseeko(f, 0, SEEK_SET);
	char *buf = new char[len + 1];
	buf[fread(buf, 1, len, f)] = 0;
	str = std::string(buf, len);
	fclose(f);
	delete [] buf;
	return true;
}

}

*/