Files
vlibc/src/internal/syscall_ret.c
T

24 lines
488 B
C

#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;
}