format all source code with clang-format

This commit is contained in:
DH 2025-04-05 22:50:45 +03:00
parent 6bbaf18e71
commit 42cb5d7977
1234 changed files with 90082 additions and 82954 deletions

View file

@ -110,9 +110,9 @@ enum class ErrorCode : int {
};
} // namespace orbis
#define ORBIS_RET_ON_ERROR(...) \
do { \
if (auto errc___ = (__VA_ARGS__); errc___ != ::orbis::ErrorCode{}) { \
return errc___; \
} \
#define ORBIS_RET_ON_ERROR(...) \
do { \
if (auto errc___ = (__VA_ARGS__); errc___ != ::orbis::ErrorCode{}) { \
return errc___; \
} \
} while (false)

View file

@ -65,8 +65,8 @@ struct ProcessOps {
uint64_t arg3);
SysResult (*dynlib_unload_prx)(Thread *thread, ModuleHandle handle);
SysResult (*thr_create)(Thread *thread, ptr<UContext> ctxt,
ptr<slong> arg, sint flags);
SysResult (*thr_create)(Thread *thread, ptr<UContext> ctxt, ptr<slong> arg,
sint flags);
SysResult (*thr_new)(Thread *thread, ptr<thr_param> param, sint param_size);
SysResult (*thr_exit)(Thread *thread, ptr<slong> state);
SysResult (*thr_kill)(Thread *thread, slong id, sint sig);

View file

@ -83,7 +83,6 @@ struct UContext {
static_assert(sizeof(UContext) == 0x500);
enum Signal {
kSigHup = 1,
kSigInt = 2,

View file

@ -1,7 +1,7 @@
#pragma once
#include "orbis-config.hpp"
#include "error/ErrorCode.hpp"
#include "orbis-config.hpp"
#include <cstddef>
#include <cstdint>
#include <cstring>
@ -49,8 +49,7 @@ struct Uio {
return {};
}
template<typename T>
ErrorCode write(const T &object) {
template <typename T> ErrorCode write(const T &object) {
return write(&object, sizeof(T));
}
};

View file

@ -54,7 +54,6 @@ inline constexpr auto kUmtxOpNwakePrivate = 21;
inline constexpr auto kUmtxOpMutexWake2 = 22;
inline constexpr auto kUmtxOpMutexWake3 = 23;
inline constexpr auto kSemNamed = 2;
struct umtx {

View file

@ -203,7 +203,8 @@ static orbis::SysResult doRelocation(orbis::Process *process,
auto &defModule = module->importedModules.at(symbol.moduleIndex);
if (!defModule) {
// std::printf("'%s' ('%s') uses undefined symbol '%llx' in unloaded module "
// std::printf("'%s' ('%s') uses undefined symbol '%llx' in unloaded
// module "
// "'%s', rel %u\n",
// module->moduleName, module->soName,
// (unsigned long long)symbol.id,
@ -295,7 +296,8 @@ static orbis::SysResult doRelocation(orbis::Process *process,
if (defObj == nullptr) {
return orbis::ErrorCode::INVAL;
}
*where32 = S ? reinterpret_cast<std::uintptr_t>(defObj->base) + S + A - P : 0;
*where32 =
S ? reinterpret_cast<std::uintptr_t>(defObj->base) + S + A - P : 0;
return {};
}
// case kRelCopy:

View file

@ -12,8 +12,8 @@ static orbis::ErrorCode pipe_read(orbis::File *file, orbis::Uio *uio,
while (true) {
if (pipe->data.empty()) {
// pipe->cv.wait(file->mtx);
// ORBIS_LOG_ERROR(__FUNCTION__, "wakeup", thread->name, thread->tid, file);
// continue;
// ORBIS_LOG_ERROR(__FUNCTION__, "wakeup", thread->name, thread->tid,
// file); continue;
return orbis::ErrorCode::WOULDBLOCK;
}
@ -32,7 +32,8 @@ static orbis::ErrorCode pipe_read(orbis::File *file, orbis::Uio *uio,
uio->offset += size;
std::memcpy(vec.base, pipe->data.data(), size);
ORBIS_LOG_ERROR(__FUNCTION__, thread->name, thread->tid, file, size, pipe->data.size(), uio->offset, file->nextOff);
ORBIS_LOG_ERROR(__FUNCTION__, thread->name, thread->tid, file, size,
pipe->data.size(), uio->offset, file->nextOff);
if (pipe->data.size() == size) {
pipe->data.clear();
@ -69,9 +70,10 @@ static orbis::ErrorCode pipe_write(orbis::File *file, orbis::Uio *uio,
uio->resid -= cnt;
uio->offset += cnt;
ORBIS_LOG_ERROR(__FUNCTION__, thread->name, thread->tid, file, uio->resid, uio->offset, file->nextOff, cnt);
ORBIS_LOG_ERROR(__FUNCTION__, thread->name, thread->tid, file, uio->resid,
uio->offset, file->nextOff, cnt);
thread->where();
return{};
return {};
}
static orbis::FileOps pipe_ops = {
@ -79,7 +81,8 @@ static orbis::FileOps pipe_ops = {
.write = pipe_write,
};
std::pair<orbis::Ref<orbis::Pipe>, orbis::Ref<orbis::Pipe>> orbis::createPipe() {
std::pair<orbis::Ref<orbis::Pipe>, orbis::Ref<orbis::Pipe>>
orbis::createPipe() {
auto a = knew<Pipe>();
auto b = knew<Pipe>();
a->event = knew<EventEmitter>();

View file

@ -1,15 +1,12 @@
#include "sys/sysproto.hpp"
orbis::SysResult orbis::sys_getcontext(Thread *thread,
ptr<UContext> ucp) {
orbis::SysResult orbis::sys_getcontext(Thread *thread, ptr<UContext> ucp) {
return ErrorCode::NOSYS;
}
orbis::SysResult orbis::sys_setcontext(Thread *thread,
ptr<UContext> ucp) {
orbis::SysResult orbis::sys_setcontext(Thread *thread, ptr<UContext> ucp) {
return ErrorCode::NOSYS;
}
orbis::SysResult orbis::sys_swapcontext(Thread *thread,
ptr<UContext> oucp,
orbis::SysResult orbis::sys_swapcontext(Thread *thread, ptr<UContext> oucp,
ptr<UContext> ucp) {
return ErrorCode::NOSYS;
}

View file

@ -148,7 +148,8 @@ orbis::SysResult orbis::sys_cpuset_setaffinity(Thread *thread, cpulevel_t level,
auto threadHandle = whichThread->getNativeHandle();
auto hostCpuSet = toHostCpuSet(whichThread->affinity);
ORBIS_LOG_ERROR(__FUNCTION__, threadHandle, thread->tid, id);
if (pthread_setaffinity_np(threadHandle, sizeof(hostCpuSet), &hostCpuSet)) {
if (pthread_setaffinity_np(threadHandle, sizeof(hostCpuSet),
&hostCpuSet)) {
ORBIS_LOG_ERROR(__FUNCTION__,
"failed to set affinity mask for host thread",
whichThread->hostTid, whichThread->affinity.bits);

View file

@ -2,8 +2,8 @@
#include "orbis/utils/Logs.hpp"
#include "stat.hpp"
#include "sys/sysproto.hpp"
#include "thread/Thread.hpp"
#include "thread/Process.hpp"
#include "thread/Thread.hpp"
orbis::SysResult orbis::sys_getdtablesize(Thread *thread) {
return ErrorCode::NOSYS;

View file

@ -1,7 +1,7 @@
#include "sys/sysproto.hpp"
#include "thread/Thread.hpp"
#include "thread/Process.hpp"
#include "thread/ProcessOps.hpp"
#include "thread/Thread.hpp"
orbis::SysResult orbis::sys_execve(Thread *thread, ptr<char> fname,
ptr<ptr<char>> argv, ptr<ptr<char>> envv) {

View file

@ -1,11 +1,11 @@
#include "KernelContext.hpp"
#include "sys/sysproto.hpp"
#include "thread/Process.hpp"
#include "thread/ProcessOps.hpp"
#include "utils/Logs.hpp"
#include <sys/resource.h>
#include <sys/wait.h>
#include <unistd.h>
#include "thread/Process.hpp"
orbis::SysResult orbis::sys_exit(Thread *thread, sint status) {
if (auto exit = thread->tproc->ops->exit) {

View file

@ -1,8 +1,8 @@
#include "file.hpp"
#include "orbis/utils/Logs.hpp"
#include "sys/sysproto.hpp"
#include "thread/Thread.hpp"
#include "thread/Process.hpp"
#include "thread/Thread.hpp"
#include "uio.hpp"
#include <sstream>

View file

@ -1,6 +1,6 @@
#include "sys/sysproto.hpp"
#include "thread/Thread.hpp"
#include "thread/Process.hpp"
#include "thread/Thread.hpp"
#include "utils/Logs.hpp"
#include <pipe.hpp>

View file

@ -59,12 +59,12 @@ orbis::SysResult orbis::sys_rtprio_thread(Thread *thread, sint function,
hostPolicy = SCHED_IDLE;
}
if (pthread_setschedparam(targetThread->getNativeHandle(),
hostPolicy, &hostParam)) {
ORBIS_LOG_ERROR(__FUNCTION__, "failed to set host priority",
hostPriority, targetThread->prio.prio,
targetThread->prio.type, errno,
targetThread->getNativeHandle(), prioMin, prioMax, errno);
if (pthread_setschedparam(targetThread->getNativeHandle(), hostPolicy,
&hostParam)) {
ORBIS_LOG_ERROR(
__FUNCTION__, "failed to set host priority", hostPriority,
targetThread->prio.prio, targetThread->prio.type, errno,
targetThread->getNativeHandle(), prioMin, prioMax, errno);
}
} else {
ORBIS_LOG_ERROR(__FUNCTION__, "set host priority", hostPriority,

View file

@ -1165,8 +1165,7 @@ orbis::sys_dynlib_get_info_ex(Thread *thread, SceKernelModule handle,
result.ehFrame = module->ehFrame;
result.ehFrameHdrSize = module->ehFrameHdrSize;
result.ehFrameSize = module->ehFrameSize;
std::memcpy(result.segments, module->segments,
sizeof(ModuleSegment) * 2);
std::memcpy(result.segments, module->segments, sizeof(ModuleSegment) * 2);
result.segmentCount = 2;
result.refCount = 1;
ORBIS_LOG_WARNING(__FUNCTION__, result.id, result.name, result.tlsIndex,

View file

@ -140,14 +140,15 @@ orbis::SysResult orbis::sys_sigreturn(Thread *thread, ptr<UContext> sigcntxp) {
ORBIS_LOG_WARNING(__FUNCTION__, sigcntxp);
// auto sigRet = thread->sigReturns.front();
// thread->sigReturns.erase(thread->sigReturns.begin(), thread->sigReturns.begin() + 1);
// writeRegister(thread->context, RegisterId::rip, sigRet.rip);
// writeRegister(thread->context, RegisterId::rsp, sigRet.rsp);
// ORBIS_LOG_ERROR(__FUNCTION__, sigRet.rip, sigRet.rsp);
// thread->sigReturns.erase(thread->sigReturns.begin(),
// thread->sigReturns.begin() + 1); writeRegister(thread->context,
// RegisterId::rip, sigRet.rip); writeRegister(thread->context,
// RegisterId::rsp, sigRet.rsp); ORBIS_LOG_ERROR(__FUNCTION__, sigRet.rip,
// sigRet.rsp);
return {};
}
orbis::SysResult orbis::nosys(Thread *thread) {
thread->sendSignal(kSigSys);
return{};
return {};
}

View file

@ -2,6 +2,6 @@
#include <thread>
orbis::SysResult orbis::sys_yield(Thread *thread) {
std::this_thread::yield();
return {};
std::this_thread::yield();
return {};
}

View file

@ -1,11 +1,10 @@
#include "sys/sysproto.hpp"
#include "thread/Process.hpp"
#include "thread/ProcessOps.hpp"
#include "thread/Thread.hpp"
#include "thread/Process.hpp"
#include "ucontext.hpp"
orbis::SysResult orbis::sys_thr_create(Thread *thread,
ptr<UContext> ctxt,
orbis::SysResult orbis::sys_thr_create(Thread *thread, ptr<UContext> ctxt,
ptr<slong> arg, sint flags) {
if (auto thr_create = thread->tproc->ops->thr_create) {
return thr_create(thread, ctxt, arg, flags);

View file

@ -1,8 +1,8 @@
#include "file.hpp"
#include "sys/sysproto.hpp"
#include "thread/Process.hpp"
#include "thread/ProcessOps.hpp"
#include "thread/Thread.hpp"
#include "thread/Process.hpp"
#include "uio.hpp"
#include "utils/Logs.hpp"
#include <sys/socket.h>
@ -128,7 +128,8 @@ orbis::SysResult orbis::sys_recvfrom(Thread *thread, sint s, caddr_t buf,
}
if (auto recvfrom = file->ops->recvfrom) {
return SysResult::notAnError(recvfrom(file.get(), buf, len, flags, from, fromlenaddr, thread));
return SysResult::notAnError(
recvfrom(file.get(), buf, len, flags, from, fromlenaddr, thread));
}
return ErrorCode::NOTSUP;

View file

@ -1,9 +1,9 @@
#include "file.hpp"
#include "orbis-config.hpp"
#include "sys/sysproto.hpp"
#include "thread/Process.hpp"
#include "thread/ProcessOps.hpp"
#include "thread/Thread.hpp"
#include "thread/Process.hpp"
orbis::SysResult orbis::sys_shm_open(Thread *thread, ptr<const char> path,
sint flags, mode_t mode) {

View file

@ -1,8 +1,8 @@
#include "stat.hpp"
#include "sys/sysproto.hpp"
#include "thread/Process.hpp"
#include "thread/ProcessOps.hpp"
#include "thread/Thread.hpp"
#include "thread/Process.hpp"
#include "utils/Logs.hpp"
#include <filesystem>
#include <span>
@ -71,8 +71,8 @@ orbis::SysResult orbis::sys_chroot(Thread *thread, ptr<char> path) {
}
// volatile bool debuggerPresent = false;
orbis::SysResult orbis::sys_open(Thread *thread, ptr<const char> path, sint flags,
sint mode) {
orbis::SysResult orbis::sys_open(Thread *thread, ptr<const char> path,
sint flags, sint mode) {
if (auto open = thread->tproc->ops->open) {
Ref<File> file;
auto result = open(thread, path, flags, mode, &file);
@ -82,16 +82,18 @@ orbis::SysResult orbis::sys_open(Thread *thread, ptr<const char> path, sint flag
auto fd = thread->tproc->fileDescriptors.insert(file);
thread->retval[0] = fd;
// if (path == std::string_view{"/app0/psm/Application/resource/Sce.Vsh.ShellUI.SystemMessage.rco"}) {
// if (path ==
// std::string_view{"/app0/psm/Application/resource/Sce.Vsh.ShellUI.SystemMessage.rco"})
// {
ORBIS_LOG_SUCCESS(__FUNCTION__, thread->tid, path, flags, mode, fd);
if (path == std::string_view{"/app0/wave/wave1.fbxd"}) {
thread->where();
}
// while (debuggerPresent == false) {
// std::this_thread::sleep_for(std::chrono::seconds(1));
// }
// // thread->where();
// while (debuggerPresent == false) {
// std::this_thread::sleep_for(std::chrono::seconds(1));
// }
// // thread->where();
// }
return {};
}
@ -288,13 +290,14 @@ orbis::SysResult orbis::sys_readlink(Thread *thread, ptr<char> path,
}
Ref<File> file;
if (auto error = thread->tproc->ops->open(thread, path, 0, 0, &file); error.value()) {
if (auto error = thread->tproc->ops->open(thread, path, 0, 0, &file);
error.value()) {
return error;
}
ORBIS_RET_ON_ERROR(uwriteRaw(buf, _path, pathLen));
thread->retval[0] = pathLen;
return{};
return {};
}
orbis::SysResult orbis::sys_readlinkat(Thread *thread, sint fd, ptr<char> path,
ptr<char> buf, size_t bufsize) {

View file

@ -1,14 +1,14 @@
#include "sys/sysproto.hpp"
#include "thread/Thread.hpp"
#include "thread/Process.hpp"
#include "thread/Thread.hpp"
#include <mutex>
#include <string>
orbis::SysResult orbis::sys___getcwd(Thread *thread, ptr<char> buf,
uint buflen) {
std::string cwd;
{
std::lock_guard lock(thread->tproc->mtx);
cwd = std::string(thread->tproc->cwd);
@ -19,5 +19,5 @@ orbis::SysResult orbis::sys___getcwd(Thread *thread, ptr<char> buf,
}
ORBIS_RET_ON_ERROR(uwriteRaw(buf, cwd.data(), cwd.size() + 1));
return{};
return {};
}

View file

@ -1,7 +1,7 @@
#include "sys/sysproto.hpp"
#include "thread/Process.hpp"
#include "thread/ProcessOps.hpp"
#include "thread/Thread.hpp"
#include "thread/Process.hpp"
orbis::SysResult orbis::sys_mount(Thread *thread, ptr<char> type,
ptr<char> path, sint flags, caddr_t data) {

View file

@ -1,8 +1,8 @@
#include "error.hpp"
#include "sys/sysproto.hpp"
#include "thread/Process.hpp"
#include "thread/ProcessOps.hpp"
#include "thread/Thread.hpp"
#include "thread/Process.hpp"
orbis::SysResult orbis::sys_sbrk(Thread *, sint) {
return ErrorCode::OPNOTSUPP;

View file

@ -47,7 +47,8 @@ void shared_mutex::impl_lock_shared(unsigned val) {
if ((old % c_sig) + c_one >= c_sig)
std::abort(); // "shared_mutex overflow"
while (impl_wait() != std::errc{}) {}
while (impl_wait() != std::errc{}) {
}
lock_downgrade();
}
void shared_mutex::impl_unlock_shared(unsigned old) {
@ -80,7 +81,7 @@ std::errc shared_mutex::impl_wait() {
}
}
return{};
return {};
}
void shared_mutex::impl_signal() {
m_value += c_sig;
@ -120,7 +121,8 @@ void shared_mutex::impl_lock(unsigned val) {
if ((old % c_sig) + c_one >= c_sig)
std::abort(); // "shared_mutex overflow"
while (impl_wait() != std::errc{}) {}
while (impl_wait() != std::errc{}) {
}
}
void shared_mutex::impl_unlock(unsigned old) {
if (old - c_one >= c_err)
@ -152,7 +154,8 @@ void shared_mutex::impl_lock_upgrade() {
return;
}
while (impl_wait() != std::errc{}) {}
while (impl_wait() != std::errc{}) {
}
}
bool shared_mutex::lock_forced(int count) {
if (count == 0)