From patchwork Sat Mar 25 14:08:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xi Ruoyao X-Patchwork-Id: 66890 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id AA3D83850401 for ; Sat, 25 Mar 2023 14:09:13 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AA3D83850401 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1679753353; bh=3cJBMqFBhp25RcPIdBZpdZeRGi6lJF/fxHBrICaDMMo=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=o1ecVpSY/inPDiW719csKIfW21SrjHfMYg2ASmNYcNhjGUp/tCZM7qs/EFDgozCy5 S9rnFOjDNqZOGcgPl8Y39J2OZJQcDOHwdmURznJzfxkQWVnoAlZHiinGmNQHWzlK7e FaHgfEWZNo5PhV8t3iSyt7jEnSbSYFssBuwtCM/w= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from xry111.site (xry111.site [89.208.246.23]) by sourceware.org (Postfix) with ESMTPS id CE2D3385840C for ; Sat, 25 Mar 2023 14:08:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org CE2D3385840C Received: from stargazer.. (unknown [IPv6:240e:358:1172:ca00:dc73:854d:832e:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (Client did not present a certificate) (Authenticated sender: xry111@xry111.site) by xry111.site (Postfix) with ESMTPSA id 0A11D66479; Sat, 25 Mar 2023 10:08:40 -0400 (EDT) To: libc-alpha@sourceware.org Cc: caiyinyu , Wang Xuerui , Adhemerval Zanella Netto , Andreas Schwab , Florian Weimer , Xi Ruoyao Subject: [PATCH v2 2/5] linux: [__ASSUME_SYSCALL_NAMED_WORKS] Avoid using va_list for various syscall wrappers Date: Sat, 25 Mar 2023 22:08:12 +0800 Message-Id: <20230325140815.4170296-3-xry111@xry111.site> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230325140815.4170296-1-xry111@xry111.site> References: <20230325140815.4170296-1-xry111@xry111.site> MIME-Version: 1.0 X-Spam-Status: No, score=-8.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, LIKELY_SPAM_FROM, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Xi Ruoyao via Libc-alpha From: Xi Ruoyao Reply-To: Xi Ruoyao Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" This patch changes fcntl64, fcntl_nocancel, ioctl, mremap, open64, open64_nocancel, openat64, openat64_nocancel, prctl, and ptrace not to use va_list if the named arguments is passed in the same way as variable arguments in the calling convention. This removes the stack store operation emitted by the compiler for va_start macro. --- include/fcntl.h | 32 ++++++++++----- sysdeps/unix/sysv/linux/fcntl64.c | 40 ++++++++++++++---- sysdeps/unix/sysv/linux/fcntl_nocancel.c | 30 +++++++++++--- sysdeps/unix/sysv/linux/ioctl.c | 38 +++++++++++++---- sysdeps/unix/sysv/linux/mremap.c | 36 +++++++++++++++-- sysdeps/unix/sysv/linux/not-cancel.h | 8 ++-- sysdeps/unix/sysv/linux/open64.c | 35 +++++++++++++--- sysdeps/unix/sysv/linux/open64_nocancel.c | 29 +++++++++++-- sysdeps/unix/sysv/linux/openat64.c | 30 ++++++++++++-- sysdeps/unix/sysv/linux/openat64_nocancel.c | 29 +++++++++++-- sysdeps/unix/sysv/linux/prctl.c | 23 ++++++++++- sysdeps/unix/sysv/linux/ptrace.c | 45 +++++++++++++++------ 12 files changed, 308 insertions(+), 67 deletions(-) diff --git a/include/fcntl.h b/include/fcntl.h index be435047bc..9fa0475138 100644 --- a/include/fcntl.h +++ b/include/fcntl.h @@ -2,31 +2,43 @@ #include #ifndef _ISOMAC + +#ifdef FCNTL_INTERNAL_NAMED_ARGS +#define MODE mode_t mode +#define FCNTL_ARG void *arg +#else +#define MODE ... +#define FCNTL_ARG ... +#endif + /* Now define the internal interfaces. */ -extern int __open64 (const char *__file, int __oflag, ...); +extern int __open64 (const char *__file, int __oflag, MODE); libc_hidden_proto (__open64) -extern int __libc_open64 (const char *file, int oflag, ...); -extern int __libc_open (const char *file, int oflag, ...); +extern int __libc_open64 (const char *file, int oflag, MODE); +extern int __libc_open (const char *file, int oflag, MODE); libc_hidden_proto (__libc_open) -extern int __libc_fcntl (int fd, int cmd, ...); +extern int __libc_fcntl (int fd, int cmd, FCNTL_ARG); libc_hidden_proto (__libc_fcntl) extern int __fcntl64_nocancel_adjusted (int fd, int cmd, void *arg) attribute_hidden; -extern int __libc_fcntl64 (int fd, int cmd, ...); +extern int __libc_fcntl64 (int fd, int cmd, FCNTL_ARG); libc_hidden_proto (__libc_fcntl64) -extern int __open (const char *__file, int __oflag, ...); +extern int __open (const char *__file, int __oflag, MODE); libc_hidden_proto (__open) -extern int __fcntl (int __fd, int __cmd, ...); +extern int __fcntl (int __fd, int __cmd, FCNTL_ARG); libc_hidden_proto (__fcntl) -extern int __fcntl64 (int __fd, int __cmd, ...) attribute_hidden; +extern int __fcntl64 (int __fd, int __cmd, FCNTL_ARG) attribute_hidden; libc_hidden_proto (__fcntl64) -extern int __openat (int __fd, const char *__file, int __oflag, ...) +extern int __openat (int __fd, const char *__file, int __oflag, MODE) __nonnull ((2)); libc_hidden_proto (__openat) -extern int __openat64 (int __fd, const char *__file, int __oflag, ...) +extern int __openat64 (int __fd, const char *__file, int __oflag, MODE) __nonnull ((2)); libc_hidden_proto (__openat64) +#undef MODE +#undef FCNTL_ARG + extern int __open_2 (const char *__path, int __oflag); extern int __open64_2 (const char *__path, int __oflag); extern int __openat_2 (int __fd, const char *__path, int __oflag); diff --git a/sysdeps/unix/sysv/linux/fcntl64.c b/sysdeps/unix/sysv/linux/fcntl64.c index 509cf0a6e2..d896d47ffb 100644 --- a/sysdeps/unix/sysv/linux/fcntl64.c +++ b/sysdeps/unix/sysv/linux/fcntl64.c @@ -16,14 +16,23 @@ License along with the GNU C Library; if not, see . */ +#include + +#ifdef __ASSUME_SYSCALL_NAMED_WORKS +#define FCNTL_INTERNAL_NAMED_ARGS 1 +#define fcntl64 __no_decl_fcntl64 +#else +#include +#endif + #define fcntl __no_decl_fcntl #define __fcntl __no_decl___fcntl #include #undef fcntl #undef __fcntl -#include +#undef fcntl64 + #include -#include #ifndef __NR_fcntl64 # define __NR_fcntl64 __NR_fcntl @@ -33,6 +42,24 @@ # define FCNTL_ADJUST_CMD(__cmd) __cmd #endif +static inline int +do_fcntl64 (int fd, int cmd, void *arg) +{ + cmd = FCNTL_ADJUST_CMD (cmd); + + if (cmd == F_SETLKW || cmd == F_SETLKW64 || cmd == F_OFD_SETLKW) + return SYSCALL_CANCEL (fcntl64, fd, cmd, arg); + + return __fcntl64_nocancel_adjusted (fd, cmd, arg); +} + +#if __ASSUME_SYSCALL_NAMED_WORKS +int +__libc_fcntl64 (int fd, int cmd, void *arg) +{ + return do_fcntl64 (fd, cmd, arg); +} +#else int __libc_fcntl64 (int fd, int cmd, ...) { @@ -43,13 +70,10 @@ __libc_fcntl64 (int fd, int cmd, ...) arg = va_arg (ap, void *); va_end (ap); - cmd = FCNTL_ADJUST_CMD (cmd); - - if (cmd == F_SETLKW || cmd == F_SETLKW64 || cmd == F_OFD_SETLKW) - return SYSCALL_CANCEL (fcntl64, fd, cmd, arg); - - return __fcntl64_nocancel_adjusted (fd, cmd, arg); + return do_fcntl64 (fd, cmd, arg); } +#endif + libc_hidden_def (__libc_fcntl64) weak_alias (__libc_fcntl64, __fcntl64) libc_hidden_weak (__fcntl64) diff --git a/sysdeps/unix/sysv/linux/fcntl_nocancel.c b/sysdeps/unix/sysv/linux/fcntl_nocancel.c index 005d324fda..b755973ce2 100644 --- a/sysdeps/unix/sysv/linux/fcntl_nocancel.c +++ b/sysdeps/unix/sysv/linux/fcntl_nocancel.c @@ -16,10 +16,17 @@ License along with the GNU C Library; if not, see . */ -#include +#include + +#ifdef __ASSUME_SYSCALL_NAMED_WORKS +#define FCNTL_INTERNAL_NAMED_ARGS 1 +#else #include +#endif + #include -#include + +#include #include #ifndef __NR_fcntl64 @@ -30,6 +37,19 @@ # define FCNTL_ADJUST_CMD(__cmd) __cmd #endif +static inline int +do_fcntl64_nocancel (int fd, int cmd, void *arg) +{ + return __fcntl64_nocancel_adjusted (fd, FCNTL_ADJUST_CMD (cmd), arg); +} + +#ifdef __ASSUME_SYSCALL_NAMED_WORKS +int +__fcntl64_nocancel (int fd, int cmd, void *arg) +{ + return do_fcntl64_nocancel (fd, cmd, arg); +} +#else int __fcntl64_nocancel (int fd, int cmd, ...) { @@ -40,10 +60,10 @@ __fcntl64_nocancel (int fd, int cmd, ...) arg = va_arg (ap, void *); va_end (ap); - cmd = FCNTL_ADJUST_CMD (cmd); - - return __fcntl64_nocancel_adjusted (fd, cmd, arg); + return do_fcntl64_nocancel (fd, cmd, arg); } +#endif + hidden_def (__fcntl64_nocancel) int diff --git a/sysdeps/unix/sysv/linux/ioctl.c b/sysdeps/unix/sysv/linux/ioctl.c index e059942801..aca5ad5daa 100644 --- a/sysdeps/unix/sysv/linux/ioctl.c +++ b/sysdeps/unix/sysv/linux/ioctl.c @@ -16,19 +16,18 @@ License along with the GNU C Library. If not, see . */ +#include + +#ifndef __ASSUME_SYSCALL_NAMED_WORKS #include #include -#include +#endif + #include -int -__ioctl (int fd, unsigned long int request, ...) +static inline int +do_ioctl (int fd, unsigned long int request, void *arg) { - va_list args; - va_start (args, request); - void *arg = va_arg (args, void *); - va_end (args); - int r; if (!__ioctl_arch (&r, fd, request, arg)) { @@ -41,6 +40,29 @@ __ioctl (int fd, unsigned long int request, ...) } return r; } + +#ifdef __ASSUME_SYSCALL_NAMED_WORKS +__typeof (do_ioctl) __ioctl; +libc_hidden_proto(__ioctl) + +int +__ioctl (int fd, unsigned long int request, void *arg) +{ + return do_ioctl (fd, request, arg); +} +#else +int +__ioctl (int fd, unsigned long int request, ...) +{ + va_list args; + va_start (args, request); + void *arg = va_arg (args, void *); + va_end (args); + + return do_ioctl (fd, request, arg); +} +#endif + libc_hidden_def (__ioctl) weak_alias (__ioctl, ioctl) diff --git a/sysdeps/unix/sysv/linux/mremap.c b/sysdeps/unix/sysv/linux/mremap.c index 0ad5da86a2..26db22ffa5 100644 --- a/sysdeps/unix/sysv/linux/mremap.c +++ b/sysdeps/unix/sysv/linux/mremap.c @@ -16,11 +16,40 @@ License along with the GNU C Library; if not, see . */ -#include #include + +#ifdef __ASSUME_SYSCALL_NAMED_WORKS +#define mremap __no_decl_mremap +#define __mremap __no_decl___mremap +#else #include +#endif + +#include + +#undef mremap +#undef __mremap + #include +static inline void * +do_mremap (void *addr, size_t old_len, size_t new_len, int flags, + void *new_addr) +{ + return (void *) INLINE_SYSCALL_CALL (mremap, addr, old_len, new_len, flags, + new_addr); +} + +#ifdef __ASSUME_SYSCALL_NAMED_WORKS +__typeof (do_mremap) __mremap; +libc_hidden_proto (__mremap) + +void * +__mremap (void *addr, size_t old_len, size_t new_len, int flags, void *new_addr) +{ + return do_mremap (addr, old_len, new_len, flags, new_addr); +} +#else void * __mremap (void *addr, size_t old_len, size_t new_len, int flags, ...) { @@ -34,8 +63,9 @@ __mremap (void *addr, size_t old_len, size_t new_len, int flags, ...) va_end (va); } - return (void *) INLINE_SYSCALL_CALL (mremap, addr, old_len, new_len, flags, - new_addr); + return do_mremap (addr, old_len, new_len, flags, new_addr); } +#endif + libc_hidden_def (__mremap) weak_alias (__mremap, mremap) diff --git a/sysdeps/unix/sysv/linux/not-cancel.h b/sysdeps/unix/sysv/linux/not-cancel.h index ea2615b38a..1a95e1b008 100644 --- a/sysdeps/unix/sysv/linux/not-cancel.h +++ b/sysdeps/unix/sysv/linux/not-cancel.h @@ -29,16 +29,16 @@ #include /* Non cancellable open syscall. */ -__typeof (open) __open_nocancel; +__typeof (__open) __open_nocancel; /* Non cancellable open syscall (LFS version). */ -__typeof (open64) __open64_nocancel; +__typeof (__open64) __open64_nocancel; /* Non cancellable openat syscall. */ -__typeof (openat) __openat_nocancel; +__typeof (__openat) __openat_nocancel; /* Non cacellable openat syscall (LFS version). */ -__typeof (openat64) __openat64_nocancel; +__typeof (__openat64) __openat64_nocancel; /* Non cancellable read syscall. */ __typeof (__read) __read_nocancel; diff --git a/sysdeps/unix/sysv/linux/open64.c b/sysdeps/unix/sysv/linux/open64.c index 9f33733ebc..af3fdb09cd 100644 --- a/sysdeps/unix/sysv/linux/open64.c +++ b/sysdeps/unix/sysv/linux/open64.c @@ -18,17 +18,42 @@ #include #include -#include -#include #include #include +#ifdef __ASSUME_SYSCALL_NAMED_WORKS +#define FCNTL_INTERNAL_NAMED_ARGS 1 +#define open64 __no_decl_open64 +#define open __no_decl_open +#else +#include +#endif + +#include + +#undef open64 +#undef open + +static inline int +do_open64 (const char *file, int oflag, mode_t mode) +{ + return SYSCALL_CANCEL (openat, AT_FDCWD, file, oflag | O_LARGEFILE, + mode); +} + /* Open FILE with access OFLAG. If O_CREAT or O_TMPFILE is in OFLAG, a third argument is the file protection. */ +#ifdef __ASSUME_SYSCALL_NAMED_WORKS +int +__libc_open64 (const char *file, int oflag, mode_t mode) +{ + return do_open64 (file, oflag, mode); +} +#else int __libc_open64 (const char *file, int oflag, ...) { - int mode = 0; + mode_t mode = 0; if (__OPEN_NEEDS_MODE (oflag)) { @@ -38,9 +63,9 @@ __libc_open64 (const char *file, int oflag, ...) va_end (arg); } - return SYSCALL_CANCEL (openat, AT_FDCWD, file, oflag | O_LARGEFILE, - mode); + return do_open64 (file, oflag, mode); } +#endif strong_alias (__libc_open64, __open64) libc_hidden_weak (__open64) diff --git a/sysdeps/unix/sysv/linux/open64_nocancel.c b/sysdeps/unix/sysv/linux/open64_nocancel.c index 5035521386..f64c308d40 100644 --- a/sysdeps/unix/sysv/linux/open64_nocancel.c +++ b/sysdeps/unix/sysv/linux/open64_nocancel.c @@ -16,17 +16,38 @@ License along with the GNU C Library; if not, see . */ +#include + +#ifdef __ASSUME_SYSCALL_NAMED_WORKS +#define FCNTL_INTERNAL_NAMED_ARGS 1 +#else +#include +#endif + #include #include #include -#include #include +static inline int +do_open64_nocancel (const char *file, int oflag, mode_t mode) +{ + return INLINE_SYSCALL_CALL (openat, AT_FDCWD, file, oflag | O_LARGEFILE, + mode); +} + +#ifdef __ASSUME_SYSCALL_NAMED_WORKS +int +__open64_nocancel (const char *file, int oflag, mode_t mode) +{ + return do_open64_nocancel (file, oflag, mode); +} +#else int __open64_nocancel (const char *file, int oflag, ...) { - int mode = 0; + mode_t mode = 0; if (__OPEN_NEEDS_MODE (oflag)) { @@ -36,9 +57,9 @@ __open64_nocancel (const char *file, int oflag, ...) va_end (arg); } - return INLINE_SYSCALL_CALL (openat, AT_FDCWD, file, oflag | O_LARGEFILE, - mode); + return do_open64_nocancel (file, oflag, mode); } +#endif hidden_def (__open64_nocancel) diff --git a/sysdeps/unix/sysv/linux/openat64.c b/sysdeps/unix/sysv/linux/openat64.c index 105eb8ab08..d5718eb261 100644 --- a/sysdeps/unix/sysv/linux/openat64.c +++ b/sysdeps/unix/sysv/linux/openat64.c @@ -16,14 +16,37 @@ License along with the GNU C Library; if not, see . */ -#include +#include + +#ifdef __ASSUME_SYSCALL_NAMED_WORKS +#define FCNTL_INTERNAL_NAMED_ARGS 1 +#define openat64 __no_decl_openat64 +#define openat __no_decl_openat +#else #include +#endif -#include +#include + +#undef openat64 +#undef openat + +static inline int +do_openat64 (int fd, const char *file, int oflag, mode_t mode) +{ + return SYSCALL_CANCEL (openat, fd, file, oflag | O_LARGEFILE, mode); +} /* Open FILE with access OFLAG. Interpret relative paths relative to the directory associated with FD. If OFLAG includes O_CREAT or O_TMPFILE, a fourth argument is the file protection. */ +#ifdef __ASSUME_SYSCALL_NAMED_WORKS +int +__libc_openat64 (int fd, const char *file, int oflag, mode_t mode) +{ + return do_openat64 (fd, file, oflag, mode); +} +#else int __libc_openat64 (int fd, const char *file, int oflag, ...) { @@ -36,8 +59,9 @@ __libc_openat64 (int fd, const char *file, int oflag, ...) va_end (arg); } - return SYSCALL_CANCEL (openat, fd, file, oflag | O_LARGEFILE, mode); + return do_openat64 (fd, file, oflag, mode); } +#endif strong_alias (__libc_openat64, __openat64) libc_hidden_weak (__openat64) diff --git a/sysdeps/unix/sysv/linux/openat64_nocancel.c b/sysdeps/unix/sysv/linux/openat64_nocancel.c index b9105805d2..55ef645179 100644 --- a/sysdeps/unix/sysv/linux/openat64_nocancel.c +++ b/sysdeps/unix/sysv/linux/openat64_nocancel.c @@ -16,12 +16,32 @@ License along with the GNU C Library; if not, see . */ -#include +#include + +#ifdef __ASSUME_SYSCALL_NAMED_WORKS +#define FCNTL_INTERNAL_NAMED_ARGS 1 +#else #include +#endif + +#include -#include #include +static inline int +do_openat64_nocancel (int fd, const char *file, int oflag, mode_t mode) +{ + return INLINE_SYSCALL_CALL (openat, fd, file, oflag | O_LARGEFILE, + mode); +} + +#ifdef __ASSUME_SYSCALL_NAMED_WORKS +int +__openat64_nocancel (int fd, const char *file, int oflag, mode_t mode) +{ + return do_openat64_nocancel (fd, file, oflag, mode); +} +#else int __openat64_nocancel (int fd, const char *file, int oflag, ...) { @@ -34,9 +54,10 @@ __openat64_nocancel (int fd, const char *file, int oflag, ...) va_end (arg); } - return INLINE_SYSCALL_CALL (openat, fd, file, oflag | O_LARGEFILE, - mode); + return do_openat64_nocancel (fd, file, oflag, mode); } +#endif + hidden_def (__openat64_nocancel) #ifdef __OFF_T_MATCHES_OFF64_T diff --git a/sysdeps/unix/sysv/linux/prctl.c b/sysdeps/unix/sysv/linux/prctl.c index 68b97a4388..2c6e889f18 100644 --- a/sysdeps/unix/sysv/linux/prctl.c +++ b/sysdeps/unix/sysv/linux/prctl.c @@ -17,14 +17,34 @@ . */ #include + +#ifndef __ASSUME_SYSCALL_NAMED_WORKS #include #include +#endif + +static inline int +do_prctl (int option, unsigned long int arg2, unsigned long int arg3, + unsigned long int arg4, unsigned long int arg5) +{ + return INLINE_SYSCALL_CALL (prctl, option, arg2, arg3, arg4, arg5); +} /* Unconditionally read all potential arguments. This may pass garbage values to the kernel, but avoids the need for teaching glibc the argument counts of individual options (including ones that are added to the kernel in the future). */ +#ifdef __ASSUME_SYSCALL_NAMED_WORKS +__typeof (do_prctl) __prctl; +libc_hidden_proto (__prctl) +int +__prctl (int option, unsigned long int arg2, unsigned long int arg3, + unsigned long int arg4, unsigned long int arg5) +{ + return do_prctl (option, arg2, arg3, arg4, arg5); +} +#else int __prctl (int option, ...) { @@ -35,8 +55,9 @@ __prctl (int option, ...) unsigned long int arg4 = va_arg (arg, unsigned long int); unsigned long int arg5 = va_arg (arg, unsigned long int); va_end (arg); - return INLINE_SYSCALL_CALL (prctl, option, arg2, arg3, arg4, arg5); + return do_prctl (option, arg2, arg3, arg4, arg5); } +#endif libc_hidden_def (__prctl) weak_alias (__prctl, prctl) diff --git a/sysdeps/unix/sysv/linux/ptrace.c b/sysdeps/unix/sysv/linux/ptrace.c index 239344fe7a..e1a1282505 100644 --- a/sysdeps/unix/sysv/linux/ptrace.c +++ b/sysdeps/unix/sysv/linux/ptrace.c @@ -17,7 +17,6 @@ #include #include -#include #include #include #include @@ -25,19 +24,17 @@ #include #include -long int -ptrace (enum __ptrace_request request, ...) +#ifdef __ASSUME_SYSCALL_NAMED_WORKS +#define ptrace __no_decl_ptrace +#endif + +#include +#undef ptrace + +static inline long int +do_ptrace (enum __ptrace_request request, pid_t pid, void *addr, void *data) { long int res, ret; - va_list ap; - pid_t pid; - void *addr, *data; - - va_start (ap, request); - pid = va_arg (ap, pid_t); - addr = va_arg (ap, void *); - data = va_arg (ap, void *); - va_end (ap); if (request > 0 && request < 4) data = &ret; @@ -51,3 +48,27 @@ ptrace (enum __ptrace_request request, ...) return res; } + +#ifdef __ASSUME_SYSCALL_NAMED_WORKS +long int +ptrace (enum __ptrace_request request, pid_t pid, void *addr, void *data) +{ + return do_ptrace (request, pid, addr, data); +} +#else +long int +ptrace (enum __ptrace_request request, ...) +{ + va_list ap; + pid_t pid; + void *addr, *data; + + va_start (ap, request); + pid = va_arg (ap, pid_t); + addr = va_arg (ap, void *); + data = va_arg (ap, void *); + va_end (ap); + + return do_ptrace (request, pid, addr, data); +} +#endif