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:
parent
4e520c8c36
commit
8c0e0235d6
3 changed files with 68 additions and 30 deletions
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue