#ifdef HAVE_CONFIG_H #include #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; }