1
0
Fork 0
mirror of https://gitlab.com/sortix/sortix.git synced 2023-02-13 20:55:38 -05:00

Refactor fcntl(2) ABI.

This is an incompatible ABI change.
This commit is contained in:
Jonas 'Sortie' Termansen 2013-09-24 12:39:48 +02:00
parent 4e520c8c36
commit 8c0e0235d6
3 changed files with 68 additions and 30 deletions

View file

@ -24,16 +24,26 @@
#include <sys/syscall.h>
#include <errno.h>
#include <fcntl.h>
#include <stdarg.h>
#include <stdint.h>
DEFN_SYSCALL3(int, sys_fcntl, SYSCALL_FCNTL, int, int, unsigned long);
DEFN_SYSCALL3(int, sys_fcntl, SYSCALL_FCNTL, int, int, uintptr_t);
extern "C" int fcntl(int fd, int cmd, ...)
{
uintptr_t arg;
va_list ap;
va_start(ap, cmd);
unsigned long arg = va_arg(ap, unsigned long);
switch ( F_DECODE_CMD_TYPE(cmd) )
{
case F_TYPE_VOID: arg = 0; break;
case F_TYPE_INT: arg = (uintptr_t) va_arg(ap, int); break;
case F_TYPE_LONG: arg = (uintptr_t) va_arg(ap, long); break;
case F_TYPE_PTR: arg = (uintptr_t) va_arg(ap, void*); break;
default: return errno = EINVAL, -1;
}
va_end(ap);
return sys_fcntl(fd, cmd, arg);
}