#include <sys/psx_syscall.h> long int psx_syscall3(long int syscall_nr, long int arg1, long int arg2, long int arg3); long int psx_syscall6(long int syscall_nr, long int arg1, long int arg2, long int arg3, long int arg4, long int arg5, long int arg6); int psx_set_sensitivity(psx_sensitivity_t sensitivity); void psx_load_syscalls(long int (**syscall_fn)(long int, long int, long int, long int), long int (**syscall6_fn)(long int, long int, long int, long int, long int, long int, long int));Link with one of these: ld ... -lpsx -lpthread --wrap=pthread_create gcc ... -lpsx -lpthread -Wl,-wrap,pthread_create
A linker trick of wrapping the pthread_create () call with a psx thread registration function is used to ensure libpsx can keep track of all pthreads.
An inefficient macrology trick supports the psx_syscall () pseudo function which takes 1 to 7 arguments, depending on the needs of the caller. The macrology (which ultimately invokes __psx_syscall ()) pads out the call to actually use psx_syscall3 () or psx_syscall6 () with zeros filling the missing arguments. While using this in source code will make it appear clean, the actual code footprint is larger. You are encouraged to use the more explicit psx_syscall3 () and psx_syscall6 () functions as needed.
psx_set_sensitivity () changes the behavior of the mirrored system calls: PSX_IGNORE ensures that differences are ignored (the default behavior); PSX_WARNING prints a stderr notification about how the results differ; and PSX_ERROR prints the error details and generates a SIGSYS signal.
psx_load_syscalls () can be used to set caller defined function pointers for invoking 3 and 6 argument syscalls. This function can be used to configure a library, or program to change behavior when linked against libpsx . Indeed, libcap uses this function from libpsx to override its thread scoped default system call based API. When linked with libpsx ", " libcap can operate on all the threads of a multithreaded program to operate with POSIX semantics.
https://sites.google.com/site/fullycapable/who-ordered-libpsx
https://bugzilla.kernel.org/buglist.cgi?component=libcap&list_id=1090757