feat(syscall): add x86_64 raw syscall layer, errno, internal ABI headers
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include "errno.h"
|
||||
#include "syscall.h"
|
||||
|
||||
/*
|
||||
* Translate a raw syscall result into the C convention: return the value on
|
||||
* success, or store the negated errno and return -1 on error. The -4095
|
||||
* bound is the kernel's MAX_ERRNO: any result at or below -4096 is a
|
||||
* legitimate value, not an error code.
|
||||
*/
|
||||
int
|
||||
syscall_ret(long r)
|
||||
{
|
||||
if (r < 0 && r > -4096)
|
||||
{
|
||||
errno = (int)-r;
|
||||
return -1;
|
||||
}
|
||||
return (int)r;
|
||||
}
|
||||
Reference in New Issue
Block a user