mirror of
https://github.com/boykopovar/AnyPS5.git
synced 2026-10-28 00:35:47 +00:00
Merge pull request #5992 from Get-fix/ps4/libkernel-underscore-io
fix(libkernel): export _readv, _writev, _fcntl, _fstat, __sys_socketex
This commit is contained in:
5 files changed
+49
-2
No files matched your search
@@ -786,6 +786,10 @@ int64_t APS5_VABI fstat_nid_disambig1_nid_postfix(int d, FileStat* sb) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int64_t APS5_VABI _fstat_nid_postfix(int d, FileStat* sb) {
|
||||
return fstat_nid_disambig1_nid_postfix(d, sb);
|
||||
}
|
||||
|
||||
int APS5_VABI ftruncate_nid_postfix(int d, int64_t length) {
|
||||
if (length < 0 || GuestSockets::IsOpen(d)) {
|
||||
return PosixFailure(GUEST_EINVAL);
|
||||
@@ -1439,4 +1443,12 @@ int64_t APS5_VABI writev_nid_postfix(int d, const KernelIovec* iov, int iovcnt)
|
||||
return result < 0 ? PosixFailure(static_cast<int>(result) & 0xffff) : result;
|
||||
}
|
||||
|
||||
int64_t APS5_VABI _readv_nid_postfix(int d, const KernelIovec* iov, int iovcnt) {
|
||||
return readv_nid_postfix(d, iov, iovcnt);
|
||||
}
|
||||
|
||||
int64_t APS5_VABI _writev_nid_postfix(int d, const KernelIovec* iov, int iovcnt) {
|
||||
return writev_nid_postfix(d, iov, iovcnt);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -943,6 +943,20 @@ int APS5_VABI fcntl_nid_postfix(int descriptor, int command, ...) {
|
||||
socket->options.nonblocking = enabled != 0;
|
||||
return 0;
|
||||
}
|
||||
int APS5_VABI _fcntl_nid_postfix(int descriptor, int command, ...) {
|
||||
#ifdef _WIN32
|
||||
__builtin_sysv_va_list arguments;
|
||||
__builtin_sysv_va_start(arguments, command);
|
||||
const auto argument = __builtin_va_arg(arguments, std::uint64_t);
|
||||
__builtin_sysv_va_end(arguments);
|
||||
#else
|
||||
std::va_list arguments;
|
||||
va_start(arguments, command);
|
||||
const auto argument = va_arg(arguments, std::uint64_t);
|
||||
va_end(arguments);
|
||||
#endif
|
||||
return fcntl_nid_postfix(descriptor, command, argument);
|
||||
}
|
||||
int APS5_VABI setsockopt_nid_postfix(int descriptor, int level, int option,
|
||||
const void* value, std::uint32_t length) {
|
||||
int netError = 0;
|
||||
@@ -1003,6 +1017,10 @@ int APS5_VABI socket_nid_postfix(int family, int type, int protocol) {
|
||||
return Fail(12);
|
||||
}
|
||||
}
|
||||
int APS5_VABI __sys_socketex_nid_postfix(const char* name, int family, int type, int protocol) {
|
||||
static_cast<void>(name);
|
||||
return socket_nid_postfix(family, type, protocol);
|
||||
}
|
||||
int APS5_VABI socketpair_nid_postfix(int family, int type, int protocol, int* descriptors) {
|
||||
const bool nonblocking = (type & GuestNonBlocking) != 0;
|
||||
const int plainType = type & ~(GuestCloseOnExec | GuestNonBlocking);
|
||||
|
||||
@@ -19,6 +19,7 @@ int APS5_VABI stat_nid_postfix(const char*, FileStat*);
|
||||
int APS5_VABI lstat_nid_postfix(const char*, FileStat*);
|
||||
int APS5_VABI sceKernelFstat(int, FileStat*);
|
||||
std::int64_t APS5_VABI fstat_nid_disambig1_nid_postfix(int, FileStat*);
|
||||
std::int64_t APS5_VABI _fstat_nid_postfix(int, FileStat*);
|
||||
int APS5_VABI open_nid_postfix(const char*, int, int);
|
||||
int APS5_VABI close_nid_postfix(int);
|
||||
int APS5_VABI pipe_nid_postfix(int*);
|
||||
@@ -37,11 +38,12 @@ static bool Same(const KernelTimespec& actual, const KernelTimeval& expected) {
|
||||
}
|
||||
|
||||
static void CheckTimes(const std::string& path, int fd, const KernelTimeval* expected) {
|
||||
FileStat byPath{}, byFd{}, byKernel{};
|
||||
FileStat byPath{}, byFd{}, byKernel{}, byAlias{};
|
||||
Require(stat_nid_postfix(path.c_str(), &byPath) == 0, "stat");
|
||||
Require(fstat_nid_disambig1_nid_postfix(fd, &byFd) == 0, "fstat");
|
||||
Require(sceKernelFstat(fd, &byKernel) == 0, "sceKernelFstat");
|
||||
for (const auto* status : {&byPath, &byFd, &byKernel}) {
|
||||
Require(_fstat_nid_postfix(fd, &byAlias) == 0, "_fstat");
|
||||
for (const auto* status : {&byPath, &byFd, &byKernel, &byAlias}) {
|
||||
Require(Same(status->st_atim, expected[0]), "access time preserves microseconds");
|
||||
Require(Same(status->st_mtim, expected[1]), "modification time preserves microseconds");
|
||||
}
|
||||
|
||||
@@ -41,6 +41,8 @@ int APS5_VABI sceKernelLseek(int, std::int64_t, int);
|
||||
std::int64_t APS5_VABI sceKernelReadv(int, const GuestIovec*, int);
|
||||
std::int64_t APS5_VABI readv_nid_postfix(int, const GuestIovec*, int);
|
||||
std::int64_t APS5_VABI writev_nid_postfix(int, const GuestIovec*, int);
|
||||
std::int64_t APS5_VABI _readv_nid_postfix(int, const GuestIovec*, int);
|
||||
std::int64_t APS5_VABI _writev_nid_postfix(int, const GuestIovec*, int);
|
||||
int* APS5_VABI __error_nid_postfix();
|
||||
std::int64_t APS5_VABI sceKernelWritev(int, const GuestIovec*, int);
|
||||
std::int64_t APS5_VABI sceKernelPreadv(int, const GuestIovec*, int, std::int64_t);
|
||||
@@ -200,6 +202,8 @@ int main() {
|
||||
Require(sceKernelLseek(file, 0, 1) == 7);
|
||||
Require(readv_nid_postfix(file, reads, 2) == 3);
|
||||
Require(readv_nid_postfix(file, reads, 2) == 0);
|
||||
Require(sceKernelLseek(file, 3, 0) == 3 && _readv_nid_postfix(file, reads, 2) == 7);
|
||||
Require(std::memcmp(first, "345", 3) == 0 && std::memcmp(second, "6789", 4) == 0);
|
||||
Require(readv_nid_postfix(file, reads, -1) == -1 && *__error_nid_postfix() == 22);
|
||||
Require(writev_nid_postfix(file, nullptr, 1) == -1 && *__error_nid_postfix() == 14);
|
||||
|
||||
@@ -224,6 +228,9 @@ int main() {
|
||||
Require(sceKernelLseek(file, 0, 1) == 13 && Contents(path) == "01ABCDE7CDEAB");
|
||||
Require(sceKernelLseek(file, 8, 0) == 8 && writev_nid_postfix(file, writes, 2) == 5);
|
||||
Require(Contents(path) == "01ABCDE7ABCDE");
|
||||
Require(sceKernelLseek(file, 8, 0) == 8 && _writev_nid_postfix(file, swapped, 2) == 5);
|
||||
Require(sceKernelLseek(file, 0, 1) == 13 && Contents(path) == "01ABCDE7CDEAB");
|
||||
Require(sceKernelLseek(file, 8, 0) == 8 && writev_nid_postfix(file, writes, 2) == 5);
|
||||
|
||||
GuestIovec gapped[3] = {{first, 2}, {nullptr, 0}, {second, 3}};
|
||||
Require(sceKernelPreadv(file, gapped, 3, 0) == 5);
|
||||
|
||||
@@ -11,9 +11,11 @@
|
||||
#include <thread>
|
||||
extern "C" {
|
||||
int APS5_VABI socket_nid_postfix(int, int, int);
|
||||
int APS5_VABI __sys_socketex_nid_postfix(const char*, int, int, int);
|
||||
int APS5_VABI close_nid_postfix(int);
|
||||
int APS5_VABI pipe_nid_postfix(int*);
|
||||
int APS5_VABI fcntl_nid_postfix(int, int, ...);
|
||||
int APS5_VABI _fcntl_nid_postfix(int, int, ...);
|
||||
int APS5_VABI ioctl_nid_postfix(int, std::uint64_t, void*);
|
||||
std::int64_t APS5_VABI read_nid_postfix(int, void*, std::uint64_t);
|
||||
std::int64_t APS5_VABI write_nid_postfix(int, const char*, std::int64_t);
|
||||
@@ -110,6 +112,8 @@ static void SocketsKeepTheirPath() {
|
||||
Require(sceKernelFcntl(socket, GetFlags) == SceEbadf);
|
||||
Require(sceKernelFcntl(-1, GetFlags) == SceEbadf);
|
||||
Require(sceKernelFcntl(12345, GetFlags) == SceEbadf);
|
||||
const int named = __sys_socketex_nid_postfix("probe", 2, 1, 0);
|
||||
Require(named >= 0 && sceKernelFcntl(named, GetFlags) == ReadWrite && close_nid_postfix(named) == 0);
|
||||
}
|
||||
|
||||
static void FileFlagsRoundTrip() {
|
||||
@@ -166,6 +170,10 @@ static void FileFlagsRoundTrip() {
|
||||
Require(fcntl_nid_postfix(file, SetLock, &lock) == 0);
|
||||
GuestLock probe{0, 0, 0, 1, 0, 0};
|
||||
Require(fcntl_nid_postfix(file, GetLock, &probe) == 0 && probe.type == 2);
|
||||
static GuestLock imageProbe{0, 0, 0, 1, 0, 0};
|
||||
Require(_fcntl_nid_postfix(file, GetLock, &imageProbe) == 0 && imageProbe.type == 2);
|
||||
Require(_fcntl_nid_postfix(file, SetDescriptorFlags, 1) == 0 && _fcntl_nid_postfix(file, GetDescriptorFlags) == 1);
|
||||
Require(_fcntl_nid_postfix(file, SetDescriptorFlags, 0) == 0);
|
||||
lock.type = 2;
|
||||
Require(fcntl_nid_postfix(file, SetLock, &lock) == 0);
|
||||
lock.type = 7;
|
||||
|
||||
Reference in new issue
Block a user