kernel: macos/linux Implement sceKernelUuidCreate (#2923)

* kernel: macos/linux Implement sceKernelUuidCreate

* Fix clang-format

* Fix Linux build

* Fix Linux build (2)

---------

Co-authored-by: squidbus <175574877+squidbus@users.noreply.github.com>
This commit is contained in:
Roman 2025-05-13 12:10:33 +07:00 committed by GitHub
parent 6bbb424c28
commit 2a3a701115
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 20 additions and 4 deletions

View file

@ -1094,9 +1094,13 @@ if (ENABLE_DISCORD_RPC)
target_compile_definitions(shadps4 PRIVATE ENABLE_DISCORD_RPC) target_compile_definitions(shadps4 PRIVATE ENABLE_DISCORD_RPC)
endif() endif()
# Optional due to https://github.com/shadps4-emu/shadPS4/issues/1704 if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux" AND ENABLE_USERFAULTFD) # Optional due to https://github.com/shadps4-emu/shadPS4/issues/1704
target_compile_definitions(shadps4 PRIVATE ENABLE_USERFAULTFD) if (ENABLE_USERFAULTFD)
target_compile_definitions(shadps4 PRIVATE ENABLE_USERFAULTFD)
endif()
target_link_libraries(shadps4 PRIVATE uuid)
endif() endif()
if (APPLE) if (APPLE)

View file

@ -28,6 +28,8 @@
#ifdef _WIN64 #ifdef _WIN64
#include <Rpc.h> #include <Rpc.h>
#else
#include <uuid/uuid.h>
#endif #endif
#include <common/singleton.h> #include <common/singleton.h>
#include "aio.h" #include "aio.h"
@ -164,7 +166,17 @@ int PS4_SYSV_ABI sceKernelUuidCreate(OrbisKernelUuid* orbisUuid) {
orbisUuid->node[i] = uuid.Data4[2 + i]; orbisUuid->node[i] = uuid.Data4[2 + i];
} }
#else #else
LOG_ERROR(Kernel, "sceKernelUuidCreate: Add linux"); uuid_t uuid;
uuid_generate(uuid);
orbisUuid->timeLow =
((u32)uuid[0] << 24) | ((u32)uuid[1] << 16) | ((u32)uuid[2] << 8) | (u32)uuid[3];
orbisUuid->timeMid = ((u16)uuid[4] << 8) | uuid[5];
orbisUuid->timeHiAndVersion = ((u16)uuid[6] << 8) | uuid[7];
orbisUuid->clockSeqHiAndReserved = uuid[8];
orbisUuid->clockSeqLow = uuid[9];
for (int i = 0; i < 6; i++) {
orbisUuid->node[i] = uuid[10 + i];
}
#endif #endif
return 0; return 0;
} }