Address compiler and test failures

This commit is contained in:
Tyler Wilding 2020-09-03 23:56:35 -04:00
parent 39eb3a90ea
commit dcde103c26
14 changed files with 47 additions and 57 deletions

View file

@ -20,6 +20,7 @@ jobs:
make -j
- name: Test Project with gTest
run: ./test.sh
timeout-minutes: 5
- name: Check Clang-Formatting
run: |
chmod +x ./third-party/run-clang-format/run-clang-format.py

View file

@ -134,7 +134,7 @@ void KernelCheckAndDispatch() {
// dispatch the kernel
//(**kernel_dispatcher)();
call_goal(Ptr<Function>(kernel_dispatcher->value), 0, 0, 0, s7.offset, g_ee_main_mem);
// TODO-WINDOWS
// TODO-WINDOWS
#ifdef __linux__
ClearPending();
#endif
@ -147,7 +147,7 @@ void KernelCheckAndDispatch() {
#ifdef _WIN32
Sleep(1000); // todo - remove this
#elif __linux__
usleep(1000);
usleep(1000);
#endif
}
}

View file

@ -71,10 +71,10 @@ void ClearPending() {
Ptr<char> msg = OutputBufArea.cast<char>() + sizeof(GoalMessageHeader);
auto size = strlen(msg.c());
// note - if size is ever greater than 2^16 this will cause an issue.
// TODO-WINDOWS
#ifdef __linux__
SendFromBuffer(msg.c(), size);
#endif
// TODO-WINDOWS
#ifdef __linux__
SendFromBuffer(msg.c(), size);
#endif
clear_output();
}
@ -87,10 +87,10 @@ void ClearPending() {
if (send_size > 64000) {
send_size = 64000;
}
// TODO-WINDOWS
#ifdef __linux__
SendFromBufferD(2, 0, msg, send_size);
#endif
// TODO-WINDOWS
#ifdef __linux__
SendFromBufferD(2, 0, msg, send_size);
#endif
size -= send_size;
msg += send_size;
}
@ -109,9 +109,11 @@ void ClearPending() {
*/
void SendAck() {
if (MasterDebug) {
#ifdef __linux__
SendFromBufferD(u16(ListenerMessageKind::MSG_ACK), protoBlock.msg_id, AckBufArea + sizeof(GoalMessageHeader), strlen(AckBufArea + sizeof(GoalMessageHeader)));
#endif
#ifdef __linux__
SendFromBufferD(u16(ListenerMessageKind::MSG_ACK), protoBlock.msg_id,
AckBufArea + sizeof(GoalMessageHeader),
strlen(AckBufArea + sizeof(GoalMessageHeader)));
#endif
}
}

View file

@ -329,10 +329,10 @@ int InitMachine() {
// }
if (MasterDebug) { // connect to GOAL compiler
// TODO-WINDOWS
#ifdef __linux__
InitGoalProto();
#endif
// TODO-WINDOWS
#ifdef __linux__
InitGoalProto();
#endif
}
printf("InitSound\n");
@ -362,10 +362,10 @@ int ShutdownMachine() {
StopIOP();
CloseListener();
ShutdownSound();
// TODO-WINDOWS
#ifdef __linux__
ShutdownGoalProto();
#endif
// TODO-WINDOWS
#ifdef __linux__
ShutdownGoalProto();
#endif
Msg(6, "kernel: machine shutdown");
return 0;
}

View file

@ -87,7 +87,7 @@ int FS_Init(u8* buffer) {
// get path to next/data/fake_iso.txt, the map file.
char fakeiso_path[512];
strcpy(fakeiso_path, next_dir);
fake_iso_path = std::getenv("FAKE_ISO_PATH");
fake_iso_path = std::getenv("FAKE_ISO_PATH");
assert(fake_iso_path);
strcat(fakeiso_path, fake_iso_path);

View file

@ -11,6 +11,7 @@
#include <third-party/mman/mman.h>
#include <Windows.h>
#endif
#include <cstring>
#include "runtime.h"
@ -55,18 +56,18 @@ namespace {
* SystemThread function for running the DECI2 communication with the GOAL compiler.
*/
void deci2_runner(SystemThreadInterface& interfaces) {
// TODO-WINDOWS
#ifdef __linux__
void deci2_runner(SystemThreadInterface& iface) {
// TODO-WINDOWS
#ifdef __linux__
// 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 iface.get_want_exit(); };
// create and register server
Deci2Server server(shutdown_callback);
ee::LIBRARY_sceDeci2_register(&server);
// now its ok to continue with initialization
interface.initialization_complete();
iface.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");
@ -78,7 +79,7 @@ void deci2_runner(SystemThreadInterface& interfaces) {
printf("[DECI2] waiting for listener...\n");
bool saw_listener = false;
while (!interface.get_want_exit()) {
while (!iface.get_want_exit()) {
if (server.check_for_listener()) {
if (!saw_listener) {
printf("[DECI2] Connected!\n");
@ -91,7 +92,7 @@ void deci2_runner(SystemThreadInterface& interfaces) {
usleep(50000);
}
}
#endif
#endif
}
// EE System
@ -235,10 +236,10 @@ void exec_runtime(int argc, char** argv) {
// step 1: sce library prep
iop::LIBRARY_INIT();
ee::LIBRARY_INIT_sceCd();
// TODO-WINDOWS
#ifdef __linux__
// TODO-WINDOWS
#ifdef __linux__
ee::LIBRARY_INIT_sceDeci2();
#endif
#endif
ee::LIBRARY_INIT_sceSif();
// step 2: system prep

View file

@ -7,12 +7,10 @@
// TODO-WINDOWS
#ifdef __linux__
#include <cstdio>
#include <sys/socket.h>
#include <netinet/tcp.h>
#include <unistd.h>
#include <cstdio>
#include <Winsock2.h>
#include <io.h>
#include <cassert>
#include <utility>
@ -20,8 +18,6 @@
#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);
@ -56,7 +52,7 @@ bool Deci2Server::init() {
return false;
}
const char opt = 1;
int opt = 1;
if (setsockopt(server_fd, SOL_SOCKET, SO_REUSEADDR | SO_REUSEPORT, &opt, sizeof(opt))) {
printf("[Deci2Server] Failed to setsockopt 1\n");
close(server_fd);
@ -64,7 +60,7 @@ bool Deci2Server::init() {
return false;
}
const char one = 1;
int one = 1;
if (setsockopt(server_fd, SOL_TCP, TCP_NODELAY, &one, sizeof(one))) {
printf("[Deci2Server] Failed to setsockopt 2\n");
close(server_fd);

View file

@ -8,7 +8,7 @@
#ifndef JAK1_DECI2SERVER_H
#define JAK1_DECI2SERVER_H
#include <Winsock2.h>
#include <netinet/in.h>
#include <thread>
#include <mutex>
#include <condition_variable>

View file

@ -99,7 +99,6 @@ void SystemThread::start(std::function<void(SystemThreadInterface&)> f) {
* Join a system thread
*/
void SystemThread::join() {
void* x;
thread.join();
running = false;
}
@ -166,5 +165,5 @@ void SystemThreadInterface::report_perf_stats() {
thread.last_cpu_user = current_user;
thread.last_collection_nanoseconds = current_ns;
}
}
}
#endif

View file

@ -10,7 +10,9 @@
#include <functional>
#include <array>
#include <mutex>
#include <thread>
#include <condition_variable>
#include "Timer.h"
constexpr int MAX_SYSTEM_THREADS = 16;

View file

@ -66,9 +66,7 @@ void TextStream::seek_past_whitespace_and_comments() {
}
}
Reader::~Reader() {
printf("destroying reader\n");
}
Reader::~Reader() {}
Reader::Reader() {
// third-party library used for a fancy line in
@ -634,7 +632,6 @@ bool Reader::try_token_as_hex(const Token& tok, Object& obj) {
* 64-bit signed. Won't accept values between INT64_MAX and UINT64_MAX.
*/
bool Reader::try_token_as_integer(const Token& tok, Object& obj) {
printf("try token as integer %ld %s\n", tok.text.size(), tok.text.c_str());
if (decimal_start(tok.text[0]) && !str_contains(tok.text, '.')) {
// determine if we look like a number or not. If we look like a number, but stoll fails,
// it means that the number is too big or too small, and we should error
@ -648,18 +645,13 @@ bool Reader::try_token_as_integer(const Token& tok, Object& obj) {
return false;
}
}
printf("going to try stoll...\n");
uint64_t v = 0;
try {
std::size_t end = 0;
v = std::stoll(tok.text, &end);
printf("stoll didn't throw, got %ld\n", v);
if (end != tok.text.size()) {
printf("didn't read whole thing\n");
return false;
}
printf("returning object!\n");
obj = Object::make_integer(v);
return true;
} catch (std::exception& e) {
@ -667,7 +659,6 @@ bool Reader::try_token_as_integer(const Token& tok, Object& obj) {
}
}
return false;
}
bool Reader::try_token_as_char(const Token& tok, Object& obj) {

View file

@ -10,8 +10,6 @@
#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"
@ -74,7 +72,7 @@ bool Listener::connect_to_target(const std::string& ip, int port) {
}
// set nodelay, which makes small rapid messages faster, but large messages slower
const char one = 1;
int one = 1;
if (setsockopt(socket_fd, SOL_TCP, TCP_NODELAY, &one, sizeof(one))) {
printf("[Listener] failed to TCP_NODELAY\n");
close(socket_fd);

View file

@ -157,7 +157,7 @@ TEST(Kernel, ftoa) {
ftoa(buffer, 1., 1, ' ', 1, 0);
EXPECT_EQ("1.0", std::string(buffer));
float zero = 0.0f;
float zero = 0.0f;
ftoa(buffer, 0.f / zero, 1, ' ', 4, 0);
EXPECT_EQ("NaN", std::string(buffer));

View file

@ -1,4 +1,4 @@
#ifdef __unix__
#ifdef __linux__
#include "gtest/gtest.h"
#include "goalc/listener/Listener.h"