From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf1-x444.google.com (mail-pf1-x444.google.com [IPv6:2607:f8b0:4864:20::444]) by sourceware.org (Postfix) with ESMTPS id CA289395B0B7 for ; Wed, 29 Apr 2020 20:52:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org CA289395B0B7 Received: by mail-pf1-x444.google.com with SMTP id p25so1645108pfn.11 for ; Wed, 29 Apr 2020 13:52:22 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=c5miYCWXpNJDGy+mIOOoTEPKajpOqbvdOG4vfk+lnII=; b=SSpqYHzKa9Hs3hksDC+JFQagvXJ8Z2yR2EFJIIevmRzZyK5zPYxK1iEE8ZqV+4+8kE PXLm+mhkxCB1BFPEkhYCNbib23n/mrF8hWtFrN4VqDcckIOLcsq31i6M/aRWxO5mZp2u hrf/8IIE0iqKCNMiH/geFq8LT1gsmmP9GlE1pBEfU5oQUTIUqTWXN7cAVn9NSjHQUANP pasYtPJsaTn9z1EAOdXEe7eDwTM9wdSE6n4eQ/SFb3WxJb2rwfQEvuwYnw8hRX1poWqX AZM46eYdl67uWqncm2gele5PVpH5MG8ZiaWX3/xO4p0AglIDtQQwBMsws0vMSDTBpilD /6UQ== X-Gm-Message-State: AGi0PubHmobzw5Y651x1v/T5YI5/zWNQLXPPiVfrFVuktAQeageua2sw 51XWhUeOtoakOwjtDT6yB3IlxUia X-Google-Smtp-Source: APiQypJCTAobIL5bKBjanHzYyZ0eGz0DY8/XEeXWQuVE2UTh4rlR1DHAJ7vBMMUw5RbeRXzc3Wnjjg== X-Received: by 2002:a63:1160:: with SMTP id 32mr10066pgr.441.1588193541526; Wed, 29 Apr 2020 13:52:21 -0700 (PDT) Received: from gnu-cfl-2.localdomain (c-69-181-90-243.hsd1.ca.comcast.net. [69.181.90.243]) by smtp.gmail.com with ESMTPSA id a21sm1784819pfk.39.2020.04.29.13.52.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Apr 2020 13:52:21 -0700 (PDT) Received: from gnu-cfl-2.localdomain (localhost [IPv6:::1]) by gnu-cfl-2.localdomain (Postfix) with ESMTP id 335CBC013E for ; Wed, 29 Apr 2020 13:52:18 -0700 (PDT) From: "H.J. Lu" To: libc-alpha@sourceware.org Subject: [PATCH] Add a C wrapper for prctl [BZ #25896] Date: Wed, 29 Apr 2020 13:52:17 -0700 Message-Id: <20200429205217.2435607-1-hjl.tools@gmail.com> X-Mailer: git-send-email 2.25.4 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-24.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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-List-Received-Date: Wed, 29 Apr 2020 20:52:24 -0000 Add a C wrapper to pass arguments in /* Control process execution. */ extern int prctl (int __option, ...) __THROW; to prctl syscall: extern int prctl (int, unsigned long int, unsigned long int, unsigned long int, unsigned long int); --- include/sys/prctl.h | 2 ++ sysdeps/unix/sysv/linux/Makefile | 2 +- sysdeps/unix/sysv/linux/prctl.c | 38 +++++++++++++++++++++++++++ sysdeps/unix/sysv/linux/syscalls.list | 1 - 4 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 sysdeps/unix/sysv/linux/prctl.c diff --git a/include/sys/prctl.h b/include/sys/prctl.h index 0920ed642b..1a74d83879 100644 --- a/include/sys/prctl.h +++ b/include/sys/prctl.h @@ -4,6 +4,8 @@ # ifndef _ISOMAC extern int __prctl (int __option, ...); +libc_hidden_proto (__prctl) +libc_hidden_proto (prctl) # endif /* !_ISOMAC */ #endif diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile index db78eeadd1..0326f92c40 100644 --- a/sysdeps/unix/sysv/linux/Makefile +++ b/sysdeps/unix/sysv/linux/Makefile @@ -59,7 +59,7 @@ sysdep_routines += adjtimex clone umount umount2 readahead sysctl \ eventfd eventfd_read eventfd_write prlimit \ personality epoll_wait tee vmsplice splice \ open_by_handle_at mlock2 pkey_mprotect pkey_set pkey_get \ - timerfd_gettime timerfd_settime \ + timerfd_gettime timerfd_settime prctl \ process_vm_readv process_vm_writev CFLAGS-gethostid.c = -fexceptions diff --git a/sysdeps/unix/sysv/linux/prctl.c b/sysdeps/unix/sysv/linux/prctl.c new file mode 100644 index 0000000000..b3fc12ccf5 --- /dev/null +++ b/sysdeps/unix/sysv/linux/prctl.c @@ -0,0 +1,38 @@ +/* prctl - Linux specific syscall. + Copyright (C) 2020 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include +#include + +int +__prctl (int option, ...) +{ + va_list arg; + va_start (arg, option); + unsigned long int arg2 = va_arg (arg, unsigned long int); + unsigned long int arg3 = va_arg (arg, unsigned long int); + 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); +} + +libc_hidden_def (__prctl) +weak_alias (__prctl, prctl) +hidden_weak (prctl) diff --git a/sysdeps/unix/sysv/linux/syscalls.list b/sysdeps/unix/sysv/linux/syscalls.list index ced77d49fa..1d8893d1b8 100644 --- a/sysdeps/unix/sysv/linux/syscalls.list +++ b/sysdeps/unix/sysv/linux/syscalls.list @@ -43,7 +43,6 @@ nfsservctl EXTRA nfsservctl i:ipp __compat_nfsservctl nfsservctl@GLIBC_2.0:GLIBC pipe - pipe i:f __pipe pipe pipe2 - pipe2 i:fi __pipe2 pipe2 pivot_root EXTRA pivot_root i:ss pivot_root -prctl EXTRA prctl i:iiiii __prctl prctl query_module EXTRA query_module i:sipip __compat_query_module query_module@GLIBC_2.0:GLIBC_2.23 quotactl EXTRA quotactl i:isip quotactl remap_file_pages - remap_file_pages i:pUiUi __remap_file_pages remap_file_pages -- 2.25.4