headers/bsd: Add sys/queue.h.
[haiku.git] / src / system / libroot / posix / unistd / ioctl.c
bloba831a2964fc355850fbedd20771848de974471ef
1 /*
2 * Copyright 2002-2007, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
3 * Distributed under the terms of the MIT License.
4 */
7 #include <unistd.h>
8 #include <syscalls.h>
9 #include <stdarg.h>
10 #include <errno.h>
12 #include <errno_private.h>
15 #define RETURN_AND_SET_ERRNO(err) \
16 if (err < 0) { \
17 __set_errno(err); \
18 return -1; \
19 } \
20 return err;
23 int
24 ioctl(int fd, ulong cmd, ...)
26 va_list args;
27 void* argument;
28 size_t size;
29 int status;
31 va_start(args, cmd);
32 argument = va_arg(args, void*);
33 size = va_arg(args, size_t);
34 va_end(args);
36 status = _kern_ioctl(fd, cmd, argument, size);
38 RETURN_AND_SET_ERRNO(status)