libroot: Use use variable argument count macro for ioctl.
Based on X512's original change, but with more modifications: * Don't use _ in macro parameter names to appease GCC 2. * Get rid of ioctl_args struct. We don't need it anymore, and just adding parameters of the same types has the exact same ABI on x86 and x86_64, so this doesn't break any existing compiled code. * Add (void*) cast to third parameter. * Enable for _KERNEL_MODE also. Change-Id: Id4ad8b85f54836fd26dc6278226954d0a081d5f0 Reviewed-on: https://review.haiku-os.org/c/haiku/+/8533 Reviewed-by: waddlesplash <[email protected]>
This commit is contained in:
committed by
waddlesplash
parent
b802b65b09
commit
bbb069a1a7
+9
-10
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2004-2015 Haiku, Inc. All Rights Reserved.
|
* Copyright 2004-2024, Haiku, Inc. All rights reserved.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
#ifndef _UNISTD_H_
|
#ifndef _UNISTD_H_
|
||||||
@@ -361,21 +361,20 @@ extern int symlinkat(const char *toPath, int fd, const char *symlinkPath);
|
|||||||
|
|
||||||
extern int ftruncate(int fd, off_t newSize);
|
extern int ftruncate(int fd, off_t newSize);
|
||||||
extern int truncate(const char *path, off_t newSize);
|
extern int truncate(const char *path, off_t newSize);
|
||||||
struct ioctl_args {
|
|
||||||
void* argument;
|
extern int __ioctl(int fd, ulong cmd, void* argument, size_t size);
|
||||||
size_t size;
|
|
||||||
};
|
|
||||||
int __ioctl(int fd, ulong cmd, struct ioctl_args args);
|
|
||||||
#ifndef __cplusplus
|
#ifndef __cplusplus
|
||||||
extern int ioctl(int fd, unsigned long op, ...);
|
extern int ioctl(int fd, unsigned long op, ...);
|
||||||
#ifndef _KERNEL_MODE
|
#define _IOCTL2(a, b) __ioctl(a, b, NULL, 0)
|
||||||
#define ioctl(a, b, c...) __ioctl(a, b, (struct ioctl_args){ c })
|
#define _IOCTL3(a, b, c) __ioctl(a, b, (void*)c, 0)
|
||||||
#endif
|
#define _IOCTL4(a, b, c, d) __ioctl(a, b, (void*)c, d)
|
||||||
|
#define _IOCTL(ARG1, ARG2, ARG3, ARG4, NAME, ...) NAME
|
||||||
|
#define ioctl(...) _IOCTL(__VA_ARGS__, _IOCTL4, _IOCTL3, _IOCTL2)(__VA_ARGS__)
|
||||||
#else
|
#else
|
||||||
inline int
|
inline int
|
||||||
ioctl(int fd, unsigned long op, void* argument = NULL, size_t size = 0)
|
ioctl(int fd, unsigned long op, void* argument = NULL, size_t size = 0)
|
||||||
{
|
{
|
||||||
return __ioctl(fd, op, (struct ioctl_args){ argument, size });
|
return __ioctl(fd, op, argument, size);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -14,9 +14,9 @@
|
|||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
__ioctl(int fd, ulong cmd, struct ioctl_args args)
|
__ioctl(int fd, ulong cmd, void* argument, size_t size)
|
||||||
{
|
{
|
||||||
RETURN_AND_SET_ERRNO(_kern_ioctl(fd, cmd, args.argument, args.size));
|
RETURN_AND_SET_ERRNO(_kern_ioctl(fd, cmd, argument, size));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user