Files
FEX-Emu--FEX/FEXHeaderUtils/CMakeLists.txt
T
Ryan Houdek 27309114be FHU: Convert to a interface target
Noticed recently that `FEXServer -w` was broken and couldn't understand
why. Turns out that FHU syscall handling was /always/ falling down the
`#else` path in the handlers since cmake `add_definitions` follows
folder scoping rules.

This means it was always returning -1, which was causing FEXServer's
pidfd_open usage to always receive -1, which meant the sendmsg with FD
was always failing, which meant the `FEXServer -w` would forever wait
for a message that was never sent.

Converting the utility over to a target not only fixes definition
scoping problems, but also makes the other paths actually work.

This found some compiling bugs and instead lets us define SYS_pidfd_open
if it doesn't exist. Letting the kernel return the ENOSYS if it doesn't
exist on that platform.

Main thing, fixes FEXServer -w hanging forever.
2022-09-14 14:58:23 -07:00

65 lines
1.4 KiB
CMake

add_library(FEXHeaderUtils INTERFACE)
# Check for syscall support here
check_cxx_source_compiles(
"
#include <sched.h>
int main() {
return ::getcpu(nullptr, nullptr);
}"
compiles)
if (compiles)
message(STATUS "Has getcpu helper")
target_compile_definitions(FEXHeaderUtils INTERFACE HAS_SYSCALL_GETCPU=1)
endif ()
check_cxx_source_compiles(
"
#include <unistd.h>
int main() {
return ::gettid();
}"
compiles)
if (compiles)
message(STATUS "Has gettid helper")
target_compile_definitions(FEXHeaderUtils INTERFACE HAS_SYSCALL_GETTID=1)
endif ()
check_cxx_source_compiles(
"
#include <signal.h>
int main() {
return ::tgkill(0, 0, 0);
}"
compiles)
if (compiles)
message(STATUS "Has tgkill helper")
target_compile_definitions(FEXHeaderUtils INTERFACE HAS_SYSCALL_TGKILL=1)
endif ()
check_cxx_source_compiles(
"
#include <sys/stat.h>
int main() {
return ::statx(0, nullptr, 0, 0, nullptr);
}"
compiles)
if (compiles)
message(STATUS "Has statx helper")
target_compile_definitions(FEXHeaderUtils INTERFACE HAS_SYSCALL_STATX=1)
endif ()
check_cxx_source_compiles(
"
#include <stdio.h>
int main() {
return ::renameat2(0, nullptr, 0, nullptr, 0);
}"
compiles)
if (compiles)
message(STATUS "Has renameat2 helper")
target_compile_definitions(FEXHeaderUtils INTERFACE HAS_SYSCALL_RENAMEAT2=1)
endif ()
target_include_directories(FEXHeaderUtils INTERFACE .)