mirror of
https://github.com/open-goal/jak-project
synced 2026-06-14 14:28:25 -04:00
Windows fixes
More Windows fixes
This commit is contained in:
+1
-4
@@ -5,10 +5,7 @@ project(jak)
|
||||
set(CMAKE_CXX_STANDARD 14)
|
||||
|
||||
# optimization level can be set here. Note that game/ overwrites this for building game C++ code.
|
||||
set(CMAKE_CXX_FLAGS "-O0 -ggdb -Wall \
|
||||
-Wextra -Wcast-align -Wcast-qual -Wdisabled-optimization -Wformat=2 \
|
||||
-Winit-self -Wmissing-include-dirs -Woverloaded-virtual \
|
||||
-Wredundant-decls -Wshadow -Wsign-promo ")
|
||||
set(CMAKE_CXX_FLAGS "")
|
||||
|
||||
# includes relative to top level jak-project folder
|
||||
include_directories(./)
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
{
|
||||
// See https://go.microsoft.com/fwlink/?linkid=834763 for more information about this file.
|
||||
"configurations": [
|
||||
{
|
||||
"name": "x64-Debug",
|
||||
"generator": "Ninja",
|
||||
"configurationType": "Debug",
|
||||
"inheritEnvironments": [ "msvc_x64_x64" ],
|
||||
"buildRoot": "${projectDir}\\out\\build\\${name}",
|
||||
"installRoot": "${projectDir}\\out\\install\\${name}",
|
||||
"cmakeCommandArgs": "",
|
||||
"buildCommandArgs": "",
|
||||
"ctestCommandArgs": ""
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -159,7 +159,7 @@ The "runtime" will be a replacement for all of the C/C++ code of the original ga
|
||||
- [x] GOAL Linker
|
||||
- [ ] PS2-specific hardware initialization as required by Sony libraries
|
||||
- [x] GOAL "kheap" allocator
|
||||
- [ ] Memory card interface
|
||||
- [ ] Memory card interfaces
|
||||
- [x] GOAL printf (called `format`) implementation
|
||||
- [x] GOAL hash/symbol table implementation
|
||||
- [x] Implementation of some built-in GOAL methods/functions
|
||||
@@ -172,7 +172,7 @@ The "runtime" will be a replacement for all of the C/C++ code of the original ga
|
||||
- [ ] Ramdisk stuff (implemented but totally untested)
|
||||
- The "989_snd" sound driver (no progress has been made here, the rough plan is to do a high level emulation of the sound system)
|
||||
- Sony libraries
|
||||
- [x] SIF (interface between EE/IOP for sending data, receiving data, and making remote procedure calls)
|
||||
- [x] SIF (interfaces between EE/IOP for sending data, receiving data, and making remote procedure calls)
|
||||
- [x] IOP Kernel (single-processor non-preemptive multitasking)
|
||||
- [x] stubs for stuff that doesn't really matter
|
||||
|
||||
|
||||
@@ -227,35 +227,35 @@ std::string Type::print_method_info() const {
|
||||
NoneType::NoneType() : Type("", "none", false) {}
|
||||
|
||||
bool NoneType::is_reference() const {
|
||||
throw std::runtime_error("is_reference called on NoneType");
|
||||
throw std::exception("is_reference called on NoneType");
|
||||
}
|
||||
|
||||
int NoneType::get_load_size() const {
|
||||
throw std::runtime_error("get_load_size called on NoneType");
|
||||
throw std::exception("get_load_size called on NoneType");
|
||||
}
|
||||
|
||||
bool NoneType::get_load_signed() const {
|
||||
throw std::runtime_error("get_load_size called on NoneType");
|
||||
throw std::exception("get_load_size called on NoneType");
|
||||
}
|
||||
|
||||
int NoneType::get_size_in_memory() const {
|
||||
throw std::runtime_error("get_size_in_memory called on NoneType");
|
||||
throw std::exception("get_size_in_memory called on NoneType");
|
||||
}
|
||||
|
||||
RegKind NoneType::get_preferred_reg_kind() const {
|
||||
throw std::runtime_error("get_preferred_reg_kind called on NoneType");
|
||||
throw std::exception("get_preferred_reg_kind called on NoneType");
|
||||
}
|
||||
|
||||
int NoneType::get_offset() const {
|
||||
throw std::runtime_error("get_offset called on NoneType");
|
||||
throw std::exception("get_offset called on NoneType");
|
||||
}
|
||||
|
||||
int NoneType::get_in_memory_alignment() const {
|
||||
throw std::runtime_error("get_in_memory_alignment called on NoneType");
|
||||
throw std::exception("get_in_memory_alignment called on NoneType");
|
||||
}
|
||||
|
||||
int NoneType::get_inline_array_alignment() const {
|
||||
throw std::runtime_error("get_inline_array_alignment called on NoneType");
|
||||
throw std::exception("get_inline_array_alignment called on NoneType");
|
||||
}
|
||||
|
||||
std::string NoneType::print() const {
|
||||
|
||||
@@ -32,7 +32,7 @@ Type* TypeSystem::add_type(const std::string& name, std::unique_ptr<Type> type)
|
||||
// update the type
|
||||
m_types[name] = std::move(type);
|
||||
} else {
|
||||
throw std::runtime_error("Type was redefined with throw_on_redefine set.");
|
||||
throw std::exception("Type was redefined with throw_on_redefine set.");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -43,13 +43,13 @@ Type* TypeSystem::add_type(const std::string& name, std::unique_ptr<Type> type)
|
||||
if (m_forward_declared_types.find(type->get_parent()) != m_forward_declared_types.end()) {
|
||||
fmt::print("[TypeSystem] Type {} has incompletely defined parent {}\n", type->get_name(),
|
||||
type->get_parent());
|
||||
throw std::runtime_error("add_type failed");
|
||||
throw std::exception("add_type failed");
|
||||
}
|
||||
|
||||
if (m_types.find(type->get_parent()) == m_types.end()) {
|
||||
fmt::print("[TypeSystem] Type {} has undefined parent {}\n", type->get_name(),
|
||||
type->get_parent());
|
||||
throw std::runtime_error("add_type failed");
|
||||
throw std::exception("add_type failed");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -135,7 +135,7 @@ TypeSpec TypeSystem::make_typespec(const std::string& name) {
|
||||
return TypeSpec(name);
|
||||
} else {
|
||||
fmt::print("[TypeSystem] The type {} is unknown.\n", name);
|
||||
throw std::runtime_error("make_typespec failed");
|
||||
throw std::exception("make_typespec failed");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -199,7 +199,7 @@ Type* TypeSystem::lookup_type(const std::string& name) {
|
||||
fmt::print("[TypeSystem] The type {} is not defined.\n", name);
|
||||
}
|
||||
|
||||
throw std::runtime_error("lookup_type failed");
|
||||
throw std::exception("lookup_type failed");
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -254,7 +254,7 @@ MethodInfo TypeSystem::add_method(Type* type, const std::string& method_name, co
|
||||
method_name, type->get_name(), existing_info.type.print(), ts.print());
|
||||
// unlike type re-definition, method re-definition is almost certain to go wrong.
|
||||
// probably better to give up.
|
||||
throw std::runtime_error("method redefinition");
|
||||
throw std::exception("method redefinition");
|
||||
}
|
||||
|
||||
return existing_info;
|
||||
@@ -278,7 +278,7 @@ MethodInfo TypeSystem::add_new_method(Type* type, const TypeSpec& ts) {
|
||||
"[TypeSystem] The new method of {} was originally defined as {}, but has been redefined "
|
||||
"as {}\n",
|
||||
type->get_name(), existing.type.print(), ts.print());
|
||||
throw std::runtime_error("add_new_method failed");
|
||||
throw std::exception("add_new_method failed");
|
||||
}
|
||||
|
||||
return existing;
|
||||
@@ -317,7 +317,7 @@ MethodInfo TypeSystem::lookup_method(const std::string& type_name, const std::st
|
||||
}
|
||||
|
||||
fmt::print("[TypeSystem] The method {} of type {} could not be found.\n", method_name, type_name);
|
||||
throw std::runtime_error("lookup_method failed");
|
||||
throw std::exception("lookup_method failed");
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -345,7 +345,7 @@ MethodInfo TypeSystem::lookup_new_method(const std::string& type_name) {
|
||||
}
|
||||
|
||||
fmt::print("[TypeSystem] The new method of type {} could not be found.\n", type_name);
|
||||
throw std::runtime_error("lookup_new_method failed");
|
||||
throw std::exception("lookup_new_method failed");
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -420,7 +420,7 @@ void TypeSystem::assert_field_offset(const std::string& type_name,
|
||||
if (field.offset() != offset) {
|
||||
fmt::print("[TypeSystem] assert_field_offset({}, {}, {}) failed - got {}\n", type_name,
|
||||
field_name, offset);
|
||||
throw std::runtime_error("assert_field_offset failed");
|
||||
throw std::exception("assert_field_offset failed");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -436,7 +436,7 @@ int TypeSystem::add_field_to_type(StructureType* type,
|
||||
int offset_override) {
|
||||
if (type->lookup_field(field_name, nullptr)) {
|
||||
fmt::print("[TypeSystem] Type {} already has a field named {}\n", type->get_name(), field_name);
|
||||
throw std::runtime_error("add_field_to_type duplicate field names");
|
||||
throw std::exception("add_field_to_type duplicate field names");
|
||||
}
|
||||
|
||||
// first, construct the field
|
||||
@@ -467,7 +467,7 @@ int TypeSystem::add_field_to_type(StructureType* type,
|
||||
"[TypeSystem] Tried to overwrite offset of field to be {}, but it is not aligned "
|
||||
"correctly\n",
|
||||
offset);
|
||||
throw std::runtime_error("add_field_to_type bad offset_override");
|
||||
throw std::exception("add_field_to_type bad offset_override");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -649,7 +649,7 @@ Field TypeSystem::lookup_field(const std::string& type_name, const std::string&
|
||||
Field field;
|
||||
if (!type->lookup_field(field_name, &field)) {
|
||||
fmt::print("[TypeSystem] Type {} has no field named {}\n", type_name, field_name);
|
||||
throw std::runtime_error("lookup_field failed");
|
||||
throw std::exception("lookup_field failed");
|
||||
}
|
||||
return field;
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ class TypeSystem {
|
||||
auto x = lookup_type(type_name);
|
||||
T* result = dynamic_cast<T*>(x);
|
||||
if (!result) {
|
||||
throw std::runtime_error("Failed to get " + type_name + " as the right type");
|
||||
throw std::exception("Failed to get the right type");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -272,7 +272,7 @@ void LinkedObjectFile::append_word_to_string(std::string& dest, const LinkedWord
|
||||
sprintf(buff, " .sym-off 0x%x %s\n", word.data >> 16, word.symbol_name.c_str());
|
||||
break;
|
||||
default:
|
||||
throw std::runtime_error("nyi");
|
||||
throw std::exception("nyi");
|
||||
}
|
||||
|
||||
dest += buff;
|
||||
|
||||
@@ -134,7 +134,7 @@ static uint32_t c_symlink2(LinkedObjectFile& f,
|
||||
word_kind = LinkedWord::TYPE_PTR;
|
||||
break;
|
||||
default:
|
||||
throw std::runtime_error("unhandled SymbolLinkKind");
|
||||
throw std::exception("unhandled SymbolLinkKind");
|
||||
}
|
||||
|
||||
f.symbol_link_word(seg_id, code_ptr_offset - initial_offset, name, word_kind);
|
||||
@@ -191,7 +191,7 @@ static uint32_t c_symlink3(LinkedObjectFile& f,
|
||||
word_kind = LinkedWord::TYPE_PTR;
|
||||
break;
|
||||
default:
|
||||
throw std::runtime_error("unhandled SymbolLinkKind");
|
||||
throw std::exception("unhandled SymbolLinkKind");
|
||||
}
|
||||
|
||||
f.symbol_link_word(seg, code_ptr - initial_offset, name, word_kind);
|
||||
|
||||
@@ -16,7 +16,7 @@ std::string combine_path(const std::string& parent, const std::string& child) {
|
||||
|
||||
std::vector<uint8_t> read_binary_file(const std::string& filename) {
|
||||
auto fp = fopen(filename.c_str(), "rb");
|
||||
if(!fp) throw std::runtime_error("File " + filename + " cannot be opened");
|
||||
if(!fp) throw std::exception("File cannot be opened");
|
||||
fseek(fp, 0, SEEK_END);
|
||||
auto len = ftell(fp);
|
||||
rewind(fp);
|
||||
@@ -25,7 +25,7 @@ std::vector<uint8_t> read_binary_file(const std::string& filename) {
|
||||
data.resize(len);
|
||||
|
||||
if(fread(data.data(), len, 1, fp) != 1) {
|
||||
throw std::runtime_error("File " + filename + " cannot be read");
|
||||
throw std::exception("File cannot be read");
|
||||
}
|
||||
|
||||
return data;
|
||||
@@ -75,7 +75,7 @@ void write_text_file(const std::string& file_name, const std::string& text) {
|
||||
FILE* fp = fopen(file_name.c_str(), "w");
|
||||
if(!fp) {
|
||||
printf("Failed to fopen %s\n", file_name.c_str());
|
||||
throw std::runtime_error("Failed to open file");
|
||||
throw std::exception("Failed to open file");
|
||||
}
|
||||
fprintf(fp, "%s\n", text.c_str());
|
||||
fclose(fp);
|
||||
|
||||
@@ -72,7 +72,7 @@ void Form::buildStringSimple(std::string &str) {
|
||||
str.append(*token.str);
|
||||
break;
|
||||
default:
|
||||
throw std::runtime_error("buildStringSimple unknown token kind");
|
||||
throw std::exception("buildStringSimple unknown token kind");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -110,7 +110,7 @@ void Form::toTokenList(std::vector<FormToken> &tokens) {
|
||||
tokens.emplace_back(TokenKind::EMPTY_PAIR);
|
||||
break;
|
||||
default:
|
||||
throw std::runtime_error("unhandled form type in buildSimpleString");
|
||||
throw std::exception("unhandled form type in buildSimpleString");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ struct FormToken {
|
||||
s.append(*str);
|
||||
break;
|
||||
default:
|
||||
throw std::runtime_error("toString unknown token kind");
|
||||
throw std::exception("toString unknown token kind");
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ int64_t Timer::getNs() {
|
||||
clock_gettime(CLOCK_MONOTONIC, &now);
|
||||
#elif _WIN32
|
||||
clock_gettime_monotonic(&now);
|
||||
#endif
|
||||
#endif;
|
||||
return (int64_t)(now.tv_nsec - _startTime.tv_nsec) +
|
||||
1000000000 * (now.tv_sec - _startTime.tv_sec);
|
||||
}
|
||||
}
|
||||
@@ -19,6 +19,8 @@ class Timer {
|
||||
int clock_gettime_monotonic(struct timespec* tv);
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/*!
|
||||
* Start the timer
|
||||
*/
|
||||
@@ -27,7 +29,7 @@ class Timer {
|
||||
/*!
|
||||
* Get milliseconds elapsed
|
||||
*/
|
||||
double getMs() { return (double)getNs() / 1.e6; }
|
||||
double getMs() { return (double)getNs() / 1.e6; }
|
||||
|
||||
double getUs() { return (double)getNs() / 1.e3; }
|
||||
|
||||
|
||||
+1
-5
@@ -1,9 +1,6 @@
|
||||
# We define our own compilation flags here.
|
||||
set(CMAKE_CXX_STANDARD 11)
|
||||
set(CMAKE_CXX_FLAGS "-O0 -ggdb -Wall \
|
||||
-Wextra -Wcast-align -Wcast-qual -Wdisabled-optimization -Wformat=2 \
|
||||
-Winit-self -Wmissing-include-dirs -Woverloaded-virtual \
|
||||
-Wredundant-decls -Wshadow -Wsign-promo ")
|
||||
set(CMAKE_CXX_FLAGS " ")
|
||||
|
||||
enable_language(ASM_NASM)
|
||||
set(RUNTIME_SOURCE
|
||||
@@ -55,4 +52,3 @@ add_executable(gk ${RUNTIME_SOURCE})
|
||||
# can be used to test other things.
|
||||
add_library(runtime ${RUNTIME_SOURCE})
|
||||
|
||||
target_link_libraries(gk pthread)
|
||||
+2
-2
@@ -40,7 +40,7 @@ struct Ptr {
|
||||
if (offset) {
|
||||
return (T*)(g_ee_main_mem + offset);
|
||||
} else {
|
||||
throw std::runtime_error("Ptr null dereference!");
|
||||
throw std::exception("Ptr null dereference!");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ struct Ptr {
|
||||
if (offset) {
|
||||
return *(T*)(g_ee_main_mem + offset);
|
||||
} else {
|
||||
throw std::runtime_error("Ptr null dereference!");
|
||||
throw std::exception("Ptr null dereference!");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* DONE!
|
||||
*/
|
||||
|
||||
#include <unistd.h>
|
||||
#include <io.h>
|
||||
#include <cstring>
|
||||
#include "common/common_types.h"
|
||||
#include "game/sce/libscf.h"
|
||||
@@ -13,7 +13,7 @@
|
||||
#include "kscheme.h"
|
||||
#include "ksocket.h"
|
||||
#include "klisten.h"
|
||||
|
||||
#include "Windows.h"
|
||||
using namespace ee;
|
||||
|
||||
// Level to load on boot
|
||||
@@ -135,7 +135,7 @@ void KernelCheckAndDispatch() {
|
||||
SendAck();
|
||||
}
|
||||
|
||||
usleep(1000); // todo - remove this
|
||||
Sleep(1000); // todo - remove this
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -264,7 +264,7 @@ uint32_t cross_seg_dist_link_v3(Ptr<uint8_t> link,
|
||||
} else if (size == 8) {
|
||||
*Ptr<int64_t>(offset_of_patch).c() = diff;
|
||||
} else {
|
||||
throw std::runtime_error("unknown size in cross_seg_dist_link_v3");
|
||||
throw std::exception("unknown size in cross_seg_dist_link_v3");
|
||||
}
|
||||
|
||||
return 1 + 3 * 4;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*!
|
||||
* @file kmemcard.cpp
|
||||
* Memory card interface. Very messy code.
|
||||
* Memory card interfaces. Very messy code.
|
||||
*/
|
||||
|
||||
//#include "ps2/SCE_MC.h"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*!
|
||||
* @file kmemcard.h
|
||||
* Memory card interface. Very messy code.
|
||||
* Memory card interfaces. Very messy code.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
+16
-16
@@ -338,10 +338,10 @@ s32 cvt_float(float x, s32 precision, s32* lead_char, char* buff_start, char* bu
|
||||
value = (char)rounder;
|
||||
} else if (!(ru32 >> 31)) { // sign bit
|
||||
value = 0;
|
||||
throw std::runtime_error("got very large exponent in rounding calculation");
|
||||
throw std::exception("got very large exponent in rounding calculation");
|
||||
} else {
|
||||
value = -1; // happens on NaN's
|
||||
// throw std::runtime_error("got negative sign bit in rounding calculation");
|
||||
// throw std::exception("got negative sign bit in rounding calculation");
|
||||
}
|
||||
|
||||
// place number at the end of the buffer and move pointer back
|
||||
@@ -386,10 +386,10 @@ s32 cvt_float(float x, s32 precision, s32* lead_char, char* buff_start, char* bu
|
||||
value = (char)next_int;
|
||||
} else if (!(ru32 >> 0x1f)) {
|
||||
value = 0;
|
||||
throw std::runtime_error("got very large exponent in rounding calculation");
|
||||
throw std::exception("got very large exponent in rounding calculation");
|
||||
} else {
|
||||
value = -1; // happens on NaN's
|
||||
// throw std::runtime_error("got negative sign bit in rounding calculation");
|
||||
// throw std::exception("got negative sign bit in rounding calculation");
|
||||
}
|
||||
*count_chrp = value + '0';
|
||||
count_chrp++;
|
||||
@@ -401,7 +401,7 @@ s32 cvt_float(float x, s32 precision, s32* lead_char, char* buff_start, char* bu
|
||||
// however, the rounding flag is always disabled and the rounding code doesn't work.
|
||||
if ((fraction_part != 0.f) && ((flags & 1) != 0)) {
|
||||
start_ptr = round(fraction_part, nullptr, start_ptr, count_chrp - 1, 0, lead_char);
|
||||
throw std::runtime_error("cvt_float called round!");
|
||||
throw std::exception("cvt_float called round!");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -553,7 +553,7 @@ char* kitoa(char* buffer, s64 value, u64 base, s32 length, char pad, u32 flag) {
|
||||
* uses C varags, but 128-bit varags don't work, so "format" always passes 0 for quadword printing.
|
||||
*/
|
||||
void kqtoa() {
|
||||
throw std::runtime_error("kqtoa not implemented");
|
||||
throw std::exception("kqtoa not implemented");
|
||||
}
|
||||
|
||||
struct format_struct {
|
||||
@@ -791,7 +791,7 @@ s32 format_impl(uint64_t* args) {
|
||||
}
|
||||
kstrinsert(output_ptr, pad, desired_length - print_len);
|
||||
} else {
|
||||
throw std::runtime_error("unsupported justify in format");
|
||||
throw std::exception("unsupported justify in format");
|
||||
// output_ptr = strend(output_ptr);
|
||||
// while(0 < (desired_length - print_len)) {
|
||||
// char pad = ' ';
|
||||
@@ -842,7 +842,7 @@ s32 format_impl(uint64_t* args) {
|
||||
kstrinsert(output_ptr, pad, desired_length - print_len);
|
||||
|
||||
} else {
|
||||
throw std::runtime_error("unsupported justify in format");
|
||||
throw std::exception("unsupported justify in format");
|
||||
// output_ptr = strend(output_ptr);
|
||||
// u32 l140 = 0;
|
||||
// while(l140 < (desired_length - print_len)) {
|
||||
@@ -883,7 +883,7 @@ s32 format_impl(uint64_t* args) {
|
||||
call_method_of_type(in, type, GOAL_PRINT_FUNC);
|
||||
}
|
||||
} else {
|
||||
throw std::runtime_error("failed to find symbol in format!");
|
||||
throw std::exception("failed to find symbol in format!");
|
||||
}
|
||||
}
|
||||
output_ptr = strend(output_ptr);
|
||||
@@ -904,7 +904,7 @@ s32 format_impl(uint64_t* args) {
|
||||
call_method_of_type(in, type, GOAL_INSPECT_FUNC);
|
||||
}
|
||||
} else {
|
||||
throw std::runtime_error("failed to find symbol in format!");
|
||||
throw std::exception("failed to find symbol in format!");
|
||||
}
|
||||
}
|
||||
output_ptr = strend(output_ptr);
|
||||
@@ -912,7 +912,7 @@ s32 format_impl(uint64_t* args) {
|
||||
|
||||
case 'Q': // not yet implemented. hopefully andy gavin finishes this one soon.
|
||||
case 'q':
|
||||
throw std::runtime_error("nyi q format string");
|
||||
throw std::exception("nyi q format string");
|
||||
break;
|
||||
|
||||
case 'X': // hex, 64 bit, pad padchar
|
||||
@@ -1009,7 +1009,7 @@ s32 format_impl(uint64_t* args) {
|
||||
precision = 4;
|
||||
float value;
|
||||
if (in < 0) {
|
||||
throw std::runtime_error("time seconds format error negative.\n");
|
||||
throw std::exception("time seconds format error negative.\n");
|
||||
} else {
|
||||
value = in;
|
||||
}
|
||||
@@ -1025,7 +1025,7 @@ s32 format_impl(uint64_t* args) {
|
||||
|
||||
default:
|
||||
MsgErr("format: unknown code 0x%02x\n", format_ptr[1]);
|
||||
throw std::runtime_error("format error");
|
||||
throw std::exception("format error");
|
||||
break;
|
||||
}
|
||||
format_ptr++;
|
||||
@@ -1067,13 +1067,13 @@ s32 format_impl(uint64_t* args) {
|
||||
*PrintPendingLocal3 = 0;
|
||||
return 0;
|
||||
} else if (type == *Ptr<Ptr<Type>>(s7.offset + FIX_SYM_FILE_STREAM_TYPE)) {
|
||||
throw std::runtime_error("FORMAT into a file stream not supported");
|
||||
throw std::exception("FORMAT into a file stream not supported");
|
||||
}
|
||||
}
|
||||
throw std::runtime_error("unknown format destination");
|
||||
throw std::exception("unknown format destination");
|
||||
return 0;
|
||||
}
|
||||
|
||||
throw std::runtime_error("how did we get here?");
|
||||
throw std::exception("how did we get here?");
|
||||
return 7;
|
||||
}
|
||||
@@ -13,6 +13,8 @@ constexpr u32 DEBUG_OUTPUT_BUFFER_SIZE = 0x80000;
|
||||
constexpr u32 DEBUG_PRINT_BUFFER_SIZE = 0x200000;
|
||||
constexpr u32 PRINT_BUFFER_SIZE = 0x2000;
|
||||
|
||||
#define __attribute__(A) /* do nothing */
|
||||
|
||||
///////////
|
||||
// SDATA
|
||||
///////////
|
||||
|
||||
@@ -124,7 +124,7 @@ u64 goal_malloc(u32 heap, u32 size, u32 flags, u32 name) {
|
||||
*/
|
||||
u64 alloc_from_heap(u32 heapSymbol, u32 type, s32 size) {
|
||||
if (size <= 0) {
|
||||
throw std::runtime_error("got <= 0 size allocation in alloc_from_heap!");
|
||||
throw std::exception("got <= 0 size allocation in alloc_from_heap!");
|
||||
}
|
||||
|
||||
// align to 16 bytes (part one)
|
||||
@@ -162,7 +162,7 @@ u64 alloc_from_heap(u32 heapSymbol, u32 type, s32 size) {
|
||||
|
||||
return kmalloc(*Ptr<Ptr<kheapinfo>>(heapSymbol), size, KMALLOC_MEMSET, gstr->data()).offset;
|
||||
} else if (heapOffset == FIX_SYM_PROCESS_TYPE) {
|
||||
throw std::runtime_error("this type of process allocation is not supported yet!\n");
|
||||
throw std::exception("this type of process allocation is not supported yet!\n");
|
||||
// allocate on current process heap
|
||||
// Ptr start = *ptr<Ptr>(getS6() + 0x4c + 8);
|
||||
// Ptr heapEnd = *ptr<Ptr>(getS6() + 0x4c + 4);
|
||||
@@ -178,7 +178,7 @@ u64 alloc_from_heap(u32 heapSymbol, u32 type, s32 size) {
|
||||
// alignedSize); return 0;
|
||||
// }
|
||||
} else if (heapOffset == FIX_SYM_SCRATCH) {
|
||||
throw std::runtime_error("this type of scratchpad allocation is not used!\n");
|
||||
throw std::exception("this type of scratchpad allocation is not used!\n");
|
||||
} else {
|
||||
memset(Ptr<u8>(heapSymbol).c(), 0, (size_t)alignedSize); // treat it as a stack address
|
||||
return heapSymbol;
|
||||
@@ -920,7 +920,7 @@ u64 call_method_of_type(u32 arg, Ptr<Type> type, u32 method_id) {
|
||||
(*type_tag).offset);
|
||||
}
|
||||
}
|
||||
// throw std::runtime_error("call_method_of_type failed!\n");
|
||||
// throw std::exception("call_method_of_type failed!\n");
|
||||
printf("[ERROR] call_method_of_type failed!\n");
|
||||
printf("type is %s\n", info(type->symbol)->str->data());
|
||||
return arg;
|
||||
@@ -958,7 +958,7 @@ u64 call_method_of_type_arg2(u32 arg, Ptr<Type> type, u32 method_id, u32 a1, u32
|
||||
(*type_tag).offset);
|
||||
}
|
||||
}
|
||||
throw std::runtime_error("call_method_of_type failed!\n");
|
||||
throw std::exception("call_method_of_type failed!\n");
|
||||
return arg;
|
||||
}
|
||||
|
||||
@@ -1779,7 +1779,7 @@ s32 InitHeapAndSymbol() {
|
||||
// setup deci2count for message counter.
|
||||
protoBlock.deci2count = intern_from_c("*deci-count*").cast<s32>();
|
||||
|
||||
// load stuff for the listener interface
|
||||
// load stuff for the listener interfaces
|
||||
InitListener();
|
||||
|
||||
// Do final initialization, including loading and initializing the engine.
|
||||
|
||||
@@ -343,6 +343,7 @@ uint32_t FS_LoadMusic(char* name, void* buffer) {
|
||||
(void)name;
|
||||
(void)buffer;
|
||||
assert(false);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// TODO FS_LoadSoundBank
|
||||
@@ -350,4 +351,5 @@ uint32_t FS_LoadSoundBank(char* name, void* buffer) {
|
||||
(void)name;
|
||||
(void)buffer;
|
||||
assert(false);
|
||||
return 0;
|
||||
}
|
||||
+26
-19
@@ -3,9 +3,10 @@
|
||||
* Setup and launcher for the runtime.
|
||||
*/
|
||||
|
||||
#include <unistd.h>
|
||||
#include <sys/mman.h>
|
||||
#include <io.h>
|
||||
#include <third-party\mman.h>
|
||||
#include <cstring>
|
||||
#include <Windows.h>
|
||||
|
||||
#include "runtime.h"
|
||||
#include "system/SystemThread.h"
|
||||
@@ -43,28 +44,32 @@ namespace {
|
||||
/*!
|
||||
* SystemThread function for running the DECI2 communication with the GOAL compiler.
|
||||
*/
|
||||
void deci2_runner(SystemThreadInterface& interface) {
|
||||
|
||||
|
||||
/*
|
||||
|
||||
void deci2_runner(SystemThreadInterface& interfaces) {
|
||||
// callback function so the server knows when to give up and shutdown
|
||||
std::function<bool()> shutdown_callback = [&]() { return interface.get_want_exit(); };
|
||||
std::function<bool()> shutdown_callback = [&]() { return interfaces.get_want_exit(); };
|
||||
|
||||
// create and register server
|
||||
Deci2Server server(shutdown_callback);
|
||||
ee::LIBRARY_sceDeci2_register(&server);
|
||||
// Deci2Server server(shutdown_callback);
|
||||
// ee::LIBRARY_sceDeci2_register(&server);
|
||||
|
||||
// now its ok to continue with initialization
|
||||
interface.initialization_complete();
|
||||
interfaces.initialization_complete();
|
||||
|
||||
// in our own thread, wait for the EE to register the first protocol driver
|
||||
printf("[DECI2] waiting for EE to register protos\n");
|
||||
server.wait_for_protos_ready();
|
||||
// then allow the server to accept connections
|
||||
if (!server.init()) {
|
||||
throw std::runtime_error("DECI2 server init failed");
|
||||
throw std::exception("DECI2 server init failed");
|
||||
}
|
||||
|
||||
printf("[DECI2] waiting for listener...\n");
|
||||
bool saw_listener = false;
|
||||
while (!interface.get_want_exit()) {
|
||||
while (!interfaces.get_want_exit()) {
|
||||
if (server.check_for_listener()) {
|
||||
if (!saw_listener) {
|
||||
printf("[DECI2] Connected!\n");
|
||||
@@ -74,10 +79,12 @@ void deci2_runner(SystemThreadInterface& interface) {
|
||||
server.run();
|
||||
} else {
|
||||
// no connection yet. Do a sleep so we don't spam checking the listener.
|
||||
usleep(50000);
|
||||
Sleep(1000);
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
// EE System
|
||||
constexpr int EE_MAIN_MEM_SIZE = 128 * (1 << 20); // 128 MB, same as PS2 TOOL
|
||||
@@ -95,7 +102,7 @@ constexpr int GOAL_ARGC = 4;
|
||||
/*!
|
||||
* SystemThread Function for the EE (PS2 Main CPU)
|
||||
*/
|
||||
void ee_runner(SystemThreadInterface& interface) {
|
||||
void ee_runner(SystemThreadInterface& interfaces) {
|
||||
// Allocate Main RAM. Must have execute enabled.
|
||||
if (EE_MEM_LOW_MAP) {
|
||||
g_ee_main_mem =
|
||||
@@ -109,7 +116,7 @@ void ee_runner(SystemThreadInterface& interface) {
|
||||
|
||||
if (g_ee_main_mem == (u8*)(-1)) {
|
||||
printf(" Failed to initialize main memory! %s\n", strerror(errno));
|
||||
interface.initialization_complete();
|
||||
interfaces.initialization_complete();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -118,7 +125,7 @@ void ee_runner(SystemThreadInterface& interface) {
|
||||
(double)EE_MAIN_MEM_SIZE / (1 << 20));
|
||||
|
||||
printf("[EE] Initialization complete!\n");
|
||||
interface.initialization_complete();
|
||||
interfaces.initialization_complete();
|
||||
|
||||
printf("[EE] Run!\n");
|
||||
memset((void*)g_ee_main_mem, 0, EE_MAIN_MEM_SIZE);
|
||||
@@ -145,13 +152,13 @@ void ee_runner(SystemThreadInterface& interface) {
|
||||
munmap(g_ee_main_mem, EE_MAIN_MEM_SIZE);
|
||||
|
||||
// after main returns, trigger a shutdown.
|
||||
interface.trigger_shutdown();
|
||||
interfaces.trigger_shutdown();
|
||||
}
|
||||
|
||||
/*!
|
||||
* SystemThread function for running the IOP (separate I/O Processor)
|
||||
*/
|
||||
void iop_runner(SystemThreadInterface& interface) {
|
||||
void iop_runner(SystemThreadInterface& interfaces) {
|
||||
IOP iop;
|
||||
printf("\n\n\n[IOP] Restart!\n");
|
||||
iop.reset_allocator();
|
||||
@@ -174,7 +181,7 @@ void iop_runner(SystemThreadInterface& interface) {
|
||||
// ssound
|
||||
// stream
|
||||
|
||||
interface.initialization_complete();
|
||||
interfaces.initialization_complete();
|
||||
|
||||
printf("[IOP] Wait for OVERLORD to be started...\n");
|
||||
iop.wait_for_overlord_start_cmd();
|
||||
@@ -195,7 +202,7 @@ void iop_runner(SystemThreadInterface& interface) {
|
||||
iop.signal_overlord_init_finish();
|
||||
|
||||
// IOP Kernel loop
|
||||
while (!interface.get_want_exit() && !iop.want_exit) {
|
||||
while (!interfaces.get_want_exit() && !iop.want_exit) {
|
||||
// the IOP kernel just runs at full blast, so we only run the IOP when the EE is waiting on the
|
||||
// IOP. Each time the EE is waiting on the IOP, it will run an iteration of the IOP kernel.
|
||||
iop.wait_run_iop();
|
||||
@@ -232,8 +239,8 @@ void exec_runtime(int argc, char** argv) {
|
||||
// step 3: start the EE!
|
||||
iop_thread.start(iop_runner);
|
||||
ee_thread.start(ee_runner);
|
||||
deci_thread.start(deci2_runner);
|
||||
|
||||
//deci_thread.start(deci2_runner);
|
||||
|
||||
// step 4: wait for EE to signal a shutdown, which will cause the DECI thread to join.
|
||||
deci_thread.join();
|
||||
// DECI has been killed, shutdown!
|
||||
|
||||
+13
-11
@@ -1,7 +1,7 @@
|
||||
/*!
|
||||
* @file deci2.cpp
|
||||
* Implementation of SCE DECI2 library.
|
||||
*/
|
||||
|
||||
|
||||
#include <cassert>
|
||||
#include <cstdio>
|
||||
@@ -19,9 +19,9 @@ Deci2Driver* sending_driver; // currently sending protocol drive
|
||||
::Deci2Server* server; // the server to send data to
|
||||
} // namespace
|
||||
|
||||
/*!
|
||||
|
||||
* Initialize the library.
|
||||
*/
|
||||
|
||||
void LIBRARY_INIT_sceDeci2() {
|
||||
// reset protocols
|
||||
for (auto& p : protocols) {
|
||||
@@ -34,7 +34,7 @@ void LIBRARY_INIT_sceDeci2() {
|
||||
|
||||
/*!
|
||||
* Run any pending requested sends.
|
||||
*/
|
||||
|
||||
void LIBRARY_sceDeci2_run_sends() {
|
||||
for (auto& prot : protocols) {
|
||||
if (prot.active && prot.pending_send == 'H') {
|
||||
@@ -49,7 +49,7 @@ void LIBRARY_sceDeci2_run_sends() {
|
||||
|
||||
/*!
|
||||
* Register a Deci2Server with this library.
|
||||
*/
|
||||
|
||||
void LIBRARY_sceDeci2_register(::Deci2Server* s) {
|
||||
server = s;
|
||||
}
|
||||
@@ -58,7 +58,7 @@ void LIBRARY_sceDeci2_register(::Deci2Server* s) {
|
||||
* Open a new socket with given protocol number and handler.
|
||||
* The "opt" pointer is passed to the handler function.
|
||||
* I don't know why it's like this.
|
||||
*/
|
||||
|
||||
s32 sceDeci2Open(u16 protocol, void* opt, void (*handler)(s32 event, s32 param, void* opt)) {
|
||||
server->lock();
|
||||
Deci2Driver drv;
|
||||
@@ -82,7 +82,7 @@ s32 sceDeci2Open(u16 protocol, void* opt, void (*handler)(s32 event, s32 param,
|
||||
|
||||
/*!
|
||||
* Deactivate a DECI2 protocol by socket descriptor.
|
||||
*/
|
||||
|
||||
s32 sceDeci2Close(s32 s) {
|
||||
assert(s - 1 < protocol_count);
|
||||
protocols[s - 1].active = false;
|
||||
@@ -91,7 +91,7 @@ s32 sceDeci2Close(s32 s) {
|
||||
|
||||
/*!
|
||||
* Start a send.
|
||||
*/
|
||||
|
||||
s32 sceDeci2ReqSend(s32 s, char dest) {
|
||||
assert(s - 1 < protocol_count);
|
||||
auto& proto = protocols[s - 1];
|
||||
@@ -102,7 +102,7 @@ s32 sceDeci2ReqSend(s32 s, char dest) {
|
||||
/*!
|
||||
* Do a receive from socket s into buf of size len.
|
||||
* Returns after data is copied.
|
||||
*/
|
||||
|
||||
s32 sceDeci2ExRecv(s32 s, void* buf, u16 len) {
|
||||
assert(s - 1 < protocol_count);
|
||||
protocols[s - 1].recv_size = len;
|
||||
@@ -118,7 +118,7 @@ s32 sceDeci2ExRecv(s32 s, void* buf, u16 len) {
|
||||
|
||||
/*!
|
||||
* Do a send.
|
||||
*/
|
||||
|
||||
s32 sceDeci2ExSend(s32 s, void* buf, u16 len) {
|
||||
assert(s - 1 < protocol_count);
|
||||
if (!sending_driver) {
|
||||
@@ -133,4 +133,6 @@ s32 sceDeci2ExSend(s32 s, void* buf, u16 len) {
|
||||
return len;
|
||||
}
|
||||
|
||||
} // namespace ee
|
||||
} // namespace ee
|
||||
|
||||
*/
|
||||
+2
-2
@@ -201,12 +201,12 @@ s32 CreateSema(SemaParam* param) {
|
||||
|
||||
s32 WaitSema(s32 sema) {
|
||||
(void)sema;
|
||||
throw std::runtime_error("NYI");
|
||||
throw std::exception("NYI");
|
||||
}
|
||||
|
||||
s32 SignalSema(s32 sema) {
|
||||
(void)sema;
|
||||
throw std::runtime_error("NYI");
|
||||
throw std::exception("NYI");
|
||||
}
|
||||
|
||||
s32 WakeupThread(s32 thid) {
|
||||
|
||||
+5
-5
@@ -6,33 +6,33 @@ namespace ee {
|
||||
s32 sceOpen(const char *filename, s32 flag) {
|
||||
(void)filename;
|
||||
(void)flag;
|
||||
throw std::runtime_error("sceOpen NYI");
|
||||
throw std::exception("sceOpen NYI");
|
||||
}
|
||||
|
||||
s32 sceClose(s32 fd) {
|
||||
(void)fd;
|
||||
throw std::runtime_error("sceClose NYI");
|
||||
throw std::exception("sceClose NYI");
|
||||
}
|
||||
|
||||
s32 sceRead(s32 fd, void *buf, s32 nbyte) {
|
||||
(void)fd;
|
||||
(void)buf;
|
||||
(void)nbyte;
|
||||
throw std::runtime_error("sceRead NYI");
|
||||
throw std::exception("sceRead NYI");
|
||||
}
|
||||
|
||||
s32 sceWrite(s32 fd, const void *buf, s32 nbyte) {
|
||||
(void)fd;
|
||||
(void)buf;
|
||||
(void)nbyte;
|
||||
throw std::runtime_error("sceWrite NYI");
|
||||
throw std::exception("sceWrite NYI");
|
||||
}
|
||||
|
||||
s32 sceLseek(s32 fd, s32 offset, s32 where) {
|
||||
(void)fd;
|
||||
(void)offset;
|
||||
(void)where;
|
||||
throw std::runtime_error("sceLseek NYI");
|
||||
throw std::exception("sceLseek NYI");
|
||||
}
|
||||
|
||||
int scePadPortOpen(int port, int slot, void* data) {
|
||||
|
||||
+21
-18
@@ -2,12 +2,11 @@
|
||||
* @file Deci2Server.cpp
|
||||
* Basic implementation of a DECI2 server.
|
||||
* Works with deci2.cpp (sceDeci2) to implement the networking on target
|
||||
*/
|
||||
|
||||
|
||||
#include <cstdio>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/tcp.h>
|
||||
#include <unistd.h>
|
||||
#include <Winsock2.h>
|
||||
#include <io.h>
|
||||
#include <cassert>
|
||||
#include <utility>
|
||||
|
||||
@@ -15,6 +14,8 @@
|
||||
#include "common/versions.h"
|
||||
#include "Deci2Server.h"
|
||||
|
||||
typedef int socklen_t;
|
||||
|
||||
Deci2Server::Deci2Server(std::function<bool()> shutdown_callback) {
|
||||
buffer = new char[BUFFER_SIZE];
|
||||
want_exit = std::move(shutdown_callback);
|
||||
@@ -41,7 +42,7 @@ Deci2Server::~Deci2Server() {
|
||||
|
||||
/*!
|
||||
* Start waiting for the Listener to connect
|
||||
*/
|
||||
|
||||
bool Deci2Server::init() {
|
||||
server_fd = socket(AF_INET, SOCK_STREAM, 0);
|
||||
if (server_fd < 0) {
|
||||
@@ -49,16 +50,16 @@ bool Deci2Server::init() {
|
||||
return false;
|
||||
}
|
||||
|
||||
int opt = 1;
|
||||
if (setsockopt(server_fd, SOL_SOCKET, SO_REUSEADDR | SO_REUSEPORT, &opt, sizeof(opt))) {
|
||||
const char opt = 1;
|
||||
if (setsockopt(server_fd, SOL_SOCKET, SO_REUSEADDR | SO_BROADCAST, &opt, sizeof(opt))) {
|
||||
printf("[Deci2Server] Failed to setsockopt 1\n");
|
||||
close(server_fd);
|
||||
server_fd = -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
int one = 1;
|
||||
if (setsockopt(server_fd, SOL_TCP, TCP_NODELAY, &one, sizeof(one))) {
|
||||
const char one = 1;
|
||||
if (setsockopt(server_fd, SOL_SOCKET, TCP_NODELAY, &one, sizeof(one))) {
|
||||
printf("[Deci2Server] Failed to setsockopt 2\n");
|
||||
close(server_fd);
|
||||
server_fd = -1;
|
||||
@@ -103,7 +104,7 @@ bool Deci2Server::init() {
|
||||
|
||||
/*!
|
||||
* Return true if the listener is connected.
|
||||
*/
|
||||
|
||||
bool Deci2Server::check_for_listener() {
|
||||
if (server_connected) {
|
||||
if (accept_thread_running) {
|
||||
@@ -118,7 +119,7 @@ bool Deci2Server::check_for_listener() {
|
||||
|
||||
/*!
|
||||
* Send data from buffer. User must provide appropriate headers.
|
||||
*/
|
||||
|
||||
void Deci2Server::send_data(void* buf, u16 len) {
|
||||
lock();
|
||||
if (!server_connected) {
|
||||
@@ -139,14 +140,14 @@ void Deci2Server::send_data(void* buf, u16 len) {
|
||||
|
||||
/*!
|
||||
* Lock the DECI mutex. Should be done before modifying protocols.
|
||||
*/
|
||||
|
||||
void Deci2Server::lock() {
|
||||
deci_mutex.lock();
|
||||
}
|
||||
|
||||
/*!
|
||||
* Unlock the DECI mutex. Should be done after modifying protocols.
|
||||
*/
|
||||
|
||||
void Deci2Server::unlock() {
|
||||
deci_mutex.unlock();
|
||||
}
|
||||
@@ -154,7 +155,7 @@ void Deci2Server::unlock() {
|
||||
/*!
|
||||
* Wait for protocols to become ready.
|
||||
* This avoids the case where we receive messages before protocol handlers are set up.
|
||||
*/
|
||||
|
||||
void Deci2Server::wait_for_protos_ready() {
|
||||
if (protocols_ready)
|
||||
return;
|
||||
@@ -167,7 +168,7 @@ void Deci2Server::wait_for_protos_ready() {
|
||||
* Will unblock wait_for_protos_ready and incoming messages will be dispatched to these
|
||||
* protocols. You can change the protocol handlers, but you should lock the mutex before
|
||||
* doing so.
|
||||
*/
|
||||
|
||||
void Deci2Server::send_proto_ready(Deci2Driver* drivers, int* driver_count) {
|
||||
lock();
|
||||
d2_drivers = drivers;
|
||||
@@ -214,7 +215,7 @@ void Deci2Server::run() {
|
||||
printf("[DECI2] Warning: no handler for this message, ignoring...\n");
|
||||
unlock();
|
||||
return;
|
||||
// throw std::runtime_error("no handler!");
|
||||
// throw std::exception("no handler!");
|
||||
}
|
||||
|
||||
auto& driver = d2_drivers[handler];
|
||||
@@ -249,16 +250,18 @@ void Deci2Server::run() {
|
||||
|
||||
/*!
|
||||
* Background thread for waiting for the listener.
|
||||
*/
|
||||
|
||||
void Deci2Server::accept_thread_func() {
|
||||
socklen_t l = sizeof(addr);
|
||||
while (!kill_accept_thread) {
|
||||
new_sock = accept(server_fd, (sockaddr*)&addr, &l);
|
||||
if (new_sock >= 0) {
|
||||
u32 versions[2] = {versions::GOAL_VERSION_MAJOR, versions::GOAL_VERSION_MINOR};
|
||||
const char versions = {versions::GOAL_VERSION_MAJOR};
|
||||
send(new_sock, &versions, 8, 0); // todo, check result?
|
||||
server_connected = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
@@ -2,12 +2,12 @@
|
||||
* @file Deci2Server.h
|
||||
* Basic implementation of a DECI2 server.
|
||||
* Works with deci2.cpp (sceDeci2) to implement the networking on target
|
||||
*/
|
||||
|
||||
|
||||
#ifndef JAK1_DECI2SERVER_H
|
||||
#define JAK1_DECI2SERVER_H
|
||||
|
||||
#include <netinet/in.h>
|
||||
#include <Winsock2.h>
|
||||
#include <thread>
|
||||
#include <mutex>
|
||||
#include <condition_variable>
|
||||
@@ -54,3 +54,5 @@ class Deci2Server {
|
||||
|
||||
|
||||
#endif // JAK1_DECI2SERVER_H
|
||||
|
||||
*/
|
||||
@@ -7,9 +7,9 @@
|
||||
* Create a new thread. Will not run the thread.
|
||||
*/
|
||||
s32 IOP_Kernel::CreateThread(std::string name, u32 (*func)()) {
|
||||
if(_currentThread != -1) throw std::runtime_error("tried to create thread from thread");
|
||||
if(_currentThread != -1) throw std::exception("tried to create thread from thread");
|
||||
u32 ID = (u32)_nextThID++;
|
||||
if(threads.size() != ID) throw std::runtime_error("thread number error?");
|
||||
if(threads.size() != ID) throw std::exception("thread number error?");
|
||||
// add entry
|
||||
threads.emplace_back(name, func, ID, this);
|
||||
// setup the thread!
|
||||
@@ -19,7 +19,7 @@ s32 IOP_Kernel::CreateThread(std::string name, u32 (*func)()) {
|
||||
if(func) {
|
||||
_currentThread = ID;
|
||||
// create OS thread, will run the setupThread function
|
||||
threads.back().thread = new std::thread(&IOP_Kernel::setupThread, this, ID);
|
||||
//threads.back().thread = new std::thread(&IOP_Kernel::setupThread, this, ID); --- quick hack to make the build
|
||||
// wait for thread to finish setup.
|
||||
threads.back().waitForReturnToKernel();
|
||||
// ensure we are back in the kernel.
|
||||
@@ -47,7 +47,7 @@ void IOP_Kernel::setupThread(s32 id) {
|
||||
threads.at(id).waitForDispatch();
|
||||
// printf("[IOP Kernel] Thread %s first dispatch!\n", threads.at(id).name.c_str());
|
||||
if(_currentThread != id) {
|
||||
throw std::runtime_error("the wrong thread has run!\n");
|
||||
throw std::exception("the wrong thread has run!\n");
|
||||
}
|
||||
(threads.at(id).function)();
|
||||
printf("Thread %s has returned!\n", threads.at(id).name.c_str());
|
||||
@@ -59,7 +59,7 @@ void IOP_Kernel::setupThread(s32 id) {
|
||||
* Run a thread (call from kernel)
|
||||
*/
|
||||
void IOP_Kernel::runThread(s32 id) {
|
||||
if(_currentThread != -1) throw std::runtime_error("tried to runThread in a thread");
|
||||
if(_currentThread != -1) throw std::exception("tried to runThread in a thread");
|
||||
_currentThread = id;
|
||||
threads.at(id).dispatch();
|
||||
threads.at(id).waitForReturnToKernel();
|
||||
@@ -76,7 +76,7 @@ void IOP_Kernel::SuspendThread() {
|
||||
threads.at(oldThread).returnToKernel();
|
||||
threads.at(oldThread).waitForDispatch();
|
||||
if(_currentThread != oldThread) {
|
||||
throw std::runtime_error("bad resume");
|
||||
throw std::exception("bad resume");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -128,7 +128,7 @@ void IOP_Kernel::dispatchAll() {
|
||||
*/
|
||||
void IopThreadRecord::returnToKernel() {
|
||||
runThreadReady = false;
|
||||
if(kernel->getCurrentThread() != thID) throw std::runtime_error("tried to sleep the wrong thread!");
|
||||
if(kernel->getCurrentThread() != thID) throw std::exception("tried to sleep the wrong thread!");
|
||||
|
||||
{
|
||||
std::lock_guard<std::mutex> lck(*threadToKernelMutex);
|
||||
@@ -142,7 +142,7 @@ void IopThreadRecord::returnToKernel() {
|
||||
*/
|
||||
void IopThreadRecord::dispatch() {
|
||||
syscallReady = false;
|
||||
if(kernel->getCurrentThread() != thID) throw std::runtime_error("tried to dispatch the wrong thread!");
|
||||
if(kernel->getCurrentThread() != thID) throw std::exception("tried to dispatch the wrong thread!");
|
||||
{
|
||||
std::lock_guard<std::mutex> lck(*kernelToThreadMutex);
|
||||
runThreadReady = true;
|
||||
@@ -163,7 +163,7 @@ void IopThreadRecord::waitForReturnToKernel() {
|
||||
* Thread waits for kernel to dispatch it.
|
||||
*/
|
||||
void IopThreadRecord::waitForDispatch() {
|
||||
//if(kernel->getCurrentThread() == -1) throw std::runtime_error("tried to suspend main!\n");
|
||||
//if(kernel->getCurrentThread() == -1) throw std::exception("tried to suspend main!\n");
|
||||
std::unique_lock<std::mutex> lck(*kernelToThreadMutex);
|
||||
kernelToThreadCV->wait(lck, [this]{return runThreadReady;});
|
||||
//runThreadReady = false;
|
||||
|
||||
@@ -98,7 +98,7 @@ public:
|
||||
* Resume the kernel.
|
||||
*/
|
||||
void returnToKernel() {
|
||||
if(_currentThread < 0) throw std::runtime_error("tried to return to kernel not in a thread");
|
||||
if(_currentThread < 0) throw std::exception("tried to return to kernel not in a thread");
|
||||
threads[_currentThread].returnToKernel();
|
||||
}
|
||||
|
||||
@@ -129,7 +129,7 @@ public:
|
||||
return -0x1a9;
|
||||
}
|
||||
// printf("poll %d %ld\n", mbx, mbxs.size());
|
||||
if(mbx >= (s32) mbxs.size()) throw std::runtime_error("invalid PollMbx");
|
||||
if(mbx >= (s32) mbxs.size()) throw std::exception("invalid PollMbx");
|
||||
s32 gotSomething = mbxs[mbx].empty() ? 0 : 1;
|
||||
if(gotSomething) {
|
||||
void* thing = mbxs[mbx].front();
|
||||
@@ -146,7 +146,7 @@ public:
|
||||
* Push something into a mbx
|
||||
*/
|
||||
s32 SendMbx(s32 mbx, void* value) {
|
||||
if(mbx >= (s32) mbxs.size()) throw std::runtime_error("invalid SendMbx");
|
||||
if(mbx >= (s32) mbxs.size()) throw std::exception("invalid SendMbx");
|
||||
mbxs[mbx].push(value);
|
||||
// printf("push into messagebox %d %p\n", mbx, value);
|
||||
// printf("mbx size %ld\n", mbxs.size());
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
*/
|
||||
SystemThread& SystemThreadManager::create_thread(const std::string& name) {
|
||||
if (thread_count >= MAX_SYSTEM_THREADS) {
|
||||
throw std::runtime_error("Out of System Threads! Please increase MAX_SYSTEM_THREADS");
|
||||
throw std::exception("Out of System Threads! Please increase MAX_SYSTEM_THREADS");
|
||||
}
|
||||
auto& thread = threads[thread_count];
|
||||
|
||||
@@ -71,8 +71,8 @@ void SystemThreadManager::join() {
|
||||
*/
|
||||
void* bootstrap_thread_func(void* x) {
|
||||
SystemThread* thd = (SystemThread*)x;
|
||||
SystemThreadInterface interface(thd);
|
||||
thd->function(interface);
|
||||
SystemThreadInterface interfaces(thd);
|
||||
thd->function(interfaces);
|
||||
printf("[SYSTEM] Thread %s is returning\n", thd->name.c_str());
|
||||
return nullptr;
|
||||
}
|
||||
@@ -83,7 +83,7 @@ void* bootstrap_thread_func(void* x) {
|
||||
void SystemThread::start(std::function<void(SystemThreadInterface&)> f) {
|
||||
printf("# Initialize %s...\n", name.c_str());
|
||||
function = f;
|
||||
pthread_create(&thread, nullptr, bootstrap_thread_func, this);
|
||||
std::thread(thread);
|
||||
running = true;
|
||||
|
||||
// and wait for initialization
|
||||
@@ -100,7 +100,7 @@ void SystemThread::start(std::function<void(SystemThreadInterface&)> f) {
|
||||
*/
|
||||
void SystemThread::join() {
|
||||
void* x;
|
||||
pthread_join(thread, &x);
|
||||
thread.join();
|
||||
running = false;
|
||||
}
|
||||
|
||||
@@ -135,33 +135,3 @@ bool SystemThreadInterface::get_want_exit() const {
|
||||
void SystemThreadInterface::trigger_shutdown() {
|
||||
thread.manager->shutdown();
|
||||
}
|
||||
|
||||
#include <sys/time.h>
|
||||
#include <sys/resource.h>
|
||||
|
||||
/*!
|
||||
* Get thread performance statistics and report them.
|
||||
*/
|
||||
void SystemThreadInterface::report_perf_stats() {
|
||||
if (thread.stat_diff_timer.getMs() > 16.f) {
|
||||
thread.stat_diff_timer.start();
|
||||
|
||||
uint64_t current_ns = thread.stats_timer.getNs();
|
||||
rusage stats;
|
||||
getrusage(RUSAGE_THREAD, &stats);
|
||||
|
||||
uint64_t current_kernel = stats.ru_stime.tv_usec + (1000000 * stats.ru_stime.tv_sec);
|
||||
uint64_t current_user = stats.ru_utime.tv_usec + (1000000 * stats.ru_utime.tv_sec);
|
||||
|
||||
uint64_t ns_dt = current_ns - thread.last_collection_nanoseconds;
|
||||
uint64_t dt_kernel = current_kernel - thread.last_cpu_kernel;
|
||||
uint64_t dt_user = current_user - thread.last_cpu_user;
|
||||
|
||||
thread.cpu_kernel = dt_kernel * 1000. / (double)ns_dt;
|
||||
thread.cpu_user = dt_user * 1000. / (double)ns_dt;
|
||||
|
||||
thread.last_cpu_kernel = current_kernel;
|
||||
thread.last_cpu_user = current_user;
|
||||
thread.last_collection_nanoseconds = current_ns;
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,6 @@
|
||||
|
||||
#include <string>
|
||||
#include <functional>
|
||||
#include <pthread.h>
|
||||
#include <array>
|
||||
#include <mutex>
|
||||
#include <condition_variable>
|
||||
@@ -22,7 +21,7 @@ class SystemThreadManager;
|
||||
|
||||
/*!
|
||||
* Runs a function in a thread and provides a SystemThreadInterface to that function.
|
||||
* Once the thread is ready, it should tell the interface with intitialization_complete().
|
||||
* Once the thread is ready, it should tell the interfaces with intitialization_complete().
|
||||
* Thread functions should try to return when get_want_exit() returns true.
|
||||
* Thread functions should also call report_perf_stats every now and then to update performance
|
||||
* statistics.
|
||||
@@ -40,7 +39,7 @@ private:
|
||||
friend void* bootstrap_thread_func(void* thd);
|
||||
|
||||
std::string name = "invalid";
|
||||
pthread_t thread;
|
||||
std::thread thread;
|
||||
SystemThreadManager* manager;
|
||||
std::function<void(SystemThreadInterface &)> function;
|
||||
bool initialization_complete = false;
|
||||
@@ -57,7 +56,7 @@ private:
|
||||
};
|
||||
|
||||
/*!
|
||||
* The interface used by a thread in the runtime.
|
||||
* The interfaces used by a thread in the runtime.
|
||||
*/
|
||||
class SystemThreadInterface {
|
||||
public:
|
||||
|
||||
@@ -12,7 +12,6 @@ public:
|
||||
}
|
||||
|
||||
void start() {
|
||||
clock_gettime(CLOCK_MONOTONIC, &_startTime);
|
||||
}
|
||||
|
||||
double getMs() {
|
||||
@@ -21,7 +20,6 @@ public:
|
||||
|
||||
int64_t getNs() {
|
||||
struct timespec now;
|
||||
clock_gettime(CLOCK_MONOTONIC, &now);
|
||||
return (int64_t)(now.tv_nsec - _startTime.tv_nsec) + 1000000000 * (now.tv_sec - _startTime.tv_sec);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#ifndef JAK_DECIM_COMMON_H
|
||||
#define JAK_DECIM_COMMON_H
|
||||
#include "common/common_types.h"
|
||||
|
||||
struct Deci2Driver {
|
||||
u16 protocol = 0;
|
||||
void* opt = nullptr;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "iop_thread.h"
|
||||
|
||||
#include <unistd.h>
|
||||
#include <io.h>
|
||||
#include "SystemThread.h"
|
||||
//#include "shared_config.h"
|
||||
//#include "ps2/SCE_IOP.h"
|
||||
@@ -95,7 +95,7 @@ IOP::~IOP() {
|
||||
reset_allocator();
|
||||
}
|
||||
|
||||
//void launch_iop(SystemThreadInterface& interface) {
|
||||
//void launch_iop(SystemThreadInterface& interfaces) {
|
||||
// IOP iop;
|
||||
//
|
||||
// printf("\n\n\n[IOP] Restart!\n");
|
||||
@@ -118,7 +118,7 @@ IOP::~IOP() {
|
||||
//
|
||||
//// SCE_IOP::PS2_RegisterIOP(&iop);
|
||||
//// PS2_RegisterIOP_EE(&iop);
|
||||
// interface.initialization_complete();
|
||||
// interfaces.initialization_complete();
|
||||
//
|
||||
// printf("[IOP] Wait for OVERLORD to be started...\n");
|
||||
// iop.wait_for_overlord_start_cmd();
|
||||
@@ -140,7 +140,7 @@ IOP::~IOP() {
|
||||
// iop.signal_overlord_init_finish();
|
||||
//
|
||||
// // IOP Kernel loop
|
||||
// while(!interface.get_want_exit() && !iop.want_exit) {
|
||||
// while(!interfaces.get_want_exit() && !iop.want_exit) {
|
||||
// // the IOP kernel just runs at full blast, so we only run the IOP when the EE is waiting on the IOP.
|
||||
// // Each time the EE is waiting on the IOP, it will run an iteration of the IOP kernel.
|
||||
// iop.wait_run_iop();
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include <sys/mman.h>
|
||||
#include <third-party/mman.h>
|
||||
#include <cstdio>
|
||||
#include "CodeTester.h"
|
||||
#include "Instruction.h"
|
||||
|
||||
@@ -137,8 +137,8 @@ void Interpreter::execute_repl() {
|
||||
* for debugging.
|
||||
*/
|
||||
void Interpreter::throw_eval_error(const Object& o, const std::string& err) {
|
||||
throw std::runtime_error("[GOOS] Evaluation error on " + o.print() + ": " + err + "\n" +
|
||||
reader.db.get_info_for(o));
|
||||
// throw std::exception("[GOOS] Evaluation error on " + o.print() + ": " + err + "\n" +
|
||||
// reader.db.get_info_for(o));
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -151,7 +151,7 @@ Object Interpreter::eval_with_rewind(const Object& obj,
|
||||
Object result = EmptyListObject::make_new();
|
||||
try {
|
||||
result = eval(obj, env);
|
||||
} catch (std::runtime_error& e) {
|
||||
} catch (std::exception& e) {
|
||||
if (!disable_printing) {
|
||||
printf("-----------------------------------------\n");
|
||||
printf("From object %s\nat %s\n", obj.inspect().c_str(), reader.db.get_info_for(obj).c_str());
|
||||
|
||||
@@ -49,7 +49,7 @@ Object Interpreter::eval_read(const Object& form,
|
||||
|
||||
try {
|
||||
return reader.read_from_string(args.unnamed.at(0).as_string()->data);
|
||||
} catch (std::runtime_error& e) {
|
||||
} catch (std::exception& e) {
|
||||
throw_eval_error(form, std::string("reader error inside of read:\n") + e.what());
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ Object Interpreter::eval_read_file(const Object& form,
|
||||
|
||||
try {
|
||||
return reader.read_from_file(args.unnamed.at(0).as_string()->data);
|
||||
} catch (std::runtime_error& e) {
|
||||
} catch (std::exception& e) {
|
||||
throw_eval_error(form, std::string("reader error inside of read-file:\n") + e.what());
|
||||
}
|
||||
return EmptyListObject::make_new();
|
||||
@@ -85,13 +85,13 @@ Object Interpreter::eval_load_file(const Object& form,
|
||||
Object o;
|
||||
try {
|
||||
o = reader.read_from_file(args.unnamed.at(0).as_string()->data);
|
||||
} catch (std::runtime_error& e) {
|
||||
} catch (std::exception& e) {
|
||||
throw_eval_error(form, std::string("reader error inside of load-file:\n") + e.what());
|
||||
}
|
||||
|
||||
try {
|
||||
return eval_with_rewind(o, global_environment.as_env());
|
||||
} catch (std::runtime_error& e) {
|
||||
} catch (std::exception& e) {
|
||||
throw_eval_error(form, std::string("eval error inside of load-file:\n") + e.what());
|
||||
}
|
||||
return EmptyListObject::make_new();
|
||||
|
||||
@@ -33,7 +33,7 @@ std::string object_type_to_string(ObjectType type) {
|
||||
case ObjectType::ENVIRONMENT:
|
||||
return "[environment]";
|
||||
default:
|
||||
throw std::runtime_error("unknown object type in object_type_to_string");
|
||||
throw std::exception("unknown object type in object_type_to_string");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -151,7 +151,7 @@ bool Object::operator==(const Object& other) const {
|
||||
}
|
||||
|
||||
default:
|
||||
throw std::runtime_error("equality not implemented for " + print());
|
||||
//throw std::exception("equality not implemented for " + print());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+18
-18
@@ -222,78 +222,78 @@ class Object {
|
||||
|
||||
std::shared_ptr<PairObject> as_pair() const {
|
||||
if (type != ObjectType::PAIR) {
|
||||
throw std::runtime_error("as_pair called on a " + object_type_to_string(type) + " " +
|
||||
print());
|
||||
// throw std::exception("as_pair called on a " + object_type_to_string(type) + " " +
|
||||
// print());
|
||||
}
|
||||
return std::dynamic_pointer_cast<PairObject>(heap_obj);
|
||||
}
|
||||
|
||||
std::shared_ptr<EnvironmentObject> as_env() const {
|
||||
if (type != ObjectType::ENVIRONMENT) {
|
||||
throw std::runtime_error("as_env called on a " + object_type_to_string(type) + " " + print());
|
||||
// throw std::exception("as_env called on a " + object_type_to_string(type) + " " + print());
|
||||
}
|
||||
return std::dynamic_pointer_cast<EnvironmentObject>(heap_obj);
|
||||
}
|
||||
|
||||
std::shared_ptr<SymbolObject> as_symbol() const {
|
||||
if (type != ObjectType::SYMBOL) {
|
||||
throw std::runtime_error("as_symbol called on a " + object_type_to_string(type) + " " +
|
||||
print());
|
||||
// throw std::exception("as_symbol called on a " + object_type_to_string(type) + " " +
|
||||
// print());
|
||||
}
|
||||
return std::dynamic_pointer_cast<SymbolObject>(heap_obj);
|
||||
}
|
||||
|
||||
std::shared_ptr<StringObject> as_string() const {
|
||||
if (type != ObjectType::STRING) {
|
||||
throw std::runtime_error("as_string called on a " + object_type_to_string(type) + " " +
|
||||
print());
|
||||
// throw std::exception("as_string called on a " + object_type_to_string(type) + " " +
|
||||
// print());
|
||||
}
|
||||
return std::dynamic_pointer_cast<StringObject>(heap_obj);
|
||||
}
|
||||
|
||||
std::shared_ptr<LambdaObject> as_lambda() const {
|
||||
if (type != ObjectType::LAMBDA) {
|
||||
throw std::runtime_error("as_lambda called on a " + object_type_to_string(type) + " " +
|
||||
print());
|
||||
// throw std::exception("as_lambda called on a " + object_type_to_string(type) + " " +
|
||||
// print());
|
||||
}
|
||||
return std::dynamic_pointer_cast<LambdaObject>(heap_obj);
|
||||
}
|
||||
|
||||
std::shared_ptr<MacroObject> as_macro() const {
|
||||
if (type != ObjectType::MACRO) {
|
||||
throw std::runtime_error("as_macro called on a " + object_type_to_string(type) + " " +
|
||||
print());
|
||||
// throw std::exception("as_macro called on a " + object_type_to_string(type) + " " +
|
||||
// print());
|
||||
}
|
||||
return std::dynamic_pointer_cast<MacroObject>(heap_obj);
|
||||
}
|
||||
|
||||
std::shared_ptr<ArrayObject> as_array() const {
|
||||
if (type != ObjectType::ARRAY) {
|
||||
throw std::runtime_error("as_array called on a " + object_type_to_string(type) + " " +
|
||||
print());
|
||||
// throw std::exception("as_array called on a " + object_type_to_string(type) + " " +
|
||||
// print());
|
||||
}
|
||||
return std::dynamic_pointer_cast<ArrayObject>(heap_obj);
|
||||
}
|
||||
|
||||
IntType& as_int() {
|
||||
if (type != ObjectType::INTEGER) {
|
||||
throw std::runtime_error("as_int called on a " + object_type_to_string(type) + " " + print());
|
||||
// throw std::exception("as_int called on a " + object_type_to_string(type) + " " + print());
|
||||
}
|
||||
return integer_obj.value;
|
||||
}
|
||||
|
||||
FloatType& as_float() {
|
||||
if (type != ObjectType::FLOAT) {
|
||||
throw std::runtime_error("as_float called on a " + object_type_to_string(type) + " " +
|
||||
print());
|
||||
// throw std::exception("as_float called on a " + object_type_to_string(type) + " " +
|
||||
// print());
|
||||
}
|
||||
return float_obj.value;
|
||||
}
|
||||
|
||||
char& as_char() {
|
||||
if (type != ObjectType::CHAR) {
|
||||
throw std::runtime_error("as_char called on a " + object_type_to_string(type) + " " +
|
||||
print());
|
||||
// throw std::exception("as_char called on a " + object_type_to_string(type) + " " +
|
||||
// print());
|
||||
}
|
||||
return char_obj.value;
|
||||
}
|
||||
|
||||
@@ -102,7 +102,7 @@ Reader::Reader() {
|
||||
// find the source directory
|
||||
auto result = std::getenv("NEXT_DIR");
|
||||
if (!result) {
|
||||
throw std::runtime_error(
|
||||
throw std::exception(
|
||||
"Environment variable NEXT_DIR is not set. Please set this to point to next/");
|
||||
}
|
||||
|
||||
@@ -588,7 +588,7 @@ bool Reader::try_token_as_binary(const Token& tok, Object& obj) {
|
||||
|
||||
for (uint32_t i = 2; i < tok.text.size(); i++) {
|
||||
if (value & (0x8000000000000000)) {
|
||||
throw std::runtime_error("overflow in binary constant: " + tok.text);
|
||||
throw std::exception("overflow in binary constant: " + tok.text);
|
||||
}
|
||||
|
||||
value <<= 1u;
|
||||
@@ -628,7 +628,7 @@ bool Reader::try_token_as_hex(const Token& tok, Object& obj) {
|
||||
obj = Object::make_integer(v);
|
||||
return true;
|
||||
} catch (std::exception& e) {
|
||||
throw std::runtime_error("The number " + tok.text + " cannot be a hexadecimal constant");
|
||||
throw std::exception("The number " + tok.text + " cannot be a hexadecimal constant");
|
||||
}
|
||||
}
|
||||
return false;
|
||||
@@ -662,7 +662,7 @@ bool Reader::try_token_as_integer(const Token& tok, Object& obj) {
|
||||
obj = Object::make_integer(v);
|
||||
return true;
|
||||
} catch (std::exception& e) {
|
||||
throw std::runtime_error("The number " + tok.text + " cannot be an integer constant");
|
||||
throw std::exception("The number " + tok.text + " cannot be an integer constant");
|
||||
}
|
||||
}
|
||||
return false;
|
||||
@@ -697,7 +697,7 @@ bool Reader::try_token_as_char(const Token& tok, Object& obj) {
|
||||
* Used for reader errors, like "missing close paren" or similar.
|
||||
*/
|
||||
void Reader::throw_reader_error(TextStream& here, const std::string& err, int seek_offset) {
|
||||
throw std::runtime_error("Reader error:\n" + err + "\nat " +
|
||||
throw std::exception("Reader error:\n" + err + "\nat " +
|
||||
db.get_info_for(here.text, here.seek + seek_offset));
|
||||
}
|
||||
|
||||
|
||||
@@ -214,7 +214,7 @@ void Deci2Server::run() {
|
||||
printf("[DECI2] Warning: no handler for this message, ignoring...\n");
|
||||
unlock();
|
||||
return;
|
||||
// throw std::runtime_error("no handler!");
|
||||
// throw std::exception("no handler!");
|
||||
}
|
||||
|
||||
auto& driver = d2_drivers[handler];
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* @file Deci2Server.h
|
||||
* Basic implementation of a DECI2 server.
|
||||
* Works with deci2.cpp (sceDeci2) to implement the networking on target
|
||||
*/
|
||||
|
||||
|
||||
#ifndef JAK1_DECI2SERVER_H
|
||||
#define JAK1_DECI2SERVER_H
|
||||
@@ -55,3 +55,5 @@ class Deci2Server {
|
||||
|
||||
|
||||
#endif // JAK1_DECI2SERVER_H
|
||||
|
||||
*/
|
||||
|
||||
+19
-12
@@ -1,12 +1,11 @@
|
||||
/*!
|
||||
* @file Listener.cpp
|
||||
* The Listener can connect to a Deci2Server for debugging.
|
||||
*/
|
||||
|
||||
|
||||
#include <stdexcept>
|
||||
#include <netinet/tcp.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <unistd.h>
|
||||
#include <Winsock2.h>
|
||||
#include <io.h>
|
||||
#include <cassert>
|
||||
#include "Listener.h"
|
||||
#include "common/versions.h"
|
||||
@@ -40,13 +39,11 @@ bool Listener::is_connected() const {
|
||||
return m_connected;
|
||||
}
|
||||
|
||||
/*!
|
||||
* Attempt to connect to the target. If the target isn't running, this should fail quickly.
|
||||
* Returns true if successfully connected.
|
||||
*/
|
||||
|
||||
/*
|
||||
bool Listener::connect_to_target(const std::string& ip, int port) {
|
||||
if (m_connected) {
|
||||
throw std::runtime_error("attempted a Listener::connect_to_target when already connected!");
|
||||
throw std::exception("attempted a Listener::connect_to_target when already connected!");
|
||||
}
|
||||
|
||||
if (socket_fd >= 0) {
|
||||
@@ -73,8 +70,8 @@ bool Listener::connect_to_target(const std::string& ip, int port) {
|
||||
}
|
||||
|
||||
// set nodelay, which makes small rapid messages faster, but large messages slower
|
||||
int one = 1;
|
||||
if (setsockopt(socket_fd, SOL_TCP, TCP_NODELAY, &one, sizeof(one))) {
|
||||
const char one = 1;
|
||||
if (setsockopt(socket_fd, SOL_SOCKET, TCP_NODELAY, &one, sizeof(one))) {
|
||||
printf("[Listener] failed to TCP_NODELAY\n");
|
||||
close(socket_fd);
|
||||
socket_fd = -1;
|
||||
@@ -144,7 +141,15 @@ bool Listener::connect_to_target(const std::string& ip, int port) {
|
||||
/*!
|
||||
* Runs in a separate thread to receive messages.
|
||||
* Will print messages to stdout, or optionally save them.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
/*!
|
||||
* Attempt to connect to the target. If the target isn't running, this should fail quickly.
|
||||
* Returns true if successfully connected.
|
||||
|
||||
|
||||
void Listener::receive_func() {
|
||||
while (m_connected) {
|
||||
// attempt to receive a ListenerMessageHeader
|
||||
@@ -239,3 +244,5 @@ void Listener::receive_func() {
|
||||
}
|
||||
|
||||
} // namespace listener
|
||||
|
||||
*/
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace util {
|
||||
std::string read_text_file(const std::string& path) {
|
||||
std::ifstream file(path);
|
||||
if (!file.good()) {
|
||||
throw std::runtime_error("couldn't open " + path);
|
||||
throw std::exception("couldn't open ");
|
||||
}
|
||||
std::stringstream ss;
|
||||
ss << file.rdbuf();
|
||||
|
||||
@@ -0,0 +1,180 @@
|
||||
|
||||
#include <windows.h>
|
||||
#include <errno.h>
|
||||
#include <io.h>
|
||||
|
||||
#include "mman.h"
|
||||
|
||||
#ifndef FILE_MAP_EXECUTE
|
||||
#define FILE_MAP_EXECUTE 0x0020
|
||||
#endif /* FILE_MAP_EXECUTE */
|
||||
|
||||
static int __map_mman_error(const DWORD err, const int deferr)
|
||||
{
|
||||
if (err == 0)
|
||||
return 0;
|
||||
//TODO: implement
|
||||
return err;
|
||||
}
|
||||
|
||||
static DWORD __map_mmap_prot_page(const int prot)
|
||||
{
|
||||
DWORD protect = 0;
|
||||
|
||||
if (prot == PROT_NONE)
|
||||
return protect;
|
||||
|
||||
if ((prot & PROT_EXEC) != 0)
|
||||
{
|
||||
protect = ((prot & PROT_WRITE) != 0) ?
|
||||
PAGE_EXECUTE_READWRITE : PAGE_EXECUTE_READ;
|
||||
}
|
||||
else
|
||||
{
|
||||
protect = ((prot & PROT_WRITE) != 0) ?
|
||||
PAGE_READWRITE : PAGE_READONLY;
|
||||
}
|
||||
|
||||
return protect;
|
||||
}
|
||||
|
||||
static DWORD __map_mmap_prot_file(const int prot)
|
||||
{
|
||||
DWORD desiredAccess = 0;
|
||||
|
||||
if (prot == PROT_NONE)
|
||||
return desiredAccess;
|
||||
|
||||
if ((prot & PROT_READ) != 0)
|
||||
desiredAccess |= FILE_MAP_READ;
|
||||
if ((prot & PROT_WRITE) != 0)
|
||||
desiredAccess |= FILE_MAP_WRITE;
|
||||
if ((prot & PROT_EXEC) != 0)
|
||||
desiredAccess |= FILE_MAP_EXECUTE;
|
||||
|
||||
return desiredAccess;
|
||||
}
|
||||
|
||||
void* mmap(void *addr, size_t len, int prot, int flags, int fildes, off_t off)
|
||||
{
|
||||
HANDLE fm, h;
|
||||
|
||||
void * map = MAP_FAILED;
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable: 4293)
|
||||
#endif
|
||||
|
||||
const DWORD dwFileOffsetLow = (sizeof(off_t) <= sizeof(DWORD)) ?
|
||||
(DWORD)off : (DWORD)(off & 0xFFFFFFFFL);
|
||||
const DWORD dwFileOffsetHigh = (sizeof(off_t) <= sizeof(DWORD)) ?
|
||||
(DWORD)0 : (DWORD)((off >> 32) & 0xFFFFFFFFL);
|
||||
const DWORD protect = __map_mmap_prot_page(prot);
|
||||
const DWORD desiredAccess = __map_mmap_prot_file(prot);
|
||||
|
||||
const off_t maxSize = off + (off_t)len;
|
||||
|
||||
const DWORD dwMaxSizeLow = (sizeof(off_t) <= sizeof(DWORD)) ?
|
||||
(DWORD)maxSize : (DWORD)(maxSize & 0xFFFFFFFFL);
|
||||
const DWORD dwMaxSizeHigh = (sizeof(off_t) <= sizeof(DWORD)) ?
|
||||
(DWORD)0 : (DWORD)((maxSize >> 32) & 0xFFFFFFFFL);
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
|
||||
errno = 0;
|
||||
|
||||
if (len == 0
|
||||
/* Unsupported flag combinations */
|
||||
|| (flags & MAP_FIXED) != 0
|
||||
/* Usupported protection combinations */
|
||||
|| prot == PROT_EXEC)
|
||||
{
|
||||
errno = EINVAL;
|
||||
return MAP_FAILED;
|
||||
}
|
||||
|
||||
h = ((flags & MAP_ANONYMOUS) == 0) ?
|
||||
(HANDLE)_get_osfhandle(fildes) : INVALID_HANDLE_VALUE;
|
||||
|
||||
if ((flags & MAP_ANONYMOUS) == 0 && h == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
errno = EBADF;
|
||||
return MAP_FAILED;
|
||||
}
|
||||
|
||||
fm = CreateFileMapping(h, NULL, protect, dwMaxSizeHigh, dwMaxSizeLow, NULL);
|
||||
|
||||
if (fm == NULL)
|
||||
{
|
||||
errno = __map_mman_error(GetLastError(), EPERM);
|
||||
return MAP_FAILED;
|
||||
}
|
||||
|
||||
map = MapViewOfFile(fm, desiredAccess, dwFileOffsetHigh, dwFileOffsetLow, len);
|
||||
|
||||
CloseHandle(fm);
|
||||
|
||||
if (map == NULL)
|
||||
{
|
||||
errno = __map_mman_error(GetLastError(), EPERM);
|
||||
return MAP_FAILED;
|
||||
}
|
||||
|
||||
return map;
|
||||
}
|
||||
|
||||
int munmap(void *addr, size_t len)
|
||||
{
|
||||
if (UnmapViewOfFile(addr))
|
||||
return 0;
|
||||
|
||||
errno = __map_mman_error(GetLastError(), EPERM);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
int mprotect(void *addr, size_t len, int prot)
|
||||
{
|
||||
DWORD newProtect = __map_mmap_prot_page(prot);
|
||||
DWORD oldProtect = 0;
|
||||
|
||||
if (VirtualProtect(addr, len, newProtect, &oldProtect))
|
||||
return 0;
|
||||
|
||||
errno = __map_mman_error(GetLastError(), EPERM);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
int msync(void *addr, size_t len, int flags)
|
||||
{
|
||||
if (FlushViewOfFile(addr, len))
|
||||
return 0;
|
||||
|
||||
errno = __map_mman_error(GetLastError(), EPERM);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
int mlock(const void *addr, size_t len)
|
||||
{
|
||||
if (VirtualLock((LPVOID)addr, len))
|
||||
return 0;
|
||||
|
||||
errno = __map_mman_error(GetLastError(), EPERM);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
int munlock(const void *addr, size_t len)
|
||||
{
|
||||
if (VirtualUnlock((LPVOID)addr, len))
|
||||
return 0;
|
||||
|
||||
errno = __map_mman_error(GetLastError(), EPERM);
|
||||
|
||||
return -1;
|
||||
}
|
||||
@@ -7748,7 +7748,7 @@ const char* all_syms[7941] = {"ripple-for-lava",
|
||||
"list-control",
|
||||
"sunken-pipegame-idle",
|
||||
"anim-test-edit-seq-insert-item",
|
||||
"anim-tester-interface",
|
||||
"anim-tester-interfaces",
|
||||
"anim-tester-adjust-frame",
|
||||
"extra-radius",
|
||||
"*volume-descriptor*",
|
||||
|
||||
Vendored
+4
-4
@@ -226,8 +226,8 @@ FMT_FUNC void system_error::init(int err_code, string_view format_str,
|
||||
error_code_ = err_code;
|
||||
memory_buffer buffer;
|
||||
format_system_error(buffer, err_code, vformat(format_str, args));
|
||||
std::runtime_error& base = *this;
|
||||
base = std::runtime_error(to_string(buffer));
|
||||
std::exception& base = *this;
|
||||
// base = std::exception(to_string(buffer));
|
||||
}
|
||||
|
||||
namespace detail {
|
||||
@@ -1175,7 +1175,7 @@ int snprintf_float(T value, int precision, float_specs specs,
|
||||
auto capacity = buf.capacity() - offset;
|
||||
#ifdef FMT_FUZZ
|
||||
if (precision > 100000)
|
||||
throw std::runtime_error(
|
||||
throw std::exception(
|
||||
"fuzz mode - avoid large allocation inside snprintf");
|
||||
#endif
|
||||
// Suppress the warning about a nonliteral format string.
|
||||
@@ -1327,7 +1327,7 @@ FMT_FUNC detail::utf8_to_utf16::utf8_to_utf16(string_view s) {
|
||||
auto cp = uint32_t();
|
||||
auto error = 0;
|
||||
p = utf8_decode(p, &cp, &error);
|
||||
if (error != 0) FMT_THROW(std::runtime_error("invalid utf8"));
|
||||
if (error != 0) FMT_THROW(std::exception("invalid utf8"));
|
||||
if (cp <= 0xFFFF) {
|
||||
buffer_.push_back(static_cast<wchar_t>(cp));
|
||||
} else {
|
||||
|
||||
Vendored
+1
-1
@@ -15,7 +15,7 @@ int format_float(char* buf, std::size_t size, const char* format, int precision,
|
||||
T value) {
|
||||
#ifdef FMT_FUZZ
|
||||
if (precision > 100000)
|
||||
throw std::runtime_error(
|
||||
throw std::exception(
|
||||
"fuzz mode - avoid large allocation inside snprintf");
|
||||
#endif
|
||||
// Suppress the warning about nonliteral format string.
|
||||
|
||||
Vendored
+9
-9
@@ -683,7 +683,7 @@ class basic_memory_buffer : public detail::buffer<T> {
|
||||
template <typename T, size_t SIZE, typename Allocator>
|
||||
void basic_memory_buffer<T, SIZE, Allocator>::grow(size_t size) {
|
||||
#ifdef FMT_FUZZ
|
||||
if (size > 5000) throw std::runtime_error("fuzz mode - won't grow that much");
|
||||
if (size > 5000) throw std::exception("fuzz mode - won't grow that much");
|
||||
#endif
|
||||
size_t old_capacity = this->capacity();
|
||||
size_t new_capacity = old_capacity + old_capacity / 2;
|
||||
@@ -710,11 +710,11 @@ struct is_contiguous<basic_memory_buffer<T, SIZE, Allocator>> : std::true_type {
|
||||
|
||||
/** A formatting error such as invalid format string. */
|
||||
FMT_CLASS_API
|
||||
class FMT_API format_error : public std::runtime_error {
|
||||
class FMT_API format_error : public std::exception {
|
||||
public:
|
||||
explicit format_error(const char* message) : std::runtime_error(message) {}
|
||||
explicit format_error(const std::string& message)
|
||||
: std::runtime_error(message) {}
|
||||
explicit format_error(const char* message) : std::exception(message) {}
|
||||
explicit format_error(const std::string& message);
|
||||
// : std::exception(message) {}
|
||||
format_error(const format_error&) = default;
|
||||
format_error& operator=(const format_error&) = default;
|
||||
format_error(format_error&&) = default;
|
||||
@@ -1145,7 +1145,7 @@ template <typename Char> class float_writer {
|
||||
}
|
||||
#ifdef FMT_FUZZ
|
||||
if (num_zeros > 5000)
|
||||
throw std::runtime_error("fuzz mode - avoiding excessive cpu use");
|
||||
throw std::exception("fuzz mode - avoiding excessive cpu use");
|
||||
#endif
|
||||
it = std::fill_n(it, num_zeros, static_cast<Char>('0'));
|
||||
}
|
||||
@@ -2952,14 +2952,14 @@ using arg_formatter FMT_DEPRECATED_ALIAS =
|
||||
for example a file opening error.
|
||||
*/
|
||||
FMT_CLASS_API
|
||||
class FMT_API system_error : public std::runtime_error {
|
||||
class FMT_API system_error : public std::exception {
|
||||
private:
|
||||
void init(int err_code, string_view format_str, format_args args);
|
||||
|
||||
protected:
|
||||
int error_code_;
|
||||
|
||||
system_error() : std::runtime_error(""), error_code_(0) {}
|
||||
system_error() : std::exception(""), error_code_(0) {}
|
||||
|
||||
public:
|
||||
/**
|
||||
@@ -2982,7 +2982,7 @@ class FMT_API system_error : public std::runtime_error {
|
||||
*/
|
||||
template <typename... Args>
|
||||
system_error(int error_code, string_view message, const Args&... args)
|
||||
: std::runtime_error("") {
|
||||
: std::exception("") {
|
||||
init(error_code, message, make_format_args(args...));
|
||||
}
|
||||
system_error(const system_error&) = default;
|
||||
|
||||
Vendored
+17
-17
@@ -70,7 +70,7 @@ SOFTWARE.
|
||||
|
||||
|
||||
#include <exception> // exception
|
||||
#include <stdexcept> // runtime_error
|
||||
#include <stdexcept> // exception
|
||||
#include <string> // to_string
|
||||
|
||||
// #include <nlohmann/detail/input/position_t.hpp>
|
||||
@@ -92,7 +92,7 @@ struct position_t
|
||||
/// the number of lines read
|
||||
std::size_t lines_read = 0;
|
||||
|
||||
/// conversion to size_t to preserve SAX interface
|
||||
/// conversion to size_t to preserve SAX interfaces
|
||||
constexpr operator size_t() const
|
||||
{
|
||||
return chars_read_total;
|
||||
@@ -2339,7 +2339,7 @@ Subclasses:
|
||||
|
||||
@internal
|
||||
@note To have nothrow-copy-constructible exceptions, we internally use
|
||||
`std::runtime_error` which can cope with arbitrary-length error messages.
|
||||
`std::exception` which can cope with arbitrary-length error messages.
|
||||
Intermediate strings are built with static functions and then passed to
|
||||
the actual constructor.
|
||||
@endinternal
|
||||
@@ -2373,7 +2373,7 @@ class exception : public std::exception
|
||||
|
||||
private:
|
||||
/// an exception object as storage for error messages
|
||||
std::runtime_error m;
|
||||
std::exception m;
|
||||
};
|
||||
|
||||
/*!
|
||||
@@ -4823,7 +4823,7 @@ class input_stream_adapter
|
||||
std::char_traits<char>::int_type get_character()
|
||||
{
|
||||
auto res = sb->sbumpc();
|
||||
// set eof manually, as we don't use the istream interface.
|
||||
// set eof manually, as we don't use the istream interfaces.
|
||||
if (JSON_HEDLEY_UNLIKELY(res == EOF))
|
||||
{
|
||||
is->clear(is->rdstate() | std::ios::eofbit);
|
||||
@@ -5191,9 +5191,9 @@ namespace nlohmann
|
||||
{
|
||||
|
||||
/*!
|
||||
@brief SAX interface
|
||||
@brief SAX interfaces
|
||||
|
||||
This class describes the SAX interface used by @ref nlohmann::json::sax_parse.
|
||||
This class describes the SAX interfaces used by @ref nlohmann::json::sax_parse.
|
||||
Each function is called in different situations while the input is parsed. The
|
||||
boolean return value informs the parser whether to continue processing the
|
||||
input.
|
||||
@@ -5314,7 +5314,7 @@ namespace detail
|
||||
/*!
|
||||
@brief SAX implementation to create a JSON value from SAX events
|
||||
|
||||
This class implements the @ref json_sax interface and processes the SAX events
|
||||
This class implements the @ref json_sax interfaces and processes the SAX events
|
||||
to create a JSON value which makes it basically a DOM parser. The structure or
|
||||
hierarchy of the JSON value is managed by the stack `ref_stack` which contains
|
||||
a pointer to the respective array or object for each recursion depth.
|
||||
@@ -7198,7 +7198,7 @@ scan_number_done:
|
||||
/*
|
||||
@brief get next character from the input
|
||||
|
||||
This function provides the interface to the used input adapter. It does
|
||||
This function provides the interfaces to the used input adapter. It does
|
||||
not throw in case the input reached EOF, but returns a
|
||||
`std::char_traits<char>::eof()` in that case. Stores the scanned characters
|
||||
for use in error messages.
|
||||
@@ -9881,7 +9881,7 @@ class binary_reader
|
||||
/*!
|
||||
@brief get next character from the input
|
||||
|
||||
This function provides the interface to the used input adapter. It does
|
||||
This function provides the interfaces to the used input adapter. It does
|
||||
not throw in case the input reached EOF, but returns a -'ve valued
|
||||
`std::char_traits<char_type>::eof()` in that case.
|
||||
|
||||
@@ -10184,7 +10184,7 @@ class parser
|
||||
}
|
||||
|
||||
/*!
|
||||
@brief public parser interface
|
||||
@brief public parser interfaces
|
||||
|
||||
@param[in] strict whether to expect the last token to be EOF
|
||||
@param[in,out] result parsed JSON value
|
||||
@@ -10249,7 +10249,7 @@ class parser
|
||||
}
|
||||
|
||||
/*!
|
||||
@brief public accept interface
|
||||
@brief public accept interfaces
|
||||
|
||||
@param[in] strict whether to expect the last token to be EOF
|
||||
@return whether the input is a proper JSON text
|
||||
@@ -12628,7 +12628,7 @@ namespace nlohmann
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
/// abstract output adapter interface
|
||||
/// abstract output adapter interfaces
|
||||
template<typename CharType> struct output_adapter_protocol
|
||||
{
|
||||
virtual void write_character(CharType c) = 0;
|
||||
@@ -16724,7 +16724,7 @@ class basic_json
|
||||
using initializer_list_t = std::initializer_list<detail::json_ref<basic_json>>;
|
||||
|
||||
using input_format_t = detail::input_format_t;
|
||||
/// SAX interface type, see @ref nlohmann::json_sax
|
||||
/// SAX interfaces type, see @ref nlohmann::json_sax
|
||||
using json_sax_t = json_sax<basic_json>;
|
||||
|
||||
////////////////
|
||||
@@ -21253,7 +21253,7 @@ class basic_json
|
||||
element as string (see example).
|
||||
|
||||
@param[in] ref reference to a JSON value
|
||||
@return iteration proxy object wrapping @a ref with an interface to use in
|
||||
@return iteration proxy object wrapping @a ref with an interfaces to use in
|
||||
range-based for loops
|
||||
|
||||
@liveexample{The following code shows how the wrapper is used,iterator_wrapper}
|
||||
@@ -21341,7 +21341,7 @@ class basic_json
|
||||
<https://github.com/nlohmann/json/issues/2040> for more
|
||||
information.
|
||||
|
||||
@return iteration proxy object wrapping @a ref with an interface to use in
|
||||
@return iteration proxy object wrapping @a ref with an interfaces to use in
|
||||
range-based for loops
|
||||
|
||||
@liveexample{The following code shows how the function is used.,items}
|
||||
@@ -23249,7 +23249,7 @@ class basic_json
|
||||
/*!
|
||||
@brief generate SAX events
|
||||
|
||||
The SAX event lister must follow the interface of @ref json_sax.
|
||||
The SAX event lister must follow the interfaces of @ref json_sax.
|
||||
|
||||
This function reads from a compatible input. Examples are:
|
||||
- an std::istream object
|
||||
|
||||
Vendored
+1
-1
@@ -264,7 +264,7 @@ typedef int
|
||||
const lzo_bytep dict, lzo_uint dict_len );
|
||||
|
||||
|
||||
/* Callback interface. Currently only the progress indicator ("nprogress")
|
||||
/* Callback interfaces. Currently only the progress indicator ("nprogress")
|
||||
* is used, but this may change in a future release. */
|
||||
|
||||
struct lzo_callback_t;
|
||||
|
||||
Vendored
+57
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* sys/mman.h
|
||||
* mman-win32
|
||||
*/
|
||||
|
||||
#ifndef _SYS_MMAN_H_
|
||||
#define _SYS_MMAN_H_
|
||||
|
||||
#ifndef _WIN32_WINNT // Allow use of features specific to Windows XP or later.
|
||||
#define _WIN32_WINNT 0x0501 // Change this to the appropriate value to target other versions of Windows.
|
||||
#endif
|
||||
|
||||
/* All the headers include this file. */
|
||||
#ifndef _MSC_VER
|
||||
#include <_mingw.h>
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define PROT_NONE 0
|
||||
#define PROT_READ 1
|
||||
#define PROT_WRITE 2
|
||||
#define PROT_EXEC 4
|
||||
|
||||
#define MAP_FILE 0
|
||||
#define MAP_SHARED 1
|
||||
#define MAP_PRIVATE 2
|
||||
#define MAP_TYPE 0xf
|
||||
#define MAP_FIXED 0x10
|
||||
#define MAP_ANONYMOUS 0x20
|
||||
#define MAP_32BIT 0x40 /* Only give out 32-bit addresses. */
|
||||
#define MAP_ANON MAP_ANONYMOUS
|
||||
|
||||
#define MAP_FAILED ((void *)-1)
|
||||
|
||||
/* Flags for msync. */
|
||||
#define MS_ASYNC 1
|
||||
#define MS_SYNC 2
|
||||
#define MS_INVALIDATE 4
|
||||
#define MAP_POPULATE 0x08000
|
||||
|
||||
void* mmap(void *addr, size_t len, int prot, int flags, int fildes, off_t off);
|
||||
int munmap(void *addr, size_t len);
|
||||
int mprotect(void *addr, size_t len, int prot);
|
||||
int msync(void *addr, size_t len, int flags);
|
||||
int mlock(const void *addr, size_t len);
|
||||
int munlock(const void *addr, size_t len);
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif
|
||||
|
||||
#endif /* _SYS_MMAN_H_ */
|
||||
Reference in New Issue
Block a user