haiku/headers/posix
Jérôme Duval 7065a89fc6 POSIX: ioctl(fd, op, arg) equals ioctl(fd, op, arg, 0)
The ioctl call cannot know the expected number of arguments
because it depends on the specific ioctl being used, and the
same value could be used to do different things by different
devices. Without knowing that, it is not safe to use va_arg
(at best a random value will be read from the stack, at worst,
it will just crash).

This changes the implementation of ioctl in two ways:
- For C++ code: a 4 argument function with default values
  for arguments 3 and 4.
- For C code: wrap arguments 3 and 4 in a struct with the
  help of a macro, providing something that behaves like the
  C++ version.

So, with this new code:
- Calling ioctl with only 3 arguments sets the 4th one to 0
- Calling ioctl with only 2 arguments sets the 3rd and 4th to 0
- Calling with 1 or 5+ arguments is a compile time error

The existing ioctl symbol is preserved for ABI compatibility.

Change-Id: I6d4d1d38fccd8cc9bd94203d3e11aeac6da8efc3
Reviewed-on: https://review.haiku-os.org/c/haiku/+/3360
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
2021-05-04 19:21:48 +00:00
..
arch Debugger: fix build after hrev54931 2021-01-29 21:38:10 +01:00
arpa arpa/nameser.h: Fix build on GCC8. 2020-07-03 15:30:00 -04:00
compat/sys Updated copyright in headers. No functional change. 2012-07-19 18:14:06 +00:00
net posix/if_types.h: Remove IFT_IEEE1394, breaks build 2019-04-22 13:21:50 -05:00
netinet headers: More removal of the BSD Advertising Clause. 2020-07-03 15:00:37 -04:00
netinet6 in6.h: declare in6_addr with a union and extra fields 2020-10-23 08:13:03 +00:00
sys POSIX: make readv() and writev() conform to IEEE Std 1003.1-2001 2021-03-16 12:03:02 +00:00
alloca.h Updated copyright in headers. No functional change. 2012-07-19 18:14:06 +00:00
assert.h assert.h: reintroduce headers guard for function declarations. 2015-08-29 23:14:03 +02:00
bsd_mem.h Updated copyright in headers. No functional change. 2012-07-19 18:14:06 +00:00
complex.h complex.h: add a C++ guard. 2016-10-05 09:18:42 +02:00
ctype.h Updated copyright in headers. No functional change. 2012-07-19 18:14:06 +00:00
dirent.h Updated copyright in headers. No functional change. 2012-07-19 18:14:06 +00:00
div_t.h Updated copyright in headers. No functional change. 2012-07-19 18:14:06 +00:00
dlfcn.h libroot.so: make first parameter of dladdr() const. 2017-09-15 23:09:24 +02:00
endian.h Clarify endianness defines. 2019-08-27 17:44:57 +02:00
errno.h Updated copyright in headers. No functional change. 2012-07-19 18:14:06 +00:00
fcntl.h fcntl.h: define O_DIRECT directly 2020-11-20 18:23:35 +00:00
fenv.h m68k: really add fenv from musl-1.1.24 2020-08-19 15:23:47 +00:00
fnmatch.h fnmatch: Replace BSD implementation with musl one. 2020-07-03 15:09:33 -04:00
fts.h Restore FTS_WHITEOUT, guard it with __HAIKU__. 2013-01-11 00:26:48 +01:00
ftw.h Add Haiku support. 2013-01-11 00:26:48 +01:00
getopt.h Updated copyright in headers. No functional change. 2012-07-19 18:14:06 +00:00
glob.h headers: More removal of the BSD Advertising Clause. 2020-07-03 15:00:37 -04:00
grp.h Updated copyright in headers. No functional change. 2012-07-19 18:14:06 +00:00
inttypes.h Remove __STDC_FORMAT/CONSTANT_MACROS 2017-06-04 17:29:29 +02:00
iovec.h Updated copyright in headers. No functional change. 2012-07-19 18:14:06 +00:00
langinfo.h <langinfo.h>/<select.h>: don't use C++ comments 2013-06-12 14:55:16 +02:00
libgen.h Updated copyright in headers. No functional change. 2012-07-19 18:14:06 +00:00
libio.h posix: protect EOF being parsed as operator and 1 2021-01-25 18:53:43 +00:00
limits.h Fix definition of PAGESIZE and B_PAGE_SIZE 2021-01-08 12:02:16 +00:00
locale.h Updated copyright in headers. No functional change. 2012-07-19 18:14:06 +00:00
malloc_debug.h malloc_debug: Implement allocation dump on exit in guarded heap. 2015-04-10 17:04:28 +02:00
malloc.h malloc: implement malloc_usable_size(). 2015-06-13 14:29:11 +02:00
math.h posix/math: Use the GCC built-ins when possible for isnan(), etc. 2020-01-06 07:44:30 +00:00
memory.h Updated copyright in headers. No functional change. 2012-07-19 18:14:06 +00:00
monetary.h Updated copyright in headers. No functional change. 2012-07-19 18:14:06 +00:00
netdb.h netdb.h: fix prototype of gethostbyaddr() 2020-08-17 00:08:02 +00:00
nl_types.h Updated copyright in headers. No functional change. 2012-07-19 18:14:06 +00:00
null.h Updated copyright in headers. No functional change. 2012-07-19 18:14:06 +00:00
poll.h Updated copyright in headers. No functional change. 2012-07-19 18:14:06 +00:00
pthread.h s/Haiku License/MIT License/g. 2019-08-30 18:16:02 -04:00
pwd.h Updated copyright in headers. No functional change. 2012-07-19 18:14:06 +00:00
regex.h use __haiku_addr_t instead of __haiku_uint32 2010-08-14 11:58:02 +00:00
resolv.h resolv.h & netdb.h: Clean up and simplify. 2020-07-02 19:33:51 -04:00
sched.h Updated copyright in headers. No functional change. 2012-07-19 18:14:06 +00:00
search.h search.h: fix typo. 2014-06-07 10:54:15 +02:00
semaphore.h Reimplement unnamed POSIX semaphores using user_mutex 2015-05-24 14:03:40 +01:00
setjmp.h setjmp.h: add noreturn keyword on longjmp variants. 2018-07-21 12:27:27 +02:00
shadow.h Updated copyright in headers. No functional change. 2012-07-19 18:14:06 +00:00
signal.h Revert "Add sys/ucontext.h" 2014-08-09 20:18:05 +02:00
size_t.h Updated copyright in headers. No functional change. 2012-07-19 18:14:06 +00:00
spawn.h s/Haiku License/MIT License/g. 2019-08-30 18:16:02 -04:00
stdint.h Remove __STDC_FORMAT/CONSTANT_MACROS 2017-06-04 17:29:29 +02:00
stdio_ext.h Updated copyright in headers. No functional change. 2012-07-19 18:14:06 +00:00
stdio_post.h Updated copyright in headers. No functional change. 2012-07-19 18:14:06 +00:00
stdio_pre.h Updated copyright in headers. No functional change. 2012-07-19 18:14:06 +00:00
stdio.h posix: protect EOF being parsed as operator and 1 2021-01-25 18:53:43 +00:00
stdlib.h C11: add aligned_alloc() 2020-11-04 21:01:42 +00:00
string.h string.h: include strings.h for compatibility. 2014-10-30 00:20:13 +01:00
strings.h strings.h: s/inline/__inline__/ 2020-05-24 13:59:57 +00:00
syslog.h syslog.h: add LOG_PRIMASK and LOG_PRI macros 2020-11-22 09:28:57 +00:00
tar.h added tar.h posix header. 2014-04-26 11:09:24 +02:00
termios.h POSIX: add tcsetsid() 2020-11-17 07:53:28 +00:00
time.h Switch to a 64-bit time_t everywhere except 32-bit x86. 2017-06-06 17:38:17 -04:00
uchar.h uchar.h: Remove duplicate definition of mbrtoc32. 2020-05-09 16:15:55 -04:00
unistd.h POSIX: ioctl(fd, op, arg) equals ioctl(fd, op, arg, 0) 2021-05-04 19:21:48 +00:00
utime.h Updated copyright in headers. No functional change. 2012-07-19 18:14:06 +00:00
utmpx.h utmpx.h: add ut_host for compatibility (not posix) 2021-03-16 16:55:44 +00:00
wchar_t.h Updated copyright in headers. No functional change. 2012-07-19 18:14:06 +00:00
wchar.h Fix #7008: Add a64l and l64a from glibc, and add some missing definitions in wchar.h and stdlib.h 2014-12-14 18:06:09 +01:00
wctype.h Updated copyright in headers. No functional change. 2012-07-19 18:14:06 +00:00