Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions core/libs/prx/libkernel/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,16 @@ if(BUILD_TESTING)
set_tests_properties(guest_getrusage PROPERTIES ENVIRONMENT_MODIFICATION
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libkernel>")
endif()
add_test_executable(guest_sched_priority_tests ${LIBS_INCLUDE_DIR}/tests/GuestSchedPriority.cpp)
target_include_directories(guest_sched_priority_tests PRIVATE ${LIBS_INCLUDE_DIR})
target_link_libraries(guest_sched_priority_tests PRIVATE libkernel libc)
configure_windows_unwind(guest_sched_priority_tests)
add_test(NAME guest_sched_priority COMMAND guest_sched_priority_tests)
set_tests_properties(guest_sched_priority PROPERTIES TIMEOUT 20)
if(WIN32)
set_tests_properties(guest_sched_priority PROPERTIES ENVIRONMENT_MODIFICATION
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libkernel>")
endif()
add_test_executable(guest_kernel_error_tests ${LIBS_INCLUDE_DIR}/tests/GuestKernelErrors.cpp)
target_include_directories(guest_kernel_error_tests PRIVATE ${LIBS_INCLUDE_DIR})
target_link_libraries(guest_kernel_error_tests PRIVATE libkernel libc)
Expand Down
2 changes: 1 addition & 1 deletion core/libs/prx/libkernel/System/src/Process.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ ProcessArguments& getProcessArguments() {
}

void validateSchedulingPolicy(int policy) {
if (policy != 1 && policy != 3)
if (policy < 1 || policy > 3)
throw std::invalid_argument("Unsupported guest scheduling policy");
}

Expand Down
19 changes: 19 additions & 0 deletions core/libs/tests/GuestSchedPriority.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#include "prx/libc/include/general/VabiMacros.hpp"
#include <cstdlib>
#include <stdexcept>
extern "C" {
int APS5_VABI sched_get_priority_max_nid_postfix(int policy);
int APS5_VABI sched_get_priority_min_nid_postfix(int policy);
}
static void Require(bool value) { if (!value) std::abort(); }
static bool Rejects(int policy) {
try { sched_get_priority_max_nid_postfix(policy); } catch (const std::invalid_argument&) { return true; }
return false;
}
int main() {
for (int policy : {1, 2, 3}) {
Require(sched_get_priority_max_nid_postfix(policy) == 256);
Require(sched_get_priority_min_nid_postfix(policy) == 767);
}
Require(Rejects(0) && Rejects(4));
}
1 change: 1 addition & 0 deletions docs/dev/TechnicalDebt.md
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ Throughout the project, every function at every stage either **does exactly what
- [scePlayerReviewDialogOpen, scePlayerReviewDialogGetResult](../../core/libs/prx/libSceCdlgPlayerReview/Export.cpp) (libSceCdlgPlayerReview) - the PS5-only dialog has no public reference: the parameter is not read and the result is assumed to start with the 32-bit common dialog result, as `sceWebBrowserDialogGetResult` assumes
- [sceHttpWaitRequest](../../core/libs/prx/libSceHttp/Export.cpp) (libSceHttp) - the timeout is assumed to be in microseconds and a negative timeout to wait without limit; the invalid-value error for a null handle or event array or a non-positive event count is assumed, not measured. No request is ever pending, so the call waits for the timeout and returns 0 events, and a wait without limit throws
- [sceVideoOutAddPreVblankStartEvent](../../core/libs/prx/libSceVideoOut/src/Event.cpp) (libSceVideoOut) - how long before the vblank the console signals pre-vblank start is unknown. The event is triggered on each emulated vblank tick immediately before the vblank event, with its own count as the event data
- [sched_get_priority_max, sched_get_priority_min](../../core/libs/prx/libkernel/System/src/Process.cpp) (libkernel) - `SCHED_OTHER` (2) reports the same 256 to 767 range as `SCHED_FIFO` and `SCHED_RR`; the console's answer is unverified. FreeBSD accepts `SCHED_OTHER` with its own range, and shadPS4 rejects it with `EINVAL`. `pthread_setschedparam` ignores the policy, so a priority taken from this range applies

- [gethostbyname](../../core/libs/prx/libScePosixForWebKit/Resolver.cpp) (libScePosixForWebKit) - numeric IPv4 forms, trailing whitespace and 64-bit accumulation follow FreeBSD 11.4 [inet_aton](https://github.com/freebsd/freebsd-src/blob/releng/11.4/lib/libc/inet/inet_addr.c); clearing the resolver error on numeric success follows [fakeaddr](https://github.com/freebsd/freebsd-src/blob/releng/11.4/lib/libc/net/gethostnamadr.c). Exact PS5 behavior is unverified; hostname lookup still uses the host resolver

Expand Down
Loading