From patchwork Tue Jul 4 19:53:41 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 107014 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp1361287qge; Tue, 4 Jul 2017 12:54:55 -0700 (PDT) X-Received: by 10.84.232.205 with SMTP id x13mr18408980plm.245.1499198095662; Tue, 04 Jul 2017 12:54:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499198095; cv=none; d=google.com; s=arc-20160816; b=bEF23OlV6pXQt9HkHvgZkCoiPUXnN15w+B6KT/4LSERMFjHW40YInnXllr3KxIFJ7Q 4A+BRqgHn1S6ZjLG5StcQ9SVvWIFgFDpcEBtEz15Z3X0q1rLP6IgzpeUOsJySjyGhg+a 96WNDqQmEmXxfcchVn/b4S36hUb4741/R0mokkPhE6Jx/8LjRaCECyCb+AE7bKtj+CXE wc1DiVwio2qlXJOHxn3dyRugrXeE1VjNxXIObbNZW30h6StW7kmNhDouhKBPvsWZkkuF VjTryLbF+n6Yy1Wl0eraBZihJTdRKT5yNF3jYQ7tqfbb+fbDVSv2LqmPDJ+9MvuiVfiI YlPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:to:from:delivered-to :sender:list-help:list-post:list-archive:list-subscribe :list-unsubscribe:list-id:precedence:mailing-list:dkim-signature :domainkey-signature:arc-authentication-results; bh=lHUWfAfMmq2a0vVk0LdjMgD9flrrI7JAg2iLEeciFig=; b=JpYSs0oMyUPS+EMj/mDFE68tXFzh8UL0ULghNzbE4qoF4CtdZuww3kaDMBL5MMUmzF JH11Vib+54rKD8g3Rv7DNt7Vlv4MNDpqTVRuUzZU2u+fVEjI4ANCK6pr5laygBPkpCYn BbY7rAgu4rt43tG/uoDh58TUliMSGwK6LOOvTKrh6JfCraxSuZX7ZZ0XxopWPfXSp2RG SfCMj5/YxV2Xys5NdHs3z/KrDsabKBbgH76WaKmCscs8EVqQzV9ST1Mr54/TxbKEewu+ HZjDOlbEIJYCBI+UJPGjesARzzmO0TpYPvaOwL5a4aMHWJXKw0arlZWh2SDvZJoUKIb9 HpMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.b=sVRpFmMr; spf=pass (google.com: domain of libc-alpha-return-81665-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-81665-patch=linaro.org@sourceware.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id r9si15529761pgu.401.2017.07.04.12.54.55 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 04 Jul 2017 12:54:55 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-return-81665-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.b=sVRpFmMr; spf=pass (google.com: domain of libc-alpha-return-81665-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-81665-patch=linaro.org@sourceware.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=dbG2+LW12wrwafvJE683kU7EWirs2En haSIaLgGonrE+MnWw3tlqsnHpe+I2dW+nIHYAM2iHE1+XGH1jQT4rrkHwbyAmAa1 IM9qqiAGUdtTBFNsdWEdvbBEDiQ0ul6Yek0GlsN3fAs6+2LI6Z9NXUZv3MIgmEB3 WOvF1j1td7Gs= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; s=default; bh=qiOI135cUFJGyrQzx0NUekN7RNQ=; b=sVRpF mMr9Bz3l+pcJnIdTPq1RKPi7YSRGjMej+mHR3x82CyNNtMo25YvLdcDELrvVU0Mk 0r4b2FyHyh09eqHmUhMyY/lm2u3fgDWDLxqfsklJXkaWs3QHEPIMW6Eqf2nPPVDJ M7+qD3V+2bJWlNnRZvVfw+xaRPf0t4dK7oXd9k= Received: (qmail 74396 invoked by alias); 4 Jul 2017 19:54:22 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 73563 invoked by uid 89); 4 Jul 2017 19:54:14 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.4 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy=Non X-HELO: mail-qk0-f169.google.com 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:in-reply-to :references; bh=lHUWfAfMmq2a0vVk0LdjMgD9flrrI7JAg2iLEeciFig=; b=fjOqnzCyUF+C2BLXdAVGt2Ssv+/s3NLfsrQXjPWmVx6wvZjO+CH8ex60eCd+XpuPZW 8nFlIhOtD14Af1QIxjEvjJgJuysJWakLJkJVKykNbAyPtjcIgsUo0mqPTPwG3QDgSFmG /eaX3FLsoihBS8Tkvi0QMXj4U20PVhsVfRGf2GUb2NJtF2FkGUNaRwpd61VK+uWiAyAC o6SOVoQ4D3EI46dtOGyKFgSkLh1VqVXL8GRZLvFPTqjvXjiK21QzvCwz/qPDc9tGkB4z mkm03yB/XZgXJGcP+zEHqcUfJaJz0ZoPuIuyi/QJSSMqRcWl1A2Yvml63oiaT7twsshw YL1w== X-Gm-Message-State: AKS2vOyWxpCgRO8TxyKOjZx/raTYPrxSjwfIO3hBI/LUv8omjLtNDRfh F0XO6W8gkGSnmAbiFBvQxg== X-Received: by 10.55.160.196 with SMTP id j187mr46776979qke.145.1499198043625; Tue, 04 Jul 2017 12:54:03 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH 01/14] Consolidate non cancellable open call Date: Tue, 4 Jul 2017 16:53:41 -0300 Message-Id: <1499198034-5837-2-git-send-email-adhemerval.zanella@linaro.org> In-Reply-To: <1499198034-5837-1-git-send-email-adhemerval.zanella@linaro.org> References: <1499198034-5837-1-git-send-email-adhemerval.zanella@linaro.org> This patch consolidates all the non cancellable open calls to use the __open_nocancel identifier. For non cancellable targets it will be just a macro to call the default respective symbol while on Linux will be a internal one. To be consistent with the following non cancellable openat call, a new __open64_nocancel is also added (although not currently used). Checked on x86_64-linux-gnu, x86_64-linux-gnu-x32, and i686-linux-gnu. * sysdeps/generic/not-cancel.h (open_not_cancel): Remove macro. (open_not_cancel_2): Likewise. (open_nocancel): New macro. (open64_nocancel): Likewise. * sysdeps/unix/sysv/linux/not-cancel.h (open_not_cancel): Remove macro. (open_not_cancel_2): Likewise. (__open_nocancel): New prototype. (__open64_nocancel): Likewise. * sysdeps/unix/sysv/linux/Versions (libc) [GLIBC_PRIVATE]: Add __open_nocancel. * sysdeps/unix/sysv/linux/open.c (__open_nocancel): New function. * sysdeps/unix/sysv/linux/open64.c (__open64_nocancel): Likewise. * catgets/open_catalog.c (__open_catalog): Replace open_not_cancel{_2} with __open_nocancel. * csu/check_fds.c (check_one_fd): Likewise. * gmon/gmon.c (write_gmon): Likewise. * iconv/gconv_cache.c (__gconv_load_cached): Likewise. * intl/loadmsgcat.c (open): Likewise. * libio/fileops.c (_IO_file_open): Likewise. * locale/loadarchive.c (_nl_load_locale_from_archive): Likewise. * locale/loadlocale.c (_nl_load_locale): Likewise. * login/utmp_file.c (setutent_file): Likewise. * misc/daemon.c (daemon): Likewise. * nss/nss_db/db-open.c (internal_setent): Likewise. * sysdeps/mach/hurd/opendir.c (__opendirat): Likewise. * sysdeps/posix/libc_fatal.c (__libc_message): Likewise. * sysdeps/posix/opendir.c (tryopen_o_directory): Likewise. (__opendir): Likewise. * sysdeps/posix/spawni.c (__spawni_child): Likewise. * sysdeps/unix/sysv/linux/fips-private.h (fips_enable_p): Likewise. * sysdeps/unix/sysv/linux/gethostid.c (sethostid): Likewise. (gethostid): Likewise. * sysdeps/unix/sysv/linux/getloadavg.c (getloadavg): Likewise. * sysdeps/unix/sysv/linux/getlogin_r.c (__getlogin_r_loginuid): Likewise. * sysdeps/unix/sysv/linux/getsysstats.c (__get_nprocs): Likewise. * sysdeps/unix/sysv/linux/grantpt.c (__close_all_fds): Likewise. * sysdeps/unix/sysv/linux/i386/smp.h (is_smp_system): Likewise. * sysdeps/unix/sysv/linux/ia64/has_cpuclock.c (has_cpuclock): Likewise. * sysdeps/unix/sysv/linux/libc_fatal.c (backtrace_and_maps): Likewise. * sysdeps/unix/sysv/linux/malloc-sysdep.h (check_may_shrink_heap): Likewise. * sysdeps/unix/sysv/linux/powerpc/get_clockfreq.c (__get_clockfreq): Likewise. * sysdeps/unix/sysv/linux/pthread_getname.c (pthread_getname_np): Likewise. * sysdeps/unix/sysv/linux/pthread_setname.c (pthread_setname_np): Likewise. * sysdeps/unix/sysv/linux/spawni.c (__spawni_child): Likewise. * sysdeps/unix/sysv/linux/sysconf.c (__sysconf): Likewise. --- ChangeLog | 55 +++++++++++++++++++++++++ catgets/open_catalog.c | 4 +- csu/check_fds.c | 2 +- gmon/gmon.c | 4 +- iconv/gconv_cache.c | 2 +- intl/loadmsgcat.c | 2 +- libio/fileops.c | 2 +- locale/loadarchive.c | 4 +- locale/loadlocale.c | 4 +- login/utmp_file.c | 6 +-- misc/daemon.c | 2 +- nss/nss_db/db-open.c | 2 +- sysdeps/generic/not-cancel.h | 8 ++-- sysdeps/mach/hurd/opendir.c | 2 +- sysdeps/posix/libc_fatal.c | 2 +- sysdeps/posix/opendir.c | 4 +- sysdeps/posix/spawni.c | 2 +- sysdeps/unix/sysv/linux/Versions | 1 + sysdeps/unix/sysv/linux/fips-private.h | 2 +- sysdeps/unix/sysv/linux/gethostid.c | 4 +- sysdeps/unix/sysv/linux/getloadavg.c | 2 +- sysdeps/unix/sysv/linux/getlogin_r.c | 2 +- sysdeps/unix/sysv/linux/getsysstats.c | 6 +-- sysdeps/unix/sysv/linux/grantpt.c | 4 +- sysdeps/unix/sysv/linux/i386/smp.h | 2 +- sysdeps/unix/sysv/linux/ia64/has_cpuclock.c | 2 +- sysdeps/unix/sysv/linux/libc_fatal.c | 2 +- sysdeps/unix/sysv/linux/malloc-sysdep.h | 4 +- sysdeps/unix/sysv/linux/not-cancel.h | 20 ++++----- sysdeps/unix/sysv/linux/open.c | 18 ++++++++ sysdeps/unix/sysv/linux/open64.c | 35 +++++++++++++--- sysdeps/unix/sysv/linux/powerpc/get_clockfreq.c | 2 +- sysdeps/unix/sysv/linux/pthread_getname.c | 2 +- sysdeps/unix/sysv/linux/pthread_setname.c | 2 +- sysdeps/unix/sysv/linux/spawni.c | 2 +- sysdeps/unix/sysv/linux/sysconf.c | 2 +- 36 files changed, 157 insertions(+), 64 deletions(-) -- 2.7.4 diff --git a/catgets/open_catalog.c b/catgets/open_catalog.c index cbb305a..4621b26 100644 --- a/catgets/open_catalog.c +++ b/catgets/open_catalog.c @@ -50,7 +50,7 @@ __open_catalog (const char *cat_name, const char *nlspath, const char *env_var, char *buf = NULL; if (strchr (cat_name, '/') != NULL || nlspath == NULL) - fd = open_not_cancel_2 (cat_name, O_RDONLY); + fd = __open_nocancel (cat_name, O_RDONLY); else { const char *run_nlspath = nlspath; @@ -178,7 +178,7 @@ __open_catalog (const char *cat_name, const char *nlspath, const char *env_var, if (bufact != 0) { - fd = open_not_cancel_2 (buf, O_RDONLY); + fd = __open_nocancel (buf, O_RDONLY); if (fd >= 0) break; } diff --git a/csu/check_fds.c b/csu/check_fds.c index 062c879..5bd6392 100644 --- a/csu/check_fds.c +++ b/csu/check_fds.c @@ -61,7 +61,7 @@ check_one_fd (int fd, int mode) /* Something is wrong with this descriptor, it's probably not opened. Open /dev/null so that the SUID program we are about to start does not accidentally use this descriptor. */ - int nullfd = open_not_cancel (name, mode, 0); + int nullfd = __open_nocancel (name, mode, 0); /* We are very paranoid here. With all means we try to ensure that we are actually opening the /dev/null device and nothing diff --git a/gmon/gmon.c b/gmon/gmon.c index f394a78..87c3c4e 100644 --- a/gmon/gmon.c +++ b/gmon/gmon.c @@ -342,12 +342,12 @@ write_gmon (void) size_t len = strlen (env); char buf[len + 20]; __snprintf (buf, sizeof (buf), "%s.%u", env, __getpid ()); - fd = open_not_cancel (buf, O_CREAT|O_TRUNC|O_WRONLY|O_NOFOLLOW, 0666); + fd = __open_nocancel (buf, O_CREAT|O_TRUNC|O_WRONLY|O_NOFOLLOW, 0666); } if (fd == -1) { - fd = open_not_cancel ("gmon.out", O_CREAT|O_TRUNC|O_WRONLY|O_NOFOLLOW, + fd = __open_nocancel ("gmon.out", O_CREAT|O_TRUNC|O_WRONLY|O_NOFOLLOW, 0666); if (fd < 0) { diff --git a/iconv/gconv_cache.c b/iconv/gconv_cache.c index 0cadea3..f1dce29 100644 --- a/iconv/gconv_cache.c +++ b/iconv/gconv_cache.c @@ -59,7 +59,7 @@ __gconv_load_cache (void) return -1; /* See whether the cache file exists. */ - fd = open_not_cancel (GCONV_MODULES_CACHE, O_RDONLY, 0); + fd = __open_nocancel (GCONV_MODULES_CACHE, O_RDONLY, 0); if (__builtin_expect (fd, 0) == -1) /* Not available. */ return -1; diff --git a/intl/loadmsgcat.c b/intl/loadmsgcat.c index c2ff64e..adca419 100644 --- a/intl/loadmsgcat.c +++ b/intl/loadmsgcat.c @@ -445,7 +445,7 @@ /* Rename the non ISO C functions. This is required by the standard because some ISO C functions will require linking with this object file and the name space must not be polluted. */ -# define open(name, flags) open_not_cancel_2 (name, flags) +# define open(name, flags) __open_nocancel (name, flags) # define close(fd) close_not_cancel_no_status (fd) # define read(fd, buf, n) read_not_cancel (fd, buf, n) # define mmap(addr, len, prot, flags, fd, offset) \ diff --git a/libio/fileops.c b/libio/fileops.c index c55e196..67f3d72 100644 --- a/libio/fileops.c +++ b/libio/fileops.c @@ -223,7 +223,7 @@ _IO_file_open (_IO_FILE *fp, const char *filename, int posix_mode, int prot, int fdesc; #ifdef _LIBC if (__glibc_unlikely (fp->_flags2 & _IO_FLAGS2_NOTCANCEL)) - fdesc = open_not_cancel (filename, + fdesc = __open_nocancel (filename, posix_mode | (is32not64 ? 0 : O_LARGEFILE), prot); else fdesc = open (filename, posix_mode | (is32not64 ? 0 : O_LARGEFILE), prot); diff --git a/locale/loadarchive.c b/locale/loadarchive.c index e6e1a05..aebb590 100644 --- a/locale/loadarchive.c +++ b/locale/loadarchive.c @@ -203,7 +203,7 @@ _nl_load_locale_from_archive (int category, const char **namep) archmapped = &headmap; /* The archive has never been opened. */ - fd = open_not_cancel_2 (archfname, O_RDONLY|O_LARGEFILE|O_CLOEXEC); + fd = __open_nocancel (archfname, O_RDONLY|O_LARGEFILE|O_CLOEXEC); if (fd < 0) /* Cannot open the archive, for whatever reason. */ return NULL; @@ -398,7 +398,7 @@ _nl_load_locale_from_archive (int category, const char **namep) if (fd == -1) { struct stat64 st; - fd = open_not_cancel_2 (archfname, + fd = __open_nocancel (archfname, O_RDONLY|O_LARGEFILE|O_CLOEXEC); if (fd == -1) /* Cannot open the archive, for whatever reason. */ diff --git a/locale/loadlocale.c b/locale/loadlocale.c index 9bca304..9c69ad4 100644 --- a/locale/loadlocale.c +++ b/locale/loadlocale.c @@ -173,7 +173,7 @@ _nl_load_locale (struct loaded_l10nfile *file, int category) file->decided = 1; file->data = NULL; - fd = open_not_cancel_2 (file->filename, O_RDONLY | O_CLOEXEC); + fd = __open_nocancel (file->filename, O_RDONLY | O_CLOEXEC); if (__builtin_expect (fd, 0) < 0) /* Cannot open the file. */ return; @@ -201,7 +201,7 @@ _nl_load_locale (struct loaded_l10nfile *file, int category) _nl_category_names.str + _nl_category_name_idxs[category], _nl_category_name_sizes[category] + 1); - fd = open_not_cancel_2 (newp, O_RDONLY | O_CLOEXEC); + fd = __open_nocancel (newp, O_RDONLY | O_CLOEXEC); if (__builtin_expect (fd, 0) < 0) return; diff --git a/login/utmp_file.c b/login/utmp_file.c index 240e0e3..1407116 100644 --- a/login/utmp_file.c +++ b/login/utmp_file.c @@ -143,7 +143,7 @@ setutent_file (void) file_name = TRANSFORM_UTMP_FILE_NAME (__libc_utmp_file_name); file_writable = false; - file_fd = open_not_cancel_2 + file_fd = __open_nocancel (file_name, O_RDONLY | O_LARGEFILE | O_CLOEXEC); if (file_fd == -1) return 0; @@ -374,7 +374,7 @@ pututline_file (const struct utmp *data) /* We must make the file descriptor writable before going on. */ const char *file_name = TRANSFORM_UTMP_FILE_NAME (__libc_utmp_file_name); - int new_fd = open_not_cancel_2 + int new_fd = __open_nocancel (file_name, O_RDWR | O_LARGEFILE | O_CLOEXEC); if (new_fd == -1) return NULL; @@ -484,7 +484,7 @@ updwtmp_file (const char *file, const struct utmp *utmp) int fd; /* Open WTMP file. */ - fd = open_not_cancel_2 (file, O_WRONLY | O_LARGEFILE); + fd = __open_nocancel (file, O_WRONLY | O_LARGEFILE); if (fd < 0) return -1; diff --git a/misc/daemon.c b/misc/daemon.c index 9d186b2..dd38f2b 100644 --- a/misc/daemon.c +++ b/misc/daemon.c @@ -63,7 +63,7 @@ daemon (int nochdir, int noclose) if (!noclose) { struct stat64 st; - if ((fd = open_not_cancel(_PATH_DEVNULL, O_RDWR, 0)) != -1 + if ((fd = __open_nocancel(_PATH_DEVNULL, O_RDWR, 0)) != -1 && (__builtin_expect (__fxstat64 (_STAT_VER, fd, &st), 0) == 0)) { if (__builtin_expect (S_ISCHR (st.st_mode), 1) != 0 diff --git a/nss/nss_db/db-open.c b/nss/nss_db/db-open.c index 1c58bd1..40a2540 100644 --- a/nss/nss_db/db-open.c +++ b/nss/nss_db/db-open.c @@ -36,7 +36,7 @@ internal_setent (const char *file, struct nss_db_map *mapping) { enum nss_status status = NSS_STATUS_UNAVAIL; - int fd = open_not_cancel_2 (file, O_RDONLY | O_LARGEFILE | O_CLOEXEC); + int fd = __open_nocancel (file, O_RDONLY | O_LARGEFILE | O_CLOEXEC); if (fd != -1) { struct nss_db_header header; diff --git a/sysdeps/generic/not-cancel.h b/sysdeps/generic/not-cancel.h index 5eabd2b..a4f7b7b 100644 --- a/sysdeps/generic/not-cancel.h +++ b/sysdeps/generic/not-cancel.h @@ -18,10 +18,10 @@ . */ /* By default we have none. Map the name to the normal functions. */ -#define open_not_cancel(name, flags, mode) \ - __libc_open (name, flags, mode) -#define open_not_cancel_2(name, flags) \ - __libc_open (name, flags) +#define __open_nocancel(...) \ + __open (__VA_ARGS__) +#define __open64_nocancel(...) \ + __open64 (__VA_ARGS__) #define openat_not_cancel(fd, name, flags, mode) \ __openat (fd, name, flags, mode) #define openat_not_cancel_3(fd, name, flags) \ diff --git a/sysdeps/mach/hurd/opendir.c b/sysdeps/mach/hurd/opendir.c index b3dab24..8db70b2 100644 --- a/sysdeps/mach/hurd/opendir.c +++ b/sysdeps/mach/hurd/opendir.c @@ -84,7 +84,7 @@ __opendirat (int dfd, const char *name) int fd; #if IS_IN (rtld) assert (dfd == AT_FDCWD); - fd = open_not_cancel_2 (name, flags); + fd = __open_nocancel (name, flags); #else fd = openat_not_cancel_3 (dfd, name, flags); #endif diff --git a/sysdeps/posix/libc_fatal.c b/sysdeps/posix/libc_fatal.c index b261963..37834c7 100644 --- a/sysdeps/posix/libc_fatal.c +++ b/sysdeps/posix/libc_fatal.c @@ -79,7 +79,7 @@ __libc_message (int do_abort, const char *fmt, ...) requests errors on standard error. */ const char *on_2 = __libc_secure_getenv ("LIBC_FATAL_STDERR_"); if (on_2 == NULL || *on_2 == '\0') - fd = open_not_cancel_2 (_PATH_TTY, O_RDWR | O_NOCTTY | O_NDELAY); + fd = __open_nocancel (_PATH_TTY, O_RDWR | O_NOCTTY | O_NDELAY); if (fd == -1) fd = STDERR_FILENO; diff --git a/sysdeps/posix/opendir.c b/sysdeps/posix/opendir.c index 909aa61..3ee27b2 100644 --- a/sysdeps/posix/opendir.c +++ b/sysdeps/posix/opendir.c @@ -61,7 +61,7 @@ static void tryopen_o_directory (void) { int serrno = errno; - int x = open_not_cancel_2 ("/dev/null", O_RDONLY|O_NDELAY|O_DIRECTORY); + int x = __open_nocancel ("/dev/null", O_RDONLY|O_NDELAY|O_DIRECTORY); if (x >= 0) { @@ -188,7 +188,7 @@ __opendir (const char *name) } } - return opendir_tail (open_not_cancel_2 (name, opendir_oflags)); + return opendir_tail (__open_nocancel (name, opendir_oflags)); } weak_alias (__opendir, opendir) diff --git a/sysdeps/posix/spawni.c b/sysdeps/posix/spawni.c index 1979830..aaca6e2 100644 --- a/sysdeps/posix/spawni.c +++ b/sysdeps/posix/spawni.c @@ -185,7 +185,7 @@ __spawni_child (void *arguments) paths (like /dev/watchdog). */ close_not_cancel (action->action.open_action.fd); - int new_fd = open_not_cancel (action->action.open_action.path, + int new_fd = __open_nocancel (action->action.open_action.path, action->action.open_action.oflag | O_LARGEFILE, action->action.open_action.mode); diff --git a/sysdeps/unix/sysv/linux/Versions b/sysdeps/unix/sysv/linux/Versions index 202ffcc..3c64077 100644 --- a/sysdeps/unix/sysv/linux/Versions +++ b/sysdeps/unix/sysv/linux/Versions @@ -169,6 +169,7 @@ libc { GLIBC_PRIVATE { # functions used in other libraries __syscall_rt_sigqueueinfo; + __open_nocancel; # functions used by nscd __netlink_assert_response; } diff --git a/sysdeps/unix/sysv/linux/fips-private.h b/sysdeps/unix/sysv/linux/fips-private.h index c9fe266..3a83a0f 100644 --- a/sysdeps/unix/sysv/linux/fips-private.h +++ b/sysdeps/unix/sysv/linux/fips-private.h @@ -42,7 +42,7 @@ fips_enabled_p (void) if (checked == FIPS_UNTESTED) { - int fd = open_not_cancel_2 ("/proc/sys/crypto/fips_enabled", O_RDONLY); + int fd = __open_nocancel ("/proc/sys/crypto/fips_enabled", O_RDONLY); if (fd != -1) { diff --git a/sysdeps/unix/sysv/linux/gethostid.c b/sysdeps/unix/sysv/linux/gethostid.c index cc108aa..3ea8656 100644 --- a/sysdeps/unix/sysv/linux/gethostid.c +++ b/sysdeps/unix/sysv/linux/gethostid.c @@ -47,7 +47,7 @@ sethostid (long int id) } /* Open file for writing. Everybody is allowed to read this file. */ - fd = open_not_cancel (HOSTIDFILE, O_CREAT|O_WRONLY|O_TRUNC, 0644); + fd = __open_nocancel (HOSTIDFILE, O_CREAT|O_WRONLY|O_TRUNC, 0644); if (fd < 0) return -1; @@ -77,7 +77,7 @@ gethostid (void) int fd; /* First try to get the ID from a former invocation of sethostid. */ - fd = open_not_cancel (HOSTIDFILE, O_RDONLY|O_LARGEFILE, 0); + fd = __open_nocancel (HOSTIDFILE, O_RDONLY|O_LARGEFILE, 0); if (fd >= 0) { ssize_t n = read_not_cancel (fd, &id, sizeof (id)); diff --git a/sysdeps/unix/sysv/linux/getloadavg.c b/sysdeps/unix/sysv/linux/getloadavg.c index 117f8c2..0bfe41d 100644 --- a/sysdeps/unix/sysv/linux/getloadavg.c +++ b/sysdeps/unix/sysv/linux/getloadavg.c @@ -33,7 +33,7 @@ getloadavg (double loadavg[], int nelem) { int fd; - fd = open_not_cancel_2 ("/proc/loadavg", O_RDONLY); + fd = __open_nocancel ("/proc/loadavg", O_RDONLY); if (fd < 0) return -1; else diff --git a/sysdeps/unix/sysv/linux/getlogin_r.c b/sysdeps/unix/sysv/linux/getlogin_r.c index 05ac36b..2519792 100644 --- a/sysdeps/unix/sysv/linux/getlogin_r.c +++ b/sysdeps/unix/sysv/linux/getlogin_r.c @@ -34,7 +34,7 @@ int attribute_hidden __getlogin_r_loginuid (char *name, size_t namesize) { - int fd = open_not_cancel_2 ("/proc/self/loginuid", O_RDONLY); + int fd = __open_nocancel ("/proc/self/loginuid", O_RDONLY); if (fd == -1) return -1; diff --git a/sysdeps/unix/sysv/linux/getsysstats.c b/sysdeps/unix/sysv/linux/getsysstats.c index a0dd6eb..e21a34c 100644 --- a/sysdeps/unix/sysv/linux/getsysstats.c +++ b/sysdeps/unix/sysv/linux/getsysstats.c @@ -143,7 +143,7 @@ __get_nprocs (void) char *re = buffer_end; const int flags = O_RDONLY | O_CLOEXEC; - int fd = open_not_cancel_2 ("/sys/devices/system/cpu/online", flags); + int fd = __open_nocancel ("/sys/devices/system/cpu/online", flags); char *l; int result = 0; if (fd != -1) @@ -194,7 +194,7 @@ __get_nprocs (void) result = 2; /* The /proc/stat format is more uniform, use it by default. */ - fd = open_not_cancel_2 ("/proc/stat", flags); + fd = __open_nocancel ("/proc/stat", flags); if (fd != -1) { result = 0; @@ -211,7 +211,7 @@ __get_nprocs (void) } else { - fd = open_not_cancel_2 ("/proc/cpuinfo", flags); + fd = __open_nocancel ("/proc/cpuinfo", flags); if (fd != -1) { GET_NPROCS_PARSER (fd, buffer, cp, re, buffer_end, result); diff --git a/sysdeps/unix/sysv/linux/grantpt.c b/sysdeps/unix/sysv/linux/grantpt.c index 8cebde3..97c6ba7 100644 --- a/sysdeps/unix/sysv/linux/grantpt.c +++ b/sysdeps/unix/sysv/linux/grantpt.c @@ -31,9 +31,9 @@ close_all_fds (void) __closedir (dir); - int nullfd = open_not_cancel_2 (_PATH_DEVNULL, O_RDONLY); + int nullfd = __open_nocancel (_PATH_DEVNULL, O_RDONLY); assert (nullfd == STDIN_FILENO); - nullfd = open_not_cancel_2 (_PATH_DEVNULL, O_WRONLY); + nullfd = __open_nocancel (_PATH_DEVNULL, O_WRONLY); assert (nullfd == STDOUT_FILENO); __dup2 (STDOUT_FILENO, STDERR_FILENO); } diff --git a/sysdeps/unix/sysv/linux/i386/smp.h b/sysdeps/unix/sysv/linux/i386/smp.h index 3109ea9..c24f2fd 100644 --- a/sysdeps/unix/sysv/linux/i386/smp.h +++ b/sysdeps/unix/sysv/linux/i386/smp.h @@ -41,7 +41,7 @@ is_smp_system (void) else { /* This was not successful. Now try reading the /proc filesystem. */ - int fd = open_not_cancel_2 ("/proc/sys/kernel/version", O_RDONLY); + int fd = __open_nocancel ("/proc/sys/kernel/version", O_RDONLY); if (__builtin_expect (fd, 0) == -1 || read_not_cancel (fd, u.buf, sizeof (u.buf)) <= 0) /* This also didn't work. We give up and say it's a UP machine. */ diff --git a/sysdeps/unix/sysv/linux/ia64/has_cpuclock.c b/sysdeps/unix/sysv/linux/ia64/has_cpuclock.c index 2207c88..04e395b 100644 --- a/sysdeps/unix/sysv/linux/ia64/has_cpuclock.c +++ b/sysdeps/unix/sysv/linux/ia64/has_cpuclock.c @@ -30,7 +30,7 @@ has_cpuclock (void) if (__builtin_expect (itc_usable == 0, 0)) { int newval = 1; - int fd = open_not_cancel_2 ("/proc/sal/itc_drift", O_RDONLY); + int fd = __open_nocancel ("/proc/sal/itc_drift", O_RDONLY); if (__builtin_expect (fd != -1, 1)) { char buf[16]; diff --git a/sysdeps/unix/sysv/linux/libc_fatal.c b/sysdeps/unix/sysv/linux/libc_fatal.c index d22bfdc..5b484cf 100644 --- a/sysdeps/unix/sysv/linux/libc_fatal.c +++ b/sysdeps/unix/sysv/linux/libc_fatal.c @@ -53,7 +53,7 @@ backtrace_and_maps (int do_abort, bool written, int fd) __backtrace_symbols_fd (addrs + 1, n - 1, fd); writestr (strnsize ("======= Memory map: ========\n")); - int fd2 = open_not_cancel_2 ("/proc/self/maps", O_RDONLY); + int fd2 = __open_nocancel ("/proc/self/maps", O_RDONLY); char buf[1024]; ssize_t n2; while ((n2 = read_not_cancel (fd2, buf, sizeof (buf))) > 0) diff --git a/sysdeps/unix/sysv/linux/malloc-sysdep.h b/sysdeps/unix/sysv/linux/malloc-sysdep.h index 48cf7c1..cb87b58 100644 --- a/sysdeps/unix/sysv/linux/malloc-sysdep.h +++ b/sysdeps/unix/sysv/linux/malloc-sysdep.h @@ -42,8 +42,8 @@ check_may_shrink_heap (void) if (__builtin_expect (may_shrink_heap == 0, 1)) { - int fd = open_not_cancel_2 ("/proc/sys/vm/overcommit_memory", - O_RDONLY | O_CLOEXEC); + int fd = __open_nocancel ("/proc/sys/vm/overcommit_memory", + O_RDONLY | O_CLOEXEC); if (fd >= 0) { char val; diff --git a/sysdeps/unix/sysv/linux/not-cancel.h b/sysdeps/unix/sysv/linux/not-cancel.h index 43959ba..8d897f0 100644 --- a/sysdeps/unix/sysv/linux/not-cancel.h +++ b/sysdeps/unix/sysv/linux/not-cancel.h @@ -20,23 +20,19 @@ #ifndef NOT_CANCEL_H # define NOT_CANCEL_H +#include #include #include #include #include -/* Uncancelable open. */ -#ifdef __NR_open -# define open_not_cancel(name, flags, mode) \ - INLINE_SYSCALL (open, 3, name, flags, mode) -# define open_not_cancel_2(name, flags) \ - INLINE_SYSCALL (open, 2, name, flags) -#else -# define open_not_cancel(name, flags, mode) \ - INLINE_SYSCALL (openat, 4, AT_FDCWD, name, flags, mode) -# define open_not_cancel_2(name, flags) \ - INLINE_SYSCALL (openat, 3, AT_FDCWD, name, flags) -#endif +/* Non cancellable open syscall. */ +__typeof (open) __open_nocancel; +libc_hidden_proto (__open_nocancel) + +/* Non cancellable open syscall (LFS version). */ +__typeof (open64) __open64_nocancel; +libc_hidden_proto (__open64_nocancel) /* Uncancelable read. */ #define __read_nocancel(fd, buf, len) \ diff --git a/sysdeps/unix/sysv/linux/open.c b/sysdeps/unix/sysv/linux/open.c index b3912d5..5069333 100644 --- a/sysdeps/unix/sysv/linux/open.c +++ b/sysdeps/unix/sysv/linux/open.c @@ -22,6 +22,7 @@ #include #include +#include #ifndef __OFF_T_MATCHES_OFF64_T @@ -48,4 +49,21 @@ weak_alias (__libc_open, __open) libc_hidden_weak (__open) weak_alias (__libc_open, open) +int +__open_nocancel (const char *file, int oflag, ...) +{ + int mode = 0; + + if (__OPEN_NEEDS_MODE (oflag)) + { + va_list arg; + va_start (arg, oflag); + mode = va_arg (arg, int); + va_end (arg); + } + + return INLINE_SYSCALL_CALL (openat, AT_FDCWD, file, oflag, mode); +} +libc_hidden_def (__open_nocancel) + #endif diff --git a/sysdeps/unix/sysv/linux/open64.c b/sysdeps/unix/sysv/linux/open64.c index fcac984..d5839e3 100644 --- a/sysdeps/unix/sysv/linux/open64.c +++ b/sysdeps/unix/sysv/linux/open64.c @@ -21,6 +21,13 @@ #include #include +#include + +#ifdef __OFF_T_MATCHES_OFF64_T +# define EXTRA_OPEN_FLAGS 0 +#else +# define EXTRA_OPEN_FLAGS O_LARGEFILE +#endif /* Open FILE with access OFLAG. If O_CREAT or O_TMPFILE is in OFLAG, a third argument is the file protection. */ @@ -37,12 +44,6 @@ __libc_open64 (const char *file, int oflag, ...) va_end (arg); } -#ifdef __OFF_T_MATCHES_OFF64_T -# define EXTRA_OPEN_FLAGS 0 -#else -# define EXTRA_OPEN_FLAGS O_LARGEFILE -#endif - return SYSCALL_CANCEL (openat, AT_FDCWD, file, oflag | EXTRA_OPEN_FLAGS, mode); } @@ -51,9 +52,31 @@ strong_alias (__libc_open64, __open64) libc_hidden_weak (__open64) weak_alias (__libc_open64, open64) + +int +__open64_nocancel (const char *file, int oflag, ...) +{ + int mode = 0; + + if (__OPEN_NEEDS_MODE (oflag)) + { + va_list arg; + va_start (arg, oflag); + mode = va_arg (arg, int); + va_end (arg); + } + + return INLINE_SYSCALL_CALL (openat, AT_FDCWD, file, oflag | EXTRA_OPEN_FLAGS, + mode); +} +libc_hidden_def (__open64_nocancel) + #ifdef __OFF_T_MATCHES_OFF64_T strong_alias (__libc_open64, __libc_open) strong_alias (__libc_open64, __open) libc_hidden_weak (__open) weak_alias (__libc_open64, open) + +strong_alias (__open64_nocancel, __open_nocancel) +libc_hidden_weak (__open_nocancel) #endif diff --git a/sysdeps/unix/sysv/linux/powerpc/get_clockfreq.c b/sysdeps/unix/sysv/linux/powerpc/get_clockfreq.c index b8d01d8..c99e7de 100644 --- a/sysdeps/unix/sysv/linux/powerpc/get_clockfreq.c +++ b/sysdeps/unix/sysv/linux/powerpc/get_clockfreq.c @@ -40,7 +40,7 @@ __get_clockfreq (void) contains at least one line like: timebase : 33333333 We search for this line and convert the number into an integer. */ - int fd = open_not_cancel_2 ("/proc/cpuinfo", O_RDONLY); + int fd = __open_nocancel ("/proc/cpuinfo", O_RDONLY); if (__glibc_likely (fd != -1)) return result; diff --git a/sysdeps/unix/sysv/linux/pthread_getname.c b/sysdeps/unix/sysv/linux/pthread_getname.c index 9a5343a..caab2cc 100644 --- a/sysdeps/unix/sysv/linux/pthread_getname.c +++ b/sysdeps/unix/sysv/linux/pthread_getname.c @@ -45,7 +45,7 @@ pthread_getname_np (pthread_t th, char *buf, size_t len) char fname[sizeof (FMT) + 8]; sprintf (fname, FMT, (unsigned int) pd->tid); - int fd = open_not_cancel_2 (fname, O_RDONLY); + int fd = __open_nocancel (fname, O_RDONLY); if (fd == -1) return errno; diff --git a/sysdeps/unix/sysv/linux/pthread_setname.c b/sysdeps/unix/sysv/linux/pthread_setname.c index 5769c5b..93f0e9d 100644 --- a/sysdeps/unix/sysv/linux/pthread_setname.c +++ b/sysdeps/unix/sysv/linux/pthread_setname.c @@ -46,7 +46,7 @@ pthread_setname_np (pthread_t th, const char *name) char fname[sizeof (FMT) + 8]; sprintf (fname, FMT, (unsigned int) pd->tid); - int fd = open_not_cancel_2 (fname, O_RDWR); + int fd = __open_nocancel (fname, O_RDWR); if (fd == -1) return errno; diff --git a/sysdeps/unix/sysv/linux/spawni.c b/sysdeps/unix/sysv/linux/spawni.c index c56f894..4994a07 100644 --- a/sysdeps/unix/sysv/linux/spawni.c +++ b/sysdeps/unix/sysv/linux/spawni.c @@ -230,7 +230,7 @@ __spawni_child (void *arguments) paths (like /dev/watchdog). */ close_not_cancel (action->action.open_action.fd); - int ret = open_not_cancel (action->action.open_action.path, + int ret = __open_nocancel (action->action.open_action.path, action->action. open_action.oflag | O_LARGEFILE, action->action.open_action.mode); diff --git a/sysdeps/unix/sysv/linux/sysconf.c b/sysdeps/unix/sysv/linux/sysconf.c index db20977..ab068ab 100644 --- a/sysdeps/unix/sysv/linux/sysconf.c +++ b/sysdeps/unix/sysv/linux/sysconf.c @@ -115,7 +115,7 @@ __sysconf (int name) if (procfname != NULL) { - int fd = open_not_cancel_2 (procfname, O_RDONLY); + int fd = __open_nocancel (procfname, O_RDONLY); if (fd != -1) { /* This is more than enough, the file contains a single integer. */ From patchwork Tue Jul 4 19:53:42 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 107016 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp1361369qge; Tue, 4 Jul 2017 12:55:06 -0700 (PDT) X-Received: by 10.84.224.142 with SMTP id s14mr18560374plj.195.1499198106088; Tue, 04 Jul 2017 12:55:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499198106; cv=none; d=google.com; s=arc-20160816; b=nwYkirQztZn1dqtbiu88aYWpSdv/uGQOvQQya6Y2KsTLLiAV89pq0uUkcCT9d7VFNH /NHgQLK7KxXpNDSAXij3cZbVoLCzLspwUdzG7DDljbwwXmar/P2JSuJIAJbmY5HJJozu 4n0gSXbYSdwJySRo13AY2TOdHLKtW6vk9iEe8kOIjyyECQ3eTD3pkRzU/lNhCJbYvINh bPj5FTuUzLvtGRJGANL4Jz3N5aFJwUOgdqilXPKYG5i1cLfVLtAJlfCkc5pl7uHWN8HE E03DTJSqq0hL488OsGQNnaON08c19gzFBtTFb54FNPuWeVE6Kx+ifuHDFkKTDA5ySofn qccQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:to:from:delivered-to :sender:list-help:list-post:list-archive:list-subscribe :list-unsubscribe:list-id:precedence:mailing-list:dkim-signature :domainkey-signature:arc-authentication-results; bh=1sOAmxsEPAvaMmYNfGC3jdL79wDYzy1dLxy6OcFOQGE=; b=J3wevo8WlhVqYP6yMk8tOng0/Niq5x47UneBid0jZ8+8QIKsnBOV8Jg1yvHh98sBEa OBGVHAxYSpRigNvV3fuXHRHRxKIxpIq1+T+TScN4PUa80ioAOhMoMM3exHMFKAexdMfp KhOfkS9jCPpft2Q9y84Ridfmzm1byRY1kKbEaEbMD2ZyB6ZP+xTD0ZNUevynJ/qsASfB mDrpEvDa/QmVZgwZ2fQV7IsGgc45wgxbw7t7idsyeCnYC7ejVWLfNGwMFC4LwTy8nc9O l7Ojt8N04PxVznSBWe4Isf5JmRxnw5RzHm8exuN3+PgqgMLSQ53bBvuTLWcu/2bzZwWp K2+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.b=jaBvm52T; spf=pass (google.com: domain of libc-alpha-return-81664-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-81664-patch=linaro.org@sourceware.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id u3si14264358pgo.497.2017.07.04.12.55.05 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 04 Jul 2017 12:55:06 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-return-81664-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.b=jaBvm52T; spf=pass (google.com: domain of libc-alpha-return-81664-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-81664-patch=linaro.org@sourceware.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=YY6dqhq+nQKJqrDtFI6SvsYRoYkzhNC TezS0dP0LquMZzbUFkzh0pr9HvjErc/qxThrzXser3JifGuQd15+xmAWrjam4LJm dqFzgtly17zKt1uxpn7KI6wRCnoZR2Bt7DaGKdpwtW30O0IkqVEq1iJSiUW6daex zgWCOb/6UG0I= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; s=default; bh=d0kF3vqU5XDRZQqbugCNUvlcy1Q=; b=jaBvm 52TEFquCrsMYy7U7naeVFHPB/++X37eMsjSx3XP/NXXp+XRqeSAXGtVW1+rT/v/g 08hXnhDa1g7Ijhxj3F9wzDyZA3tdi0PRg5Uwv0zjdQGNcB5/xo354/3nD4f+CixS IFuFSGvs9GlyQh/8QYGUtXtBPcn1kzy5ARy9BM= Received: (qmail 74287 invoked by alias); 4 Jul 2017 19:54:21 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 73503 invoked by uid 89); 4 Jul 2017 19:54:13 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.4 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy=Non X-HELO: mail-qk0-f170.google.com 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:in-reply-to :references; bh=1sOAmxsEPAvaMmYNfGC3jdL79wDYzy1dLxy6OcFOQGE=; b=RBwUv1ifRpzhDtrZSJRhGncYYddqHIYD1ax1STJhTPsyFZmlaTGrkVdlZI98Fl3uHm rOd4V7/w0SILWNh06QMq5f+Nf00M62beX97k6xoEx2PeKdrByOeefqqhu11/cTPGGIYv ezS9x6dmBLmE6SAeO7+N4XFKxRKZnq0f2TqfQ4hMJvlY5n0pwfVrAjCcSel3EgB6DGDJ TNlmsPmQBrAGkSCI9geDyLFWH4MHovyBBbiIy0Y9rb5JDrS9i9XJ2OwqQG7JMI6QGkTM YEpR0PhQwmtRCLqIZl9gi9HE52kqhJ346ys0wvKTM42LTb+1jqAVAHB9bDrLGu8Vjojx VbcA== X-Gm-Message-State: AIVw112StrC+7Ijz+9epggDxA/bEnTzs1usLZ7SZEnL71W7N1V8Qa+Cq y7+0RZ5MHYBi96eJJ21/Ug== X-Received: by 10.55.153.4 with SMTP id b4mr19298285qke.203.1499198045029; Tue, 04 Jul 2017 12:54:05 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH 02/14] Consolidate non cancellable read call Date: Tue, 4 Jul 2017 16:53:42 -0300 Message-Id: <1499198034-5837-3-git-send-email-adhemerval.zanella@linaro.org> In-Reply-To: <1499198034-5837-1-git-send-email-adhemerval.zanella@linaro.org> References: <1499198034-5837-1-git-send-email-adhemerval.zanella@linaro.org> This patch consolidates all the non cancellable read calls to use the __read_nocancel identifier. For non cancellable targets it will be just a macro to call the default respective symbol while on Linux will be a internal one. Also, since it is used on libcrypto it is exported in GLIBC_PRIVATE namespace. Checked on x86_64-linux-gnu, x86_64-linux-gnu-x32, and i686-linux-gnu. * sysdeps/generic/not-cancel.h (read_not_cancel): Remove macro. (__read_nocancel): New macro. * sysdeps/unix/sysv/linux/Versions (libc) [GLIBC_PRIVATE]: Add __read_nocancel. * sysdeps/unix/sysv/linux/not-cancel.h (__read_nocancel): Remove macro. (__read_nocancel): New prototype. * sysdeps/unix/sysv/linux/read.c (__read_nocancel): New function. * catgets/open_catalog.c (__open_catalog): Replace read_not_cancel with __read_nocancel. * intl/loadmsgcat.c (read): Likewise. * libio/fileops.c (_IO_file_read): Likewise. * locale/loadlocale.c (_nl_load_locale): Likewise. * login/utmp_file.c (getutent_r_file): Likewise. (internal_getut_r): Likewise. (getutline_r_file): Likewise. * sysdeps/unix/sysv/linux/fips-private.h (fips_enable_p): Likewise. * sysdeps/unix/sysv/linux/gethostid.c (gethostid): Likewise. * sysdeps/unix/sysv/linux/getloadavg.c (getloadavg): Likewise. * sysdeps/unix/sysv/linux/getlogin_r.c (__getlogin_r_loginuid): Likewise. * sysdeps/unix/sysv/linux/getsysstats.c (next_line): Likewise. * sysdeps/unix/sysv/linux/i386/smp.h (is_smp_system): Likewise. * sysdeps/unix/sysv/linux/ia64/has_cpuclock.c (has_cpuclock): Likewise. * sysdeps/unix/sysv/linux/libc_fatal.c (backtrace_and_maps): Likewise. * sysdeps/unix/sysv/linux/malloc-sysdep.h (check_may_shrink_heap): Likewise. * sysdeps/unix/sysv/linux/pthread_getname.c (pthread_getname_np): Likewise. * sysdeps/unix/sysv/linux/sysconf.c (__sysconf): Likewise. --- ChangeLog | 33 +++++++++++++++++++++++++++++ catgets/open_catalog.c | 2 +- intl/loadmsgcat.c | 2 +- libio/fileops.c | 2 +- locale/loadlocale.c | 2 +- login/utmp_file.c | 8 +++---- sysdeps/generic/not-cancel.h | 2 +- sysdeps/unix/sysv/linux/Versions | 1 + sysdeps/unix/sysv/linux/fips-private.h | 2 +- sysdeps/unix/sysv/linux/gethostid.c | 2 +- sysdeps/unix/sysv/linux/getloadavg.c | 2 +- sysdeps/unix/sysv/linux/getlogin_r.c | 2 +- sysdeps/unix/sysv/linux/getsysstats.c | 4 ++-- sysdeps/unix/sysv/linux/i386/smp.h | 2 +- sysdeps/unix/sysv/linux/ia64/has_cpuclock.c | 2 +- sysdeps/unix/sysv/linux/libc_fatal.c | 2 +- sysdeps/unix/sysv/linux/malloc-sysdep.h | 2 +- sysdeps/unix/sysv/linux/not-cancel.h | 10 +++------ sysdeps/unix/sysv/linux/pthread_getname.c | 2 +- sysdeps/unix/sysv/linux/read.c | 8 +++++++ sysdeps/unix/sysv/linux/sysconf.c | 2 +- 21 files changed, 66 insertions(+), 28 deletions(-) -- 2.7.4 diff --git a/catgets/open_catalog.c b/catgets/open_catalog.c index 4621b26..d79a6b1 100644 --- a/catgets/open_catalog.c +++ b/catgets/open_catalog.c @@ -237,7 +237,7 @@ __open_catalog (const char *cat_name, const char *nlspath, const char *env_var, /* Save read, handle partial reads. */ do { - size_t now = read_not_cancel (fd, (((char *) catalog->file_ptr) + size_t now = __read_nocancel (fd, (((char *) catalog->file_ptr) + (st.st_size - todo)), todo); if (now == 0 || now == (size_t) -1) { diff --git a/intl/loadmsgcat.c b/intl/loadmsgcat.c index adca419..514e38f 100644 --- a/intl/loadmsgcat.c +++ b/intl/loadmsgcat.c @@ -447,7 +447,7 @@ file and the name space must not be polluted. */ # define open(name, flags) __open_nocancel (name, flags) # define close(fd) close_not_cancel_no_status (fd) -# define read(fd, buf, n) read_not_cancel (fd, buf, n) +# define read(fd, buf, n) __read_nocancel (fd, buf, n) # define mmap(addr, len, prot, flags, fd, offset) \ __mmap (addr, len, prot, flags, fd, offset) # define munmap(addr, len) __munmap (addr, len) diff --git a/libio/fileops.c b/libio/fileops.c index 67f3d72..80bd3f5 100644 --- a/libio/fileops.c +++ b/libio/fileops.c @@ -1204,7 +1204,7 @@ _IO_ssize_t _IO_file_read (_IO_FILE *fp, void *buf, _IO_ssize_t size) { return (__builtin_expect (fp->_flags2 & _IO_FLAGS2_NOTCANCEL, 0) - ? read_not_cancel (fp->_fileno, buf, size) + ? __read_nocancel (fp->_fileno, buf, size) : read (fp->_fileno, buf, size)); } libc_hidden_def (_IO_file_read) diff --git a/locale/loadlocale.c b/locale/loadlocale.c index 9c69ad4..a733557 100644 --- a/locale/loadlocale.c +++ b/locale/loadlocale.c @@ -238,7 +238,7 @@ _nl_load_locale (struct loaded_l10nfile *file, int category) char *p = (char *) filedata; while (to_read > 0) { - nread = read_not_cancel (fd, p, to_read); + nread = __read_nocancel (fd, p, to_read); if (__builtin_expect (nread, 1) <= 0) { free (filedata); diff --git a/login/utmp_file.c b/login/utmp_file.c index 1407116..61d03d6 100644 --- a/login/utmp_file.c +++ b/login/utmp_file.c @@ -187,7 +187,7 @@ getutent_r_file (struct utmp *buffer, struct utmp **result) } /* Read the next entry. */ - nbytes = read_not_cancel (file_fd, &last_entry, sizeof (struct utmp)); + nbytes = __read_nocancel (file_fd, &last_entry, sizeof (struct utmp)); UNLOCK_FILE (file_fd); @@ -231,7 +231,7 @@ internal_getut_r (const struct utmp *id, struct utmp *buffer, while (1) { /* Read the next entry. */ - if (read_not_cancel (file_fd, buffer, sizeof (struct utmp)) + if (__read_nocancel (file_fd, buffer, sizeof (struct utmp)) != sizeof (struct utmp)) { __set_errno (ESRCH); @@ -253,7 +253,7 @@ internal_getut_r (const struct utmp *id, struct utmp *buffer, while (1) { /* Read the next entry. */ - if (read_not_cancel (file_fd, buffer, sizeof (struct utmp)) + if (__read_nocancel (file_fd, buffer, sizeof (struct utmp)) != sizeof (struct utmp)) { __set_errno (ESRCH); @@ -329,7 +329,7 @@ getutline_r_file (const struct utmp *line, struct utmp *buffer, while (1) { /* Read the next entry. */ - if (read_not_cancel (file_fd, &last_entry, sizeof (struct utmp)) + if (__read_nocancel (file_fd, &last_entry, sizeof (struct utmp)) != sizeof (struct utmp)) { __set_errno (ESRCH); diff --git a/sysdeps/generic/not-cancel.h b/sysdeps/generic/not-cancel.h index a4f7b7b..4fada2f 100644 --- a/sysdeps/generic/not-cancel.h +++ b/sysdeps/generic/not-cancel.h @@ -34,7 +34,7 @@ __close (fd) #define close_not_cancel_no_status(fd) \ (void) __close (fd) -#define read_not_cancel(fd, buf, n) \ +#define __read_nocancel(fd, buf, n) \ __read (fd, buf, n) #define write_not_cancel(fd, buf, n) \ __write (fd, buf, n) diff --git a/sysdeps/unix/sysv/linux/Versions b/sysdeps/unix/sysv/linux/Versions index 3c64077..b553514 100644 --- a/sysdeps/unix/sysv/linux/Versions +++ b/sysdeps/unix/sysv/linux/Versions @@ -170,6 +170,7 @@ libc { # functions used in other libraries __syscall_rt_sigqueueinfo; __open_nocancel; + __read_nocancel; # functions used by nscd __netlink_assert_response; } diff --git a/sysdeps/unix/sysv/linux/fips-private.h b/sysdeps/unix/sysv/linux/fips-private.h index 3a83a0f..775f2c2 100644 --- a/sysdeps/unix/sysv/linux/fips-private.h +++ b/sysdeps/unix/sysv/linux/fips-private.h @@ -49,7 +49,7 @@ fips_enabled_p (void) /* This is more than enough, the file contains a single integer. */ char buf[32]; ssize_t n; - n = TEMP_FAILURE_RETRY (read_not_cancel (fd, buf, sizeof (buf) - 1)); + n = TEMP_FAILURE_RETRY (__read_nocancel (fd, buf, sizeof (buf) - 1)); close_not_cancel_no_status (fd); if (n > 0) diff --git a/sysdeps/unix/sysv/linux/gethostid.c b/sysdeps/unix/sysv/linux/gethostid.c index 3ea8656..6e19dee 100644 --- a/sysdeps/unix/sysv/linux/gethostid.c +++ b/sysdeps/unix/sysv/linux/gethostid.c @@ -80,7 +80,7 @@ gethostid (void) fd = __open_nocancel (HOSTIDFILE, O_RDONLY|O_LARGEFILE, 0); if (fd >= 0) { - ssize_t n = read_not_cancel (fd, &id, sizeof (id)); + ssize_t n = __read_nocancel (fd, &id, sizeof (id)); close_not_cancel_no_status (fd); diff --git a/sysdeps/unix/sysv/linux/getloadavg.c b/sysdeps/unix/sysv/linux/getloadavg.c index 0bfe41d..64bad17 100644 --- a/sysdeps/unix/sysv/linux/getloadavg.c +++ b/sysdeps/unix/sysv/linux/getloadavg.c @@ -42,7 +42,7 @@ getloadavg (double loadavg[], int nelem) ssize_t nread; int i; - nread = read_not_cancel (fd, buf, sizeof buf - 1); + nread = __read_nocancel (fd, buf, sizeof buf - 1); close_not_cancel_no_status (fd); if (nread <= 0) return -1; diff --git a/sysdeps/unix/sysv/linux/getlogin_r.c b/sysdeps/unix/sysv/linux/getlogin_r.c index 2519792..1de746b 100644 --- a/sysdeps/unix/sysv/linux/getlogin_r.c +++ b/sysdeps/unix/sysv/linux/getlogin_r.c @@ -41,7 +41,7 @@ __getlogin_r_loginuid (char *name, size_t namesize) /* We are reading a 32-bit number. 12 bytes are enough for the text representation. If not, something is wrong. */ char uidbuf[12]; - ssize_t n = TEMP_FAILURE_RETRY (read_not_cancel (fd, uidbuf, + ssize_t n = TEMP_FAILURE_RETRY (__read_nocancel (fd, uidbuf, sizeof (uidbuf))); close_not_cancel_no_status (fd); diff --git a/sysdeps/unix/sysv/linux/getsysstats.c b/sysdeps/unix/sysv/linux/getsysstats.c index e21a34c..d1400d6 100644 --- a/sysdeps/unix/sysv/linux/getsysstats.c +++ b/sysdeps/unix/sysv/linux/getsysstats.c @@ -85,7 +85,7 @@ next_line (int fd, char *const buffer, char **cp, char **re, *re = buffer + (*re - *cp); *cp = buffer; - ssize_t n = read_not_cancel (fd, *re, buffer_end - *re); + ssize_t n = __read_nocancel (fd, *re, buffer_end - *re); if (n < 0) return NULL; @@ -96,7 +96,7 @@ next_line (int fd, char *const buffer, char **cp, char **re, { /* Truncate too long lines. */ *re = buffer + 3 * (buffer_end - buffer) / 4; - n = read_not_cancel (fd, *re, buffer_end - *re); + n = __read_nocancel (fd, *re, buffer_end - *re); if (n < 0) return NULL; diff --git a/sysdeps/unix/sysv/linux/i386/smp.h b/sysdeps/unix/sysv/linux/i386/smp.h index c24f2fd..eb1ac5d 100644 --- a/sysdeps/unix/sysv/linux/i386/smp.h +++ b/sysdeps/unix/sysv/linux/i386/smp.h @@ -43,7 +43,7 @@ is_smp_system (void) /* This was not successful. Now try reading the /proc filesystem. */ int fd = __open_nocancel ("/proc/sys/kernel/version", O_RDONLY); if (__builtin_expect (fd, 0) == -1 - || read_not_cancel (fd, u.buf, sizeof (u.buf)) <= 0) + || __read_nocancel (fd, u.buf, sizeof (u.buf)) <= 0) /* This also didn't work. We give up and say it's a UP machine. */ u.buf[0] = '\0'; diff --git a/sysdeps/unix/sysv/linux/ia64/has_cpuclock.c b/sysdeps/unix/sysv/linux/ia64/has_cpuclock.c index 04e395b..6aab1e8 100644 --- a/sysdeps/unix/sysv/linux/ia64/has_cpuclock.c +++ b/sysdeps/unix/sysv/linux/ia64/has_cpuclock.c @@ -37,7 +37,7 @@ has_cpuclock (void) /* We expect the file to contain a single digit followed by a newline. If the format changes we better not rely on the file content. */ - if (read_not_cancel (fd, buf, sizeof buf) != 2 + if (__read_nocancel (fd, buf, sizeof buf) != 2 || buf[0] != '0' || buf[1] != '\n') newval = -1; diff --git a/sysdeps/unix/sysv/linux/libc_fatal.c b/sysdeps/unix/sysv/linux/libc_fatal.c index 5b484cf..ca838a7 100644 --- a/sysdeps/unix/sysv/linux/libc_fatal.c +++ b/sysdeps/unix/sysv/linux/libc_fatal.c @@ -56,7 +56,7 @@ backtrace_and_maps (int do_abort, bool written, int fd) int fd2 = __open_nocancel ("/proc/self/maps", O_RDONLY); char buf[1024]; ssize_t n2; - while ((n2 = read_not_cancel (fd2, buf, sizeof (buf))) > 0) + while ((n2 = __read_nocancel (fd2, buf, sizeof (buf))) > 0) if (write_not_cancel (fd, buf, n2) != n2) break; close_not_cancel_no_status (fd2); diff --git a/sysdeps/unix/sysv/linux/malloc-sysdep.h b/sysdeps/unix/sysv/linux/malloc-sysdep.h index cb87b58..7a7acba 100644 --- a/sysdeps/unix/sysv/linux/malloc-sysdep.h +++ b/sysdeps/unix/sysv/linux/malloc-sysdep.h @@ -47,7 +47,7 @@ check_may_shrink_heap (void) if (fd >= 0) { char val; - ssize_t n = read_not_cancel (fd, &val, 1); + ssize_t n = __read_nocancel (fd, &val, 1); may_shrink_heap = n > 0 && val == '2'; close_not_cancel_no_status (fd); } diff --git a/sysdeps/unix/sysv/linux/not-cancel.h b/sysdeps/unix/sysv/linux/not-cancel.h index 8d897f0..3d26075 100644 --- a/sysdeps/unix/sysv/linux/not-cancel.h +++ b/sysdeps/unix/sysv/linux/not-cancel.h @@ -34,9 +34,9 @@ libc_hidden_proto (__open_nocancel) __typeof (open64) __open64_nocancel; libc_hidden_proto (__open64_nocancel) -/* Uncancelable read. */ -#define __read_nocancel(fd, buf, len) \ - INLINE_SYSCALL (read, 3, fd, buf, len) +/* Non cancellable read syscall. */ +__typeof (__read) __read_nocancel; +libc_hidden_proto (__read_nocancel) /* Uncancelable write. */ #define __write_nocancel(fd, buf, len) \ @@ -61,10 +61,6 @@ libc_hidden_proto (__open64_nocancel) (void) ({ INTERNAL_SYSCALL_DECL (err); \ INTERNAL_SYSCALL (close, err, 1, (fd)); }) -/* Uncancelable read. */ -#define read_not_cancel(fd, buf, n) \ - __read_nocancel (fd, buf, n) - /* Uncancelable write. */ #define write_not_cancel(fd, buf, n) \ __write_nocancel (fd, buf, n) diff --git a/sysdeps/unix/sysv/linux/pthread_getname.c b/sysdeps/unix/sysv/linux/pthread_getname.c index caab2cc..93c1dfd 100644 --- a/sysdeps/unix/sysv/linux/pthread_getname.c +++ b/sysdeps/unix/sysv/linux/pthread_getname.c @@ -50,7 +50,7 @@ pthread_getname_np (pthread_t th, char *buf, size_t len) return errno; int res = 0; - ssize_t n = TEMP_FAILURE_RETRY (read_not_cancel (fd, buf, len)); + ssize_t n = TEMP_FAILURE_RETRY (__read_nocancel (fd, buf, len)); if (n < 0) res = errno; else diff --git a/sysdeps/unix/sysv/linux/read.c b/sysdeps/unix/sysv/linux/read.c index 2a02c1b..e519474 100644 --- a/sysdeps/unix/sysv/linux/read.c +++ b/sysdeps/unix/sysv/linux/read.c @@ -18,6 +18,7 @@ #include #include +#include /* Read NBYTES into BUF from FD. Return the number read or -1. */ ssize_t @@ -31,3 +32,10 @@ libc_hidden_def (__read) weak_alias (__libc_read, __read) libc_hidden_def (read) weak_alias (__libc_read, read) + +ssize_t +__read_nocancel (int fd, void *buf, size_t nbytes) +{ + return INLINE_SYSCALL_CALL (read, fd, buf, nbytes); +} +libc_hidden_def (__read_nocancel) diff --git a/sysdeps/unix/sysv/linux/sysconf.c b/sysdeps/unix/sysv/linux/sysconf.c index ab068ab..f9becfb 100644 --- a/sysdeps/unix/sysv/linux/sysconf.c +++ b/sysdeps/unix/sysv/linux/sysconf.c @@ -121,7 +121,7 @@ __sysconf (int name) /* This is more than enough, the file contains a single integer. */ char buf[32]; ssize_t n; - n = TEMP_FAILURE_RETRY (read_not_cancel (fd, buf, sizeof (buf) - 1)); + n = TEMP_FAILURE_RETRY (__read_nocancel (fd, buf, sizeof (buf) - 1)); close_not_cancel_no_status (fd); if (n > 0) From patchwork Tue Jul 4 19:53:43 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 107012 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp1361048qge; Tue, 4 Jul 2017 12:54:32 -0700 (PDT) X-Received: by 10.99.120.132 with SMTP id t126mr17463447pgc.276.1499198072582; Tue, 04 Jul 2017 12:54:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499198072; cv=none; d=google.com; s=arc-20160816; b=J7MPjiCyHON9y1AhJLkROZH/WAv8NRQUA57Lg4WjMKgvQJvsIL695mUQVLJEye2MN1 BZLHgErpJOzg+DQG65Izl258e1olr1/rHZgP5OROVW7kw5rzpWmTFj8mEFs8BpCnXKY1 zVie1n/V8Yt+TRdQB95rkN9UlM5IquLPL4Ad0/YHAe8/W72xFWRcTiRFIBVJT5xGlKMq 4/ywx++4ta2RxTWAhDPh5qtchiKOUMrFh9WUCGf+oafEdDgpYZoncoiPEu+xePE8Y2cs KiEv8l9kmoH5euuaQ6Rkeut/YxEpclYAa1/ba9oYbPnKhK55gGSCkek2YSHf6xtkz3xP Gn3g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:to:from:delivered-to :sender:list-help:list-post:list-archive:list-subscribe :list-unsubscribe:list-id:precedence:mailing-list:dkim-signature :domainkey-signature:arc-authentication-results; bh=Onw9rW+Xab24Ot9V8gGJExejpV9ThaT42cj+GgHKhOg=; b=JctCVVLO2T2pA3LIPVKrIwvYDeMmejWvLHHAbUMcVV9gaaJ6L3Dn1EqpZ+iLrnwFg2 22t/Rj4kN1Xlv1zdWOpZurIxxAD7aqOCwDARD+jMtSg6vQL8pOkTONGTnOJZ+DStYwRt QkiyKf27IdnNVjROwsP6nj6PfqUlNYKTjeCpyXwF1sXVLje1Y+XTrr5jTatjXZviWrRt ToA+dPb8/pNvmAJ4LPiuBqPCjB3bFlSjqMVmsAABmp5NpaRFbtuGCeZ0llDW+NmmH4mr v/4YOzkyV/T0UuD+sNa6l/MDL4BlbUYVUxpUCXb3/AvMU+2Xnd52gp6tMTzD/fhu1yp0 ibxQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.b=Nqpntseu; spf=pass (google.com: domain of libc-alpha-return-81662-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-81662-patch=linaro.org@sourceware.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id r59si16082086plb.75.2017.07.04.12.54.32 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 04 Jul 2017 12:54:32 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-return-81662-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.b=Nqpntseu; spf=pass (google.com: domain of libc-alpha-return-81662-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-81662-patch=linaro.org@sourceware.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=DNpEIjXd0ceVlsXtBBAafOfb3XFR07k HQL5h4s0OTyFeMe2XFy0qWApl1Vrzeo9L6zQhguZVKkF+4pAhx7JH/L3rV886Fy/ JCB+FpMqJpAcrLCe8oGlG4W4eRtoYVtZ5CUBUARQuioPNBCUl98ABLGBCOXWswkB F3ZGYUotolw0= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; s=default; bh=6+domb03oT26SWxXc6DxTEwldC0=; b=Nqpnt seudDLmPjICEltbR1+FcaPJTb3TPOMbMDiGZ+ArxedcvXYuWqKx9OJDm0zprm4Zf 0VjroKgzSrYhOeXDKeB9KSwCq3fOW3DRfj7sNzGqeQu7MwuRNLLvOXbpOoOxM+tr chYmRLHMKtrdyYuVYbLQZwoDcOjZcIgWcsCY9c= Received: (qmail 73262 invoked by alias); 4 Jul 2017 19:54:11 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 73207 invoked by uid 89); 4 Jul 2017 19:54:10 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.4 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy=1995 X-HELO: mail-qk0-f173.google.com 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:in-reply-to :references; bh=Onw9rW+Xab24Ot9V8gGJExejpV9ThaT42cj+GgHKhOg=; b=Q+9iGLmbEmrd/SGX6cByMNIvgl6xRl+VMUMlCFkV1RWKPABzi+B1mfywKLtCON954n 9SgENZv6Fsl5KxASVsrWpqZS6B/JkbD8eCMnDUDq8IfeJp8q2moEf9q8bc0UaZ4jpaS6 1XSreH+XIBbzD7UyloQTq7M0jULtZ2zEc4AKwrhwkG0C66uTN1EcVf234ts55cIENT0m 8JCLvUYIuI1Klc58iMpu7JzD6kakH7YBneD5dXQKNOZJis3sycEozpPSFN29/CJKXMDm XrSLA/llH0zLTBjMUmzO5yvmqXhLqQ6G0XXYOrYWwo1PNByfASoeFmPDapiXSz2y4JBH q1eA== X-Gm-Message-State: AKS2vOx2Ay3zN1Vpapap9gj17aefOyiqFWdAfajWwgfdUAJqAwfGlCCD 0nQAjfElUVkjDN8saFgyNg== X-Received: by 10.55.146.133 with SMTP id u127mr50826986qkd.17.1499198046422; Tue, 04 Jul 2017 12:54:06 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH 03/14] Consolidate non cancellable write call Date: Tue, 4 Jul 2017 16:53:43 -0300 Message-Id: <1499198034-5837-4-git-send-email-adhemerval.zanella@linaro.org> In-Reply-To: <1499198034-5837-1-git-send-email-adhemerval.zanella@linaro.org> References: <1499198034-5837-1-git-send-email-adhemerval.zanella@linaro.org> This patch consolidates all the non cancellable write calls to use the __write_nocancel identifier. For non cancellable targets it will be just a macro to call the default respective symbol while on Linux will be a internal one. Checked on x86_64-linux-gnu, x86_64-linux-gnu-x32, and i686-linux-gnu. * sysdeps/generic/not-cancel.h (write_not_cancel): Remove macro. (__write_nocancel): New macro. * sysdeps/unix/sysv/linux/not-cancel.h (__write_nocancel): Rewrite as a function prototype. (write_not_cancel): Remove macro. * sysdeps/unix/sysv/linux/write.c (__write_nocancel): New function. * gmon/gmon.c (ERR): Replace write_not_cancel with __write_nocancel. (write_gmon): Likewise. * libio/fileops.c (_IO_new_file_write): Likewise. * login/utmp_file.c (pututline_file): Likewise. (updwtmp_file): Likewise. * stdio-common/psiginfo.c (psiginfo): Likewise. * sysdeps/posix/spawni.c (__spawni_child): Likewise. * sysdeps/unix/sysv/linux/gethostid.c (sethostid): Likewise. * sysdeps/unix/sysv/linux/libc_fatal.c (backtrace_and_maps): Likewise. * sysdeps/unix/sysv/linux/pthread_setname.c (pthread_setname_np): Likewise. --- ChangeLog | 19 +++++++++++++++++++ gmon/gmon.c | 4 ++-- libio/fileops.c | 2 +- login/utmp_file.c | 4 ++-- stdio-common/psiginfo.c | 2 +- sysdeps/generic/not-cancel.h | 2 +- sysdeps/posix/spawni.c | 2 +- sysdeps/unix/sysv/linux/gethostid.c | 2 +- sysdeps/unix/sysv/linux/libc_fatal.c | 4 ++-- sysdeps/unix/sysv/linux/not-cancel.h | 8 ++------ sysdeps/unix/sysv/linux/pthread_setname.c | 2 +- sysdeps/unix/sysv/linux/write.c | 8 ++++++++ 12 files changed, 41 insertions(+), 18 deletions(-) -- 2.7.4 diff --git a/gmon/gmon.c b/gmon/gmon.c index 87c3c4e..e7701b9 100644 --- a/gmon/gmon.c +++ b/gmon/gmon.c @@ -58,7 +58,7 @@ struct gmonparam _gmonparam attribute_hidden = { GMON_PROF_OFF }; static int s_scale; #define SCALE_1_TO_1 0x10000L -#define ERR(s) write_not_cancel (STDERR_FILENO, s, sizeof (s) - 1) +#define ERR(s) __write_nocancel (STDERR_FILENO, s, sizeof (s) - 1) void moncontrol (int mode); void __moncontrol (int mode); @@ -375,7 +375,7 @@ write_gmon (void) memcpy (&ghdr.cookie[0], GMON_MAGIC, sizeof (ghdr.cookie)); ghdr.version = GMON_VERSION; memset (ghdr.spare, '\0', sizeof (ghdr.spare)); - write_not_cancel (fd, &ghdr, sizeof (struct gmon_hdr)); + __write_nocancel (fd, &ghdr, sizeof (struct gmon_hdr)); /* write PC histogram: */ write_hist (fd); diff --git a/libio/fileops.c b/libio/fileops.c index 80bd3f5..f025178 100644 --- a/libio/fileops.c +++ b/libio/fileops.c @@ -1251,7 +1251,7 @@ _IO_new_file_write (_IO_FILE *f, const void *data, _IO_ssize_t n) { _IO_ssize_t count = (__builtin_expect (f->_flags2 & _IO_FLAGS2_NOTCANCEL, 0) - ? write_not_cancel (f->_fileno, data, to_do) + ? __write_nocancel (f->_fileno, data, to_do) : write (f->_fileno, data, to_do)); if (count < 0) { diff --git a/login/utmp_file.c b/login/utmp_file.c index 61d03d6..26e3f4b 100644 --- a/login/utmp_file.c +++ b/login/utmp_file.c @@ -444,7 +444,7 @@ pututline_file (const struct utmp *data) } /* Write the new data. */ - if (write_not_cancel (file_fd, data, sizeof (struct utmp)) + if (__write_nocancel (file_fd, data, sizeof (struct utmp)) != sizeof (struct utmp)) { /* If we appended a new record this is only partially written. @@ -505,7 +505,7 @@ updwtmp_file (const char *file, const struct utmp *utmp) /* Write the entry. If we can't write all the bytes, reset the file size back to the original size. That way, no partial entries will remain. */ - if (write_not_cancel (fd, utmp, sizeof (struct utmp)) + if (__write_nocancel (fd, utmp, sizeof (struct utmp)) != sizeof (struct utmp)) { __ftruncate64 (fd, offset); diff --git a/stdio-common/psiginfo.c b/stdio-common/psiginfo.c index 6954a42..7bf2e2d 100644 --- a/stdio-common/psiginfo.c +++ b/stdio-common/psiginfo.c @@ -199,5 +199,5 @@ Signal generated by the completion of an I/O request"); fclose (fp); - write_not_cancel (STDERR_FILENO, buf, strlen (buf)); + __write_nocancel (STDERR_FILENO, buf, strlen (buf)); } diff --git a/sysdeps/generic/not-cancel.h b/sysdeps/generic/not-cancel.h index 4fada2f..e91cb6c 100644 --- a/sysdeps/generic/not-cancel.h +++ b/sysdeps/generic/not-cancel.h @@ -36,7 +36,7 @@ (void) __close (fd) #define __read_nocancel(fd, buf, n) \ __read (fd, buf, n) -#define write_not_cancel(fd, buf, n) \ +#define __write_nocancel(fd, buf, n) \ __write (fd, buf, n) #define writev_not_cancel_no_status(fd, iov, n) \ (void) __writev (fd, iov, n) diff --git a/sysdeps/posix/spawni.c b/sysdeps/posix/spawni.c index aaca6e2..7617279 100644 --- a/sysdeps/posix/spawni.c +++ b/sysdeps/posix/spawni.c @@ -234,7 +234,7 @@ fail: /* Since sizeof errno < PIPE_BUF, the write is atomic. */ ret = -ret; if (ret) - while (write_not_cancel (args->pipe[1], &ret, sizeof (ret)) < 0); + while (__write_nocancel (args->pipe[1], &ret, sizeof (ret)) < 0); _exit (SPAWN_ERROR); } diff --git a/sysdeps/unix/sysv/linux/gethostid.c b/sysdeps/unix/sysv/linux/gethostid.c index 6e19dee..11c7e73 100644 --- a/sysdeps/unix/sysv/linux/gethostid.c +++ b/sysdeps/unix/sysv/linux/gethostid.c @@ -51,7 +51,7 @@ sethostid (long int id) if (fd < 0) return -1; - written = write_not_cancel (fd, &id32, sizeof (id32)); + written = __write_nocancel (fd, &id32, sizeof (id32)); close_not_cancel_no_status (fd); diff --git a/sysdeps/unix/sysv/linux/libc_fatal.c b/sysdeps/unix/sysv/linux/libc_fatal.c index ca838a7..c7c6a07 100644 --- a/sysdeps/unix/sysv/linux/libc_fatal.c +++ b/sysdeps/unix/sysv/linux/libc_fatal.c @@ -48,7 +48,7 @@ backtrace_and_maps (int do_abort, bool written, int fd) if (n > 2) { #define strnsize(str) str, strlen (str) -#define writestr(str) write_not_cancel (fd, str) +#define writestr(str) __write_nocancel (fd, str) writestr (strnsize ("======= Backtrace: =========\n")); __backtrace_symbols_fd (addrs + 1, n - 1, fd); @@ -57,7 +57,7 @@ backtrace_and_maps (int do_abort, bool written, int fd) char buf[1024]; ssize_t n2; while ((n2 = __read_nocancel (fd2, buf, sizeof (buf))) > 0) - if (write_not_cancel (fd, buf, n2) != n2) + if (__write_nocancel (fd, buf, n2) != n2) break; close_not_cancel_no_status (fd2); } diff --git a/sysdeps/unix/sysv/linux/not-cancel.h b/sysdeps/unix/sysv/linux/not-cancel.h index 3d26075..84dc72a 100644 --- a/sysdeps/unix/sysv/linux/not-cancel.h +++ b/sysdeps/unix/sysv/linux/not-cancel.h @@ -39,8 +39,8 @@ __typeof (__read) __read_nocancel; libc_hidden_proto (__read_nocancel) /* Uncancelable write. */ -#define __write_nocancel(fd, buf, len) \ - INLINE_SYSCALL (write, 3, fd, buf, len) +__typeof (__write) __write_nocancel; +libc_hidden_proto (__write_nocancel) /* Uncancelable openat. */ #define openat_not_cancel(fd, fname, oflag, mode) \ @@ -61,10 +61,6 @@ libc_hidden_proto (__read_nocancel) (void) ({ INTERNAL_SYSCALL_DECL (err); \ INTERNAL_SYSCALL (close, err, 1, (fd)); }) -/* Uncancelable write. */ -#define write_not_cancel(fd, buf, n) \ - __write_nocancel (fd, buf, n) - /* Uncancelable writev. */ #define writev_not_cancel_no_status(fd, iov, n) \ (void) ({ INTERNAL_SYSCALL_DECL (err); \ diff --git a/sysdeps/unix/sysv/linux/pthread_setname.c b/sysdeps/unix/sysv/linux/pthread_setname.c index 93f0e9d..c5e9a33 100644 --- a/sysdeps/unix/sysv/linux/pthread_setname.c +++ b/sysdeps/unix/sysv/linux/pthread_setname.c @@ -51,7 +51,7 @@ pthread_setname_np (pthread_t th, const char *name) return errno; int res = 0; - ssize_t n = TEMP_FAILURE_RETRY (write_not_cancel (fd, name, name_len)); + ssize_t n = TEMP_FAILURE_RETRY (__write_nocancel (fd, name, name_len)); if (n < 0) res = errno; else if (n != name_len) diff --git a/sysdeps/unix/sysv/linux/write.c b/sysdeps/unix/sysv/linux/write.c index d495145..bf12ca5 100644 --- a/sysdeps/unix/sysv/linux/write.c +++ b/sysdeps/unix/sysv/linux/write.c @@ -18,6 +18,7 @@ #include #include +#include /* Write NBYTES of BUF to FD. Return the number written, or -1. */ ssize_t @@ -31,3 +32,10 @@ weak_alias (__libc_write, __write) libc_hidden_weak (__write) weak_alias (__libc_write, write) libc_hidden_weak (write) + +ssize_t +__write_nocancel (int fd, const void *buf, size_t nbytes) +{ + return INLINE_SYSCALL_CALL (write, fd, buf, nbytes); +} +libc_hidden_def (__write_nocancel) From patchwork Tue Jul 4 19:53:44 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 107013 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp1361174qge; Tue, 4 Jul 2017 12:54:45 -0700 (PDT) X-Received: by 10.98.135.140 with SMTP id i134mr16548778pfe.237.1499198085061; Tue, 04 Jul 2017 12:54:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499198085; cv=none; d=google.com; s=arc-20160816; b=Y+d23qKS3bBYOuLkOpR6ZNUqIZN5Y+tFqIaHKI8aCjzS60oTZlQfekPTadICFvSE5I PvCcSbo1pkyKGl9p7CZGqdd2qccKPEkgBhRrPYj5XTencN0o5JUYmZsMtqRSHK9ra9B4 idsNJ2FHReTlzjmT57cIxwN5lX6uiJOaU5gfvsJrxSkwE/pG+3SjYzdg1imvxIEtUD5C OjDR7khh1IsORpzLMZxU4H5OwDNi7ygMiMz0tz7nj6PESB0DiV6anPYMGE8HCywRYCt6 qlt6ydKNYLF5RwLduHOEAGWfrmeOqmodsV0ZR158ZL6PGuXgWCCnzaPpXCm5VLZakE4B yHAA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:to:from:delivered-to :sender:list-help:list-post:list-archive:list-subscribe :list-unsubscribe:list-id:precedence:mailing-list:dkim-signature :domainkey-signature:arc-authentication-results; bh=MNDYV8eYj5bC/Z9BO3lUmRbU/VJEOPN13aHerBf1P8A=; b=i4kSb0z0U70laX7OcnMkQtW44/5JDFB1qrNzPMUJ9lZ61RHXWyCoBvwQBENyjETh/w pduN/qGX7I2Kq5ITKICOUwNNB4TvmYObx+pkvMfPRf3jCo5PKPp8rz5Pl8NaDbYVDCKC HMquVf9pfcBjmRrVHXfarbhl5Af4oxZKziyVqcUFOLSkXQGZR8op44kcXbs5QYZEmuaL CkEI97PYzn29+jSJqVehtTFcuRG/JHPoKexBJTpaxzM7aNeBDL73gYTT2Q8DRWnJzszx wh9gxHDdKWGzrdW8X/hyOwsyDoe3hRAer21pWc/Djwe9iinyHqoypf4esUV3eUyVY8yG +VWQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.b=ipucqwrq; spf=pass (google.com: domain of libc-alpha-return-81663-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-81663-patch=linaro.org@sourceware.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id e11si15480525pgp.217.2017.07.04.12.54.44 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 04 Jul 2017 12:54:45 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-return-81663-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.b=ipucqwrq; spf=pass (google.com: domain of libc-alpha-return-81663-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-81663-patch=linaro.org@sourceware.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=g69IlSxWi9H/JAKMRu+t8znKwh4hkb1 VcQ3+9MfvMejR4pAZoK8vSBWniBzwlno3OzYYZ1BlMx/+sWQYD51fIh6142FqcEM QzokbV917J/5hdK5FPxBrgEX8aRj17d/dFpT8k1w/CwEuqfRKjFTDM2lC9A+wPq/ cmorW3K8dt6c= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; s=default; bh=KJMzgB9OMdPkuKD3g9gXYQlbvPE=; b=ipucq wrqNBLyoLDJMnNm5ls4ZeYCPr29UslowxDVuLcuka+oLz/AZXxPMLdfdyvkIYiP6 eRFZKemHnSV+1HX3fzvOu6TKWNRku0Kdze/hUC27fHtvl3kjxvKMzRG+mamFWxFm zddGE5HuwZf4QqYBt25t+DpBiFIgRMJY6e17Vg= Received: (qmail 73826 invoked by alias); 4 Jul 2017 19:54:16 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 73427 invoked by uid 89); 4 Jul 2017 19:54:12 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.4 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy=Non X-HELO: mail-qk0-f172.google.com 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:in-reply-to :references; bh=MNDYV8eYj5bC/Z9BO3lUmRbU/VJEOPN13aHerBf1P8A=; b=uHM+u3DbINDwAh8E8+GWyKGkjPhUZsJ00tTrQLHRbbt84CyxFm7aTpyMfcRq5mGBhn TeYgknJwQVJUbftnDXeCJqL2h37ydRDwN70gBtUvatKt6Ptm4mABTgX+PRK+2iqEs0mQ tRaLB7FRhWX8BFQQznIXSh1NLog8xRHNw6wuuO8Ws2M7k99BCKw2I72J34jJgvm328sq XXdOJ0juoy6G6Ghk6dVvk5tfgSkJPEe0FChl7ZwmQVsT/4AEBjbbLrl2TnvMQ72RIGji Jr+XPMotfHX3ZQs9QL6dXpl9DA7y+5fb14UPs4Qw2Nngs9EYYe5Ab3veUhFFyGd931CW 2b+w== X-Gm-Message-State: AKS2vOz0CRRhXvbEQ6hBgkIiCDBgW2zllFWq2bQN9IAkCecZxKfDbhev 6cYFI/fA3gPSs/sF7ML7fw== X-Received: by 10.55.168.17 with SMTP id r17mr50953898qke.146.1499198047765; Tue, 04 Jul 2017 12:54:07 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH 04/14] Consolidate non cancellable openat call Date: Tue, 4 Jul 2017 16:53:44 -0300 Message-Id: <1499198034-5837-5-git-send-email-adhemerval.zanella@linaro.org> In-Reply-To: <1499198034-5837-1-git-send-email-adhemerval.zanella@linaro.org> References: <1499198034-5837-1-git-send-email-adhemerval.zanella@linaro.org> This patch consolidates all the non cancellable openat{64} calls to use the __openat{64}_nocancel identifier. For non cancellable targets it will be just a macro to call the default respective symbol while on Linux will be a internal one. Checked on x86_64-linux-gnu, x86_64-linux-gnu-x32, and i686-linux-gnu. * sysdeps/generic/not-cancel.h (openat_not_cancel): Remove macro. (openat_not_cancel_3): Likewise. (openat64_not_cancel_3): Likewise). (openat_not_cancel_3): Likewise). * sysdeps/unix/sysv/linux/not-cancel.h (openat_not_cancel): Remove macro. (openat_not_cancel_3): Likewise. (openat64_not_cancel): Likewise. (openat64_not_cancel_3): Likewise. * sysdeps/unix/sysv/linux/openat.c (__openat_nocancel): New function. * sysdeps/unix/sysv/linux/openat64.c (__openat64_nocancel): Likewise. * io/ftw.c (open_dir_stream): Replace openat{64}_not_cancel{_3} with __open{64}_nocancel. * sysdeps/mach/hurd/opendir.c (__opendirat): Likewise. * sysdeps/posix/getcwd.c (__getcwd): Likewise. * sysdeps/posix/opendir.c (__opendirat): Likewise. --- ChangeLog | 17 +++++++++++++++++ io/ftw.c | 4 ++-- sysdeps/generic/not-cancel.h | 12 ++++-------- sysdeps/mach/hurd/opendir.c | 2 +- sysdeps/posix/getcwd.c | 4 ++-- sysdeps/posix/opendir.c | 2 +- sysdeps/unix/sysv/linux/not-cancel.h | 18 ++++++++---------- sysdeps/unix/sysv/linux/openat.c | 16 ++++++++++++++++ sysdeps/unix/sysv/linux/openat64.c | 32 ++++++++++++++++++++++++++------ 9 files changed, 77 insertions(+), 30 deletions(-) -- 2.7.4 diff --git a/io/ftw.c b/io/ftw.c index 140a237..f33fed3 100644 --- a/io/ftw.c +++ b/io/ftw.c @@ -337,8 +337,8 @@ open_dir_stream (int *dfdp, struct ftw_data *data, struct dir_data *dirp) if (dfdp != NULL && *dfdp != -1) { - int fd = openat64_not_cancel_3 (*dfdp, data->dirbuf + data->ftw.base, - O_RDONLY | O_DIRECTORY | O_NDELAY); + int fd = __openat64_nocancel (*dfdp, data->dirbuf + data->ftw.base, + O_RDONLY | O_DIRECTORY | O_NDELAY); dirp->stream = NULL; if (fd != -1 && (dirp->stream = __fdopendir (fd)) == NULL) close_not_cancel_no_status (fd); diff --git a/sysdeps/generic/not-cancel.h b/sysdeps/generic/not-cancel.h index e91cb6c..df9aea6 100644 --- a/sysdeps/generic/not-cancel.h +++ b/sysdeps/generic/not-cancel.h @@ -22,14 +22,10 @@ __open (__VA_ARGS__) #define __open64_nocancel(...) \ __open64 (__VA_ARGS__) -#define openat_not_cancel(fd, name, flags, mode) \ - __openat (fd, name, flags, mode) -#define openat_not_cancel_3(fd, name, flags) \ - __openat (fd, name, flags, 0) -#define openat64_not_cancel(fd, name, flags, mode) \ - __openat64 (fd, name, flags, mode) -#define openat64_not_cancel_3(fd, name, flags) \ - __openat64 (fd, name, flags, 0) +#define __openat_nocancel(...) \ + __openat (__VA_ARGS__) +#define __openat64_nocancel(...) \ + __openat64 (__VA_ARGS__) #define close_not_cancel(fd) \ __close (fd) #define close_not_cancel_no_status(fd) \ diff --git a/sysdeps/mach/hurd/opendir.c b/sysdeps/mach/hurd/opendir.c index 8db70b2..d3757f0 100644 --- a/sysdeps/mach/hurd/opendir.c +++ b/sysdeps/mach/hurd/opendir.c @@ -86,7 +86,7 @@ __opendirat (int dfd, const char *name) assert (dfd == AT_FDCWD); fd = __open_nocancel (name, flags); #else - fd = openat_not_cancel_3 (dfd, name, flags); + fd = __openat_nocancel (dfd, name, flags); #endif if (fd < 0) return NULL; diff --git a/sysdeps/posix/getcwd.c b/sysdeps/posix/getcwd.c index eb1706a..ecae628 100644 --- a/sysdeps/posix/getcwd.c +++ b/sysdeps/posix/getcwd.c @@ -175,7 +175,7 @@ extern char *alloca (); # include # include #else -# define openat64_not_cancel_3(dfd, name, mode) openat64 (dfd, name, mode) +# define __openat64_nocancel(dfd, name, mode) openat64 (dfd, name, mode) # define close_not_cancel_no_status(fd) close (fd) #endif @@ -281,7 +281,7 @@ __getcwd (char *buf, size_t size) while (!(thisdev == rootdev && thisino == rootino)) { if (__have_atfcts >= 0) - fd = openat64_not_cancel_3 (fd, "..", O_RDONLY | O_CLOEXEC); + fd = __openat64_nocancel (fd, "..", O_RDONLY | O_CLOEXEC); else fd = -1; if (fd >= 0) diff --git a/sysdeps/posix/opendir.c b/sysdeps/posix/opendir.c index 3ee27b2..51a92e8 100644 --- a/sysdeps/posix/opendir.c +++ b/sysdeps/posix/opendir.c @@ -161,7 +161,7 @@ __opendirat (int dfd, const char *name) } } - return opendir_tail (openat_not_cancel_3 (dfd, name, opendir_oflags)); + return opendir_tail (__openat_nocancel (dfd, name, opendir_oflags)); } #endif diff --git a/sysdeps/unix/sysv/linux/not-cancel.h b/sysdeps/unix/sysv/linux/not-cancel.h index 84dc72a..08ad773 100644 --- a/sysdeps/unix/sysv/linux/not-cancel.h +++ b/sysdeps/unix/sysv/linux/not-cancel.h @@ -34,6 +34,14 @@ libc_hidden_proto (__open_nocancel) __typeof (open64) __open64_nocancel; libc_hidden_proto (__open64_nocancel) +/* Non cancellable openat syscall. */ +__typeof (openat) __openat_nocancel; +libc_hidden_proto (__openat_nocancel) + +/* Non cacellable openat syscall (LFS version). */ +__typeof (openat64) __openat64_nocancel; +libc_hidden_proto (__openat64_nocancel) + /* Non cancellable read syscall. */ __typeof (__read) __read_nocancel; libc_hidden_proto (__read_nocancel) @@ -42,16 +50,6 @@ libc_hidden_proto (__read_nocancel) __typeof (__write) __write_nocancel; libc_hidden_proto (__write_nocancel) -/* Uncancelable openat. */ -#define openat_not_cancel(fd, fname, oflag, mode) \ - INLINE_SYSCALL (openat, 4, fd, fname, oflag, mode) -#define openat_not_cancel_3(fd, fname, oflag) \ - INLINE_SYSCALL (openat, 3, fd, fname, oflag) -#define openat64_not_cancel(fd, fname, oflag, mode) \ - INLINE_SYSCALL (openat, 4, fd, fname, oflag | O_LARGEFILE, mode) -#define openat64_not_cancel_3(fd, fname, oflag) \ - INLINE_SYSCALL (openat, 3, fd, fname, oflag | O_LARGEFILE) - /* Uncancelable close. */ #define __close_nocancel(fd) \ INLINE_SYSCALL (close, 1, fd) diff --git a/sysdeps/unix/sysv/linux/openat.c b/sysdeps/unix/sysv/linux/openat.c index 1587305..3057301 100644 --- a/sysdeps/unix/sysv/linux/openat.c +++ b/sysdeps/unix/sysv/linux/openat.c @@ -19,6 +19,7 @@ #include #include +#include #ifndef __OFF_T_MATCHES_OFF64_T @@ -43,4 +44,19 @@ weak_alias (__libc_openat, __openat) libc_hidden_weak (__openat) weak_alias (__libc_openat, openat) +int +__openat_nocancel (int fd, const char *file, int oflag, ...) +{ + mode_t mode = 0; + if (__OPEN_NEEDS_MODE (oflag)) + { + va_list arg; + va_start (arg, oflag); + mode = va_arg (arg, mode_t); + va_end (arg); + } + + return SYSCALL_CANCEL (openat, fd, file, oflag, mode); +} +libc_hidden_weak (__openat_nocancel) #endif diff --git a/sysdeps/unix/sysv/linux/openat64.c b/sysdeps/unix/sysv/linux/openat64.c index 4942061..3c1cdf8 100644 --- a/sysdeps/unix/sysv/linux/openat64.c +++ b/sysdeps/unix/sysv/linux/openat64.c @@ -19,6 +19,13 @@ #include #include +#include + +#ifdef __OFF_T_MATCHES_OFF64_T +# define EXTRA_OPEN_FLAGS 0 +#else +# define EXTRA_OPEN_FLAGS O_LARGEFILE +#endif /* Open FILE with access OFLAG. Interpret relative paths relative to the directory associated with FD. If OFLAG includes O_CREAT or @@ -35,12 +42,6 @@ __libc_openat64 (int fd, const char *file, int oflag, ...) va_end (arg); } -#ifdef __OFF_T_MATCHES_OFF64_T -# define EXTRA_OPEN_FLAGS 0 -#else -# define EXTRA_OPEN_FLAGS O_LARGEFILE -#endif - return SYSCALL_CANCEL (openat, fd, file, oflag | EXTRA_OPEN_FLAGS, mode); } @@ -48,8 +49,27 @@ strong_alias (__libc_openat64, __openat64) libc_hidden_weak (__openat64) weak_alias (__libc_openat64, openat64) +int +__openat64_nocancel (int fd, const char *file, int oflag, ...) +{ + mode_t mode = 0; + if (__OPEN_NEEDS_MODE (oflag)) + { + va_list arg; + va_start (arg, oflag); + mode = va_arg (arg, mode_t); + va_end (arg); + } + + return INLINE_SYSCALL_CALL (openat, fd, file, oflag | EXTRA_OPEN_FLAGS, + mode); +} +libc_hidden_def (__openat64_nocancel) + #ifdef __OFF_T_MATCHES_OFF64_T strong_alias (__libc_openat64, __openat) libc_hidden_weak (__openat) weak_alias (__libc_openat64, openat) + +strong_alias (__openat64_nocancel, __openat_nocancel) #endif From patchwork Tue Jul 4 19:53:45 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 107021 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp1361927qge; Tue, 4 Jul 2017 12:56:00 -0700 (PDT) X-Received: by 10.99.151.1 with SMTP id n1mr17629576pge.166.1499198160058; Tue, 04 Jul 2017 12:56:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499198160; cv=none; d=google.com; s=arc-20160816; b=o9BDvQCttHL5GK+6hKVtonMNkY6+6C9xgHqxnUeF+RaPh3VOKjZw6CYd1bgdZcb+Tz I+2HP1GonzY9LMarEgv1Z4cICl9QZUPSfqqdASNKZ8UKHKacQUOXt4uskQk6VKZtu5Yg tdV6iD5URV/YCAyQN3sg87i/MCwNBOvyUWTH3NAVNU+/Qf2VDgHx/NkP4Ss17rh8OjRi iH64FPfJh4RVDfCWygKpotZCO8Iz7ty4uIec8Od8RdAa8+cR1yFtOP22HVYKuPuLsxIf mFrvjNrueqpjsXHTkpEgq5sQVT4OaVJF9x2WOARfcyv2YW9BsHD9fSPLYNohgIbJtJht Layg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:to:from:delivered-to :sender:list-help:list-post:list-archive:list-subscribe :list-unsubscribe:list-id:precedence:mailing-list:dkim-signature :domainkey-signature:arc-authentication-results; bh=Hzw+nHl827nBSpSOaxXZix7vi+34u9VJmkiY4dwubZ8=; b=pylQERaWZvEC05vSNwljYFxOHu0QWpZMfWyMbh1r59uIzwmUgyfsW6EO3d/eobH8aF qEIsx4LQcfhiKnWxoTajLM/Dsf/Z8+9dG1isaB4Dh6HkrdFzFeGXmWaySPRSNBzi3gJl Z8fuhiER254DDAQx4hKy7IZwpauv9DGXPzuzwmUxFukkL5loVS2lkdp1ZzlITqhAPnI4 vgEdNrYeYjIyJRoBz651+oadYA7wLvpZt+/hOnO+Jwl5tLi61sSio9L5AeW6tB9H7b85 8noin5p1poVkOPgjRoGjm++bl+S75K2GS3aHPbMQQuDBUUD4XRv5F3ckp0wWn2k3xR+A 72RA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.b=sgjYyTIh; spf=pass (google.com: domain of libc-alpha-return-81670-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-81670-patch=linaro.org@sourceware.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id s64si4230138pfb.158.2017.07.04.12.55.59 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 04 Jul 2017 12:56:00 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-return-81670-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.b=sgjYyTIh; spf=pass (google.com: domain of libc-alpha-return-81670-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-81670-patch=linaro.org@sourceware.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=AgNkHVxhxZ4Pe+VjUvXGPSZZdc9CVyJ Hf+gpUBt+6qHjXheWTOzDoAWCVwTYCsfO8eHyruHYAVHpzWlLeZ3+faejJVVkooz w2N92U3O6RzYbmmJjFMsETCPeWxeoYP0168AUc67b/Aq82hxRF23WgzFTD6S8Dxb xWNg6w0vyHCo= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; s=default; bh=EJcP7UJaHqC54x/qymr4SGeQjNg=; b=sgjYy TIhPMhYevcJDd1fQLwyKuuSU7Rw9+FDkDIvN8Sdr1d+2diSOcIC+UmlR3pONbmek XcEG5f8IMPuyZ1Hru/b1srA9H7/jVV0cwJ+jttaupN5FdziJNLPPQG7U3fXfJ/kB 2ceTDdDseAXfRBE0fNekv9+xGHfAPsuIso0MfY= Received: (qmail 74847 invoked by alias); 4 Jul 2017 19:54:24 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 74112 invoked by uid 89); 4 Jul 2017 19:54:19 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.4 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy=cancelling X-HELO: mail-qk0-f174.google.com 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:in-reply-to :references; bh=Hzw+nHl827nBSpSOaxXZix7vi+34u9VJmkiY4dwubZ8=; b=g3Y7nya5CVB9JM+JX+aH/kxy3uV+cAUUXozpsUMzroLI7RH2ERr5tihNUOIR7P2q6/ /9pYOzYsfy432j+DrSj0sDtKxzbA/n4s2xefXjSAMp6cDyP1roRLaOYTFWJgjbNpp+S6 ykAt5Zyjukx9X30WEdhhIv2wAX/dLzrKDIq4vZdoBMj60+BA3znJ927xREOh0xQ05a/q yRPOEpFR5AGUDD5qGs0anxYLB3Oc2biGdwnfLaHmgAYg58fnM5lpXE9TtnVQpRPXdFex 3IJDDuvyNVH+vOtzy2fnABp1YFPnxt4/jKtqC1AJ3cZZqITjNteaeOKIwFEjSqJ6wwtM RoPg== X-Gm-Message-State: AKS2vOyF40wtyqK2z0LfWHcASOzZ1Wiv1oocUaXLI3RVVOQseC5YRI4y R5gav7A/34iriEESatsqrg== X-Received: by 10.55.33.80 with SMTP id h77mr45670726qkh.86.1499198049297; Tue, 04 Jul 2017 12:54:09 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH 05/14] Consolidate non cancellable close call Date: Tue, 4 Jul 2017 16:53:45 -0300 Message-Id: <1499198034-5837-6-git-send-email-adhemerval.zanella@linaro.org> In-Reply-To: <1499198034-5837-1-git-send-email-adhemerval.zanella@linaro.org> References: <1499198034-5837-1-git-send-email-adhemerval.zanella@linaro.org> This patch consolidates all the non cancellable close calls to use the __close_nocancel{_nostatus} identifier. For non cancellable targets it will be just a macro to call the default respective symbol while on Linux will be a internal one. Checked on x86_64-linux-gnu, x86_64-linux-gnu-x32, and i686-linux-gnu. * sysdeps/generic/not-cancel.h (close_not_cancel): Remove macro. (close_not_cancel_no_status): Likewise. (__close_nocancel): New macro. (__close_nocancel_no_status): Likewise. * sysdeps/unix/sysv/linux/not-cancel.h (__close_nocancel): Remove macro. (close_not_cancel): Likewise. (close_not_cancel_no_status): Likewise. (__close_nocancel): New prototype. (__close_nocancel_no_status): New function. * sysdeps/unix/sysv/linux/close.c (__close_nocancel): New function. * catgets/open_catalog.c (__open_catalog): Replace close_not_cancel{_no_status) with __close_nocancel{_nostatus}. * gmon/gmon.c (write_gmon): Likewise. * iconv/gconv_cache.c (__gconv_load_cache): Likewise. * intl/loadmsgcat.c (close): Likewise. * io/ftw.c (open_dir_stream): Likewise. (ftw_startup): Likewise. * libio/fileops.c (_IO_file_open): Likewise. (_IO_file_close_mmap): Likewise. (_IO_file_close): Likewise. * libio/iopopen.c (_IO_dup2): Likewise. * locale/loadarchive.c (_nl_load_locale_from_archive): Likewise. * locale/loadlocale.c (_nl_load_locale): Likewise. * login/utmp_file.c (pututline_file): Likewise. (endutent_file): Likewise. * misc/daemon.c (daemon): Likewise. * nscd/nscd_getai.c (__nscd_getai): Likewise. * nscd/nscd_getgr_r.c (nscd_getgr_r): Likewise. * nscd/nscd_gethst_r.c (nscd_gethst_r): Likewise. * nscd/nscd_getpw_r.c (nscd_getpw_r): Likewise. * nscd/nscd_getserv_r.c (nscd_getserv_r): Likewise. * nscd/nscd_helper.c (open_socket): Likewise. (__nscd_open_socket): Likewise. * nscd/nscd_initgroups.c (__nscd_getgrouplist): Likewise. * nscd/nscd_netgroup.c (__nscd_setnetgrent): Likewise. (__nscd_innetgr): Likewise. * nss/nss_db/db-open.c (internal_setent): Likewise. * resolv/res-close.c (__res_iclose): Likewise. * sunrpc/pm_getmaps.c (pmap_getmaps): Likewise. * sysdeps/posix/closedir.c (__closedir): Likewise. * sysdeps/posix/getaddrinfo.c (getaddrinfo): Likewise. * sysdeps/posix/getcwd.c (__getcwd): Likewise. * sysdeps/posix/opendir.c (tryopen_o_directory): Likewise. (opendir_tail): Likewise. * sysdeps/posix/spawni.c (__spawni_child): Likewise. * sysdeps/unix/sysv/linux/check_native.c (__check_native): Likewise. * sysdeps/unix/sysv/linux/check_pf.c (__check_pf): Likewise. * sysdeps/unix/sysv/linux/fips-private.h (fips_enabled_p): Likewise. * sysdeps/unix/sysv/linux/gethostid.c (sethostid): Likewise. (gethostid): Likewise. * sysdeps/unix/sysv/linux/getloadavg.c (getloadavg): Likewise. * sysdeps/unix/sysv/linux/getlogin_r.c (__getlogin_r_loginuid): Likewise. * sysdeps/unix/sysv/linux/getsysstats.c (__get_nprocs): Likewise. * sysdeps/unix/sysv/linux/grantpt.c (close_all_fds): Likewise. * sysdeps/unix/sysv/linux/i386/smp.h (is_smp_system): Likewise. * sysdeps/unix/sysv/linux/ia64/has_cpuclock.c (has_cpuclock): Likewise. * sysdeps/unix/sysv/linux/if_index.c (__if_nametoindex): Likewise. * sysdeps/unix/sysv/linux/libc_fatal.c (backtrace_and_maps): Likewise. * sysdeps/unix/sysv/linux/malloc-sysdep.h (check_may_shrink_heap): Likewise. * sysdeps/unix/sysv/linux/mq_notify.c (init_mq_netlink): Likewise. * sysdeps/unix/sysv/linux/pthread_getname.c (pthread_getname_np): Likewise. * sysdeps/unix/sysv/linux/pthread_setname.c (pthread_setname_np): Likewise. * sysdeps/unix/sysv/linux/spawni.c (__spawni_child): Likewise. * sysdeps/unix/sysv/linux/sysconf.c (__sysconf): Likewise. --- ChangeLog | 71 +++++++++++++++++++++++++++++ catgets/open_catalog.c | 2 +- gmon/gmon.c | 2 +- iconv/gconv_cache.c | 4 +- intl/loadmsgcat.c | 2 +- io/ftw.c | 4 +- libio/fileops.c | 6 +-- libio/iopopen.c | 2 +- locale/loadarchive.c | 6 +-- locale/loadlocale.c | 6 +-- login/utmp_file.c | 8 ++-- misc/daemon.c | 4 +- nscd/nscd_getai.c | 2 +- nscd/nscd_getgr_r.c | 2 +- nscd/nscd_gethst_r.c | 2 +- nscd/nscd_getpw_r.c | 2 +- nscd/nscd_getserv_r.c | 2 +- nscd/nscd_helper.c | 4 +- nscd/nscd_initgroups.c | 2 +- nscd/nscd_netgroup.c | 4 +- nss/nss_db/db-open.c | 2 +- resolv/res-close.c | 4 +- sunrpc/pm_getmaps.c | 2 +- sysdeps/generic/not-cancel.h | 4 +- sysdeps/posix/closedir.c | 2 +- sysdeps/posix/getaddrinfo.c | 4 +- sysdeps/posix/getcwd.c | 4 +- sysdeps/posix/opendir.c | 6 +-- sysdeps/posix/spawni.c | 6 +-- sysdeps/unix/sysv/linux/check_native.c | 2 +- sysdeps/unix/sysv/linux/check_pf.c | 2 +- sysdeps/unix/sysv/linux/close.c | 8 ++++ sysdeps/unix/sysv/linux/fips-private.h | 2 +- sysdeps/unix/sysv/linux/gethostid.c | 4 +- sysdeps/unix/sysv/linux/getloadavg.c | 2 +- sysdeps/unix/sysv/linux/getlogin_r.c | 2 +- sysdeps/unix/sysv/linux/getsysstats.c | 6 +-- sysdeps/unix/sysv/linux/grantpt.c | 2 +- sysdeps/unix/sysv/linux/i386/smp.h | 2 +- sysdeps/unix/sysv/linux/ia64/has_cpuclock.c | 2 +- sysdeps/unix/sysv/linux/if_index.c | 6 +-- sysdeps/unix/sysv/linux/libc_fatal.c | 2 +- sysdeps/unix/sysv/linux/malloc-sysdep.h | 2 +- sysdeps/unix/sysv/linux/mq_notify.c | 2 +- sysdeps/unix/sysv/linux/not-cancel.h | 18 +++++--- sysdeps/unix/sysv/linux/pthread_getname.c | 2 +- sysdeps/unix/sysv/linux/pthread_setname.c | 2 +- sysdeps/unix/sysv/linux/spawni.c | 6 +-- sysdeps/unix/sysv/linux/sysconf.c | 2 +- 49 files changed, 165 insertions(+), 82 deletions(-) -- 2.7.4 diff --git a/catgets/open_catalog.c b/catgets/open_catalog.c index d79a6b1..73b7243 100644 --- a/catgets/open_catalog.c +++ b/catgets/open_catalog.c @@ -328,7 +328,7 @@ __open_catalog (const char *cat_name, const char *nlspath, const char *env_var, /* Release the lock again. */ close_unlock_return: - close_not_cancel_no_status (fd); + __close_nocancel_no_status (fd); free (buf); return result; diff --git a/gmon/gmon.c b/gmon/gmon.c index e7701b9..b26c27a 100644 --- a/gmon/gmon.c +++ b/gmon/gmon.c @@ -386,7 +386,7 @@ write_gmon (void) /* write basic-block execution counts: */ write_bb_counts (fd); - close_not_cancel_no_status (fd); + __close_nocancel_no_status (fd); } diff --git a/iconv/gconv_cache.c b/iconv/gconv_cache.c index f1dce29..0ff1c3b 100644 --- a/iconv/gconv_cache.c +++ b/iconv/gconv_cache.c @@ -71,7 +71,7 @@ __gconv_load_cache (void) || (size_t) st.st_size < sizeof (struct gconvcache_header)) { close_and_exit: - close_not_cancel_no_status (fd); + __close_nocancel_no_status (fd); return -1; } @@ -108,7 +108,7 @@ __gconv_load_cache (void) } /* We don't need the file descriptor anymore. */ - close_not_cancel_no_status (fd); + __close_nocancel_no_status (fd); /* Check the consistency. */ header = (struct gconvcache_header *) gconv_cache; diff --git a/intl/loadmsgcat.c b/intl/loadmsgcat.c index 514e38f..745bd53 100644 --- a/intl/loadmsgcat.c +++ b/intl/loadmsgcat.c @@ -446,7 +446,7 @@ because some ISO C functions will require linking with this object file and the name space must not be polluted. */ # define open(name, flags) __open_nocancel (name, flags) -# define close(fd) close_not_cancel_no_status (fd) +# define close(fd) __close_nocancel_no_status (fd) # define read(fd, buf, n) __read_nocancel (fd, buf, n) # define mmap(addr, len, prot, flags, fd, offset) \ __mmap (addr, len, prot, flags, fd, offset) diff --git a/io/ftw.c b/io/ftw.c index f33fed3..4dac3b6 100644 --- a/io/ftw.c +++ b/io/ftw.c @@ -341,7 +341,7 @@ open_dir_stream (int *dfdp, struct ftw_data *data, struct dir_data *dirp) O_RDONLY | O_DIRECTORY | O_NDELAY); dirp->stream = NULL; if (fd != -1 && (dirp->stream = __fdopendir (fd)) == NULL) - close_not_cancel_no_status (fd); + __close_nocancel_no_status (fd); } else { @@ -791,7 +791,7 @@ ftw_startup (const char *dir, int is_nftw, void *func, int descriptors, { int save_err = errno; __fchdir (cwdfd); - close_not_cancel_no_status (cwdfd); + __close_nocancel_no_status (cwdfd); __set_errno (save_err); } else if (cwd != NULL) diff --git a/libio/fileops.c b/libio/fileops.c index f025178..b8b02ba 100644 --- a/libio/fileops.c +++ b/libio/fileops.c @@ -242,7 +242,7 @@ _IO_file_open (_IO_FILE *fp, const char *filename, int posix_mode, int prot, _IO_off64_t new_pos = _IO_SYSSEEK (fp, 0, _IO_seek_end); if (new_pos == _IO_pos_BAD && errno != ESPIPE) { - close_not_cancel (fdesc); + __close_nocancel (fdesc); return NULL; } } @@ -1231,7 +1231,7 @@ _IO_file_close_mmap (_IO_FILE *fp) fp->_IO_buf_base = fp->_IO_buf_end = NULL; /* Cancelling close should be avoided if possible since it leaves an unrecoverable state behind. */ - return close_not_cancel (fp->_fileno); + return __close_nocancel (fp->_fileno); } int @@ -1239,7 +1239,7 @@ _IO_file_close (_IO_FILE *fp) { /* Cancelling close should be avoided if possible since it leaves an unrecoverable state behind. */ - return close_not_cancel (fp->_fileno); + return __close_nocancel (fp->_fileno); } libc_hidden_def (_IO_file_close) diff --git a/libio/iopopen.c b/libio/iopopen.c index b78e7e5..0c20cbb 100644 --- a/libio/iopopen.c +++ b/libio/iopopen.c @@ -76,7 +76,7 @@ extern int _IO_dup2 (int fd, int fd2) __THROW; #ifndef _IO_close #ifdef _LIBC -#define _IO_close close_not_cancel +#define _IO_close __close_nocancel #else #define _IO_close close #endif diff --git a/locale/loadarchive.c b/locale/loadarchive.c index aebb590..86fa584 100644 --- a/locale/loadarchive.c +++ b/locale/loadarchive.c @@ -213,7 +213,7 @@ _nl_load_locale_from_archive (int category, const char **namep) /* stat failed, very strange. */ close_and_out: if (fd >= 0) - close_not_cancel_no_status (fd); + __close_nocancel_no_status (fd); return NULL; } @@ -253,7 +253,7 @@ _nl_load_locale_from_archive (int category, const char **namep) { /* We've mapped the whole file already, so we can be sure we won't need this file descriptor later. */ - close_not_cancel_no_status (fd); + __close_nocancel_no_status (fd); fd = -1; } @@ -452,7 +452,7 @@ _nl_load_locale_from_archive (int category, const char **namep) /* We don't need the file descriptor any longer. */ if (fd >= 0) - close_not_cancel_no_status (fd); + __close_nocancel_no_status (fd); fd = -1; /* We succeeded in mapping all the necessary regions of the archive. diff --git a/locale/loadlocale.c b/locale/loadlocale.c index a733557..552d03f 100644 --- a/locale/loadlocale.c +++ b/locale/loadlocale.c @@ -181,7 +181,7 @@ _nl_load_locale (struct loaded_l10nfile *file, int category) if (__builtin_expect (__fxstat64 (_STAT_VER, fd, &st), 0) < 0) { puntfd: - close_not_cancel_no_status (fd); + __close_nocancel_no_status (fd); return; } if (__glibc_unlikely (S_ISDIR (st.st_mode))) @@ -191,7 +191,7 @@ _nl_load_locale (struct loaded_l10nfile *file, int category) char *newp; size_t filenamelen; - close_not_cancel_no_status (fd); + __close_nocancel_no_status (fd); filenamelen = strlen (file->filename); newp = (char *) alloca (filenamelen @@ -257,7 +257,7 @@ _nl_load_locale (struct loaded_l10nfile *file, int category) #endif /* _POSIX_MAPPED_FILES */ /* We have mapped the data, so we no longer need the descriptor. */ - close_not_cancel_no_status (fd); + __close_nocancel_no_status (fd); if (__glibc_unlikely (filedata == NULL)) /* We failed to map or read the data. */ diff --git a/login/utmp_file.c b/login/utmp_file.c index 26e3f4b..4dd38dd 100644 --- a/login/utmp_file.c +++ b/login/utmp_file.c @@ -382,10 +382,10 @@ pututline_file (const struct utmp *data) if (__lseek64 (new_fd, __lseek64 (file_fd, 0, SEEK_CUR), SEEK_SET) == -1 || __dup2 (new_fd, file_fd) < 0) { - close_not_cancel_no_status (new_fd); + __close_nocancel_no_status (new_fd); return NULL; } - close_not_cancel_no_status (new_fd); + __close_nocancel_no_status (new_fd); file_writable = true; } @@ -471,7 +471,7 @@ endutent_file (void) { assert (file_fd >= 0); - close_not_cancel_no_status (file_fd); + __close_nocancel_no_status (file_fd); file_fd = -1; } @@ -518,7 +518,7 @@ unlock_return: UNLOCK_FILE (fd); /* Close WTMP file. */ - close_not_cancel_no_status (fd); + __close_nocancel_no_status (fd); return result; } diff --git a/misc/daemon.c b/misc/daemon.c index dd38f2b..b35e20f 100644 --- a/misc/daemon.c +++ b/misc/daemon.c @@ -80,12 +80,12 @@ daemon (int nochdir, int noclose) } else { /* We must set an errno value since no function call actually failed. */ - close_not_cancel_no_status (fd); + __close_nocancel_no_status (fd); __set_errno (ENODEV); return -1; } } else { - close_not_cancel_no_status (fd); + __close_nocancel_no_status (fd); return -1; } } diff --git a/nscd/nscd_getai.c b/nscd/nscd_getai.c index daaf6d6..73347ff 100644 --- a/nscd/nscd_getai.c +++ b/nscd/nscd_getai.c @@ -189,7 +189,7 @@ __nscd_getai (const char *key, struct nscd_ai_result **result, int *h_errnop) out_close: if (sock != -1) - close_not_cancel_no_status (sock); + __close_nocancel_no_status (sock); out: if (__nscd_drop_map_ref (mapped, &gc_cycle) != 0) { diff --git a/nscd/nscd_getgr_r.c b/nscd/nscd_getgr_r.c index 87b4552..5f743c8 100644 --- a/nscd/nscd_getgr_r.c +++ b/nscd/nscd_getgr_r.c @@ -305,7 +305,7 @@ nscd_getgr_r (const char *key, size_t keylen, request_type type, out_close: if (sock != -1) - close_not_cancel_no_status (sock); + __close_nocancel_no_status (sock); out: if (__nscd_drop_map_ref (mapped, &gc_cycle) != 0) { diff --git a/nscd/nscd_gethst_r.c b/nscd/nscd_gethst_r.c index daa708b..d986824 100644 --- a/nscd/nscd_gethst_r.c +++ b/nscd/nscd_gethst_r.c @@ -436,7 +436,7 @@ nscd_gethst_r (const char *key, size_t keylen, request_type type, out_close: if (sock != -1) - close_not_cancel_no_status (sock); + __close_nocancel_no_status (sock); out: if (__nscd_drop_map_ref (mapped, &gc_cycle) != 0) { diff --git a/nscd/nscd_getpw_r.c b/nscd/nscd_getpw_r.c index b291d2f..a969d60 100644 --- a/nscd/nscd_getpw_r.c +++ b/nscd/nscd_getpw_r.c @@ -218,7 +218,7 @@ nscd_getpw_r (const char *key, size_t keylen, request_type type, out_close: if (sock != -1) - close_not_cancel_no_status (sock); + __close_nocancel_no_status (sock); out: if (__nscd_drop_map_ref (mapped, &gc_cycle) != 0) { diff --git a/nscd/nscd_getserv_r.c b/nscd/nscd_getserv_r.c index 7dfb1c8..1ac5aac 100644 --- a/nscd/nscd_getserv_r.c +++ b/nscd/nscd_getserv_r.c @@ -356,7 +356,7 @@ nscd_getserv_r (const char *crit, size_t critlen, const char *proto, out_close: if (sock != -1) - close_not_cancel_no_status (sock); + __close_nocancel_no_status (sock); out: if (__nscd_drop_map_ref (mapped, &gc_cycle) != 0) { diff --git a/nscd/nscd_helper.c b/nscd/nscd_helper.c index 22905d0..bc884aa 100644 --- a/nscd/nscd_helper.c +++ b/nscd/nscd_helper.c @@ -236,7 +236,7 @@ open_socket (request_type type, const char *key, size_t keylen) } out: - close_not_cancel_no_status (sock); + __close_nocancel_no_status (sock); return -1; } @@ -555,7 +555,7 @@ __nscd_open_socket (const char *key, size_t keylen, request_type type, return sock; } - close_not_cancel_no_status (sock); + __close_nocancel_no_status (sock); } __set_errno (saved_errno); diff --git a/nscd/nscd_initgroups.c b/nscd/nscd_initgroups.c index 00c6508..b696b66 100644 --- a/nscd/nscd_initgroups.c +++ b/nscd/nscd_initgroups.c @@ -157,7 +157,7 @@ __nscd_getgrouplist (const char *user, gid_t group, long int *size, out_close: if (sock != -1) - close_not_cancel_no_status (sock); + __close_nocancel_no_status (sock); out: if (__nscd_drop_map_ref (mapped, &gc_cycle) != 0) { diff --git a/nscd/nscd_netgroup.c b/nscd/nscd_netgroup.c index 44f37ef..14c780b 100644 --- a/nscd/nscd_netgroup.c +++ b/nscd/nscd_netgroup.c @@ -139,7 +139,7 @@ __nscd_setnetgrent (const char *group, struct __netgrent *datap) out_close: if (sock != -1) - close_not_cancel_no_status (sock); + __close_nocancel_no_status (sock); out: if (__nscd_drop_map_ref (mapped, &gc_cycle) != 0) { @@ -263,7 +263,7 @@ __nscd_innetgr (const char *netgroup, const char *host, const char *user, out_close: if (sock != -1) - close_not_cancel_no_status (sock); + __close_nocancel_no_status (sock); out: if (__nscd_drop_map_ref (mapped, &gc_cycle) != 0) { diff --git a/nss/nss_db/db-open.c b/nss/nss_db/db-open.c index 40a2540..97eb0a6 100644 --- a/nss/nss_db/db-open.c +++ b/nss/nss_db/db-open.c @@ -52,7 +52,7 @@ internal_setent (const char *file, struct nss_db_map *mapping) status = NSS_STATUS_TRYAGAIN; } - close_not_cancel_no_status (fd); + __close_nocancel_no_status (fd); } return status; diff --git a/resolv/res-close.c b/resolv/res-close.c index 21f038c..2adf47c 100644 --- a/resolv/res-close.c +++ b/resolv/res-close.c @@ -94,7 +94,7 @@ __res_iclose (res_state statp, bool free_addr) { if (statp->_vcsock >= 0) { - close_not_cancel_no_status (statp->_vcsock); + __close_nocancel_no_status (statp->_vcsock); statp->_vcsock = -1; statp->_flags &= ~(RES_F_VC | RES_F_CONN); } @@ -103,7 +103,7 @@ __res_iclose (res_state statp, bool free_addr) { if (statp->_u._ext.nssocks[ns] != -1) { - close_not_cancel_no_status (statp->_u._ext.nssocks[ns]); + __close_nocancel_no_status (statp->_u._ext.nssocks[ns]); statp->_u._ext.nssocks[ns] = -1; } if (free_addr) diff --git a/sunrpc/pm_getmaps.c b/sunrpc/pm_getmaps.c index 88c44f0..094492b 100644 --- a/sunrpc/pm_getmaps.c +++ b/sunrpc/pm_getmaps.c @@ -81,7 +81,7 @@ pmap_getmaps (struct sockaddr_in *address) } /* We only need to close the socket here if we opened it. */ if (closeit) - close_not_cancel (socket); + __close_nocancel (socket); address->sin_port = 0; return head; } diff --git a/sysdeps/generic/not-cancel.h b/sysdeps/generic/not-cancel.h index df9aea6..53214cd 100644 --- a/sysdeps/generic/not-cancel.h +++ b/sysdeps/generic/not-cancel.h @@ -26,9 +26,9 @@ __openat (__VA_ARGS__) #define __openat64_nocancel(...) \ __openat64 (__VA_ARGS__) -#define close_not_cancel(fd) \ +#define __close_nocancel(fd) \ __close (fd) -#define close_not_cancel_no_status(fd) \ +#define __close_nocancel_no_status(fd) \ (void) __close (fd) #define __read_nocancel(fd, buf, n) \ __read (fd, buf, n) diff --git a/sysdeps/posix/closedir.c b/sysdeps/posix/closedir.c index e7b7d77..dbde65f 100644 --- a/sysdeps/posix/closedir.c +++ b/sysdeps/posix/closedir.c @@ -49,6 +49,6 @@ __closedir (DIR *dirp) free ((void *) dirp); - return close_not_cancel (fd); + return __close_nocancel (fd); } weak_alias (__closedir, closedir) diff --git a/sysdeps/posix/getaddrinfo.c b/sysdeps/posix/getaddrinfo.c index efa7118..868fee0 100644 --- a/sysdeps/posix/getaddrinfo.c +++ b/sysdeps/posix/getaddrinfo.c @@ -2401,7 +2401,7 @@ getaddrinfo (const char *name, const char *service, { if (fd != -1) close_retry: - close_not_cancel_no_status (fd); + __close_nocancel_no_status (fd); af = q->ai_family; fd = __socket (af, SOCK_DGRAM | SOCK_CLOEXEC, IPPROTO_IP); } @@ -2504,7 +2504,7 @@ getaddrinfo (const char *name, const char *service, } if (fd != -1) - close_not_cancel_no_status (fd); + __close_nocancel_no_status (fd); /* We got all the source addresses we can get, now sort using the information. */ diff --git a/sysdeps/posix/getcwd.c b/sysdeps/posix/getcwd.c index ecae628..79a4cd0 100644 --- a/sysdeps/posix/getcwd.c +++ b/sysdeps/posix/getcwd.c @@ -176,7 +176,7 @@ extern char *alloca (); # include #else # define __openat64_nocancel(dfd, name, mode) openat64 (dfd, name, mode) -# define close_not_cancel_no_status(fd) close (fd) +# define __close_nocancel_no_status(fd) close (fd) #endif #ifndef PATH_MAX @@ -521,7 +521,7 @@ __getcwd (char *buf, size_t size) if (dirstream != NULL) __closedir (dirstream); if (fd_needs_closing) - close_not_cancel_no_status (fd); + __close_nocancel_no_status (fd); #ifndef NO_ALLOCATION if (buf == NULL) free (path); diff --git a/sysdeps/posix/opendir.c b/sysdeps/posix/opendir.c index 51a92e8..90d28ca 100644 --- a/sysdeps/posix/opendir.c +++ b/sysdeps/posix/opendir.c @@ -65,7 +65,7 @@ tryopen_o_directory (void) if (x >= 0) { - close_not_cancel_no_status (x); + __close_nocancel_no_status (x); o_directory_works = -1; } else if (errno != ENOTDIR) @@ -129,7 +129,7 @@ opendir_tail (int fd) { __set_errno (ENOTDIR); lose: - close_not_cancel_no_status (fd); + __close_nocancel_no_status (fd); return NULL; } @@ -227,7 +227,7 @@ __alloc_dir (int fd, bool close_fd, int flags, const struct stat64 *statp) if (close_fd) { int save_errno = errno; - close_not_cancel_no_status (fd); + __close_nocancel_no_status (fd); __set_errno (save_errno); } return NULL; diff --git a/sysdeps/posix/spawni.c b/sysdeps/posix/spawni.c index 7617279..e308f08 100644 --- a/sysdeps/posix/spawni.c +++ b/sysdeps/posix/spawni.c @@ -157,7 +157,7 @@ __spawni_child (void *arguments) switch (action->tag) { case spawn_do_close: - if (close_not_cancel (action->action.close_action.fd) != 0) + if (__close_nocancel (action->action.close_action.fd) != 0) { if (have_fdlimit == 0) { @@ -183,7 +183,7 @@ __spawni_child (void *arguments) with the process already at maximum number of file descriptor opened and also for multiple actions on single-open special paths (like /dev/watchdog). */ - close_not_cancel (action->action.open_action.fd); + __close_nocancel (action->action.open_action.fd); int new_fd = __open_nocancel (action->action.open_action.path, action->action.open_action.oflag @@ -200,7 +200,7 @@ __spawni_child (void *arguments) != action->action.open_action.fd) goto fail; - if ((ret = close_not_cancel (new_fd) != 0)) + if ((ret = __close_nocancel (new_fd) != 0)) goto fail; } } diff --git a/sysdeps/unix/sysv/linux/check_native.c b/sysdeps/unix/sysv/linux/check_native.c index 7e5a7c9..933e6f8 100644 --- a/sysdeps/unix/sysv/linux/check_native.c +++ b/sysdeps/unix/sysv/linux/check_native.c @@ -167,7 +167,7 @@ __check_native (uint32_t a1_index, int *a1_native, while (! done); out: - close_not_cancel_no_status (fd); + __close_nocancel_no_status (fd); return; diff --git a/sysdeps/unix/sysv/linux/check_pf.c b/sysdeps/unix/sysv/linux/check_pf.c index 3bf221a..79f1456 100644 --- a/sysdeps/unix/sysv/linux/check_pf.c +++ b/sysdeps/unix/sysv/linux/check_pf.c @@ -328,7 +328,7 @@ __check_pf (bool *seen_ipv4, bool *seen_ipv6, &addr_len) == 0) data = make_request (fd, nladdr.nl_pid); - close_not_cancel_no_status (fd); + __close_nocancel_no_status (fd); } if (data != NULL) diff --git a/sysdeps/unix/sysv/linux/close.c b/sysdeps/unix/sysv/linux/close.c index 1ac71ce..47b21ee 100644 --- a/sysdeps/unix/sysv/linux/close.c +++ b/sysdeps/unix/sysv/linux/close.c @@ -18,6 +18,7 @@ #include #include +#include /* Close the file descriptor FD. */ int @@ -28,3 +29,10 @@ __close (int fd) libc_hidden_def (__close) strong_alias (__close, __libc_close) weak_alias (__close, close) + +int +__close_nocancel (int fd) +{ + return INLINE_SYSCALL_CALL (close, fd); +} +libc_hidden_def (__close_nocancel) diff --git a/sysdeps/unix/sysv/linux/fips-private.h b/sysdeps/unix/sysv/linux/fips-private.h index 775f2c2..66d29d3 100644 --- a/sysdeps/unix/sysv/linux/fips-private.h +++ b/sysdeps/unix/sysv/linux/fips-private.h @@ -50,7 +50,7 @@ fips_enabled_p (void) char buf[32]; ssize_t n; n = TEMP_FAILURE_RETRY (__read_nocancel (fd, buf, sizeof (buf) - 1)); - close_not_cancel_no_status (fd); + __close_nocancel_no_status (fd); if (n > 0) { diff --git a/sysdeps/unix/sysv/linux/gethostid.c b/sysdeps/unix/sysv/linux/gethostid.c index 11c7e73..a719dad 100644 --- a/sysdeps/unix/sysv/linux/gethostid.c +++ b/sysdeps/unix/sysv/linux/gethostid.c @@ -53,7 +53,7 @@ sethostid (long int id) written = __write_nocancel (fd, &id32, sizeof (id32)); - close_not_cancel_no_status (fd); + __close_nocancel_no_status (fd); return written != sizeof (id32) ? -1 : 0; } @@ -82,7 +82,7 @@ gethostid (void) { ssize_t n = __read_nocancel (fd, &id, sizeof (id)); - close_not_cancel_no_status (fd); + __close_nocancel_no_status (fd); if (n == sizeof (id)) return id; diff --git a/sysdeps/unix/sysv/linux/getloadavg.c b/sysdeps/unix/sysv/linux/getloadavg.c index 64bad17..60c470e 100644 --- a/sysdeps/unix/sysv/linux/getloadavg.c +++ b/sysdeps/unix/sysv/linux/getloadavg.c @@ -43,7 +43,7 @@ getloadavg (double loadavg[], int nelem) int i; nread = __read_nocancel (fd, buf, sizeof buf - 1); - close_not_cancel_no_status (fd); + __close_nocancel_no_status (fd); if (nread <= 0) return -1; buf[nread - 1] = '\0'; diff --git a/sysdeps/unix/sysv/linux/getlogin_r.c b/sysdeps/unix/sysv/linux/getlogin_r.c index 1de746b..ecc7eb4 100644 --- a/sysdeps/unix/sysv/linux/getlogin_r.c +++ b/sysdeps/unix/sysv/linux/getlogin_r.c @@ -43,7 +43,7 @@ __getlogin_r_loginuid (char *name, size_t namesize) char uidbuf[12]; ssize_t n = TEMP_FAILURE_RETRY (__read_nocancel (fd, uidbuf, sizeof (uidbuf))); - close_not_cancel_no_status (fd); + __close_nocancel_no_status (fd); uid_t uid; char *endp; diff --git a/sysdeps/unix/sysv/linux/getsysstats.c b/sysdeps/unix/sysv/linux/getsysstats.c index d1400d6..977642f 100644 --- a/sysdeps/unix/sysv/linux/getsysstats.c +++ b/sysdeps/unix/sysv/linux/getsysstats.c @@ -180,7 +180,7 @@ __get_nprocs (void) } while (l < re); - close_not_cancel_no_status (fd); + __close_nocancel_no_status (fd); if (result > 0) goto out; @@ -207,7 +207,7 @@ __get_nprocs (void) else if (isdigit (l[3])) ++result; - close_not_cancel_no_status (fd); + __close_nocancel_no_status (fd); } else { @@ -215,7 +215,7 @@ __get_nprocs (void) if (fd != -1) { GET_NPROCS_PARSER (fd, buffer, cp, re, buffer_end, result); - close_not_cancel_no_status (fd); + __close_nocancel_no_status (fd); } } diff --git a/sysdeps/unix/sysv/linux/grantpt.c b/sysdeps/unix/sysv/linux/grantpt.c index 97c6ba7..af2a9db 100644 --- a/sysdeps/unix/sysv/linux/grantpt.c +++ b/sysdeps/unix/sysv/linux/grantpt.c @@ -26,7 +26,7 @@ close_all_fds (void) char *endp; long int fd = strtol (d->d_name, &endp, 10); if (*endp == '\0' && fd != PTY_FILENO && fd != dirfd (dir)) - close_not_cancel_no_status (fd); + __close_nocancel_no_status (fd); } __closedir (dir); diff --git a/sysdeps/unix/sysv/linux/i386/smp.h b/sysdeps/unix/sysv/linux/i386/smp.h index eb1ac5d..2efbc71 100644 --- a/sysdeps/unix/sysv/linux/i386/smp.h +++ b/sysdeps/unix/sysv/linux/i386/smp.h @@ -47,7 +47,7 @@ is_smp_system (void) /* This also didn't work. We give up and say it's a UP machine. */ u.buf[0] = '\0'; - close_not_cancel_no_status (fd); + __close_nocancel_no_status (fd); cp = u.buf; } diff --git a/sysdeps/unix/sysv/linux/ia64/has_cpuclock.c b/sysdeps/unix/sysv/linux/ia64/has_cpuclock.c index 6aab1e8..8267848 100644 --- a/sysdeps/unix/sysv/linux/ia64/has_cpuclock.c +++ b/sysdeps/unix/sysv/linux/ia64/has_cpuclock.c @@ -41,7 +41,7 @@ has_cpuclock (void) || buf[0] != '0' || buf[1] != '\n') newval = -1; - close_not_cancel_no_status (fd); + __close_nocancel_no_status (fd); } itc_usable = newval; diff --git a/sysdeps/unix/sysv/linux/if_index.c b/sysdeps/unix/sysv/linux/if_index.c index 8ba5eae..3474d4f 100644 --- a/sysdeps/unix/sysv/linux/if_index.c +++ b/sysdeps/unix/sysv/linux/if_index.c @@ -47,12 +47,12 @@ __if_nametoindex (const char *ifname) if (__ioctl (fd, SIOCGIFINDEX, &ifr) < 0) { int saved_errno = errno; - close_not_cancel_no_status (fd); + __close_nocancel_no_status (fd); if (saved_errno == EINVAL) __set_errno (ENOSYS); return 0; } - close_not_cancel_no_status (fd); + __close_nocancel_no_status (fd); return ifr.ifr_ifindex; #endif } @@ -224,7 +224,7 @@ __if_indextoname (unsigned int ifindex, char *ifname) ifr.ifr_ifindex = ifindex; status = __ioctl (fd, SIOCGIFNAME, &ifr); - close_not_cancel_no_status (fd); + __close_nocancel_no_status (fd); if (status < 0) { diff --git a/sysdeps/unix/sysv/linux/libc_fatal.c b/sysdeps/unix/sysv/linux/libc_fatal.c index c7c6a07..4e06c90 100644 --- a/sysdeps/unix/sysv/linux/libc_fatal.c +++ b/sysdeps/unix/sysv/linux/libc_fatal.c @@ -59,7 +59,7 @@ backtrace_and_maps (int do_abort, bool written, int fd) while ((n2 = __read_nocancel (fd2, buf, sizeof (buf))) > 0) if (__write_nocancel (fd, buf, n2) != n2) break; - close_not_cancel_no_status (fd2); + __close_nocancel_no_status (fd2); } } } diff --git a/sysdeps/unix/sysv/linux/malloc-sysdep.h b/sysdeps/unix/sysv/linux/malloc-sysdep.h index 7a7acba..0dcd3d1 100644 --- a/sysdeps/unix/sysv/linux/malloc-sysdep.h +++ b/sysdeps/unix/sysv/linux/malloc-sysdep.h @@ -49,7 +49,7 @@ check_may_shrink_heap (void) char val; ssize_t n = __read_nocancel (fd, &val, 1); may_shrink_heap = n > 0 && val == '2'; - close_not_cancel_no_status (fd); + __close_nocancel_no_status (fd); } } diff --git a/sysdeps/unix/sysv/linux/mq_notify.c b/sysdeps/unix/sysv/linux/mq_notify.c index 626430c..e724a46 100644 --- a/sysdeps/unix/sysv/linux/mq_notify.c +++ b/sysdeps/unix/sysv/linux/mq_notify.c @@ -209,7 +209,7 @@ init_mq_netlink (void) if (err != 0) { - close_not_cancel_no_status (netlink_socket); + __close_nocancel_no_status (netlink_socket); netlink_socket = -1; } } diff --git a/sysdeps/unix/sysv/linux/not-cancel.h b/sysdeps/unix/sysv/linux/not-cancel.h index 08ad773..c620c8a 100644 --- a/sysdeps/unix/sysv/linux/not-cancel.h +++ b/sysdeps/unix/sysv/linux/not-cancel.h @@ -51,13 +51,17 @@ __typeof (__write) __write_nocancel; libc_hidden_proto (__write_nocancel) /* Uncancelable close. */ -#define __close_nocancel(fd) \ - INLINE_SYSCALL (close, 1, fd) -#define close_not_cancel(fd) \ - __close_nocancel (fd) -#define close_not_cancel_no_status(fd) \ - (void) ({ INTERNAL_SYSCALL_DECL (err); \ - INTERNAL_SYSCALL (close, err, 1, (fd)); }) +__typeof (__close) __close_nocancel; +libc_hidden_proto (__close_nocancel) + +/* Non cancellable close syscall that does not also set errno in case of + failure. */ +static inline int +__close_nocancel_no_status (int fd) +{ + INTERNAL_SYSCALL_DECL (err); + return INTERNAL_SYSCALL (close, err, 1, (fd)); +} /* Uncancelable writev. */ #define writev_not_cancel_no_status(fd, iov, n) \ diff --git a/sysdeps/unix/sysv/linux/pthread_getname.c b/sysdeps/unix/sysv/linux/pthread_getname.c index 93c1dfd..919a25b 100644 --- a/sysdeps/unix/sysv/linux/pthread_getname.c +++ b/sysdeps/unix/sysv/linux/pthread_getname.c @@ -63,7 +63,7 @@ pthread_getname_np (pthread_t th, char *buf, size_t len) buf[n] = '\0'; } - close_not_cancel_no_status (fd); + __close_nocancel_no_status (fd); return res; } diff --git a/sysdeps/unix/sysv/linux/pthread_setname.c b/sysdeps/unix/sysv/linux/pthread_setname.c index c5e9a33..3cb112f 100644 --- a/sysdeps/unix/sysv/linux/pthread_setname.c +++ b/sysdeps/unix/sysv/linux/pthread_setname.c @@ -57,7 +57,7 @@ pthread_setname_np (pthread_t th, const char *name) else if (n != name_len) res = EIO; - close_not_cancel_no_status (fd); + __close_nocancel_no_status (fd); return res; } diff --git a/sysdeps/unix/sysv/linux/spawni.c b/sysdeps/unix/sysv/linux/spawni.c index 4994a07..dea1650 100644 --- a/sysdeps/unix/sysv/linux/spawni.c +++ b/sysdeps/unix/sysv/linux/spawni.c @@ -205,7 +205,7 @@ __spawni_child (void *arguments) switch (action->tag) { case spawn_do_close: - if (close_not_cancel (action->action.close_action.fd) != 0) + if (__close_nocancel (action->action.close_action.fd) != 0) { if (!have_fdlimit) { @@ -228,7 +228,7 @@ __spawni_child (void *arguments) with the process already at maximum number of file descriptor opened and also for multiple actions on single-open special paths (like /dev/watchdog). */ - close_not_cancel (action->action.open_action.fd); + __close_nocancel (action->action.open_action.fd); int ret = __open_nocancel (action->action.open_action.path, action->action. @@ -247,7 +247,7 @@ __spawni_child (void *arguments) != action->action.open_action.fd) goto fail; - if (close_not_cancel (new_fd) != 0) + if (__close_nocancel (new_fd) != 0) goto fail; } } diff --git a/sysdeps/unix/sysv/linux/sysconf.c b/sysdeps/unix/sysv/linux/sysconf.c index f9becfb..d2a124b 100644 --- a/sysdeps/unix/sysv/linux/sysconf.c +++ b/sysdeps/unix/sysv/linux/sysconf.c @@ -122,7 +122,7 @@ __sysconf (int name) char buf[32]; ssize_t n; n = TEMP_FAILURE_RETRY (__read_nocancel (fd, buf, sizeof (buf) - 1)); - close_not_cancel_no_status (fd); + __close_nocancel_no_status (fd); if (n > 0) { From patchwork Tue Jul 4 19:53:46 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 107019 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp1361685qge; Tue, 4 Jul 2017 12:55:37 -0700 (PDT) X-Received: by 10.99.67.68 with SMTP id q65mr17200065pga.260.1499198137651; Tue, 04 Jul 2017 12:55:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499198137; cv=none; d=google.com; s=arc-20160816; b=PJgD/e/sVeL7KSFo2EqeE1eWkpY3GabFVul7EfQfAZ0ohams3DlnDnqKzrFLCbwKhj hkrkwRec8Mb3932zCsMh3NoqkOlyZzR6y7PWqAnP1+2uDT9RjH64md/oplD3Raaa37jV AX40FKEW4JPWtcWWKmY3ppXHzZSVTE3Iz8Hz9pI8Lmn+hWTkUHBb4+5JVefM2NAiFSa2 AjYiPGldaoi/DdHxhXun1Af+Qg8rEfJHy2RqxzVfROzGUdHyZxJ+vLTJ1A3kxiNOGqYp dGo2Y0l9uXKXQyGuQ1gLuAo9zAeJM5/aHgIYdeVWTfbbsQ4Gtky5zYmHB7SE0ZEuu9A1 mfHw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:to:from:delivered-to :sender:list-help:list-post:list-archive:list-subscribe :list-unsubscribe:list-id:precedence:mailing-list:dkim-signature :domainkey-signature:arc-authentication-results; bh=XEecaJqrXxRlEdFexnOLR+Qjquz1J5T1sih4gaDSfGA=; b=DoEUwdDK1vZLvpU1pctGUWVMfGKRhyKEvxPGmF6zaYEb5YkfmumeAoFieXboPlzLZB M9qt+kyyTGaf7QKPzidIIeJToH2CsEE8hniJGOGMHrEuhoZS5wzKwuqIaS7ODYavGunv ZYZ+AvDfzRkU535Xm2z/D7Sczq/Rh3C43htAamhYM6Vy3eOzf01/+8emQjHxD4g6B+Rl EwWEizP/xFd8pecLOVdfzCvTSNd8JyFEvUwm4MwCIFJd9fYAfW5I+kqVA0W7iNuSiMiH YY7Ax31qbBfVxquIGNoonicU1ewOoxDm2zIIsZd88kOBRyCTcgX3U5B5kJVyutQrADMu TSXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.b=ui7yCTDQ; spf=pass (google.com: domain of libc-alpha-return-81668-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-81668-patch=linaro.org@sourceware.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id 191si11678269pfu.378.2017.07.04.12.55.37 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 04 Jul 2017 12:55:37 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-return-81668-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.b=ui7yCTDQ; spf=pass (google.com: domain of libc-alpha-return-81668-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-81668-patch=linaro.org@sourceware.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=kWJSnGGDui3BGxfAr8hOlOSLD+NPMoy WW7tuaxXb9cjycTgnMLHN31VuZVsOG/QLgwU+I3BXLOZm55UgXvWN5lQsGaEHIhU R/i19g1IITI7Vmpa3t7T0s3QLs8AsQl/n0E6kwERE197M/BqJwr74lDhna/SA747 EbYKT0s3W/Mo= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; s=default; bh=Qh1I7Cer1hn8j1wPTjhoZSkw1vQ=; b=ui7yC TDQWkCc6r2keH9HjiE7/dA64WlyH09oCxq+KmEkKkAk/RJPg0d/Gc8yCqZxEdzMF GKBraW2ojqgEZ0saqsnwqgk5V0Ek6BEzhHlgeCKAB9qeduVxQdv56PWvazNnHZ1Y yOwcfEk60jTmiZ4ot1EbegxnPlu27z3gyIUS4c= Received: (qmail 74718 invoked by alias); 4 Jul 2017 19:54:23 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 73808 invoked by uid 89); 4 Jul 2017 19:54:16 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.4 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-qk0-f173.google.com 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:in-reply-to :references; bh=XEecaJqrXxRlEdFexnOLR+Qjquz1J5T1sih4gaDSfGA=; b=FYZzLqqjNSIP1nMle8IzdkxpTAy6uqRyYLtJofL/08mooWfTO406K+YFFbATcmCypK nA5gsCCT7PbRk9+H0ojwvJu92VhZZdeCYH4b2ldHFEXVC+AYasx1w257XOnr3NyL+Qdo RShBFD5GkdFdvo/Sxo/QRkVRb3X6YaGO+d25QASmQJI51w1Uskzdg5FoQgeQFHrN9wSa klkdYloZB6Lb9DLA6EFxDnvI65WDKvG+KbubtblSVIjn3Khbthq1XnhlX66tjIV69v5l RRu6bHt5/8ofB5B+FZ2BeeLX1w5X+l8Oac1XOutb32/NPKXgvsB7Ozdj458n1zhmtkb5 Tyeg== X-Gm-Message-State: AKS2vOxQP7AlsGwOrB4/+XhIWfAn9e1+1D0jUKK2vAV8+9Qx9VKafoaO z7aIsMyCuiWG9dUMzb5tDQ== X-Received: by 10.55.112.66 with SMTP id l63mr50557580qkc.56.1499198050671; Tue, 04 Jul 2017 12:54:10 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH 06/14] Consolidate non cancellable writev call Date: Tue, 4 Jul 2017 16:53:46 -0300 Message-Id: <1499198034-5837-7-git-send-email-adhemerval.zanella@linaro.org> In-Reply-To: <1499198034-5837-1-git-send-email-adhemerval.zanella@linaro.org> References: <1499198034-5837-1-git-send-email-adhemerval.zanella@linaro.org> This patch consolidates all the non cancellable writev calls to use the __writev_nocancel identifier. For non cancellable targets it will be just a macro to call the default respective symbol while on Linux will be a internal one. Checked on x86_64-linux-gnu, x86_64-linux-gnu-x32, and i686-linux-gnu. * gmon/gmon.c (write_hist): Replace writev_not_cancel_no_status with __writev_nocancel_nostatus. (write_call_graph): Likewise. (write_bb_counts): Likewise. * resolv/herror.c (herror): Likewise. * sysdeps/generic/not-cancel.h (writev_not_cancel_no_status): Remove macro. (__writev_nocancel_nostatus): New macro. * sysdeps/unix/sysv/linux/not-cancel.h (writev_not_cancel_no_status): Remove macro. (__writev_nocancel_nostatus): New function. --- ChangeLog | 12 ++++++++++++ gmon/gmon.c | 12 ++++++------ resolv/herror.c | 2 +- sysdeps/generic/not-cancel.h | 2 +- sysdeps/unix/sysv/linux/not-cancel.h | 12 ++++++++---- 5 files changed, 28 insertions(+), 12 deletions(-) -- 2.7.4 diff --git a/gmon/gmon.c b/gmon/gmon.c index b26c27a..8408e53 100644 --- a/gmon/gmon.c +++ b/gmon/gmon.c @@ -216,7 +216,7 @@ write_hist (int fd) strncpy (thdr.dimen, "seconds", sizeof (thdr.dimen)); thdr.dimen_abbrev = 's'; - writev_not_cancel_no_status (fd, iov, 3); + __writev_nocancel_nostatus (fd, iov, 3); } } @@ -273,13 +273,13 @@ write_call_graph (int fd) if (++nfilled == NARCS_PER_WRITEV) { - writev_not_cancel_no_status (fd, iov, 2 * nfilled); + __writev_nocancel_nostatus (fd, iov, 2 * nfilled); nfilled = 0; } } } if (nfilled > 0) - writev_not_cancel_no_status (fd, iov, 2 * nfilled); + __writev_nocancel_nostatus (fd, iov, 2 * nfilled); } @@ -312,12 +312,12 @@ write_bb_counts (int fd) for (grp = __bb_head; grp; grp = grp->next) { ncounts = grp->ncounts; - writev_not_cancel_no_status (fd, bbhead, 2); + __writev_nocancel_nostatus (fd, bbhead, 2); for (nfilled = i = 0; i < ncounts; ++i) { if (nfilled > (sizeof (bbbody) / sizeof (bbbody[0])) - 2) { - writev_not_cancel_no_status (fd, bbbody, nfilled); + __writev_nocancel_nostatus (fd, bbbody, nfilled); nfilled = 0; } @@ -325,7 +325,7 @@ write_bb_counts (int fd) bbbody[nfilled++].iov_base = &grp->counts[i]; } if (nfilled > 0) - writev_not_cancel_no_status (fd, bbbody, nfilled); + __writev_nocancel_nostatus (fd, bbbody, nfilled); } } diff --git a/resolv/herror.c b/resolv/herror.c index b3df236..45c0a5d 100644 --- a/resolv/herror.c +++ b/resolv/herror.c @@ -89,7 +89,7 @@ herror(const char *s) { v++; v->iov_base = (char *) "\n"; v->iov_len = 1; - writev_not_cancel_no_status(STDERR_FILENO, iov, (v - iov) + 1); + __writev_nocancel_nostatus(STDERR_FILENO, iov, (v - iov) + 1); } /* diff --git a/sysdeps/generic/not-cancel.h b/sysdeps/generic/not-cancel.h index 53214cd..9959c87 100644 --- a/sysdeps/generic/not-cancel.h +++ b/sysdeps/generic/not-cancel.h @@ -34,7 +34,7 @@ __read (fd, buf, n) #define __write_nocancel(fd, buf, n) \ __write (fd, buf, n) -#define writev_not_cancel_no_status(fd, iov, n) \ +#define __writev_nocancel_nostatus(fd, iov, n) \ (void) __writev (fd, iov, n) #define fcntl_not_cancel(fd, cmd, val) \ __fcntl (fd, cmd, val) diff --git a/sysdeps/unix/sysv/linux/not-cancel.h b/sysdeps/unix/sysv/linux/not-cancel.h index c620c8a..7fd42c2 100644 --- a/sysdeps/unix/sysv/linux/not-cancel.h +++ b/sysdeps/unix/sysv/linux/not-cancel.h @@ -63,10 +63,14 @@ __close_nocancel_no_status (int fd) return INTERNAL_SYSCALL (close, err, 1, (fd)); } -/* Uncancelable writev. */ -#define writev_not_cancel_no_status(fd, iov, n) \ - (void) ({ INTERNAL_SYSCALL_DECL (err); \ - INTERNAL_SYSCALL (writev, err, 3, (fd), (iov), (n)); }) +/* Non cancellable writev syscall that does not also set errno in case of + failure. */ +static inline int +__writev_nocancel_nostatus (int fd, const struct iovec *iov, int iovcnt) +{ + INTERNAL_SYSCALL_DECL (err); + return INTERNAL_SYSCALL_CALL (writev, err, fd, iov, iovcnt); +} /* Uncancelable fcntl. */ #define fcntl_not_cancel(fd, cmd, val) \ From patchwork Tue Jul 4 19:53:47 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 107018 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp1361556qge; Tue, 4 Jul 2017 12:55:25 -0700 (PDT) X-Received: by 10.84.229.6 with SMTP id b6mr17793211plk.247.1499198124964; Tue, 04 Jul 2017 12:55:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499198124; cv=none; d=google.com; s=arc-20160816; b=xxcqL25stOoC1uRdtBuMSSKvBhfIvE4Zkwvf6s2T2+daMStVRAIVq/W3B1cBcrdqUs eEkIiwXsg8GkoibapBvq38UmBLY4X67bHz0qEBM975tFooZZpAKdYcx3Qh9l4NZobhuJ hZKyzQbFuInIIFR4YEmNmX5Nv3I7w+DpXics4b6nwVsQPHCB9KHKrXtIdW8OYylfJkeZ HNnLf8Q9HM0B3zLrm9GMNcmAz6gypTiqfH5mUwsZb4y8VnkOYk0Xox6wslpTbtzxQSAv aMgvx4eaHIk3RNaVnlI59VNgbH+lltYNij/0EZlWVjS3AJm863DwyqRNSuyq7C5eoner c9Sw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:to:from:delivered-to :sender:list-help:list-post:list-archive:list-subscribe :list-unsubscribe:list-id:precedence:mailing-list:dkim-signature :domainkey-signature:arc-authentication-results; bh=kVuRia8YFXoEvWTz1XsIZ+ncjsiGV69O6x/xBemu83s=; b=jVD8p341Q8PwdaPPr/Ah3IzTRNrbkXszXlke4u48v1irOlXho4FqbiHnl83klv2r7J hYRLX8lGG8SDGIX72UuCRJ30NaN2aSu4jij/N+Hdonk1lAFYS6fETorQt5CzrjErzSJr mUFO2cqMsYW16zjlaeua62kut6x4aOXWSCZgsrk1b+z5jzTGdfiWJpIyN1jQjMxzPHww 6aJ48J1tFYGTNXimptBD/sUx5h1EJ5WtCKkl9cEDL88uoTkPN26OcRw420qAevC0JukF e0KxxmdQPiWgRndDxX50wbKTS1Q86G2la6yl9/qoSmTB4tut/aLCNt6NnrLjSk552aBd tmTg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.b=qFA6nIMR; spf=pass (google.com: domain of libc-alpha-return-81666-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-81666-patch=linaro.org@sourceware.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id o4si14498998pgd.352.2017.07.04.12.55.24 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 04 Jul 2017 12:55:24 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-return-81666-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.b=qFA6nIMR; spf=pass (google.com: domain of libc-alpha-return-81666-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-81666-patch=linaro.org@sourceware.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=oANd3MYMeVBaKNhvSWTt6LE7YP1hjhB vdadwpVRN9LcBlmpN3twmMmxbEEvMICYlhP/7k2j2+2+aqLyoZusxyLsBfGwPDJJ kCtiHy4bkkEJSOS1YnFeztagOUwjtwKKnah6qTPcjoqfzFIidWfidvuKdmHgmMoP wWBVItsT096c= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; s=default; bh=SAquF5gRfceM4z91R/I6zwxiboA=; b=qFA6n IMR4e3wY6Xb4WFd3dXBxByunPSr/s08qATCi2bMhsYXt6bh9anbwy10sjBYlcfNV eOMpF95Mv1sFR5ziNZsq+6adQPjqAZzapU3md2q6DfDVnz71/awdh2RD2PiGeHdu Enf2F5GPD4dCHysRvP7EhMeUgJqAoKtu9WLsj0= Received: (qmail 74521 invoked by alias); 4 Jul 2017 19:54:22 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 73805 invoked by uid 89); 4 Jul 2017 19:54:16 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.4 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy=Unlock X-HELO: mail-qk0-f182.google.com 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:in-reply-to :references; bh=kVuRia8YFXoEvWTz1XsIZ+ncjsiGV69O6x/xBemu83s=; b=Ud6ABzMarbMX5mIqi8//aquvcRQi07vDG8xFxMVJqu9kQVvkwHbzUJi/m/nrnXsF0e YUEvewEYHQmPgF0iZ06Xgh7RmNEh5AT+sT/NC61hBmUTsRih9MyCtyrMWo44UGfDVHyk NMO81cEpktCHZbC58BmflwwdFSl7lW8M9dzxwC6FwN/b6jOSVoqPit2ZwZRNtB4k42+o nCqEoOV8rAfrVq0V9XRSnOF9thrYFOzmUiZc2r60KQaRJAP6aawkBdSn4BzcKcv18zMd 8YCPBbr+iWjI/MUkSABga40vCSyCED+fBbIdjXz2Mko5WjoujGnZidEh/osUaELSNJI6 u+vA== X-Gm-Message-State: AKS2vOzmwleha4Z+MlSG2Sds8M4z6UJUwqZFzih3Pc9CFNBsG8kuTD3F JEaTedcc/tg/BdNvVRqPnA== X-Received: by 10.55.20.147 with SMTP id 19mr53589972qku.204.1499198052078; Tue, 04 Jul 2017 12:54:12 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH 07/14] Consolidate non cancellable fcntl call Date: Tue, 4 Jul 2017 16:53:47 -0300 Message-Id: <1499198034-5837-8-git-send-email-adhemerval.zanella@linaro.org> In-Reply-To: <1499198034-5837-1-git-send-email-adhemerval.zanella@linaro.org> References: <1499198034-5837-1-git-send-email-adhemerval.zanella@linaro.org> This patch consolidates all the non cancellable fcntl calls to use the __fcntl_nocancel identifier. For non cancellable targets it will be just a macro to call the default respective symbol while on Linux will be a internal one. Since its prototype is already defined at internal fcntl.h header, it is removed from not-cancel.h one. Checked on x86_64-linux-gnu, x86_64-linux-gnu-x32, and i686-linux-gnu. * login/utmp_file.c (timeout_handler): Replace fcntl_not_cancel with __fcntl_nocancel. * sysdeps/generic/not-cancel.h (fcntl_not_cancel): Remove macro. * sysdeps/unix/sysv/linux/not-cancel.h (fcntl_not_cancel): Likewise. --- ChangeLog | 5 +++++ login/utmp_file.c | 4 ++-- sysdeps/generic/not-cancel.h | 2 -- sysdeps/unix/sysv/linux/not-cancel.h | 4 ---- 4 files changed, 7 insertions(+), 8 deletions(-) -- 2.7.4 diff --git a/login/utmp_file.c b/login/utmp_file.c index 4dd38dd..7462a13 100644 --- a/login/utmp_file.c +++ b/login/utmp_file.c @@ -81,7 +81,7 @@ static void timeout_handler (int signum) {}; memset (&fl, '\0', sizeof (struct flock)); \ fl.l_type = (type); \ fl.l_whence = SEEK_SET; \ - if (fcntl_not_cancel ((fd), F_SETLKW, &fl) < 0) + if (__fcntl_nocancel ((fd), F_SETLKW, &fl) < 0) #define LOCKING_FAILED() \ goto unalarm_return @@ -89,7 +89,7 @@ static void timeout_handler (int signum) {}; #define UNLOCK_FILE(fd) \ /* Unlock the file. */ \ fl.l_type = F_UNLCK; \ - fcntl_not_cancel ((fd), F_SETLKW, &fl); \ + __fcntl_nocancel ((fd), F_SETLKW, &fl); \ \ unalarm_return: \ /* Reset the signal handler and alarm. We must reset the alarm \ diff --git a/sysdeps/generic/not-cancel.h b/sysdeps/generic/not-cancel.h index 9959c87..fa7b4d3 100644 --- a/sysdeps/generic/not-cancel.h +++ b/sysdeps/generic/not-cancel.h @@ -36,8 +36,6 @@ __write (fd, buf, n) #define __writev_nocancel_nostatus(fd, iov, n) \ (void) __writev (fd, iov, n) -#define fcntl_not_cancel(fd, cmd, val) \ - __fcntl (fd, cmd, val) # define waitpid_not_cancel(pid, stat_loc, options) \ __waitpid (pid, stat_loc, options) #define pause_not_cancel() \ diff --git a/sysdeps/unix/sysv/linux/not-cancel.h b/sysdeps/unix/sysv/linux/not-cancel.h index 7fd42c2..625bbaa 100644 --- a/sysdeps/unix/sysv/linux/not-cancel.h +++ b/sysdeps/unix/sysv/linux/not-cancel.h @@ -72,10 +72,6 @@ __writev_nocancel_nostatus (int fd, const struct iovec *iov, int iovcnt) return INTERNAL_SYSCALL_CALL (writev, err, fd, iov, iovcnt); } -/* Uncancelable fcntl. */ -#define fcntl_not_cancel(fd, cmd, val) \ - __fcntl_nocancel (fd, cmd, val) - /* Uncancelable waitpid. */ #define __waitpid_nocancel(pid, stat_loc, options) \ INLINE_SYSCALL (wait4, 4, pid, stat_loc, options, NULL) From patchwork Tue Jul 4 19:53:48 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 107017 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp1361471qge; Tue, 4 Jul 2017 12:55:16 -0700 (PDT) X-Received: by 10.84.231.199 with SMTP id g7mr18087843pln.258.1499198115934; Tue, 04 Jul 2017 12:55:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499198115; cv=none; d=google.com; s=arc-20160816; b=NHP3+jg87EnCa0yRTU7NXOiqDIs8BKc+Cc+YhJi9nuCdeTsNytnJsr7CWHWVM8BA9B hQCtHxoox4XYd8RFsaZXvlBO0QkqejUcnVWnvKBKbk/YaDR0FxWiB+G9UmRhFrtIExyj R8FYXRkTPjwMZwMVYb7J+8V7qxNHdG/YSarlC8AdjnSBWFmTY3mjWgCUlt0F1v/q20iz PhVMwelpfZXn4lVgJlsDcAVqAq9uvgO7z80L3nelLhAsu02ujrusm6vOH44Ur2/Ce60c L9vjsfbh0sYHLzpQDzKZxaD+UrCsH+M7ezRGkwm/1zEYx3pNRuY6VkcSe8T1j8uq1DKK mihQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:to:from:delivered-to :sender:list-help:list-post:list-archive:list-subscribe :list-unsubscribe:list-id:precedence:mailing-list:dkim-signature :domainkey-signature:arc-authentication-results; bh=8sCDcwyNuEjO1BshqJo9954riFTBac5yeyrEGzulo2I=; b=hC38Cds1CA0XGgbKSu2+KiQ5N3xQGYFR7lVIA/sDdev/34CG1Ts5DxXySdYBtt+ahV e7SYWtbM1qF2PdRXPlsVDEPnfresa6nFtprAx27Zqb+dlbRKXNQ0uGV/uKwz+yNEoZ+n 3oE0aBOhR2vludQ4I44NZpynGBn6zMii3gi0vogqzLzG2DBA/UzAstlL49tTHnzdE31k er2kz+214Mj1CAm+tPfqxJl8V6tDINXfYr8nxvWjxhCygItrb/cboLZIMxWZ0JXpRQss +BTrhJRykfcjPAPPjsweLhHK/1KHSURNjQ9wjMvO4vHn+sORxy1fBCmXjsh82gJucAXa d83Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.b=PNrTqPLD; spf=pass (google.com: domain of libc-alpha-return-81667-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-81667-patch=linaro.org@sourceware.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id r63si16339047plb.589.2017.07.04.12.55.15 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 04 Jul 2017 12:55:15 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-return-81667-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.b=PNrTqPLD; spf=pass (google.com: domain of libc-alpha-return-81667-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-81667-patch=linaro.org@sourceware.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=P2eEr/NPBPmURJ7btPTsQH+kxTrqaA5 2ZdmTVnf6u6nGG6LmtxDMnLzeCC7m67IsVfFGw6/nmmbtAIrPC4T9yxTyA/IPGE4 mZOSCkTQRlNzT99GMFNy3OPczsWtJf2pHF/kShUooQzKeN9Mw01WIJ0iRNFzN/Vg Ja4VZE/xz3ac= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; s=default; bh=kOHkeiq7Boa1VHcI7ZOscuthOxU=; b=PNrTq PLDHUmQBI0zH8dz7YEhplCeaeD1Aee2UPg0UohOlgrBokL0XCist77skSQn3x+ph sTu9ojeXti06vBsBmNPRJxgtfHkZSU9QSBl/aXpCdx+OCHrjWqktKfGFtnqJEgXA ri5eW69guXOkGlRG7onQA5n5AKSyaGhiJJAcS4= Received: (qmail 74589 invoked by alias); 4 Jul 2017 19:54:23 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 74022 invoked by uid 89); 4 Jul 2017 19:54:18 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.4 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy=3314 X-HELO: mail-qk0-f173.google.com 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:in-reply-to :references; bh=8sCDcwyNuEjO1BshqJo9954riFTBac5yeyrEGzulo2I=; b=nx7l4PDFyTsYiJQtVrOaK71Vtn66I8GLPesotv+rDGv+kYbgTQwa7yZYaZbA4s5CZ+ Ulcjc+1GI7pp528RWtr/xg7Z856N4O+m1MOjXVwseGvKW4j3nW65cp5mQhw6/KYiOskR 6y38utsj8QzyhSCseMHO/nyg7IdNWXk0VfyKiIqnzYxaoJteYD5O8WQwgfR687Zezl7g 4mkCmuXd8x0BFpu6FfdwGH4JIsfvmCNyTpnJlLllLiomKny6yP2gOWPU/zxD0X2VHFcb V2jlhdzpw+BZQ4Xf+qEcL1KRS6vrp3y92EPJHj4RrpeU0IKjxfdoZj0L6/pGQEmM+7XU TJBA== X-Gm-Message-State: AKS2vOwLlqZNc0tASt0JxfK8hm8KvQ9IA2B9lM4LNMAzm61BSn/NwBci sbbP5xQJZfS+km/kXOMILA== X-Received: by 10.55.204.133 with SMTP id n5mr50951946qkl.135.1499198053424; Tue, 04 Jul 2017 12:54:13 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH 08/14] Consolidate non cancellable waitpid call Date: Tue, 4 Jul 2017 16:53:48 -0300 Message-Id: <1499198034-5837-9-git-send-email-adhemerval.zanella@linaro.org> In-Reply-To: <1499198034-5837-1-git-send-email-adhemerval.zanella@linaro.org> References: <1499198034-5837-1-git-send-email-adhemerval.zanella@linaro.org> This patch consolidates all the non cancellable waitpid calls to use the __waitpid_nocancel identifier. For non cancellable targets it will be just a macro to call the default respective symbol while on Linux will be a internal one. Checked on x86_64-linux-gnu, x86_64-linux-gnu-x32, and i686-linux-gnu. * login/utmp_file.c (timeout_handler): Replace fcntl_not_cancel with __fcntl_nocancel. * sysdeps/generic/not-cancel.h (fcntl_not_cancel): Remove macro. * sysdeps/unix/sysv/linux/not-cancel.h (fcntl_not_cancel): Likewise. --- libio/iopopen.c | 2 +- sysdeps/generic/not-cancel.h | 2 +- sysdeps/unix/sysv/linux/not-cancel.h | 7 +++---- sysdeps/unix/sysv/linux/waitpid.c | 15 ++++++++++++++- 4 files changed, 19 insertions(+), 7 deletions(-) -- 2.7.4 diff --git a/libio/iopopen.c b/libio/iopopen.c index 0c20cbb..a2ddebb 100644 --- a/libio/iopopen.c +++ b/libio/iopopen.c @@ -61,7 +61,7 @@ extern int _IO_dup2 (int fd, int fd2) __THROW; #ifndef _IO_waitpid #ifdef _LIBC -#define _IO_waitpid waitpid_not_cancel +#define _IO_waitpid __waitpid_nocancel #else #define _IO_waitpid waitpid #endif diff --git a/sysdeps/generic/not-cancel.h b/sysdeps/generic/not-cancel.h index fa7b4d3..6c3afc2 100644 --- a/sysdeps/generic/not-cancel.h +++ b/sysdeps/generic/not-cancel.h @@ -36,7 +36,7 @@ __write (fd, buf, n) #define __writev_nocancel_nostatus(fd, iov, n) \ (void) __writev (fd, iov, n) -# define waitpid_not_cancel(pid, stat_loc, options) \ +# define __waitpid_nocancel(pid, stat_loc, options) \ __waitpid (pid, stat_loc, options) #define pause_not_cancel() \ __pause () diff --git a/sysdeps/unix/sysv/linux/not-cancel.h b/sysdeps/unix/sysv/linux/not-cancel.h index 625bbaa..3047848 100644 --- a/sysdeps/unix/sysv/linux/not-cancel.h +++ b/sysdeps/unix/sysv/linux/not-cancel.h @@ -25,6 +25,7 @@ #include #include #include +#include /* Non cancellable open syscall. */ __typeof (open) __open_nocancel; @@ -73,10 +74,8 @@ __writev_nocancel_nostatus (int fd, const struct iovec *iov, int iovcnt) } /* Uncancelable waitpid. */ -#define __waitpid_nocancel(pid, stat_loc, options) \ - INLINE_SYSCALL (wait4, 4, pid, stat_loc, options, NULL) -#define waitpid_not_cancel(pid, stat_loc, options) \ - __waitpid_nocancel(pid, stat_loc, options) +__typeof (waitpid) __waitpid_nocancel; +libc_hidden_proto (__waitpid_nocancel) /* Uncancelable pause. */ #define pause_not_cancel() \ diff --git a/sysdeps/unix/sysv/linux/waitpid.c b/sysdeps/unix/sysv/linux/waitpid.c index 2fed421..052462d 100644 --- a/sysdeps/unix/sysv/linux/waitpid.c +++ b/sysdeps/unix/sysv/linux/waitpid.c @@ -16,10 +16,12 @@ . */ #include -#include #include #include +#include +#include + __pid_t __waitpid (__pid_t pid, int *stat_loc, int options) { @@ -31,3 +33,14 @@ __waitpid (__pid_t pid, int *stat_loc, int options) } libc_hidden_def (__waitpid) weak_alias (__waitpid, waitpid) + +__pid_t +__waitpid_nocancel (__pid_t pid, int *stat_loc, int options) +{ +#ifdef __NR_waitpid + return INLINE_SYSCALL_CALL (waitpid, pid, stat_loc, options); +#else + return INLINE_SYSCALL_CALL (wait4, pid, stat_loc, options, NULL); +#endif +} +libc_hidden_def (__waitpid_nocancel) From patchwork Tue Jul 4 19:53:49 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 107022 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp1362040qge; Tue, 4 Jul 2017 12:56:08 -0700 (PDT) X-Received: by 10.99.124.16 with SMTP id x16mr17627421pgc.280.1499198168747; Tue, 04 Jul 2017 12:56:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499198168; cv=none; d=google.com; s=arc-20160816; b=GgGL5liKRjR2t/sCmAEjFGBTZHfB2BEj2h0HFEFk6oNeK/HOgUtE6hmDGOaEydCZu1 hvUFcPLTnLocxPF5FlS1blkK2neLuy/ooLp3RpV9OeuCetkJsyUp8K81jGDS9/V679jz WECRWr6no4olyco1OBcHiLijYqtu4S2UD2UY/5W7Dhg80KJdgMTD8JsqnOdH82P04nKS kJFpgl3aziCIpIMskqhPFB2cJiPl3y33qTcVivGBs74aNoGnKVqV5H08qkkn4Lbm+zrA uzaBoT0u/z9/8cQkXGPucxvnYgPzpQ3IM0VMAprdK/alyAeDd/b9qTUwQMAg2DjnVju7 jZlw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:to:from:delivered-to :sender:list-help:list-post:list-archive:list-subscribe :list-unsubscribe:list-id:precedence:mailing-list:dkim-signature :domainkey-signature:arc-authentication-results; bh=p6HG+b6eIzAnjPvTxHDJmJmo5eGstVb1TOBMj0ncJEQ=; b=m5mXtjs5YaLHTkeOghZccTKGH4ek6jE3fgZQ4YZsO6BAGhZCfDD+53uz8GpN0O24Mp eCeagO4g+vfG8fgqmebOUWL3fJ7YF+SXa2vw936jlMKq99NgF1FwoWg7x9GRtfVJa1Dn Ljqo57T1cfkGp9NH12LwKtr0qYb+u6y1WggF0HzeP4SY8vwG/WvyWFdRsTN8cp3RlfHE 8zUJrwMsOFeRAKTdxXgxSLoR5YqkC/0HhrsqGGGfbkYPngEwxuhUud0r6FH0DrhQMzMe L0p+pi+qrHUO3FefIOmEMkmHx9Kr2xe8LJxnX9VQLkVw0ygjnwQIgNYddGcG3Qjn6qmx lGcQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.b=Rpjlo16s; spf=pass (google.com: domain of libc-alpha-return-81671-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-81671-patch=linaro.org@sourceware.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id u192si15064851pgb.46.2017.07.04.12.56.08 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 04 Jul 2017 12:56:08 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-return-81671-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.b=Rpjlo16s; spf=pass (google.com: domain of libc-alpha-return-81671-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-81671-patch=linaro.org@sourceware.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=Zl2RiTCXAqw1LGOCv+D/NcDs8REbUaZ rv8w0GxnX+S8lscAWu4D/1lXbRjMk60ryLbDmzqMtpxVzkcEFxllqryI+Pd6Zuc+ RNyKoQPthZJZedpxRmQC1dxKzsjIqSStPFOuWTHRiWV8oWt0Xn1DXcffmnoW/NAp 6IS4EYTNIurE= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; s=default; bh=eHYnMP9pOVHmoIHXRAx8l4vkJh4=; b=Rpjlo 16spyqBqXVVaZOM5ePCURcpWuXd4kSp01Byj6pqTa/8XyevXwqS14YzAfxT1kkZa ZisSS83YXlRx38BBYZnndCRR7BFSQXxcUjiLhPZYr+GTbuAH7zYv5s5s4uU1EbFc L2Cjck1DCGlz8FpP/ZJMch+Rro3VqtA9ovgm+4= Received: (qmail 74980 invoked by alias); 4 Jul 2017 19:54:25 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 74077 invoked by uid 89); 4 Jul 2017 19:54:18 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.4 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy=suspend X-HELO: mail-qk0-f172.google.com 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:in-reply-to :references; bh=p6HG+b6eIzAnjPvTxHDJmJmo5eGstVb1TOBMj0ncJEQ=; b=ehgksQZ7SaRBQLX/6Gy4bOUqAvxRX/W44O/plAl++Q+PkoP/oipCvHUO0kwZuyWGGS 7RMtN4nYzzM8t5x/MjnzFxzv+W03O3IfCFy4GVO8ZNNfTzFysbtbMbUb6sxEB+SaPRSs vThVUAEOf5RBfVHXopmShazM9x9ZIlHqBvAJZ1V72jiNy8eGLIB0haZOGJ39HFBxe9Uc TzH4pYXm7+03P3RHi6zoKjJ2a6f4TogHfkOs4E05P6ULWhgqc/k5l9brUM19g8aLTibW MmJ4ZKPyvd7IfIgDBgjzf4qdX4M9mlzdHEiVYBwrA15FBRPUX0WDIlFMQTaF4fdFE8Rk ujSw== X-Gm-Message-State: AIVw112O+u4/zFBYSXc3IgKuCDC/G6lpPuvTQL/zreBCdjksqKjVSQfQ a4gFJ2Q/FJWDWhnpMQ7LyA== X-Received: by 10.55.209.139 with SMTP id o11mr2146217qkl.144.1499198054996; Tue, 04 Jul 2017 12:54:14 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH 09/14] Consolidate non cancellable pause call Date: Tue, 4 Jul 2017 16:53:49 -0300 Message-Id: <1499198034-5837-10-git-send-email-adhemerval.zanella@linaro.org> In-Reply-To: <1499198034-5837-1-git-send-email-adhemerval.zanella@linaro.org> References: <1499198034-5837-1-git-send-email-adhemerval.zanella@linaro.org> This patch consolidates all the non cancellable pause calls to use the __pause_nocancel identifier. For non cancellable targets it will be just a macro to call the default respective symbol while on Linux will be a internal one. Checked on x86_64-linux-gnu, x86_64-linux-gnu-x32, and i686-linux-gnu. * nptl/pthread_mutex_lock.c (__pthread_mutex_lock_full): Replace pause_not_cancel with __pause_nocancel. * sysdeps/generic/not-cancel.h (pause_not_cancel): Remove macro. (__pause_nocancel): New macro. * sysdeps/unix/sysv/linux/not-cancel.h (pause_not_cancel): Remove macro. (__pause_nocancel): New prototype. * sysdeps/unix/sysv/linux/pause.c (__pause_nocancel): New function. --- ChangeLog | 9 +++++++++ nptl/pthread_mutex_lock.c | 2 +- sysdeps/generic/not-cancel.h | 2 +- sysdeps/unix/sysv/linux/not-cancel.h | 10 ++-------- sysdeps/unix/sysv/linux/pause.c | 14 +++++++++++++- 5 files changed, 26 insertions(+), 11 deletions(-) -- 2.7.4 diff --git a/nptl/pthread_mutex_lock.c b/nptl/pthread_mutex_lock.c index b76475b..8fa23c6 100644 --- a/nptl/pthread_mutex_lock.c +++ b/nptl/pthread_mutex_lock.c @@ -425,7 +425,7 @@ __pthread_mutex_lock_full (pthread_mutex_t *mutex) /* Delay the thread indefinitely. */ while (1) - pause_not_cancel (); + __pause_nocancel (); } oldval = mutex->__data.__lock; diff --git a/sysdeps/generic/not-cancel.h b/sysdeps/generic/not-cancel.h index 6c3afc2..e80b89a 100644 --- a/sysdeps/generic/not-cancel.h +++ b/sysdeps/generic/not-cancel.h @@ -38,7 +38,7 @@ (void) __writev (fd, iov, n) # define __waitpid_nocancel(pid, stat_loc, options) \ __waitpid (pid, stat_loc, options) -#define pause_not_cancel() \ +#define __pause_nocancel() \ __pause () #define nanosleep_not_cancel(requested_time, remaining) \ __nanosleep (requested_time, remaining) diff --git a/sysdeps/unix/sysv/linux/not-cancel.h b/sysdeps/unix/sysv/linux/not-cancel.h index 3047848..00070fd 100644 --- a/sysdeps/unix/sysv/linux/not-cancel.h +++ b/sysdeps/unix/sysv/linux/not-cancel.h @@ -78,14 +78,8 @@ __typeof (waitpid) __waitpid_nocancel; libc_hidden_proto (__waitpid_nocancel) /* Uncancelable pause. */ -#define pause_not_cancel() \ - ({ sigset_t set; \ - int __rc = INLINE_SYSCALL (rt_sigprocmask, 4, SIG_BLOCK, NULL, &set, \ - _NSIG / 8); \ - if (__rc == 0) \ - __rc = INLINE_SYSCALL (rt_sigsuspend, 2, &set, _NSIG / 8); \ - __rc; \ - }) +__typeof (pause) __pause_nocancel; +libc_hidden_proto (__pause_nocancel) /* Uncancelable nanosleep. */ #define nanosleep_not_cancel(requested_time, remaining) \ diff --git a/sysdeps/unix/sysv/linux/pause.c b/sysdeps/unix/sysv/linux/pause.c index 4ccce9e..ad105d9 100644 --- a/sysdeps/unix/sysv/linux/pause.c +++ b/sysdeps/unix/sysv/linux/pause.c @@ -18,11 +18,12 @@ #include #include + #include +#include /* Suspend the process until a signal arrives. This always returns -1 and sets errno to EINTR. */ - int __libc_pause (void) { @@ -33,3 +34,14 @@ __libc_pause (void) #endif } weak_alias (__libc_pause, pause) + +int +__pause_nocancel (void) +{ +#ifdef __NR_pause + return INLINE_SYSCALL_CALL (pause); +#else + return INLINE_SYSCALL_CALL (ppoll, NULL, 0, NULL, NULL); +#endif +} +libc_hidden_def (__pause_nocancel) From patchwork Tue Jul 4 19:53:50 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 107020 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp1361798qge; Tue, 4 Jul 2017 12:55:48 -0700 (PDT) X-Received: by 10.99.7.129 with SMTP id 123mr17420128pgh.171.1499198148419; Tue, 04 Jul 2017 12:55:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499198148; cv=none; d=google.com; s=arc-20160816; b=A6TnAVfaJ7dnb/n45p2pnfbvbFBXJNPw09BXYL9RRfDADQX3GCyDd7hIjQUBBesEyV QRca+PaSvTXFXbZKjmmVrce18uPZAcr1uVMELU0EwjRFUO4h+hKb2gbfZQhcEGFhbvPZ lVI6MRaJXD/JEFFfJa7GcgXEDq8B9ao8EZyZx+wcNbLtqOKJzoUlh8z+zReb/nQztTi1 Z5qVQxGjBQvhkRLKmKyvmPtVZRiyvzndtWLdzDC9k1U0vytVHoaRKSGMqVAkGYKWFlXk 5Rg9NgLi+YDLFZTwrlh1vJfQWgUc4C7L8VbngUniDaavDX6TFDCTMl+eRWuWs8IShwF1 i9YA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:to:from:delivered-to :sender:list-help:list-post:list-archive:list-subscribe :list-unsubscribe:list-id:precedence:mailing-list:dkim-signature :domainkey-signature:arc-authentication-results; bh=pJZC9Kc/3cOtXC3tgxv5TKdLW28mHJrKi5uU5XSkm0I=; b=nT6rw58Ost3k+e7G/4XowPdzq6X/SyOj+WVksj1MysK8IZaE23ax6L95kqoQQYoVNc p7nKR27vj/xCv+89dPWo0Ws0aBozTDhsrU73LJGeRACYogOVsYGJWPTpHwkWq6Yz4vjs AuOC0FKD4SCN2P4yxx8O87zk6SiMN0Ul9+a2Jv9CCBMFl0gpirfAPlPv0d87gmK13Adb 34SbSG2Hw/uvRaul2xrfjzV/zvS9bJxEBe9ssFtGu+UMUv6eBzCuLn7PHhQaLbEcWuGL xZ7Z9fFBh6mwXh7054P15mm3VFgqvAKevoBO5aXdH/so6tMcdytosizHB6sk4brnFGjA /SDQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.b=ZHgiOhKC; spf=pass (google.com: domain of libc-alpha-return-81669-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-81669-patch=linaro.org@sourceware.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id n34si16329653pld.288.2017.07.04.12.55.48 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 04 Jul 2017 12:55:48 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-return-81669-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.b=ZHgiOhKC; spf=pass (google.com: domain of libc-alpha-return-81669-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-81669-patch=linaro.org@sourceware.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=wKMJO0ZUD3MvU2W3uXHwFee3CDljlsX EfcyKQDOy/fds7LjS8jT6VYvzM8gtGoczCNbDNbc1AQI9qjhcZPCWAmOarfgzcvr eD9/lItThdUE1r8TQ6JjLMyjZoTch/rvfSe5tgbcFgXizP2fE6TuDYG/tqn8zuAR vAw5GJt3W3qA= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; s=default; bh=+cYrZmsnwxQxgYNrtIzAK/2IvVQ=; b=ZHgiO hKCvpRwlOWWuozOV7+1ryD5pAQSxo7Co5Pi6HuelBSd4Z/C9n2aLgZuQ1FCSnCEI ThA3o5/XC+5sGDvcrwIvaECZhSrvU+brwGYLK6DAMiCVT0PR6NpqgzKlsLL2pvFQ oKyKOaX7p69I89gaPQ6PVQs9mrQfnRWNzVJm2k= Received: (qmail 74764 invoked by alias); 4 Jul 2017 19:54:24 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 74288 invoked by uid 89); 4 Jul 2017 19:54:21 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.4 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-qk0-f169.google.com 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:in-reply-to :references; bh=pJZC9Kc/3cOtXC3tgxv5TKdLW28mHJrKi5uU5XSkm0I=; b=j8hy+ix2LCxr7qTCuy9YppwRIVbQuS1Yuz97YzZWbMYikQSQaSiidZeoe1riQj1S92 7yTx6diAfGfHnvBlLc/vezM46P5TJj45lr8tFP84MXToz2vXdR2jCZC/DTWpfYoLzHZO IepjvNpnUQcTCWEnQSijv0xCXyqdRPqgoo5qWNZtWlW1XIpclixyjWSlM1D7G4Zk2Odt /nOKisaiZQ0IsW27zc6yyqznWEDylvNpuAx61kzvYONIVf2u1iEFNNFIh6c4Oqu3qTMx ZyA5s1K+Svd8q+fBKQKGxAPJ24glvAcmeEnm6nSIg0ib40o/whON1PTZNCDIBy5VAd3F EuBA== X-Gm-Message-State: AKS2vOx2UARezvMClVEdXIX1JtDL4GbwHtSS5tpuJeGBnADy4QUFaVT2 fXN5quvByrkBmobLz0+QQw== X-Received: by 10.55.27.136 with SMTP id m8mr46721573qkh.196.1499198056341; Tue, 04 Jul 2017 12:54:16 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH 10/14] Consolidate non cancellable nanosleep call Date: Tue, 4 Jul 2017 16:53:50 -0300 Message-Id: <1499198034-5837-11-git-send-email-adhemerval.zanella@linaro.org> In-Reply-To: <1499198034-5837-1-git-send-email-adhemerval.zanella@linaro.org> References: <1499198034-5837-1-git-send-email-adhemerval.zanella@linaro.org> This patch consolidates all the non cancellable nanosleep calls to use the __nanosleep_nocancel identifier. For non cancellable targets it will be just a macro to call the default respective symbol while on Linux will be a internal one. Checked on x86_64-linux-gnu, x86_64-linux-gnu-x32, and i686-linux-gnu. * nptl/pthread_mutex_timedlock.c (__pthread_mutex_timedlock): Replace nanosleep_not_cancel with __nanosleep_nocancel. * sysdeps/generic/not-cancel.h (nanosleep_not_cancel): Remove macro. (__nanosleep_nocancel): New macro. * sysdeps/unix/sysv/linux/nanosleep.c (__nanosleep_nocancel): New function. * sysdeps/unix/sysv/linux/not-cancel.h (nanosleep_not_cancel): Remove macro. (__nanosleep_nocancel): New prototype. --- ChangeLog | 10 ++++++++++ nptl/pthread_mutex_timedlock.c | 2 +- sysdeps/generic/not-cancel.h | 2 +- sysdeps/unix/sysv/linux/nanosleep.c | 9 +++++++++ sysdeps/unix/sysv/linux/not-cancel.h | 5 +++-- 5 files changed, 24 insertions(+), 4 deletions(-) -- 2.7.4 diff --git a/nptl/pthread_mutex_timedlock.c b/nptl/pthread_mutex_timedlock.c index be53381..c522abe 100644 --- a/nptl/pthread_mutex_timedlock.c +++ b/nptl/pthread_mutex_timedlock.c @@ -429,7 +429,7 @@ __pthread_mutex_timedlock (pthread_mutex_t *mutex, --reltime.tv_sec; } if (reltime.tv_sec >= 0) - while (nanosleep_not_cancel (&reltime, &reltime) != 0) + while (__nanosleep_nocancel (&reltime, &reltime) != 0) continue; return ETIMEDOUT; diff --git a/sysdeps/generic/not-cancel.h b/sysdeps/generic/not-cancel.h index e80b89a..8eb2995 100644 --- a/sysdeps/generic/not-cancel.h +++ b/sysdeps/generic/not-cancel.h @@ -40,7 +40,7 @@ __waitpid (pid, stat_loc, options) #define __pause_nocancel() \ __pause () -#define nanosleep_not_cancel(requested_time, remaining) \ +#define __nanosleep_nocancel(requested_time, remaining) \ __nanosleep (requested_time, remaining) #define sigsuspend_not_cancel(set) \ __sigsuspend (set) diff --git a/sysdeps/unix/sysv/linux/nanosleep.c b/sysdeps/unix/sysv/linux/nanosleep.c index 2d15328..e7ac2c0 100644 --- a/sysdeps/unix/sysv/linux/nanosleep.c +++ b/sysdeps/unix/sysv/linux/nanosleep.c @@ -18,6 +18,7 @@ #include #include +#include /* Pause execution for a number of nanoseconds. */ int @@ -28,3 +29,11 @@ __nanosleep (const struct timespec *requested_time, } hidden_def (__nanosleep) weak_alias (__nanosleep, nanosleep) + +int +__nanosleep_nocancel (const struct timespec *requested_time, + struct timespec *remaining) +{ + return INLINE_SYSCALL_CALL (nanosleep, requested_time, remaining); +} +hidden_def (__nanosleep_nocancel) diff --git a/sysdeps/unix/sysv/linux/not-cancel.h b/sysdeps/unix/sysv/linux/not-cancel.h index 00070fd..9aaa781 100644 --- a/sysdeps/unix/sysv/linux/not-cancel.h +++ b/sysdeps/unix/sysv/linux/not-cancel.h @@ -26,6 +26,7 @@ #include #include #include +#include /* Non cancellable open syscall. */ __typeof (open) __open_nocancel; @@ -82,8 +83,8 @@ __typeof (pause) __pause_nocancel; libc_hidden_proto (__pause_nocancel) /* Uncancelable nanosleep. */ -#define nanosleep_not_cancel(requested_time, remaining) \ - INLINE_SYSCALL (nanosleep, 2, requested_time, remaining) +__typeof (__nanosleep) __nanosleep_nocancel; +hidden_proto (__nanosleep_nocancel) /* Uncancelable sigsuspend. */ #define sigsuspend_not_cancel(set) \ From patchwork Tue Jul 4 19:53:51 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 107023 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp1362104qge; Tue, 4 Jul 2017 12:56:16 -0700 (PDT) X-Received: by 10.98.144.74 with SMTP id a71mr17096670pfe.162.1499198176408; Tue, 04 Jul 2017 12:56:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499198176; cv=none; d=google.com; s=arc-20160816; b=dRHGXbUAYYhSkDtNgMW5sC01TcgKdBUJpaj9BGuTimBblwvOW6dVDQk4LtPPsMODbn u3Q0zzn0bAjMlqvHGosgjISren3Zd0CLcCLnJ+0HtWEumiLayGg4rgeuso/LNPfe0Gkn Ho9jg+U6nMj1cJyNoF3SfCXpBlirp4+bse3/vPD7C94HS4sCYtRJktl46P6elAMnFC9d TPcYVHMnDb6mOxirCNT4tJenyf/EP/5TLUgQC7wSL5a3XeTcf1bWie4dCY6iqSrzXAa1 AXvSh2oN9vHUWAorCYwuO/bk4J6lQ7+d57vhKolZ3sdro7Sei4lq1nooSu6nqDoQk1Qh 0SBA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:to:from:delivered-to :sender:list-help:list-post:list-archive:list-subscribe :list-unsubscribe:list-id:precedence:mailing-list:dkim-signature :domainkey-signature:arc-authentication-results; bh=C89AOZpBPa7mlMjpMqhSOTaArXb359FfqBuiVGYD0Yo=; b=vYgpgTHY+XzXnUu2dE1LvNdgdaO9/PQaTySoeABatnUYfQJfe4GaP3B9c4SYbgDvC8 QXizUd0jVSs23TeFZXhKfc4Da85YuQI2Ir0SmhsXm0nQ9ahnTJvh5AMw7/sw9sVjfWrN 3i9Er3nrKNCp9vf+zywXg5x3SgyXRcnZPKTEhfQ0cbdKpB0N2R/91+CdB5p604EAazL9 4FVb8vEDD1KgARYiAOCyBwWURL/nBXj9BqGzrjL9sX3CZ6eyiDy5W5tOgzhhxB7Y5RZl 6uwdOFsKbWCJSouS0KzrXpfezRLZfFUzBr9RRMIL5TfFPwGDISBqHL2hGtq61B+PJ2lx b3OA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.b=D+nEEUfj; spf=pass (google.com: domain of libc-alpha-return-81672-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-81672-patch=linaro.org@sourceware.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id y13si15445056pgs.486.2017.07.04.12.56.16 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 04 Jul 2017 12:56:16 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-return-81672-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.b=D+nEEUfj; spf=pass (google.com: domain of libc-alpha-return-81672-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-81672-patch=linaro.org@sourceware.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=S/4AOxtbLjok73vKzQk1gqS0vuVkbAW K5zc/1qRPDF4uBbzRoxtYhBfmLSBTxvpX7ruC2FUEkH/pNscN8RhZW+g7SKq6gbi dN0yta1DfvHRpXgrsAWke4S5z3hjtbQgqCaNbXrvQYJQt5/mkX5R9103BH4Am1gQ 4Bk8DFgdTI30= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; s=default; bh=Mc7QjPlUu1KWaocf0eCKoFzm+HQ=; b=D+nEE UfjAIppYilcyo6HlDZmsYCc73cgH5ac7PeO9Iynh2lYuT8mpKzl+OpTybroONeAj j226l09eYw30l3Zk2By5xQ4OdYF7b1e0xMQCyGl0bQlU6KNJTSsHphVB4gbcFHR3 NkUTCES1jj6GXdFu2QoLLflm7fOayOUqoHKFQk= Received: (qmail 75101 invoked by alias); 4 Jul 2017 19:54:26 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 74485 invoked by uid 89); 4 Jul 2017 19:54:22 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.4 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-qt0-f173.google.com 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:in-reply-to :references; bh=C89AOZpBPa7mlMjpMqhSOTaArXb359FfqBuiVGYD0Yo=; b=b+tEKL/2KDtjBOCDHIMbBR7pBfMh/9o12de80ofy3jcAfM9YX/HFfN1lR46LGd2yLy +IcuQyG+AKDZ/8ZzVMwqX5J4SNWq3sCjfmxcFefyTtqjZ5VoP0+k+CFEcy4T9Pgjp6Ti n4y8JFN2skOTwfWjQisYdQ8c/XuO1NvwTd/JJxCkAeVc9Qa/2cbeFMUuyTv79It+zMyl iOQFTCuVD6QCK7VvnepwmNaAHBIHU1B23izPeaYjXhPv1sUKaXfn+VtvERjw7q3+8JPd 4EjfBTpYSGefWmIuU0kbNe7bDth9dFC6PWfKb5ZtDzVPV/A9RRl6lXRUtSZjJTaYJWcx UC7Q== X-Gm-Message-State: AKS2vOycWiADb6sghed5bVkYDZok4nqVZZY8lksNMo8blI+E1/n3CH+A +9HyDaPsncSkklXuzygNIg== X-Received: by 10.237.41.132 with SMTP id o4mr49502415qtd.242.1499198057826; Tue, 04 Jul 2017 12:54:17 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH 11/14] Remove non cancellable sigsuspend definition Date: Tue, 4 Jul 2017 16:53:51 -0300 Message-Id: <1499198034-5837-12-git-send-email-adhemerval.zanella@linaro.org> In-Reply-To: <1499198034-5837-1-git-send-email-adhemerval.zanella@linaro.org> References: <1499198034-5837-1-git-send-email-adhemerval.zanella@linaro.org> There is no current internal usage fo non cancellable sigsuspend calls. Checked on x86_64-linux-gnu, x86_64-linux-gnu-x32, and i686-linux-gnu. * sysdeps/generic/not-cancel.h (sigsuspend_not_cancel): Remove macro. * sysdeps/unix/sysv/linux/not-cancel.h (sigsuspend_not_cancel): Likewise. --- ChangeLog | 5 +++++ sysdeps/generic/not-cancel.h | 2 -- sysdeps/unix/sysv/linux/not-cancel.h | 4 ---- 3 files changed, 5 insertions(+), 6 deletions(-) -- 2.7.4 diff --git a/sysdeps/generic/not-cancel.h b/sysdeps/generic/not-cancel.h index 8eb2995..3418db5 100644 --- a/sysdeps/generic/not-cancel.h +++ b/sysdeps/generic/not-cancel.h @@ -42,7 +42,5 @@ __pause () #define __nanosleep_nocancel(requested_time, remaining) \ __nanosleep (requested_time, remaining) -#define sigsuspend_not_cancel(set) \ - __sigsuspend (set) #define NO_CANCELLATION 1 diff --git a/sysdeps/unix/sysv/linux/not-cancel.h b/sysdeps/unix/sysv/linux/not-cancel.h index 9aaa781..797c925 100644 --- a/sysdeps/unix/sysv/linux/not-cancel.h +++ b/sysdeps/unix/sysv/linux/not-cancel.h @@ -86,8 +86,4 @@ libc_hidden_proto (__pause_nocancel) __typeof (__nanosleep) __nanosleep_nocancel; hidden_proto (__nanosleep_nocancel) -/* Uncancelable sigsuspend. */ -#define sigsuspend_not_cancel(set) \ - INLINE_SYSCALL (rt_sigsuspend, 2, set, _NSIG / 8) - #endif /* NOT_CANCEL_H */ From patchwork Tue Jul 4 19:53:52 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 107025 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp1362283qge; Tue, 4 Jul 2017 12:56:37 -0700 (PDT) X-Received: by 10.98.91.71 with SMTP id p68mr10567123pfb.209.1499198196971; Tue, 04 Jul 2017 12:56:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499198196; cv=none; d=google.com; s=arc-20160816; b=qSqz3h/5VClj9r17aasqhg6srd7iOAOdUe0OVSc7MrT9spLhab7Kz9gwx7Ihu/+1bS JvTiQ4Y7Pg6aeXNFMcv9GXpNHKuK8ffoU8TzUf/nrR4VMYtPNwsja7gmYbxeLaJ/V4yF JExOH23wUVb36zFoTTIaY8+bDOY4c0A1GSp1p5VSv/3lwzs0Jr+Gvs7lXpMpPoqtFF0b ifSmTh4QAxgzoqtAh//w6wL0mrOARo1Ac4Ur9Zx+ZXngzP6MsIEGooryjI50fb/W/Xtn MrfFH7RVbSxyfcRke06U/MqxKomNd0XsOrjsXWcFes8559BoY1UqQaYEFHeoj0ayEWEC 0MdQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :delivered-to:sender:list-help:list-post:list-archive:list-subscribe :list-unsubscribe:list-id:precedence:mailing-list:dkim-signature :domainkey-signature:arc-authentication-results; bh=W24tHI8gG2Z1A1AqEHyvV0EOPPwe0D8zXJ0r7k81zRY=; b=jVN0yHDMutdudzuUz0kQdjS8vqQuQBQOE4yyLwyxyE9YG/OOPc43Ddfacm2XV1tvoH MRb/kXisi9aBI7fDCQsrOsrM1MtgCY1LUXSep2Iorrkj1Xrl4nhyaqJX5pm5Sb163O7J 0tRZct0DBlV6iBSyOjnAqWdb5Ed5JqAOrvAHjO+yUo6SO9ItXANibo3ZE6EDtjOFXiM2 TqYMyioxo4ggjigk+hREeDyyutRti3R97AXKUjithQYCCW8+RJtuMctuKmOgFDcYnnDV sCUSrjXZ71gRXjiWYmvlfnP30SOhtc7d+RllYFcCKVx/kfQmVZiaXdxRLJcpXGOQDbRw g9Qw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.b=Vld92pad; spf=pass (google.com: domain of libc-alpha-return-81674-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-81674-patch=linaro.org@sourceware.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id z44si16483598plh.218.2017.07.04.12.56.36 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 04 Jul 2017 12:56:36 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-return-81674-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.b=Vld92pad; spf=pass (google.com: domain of libc-alpha-return-81674-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-81674-patch=linaro.org@sourceware.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=eepOuFGSucbTCSmVlq0Jz2RC7S0ST6f TQWq/aVfe9Cnk3z29u+VhIEclI5+977e53N4Iore4o5WE/3ruwaHanJ3MTIPp0RQ 3Hezo0fnsSpzdgzunbeXDfZBEnh+Xpby0As1tHsqXElKy3R1wyFcH1ScbGTexCY0 bNyaUXtrKU+4= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id:in-reply-to :references; s=default; bh=saWoEP/iM1iYwytu8+84I31EN9w=; b=Vld92 pad79X2E71J/NuVUYwkDFpbpqDaLppws6ty97TELvA2n6EFopg9YlI295JBX9IM7 xRFKqXsK430vZDjhEB21Ex7Unmqkrsw7HhuCA0Hb5Z1cI7wG5Hyn7rsZfM3fYMKL 4yn/7yOhtd4I5rUppjRsb0v3mLjxwZc+UavbtE= Received: (qmail 75418 invoked by alias); 4 Jul 2017 19:54:27 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 74877 invoked by uid 89); 4 Jul 2017 19:54:25 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.4 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-qk0-f179.google.com X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=W24tHI8gG2Z1A1AqEHyvV0EOPPwe0D8zXJ0r7k81zRY=; b=KQnWoHbvCqw9Tk41EVqGGTIZBOFYBs9VltTmWCY9/vcIkHZPKXnJQnGfkiC+OrY4Cf LXDn73/+SgGe72SjXiXJ4r6nulft9NSGWUD8iA68qdz6Cy3QP8l0FKSlxmUc1IjhE6Zd 1k3llT3xqMluPmuu6q09H2ke1wSdQh2v/zWtO4nSrlTgMmpV6Z6XZecHaGTCe4bs+UYP 7lYhFebIsE8m3XIziFxj/HbUuIzDjL+UjoEYr9FAlx7DjBe3382+E04H6ojM6r4nqa/T y6u5AoB5xsBOtSP9WldtPrvTGofois25uCSd74qKDNkDw9x612o6AFf1DUsG2hSQCHoZ WlAw== X-Gm-Message-State: AKS2vOwmTlHSmsLOibcoVo0hNJEce5O1DBc2rKB6HBZfqC6xikri1EbA NxPsz/N9iFIY5amhfhMZ+A== X-Received: by 10.55.33.80 with SMTP id h77mr45671270qkh.86.1499198059751; Tue, 04 Jul 2017 12:54:19 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Cc: Adhemerval Zanella Subject: [PATCH 12/14] Fix {INLINE,INTERNAL}_SYSCALL macros for x32 Date: Tue, 4 Jul 2017 16:53:52 -0300 Message-Id: <1499198034-5837-13-git-send-email-adhemerval.zanella@linaro.org> In-Reply-To: <1499198034-5837-1-git-send-email-adhemerval.zanella@linaro.org> References: <1499198034-5837-1-git-send-email-adhemerval.zanella@linaro.org> From: Adhemerval Zanella The problem for x32 is the {INTERNAL,INLINE}_SYSCALL C macros explicit cast the arguments to 'long int', thus passing as 32 bits arguments that should be passed to 64 bits. Previous x32 implementation uses the auto-generated syscalls from assembly macros (syscalls.list), so the {INTERNAL,INLINE}_SYSCALL macros are never used with 64 bit argument in x32 (which are internally broken for this ILP). To fix it I used a strategy similar to MIPS64n32 (although both ABI differs for some syscalls on how top pass 64-bits arguments) where argument types for kernel call are defined using GCC extension 'typeof' with a arithmetic operation. This allows 64-bits arguments to be defined while 32-bits argument will still passed as 32-bits. I also cleanup the {INLINE,INTERNAL}_SYSCALL definition by defining 'inline_syscallX' instead of constructing the argument passing using macros (it adds some readability) and removed the ununsed INTERNAL_SYSCALL_NCS_TYPES define (since the patch idea is exactly to avoid requiric explicit types passing). Tested on x86_64 and x32. * sysdeps/unix/sysv/linux/x86_64/sysdep.h (INTERNAL_SYSCALL_NCS_TYPES): Remove define. (LOAD_ARGS_0): Likewise. (LOAD_ARGS_1): Likewise. (LOAD_ARGS_2): Likewise. (LOAD_ARGS_3): Likewise. (LOAD_ARGS_4): Likewise. (LOAD_ARGS_5): Likewise. (LOAD_ARGS_6): Likewise. (LOAD_REGS_0): Likewise. (LOAD_REGS_1): Likewise. (LOAD_REGS_2): Likewise. (LOAD_REGS_3): Likewise. (LOAD_REGS_4): Likewise. (LOAD_REGS_5): Likewise. (LOAD_REGS_6): Likewise. (ASM_ARGS_0): Likewise. (ASM_ARGS_1): Likewise. (ASM_ARGS_2): Likewise. (ASM_ARGS_3): Likewise. (ASM_ARGS_4): Likewise. (ASM_ARGS_5): Likewise. (ASM_ARGS_6): Likewise. (LOAD_ARGS_TYPES_1): Likewise. (LOAD_ARGS_TYPES_2): Likewise. (LOAD_ARGS_TYPES_3): Likewise. (LOAD_ARGS_TYPES_4): Likewise. (LOAD_ARGS_TYPES_5): Likewise. (LOAD_ARGS_TYPES_6): Likewise. (LOAD_REGS_TYPES_1): Likewise. (LOAD_REGS_TYPES_2): Likewise. (LOAD_REGS_TYPES_3): Likewise. (LOAD_REGS_TYPES_4): Likewise. (LOAD_REGS_TYPES_5): Likewise. (LOAD_REGS_TYPES_6): Likewise. (TYPEFY): New define. (ARGIFY): Likewise. (internal_syscall0): Likewise. (internal_syscall1): Likewise. (internal_syscall2): Likewise. (internal_syscall3): Likewise. (internal_syscall4): Likewise. (internal_syscall5): Likewise. (internal_syscall6): Likewise. * sysdeps/unix/sysv/linux/x86_64/x32/times.c (INTERNAL_SYSCALL_NCS): Remove define. (internal_syscall1): Add define. --- ChangeLog | 48 ++++++ sysdeps/unix/sysv/linux/x86_64/sysdep.h | 251 ++++++++++++++++------------- sysdeps/unix/sysv/linux/x86_64/x32/times.c | 24 +-- 3 files changed, 203 insertions(+), 120 deletions(-) -- 2.7.4 diff --git a/sysdeps/unix/sysv/linux/x86_64/sysdep.h b/sysdeps/unix/sysv/linux/x86_64/sysdep.h index 880e496..f299bf2 100644 --- a/sysdeps/unix/sysv/linux/x86_64/sysdep.h +++ b/sysdeps/unix/sysv/linux/x86_64/sysdep.h @@ -221,33 +221,148 @@ /* Registers clobbered by syscall. */ # define REGISTERS_CLOBBERED_BY_SYSCALL "cc", "r11", "cx" -# define INTERNAL_SYSCALL_NCS(name, err, nr, args...) \ - ({ \ - unsigned long int resultvar; \ - LOAD_ARGS_##nr (args) \ - LOAD_REGS_##nr \ - asm volatile ( \ - "syscall\n\t" \ - : "=a" (resultvar) \ - : "0" (name) ASM_ARGS_##nr : "memory", REGISTERS_CLOBBERED_BY_SYSCALL); \ - (long int) resultvar; }) -# undef INTERNAL_SYSCALL -# define INTERNAL_SYSCALL(name, err, nr, args...) \ - INTERNAL_SYSCALL_NCS (__NR_##name, err, nr, ##args) - -# define INTERNAL_SYSCALL_NCS_TYPES(name, err, nr, args...) \ - ({ \ - unsigned long int resultvar; \ - LOAD_ARGS_TYPES_##nr (args) \ - LOAD_REGS_TYPES_##nr (args) \ - asm volatile ( \ - "syscall\n\t" \ - : "=a" (resultvar) \ - : "0" (name) ASM_ARGS_##nr : "memory", REGISTERS_CLOBBERED_BY_SYSCALL); \ - (long int) resultvar; }) -# undef INTERNAL_SYSCALL_TYPES -# define INTERNAL_SYSCALL_TYPES(name, err, nr, args...) \ - INTERNAL_SYSCALL_NCS_TYPES (__NR_##name, err, nr, ##args) +/* Create a variable 'name' based on type 'X' to avoid explicit types. + This is mainly used set use 64-bits arguments in x32. */ +#define TYPEFY(X, name) __typeof__ ((X) - (X)) name +/* Explicit cast the argument to avoid integer from pointer warning on + x32. */ +#define ARGIFY(X) ((__typeof__ ((X) - (X))) (X)) + +#undef INTERNAL_SYSCALL +#define INTERNAL_SYSCALL(name, err, nr, args...) \ + internal_syscall##nr (SYS_ify (name), err, args) + +#undef INTERNAL_SYSCALL_NCS +#define INTERNAL_SYSCALL_NCS(number, err, nr, args...) \ + internal_syscall##nr (number, err, args) + +#undef internal_syscall0 +#define internal_syscall0(number, err, dummy...) \ +({ \ + unsigned long int resultvar; \ + asm volatile ( \ + "syscall\n\t" \ + : "=a" (resultvar) \ + : "0" (number) \ + : "memory", REGISTERS_CLOBBERED_BY_SYSCALL); \ + (long int) resultvar; \ +}) + +#undef internal_syscall1 +#define internal_syscall1(number, err, arg1) \ +({ \ + unsigned long int resultvar; \ + TYPEFY (arg1, __arg1) = ARGIFY (arg1); \ + register TYPEFY (arg1, _a1) asm ("rdi") = __arg1; \ + asm volatile ( \ + "syscall\n\t" \ + : "=a" (resultvar) \ + : "0" (number), "r" (_a1) \ + : "memory", REGISTERS_CLOBBERED_BY_SYSCALL); \ + (long int) resultvar; \ +}) + +#undef internal_syscall2 +#define internal_syscall2(number, err, arg1, arg2) \ +({ \ + unsigned long int resultvar; \ + TYPEFY (arg2, __arg2) = ARGIFY (arg2); \ + TYPEFY (arg1, __arg1) = ARGIFY (arg1); \ + register TYPEFY (arg2, _a2) asm ("rsi") = __arg2; \ + register TYPEFY (arg1, _a1) asm ("rdi") = __arg1; \ + asm volatile ( \ + "syscall\n\t" \ + : "=a" (resultvar) \ + : "0" (number), "r" (_a1), "r" (_a2) \ + : "memory", REGISTERS_CLOBBERED_BY_SYSCALL); \ + (long int) resultvar; \ +}) + +#undef internal_syscall3 +#define internal_syscall3(number, err, arg1, arg2, arg3) \ +({ \ + unsigned long int resultvar; \ + TYPEFY (arg3, __arg3) = ARGIFY (arg3); \ + TYPEFY (arg2, __arg2) = ARGIFY (arg2); \ + TYPEFY (arg1, __arg1) = ARGIFY (arg1); \ + register TYPEFY (arg3, _a3) asm ("rdx") = __arg3; \ + register TYPEFY (arg2, _a2) asm ("rsi") = __arg2; \ + register TYPEFY (arg1, _a1) asm ("rdi") = __arg1; \ + asm volatile ( \ + "syscall\n\t" \ + : "=a" (resultvar) \ + : "0" (number), "r" (_a1), "r" (_a2), "r" (_a3) \ + : "memory", REGISTERS_CLOBBERED_BY_SYSCALL); \ + (long int) resultvar; \ +}) + +#undef internal_syscall4 +#define internal_syscall4(number, err, arg1, arg2, arg3, arg4) \ +({ \ + unsigned long int resultvar; \ + TYPEFY (arg4, __arg4) = ARGIFY (arg4); \ + TYPEFY (arg3, __arg3) = ARGIFY (arg3); \ + TYPEFY (arg2, __arg2) = ARGIFY (arg2); \ + TYPEFY (arg1, __arg1) = ARGIFY (arg1); \ + register TYPEFY (arg4, _a4) asm ("r10") = __arg4; \ + register TYPEFY (arg3, _a3) asm ("rdx") = __arg3; \ + register TYPEFY (arg2, _a2) asm ("rsi") = __arg2; \ + register TYPEFY (arg1, _a1) asm ("rdi") = __arg1; \ + asm volatile ( \ + "syscall\n\t" \ + : "=a" (resultvar) \ + : "0" (number), "r" (_a1), "r" (_a2), "r" (_a3), "r" (_a4) \ + : "memory", REGISTERS_CLOBBERED_BY_SYSCALL); \ + (long int) resultvar; \ +}) + +#undef internal_syscall5 +#define internal_syscall5(number, err, arg1, arg2, arg3, arg4, arg5) \ +({ \ + unsigned long int resultvar; \ + TYPEFY (arg5, __arg5) = ARGIFY (arg5); \ + TYPEFY (arg4, __arg4) = ARGIFY (arg4); \ + TYPEFY (arg3, __arg3) = ARGIFY (arg3); \ + TYPEFY (arg2, __arg2) = ARGIFY (arg2); \ + TYPEFY (arg1, __arg1) = ARGIFY (arg1); \ + register TYPEFY (arg5, _a5) asm ("r8") = __arg5; \ + register TYPEFY (arg4, _a4) asm ("r10") = __arg4; \ + register TYPEFY (arg3, _a3) asm ("rdx") = __arg3; \ + register TYPEFY (arg2, _a2) asm ("rsi") = __arg2; \ + register TYPEFY (arg1, _a1) asm ("rdi") = __arg1; \ + asm volatile ( \ + "syscall\n\t" \ + : "=a" (resultvar) \ + : "0" (number), "r" (_a1), "r" (_a2), "r" (_a3), "r" (_a4), \ + "r" (_a5) \ + : "memory", REGISTERS_CLOBBERED_BY_SYSCALL); \ + (long int) resultvar; \ +}) + +#undef internal_syscall6 +#define internal_syscall6(number, err, arg1, arg2, arg3, arg4, arg5, arg6) \ +({ \ + unsigned long int resultvar; \ + TYPEFY (arg6, __arg6) = ARGIFY (arg6); \ + TYPEFY (arg5, __arg5) = ARGIFY (arg5); \ + TYPEFY (arg4, __arg4) = ARGIFY (arg4); \ + TYPEFY (arg3, __arg3) = ARGIFY (arg3); \ + TYPEFY (arg2, __arg2) = ARGIFY (arg2); \ + TYPEFY (arg1, __arg1) = ARGIFY (arg1); \ + register TYPEFY (arg6, _a6) asm ("r9") = __arg6; \ + register TYPEFY (arg5, _a5) asm ("r8") = __arg5; \ + register TYPEFY (arg4, _a4) asm ("r10") = __arg4; \ + register TYPEFY (arg3, _a3) asm ("rdx") = __arg3; \ + register TYPEFY (arg2, _a2) asm ("rsi") = __arg2; \ + register TYPEFY (arg1, _a1) asm ("rdi") = __arg1; \ + asm volatile ( \ + "syscall\n\t" \ + : "=a" (resultvar) \ + : "0" (number), "r" (_a1), "r" (_a2), "r" (_a3), "r" (_a4), \ + "r" (_a5), "r" (_a6) \ + : "memory", REGISTERS_CLOBBERED_BY_SYSCALL); \ + (long int) resultvar; \ +}) # undef INTERNAL_SYSCALL_ERROR_P # define INTERNAL_SYSCALL_ERROR_P(val, err) \ @@ -261,88 +376,6 @@ # define HAVE_GETTIMEOFDAY_VSYSCALL 1 # define HAVE_GETCPU_VSYSCALL 1 -# define LOAD_ARGS_0() -# define LOAD_REGS_0 -# define ASM_ARGS_0 - -# define LOAD_ARGS_TYPES_1(t1, a1) \ - t1 __arg1 = (t1) (a1); \ - LOAD_ARGS_0 () -# define LOAD_REGS_TYPES_1(t1, a1) \ - register t1 _a1 asm ("rdi") = __arg1; \ - LOAD_REGS_0 -# define ASM_ARGS_1 ASM_ARGS_0, "r" (_a1) -# define LOAD_ARGS_1(a1) \ - LOAD_ARGS_TYPES_1 (long int, a1) -# define LOAD_REGS_1 \ - LOAD_REGS_TYPES_1 (long int, a1) - -# define LOAD_ARGS_TYPES_2(t1, a1, t2, a2) \ - t2 __arg2 = (t2) (a2); \ - LOAD_ARGS_TYPES_1 (t1, a1) -# define LOAD_REGS_TYPES_2(t1, a1, t2, a2) \ - register t2 _a2 asm ("rsi") = __arg2; \ - LOAD_REGS_TYPES_1(t1, a1) -# define ASM_ARGS_2 ASM_ARGS_1, "r" (_a2) -# define LOAD_ARGS_2(a1, a2) \ - LOAD_ARGS_TYPES_2 (long int, a1, long int, a2) -# define LOAD_REGS_2 \ - LOAD_REGS_TYPES_2 (long int, a1, long int, a2) - -# define LOAD_ARGS_TYPES_3(t1, a1, t2, a2, t3, a3) \ - t3 __arg3 = (t3) (a3); \ - LOAD_ARGS_TYPES_2 (t1, a1, t2, a2) -# define LOAD_REGS_TYPES_3(t1, a1, t2, a2, t3, a3) \ - register t3 _a3 asm ("rdx") = __arg3; \ - LOAD_REGS_TYPES_2(t1, a1, t2, a2) -# define ASM_ARGS_3 ASM_ARGS_2, "r" (_a3) -# define LOAD_ARGS_3(a1, a2, a3) \ - LOAD_ARGS_TYPES_3 (long int, a1, long int, a2, long int, a3) -# define LOAD_REGS_3 \ - LOAD_REGS_TYPES_3 (long int, a1, long int, a2, long int, a3) - -# define LOAD_ARGS_TYPES_4(t1, a1, t2, a2, t3, a3, t4, a4) \ - t4 __arg4 = (t4) (a4); \ - LOAD_ARGS_TYPES_3 (t1, a1, t2, a2, t3, a3) -# define LOAD_REGS_TYPES_4(t1, a1, t2, a2, t3, a3, t4, a4) \ - register t4 _a4 asm ("r10") = __arg4; \ - LOAD_REGS_TYPES_3(t1, a2, t2, a2, t3, a3) -# define ASM_ARGS_4 ASM_ARGS_3, "r" (_a4) -# define LOAD_ARGS_4(a1, a2, a3, a4) \ - LOAD_ARGS_TYPES_4 (long int, a1, long int, a2, long int, a3, \ - long int, a4) -# define LOAD_REGS_4 \ - LOAD_REGS_TYPES_4 (long int, a1, long int, a2, long int, a3, \ - long int, a4) - -# define LOAD_ARGS_TYPES_5(t1, a1, t2, a2, t3, a3, t4, a4, t5, a5) \ - t5 __arg5 = (t5) (a5); \ - LOAD_ARGS_TYPES_4 (t1, a1, t2, a2, t3, a3, t4, a4) -# define LOAD_REGS_TYPES_5(t1, a1, t2, a2, t3, a3, t4, a4, t5, a5) \ - register t5 _a5 asm ("r8") = __arg5; \ - LOAD_REGS_TYPES_4 (t1, a1, t2, a2, t3, a3, t4, a4) -# define ASM_ARGS_5 ASM_ARGS_4, "r" (_a5) -# define LOAD_ARGS_5(a1, a2, a3, a4, a5) \ - LOAD_ARGS_TYPES_5 (long int, a1, long int, a2, long int, a3, \ - long int, a4, long int, a5) -# define LOAD_REGS_5 \ - LOAD_REGS_TYPES_5 (long int, a1, long int, a2, long int, a3, \ - long int, a4, long int, a5) - -# define LOAD_ARGS_TYPES_6(t1, a1, t2, a2, t3, a3, t4, a4, t5, a5, t6, a6) \ - t6 __arg6 = (t6) (a6); \ - LOAD_ARGS_TYPES_5 (t1, a1, t2, a2, t3, a3, t4, a4, t5, a5) -# define LOAD_REGS_TYPES_6(t1, a1, t2, a2, t3, a3, t4, a4, t5, a5, t6, a6) \ - register t6 _a6 asm ("r9") = __arg6; \ - LOAD_REGS_TYPES_5 (t1, a1, t2, a2, t3, a3, t4, a4, t5, a5) -# define ASM_ARGS_6 ASM_ARGS_5, "r" (_a6) -# define LOAD_ARGS_6(a1, a2, a3, a4, a5, a6) \ - LOAD_ARGS_TYPES_6 (long int, a1, long int, a2, long int, a3, \ - long int, a4, long int, a5, long int, a6) -# define LOAD_REGS_6 \ - LOAD_REGS_TYPES_6 (long int, a1, long int, a2, long int, a3, \ - long int, a4, long int, a5, long int, a6) - #endif /* __ASSEMBLER__ */ diff --git a/sysdeps/unix/sysv/linux/x86_64/x32/times.c b/sysdeps/unix/sysv/linux/x86_64/x32/times.c index d56106e..8763047 100644 --- a/sysdeps/unix/sysv/linux/x86_64/x32/times.c +++ b/sysdeps/unix/sysv/linux/x86_64/x32/times.c @@ -19,17 +19,19 @@ #include /* Linux times system call returns 64-bit integer. */ -#undef INTERNAL_SYSCALL_NCS -#define INTERNAL_SYSCALL_NCS(name, err, nr, args...) \ - ({ \ - unsigned long long int resultvar; \ - LOAD_ARGS_##nr (args) \ - LOAD_REGS_##nr \ - asm volatile ( \ - "syscall\n\t" \ - : "=a" (resultvar) \ - : "0" (name) ASM_ARGS_##nr : "memory", REGISTERS_CLOBBERED_BY_SYSCALL); \ - (long long int) resultvar; }) +#undef internal_syscall1 +#define internal_syscall1(number, err, arg1) \ +({ \ + unsigned long long int resultvar; \ + TYPEFY (arg1, __arg1) = ARGIFY (arg1); \ + register TYPEFY (arg1, _a1) asm ("rdi") = __arg1; \ + asm volatile ( \ + "syscall\n\t" \ + : "=a" (resultvar) \ + : "0" (number), "r" (_a1) \ + : "memory", REGISTERS_CLOBBERED_BY_SYSCALL); \ + (long long int) resultvar; \ +}) #undef INTERNAL_SYSCALL_ERROR_P #define INTERNAL_SYSCALL_ERROR_P(val, err) \ From patchwork Tue Jul 4 19:53:53 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 107024 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp1362185qge; Tue, 4 Jul 2017 12:56:24 -0700 (PDT) X-Received: by 10.101.86.68 with SMTP id m4mr842116pgs.46.1499198184629; Tue, 04 Jul 2017 12:56:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499198184; cv=none; d=google.com; s=arc-20160816; b=pNWkFBIDdyswKdsMVF6aabKZLCm5PYPqnMI1LgZ8CsIATR5n206lcK69MwqQRVE+mU ofWiushY1SSVvqGQ2wnCvziXEeOJH7GID968IlOL7sbPtAyTPB2B/EbnFoZgl5mO4nM0 NqB84qQD+oeAiJzlBRjTxejKW2GPSYttgWpR5HzsM++7grC41ZwkzxftlDNVKieqnW0W rERmtUtI7MdyHlG0H7vpp8gjKiumk33SG7nqSEn5CI/f4XQn517LZOzo9nvezJxSzZ/j 7vssCbZuDluIyMN1PlMvM0/fnxXG7iC9Y2yAdhIYK5C0rw5pCLijDdP0Dn7hqtvze8bf 492g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:to:from:delivered-to :sender:list-help:list-post:list-archive:list-subscribe :list-unsubscribe:list-id:precedence:mailing-list:dkim-signature :domainkey-signature:arc-authentication-results; bh=cUGmKuv+3LoHzmWHY5wrb8dmtu+ve44CH8yQsayVti8=; b=tkBiJoyftdokszYLgXVxJmWA1cALRhUcsh35BK/ofayXxyrBZY7fWp1ys1vmSkYECs n21ue5O6Xf+rCQERbd355X1eM3Rtr8M7iMdTLvdjSe6qiToBPfJ7UxmWJ5kD8CKBNvp3 2j2nkdSRLKcjMBmaKDTCT2xNC9AO3lp3mj4He1B6sn3sUb4UHa9XrRNXpGsx1iZ/D3CO uEDg1NsP/y7pIHhL9vTGk3rWzWZgOS6m7LsfycC1Y3Ty7KpEyGmnXqTtyeBCYCZMxnv1 6SWpekSU4WOzUefyo8RxTyfLVAFOOU/1UI2/O1Bv1OMQ6nvYc3bLqqQ2tB0PiFINhkBE 1e3A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.b=jpID4UId; spf=pass (google.com: domain of libc-alpha-return-81673-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-81673-patch=linaro.org@sourceware.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id p7si16468487pli.398.2017.07.04.12.56.24 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 04 Jul 2017 12:56:24 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-return-81673-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.b=jpID4UId; spf=pass (google.com: domain of libc-alpha-return-81673-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-81673-patch=linaro.org@sourceware.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=xwQzPL9Naju5On7Syw2zZPP5JDDdbYK 13UI6zx/cE6TWU4wgE3uvD4Jo0p6ZitIc3tkYJMPsSZZ8zVJU9H0DGT3hQFG5fA1 9KU5mxRdhhWo9E2QnzN0EZXOwsgaYhRMJa+5ChbL0pMeBt/DrGZr7bZxZKLd3F5E qrNwW055yV9E= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; s=default; bh=ASyvZwCjU15Ek20wwoMasLKA648=; b=jpID4 UIdHYRNekPEF0RPOU6C1LgkkQjJU1lxmIrKPhpJRTP4TIimUnPEQ1MqlZ20huL8M 92lLh/unbPPyOTXTETO/VQHbDGbwgmKhjCU3LdP3obAnmSbPI2gErs+23UugAvQt 2TFuF47BVTcFK91tPfqonBnKsg6XCO9fHWL1W4= Received: (qmail 75246 invoked by alias); 4 Jul 2017 19:54:26 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 74756 invoked by uid 89); 4 Jul 2017 19:54:24 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.4 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy=personality, Strong X-HELO: mail-qk0-f170.google.com 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:in-reply-to :references; bh=cUGmKuv+3LoHzmWHY5wrb8dmtu+ve44CH8yQsayVti8=; b=Pwrs8CRNN/fx8bPr+2i097Sk/8qHVj2FrWUGXWVsL3wKszbN1JW3FmUcMc1EnWBhMm CFNMCvWmkfWmutpmPrM+DGTXYzkoVOPzuXOtFffBN/oj3c4J6Paa0jbE9VEi946q5s08 CfNhO6m+zOdXFG6cvWLpcVNPUXNJq9pQ2NHMLb3v8baA569gPUQCY00By7gc0jiQ5ZnV GXKX1kRF89zX/swMjZLM/KRF7ccftMqsdw3xp0eAHpO1WyG0IYSiZf/B1Gb//8klGE3T FXomLQUTxCmRSh7zKmXaS0mpaxgDWzQf2BujcpsUlb+0Atf76B+fm2Q6h9HpvP9UXqbl gYMw== X-Gm-Message-State: AIVw113ZtvMYZw8NimsgDMhbvPZcB4SKRpoOH7WlYfbazyc722NiQ6oV hG3gzugNabM84cbNBQa+XQ== X-Received: by 10.55.82.139 with SMTP id g133mr27111436qkb.2.1499198061066; Tue, 04 Jul 2017 12:54:21 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH 13/14] Remove p{read, write}{v} and fallocate from x86 auto-generation list Date: Tue, 4 Jul 2017 16:53:53 -0300 Message-Id: <1499198034-5837-14-git-send-email-adhemerval.zanella@linaro.org> In-Reply-To: <1499198034-5837-1-git-send-email-adhemerval.zanella@linaro.org> References: <1499198034-5837-1-git-send-email-adhemerval.zanella@linaro.org> With {INLINE,INTERNAL}_SYSCALL macros fixed for 64-bits arguments on x32, we can remove the p{read,write}{v} from auto-generation list. Tested on x86_64 and x32. * sysdeps/unix/sysv/linux/x86_64/syscalls.list (pread64): Remove. (preadv64): Likewise. (pwrite64(: Likewise. (pwritev64): Likewise. --- ChangeLog | 5 +++++ sysdeps/unix/sysv/linux/x86_64/syscalls.list | 4 ---- sysdeps/unix/sysv/linux/x86_64/x32/syscalls.list | 1 - 3 files changed, 5 insertions(+), 5 deletions(-) -- 2.7.4 diff --git a/sysdeps/unix/sysv/linux/x86_64/syscalls.list b/sysdeps/unix/sysv/linux/x86_64/syscalls.list index 889193b..d46524e 100644 --- a/sysdeps/unix/sysv/linux/x86_64/syscalls.list +++ b/sysdeps/unix/sysv/linux/x86_64/syscalls.list @@ -2,10 +2,6 @@ arch_prctl EXTRA arch_prctl i:ii __arch_prctl arch_prctl modify_ldt EXTRA modify_ldt i:ipi __modify_ldt modify_ldt -pread64 - pread64 Ci:ipii __libc_pread __libc_pread64 __pread64 pread64 __pread pread -preadv64 - preadv Ci:ipii preadv64 preadv -pwrite64 - pwrite64 Ci:ipii __libc_pwrite __libc_pwrite64 __pwrite64 pwrite64 __pwrite pwrite -pwritev64 - pwritev Ci:ipii pwritev64 pwritev syscall_clock_gettime EXTRA clock_gettime Ei:ip __syscall_clock_gettime diff --git a/sysdeps/unix/sysv/linux/x86_64/x32/syscalls.list b/sysdeps/unix/sysv/linux/x86_64/x32/syscalls.list index a41c8ac..b44f6f9 100644 --- a/sysdeps/unix/sysv/linux/x86_64/x32/syscalls.list +++ b/sysdeps/unix/sysv/linux/x86_64/x32/syscalls.list @@ -1,6 +1,5 @@ # File name Caller Syscall name # args Strong name Weak names -fallocate - fallocate Ci:iiii fallocate fallocate64 gettimeofday - gettimeofday:__vdso_gettimeofday@LINUX_2.6 i:pP __gettimeofday gettimeofday personality EXTRA personality Ei:i __personality personality posix_fadvise64 - fadvise64 Vi:iiii posix_fadvise posix_fadvise64 From patchwork Tue Jul 4 19:53:54 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 107026 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp1362495qge; Tue, 4 Jul 2017 12:56:58 -0700 (PDT) X-Received: by 10.99.147.19 with SMTP id b19mr17458083pge.154.1499198218646; Tue, 04 Jul 2017 12:56:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499198218; cv=none; d=google.com; s=arc-20160816; b=VrWynMytWAQzXHx3vKeX5wxtGdYnKe+PQX+J2SHbRb7zzQFzu0PvHoZu5wWgyDEuNR fYYl7zNZ7wPytGfzumtY+5VfSbIC+nay3NeCH6ICRXGv+4qH3EkX8Su7xyOG0+7IIMtX VUJCIRhvZpCPZqZJOa3KNzytYybRsxjNda43pqZkOZWnRgoE06hC+KFOdPTPV/WJ9pIp KfKk+TbrXj61hKYRLIVKLg87d4m5fnkWTC7isF16s1HlE05EdJbtedjpUGX83OXe7NTQ zN8N1e4NMZ001u4rA0txIluQye7Ya4+9O58cvVz2Mv5WceE5wnN28cCKskC/+9lVM+KQ UpNw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:to:from:delivered-to :sender:list-help:list-post:list-archive:list-subscribe :list-unsubscribe:list-id:precedence:mailing-list:dkim-signature :domainkey-signature:arc-authentication-results; bh=6YfK7CDoOwf3Wq21icDRUYZbxPxSu+SmaauAclxxHJ8=; b=Ea6YyI7vOnIx9GmCfuMcw4cAAMF4OzVvIVL8OFD4//9G0sI32OklvLUB/XPDbzMoWO 1pwnXO/0iWWhN7sx9Go15P9Sy7SnJd6vOMAz6rUEKcgV9GO//uwzlOVkmlcwMV/PmOYG njvwUCEINF2L6iXF7iqYi34WdklX2jJ3ZFCn3uDfho2a9sab31feb5j4yxFgxNqw8dKa d0z5piOlvLtl+PqJR4t4MjLt1a4Z/qOpNo6jSpK77AU9toTovZCU3WaVyuvA/F3IxObv kYGqHovQCTHSIWfx62ccHbgWWNBqwOcdqSR1hgpL91e2gUJH0EM/YO+xPtsc3R7HZoNo 4Eww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.b=ctqPCKvu; spf=pass (google.com: domain of libc-alpha-return-81675-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-81675-patch=linaro.org@sourceware.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id c66si15027605pfc.226.2017.07.04.12.56.58 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 04 Jul 2017 12:56:58 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-return-81675-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.b=ctqPCKvu; spf=pass (google.com: domain of libc-alpha-return-81675-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-81675-patch=linaro.org@sourceware.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=ji69NHnAE1hZvFCRBYehnSxdTB7Qz4X wjGJjYR6S+gESdNo+V4OiiZcXkA8hINfQqWxMn/hVM2ZQ3mugxYmRQllAyFrhmQ0 Eth59l/K71fPr7e6Xk/80vN3f0suiaBJHN1/wNJaspp3M7EVHS5cdvcIWUHaNPEE PGhrUoFw449Q= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; s=default; bh=pq62OPveD8xUnVXA4R9sRtb2fpQ=; b=ctqPC KvujBRKu+P62l5rt3DaOyJL8jPojJIyz3bGCW/Yd3rJAGMhun2UwsGp+Ylx8SPsB WNYiXq6pLqIhoOAr/PutFkFs8n54dTPvqI4m4xJOGxuqUJuHGMpL6tid1W2Lt39h 7daLDORd2oDO8RTxbZGvv3UqbLuFP9JPNB4uBg= Received: (qmail 77735 invoked by alias); 4 Jul 2017 19:54:49 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 77638 invoked by uid 89); 4 Jul 2017 19:54:48 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-27.1 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_LOW, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy=Gas, ldi X-HELO: mail-qt0-f180.google.com 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:in-reply-to :references; bh=6YfK7CDoOwf3Wq21icDRUYZbxPxSu+SmaauAclxxHJ8=; b=GQASOwMZ2eyCfrNssk3uMc0P8fhdyhtqEliWge/4qfdNFV0A4gTMJx/GFoHozMEdva Y246zN0Z2Oo3PlWoN0PwKWXPqkMYveLI/FAqguLcsJ4p0Vr01dT+dh/tSAhl17tl+jk7 aF6LmrbQ/WYRMjiS/GFlYlKAKmbDJYxzf1r/buFymW9dQ/CDi6+LCtHlVWjRtqLb9hjl Cr6d+AUQHRPjgqDy9HW+dDCmLaELU+Nnqy4y9KooVf/gvF/Vct0Vt+XpYT9SnMVtfWWc XGqtqItViSppPWohkl49pnBeRbrrb0cjL4tUE1sU6xNymfvAuQ6QmUh5BebZkMC6ly0P 0RHg== X-Gm-Message-State: AKS2vOyRL3nhy1KPq6Ea7Cq314NSzF+ZkDRYBIMJWNvsCyJ41k2yCv8C akxH/S/2vl3BXExCH6wT+A== X-Received: by 10.237.59.243 with SMTP id s48mr50549091qte.192.1499198062957; Tue, 04 Jul 2017 12:54:22 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH 14/14] Remove cancellation support for syscall generation Date: Tue, 4 Jul 2017 16:53:54 -0300 Message-Id: <1499198034-5837-15-git-send-email-adhemerval.zanella@linaro.org> In-Reply-To: <1499198034-5837-1-git-send-email-adhemerval.zanella@linaro.org> References: <1499198034-5837-1-git-send-email-adhemerval.zanella@linaro.org> This patch removes the cancellation mark from the auto-generation syscall script. Now all the cancellable syscalls are done throught C code using the SYSCALL_CANCEL macro. It simplifies the assembly required to each architecture port, since the SYSCALL_CANCEL uses the already defined INLINE_SYSCALL macros, and allows a more straigh fix on cancellation machanism (since no more specific assembly fixes will be required). Checked on i686-linux-gnu, x86_64-linux-gnu, x86_64-linux-gnux32, aarch64-linux-gnu, arm-linux-gnueabihf, and powerpc64le-linux-gnu. * sysdeps/unix/make-syscalls.sh: Remove cancellable tagging for syscall definitions. * sysdeps/unix/syscall-template.S (SYSCALL_CANCELLABLE): Remove definition. * sysdeps/unix/sysv/linux/aarch64/sysdep-cancel.h (PSEUDO): Remove definition. (PSEUDO_END): Likewise. [IS_IN (libpthread)] (CENABLE): Likewise. [IS_IN (libpthread)] (CDISABLE): Likewise. [IS_IN (libc)] (CENABLE): Likewise. [IS_IN (libc)] (CENABLE): Likewise. [IS_IN (librt)] (CDISABLE): Likewise. [IS_IN (librt)] (CDISABLE): Likewise. [__ASSEMBLER__] (SINGLE_THREAD_P): Likewise. * sysdeps/unix/sysv/linux/alpha/sysdep-cancel.h (PSEUDO): Remove definition. (PSEUDO_END): Likewise. [IS_IN (libpthread)] (__local_enable_asynccancel): Likewise. [IS_IN (libpthread)] (__local_disable_asynccancel): Likewise. [IS_IN (libc)] (__local_enable_asynccancel): Likewise. [IS_IN (libc)] (__local_enable_asynccancel): Likewise. [IS_IN (librt)] (__local_disable_asynccancel): Likewise. [IS_IN (librt)] (__local_disable_asynccancel): Likewise. (CENABLE): Likewise. (CDISABLE): Likewise. [__ASSEMBLER__] (SINGLE_THREAD_P): Likewise. * sysdeps/unix/sysv/linux/arm/sysdep-cancel.h (PSEUDO): Remove defintion. (PSEUDO_END): Likewise. [IS_IN (libpthread)] (CENABLE): Likewise. [IS_IN (libpthread)] (CDISABLE): Likewise. [IS_IN (libc)] (CENABLE): Likewise. [IS_IN (libc)] (CENABLE): Likewise. [IS_IN (librt)] (CDISABLE): Likewise. [IS_IN (librt)] (CDISABLE): Likewise. [__ASSEMBLER__] (SINGLE_THREAD_P): Likewise. * sysdeps/unix/sysv/linux/hppa/sysdep-cancel.h (PSEUDO): Remove definition. (PSEUDO_END): Likewise. [IS_IN (libpthread)] (CENABLE): Likewise. [IS_IN (libpthread)] (CDISABLE): Likewise. [IS_IN (libc)] (CENABLE): Likewise. [IS_IN (libc)] (CENABLE): Likewise. [IS_IN (librt)] (CDISABLE): Likewise. [IS_IN (librt)] (CDISABLE): Likewise. [__ASSEMBLER__] (SINGLE_THREAD_P): Likewise. * sysdeps/unix/sysv/linux/i386/sysdep-cancel.h (PSEUDO): Remove definition. (PSEUDO_END): Likewise. [IS_IN (libpthread)] (CENABLE): Likewise. [IS_IN (libpthread)] (CDISABLE): Likewise. [IS_IN (libc)] (CENABLE): Likewise. [IS_IN (libc)] (CENABLE): Likewise. [IS_IN (librt)] (CDISABLE): Likewise. [IS_IN (librt)] (CDISABLE): Likewise. [__ASSEMBLER__] (SINGLE_THREAD_P): Likewise. * sysdeps/unix/sysv/linux/ia64/sysdep-cancel.h (PSEUDO): Remove definition. (PSEUDO_END): Likewise. [IS_IN (libpthread)] (CENABLE): Likewise. [IS_IN (libpthread)] (CDISABLE): Likewise. [IS_IN (libc)] (CENABLE): Likewise. [IS_IN (libc)] (CENABLE): Likewise. [IS_IN (librt)] (CDISABLE): Likewise. [IS_IN (librt)] (CDISABLE): Likewise. [__ASSEMBLER__] (SINGLE_THREAD_P): Likewise. * sysdeps/unix/sysv/linux/m68k/sysdep-cancel.h (PSEUDO): Remove definition. (PSEUDO_END): Likewise. [IS_IN (libpthread)] (CENABLE): Likewise. [IS_IN (libpthread)] (CDISABLE): Likewise. [IS_IN (libc)] (CENABLE): Likewise. [IS_IN (libc)] (CENABLE): Likewise. [IS_IN (librt)] (CDISABLE): Likewise. [IS_IN (librt)] (CDISABLE): Likewise. [__ASSEMBLER__] (SINGLE_THREAD_P): Likewise. * sysdeps/unix/sysv/linux/microblaze/sysdep-cancel.h (PSEUDO): Remove definition. (PSEUDO_END): Likewise. [IS_IN (libpthread)] (CENABLE): Likewise. [IS_IN (libpthread)] (CDISABLE): Likewise. [IS_IN (libc)] (CENABLE): Likewise. [IS_IN (libc)] (CENABLE): Likewise. [IS_IN (librt)] (CDISABLE): Likewise. [IS_IN (librt)] (CDISABLE): Likewise. [__ASSEMBLER__] (SINGLE_THREAD_P): Likewise. * sysdeps/unix/sysv/linux/mips/mips64/sysdep-cancel.h (PSEUDO): Remove definition. (PSEUDO_END): Likewise. [IS_IN (libpthread)] (CENABLE): Likewise. [IS_IN (libpthread)] (CDISABLE): Likewise. [IS_IN (libc)] (CENABLE): Likewise. [IS_IN (libc)] (CENABLE): Likewise. [IS_IN (librt)] (CDISABLE): Likewise. [IS_IN (librt)] (CDISABLE): Likewise. (SINGLE_THREAD_P): Likewise. * sysdeps/unix/sysv/linux/mips/sysdep-cancel.h (PSEUDO): Remove definition. (PSEUDO_END): Likewise. [IS_IN (libpthread)] (CENABLE): Likewise. [IS_IN (libpthread)] (CDISABLE): Likewise. [IS_IN (libc)] (CENABLE): Likewise. [IS_IN (libc)] (CENABLE): Likewise. [IS_IN (librt)] (CDISABLE): Likewise. [IS_IN (librt)] (CDISABLE): Likewise. [__ASSEMBLER__] (SINGLE_THREAD_P): Likewise. * sysdeps/unix/sysv/linux/nios2/sysdep-cancel.h (PSEUDO): Remove definition. (PSEUDO_END): Likewise. [IS_IN (libpthread)] (CENABLE): Likewise. [IS_IN (libpthread)] (CDISABLE): Likewise. [IS_IN (libc)] (CENABLE): Likewise. [IS_IN (libc)] (CENABLE): Likewise. [IS_IN (librt)] (CDISABLE): Likewise. [IS_IN (librt)] (CDISABLE): Likewise. [__ASSEMBLER__] (SINGLE_THREAD_P): Likewise. * sysdeps/sysv/linux/powerpc/powerpc32/sysdep-cancel.h: Remove file. * sysdeps/sysv/linux/powerpc/powerpc64/sysdep-cancel.h: Likewise. * sysdeps/unix/sysv/linux/powerpc/sysdep-cancel.h: New file. * sysdeps/unix/sysv/linux/s390/s390-32/sysdep-cancel.h (PSEUDO): Remove definition. (PSEUDO_END): Likewise. [IS_IN (libpthread)] (CENABLE): Likewise. [IS_IN (libpthread)] (CDISABLE): Likewise. [IS_IN (libc)] (CENABLE): Likewise. [IS_IN (libc)] (CENABLE): Likewise. [IS_IN (librt)] (CDISABLE): Likewise. [IS_IN (librt)] (CDISABLE): Likewise. [__ASSEMBLER__] (SINGLE_THREAD_P): Likewise. * sysdeps/unix/sysv/linux/s390/s390-64/sysdep-cancel.h (PSEUDO): Remove definition. (PSEUDO_END): Likewise. [IS_IN (libpthread)] (CENABLE): Likewise. [IS_IN (libpthread)] (CDISABLE): Likewise. [IS_IN (libc)] (CENABLE): Likewise. [IS_IN (libc)] (CENABLE): Likewise. [IS_IN (librt)] (CDISABLE): Likewise. [IS_IN (librt)] (CDISABLE): Likewise. [__ASSEMBLER__] (SINGLE_THREAD_P): Likewise. * sysdeps/unix/sysv/linux/sh/sysdep-cancel.h (PSEUDO): Remove definition. (PSEUDO_END): Likewise. [IS_IN (libpthread)] (CENABLE): Likewise. [IS_IN (libpthread)] (CDISABLE): Likewise. [IS_IN (libc)] (CENABLE): Likewise. [IS_IN (libc)] (CENABLE): Likewise. [IS_IN (librt)] (CDISABLE): Likewise. [IS_IN (librt)] (CDISABLE): Likewise. [__ASSEMBLER__] (SINGLE_THREAD_P): Likewise. * sysdeps/unix/sysv/linux/sparc/sparc32/sysdep-cancel.h: Remove file. * sysdeps/unix/sysv/linux/sparc/sparc64/sysdep-cancel.h: Likewise. * sysdeps/unix/sysv/linux/sparc/sysdep-cancel.h: New file. * sysdeps/unix/sysv/linux/tile/sysdep-cancel.h (PSEUDO): Remove definition. (PSEUDO_END): Likewise. [IS_IN (libpthread)] (CENABLE): Likewise. [IS_IN (libpthread)] (CDISABLE): Likewise. [IS_IN (libc)] (CENABLE): Likewise. [IS_IN (libc)] (CENABLE): Likewise. [IS_IN (librt)] (CDISABLE): Likewise. [IS_IN (librt)] (CDISABLE): Likewise. [__ASSEMBLER__] (SINGLE_THREAD_P): Likewise. * sysdeps/unix/sysv/linux/x86_64/sysdep-cancel.h (PSEUDO): Remove definition. (PSEUDO_END): Likewise. [IS_IN (libpthread)] (CENABLE): Likewise. [IS_IN (libpthread)] (CDISABLE): Likewise. [IS_IN (libc)] (CENABLE): Likewise. [IS_IN (libc)] (CENABLE): Likewise. [IS_IN (librt)] (CDISABLE): Likewise. [IS_IN (librt)] (CDISABLE): Likewise. [__ASSEMBLER__] (SINGLE_THREAD_P): Likewise. --- ChangeLog | 173 ++++++++++++++ sysdeps/unix/make-syscalls.sh | 4 - sysdeps/unix/syscall-template.S | 7 +- sysdeps/unix/sysv/linux/aarch64/sysdep-cancel.h | 87 +------ sysdeps/unix/sysv/linux/alpha/sysdep-cancel.h | 131 +---------- sysdeps/unix/sysv/linux/arm/sysdep-cancel.h | 197 +--------------- sysdeps/unix/sysv/linux/hppa/sysdep-cancel.h | 236 +------------------ sysdeps/unix/sysv/linux/i386/sysdep-cancel.h | 119 +--------- sysdeps/unix/sysv/linux/ia64/sysdep-cancel.h | 194 +--------------- sysdeps/unix/sysv/linux/m68k/sysdep-cancel.h | 108 +-------- sysdeps/unix/sysv/linux/microblaze/sysdep-cancel.h | 116 +--------- .../unix/sysv/linux/mips/mips64/sysdep-cancel.h | 249 --------------------- sysdeps/unix/sysv/linux/mips/sysdep-cancel.h | 159 +------------ sysdeps/unix/sysv/linux/nios2/sysdep-cancel.h | 110 +-------- .../sysv/linux/powerpc/powerpc32/sysdep-cancel.h | 118 ---------- .../sysv/linux/powerpc/powerpc64/sysdep-cancel.h | 147 ------------ sysdeps/unix/sysv/linux/powerpc/sysdep-cancel.h | 38 ++++ .../unix/sysv/linux/s390/s390-32/sysdep-cancel.h | 105 +-------- .../unix/sysv/linux/s390/s390-64/sysdep-cancel.h | 109 +-------- sysdeps/unix/sysv/linux/sh/sysdep-cancel.h | 136 +---------- .../unix/sysv/linux/sparc/sparc32/sysdep-cancel.h | 111 --------- .../unix/sysv/linux/sparc/sparc64/sysdep-cancel.h | 109 --------- sysdeps/unix/sysv/linux/sparc/sysdep-cancel.h | 38 ++++ sysdeps/unix/sysv/linux/tile/sysdep-cancel.h | 123 +--------- sysdeps/unix/sysv/linux/x86_64/sysdep-cancel.h | 62 +---- 25 files changed, 305 insertions(+), 2681 deletions(-) delete mode 100644 sysdeps/unix/sysv/linux/mips/mips64/sysdep-cancel.h delete mode 100644 sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep-cancel.h delete mode 100644 sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep-cancel.h create mode 100644 sysdeps/unix/sysv/linux/powerpc/sysdep-cancel.h delete mode 100644 sysdeps/unix/sysv/linux/sparc/sparc32/sysdep-cancel.h delete mode 100644 sysdeps/unix/sysv/linux/sparc/sparc64/sysdep-cancel.h create mode 100644 sysdeps/unix/sysv/linux/sparc/sysdep-cancel.h -- 2.7.4 diff --git a/sysdeps/unix/make-syscalls.sh b/sysdeps/unix/make-syscalls.sh index 123553c..042cfac 100644 --- a/sysdeps/unix/make-syscalls.sh +++ b/sysdeps/unix/make-syscalls.sh @@ -12,7 +12,6 @@ # # Syscall Signature Prefixes: # -# C: cancellable (i.e., this syscall is a cancellation point) # E: errno and return value are not set by the call # V: errno is not set, but errno or zero (success) is returned from the call # @@ -171,11 +170,9 @@ while read file srcfile caller syscall args strong weak; do ;; esac - cancellable=0 noerrno=0 errval=0 case $args in - C*) cancellable=1; args=`echo $args | sed 's/C:\?//'`;; E*) noerrno=1; args=`echo $args | sed 's/E:\?//'`;; V*) errval=1; args=`echo $args | sed 's/V:\?//'`;; esac @@ -258,7 +255,6 @@ while read file srcfile caller syscall args strong weak; do (echo '#define SYSCALL_NAME $syscall'; \\ echo '#define SYSCALL_NARGS $nargs'; \\ echo '#define SYSCALL_SYMBOL $strong'; \\ - echo '#define SYSCALL_CANCELLABLE $cancellable'; \\ echo '#define SYSCALL_NOERRNO $noerrno'; \\ echo '#define SYSCALL_ERRVAL $errval'; \\ echo '#include '; \\" diff --git a/sysdeps/unix/syscall-template.S b/sysdeps/unix/syscall-template.S index 4993ff5..d4584a9 100644 --- a/sysdeps/unix/syscall-template.S +++ b/sysdeps/unix/syscall-template.S @@ -27,7 +27,6 @@ SYSCALL_NAME syscall name SYSCALL_NARGS number of arguments this call takes SYSCALL_SYMBOL primary symbol name - SYSCALL_CANCELLABLE 1 if the call is a cancelation point SYSCALL_NOERRNO 1 to define a no-errno version (see below) SYSCALL_ERRVAL 1 to define an error-value version (see below) @@ -41,11 +40,7 @@ instructions long and the untrained eye might not distinguish them from some compiled code that inexplicably lacks source line information. */ -#if SYSCALL_CANCELLABLE -# include -#else -# include -#endif +#include /* This indirection is needed so that SYMBOL gets macro-expanded. */ #define syscall_hidden_def(SYMBOL) hidden_def (SYMBOL) diff --git a/sysdeps/unix/sysv/linux/aarch64/sysdep-cancel.h b/sysdeps/unix/sysv/linux/aarch64/sysdep-cancel.h index 4be2259..d39b6a2 100644 --- a/sysdeps/unix/sysv/linux/aarch64/sysdep-cancel.h +++ b/sysdeps/unix/sysv/linux/aarch64/sysdep-cancel.h @@ -24,102 +24,23 @@ #if IS_IN (libc) || IS_IN (libpthread) || IS_IN (librt) -# undef PSEUDO -# define PSEUDO(name, syscall_name, args) \ - .section ".text"; \ -ENTRY (__##syscall_name##_nocancel); \ -.Lpseudo_nocancel: \ - DO_CALL (syscall_name, args); \ -.Lpseudo_finish: \ - cmn x0, 4095; \ - b.cs .Lsyscall_error; \ - .subsection 2; \ - .size __##syscall_name##_nocancel,.-__##syscall_name##_nocancel; \ -ENTRY (name); \ - SINGLE_THREAD_P(16); \ - cbz w16, .Lpseudo_nocancel; \ - /* Setup common stack frame no matter the number of args. \ - Also save the first arg, since it's basically free. */ \ - stp x30, x0, [sp, -64]!; \ - cfi_adjust_cfa_offset (64); \ - cfi_rel_offset (x30, 0); \ - DOCARGS_##args; /* save syscall args around CENABLE. */ \ - CENABLE; \ - mov x16, x0; /* save mask around syscall. */ \ - UNDOCARGS_##args; /* restore syscall args. */ \ - DO_CALL (syscall_name, args); \ - str x0, [sp, 8]; /* save result around CDISABLE. */ \ - mov x0, x16; /* restore mask for CDISABLE. */ \ - CDISABLE; \ - /* Break down the stack frame, restoring result at once. */ \ - ldp x30, x0, [sp], 64; \ - cfi_adjust_cfa_offset (-64); \ - cfi_restore (x30); \ - b .Lpseudo_finish; \ - cfi_endproc; \ - .size name, .-name; \ - .previous - -# undef PSEUDO_END -# define PSEUDO_END(name) \ - SYSCALL_ERROR_HANDLER; \ - cfi_endproc - -# define DOCARGS_0 -# define DOCARGS_1 -# define DOCARGS_2 str x1, [sp, 16] -# define DOCARGS_3 stp x1, x2, [sp, 16] -# define DOCARGS_4 DOCARGS_3; str x3, [sp, 32] -# define DOCARGS_5 DOCARGS_3; stp x3, x4, [sp, 32] -# define DOCARGS_6 DOCARGS_5; str x5, [sp, 48] - -# define UNDOCARGS_0 -# define UNDOCARGS_1 ldr x0, [sp, 8] -# define UNDOCARGS_2 ldp x0, x1, [sp, 8] -# define UNDOCARGS_3 UNDOCARGS_1; ldp x1, x2, [sp, 16] -# define UNDOCARGS_4 UNDOCARGS_2; ldp x2, x3, [sp, 24] -# define UNDOCARGS_5 UNDOCARGS_3; ldp x3, x4, [sp, 32] -# define UNDOCARGS_6 UNDOCARGS_4; ldp x4, x5, [sp, 40] - # if IS_IN (libpthread) -# define CENABLE bl __pthread_enable_asynccancel -# define CDISABLE bl __pthread_disable_asynccancel # define __local_multiple_threads __pthread_multiple_threads # elif IS_IN (libc) -# define CENABLE bl __libc_enable_asynccancel -# define CDISABLE bl __libc_disable_asynccancel # define __local_multiple_threads __libc_multiple_threads -# elif IS_IN (librt) -# define CENABLE bl __librt_enable_asynccancel -# define CDISABLE bl __librt_disable_asynccancel -# else -# error Unsupported library # endif # if IS_IN (libpthread) || IS_IN (libc) -# ifndef __ASSEMBLER__ extern int __local_multiple_threads attribute_hidden; -# define SINGLE_THREAD_P __builtin_expect (__local_multiple_threads == 0, 1) -# else -# define SINGLE_THREAD_P(R) \ - adrp x##R, __local_multiple_threads; \ - ldr w##R, [x##R, :lo12:__local_multiple_threads] -# endif +# define SINGLE_THREAD_P __builtin_expect (__local_multiple_threads == 0, 1) # else /* There is no __local_multiple_threads for librt, so use the TCB. */ -# ifndef __ASSEMBLER__ -# define SINGLE_THREAD_P \ +# define SINGLE_THREAD_P \ __builtin_expect (THREAD_GETMEM (THREAD_SELF, \ header.multiple_threads) == 0, 1) -# else -# define SINGLE_THREAD_P(R) \ - mrs x##R, tpidr_el0; \ - sub x##R, x##R, PTHREAD_SIZEOF; \ - ldr w##R, [x##R, PTHREAD_MULTIPLE_THREADS_OFFSET] -# endif # endif -#elif !defined __ASSEMBLER__ +#else /* For rtld, et cetera. */ # define SINGLE_THREAD_P 1 @@ -127,8 +48,6 @@ extern int __local_multiple_threads attribute_hidden; #endif -#ifndef __ASSEMBLER__ # define RTLD_SINGLE_THREAD_P \ __builtin_expect (THREAD_GETMEM (THREAD_SELF, \ header.multiple_threads) == 0, 1) -#endif diff --git a/sysdeps/unix/sysv/linux/alpha/sysdep-cancel.h b/sysdeps/unix/sysv/linux/alpha/sysdep-cancel.h index 66d6962..366cf31 100644 --- a/sysdeps/unix/sysv/linux/alpha/sysdep-cancel.h +++ b/sysdeps/unix/sysv/linux/alpha/sysdep-cancel.h @@ -17,147 +17,24 @@ #include #include -#ifndef __ASSEMBLER__ -# include -#endif +#include #if IS_IN (libc) || IS_IN (libpthread) || IS_IN (librt) -/* ??? Assumes that nothing comes between PSEUDO and PSEUDO_END - besides "ret". */ - -# undef PSEUDO -# define PSEUDO(name, syscall_name, args) \ - .globl __##syscall_name##_nocancel; \ - .type __##syscall_name##_nocancel, @function; \ - .usepv __##syscall_name##_nocancel, std; \ - .align 4; \ - cfi_startproc; \ -__LABEL(__##syscall_name##_nocancel) \ - ldgp gp, 0(pv); \ - PSEUDO_PROF; \ -__LABEL($pseudo_nocancel) \ - PSEUDO_PREPARE_ARGS; \ - lda v0, SYS_ify(syscall_name); \ - call_pal PAL_callsys; \ - bne a3, SYSCALL_ERROR_LABEL; \ -__LABEL($pseudo_ret) \ - .subsection 2; \ - .size __##syscall_name##_nocancel, .-__##syscall_name##_nocancel; \ - .globl name; \ - .type name, @function; \ - .usepv name, std; \ - .align 4; \ - cfi_startproc; \ -__LABEL(name) \ - ldgp gp, 0(pv); \ - PSEUDO_PROF; \ - SINGLE_THREAD_P(t0); \ - beq t0, $pseudo_nocancel; \ - subq sp, 64, sp; \ - cfi_def_cfa_offset(64); \ - stq ra, 0(sp); \ - cfi_offset(ra, -64); \ - SAVE_ARGS_##args; \ - CENABLE; \ - LOAD_ARGS_##args; \ - /* Save the CENABLE return value in RA. That register \ - is preserved across syscall and the real return \ - address is saved on the stack. */ \ - mov v0, ra; \ - lda v0, SYS_ify(syscall_name); \ - call_pal PAL_callsys; \ - stq v0, 8(sp); \ - mov ra, a0; \ - bne a3, $multi_error; \ - CDISABLE; \ - ldq ra, 0(sp); \ - ldq v0, 8(sp); \ - addq sp, 64, sp; \ - cfi_remember_state; \ - cfi_restore(ra); \ - cfi_def_cfa_offset(0); \ - ret; \ - cfi_restore_state; \ -__LABEL($multi_error) \ - CDISABLE; \ - ldq ra, 0(sp); \ - ldq v0, 8(sp); \ - addq sp, 64, sp; \ - cfi_restore(ra); \ - cfi_def_cfa_offset(0); \ - SYSCALL_ERROR_FALLTHRU; \ - SYSCALL_ERROR_HANDLER; \ - cfi_endproc; \ - .previous - -# undef PSEUDO_END -# define PSEUDO_END(sym) \ - cfi_endproc; \ - .subsection 2; \ - .size sym, .-sym - -# define SAVE_ARGS_0 /* Nothing. */ -# define SAVE_ARGS_1 SAVE_ARGS_0; stq a0, 8(sp) -# define SAVE_ARGS_2 SAVE_ARGS_1; stq a1, 16(sp) -# define SAVE_ARGS_3 SAVE_ARGS_2; stq a2, 24(sp) -# define SAVE_ARGS_4 SAVE_ARGS_3; stq a3, 32(sp) -# define SAVE_ARGS_5 SAVE_ARGS_4; stq a4, 40(sp) -# define SAVE_ARGS_6 SAVE_ARGS_5; stq a5, 48(sp) - -# define LOAD_ARGS_0 /* Nothing. */ -# define LOAD_ARGS_1 LOAD_ARGS_0; ldq a0, 8(sp) -# define LOAD_ARGS_2 LOAD_ARGS_1; ldq a1, 16(sp) -# define LOAD_ARGS_3 LOAD_ARGS_2; ldq a2, 24(sp) -# define LOAD_ARGS_4 LOAD_ARGS_3; ldq a3, 32(sp) -# define LOAD_ARGS_5 LOAD_ARGS_4; ldq a4, 40(sp) -# define LOAD_ARGS_6 LOAD_ARGS_5; ldq a5, 48(sp) - # if IS_IN (libpthread) -# define __local_enable_asynccancel __pthread_enable_asynccancel -# define __local_disable_asynccancel __pthread_disable_asynccancel # define __local_multiple_threads __pthread_multiple_threads # elif IS_IN (libc) -# define __local_enable_asynccancel __libc_enable_asynccancel -# define __local_disable_asynccancel __libc_disable_asynccancel # define __local_multiple_threads __libc_multiple_threads -# elif IS_IN (librt) -# define __local_enable_asynccancel __librt_enable_asynccancel -# define __local_disable_asynccancel __librt_disable_asynccancel -# else -# error Unsupported library -# endif - -# ifdef PIC -# define CENABLE bsr ra, __local_enable_asynccancel !samegp -# define CDISABLE bsr ra, __local_disable_asynccancel !samegp -# else -# define CENABLE jsr ra, __local_enable_asynccancel; ldgp ra, 0(gp) -# define CDISABLE jsr ra, __local_disable_asynccancel; ldgp ra, 0(gp) # endif # if IS_IN (libpthread) || IS_IN (libc) -# ifndef __ASSEMBLER__ extern int __local_multiple_threads attribute_hidden; -# define SINGLE_THREAD_P \ +# define SINGLE_THREAD_P \ __builtin_expect (__local_multiple_threads == 0, 1) -# elif defined(PIC) -# define SINGLE_THREAD_P(reg) ldl reg, __local_multiple_threads(gp) !gprel -# else -# define SINGLE_THREAD_P(reg) \ - ldah reg, __local_multiple_threads(gp) !gprelhigh; \ - ldl reg, __local_multiple_threads(reg) !gprellow -# endif # else -# ifndef __ASSEMBLER__ -# define SINGLE_THREAD_P \ +# define SINGLE_THREAD_P \ __builtin_expect (THREAD_GETMEM (THREAD_SELF, \ header.multiple_threads) == 0, 1) -# else -# define SINGLE_THREAD_P(reg) \ - call_pal PAL_rduniq; \ - ldl reg, MULTIPLE_THREADS_OFFSET($0) -# endif # endif #else @@ -167,8 +44,6 @@ extern int __local_multiple_threads attribute_hidden; #endif -#ifndef __ASSEMBLER__ # define RTLD_SINGLE_THREAD_P \ __builtin_expect (THREAD_GETMEM (THREAD_SELF, \ header.multiple_threads) == 0, 1) -#endif diff --git a/sysdeps/unix/sysv/linux/arm/sysdep-cancel.h b/sysdeps/unix/sysv/linux/arm/sysdep-cancel.h index de12acf..738e749 100644 --- a/sysdeps/unix/sysv/linux/arm/sysdep-cancel.h +++ b/sysdeps/unix/sysv/linux/arm/sysdep-cancel.h @@ -23,210 +23,23 @@ #if IS_IN (libc) || IS_IN (libpthread) || IS_IN (librt) -/* NOTE: We do mark syscalls with unwind annotations, for the benefit of - cancellation; but they're really only accurate at the point of the - syscall. The ARM unwind directives are not rich enough without adding - a custom personality function. */ - -# undef PSEUDO -# define PSEUDO(name, syscall_name, args) \ - .text; \ - ENTRY (__##syscall_name##_nocancel); \ - CFI_SECTIONS; \ - DO_CALL (syscall_name, args); \ - cmn r0, $4096; \ - PSEUDO_RET; \ - END (__##syscall_name##_nocancel); \ - ENTRY (name); \ - SINGLE_THREAD_P; \ - DOARGS_##args; \ - bne .Lpseudo_cancel; \ - cfi_remember_state; \ - ldr r7, =SYS_ify (syscall_name); \ - swi 0x0; \ - UNDOARGS_##args; \ - cmn r0, $4096; \ - PSEUDO_RET; \ - cfi_restore_state; \ - .Lpseudo_cancel: \ - .fnstart; /* matched by the .fnend in UNDOARGS below. */ \ - DOCARGS_##args; /* save syscall args etc. around CENABLE. */ \ - CENABLE; \ - mov ip, r0; /* put mask in safe place. */ \ - UNDOCARGS_##args; /* restore syscall args. */ \ - ldr r7, =SYS_ify (syscall_name); \ - swi 0x0; /* do the call. */ \ - mov r7, r0; /* save syscall return value. */ \ - mov r0, ip; /* get mask back. */ \ - CDISABLE; \ - mov r0, r7; /* retrieve return value. */ \ - RESTORE_LR_##args; \ - UNDOARGS_##args; \ - cmn r0, $4096 - -/* DOARGS pushes eight bytes on the stack for five arguments, twelve bytes for - six arguments, and four bytes for fewer. In order to preserve doubleword - alignment, sometimes we must save an extra register. */ - -# define RESTART_UNWIND \ - .fnend; \ - .fnstart; \ - .save {r7}; \ - .save {lr} - -# define DOCARGS_0 \ - .save {r7}; \ - push {lr}; \ - cfi_adjust_cfa_offset (4); \ - cfi_rel_offset (lr, 0); \ - .save {lr} -# define UNDOCARGS_0 -# define RESTORE_LR_0 \ - pop {lr}; \ - cfi_adjust_cfa_offset (-4); \ - cfi_restore (lr) - -# define DOCARGS_1 \ - .save {r7}; \ - push {r0, r1, lr}; \ - cfi_adjust_cfa_offset (12); \ - cfi_rel_offset (lr, 8); \ - .save {lr}; \ - .pad #8 -# define UNDOCARGS_1 \ - ldr r0, [sp], #8; \ - cfi_adjust_cfa_offset (-8); \ - RESTART_UNWIND -# define RESTORE_LR_1 \ - RESTORE_LR_0 - -# define DOCARGS_2 \ - .save {r7}; \ - push {r0, r1, lr}; \ - cfi_adjust_cfa_offset (12); \ - cfi_rel_offset (lr, 8); \ - .save {lr}; \ - .pad #8 -# define UNDOCARGS_2 \ - pop {r0, r1}; \ - cfi_adjust_cfa_offset (-8); \ - RESTART_UNWIND -# define RESTORE_LR_2 \ - RESTORE_LR_0 - -# define DOCARGS_3 \ - .save {r7}; \ - push {r0, r1, r2, r3, lr}; \ - cfi_adjust_cfa_offset (20); \ - cfi_rel_offset (lr, 16); \ - .save {lr}; \ - .pad #16 -# define UNDOCARGS_3 \ - pop {r0, r1, r2, r3}; \ - cfi_adjust_cfa_offset (-16); \ - RESTART_UNWIND -# define RESTORE_LR_3 \ - RESTORE_LR_0 - -# define DOCARGS_4 \ - .save {r7}; \ - push {r0, r1, r2, r3, lr}; \ - cfi_adjust_cfa_offset (20); \ - cfi_rel_offset (lr, 16); \ - .save {lr}; \ - .pad #16 -# define UNDOCARGS_4 \ - pop {r0, r1, r2, r3}; \ - cfi_adjust_cfa_offset (-16); \ - RESTART_UNWIND -# define RESTORE_LR_4 \ - RESTORE_LR_0 - -/* r4 is only stmfd'ed for correct stack alignment. */ -# define DOCARGS_5 \ - .save {r4, r7}; \ - push {r0, r1, r2, r3, r4, lr}; \ - cfi_adjust_cfa_offset (24); \ - cfi_rel_offset (lr, 20); \ - .save {lr}; \ - .pad #20 -# define UNDOCARGS_5 \ - pop {r0, r1, r2, r3}; \ - cfi_adjust_cfa_offset (-16); \ - .fnend; \ - .fnstart; \ - .save {r4, r7}; \ - .save {lr}; \ - .pad #4 -# define RESTORE_LR_5 \ - pop {r4, lr}; \ - cfi_adjust_cfa_offset (-8); \ - /* r4 will be marked as restored later. */ \ - cfi_restore (lr) - -# define DOCARGS_6 \ - .save {r4, r5, r7}; \ - push {r0, r1, r2, r3, lr}; \ - cfi_adjust_cfa_offset (20); \ - cfi_rel_offset (lr, 16); \ - .save {lr}; \ - .pad #16 -# define UNDOCARGS_6 \ - pop {r0, r1, r2, r3}; \ - cfi_adjust_cfa_offset (-16); \ - .fnend; \ - .fnstart; \ - .save {r4, r5, r7}; \ - .save {lr}; -# define RESTORE_LR_6 \ - RESTORE_LR_0 - # if IS_IN (libpthread) -# define CENABLE bl PLTJMP(__pthread_enable_asynccancel) -# define CDISABLE bl PLTJMP(__pthread_disable_asynccancel) # define __local_multiple_threads __pthread_multiple_threads # elif IS_IN (libc) -# define CENABLE bl PLTJMP(__libc_enable_asynccancel) -# define CDISABLE bl PLTJMP(__libc_disable_asynccancel) # define __local_multiple_threads __libc_multiple_threads -# elif IS_IN (librt) -# define CENABLE bl PLTJMP(__librt_enable_asynccancel) -# define CDISABLE bl PLTJMP(__librt_disable_asynccancel) -# else -# error Unsupported library # endif # if IS_IN (libpthread) || IS_IN (libc) -# ifndef __ASSEMBLER__ extern int __local_multiple_threads attribute_hidden; -# define SINGLE_THREAD_P __builtin_expect (__local_multiple_threads == 0, 1) -# else -# define SINGLE_THREAD_P \ - LDST_PCREL(ldr, ip, ip, __local_multiple_threads); \ - teq ip, #0 -# endif +# define SINGLE_THREAD_P __builtin_expect (__local_multiple_threads == 0, 1) # else /* There is no __local_multiple_threads for librt, so use the TCB. */ -# ifndef __ASSEMBLER__ -# define SINGLE_THREAD_P \ +# define SINGLE_THREAD_P \ __builtin_expect (THREAD_GETMEM (THREAD_SELF, \ header.multiple_threads) == 0, 1) -# else -# define SINGLE_THREAD_P \ - push {r0, lr}; \ - cfi_adjust_cfa_offset (8); \ - cfi_rel_offset (lr, 4); \ - GET_TLS (lr); \ - NEGOFF_ADJ_BASE (r0, MULTIPLE_THREADS_OFFSET); \ - ldr ip, NEGOFF_OFF1 (r0, MULTIPLE_THREADS_OFFSET); \ - pop {r0, lr}; \ - cfi_adjust_cfa_offset (-8); \ - cfi_restore (lr); \ - teq ip, #0 -# endif # endif -#elif !defined __ASSEMBLER__ +#else /* For rtld, et cetera. */ # define SINGLE_THREAD_P 1 @@ -234,8 +47,6 @@ extern int __local_multiple_threads attribute_hidden; #endif -#ifndef __ASSEMBLER__ -# define RTLD_SINGLE_THREAD_P \ +#define RTLD_SINGLE_THREAD_P \ __builtin_expect (THREAD_GETMEM (THREAD_SELF, \ header.multiple_threads) == 0, 1) -#endif diff --git a/sysdeps/unix/sysv/linux/hppa/sysdep-cancel.h b/sysdeps/unix/sysv/linux/hppa/sysdep-cancel.h index 5ea2972..a6189a7 100644 --- a/sysdeps/unix/sysv/linux/hppa/sysdep-cancel.h +++ b/sysdeps/unix/sysv/linux/hppa/sysdep-cancel.h @@ -23,226 +23,6 @@ #if IS_IN (libc) || IS_IN (libpthread) || IS_IN (librt) -# ifndef NO_ERROR -# define NO_ERROR -0x1000 -# endif - -/* The syscall cancellation mechanism requires userspace - assistance, the following code does roughly this: - - do arguments (read arg5 and arg6 to registers) - setup frame - - check if there are threads, yes jump to pseudo_cancel - - unthreaded: - syscall - check syscall return (jump to pre_end) - set errno - set return to -1 - (jump to pre_end) - - pseudo_cancel: - cenable - syscall - cdisable - check syscall return (jump to pre_end) - set errno - set return to -1 - - pre_end - restore stack - - It is expected that 'ret' and 'END' macros will - append an 'undo arguments' and 'return' to the - this PSEUDO macro. */ - -# undef PSEUDO -# define PSEUDO(name, syscall_name, args) \ - ENTRY (__##syscall_name##_nocancel) \ - DOARGS_##args ASM_LINE_SEP \ - stwm TREG, 64(%sp) ASM_LINE_SEP \ - .cfi_offset TREG, 0 ASM_LINE_SEP \ - .cfi_adjust_cfa_offset 64 ASM_LINE_SEP \ - stw %sp, -4(%sp) ASM_LINE_SEP \ - .cfi_offset 30, -4 ASM_LINE_SEP \ - stw %r19, -32(%sp) ASM_LINE_SEP \ - .cfi_offset 19, -32 ASM_LINE_SEP \ - /* Save r19 */ ASM_LINE_SEP \ - SAVE_PIC(TREG) ASM_LINE_SEP \ - /* Do syscall, delay loads # */ ASM_LINE_SEP \ - ble 0x100(%sr2,%r0) ASM_LINE_SEP \ - ldi SYS_ify (syscall_name), %r20 /* delay */ ASM_LINE_SEP \ - ldi NO_ERROR,%r1 ASM_LINE_SEP \ - cmpb,>>=,n %r1,%ret0,L(pre_nc_end) ASM_LINE_SEP \ - /* Restore r19 from TREG */ ASM_LINE_SEP \ - LOAD_PIC(TREG) /* delay */ ASM_LINE_SEP \ - SYSCALL_ERROR_HANDLER ASM_LINE_SEP \ - /* Use TREG for temp storage */ ASM_LINE_SEP \ - copy %ret0, TREG /* delay */ ASM_LINE_SEP \ - /* OPTIMIZE: Don't reload r19 */ ASM_LINE_SEP \ - /* do a -1*syscall_ret0 */ ASM_LINE_SEP \ - sub %r0, TREG, TREG ASM_LINE_SEP \ - /* Store into errno location */ ASM_LINE_SEP \ - stw TREG, 0(%sr0,%ret0) ASM_LINE_SEP \ - /* return -1 as error */ ASM_LINE_SEP \ - ldi -1, %ret0 ASM_LINE_SEP \ -L(pre_nc_end): ASM_LINE_SEP \ - /* No need to LOAD_PIC */ ASM_LINE_SEP \ - /* Undo frame */ ASM_LINE_SEP \ - ldwm -64(%sp),TREG ASM_LINE_SEP \ - .cfi_adjust_cfa_offset -64 ASM_LINE_SEP \ - /* Restore rp before exit */ ASM_LINE_SEP \ - ldw -20(%sp), %rp ASM_LINE_SEP \ - .cfi_restore 2 ASM_LINE_SEP \ - ret ASM_LINE_SEP \ - END(__##syscall_name##_nocancel) ASM_LINE_SEP \ - /**********************************************/ASM_LINE_SEP \ - ENTRY (name) \ - DOARGS_##args ASM_LINE_SEP \ - stwm TREG, 64(%sp) ASM_LINE_SEP \ - .cfi_adjust_cfa_offset 64 ASM_LINE_SEP \ - stw %sp, -4(%sp) ASM_LINE_SEP \ - .cfi_offset 30, -4 ASM_LINE_SEP \ - stw %r19, -32(%sp) ASM_LINE_SEP \ - .cfi_offset 19, -32 ASM_LINE_SEP \ - /* Done setting up frame, continue... */ ASM_LINE_SEP \ - SINGLE_THREAD_P ASM_LINE_SEP \ - cmpib,<>,n 0,%ret0,L(pseudo_cancel) ASM_LINE_SEP \ -L(unthreaded): ASM_LINE_SEP \ - /* Save r19 */ ASM_LINE_SEP \ - SAVE_PIC(TREG) ASM_LINE_SEP \ - /* Do syscall, delay loads # */ ASM_LINE_SEP \ - ble 0x100(%sr2,%r0) ASM_LINE_SEP \ - ldi SYS_ify (syscall_name), %r20 /* delay */ ASM_LINE_SEP \ - ldi NO_ERROR,%r1 ASM_LINE_SEP \ - cmpb,>>=,n %r1,%ret0,L(pre_end) ASM_LINE_SEP \ - /* Restore r19 from TREG */ ASM_LINE_SEP \ - LOAD_PIC(TREG) /* delay */ ASM_LINE_SEP \ - SYSCALL_ERROR_HANDLER ASM_LINE_SEP \ - /* Use TREG for temp storage */ ASM_LINE_SEP \ - copy %ret0, TREG /* delay */ ASM_LINE_SEP \ - /* OPTIMIZE: Don't reload r19 */ ASM_LINE_SEP \ - /* do a -1*syscall_ret0 */ ASM_LINE_SEP \ - sub %r0, TREG, TREG ASM_LINE_SEP \ - /* Store into errno location */ ASM_LINE_SEP \ - stw TREG, 0(%sr0,%ret0) ASM_LINE_SEP \ - b L(pre_end) ASM_LINE_SEP \ - /* return -1 as error */ ASM_LINE_SEP \ - ldi -1, %ret0 /* delay */ ASM_LINE_SEP \ -L(pseudo_cancel): ASM_LINE_SEP \ - PUSHARGS_##args /* Save args */ ASM_LINE_SEP \ - /* Save r19 into TREG */ ASM_LINE_SEP \ - CENABLE /* FUNC CALL */ ASM_LINE_SEP \ - SAVE_PIC(TREG) /* delay */ ASM_LINE_SEP \ - /* restore syscall args */ ASM_LINE_SEP \ - POPARGS_##args ASM_LINE_SEP \ - /* save mask from cenable (use stub rp slot) */ ASM_LINE_SEP \ - stw %ret0, -24(%sp) ASM_LINE_SEP \ - /* ... SYSCALL ... */ ASM_LINE_SEP \ - ble 0x100(%sr2,%r0) ASM_LINE_SEP \ - ldi SYS_ify (syscall_name), %r20 /* delay */ ASM_LINE_SEP \ - /* ............... */ ASM_LINE_SEP \ - LOAD_PIC(TREG) ASM_LINE_SEP \ - /* pass mask as arg0 to cdisable */ ASM_LINE_SEP \ - ldw -24(%sp), %r26 ASM_LINE_SEP \ - CDISABLE ASM_LINE_SEP \ - stw %ret0, -24(%sp) /* delay */ ASM_LINE_SEP \ - /* Restore syscall return */ ASM_LINE_SEP \ - ldw -24(%sp), %ret0 ASM_LINE_SEP \ - /* compare error */ ASM_LINE_SEP \ - ldi NO_ERROR,%r1 ASM_LINE_SEP \ - /* branch if no error */ ASM_LINE_SEP \ - cmpb,>>=,n %r1,%ret0,L(pre_end) ASM_LINE_SEP \ - LOAD_PIC(TREG) /* cond. nullify */ ASM_LINE_SEP \ - copy %ret0, TREG /* save syscall return */ ASM_LINE_SEP \ - SYSCALL_ERROR_HANDLER ASM_LINE_SEP \ - /* make syscall res value positive */ ASM_LINE_SEP \ - sub %r0, TREG, TREG /* delay */ ASM_LINE_SEP \ - /* No need to LOAD_PIC */ ASM_LINE_SEP \ - /* store into errno location */ ASM_LINE_SEP \ - stw TREG, 0(%sr0,%ret0) ASM_LINE_SEP \ - /* return -1 */ ASM_LINE_SEP \ - ldi -1, %ret0 ASM_LINE_SEP \ -L(pre_end): ASM_LINE_SEP \ - /* No need to LOAD_PIC */ ASM_LINE_SEP \ - /* Undo frame */ ASM_LINE_SEP \ - ldwm -64(%sp),TREG ASM_LINE_SEP \ - .cfi_adjust_cfa_offset -64 ASM_LINE_SEP \ - /* Restore rp before exit */ ASM_LINE_SEP \ - ldw -20(%sp), %rp ASM_LINE_SEP \ - .cfi_restore 2 ASM_LINE_SEP - -/* Save arguments into our frame */ -# define PUSHARGS_0 /* nothing to do */ -# define PUSHARGS_1 PUSHARGS_0 stw %r26, -36(%sr0,%sp) ASM_LINE_SEP \ - .cfi_offset 26, -36 ASM_LINE_SEP -# define PUSHARGS_2 PUSHARGS_1 stw %r25, -40(%sr0,%sp) ASM_LINE_SEP \ - .cfi_offset 25, -40 ASM_LINE_SEP -# define PUSHARGS_3 PUSHARGS_2 stw %r24, -44(%sr0,%sp) ASM_LINE_SEP \ - .cfi_offset 24, -44 ASM_LINE_SEP -# define PUSHARGS_4 PUSHARGS_3 stw %r23, -48(%sr0,%sp) ASM_LINE_SEP \ - .cfi_offset 23, -48 ASM_LINE_SEP -# define PUSHARGS_5 PUSHARGS_4 stw %r22, -52(%sr0,%sp) ASM_LINE_SEP \ - .cfi_offset 22, -52 ASM_LINE_SEP -# define PUSHARGS_6 PUSHARGS_5 stw %r21, -56(%sr0,%sp) ASM_LINE_SEP \ - .cfi_offset 21, -56 ASM_LINE_SEP - -/* Bring them back from the stack */ -# define POPARGS_0 /* nothing to do */ -# define POPARGS_1 POPARGS_0 ldw -36(%sr0,%sp), %r26 ASM_LINE_SEP \ - .cfi_restore 26 ASM_LINE_SEP -# define POPARGS_2 POPARGS_1 ldw -40(%sr0,%sp), %r25 ASM_LINE_SEP \ - .cfi_restore 25 ASM_LINE_SEP -# define POPARGS_3 POPARGS_2 ldw -44(%sr0,%sp), %r24 ASM_LINE_SEP \ - .cfi_restore 24 ASM_LINE_SEP -# define POPARGS_4 POPARGS_3 ldw -48(%sr0,%sp), %r23 ASM_LINE_SEP \ - .cfi_restore 23 ASM_LINE_SEP -# define POPARGS_5 POPARGS_4 ldw -52(%sr0,%sp), %r22 ASM_LINE_SEP \ - .cfi_restore 22 ASM_LINE_SEP -# define POPARGS_6 POPARGS_5 ldw -56(%sr0,%sp), %r21 ASM_LINE_SEP \ - .cfi_restore 21 ASM_LINE_SEP - -# if IS_IN (libpthread) -# ifdef PIC -# define CENABLE .import __pthread_enable_asynccancel,code ASM_LINE_SEP \ - bl __pthread_enable_asynccancel,%r2 ASM_LINE_SEP -# define CDISABLE .import __pthread_disable_asynccancel,code ASM_LINE_SEP \ - bl __pthread_disable_asynccancel,%r2 ASM_LINE_SEP -# else -# define CENABLE .import __pthread_enable_asynccancel,code ASM_LINE_SEP \ - bl __pthread_enable_asynccancel,%r2 ASM_LINE_SEP -# define CDISABLE .import __pthread_disable_asynccancel,code ASM_LINE_SEP \ - bl __pthread_disable_asynccancel,%r2 ASM_LINE_SEP -# endif -# elif IS_IN (libc) -# ifdef PIC -# define CENABLE .import __libc_enable_asynccancel,code ASM_LINE_SEP \ - bl __libc_enable_asynccancel,%r2 ASM_LINE_SEP -# define CDISABLE .import __libc_disable_asynccancel,code ASM_LINE_SEP \ - bl __libc_disable_asynccancel,%r2 ASM_LINE_SEP -# else -# define CENABLE .import __libc_enable_asynccancel,code ASM_LINE_SEP \ - bl __libc_enable_asynccancel,%r2 ASM_LINE_SEP -# define CDISABLE .import __libc_disable_asynccancel,code ASM_LINE_SEP \ - bl __libc_disable_asynccancel,%r2 ASM_LINE_SEP -# endif -# elif IS_IN (librt) -# ifdef PIC -# define CENABLE .import __librt_enable_asynccancel,code ASM_LINE_SEP \ - bl __librt_enable_asynccancel,%r2 ASM_LINE_SEP -# define CDISABLE .import __librt_disable_asynccancel,code ASM_LINE_SEP \ - bl __librt_disable_asynccancel,%r2 ASM_LINE_SEP -# else -# define CENABLE .import __librt_enable_asynccancel,code ASM_LINE_SEP \ - bl __librt_enable_asynccancel,%r2 ASM_LINE_SEP -# define CDISABLE .import __librt_disable_asynccancel,code ASM_LINE_SEP \ - bl __librt_disable_asynccancel,%r2 ASM_LINE_SEP -# endif -# else -# error Unsupported library -# endif - # if IS_IN (libpthread) # define __local_multiple_threads __pthread_multiple_threads # elif IS_IN (libc) @@ -253,17 +33,11 @@ L(pre_end): ASM_LINE_SEP \ # error Unsupported library # endif -# ifndef __ASSEMBLER__ -# define SINGLE_THREAD_P \ +# define SINGLE_THREAD_P \ __builtin_expect (THREAD_GETMEM (THREAD_SELF, \ header.multiple_threads) == 0, 1) -# else -/* Read the value of header.multiple_threads from the thread pointer */ -# define SINGLE_THREAD_P \ - mfctl %cr27, %ret0 ASM_LINE_SEP \ - ldw MULTIPLE_THREADS_THREAD_OFFSET(%sr0,%ret0),%ret0 ASM_LINE_SEP -# endif -#elif !defined __ASSEMBLER__ + +#else /* This code should never be used but we define it anyhow. */ # define SINGLE_THREAD_P (1) @@ -272,8 +46,6 @@ L(pre_end): ASM_LINE_SEP \ #endif /* IS_IN (libc) || IS_IN (libpthread) || IS_IN (librt) */ -#ifndef __ASSEMBLER__ -# define RTLD_SINGLE_THREAD_P \ +#define RTLD_SINGLE_THREAD_P \ __builtin_expect (THREAD_GETMEM (THREAD_SELF, \ header.multiple_threads) == 0, 1) -#endif diff --git a/sysdeps/unix/sysv/linux/i386/sysdep-cancel.h b/sysdeps/unix/sysv/linux/i386/sysdep-cancel.h index ebf6019..34e2b6f 100644 --- a/sysdeps/unix/sysv/linux/i386/sysdep-cancel.h +++ b/sysdeps/unix/sysv/linux/i386/sysdep-cancel.h @@ -24,130 +24,17 @@ #if IS_IN (libc) || IS_IN (libpthread) || IS_IN (librt) -# undef PSEUDO -# define PSEUDO(name, syscall_name, args) \ - .text; \ - ENTRY (name) \ - cmpl $0, %gs:MULTIPLE_THREADS_OFFSET; \ - jne L(pseudo_cancel); \ - .type __##syscall_name##_nocancel,@function; \ - .globl __##syscall_name##_nocancel; \ - __##syscall_name##_nocancel: \ - DO_CALL (syscall_name, args); \ - cmpl $-4095, %eax; \ - jae SYSCALL_ERROR_LABEL; \ - ret; \ - .size __##syscall_name##_nocancel,.-__##syscall_name##_nocancel; \ - L(pseudo_cancel): \ - CENABLE \ - SAVE_OLDTYPE_##args \ - PUSHCARGS_##args \ - DOCARGS_##args \ - movl $SYS_ify (syscall_name), %eax; \ - ENTER_KERNEL; \ - POPCARGS_##args; \ - POPSTATE_##args \ - cmpl $-4095, %eax; \ - jae SYSCALL_ERROR_LABEL - -# define SAVE_OLDTYPE_0 movl %eax, %ecx; -# define SAVE_OLDTYPE_1 SAVE_OLDTYPE_0 -# define SAVE_OLDTYPE_2 pushl %eax; cfi_adjust_cfa_offset (4); -# define SAVE_OLDTYPE_3 SAVE_OLDTYPE_2 -# define SAVE_OLDTYPE_4 SAVE_OLDTYPE_2 -# define SAVE_OLDTYPE_5 SAVE_OLDTYPE_2 -# define SAVE_OLDTYPE_6 SAVE_OLDTYPE_2 - -# define PUSHCARGS_0 /* No arguments to push. */ -# define DOCARGS_0 /* No arguments to frob. */ -# define POPCARGS_0 /* No arguments to pop. */ -# define _PUSHCARGS_0 /* No arguments to push. */ -# define _POPCARGS_0 /* No arguments to pop. */ - -# define PUSHCARGS_1 movl %ebx, %edx; cfi_register (ebx, edx); PUSHCARGS_0 -# define DOCARGS_1 _DOARGS_1 (4) -# define POPCARGS_1 POPCARGS_0; movl %edx, %ebx; cfi_restore (ebx); -# define _PUSHCARGS_1 pushl %ebx; cfi_adjust_cfa_offset (4); \ - cfi_rel_offset (ebx, 0); _PUSHCARGS_0 -# define _POPCARGS_1 _POPCARGS_0; popl %ebx; \ - cfi_adjust_cfa_offset (-4); cfi_restore (ebx); - -# define PUSHCARGS_2 PUSHCARGS_1 -# define DOCARGS_2 _DOARGS_2 (12) -# define POPCARGS_2 POPCARGS_1 -# define _PUSHCARGS_2 _PUSHCARGS_1 -# define _POPCARGS_2 _POPCARGS_1 - -# define PUSHCARGS_3 _PUSHCARGS_2 -# define DOCARGS_3 _DOARGS_3 (20) -# define POPCARGS_3 _POPCARGS_3 -# define _PUSHCARGS_3 _PUSHCARGS_2 -# define _POPCARGS_3 _POPCARGS_2 - -# define PUSHCARGS_4 _PUSHCARGS_4 -# define DOCARGS_4 _DOARGS_4 (28) -# define POPCARGS_4 _POPCARGS_4 -# define _PUSHCARGS_4 pushl %esi; cfi_adjust_cfa_offset (4); \ - cfi_rel_offset (esi, 0); _PUSHCARGS_3 -# define _POPCARGS_4 _POPCARGS_3; popl %esi; \ - cfi_adjust_cfa_offset (-4); cfi_restore (esi); - -# define PUSHCARGS_5 _PUSHCARGS_5 -# define DOCARGS_5 _DOARGS_5 (36) -# define POPCARGS_5 _POPCARGS_5 -# define _PUSHCARGS_5 pushl %edi; cfi_adjust_cfa_offset (4); \ - cfi_rel_offset (edi, 0); _PUSHCARGS_4 -# define _POPCARGS_5 _POPCARGS_4; popl %edi; \ - cfi_adjust_cfa_offset (-4); cfi_restore (edi); - -# define PUSHCARGS_6 _PUSHCARGS_6 -# define DOCARGS_6 _DOARGS_6 (44) -# define POPCARGS_6 _POPCARGS_6 -# define _PUSHCARGS_6 pushl %ebp; cfi_adjust_cfa_offset (4); \ - cfi_rel_offset (ebp, 0); _PUSHCARGS_5 -# define _POPCARGS_6 _POPCARGS_5; popl %ebp; \ - cfi_adjust_cfa_offset (-4); cfi_restore (ebp); - -# if IS_IN (libpthread) -# define CENABLE call __pthread_enable_asynccancel; -# define CDISABLE call __pthread_disable_asynccancel -# elif IS_IN (libc) -# define CENABLE call __libc_enable_asynccancel; -# define CDISABLE call __libc_disable_asynccancel -# elif IS_IN (librt) -# define CENABLE call __librt_enable_asynccancel; -# define CDISABLE call __librt_disable_asynccancel -# else -# error Unsupported library -# endif -# define POPSTATE_0 \ - pushl %eax; cfi_adjust_cfa_offset (4); movl %ecx, %eax; \ - CDISABLE; popl %eax; cfi_adjust_cfa_offset (-4); -# define POPSTATE_1 POPSTATE_0 -# define POPSTATE_2 xchgl (%esp), %eax; CDISABLE; popl %eax; \ - cfi_adjust_cfa_offset (-4); -# define POPSTATE_3 POPSTATE_2 -# define POPSTATE_4 POPSTATE_3 -# define POPSTATE_5 POPSTATE_4 -# define POPSTATE_6 POPSTATE_5 - -# ifndef __ASSEMBLER__ -# define SINGLE_THREAD_P \ +# define SINGLE_THREAD_P \ __builtin_expect (THREAD_GETMEM (THREAD_SELF, \ header.multiple_threads) == 0, 1) -# else -# define SINGLE_THREAD_P cmpl $0, %gs:MULTIPLE_THREADS_OFFSET -# endif -#elif !defined __ASSEMBLER__ +#else # define SINGLE_THREAD_P (1) # define NO_CANCELLATION 1 #endif -#ifndef __ASSEMBLER__ -# define RTLD_SINGLE_THREAD_P \ +#define RTLD_SINGLE_THREAD_P \ __builtin_expect (THREAD_GETMEM (THREAD_SELF, \ header.multiple_threads) == 0, 1) -#endif diff --git a/sysdeps/unix/sysv/linux/ia64/sysdep-cancel.h b/sysdeps/unix/sysv/linux/ia64/sysdep-cancel.h index 7c7f619..96d04de 100644 --- a/sysdeps/unix/sysv/linux/ia64/sysdep-cancel.h +++ b/sysdeps/unix/sysv/linux/ia64/sysdep-cancel.h @@ -23,201 +23,13 @@ #endif #if IS_IN (libc) || IS_IN (libpthread) || IS_IN (librt) - -# undef PSEUDO - -# if IS_IN (libc) -# define SYSDEP_CANCEL_ERRNO __libc_errno -# else -# define SYSDEP_CANCEL_ERRNO errno -# endif -# define SYSDEP_CANCEL_ERROR(args) \ -.section .gnu.linkonce.t.__syscall_error_##args, "ax"; \ - .align 32; \ - .proc __syscall_error_##args; \ - .global __syscall_error_##args; \ - .hidden __syscall_error_##args; \ - .size __syscall_error_##args, 64; \ -__syscall_error_##args: \ - .prologue; \ - .regstk args, 5, args, 0; \ - .save ar.pfs, loc0; \ - .save rp, loc1; \ - .body; \ - addl loc4 = @ltoff(@tprel(SYSDEP_CANCEL_ERRNO)), gp;; \ - ld8 loc4 = [loc4]; \ - mov rp = loc1;; \ - mov r8 = -1; \ - add loc4 = loc4, r13;; \ - st4 [loc4] = loc3; \ - mov ar.pfs = loc0 - -# ifndef USE_DL_SYSINFO - -# define PSEUDO(name, syscall_name, args) \ -.text; \ -ENTRY (name) \ - adds r14 = MULTIPLE_THREADS_OFFSET, r13;; \ - ld4 r14 = [r14]; \ - mov r15 = SYS_ify(syscall_name);; \ - cmp4.ne p6, p7 = 0, r14; \ -(p6) br.cond.spnt .Lpseudo_cancel;; \ - break __BREAK_SYSCALL;; \ - cmp.eq p6,p0=-1,r10; \ -(p6) br.cond.spnt.few __syscall_error; \ - ret;; \ - .endp name; \ - .proc __GC_##name; \ - .globl __GC_##name; \ - .hidden __GC_##name; \ -__GC_##name: \ -.Lpseudo_cancel: \ - .prologue; \ - .regstk args, 5, args, 0; \ - .save ar.pfs, loc0; \ - alloc loc0 = ar.pfs, args, 5, args, 0; \ - .save rp, loc1; \ - mov loc1 = rp;; \ - .body; \ - CENABLE;; \ - mov loc2 = r8; \ - COPY_ARGS_##args \ - mov r15 = SYS_ify(syscall_name); \ - break __BREAK_SYSCALL;; \ - mov loc3 = r8; \ - mov loc4 = r10; \ - mov out0 = loc2; \ - CDISABLE;; \ - cmp.eq p6,p0=-1,loc4; \ -(p6) br.cond.spnt.few __syscall_error_##args; \ - mov r8 = loc3; \ - mov rp = loc1; \ - mov ar.pfs = loc0; \ -.Lpseudo_end: \ - ret; \ - .endp __GC_##name; \ - SYSDEP_CANCEL_ERROR(args) - -# else /* USE_DL_SYSINFO */ - -# define PSEUDO(name, syscall_name, args) \ -.text; \ -ENTRY (name) \ - .prologue; \ - adds r2 = SYSINFO_OFFSET, r13; \ - adds r14 = MULTIPLE_THREADS_OFFSET, r13; \ - .save ar.pfs, r11; \ - mov r11 = ar.pfs;; \ - .body; \ - ld4 r14 = [r14]; \ - ld8 r2 = [r2]; \ - mov r15 = SYS_ify(syscall_name);; \ - cmp4.ne p6, p7 = 0, r14; \ - mov b7 = r2; \ -(p6) br.cond.spnt .Lpseudo_cancel; \ - br.call.sptk.many b6 = b7;; \ - mov ar.pfs = r11; \ - cmp.eq p6,p0 = -1, r10; \ -(p6) br.cond.spnt.few __syscall_error; \ - ret;; \ - .endp name; \ - \ - .proc __##syscall_name##_nocancel; \ - .globl __##syscall_name##_nocancel; \ -__##syscall_name##_nocancel: \ - .prologue; \ - adds r2 = SYSINFO_OFFSET, r13; \ - .save ar.pfs, r11; \ - mov r11 = ar.pfs;; \ - .body; \ - ld8 r2 = [r2]; \ - mov r15 = SYS_ify(syscall_name);; \ - mov b7 = r2; \ - br.call.sptk.many b6 = b7;; \ - mov ar.pfs = r11; \ - cmp.eq p6,p0 = -1, r10; \ -(p6) br.cond.spnt.few __syscall_error; \ - ret;; \ - .endp __##syscall_name##_nocancel; \ - \ - .proc __GC_##name; \ - .globl __GC_##name; \ - .hidden __GC_##name; \ -__GC_##name: \ -.Lpseudo_cancel: \ - .prologue; \ - .regstk args, 5, args, 0; \ - .save ar.pfs, loc0; \ - alloc loc0 = ar.pfs, args, 5, args, 0; \ - adds loc4 = SYSINFO_OFFSET, r13; \ - .save rp, loc1; \ - mov loc1 = rp;; \ - .body; \ - ld8 loc4 = [loc4]; \ - CENABLE;; \ - mov loc2 = r8; \ - mov b7 = loc4; \ - COPY_ARGS_##args \ - mov r15 = SYS_ify(syscall_name); \ - br.call.sptk.many b6 = b7;; \ - mov loc3 = r8; \ - mov loc4 = r10; \ - mov out0 = loc2; \ - CDISABLE;; \ - cmp.eq p6,p0=-1,loc4; \ -(p6) br.cond.spnt.few __syscall_error_##args; \ - mov r8 = loc3; \ - mov rp = loc1; \ - mov ar.pfs = loc0; \ -.Lpseudo_end: \ - ret; \ - .endp __GC_##name; \ - SYSDEP_CANCEL_ERROR(args) - -# endif /* USE_DL_SYSINFO */ - -# undef PSEUDO_END -# define PSEUDO_END(name) .endp - -# if IS_IN (libpthread) -# define CENABLE br.call.sptk.many b0 = __pthread_enable_asynccancel -# define CDISABLE br.call.sptk.many b0 = __pthread_disable_asynccancel -# elif IS_IN (libc) -# define CENABLE br.call.sptk.many b0 = __libc_enable_asynccancel -# define CDISABLE br.call.sptk.many b0 = __libc_disable_asynccancel -# elif IS_IN (librt) -# define CENABLE br.call.sptk.many b0 = __librt_enable_asynccancel -# define CDISABLE br.call.sptk.many b0 = __librt_disable_asynccancel -# else -# error Unsupported library -# endif - -# define COPY_ARGS_0 /* Nothing */ -# define COPY_ARGS_1 COPY_ARGS_0 mov out0 = in0; -# define COPY_ARGS_2 COPY_ARGS_1 mov out1 = in1; -# define COPY_ARGS_3 COPY_ARGS_2 mov out2 = in2; -# define COPY_ARGS_4 COPY_ARGS_3 mov out3 = in3; -# define COPY_ARGS_5 COPY_ARGS_4 mov out4 = in4; -# define COPY_ARGS_6 COPY_ARGS_5 mov out5 = in5; -# define COPY_ARGS_7 COPY_ARGS_6 mov out6 = in6; - -# ifndef __ASSEMBLER__ -# define SINGLE_THREAD_P \ +# define SINGLE_THREAD_P \ __builtin_expect (THREAD_GETMEM (THREAD_SELF, header.multiple_threads) == 0, 1) -# else -# define SINGLE_THREAD_P \ - adds r14 = MULTIPLE_THREADS_OFFSET, r13 ;; ld4 r14 = [r14] ;; cmp4.ne p6, p7 = 0, r14 -# endif - -#elif !defined __ASSEMBLER__ - +#else # define SINGLE_THREAD_P (1) # define NO_CANCELLATION 1 - #endif -#ifndef __ASSEMBLER__ -# define RTLD_SINGLE_THREAD_P \ +#define RTLD_SINGLE_THREAD_P \ __builtin_expect (THREAD_GETMEM (THREAD_SELF, \ header.multiple_threads) == 0, 1) -#endif diff --git a/sysdeps/unix/sysv/linux/m68k/sysdep-cancel.h b/sysdeps/unix/sysv/linux/m68k/sysdep-cancel.h index 9bc9e13..1603c5f 100644 --- a/sysdeps/unix/sysv/linux/m68k/sysdep-cancel.h +++ b/sysdeps/unix/sysv/linux/m68k/sysdep-cancel.h @@ -18,121 +18,21 @@ #include #include -#ifndef __ASSEMBLER__ -# include -#endif +#include #if IS_IN (libc) || IS_IN (libpthread) || IS_IN (librt) -# undef PSEUDO -# define PSEUDO(name, syscall_name, args) \ - .text; \ - ENTRY (name) \ - SINGLE_THREAD_P; \ - jne .Lpseudo_cancel; \ - .type __##syscall_name##_nocancel,@function; \ - .globl __##syscall_name##_nocancel; \ - __##syscall_name##_nocancel: \ - DO_CALL (syscall_name, args); \ - cmp.l &-4095, %d0; \ - jcc SYSCALL_ERROR_LABEL; \ - rts; \ - .size __##syscall_name##_nocancel,.-__##syscall_name##_nocancel; \ - .Lpseudo_cancel: \ - CENABLE; \ - DOCARGS_##args \ - move.l %d0, -(%sp); /* Save result of CENABLE. */ \ - cfi_adjust_cfa_offset (4); \ - move.l &SYS_ify (syscall_name), %d0; \ - trap &0; \ - move.l %d0, %d2; \ - CDISABLE; \ - addq.l &4, %sp; /* Remove result of CENABLE from the stack. */ \ - cfi_adjust_cfa_offset (-4); \ - move.l %d2, %d0; \ - UNDOCARGS_##args \ - cmp.l &-4095, %d0; \ - jcc SYSCALL_ERROR_LABEL - -/* Note: we use D2 to save syscall's return value as D0 will be clobbered in - CDISABLE. */ -# define DOCARGS_0 move.l %d2, -(%sp); \ - cfi_adjust_cfa_offset (4); cfi_rel_offset (%d2, 0); -# define UNDOCARGS_0 move.l (%sp)+, %d2; \ - cfi_adjust_cfa_offset (-4); cfi_restore (%d2); - -# define DOCARGS_1 _DOCARGS_1 (4); DOCARGS_0 -# define _DOCARGS_1(n) move.l n(%sp), %d1; -# define UNDOCARGS_1 UNDOCARGS_0 - -# define DOCARGS_2 _DOCARGS_2 (8) -# define _DOCARGS_2(n) DOCARGS_0 move.l n+4(%sp), %d2; _DOCARGS_1 (n) -# define UNDOCARGS_2 UNDOCARGS_0 - -# define DOCARGS_3 _DOCARGS_3 (12) -# define _DOCARGS_3(n) move.l %d3, -(%sp); \ - cfi_adjust_cfa_offset (4); cfi_rel_offset (%d3, 0); \ - move.l n+4(%sp), %d3; _DOCARGS_2 (n) -# define UNDOCARGS_3 UNDOCARGS_2 move.l (%sp)+, %d3; \ - cfi_adjust_cfa_offset (-4); cfi_restore (%d3); - -# define DOCARGS_4 _DOCARGS_4 (16) -# define _DOCARGS_4(n) move.l %d4, -(%sp); \ - cfi_adjust_cfa_offset (4); cfi_rel_offset (%d4, 0); \ - move.l n+4(%sp), %d4; _DOCARGS_3 (n) -# define UNDOCARGS_4 UNDOCARGS_3 move.l (%sp)+, %d4; \ - cfi_adjust_cfa_offset (-4); cfi_restore (%d4); - -# define DOCARGS_5 _DOCARGS_5 (20) -# define _DOCARGS_5(n) move.l %d5, -(%sp); \ - cfi_adjust_cfa_offset (4); cfi_rel_offset (%d5, 0); \ - move.l n+4(%sp), %d5; _DOCARGS_4 (n) -# define UNDOCARGS_5 UNDOCARGS_4 move.l (%sp)+, %d5; \ - cfi_adjust_cfa_offset (-4); cfi_restore (%d5); - -# define DOCARGS_6 _DOCARGS_6 (24) -# define _DOCARGS_6(n) move.l n(%sp), %a0; _DOCARGS_5 (n-4) -# define UNDOCARGS_6 UNDOCARGS_5 - -# ifdef PIC -# define PSEUDO_JMP(sym) jbsr sym ## @PLTPC -# else -# define PSEUDO_JMP(sym) jbsr sym -# endif - -# if IS_IN (libpthread) -# define CENABLE PSEUDO_JMP (__pthread_enable_asynccancel) -# define CDISABLE PSEUDO_JMP (__pthread_disable_asynccancel) -# elif IS_IN (libc) -# define CENABLE PSEUDO_JMP (__libc_enable_asynccancel) -# define CDISABLE PSEUDO_JMP (__libc_disable_asynccancel) -# elif IS_IN (librt) -# define CENABLE PSEUDO_JMP (__librt_enable_asynccancel) -# define CDISABLE PSEUDO_JMP (__librt_disable_asynccancel) -# else -# error Unsupported library -# endif - -# ifndef __ASSEMBLER__ -# define SINGLE_THREAD_P \ +# define SINGLE_THREAD_P \ __builtin_expect (THREAD_GETMEM (THREAD_SELF, \ header.multiple_threads) == 0, 1) -# else -# define SINGLE_THREAD_P \ - PSEUDO_JMP (__m68k_read_tp); \ - tst.l MULTIPLE_THREADS_OFFSET(%a0) -# endif - -#elif !defined __ASSEMBLER__ +#else # define SINGLE_THREAD_P (1) # define NO_CANCELLATION (1) #endif -#ifndef __ASSEMBLER__ -# define RTLD_SINGLE_THREAD_P \ +#define RTLD_SINGLE_THREAD_P \ __builtin_expect (THREAD_GETMEM (THREAD_SELF, \ header.multiple_threads) == 0, \ 1) -#endif diff --git a/sysdeps/unix/sysv/linux/microblaze/sysdep-cancel.h b/sysdeps/unix/sysv/linux/microblaze/sysdep-cancel.h index dbcc2b2..7fe030b 100644 --- a/sysdeps/unix/sysv/linux/microblaze/sysdep-cancel.h +++ b/sysdeps/unix/sysv/linux/microblaze/sysdep-cancel.h @@ -23,136 +23,28 @@ #if IS_IN (libc) || IS_IN (libpthread) || IS_IN (librt) -# if !IS_IN (librt) || !defined(PIC) -# define AC_STACK_SIZE 16 /* space for r15, async_cancel arg and 2 temp words */ -# define AC_SET_GOT /* empty */ -# define AC_RESTORE_GOT /* empty */ -# else -# define AC_STACK_SIZE 20 /* extra 4 bytes for r20 */ -# define AC_SET_GOT \ - swi r20, r1, AC_STACK_SIZE-4; \ - mfs r20, rpc; \ - addik r20, r20, _GLOBAL_OFFSET_TABLE_+8; -# define AC_RESTORE_GOT \ - lwi r20, r1, AC_STACK_SIZE-4; -# endif - -# undef PSEUDO -# define PSEUDO(name, syscall_name, args) \ - .text; \ - ENTRY (name) \ - SINGLE_THREAD_P(r12); \ - bnei r12, L(pseudo_cancel); \ - .globl __##syscall_name##_nocancel; \ - .type __##syscall_name##_nocancel,@function; \ -__##syscall_name##_nocancel: \ - DO_CALL (syscall_name, args); \ - addik r4, r0, -4095; \ - cmpu r4, r4, r3; \ - bgei r4, SYSCALL_ERROR_LABEL; \ - rtsd r15, 8; \ - nop; \ - .size __##syscall_name##_nocancel, .-__##syscall_name##_nocancel; \ -L(pseudo_cancel): \ - addik r1, r1, -AC_STACK_SIZE; \ - swi r15, r1, 0; \ - AC_SET_GOT \ - DOCARGS_##args \ - CENABLE; \ - swi r3, r1, 8; \ - UNDOCARGS_##args \ - DO_CALL (syscall_name, args); \ - swi r3, r1, 12; \ - lwi r5, r1, 8; \ - CDISABLE; \ - lwi r3, r1, 12; \ - lwi r15, r1, 0; \ - AC_RESTORE_GOT \ - addik r1, r1, AC_STACK_SIZE; \ - addik r4, r0, -4095; \ - cmpu r4, r4, r3; \ - bgei r4, SYSCALL_ERROR_LABEL; \ - rtsd r15, 8; \ - nop; - -/* - * Macros to save/restore syscall arguments across CENABLE - * The arguments are saved into the caller's stack (original r1 + 4) - */ - -# define DOCARGS_0 -# define DOCARGS_1 swi r5, r1, AC_STACK_SIZE + 4; -# define DOCARGS_2 swi r6, r1, AC_STACK_SIZE + 8; DOCARGS_1 -# define DOCARGS_3 swi r7, r1, AC_STACK_SIZE + 12; DOCARGS_2 -# define DOCARGS_4 swi r8, r1, AC_STACK_SIZE + 16; DOCARGS_3 -# define DOCARGS_5 swi r9, r1, AC_STACK_SIZE + 20; DOCARGS_4 -# define DOCARGS_6 swi r10, r1, AC_STACK_SIZE + 24; DOCARGS_5 - -# define UNDOCARGS_0 -# define UNDOCARGS_1 lwi r5, r1, AC_STACK_SIZE + 4; -# define UNDOCARGS_2 UNDOCARGS_1 lwi r6, r1, AC_STACK_SIZE + 8; -# define UNDOCARGS_3 UNDOCARGS_2 lwi r7, r1, AC_STACK_SIZE + 12; -# define UNDOCARGS_4 UNDOCARGS_3 lwi r8, r1, AC_STACK_SIZE + 16; -# define UNDOCARGS_5 UNDOCARGS_4 lwi r9, r1, AC_STACK_SIZE + 20; -# define UNDOCARGS_6 UNDOCARGS_5 lwi r10, r1, AC_STACK_SIZE + 24; - -# ifdef PIC -# define PSEUDO_JMP(sym) brlid r15, sym##@PLTPC; addk r0, r0, r0 -# else -# define PSEUDO_JMP(sym) brlid r15, sym; addk r0, r0, r0 -# endif - # if IS_IN (libpthread) -# define CENABLE PSEUDO_JMP (__pthread_enable_asynccancel) -# define CDISABLE PSEUDO_JMP (__pthread_disable_asynccancel) # define __local_multiple_threads __pthread_multiple_threads # elif IS_IN (libc) -# define CENABLE PSEUDO_JMP (__libc_enable_asynccancel) -# define CDISABLE PSEUDO_JMP (__libc_disable_asynccancel) # define __local_multiple_threads __libc_multiple_threads -# elif IS_IN (librt) -# define CENABLE PSEUDO_JMP (__librt_enable_asynccancel) -# define CDISABLE PSEUDO_JMP (__librt_disable_asynccancel) -# else -# error Unsupported library # endif - # if IS_IN (libpthread) || IS_IN (libc) -# ifndef __ASSEMBLER__ extern int __local_multiple_threads attribute_hidden; -# define SINGLE_THREAD_P __builtin_expect (__local_multiple_threads == 0, 1) -# else -# if !defined PIC -# define SINGLE_THREAD_P(reg) lwi reg, r0, __local_multiple_threads; -# else -# define SINGLE_THREAD_P(reg) \ - mfs reg, rpc; \ - addik reg, reg, _GLOBAL_OFFSET_TABLE_+8; \ - lwi reg, reg, __local_multiple_threads@GOT; \ - lwi reg, reg, 0; -# endif -# endif +# define SINGLE_THREAD_P __builtin_expect (__local_multiple_threads == 0, 1) # else -# ifndef __ASSEMBLER__ -# define SINGLE_THREAD_P \ +# define SINGLE_THREAD_P \ __builtin_expect (THREAD_GETMEM (THREAD_SELF, \ header.multiple_threads) == 0, 1) -# else -# define SINGLE_THREAD_P(reg) \ - lwi reg, r0, MULTIPLE_THREADS_OFFSET(reg) -# endif # endif -#elif !defined __ASSEMBLER__ +#else # define SINGLE_THREAD_P (1) # define NO_CANCELLATION (1) #endif -#ifndef __ASSEMBLER__ -# define RTLD_SINGLE_THREAD_P \ +#define RTLD_SINGLE_THREAD_P \ __builtin_expect (THREAD_GETMEM (THREAD_SELF, \ header.multiple_threads) == 0, 1) -#endif diff --git a/sysdeps/unix/sysv/linux/mips/mips64/sysdep-cancel.h b/sysdeps/unix/sysv/linux/mips/mips64/sysdep-cancel.h deleted file mode 100644 index 0ed3e3d..0000000 --- a/sysdeps/unix/sysv/linux/mips/mips64/sysdep-cancel.h +++ /dev/null @@ -1,249 +0,0 @@ -/* Copyright (C) 2003-2017 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 -#ifndef __ASSEMBLER__ -# include -#endif -#include - -/* Gas will put the initial save of $gp into the CIE, because it appears to - happen before any instructions. So we use cfi_same_value instead of - cfi_restore. */ - -#if IS_IN (libc) || IS_IN (libpthread) || IS_IN (librt) - -#ifdef __PIC__ -# undef PSEUDO -# define PSEUDO(name, syscall_name, args) \ - .align 2; \ - L(pseudo_start): \ - cfi_startproc; \ - cfi_adjust_cfa_offset (STKSPACE); \ - cfi_rel_offset (gp, STKOFF_GP); \ - 99: PTR_LA t9,__syscall_error; \ - /* manual cpreturn */ \ - REG_L gp, STKOFF_GP(sp); \ - cfi_same_value (gp); \ - RESTORESTK; \ - jr t9; \ - .type __##syscall_name##_nocancel, @function; \ - .globl __##syscall_name##_nocancel; \ - __##syscall_name##_nocancel: \ - SAVESTK; \ - .cpsetup t9, STKOFF_GP, __##syscall_name##_nocancel; \ - cfi_rel_offset (gp, STKOFF_GP); \ - li v0, SYS_ify(syscall_name); \ - syscall; \ - bne a3, zero, SYSCALL_ERROR_LABEL; \ - /* manual cpreturn */ \ - REG_L gp, STKOFF_GP(sp); \ - cfi_same_value (gp); \ - RESTORESTK; \ - ret; \ - cfi_endproc; \ - .size __##syscall_name##_nocancel,.-__##syscall_name##_nocancel; \ - ENTRY (name) \ - SAVESTK; \ - .cpsetup t9, STKOFF_GP, name; \ - cfi_rel_offset (gp, STKOFF_GP); \ - SINGLE_THREAD_P(v1); \ - bne zero, v1, L(pseudo_cancel); \ - .set noreorder; \ - li v0, SYS_ify(syscall_name); \ - syscall; \ - .set reorder; \ - bne a3, zero, SYSCALL_ERROR_LABEL; \ - /* manual cpreturn */ \ - REG_L gp, STKOFF_GP(sp); \ - cfi_same_value (gp); \ - RESTORESTK; \ - ret; \ - L(pseudo_cancel): \ - cfi_adjust_cfa_offset (STKSPACE); \ - cfi_rel_offset (gp, STKOFF_GP); \ - REG_S ra, STKOFF_RA(sp); \ - cfi_rel_offset (ra, STKOFF_RA); \ - PUSHARGS_##args; /* save syscall args */ \ - CENABLE; \ - REG_S v0, STKOFF_SVMSK(sp); /* save mask */ \ - POPARGS_##args; /* restore syscall args */ \ - .set noreorder; \ - li v0, SYS_ify (syscall_name); \ - syscall; \ - .set reorder; \ - REG_S v0, STKOFF_SC_V0(sp); /* save syscall result */ \ - REG_S a3, STKOFF_SC_ERR(sp); /* save syscall error flag */ \ - REG_L a0, STKOFF_SVMSK(sp); /* pass mask as arg1 */ \ - CDISABLE; \ - REG_L a3, STKOFF_SC_ERR(sp); /* restore syscall error flag */ \ - REG_L ra, STKOFF_RA(sp); /* restore return address */ \ - REG_L v0, STKOFF_SC_V0(sp); /* restore syscall result */ \ - bne a3, zero, SYSCALL_ERROR_LABEL; \ - /* manual cpreturn */ \ - REG_L gp, STKOFF_GP(sp); \ - cfi_same_value (gp); \ - RESTORESTK; \ - L(pseudo_end): -#else -# undef PSEUDO -# define PSEUDO(name, syscall_name, args) \ - .align 2; \ - L(pseudo_start): \ - cfi_startproc; \ - cfi_adjust_cfa_offset (STKSPACE); \ - 99: RESTORESTK; \ - j __syscall_error; \ - .type __##syscall_name##_nocancel, @function; \ - .globl __##syscall_name##_nocancel; \ - __##syscall_name##_nocancel: \ - SAVESTK; \ - li v0, SYS_ify(syscall_name); \ - syscall; \ - bne a3, zero, SYSCALL_ERROR_LABEL; \ - RESTORESTK; \ - ret; \ - cfi_endproc; \ - .size __##syscall_name##_nocancel,.-__##syscall_name##_nocancel; \ - ENTRY (name) \ - SAVESTK; \ - SINGLE_THREAD_P(v1); \ - bne zero, v1, L(pseudo_cancel); \ - .set noreorder; \ - li v0, SYS_ify(syscall_name); \ - syscall; \ - .set reorder; \ - bne a3, zero, SYSCALL_ERROR_LABEL; \ - RESTORESTK; \ - ret; \ - L(pseudo_cancel): \ - cfi_adjust_cfa_offset (STKSPACE); \ - REG_S ra, STKOFF_RA(sp); \ - cfi_rel_offset (ra, STKOFF_RA); \ - PUSHARGS_##args; /* save syscall args */ \ - CENABLE; \ - REG_S v0, STKOFF_SVMSK(sp); /* save mask */ \ - POPARGS_##args; /* restore syscall args */ \ - .set noreorder; \ - li v0, SYS_ify (syscall_name); \ - syscall; \ - .set reorder; \ - REG_S v0, STKOFF_SC_V0(sp); /* save syscall result */ \ - REG_S a3, STKOFF_SC_ERR(sp); /* save syscall error flag */ \ - REG_L a0, STKOFF_SVMSK(sp); /* pass mask as arg1 */ \ - CDISABLE; \ - REG_L a3, STKOFF_SC_ERR(sp); /* restore syscall error flag */ \ - REG_L ra, STKOFF_RA(sp); /* restore return address */ \ - REG_L v0, STKOFF_SC_V0(sp); /* restore syscall result */ \ - bne a3, zero, SYSCALL_ERROR_LABEL; \ - RESTORESTK; \ - L(pseudo_end): -#endif - -# undef PSEUDO_END -# define PSEUDO_END(sym) cfi_endproc; .end sym; .size sym,.-sym - -# define PUSHARGS_0 /* nothing to do */ -# define PUSHARGS_1 PUSHARGS_0 REG_S a0, STKOFF_A0(sp); cfi_rel_offset (a0, STKOFF_A0); -# define PUSHARGS_2 PUSHARGS_1 REG_S a1, STKOFF_A1(sp); cfi_rel_offset (a1, STKOFF_A1); -# define PUSHARGS_3 PUSHARGS_2 REG_S a2, STKOFF_A2(sp); cfi_rel_offset (a2, STKOFF_A2); -# define PUSHARGS_4 PUSHARGS_3 REG_S a3, STKOFF_A3(sp); cfi_rel_offset (a3, STKOFF_A3); -# define PUSHARGS_5 PUSHARGS_4 REG_S a4, STKOFF_A4(sp); cfi_rel_offset (a3, STKOFF_A4); -# define PUSHARGS_6 PUSHARGS_5 REG_S a5, STKOFF_A5(sp); cfi_rel_offset (a3, STKOFF_A5); - -# define POPARGS_0 /* nothing to do */ -# define POPARGS_1 POPARGS_0 REG_L a0, STKOFF_A0(sp); -# define POPARGS_2 POPARGS_1 REG_L a1, STKOFF_A1(sp); -# define POPARGS_3 POPARGS_2 REG_L a2, STKOFF_A2(sp); -# define POPARGS_4 POPARGS_3 REG_L a3, STKOFF_A3(sp); -# define POPARGS_5 POPARGS_4 REG_L a4, STKOFF_A4(sp); -# define POPARGS_6 POPARGS_5 REG_L a5, STKOFF_A5(sp); - -/* Save an even number of slots. Should be 0 if an even number of slots - are used below, or SZREG if an odd number are used. */ -# ifdef __PIC__ -# define STK_PAD SZREG -# else -# define STK_PAD 0 -# endif - -/* Place values that we are more likely to use later in this sequence, i.e. - closer to the SP at function entry. If you do that, the are more - likely to already be in your d-cache. */ -# define STKOFF_A5 (STK_PAD) -# define STKOFF_A4 (STKOFF_A5 + SZREG) -# define STKOFF_A3 (STKOFF_A4 + SZREG) -# define STKOFF_A2 (STKOFF_A3 + SZREG) /* MT and more args. */ -# define STKOFF_A1 (STKOFF_A2 + SZREG) /* MT and 2 args. */ -# define STKOFF_A0 (STKOFF_A1 + SZREG) /* MT and 1 arg. */ -# define STKOFF_RA (STKOFF_A0 + SZREG) /* Used if MT. */ -# define STKOFF_SC_V0 (STKOFF_RA + SZREG) /* Used if MT. */ -# define STKOFF_SC_ERR (STKOFF_SC_V0 + SZREG) /* Used if MT. */ -# define STKOFF_SVMSK (STKOFF_SC_ERR + SZREG) /* Used if MT. */ - -# ifdef __PIC__ -# define STKOFF_GP (STKOFF_SVMSK + SZREG) /* Always used. */ -# define STKSPACE (STKOFF_GP + SZREG) -# else -# define STKSPACE (STKOFF_SVMSK + SZREG) -# endif - -# define SAVESTK PTR_SUBU sp, STKSPACE; cfi_adjust_cfa_offset(STKSPACE) -# define RESTORESTK PTR_ADDU sp, STKSPACE; cfi_adjust_cfa_offset(-STKSPACE) - -# ifdef __PIC__ -# define PSEUDO_JMP(sym) PTR_LA t9, sym; jalr t9 -# else -# define PSEUDO_JMP(sym) jal sym -# endif - -# if IS_IN (libpthread) -# define CENABLE PSEUDO_JMP (__pthread_enable_asynccancel) -# define CDISABLE PSEUDO_JMP (__pthread_disable_asynccancel) -# elif IS_IN (librt) -# define CENABLE PSEUDO_JMP (__librt_enable_asynccancel) -# define CDISABLE PSEUDO_JMP (__librt_disable_asynccancel) -# else -# define CENABLE PSEUDO_JMP (__libc_enable_asynccancel) -# define CDISABLE PSEUDO_JMP (__libc_disable_asynccancel) -# endif - -# ifndef __ASSEMBLER__ -# define SINGLE_THREAD_P \ - __builtin_expect (THREAD_GETMEM (THREAD_SELF, \ - header.multiple_threads) \ - == 0, 1) -# else -# define SINGLE_THREAD_P(reg) \ - READ_THREAD_POINTER(reg); \ - lw reg, MULTIPLE_THREADS_OFFSET(reg) -#endif - -#elif !defined __ASSEMBLER__ - -# define SINGLE_THREAD_P 1 -# define NO_CANCELLATION 1 - -#endif - -#ifndef __ASSEMBLER__ -# define RTLD_SINGLE_THREAD_P \ - __builtin_expect (THREAD_GETMEM (THREAD_SELF, \ - header.multiple_threads) == 0, 1) -#endif diff --git a/sysdeps/unix/sysv/linux/mips/sysdep-cancel.h b/sysdeps/unix/sysv/linux/mips/sysdep-cancel.h index 0e45f00..fe9a3fc 100644 --- a/sysdeps/unix/sysv/linux/mips/sysdep-cancel.h +++ b/sysdeps/unix/sysv/linux/mips/sysdep-cancel.h @@ -18,173 +18,22 @@ #include #include #include -#ifndef __ASSEMBLER__ -# include -#endif +#include #if IS_IN (libc) || IS_IN (libpthread) || IS_IN (librt) -# ifdef __PIC__ -# define PSEUDO_CPLOAD .cpload t9; -# define PSEUDO_ERRJMP la t9, __syscall_error; jr t9; -# define PSEUDO_SAVEGP sw gp, 32(sp); cfi_rel_offset (gp, 32); -# define PSEUDO_LOADGP lw gp, 32(sp); -# else -# define PSEUDO_CPLOAD -# define PSEUDO_ERRJMP j __syscall_error; -# define PSEUDO_SAVEGP -# define PSEUDO_LOADGP -# endif - -# undef PSEUDO -# define PSEUDO(name, syscall_name, args) \ - .align 2; \ - .set nomips16; \ - L(pseudo_start): \ - cfi_startproc; \ - 99: PSEUDO_ERRJMP \ - .type __##syscall_name##_nocancel, @function; \ - .globl __##syscall_name##_nocancel; \ - __##syscall_name##_nocancel: \ - .set noreorder; \ - PSEUDO_CPLOAD \ - li v0, SYS_ify(syscall_name); \ - syscall; \ - .set reorder; \ - bne a3, zero, 99b; \ - ret; \ - cfi_endproc; \ - .size __##syscall_name##_nocancel,.-__##syscall_name##_nocancel; \ - ENTRY (name) \ - .set noreorder; \ - PSEUDO_CPLOAD \ - .set reorder; \ - SINGLE_THREAD_P(v1); \ - bne zero, v1, L(pseudo_cancel); \ - .set noreorder; \ - li v0, SYS_ify(syscall_name); \ - syscall; \ - .set reorder; \ - bne a3, zero, 99b; \ - ret; \ - L(pseudo_cancel): \ - SAVESTK_##args; \ - sw ra, 28(sp); \ - cfi_rel_offset (ra, 28); \ - PSEUDO_SAVEGP \ - PUSHARGS_##args; /* save syscall args */ \ - CENABLE; \ - PSEUDO_LOADGP \ - sw v0, 44(sp); /* save mask */ \ - POPARGS_##args; /* restore syscall args */ \ - .set noreorder; \ - li v0, SYS_ify (syscall_name); \ - syscall; \ - .set reorder; \ - sw v0, 36(sp); /* save syscall result */ \ - sw a3, 40(sp); /* save syscall error flag */ \ - lw a0, 44(sp); /* pass mask as arg1 */ \ - CDISABLE; \ - PSEUDO_LOADGP \ - lw v0, 36(sp); /* restore syscall result */ \ - lw a3, 40(sp); /* restore syscall error flag */ \ - lw ra, 28(sp); /* restore return address */ \ - .set noreorder; \ - bne a3, zero, 99b; \ - RESTORESTK; \ - L(pseudo_end): \ - .set reorder; - -# undef PSEUDO_END -# define PSEUDO_END(sym) cfi_endproc; .end sym; .size sym,.-sym - -# define PUSHARGS_0 /* nothing to do */ -# define PUSHARGS_1 PUSHARGS_0 sw a0, 0(sp); cfi_rel_offset (a0, 0); -# define PUSHARGS_2 PUSHARGS_1 sw a1, 4(sp); cfi_rel_offset (a1, 4); -# define PUSHARGS_3 PUSHARGS_2 sw a2, 8(sp); cfi_rel_offset (a2, 8); -# define PUSHARGS_4 PUSHARGS_3 sw a3, 12(sp); cfi_rel_offset (a3, 12); -# define PUSHARGS_5 PUSHARGS_4 /* handled by SAVESTK_## */ -# define PUSHARGS_6 PUSHARGS_5 -# define PUSHARGS_7 PUSHARGS_6 - -# define POPARGS_0 /* nothing to do */ -# define POPARGS_1 POPARGS_0 lw a0, 0(sp); -# define POPARGS_2 POPARGS_1 lw a1, 4(sp); -# define POPARGS_3 POPARGS_2 lw a2, 8(sp); -# define POPARGS_4 POPARGS_3 lw a3, 12(sp); -# define POPARGS_5 POPARGS_4 /* args already in new stackframe */ -# define POPARGS_6 POPARGS_5 -# define POPARGS_7 POPARGS_6 - - -# define STKSPACE 48 -# define SAVESTK_0 subu sp, STKSPACE; cfi_adjust_cfa_offset(STKSPACE) -# define SAVESTK_1 SAVESTK_0 -# define SAVESTK_2 SAVESTK_1 -# define SAVESTK_3 SAVESTK_2 -# define SAVESTK_4 SAVESTK_3 -# define SAVESTK_5 lw t0, 16(sp); \ - SAVESTK_0; \ - sw t0, 16(sp) - -# define SAVESTK_6 lw t0, 16(sp); \ - lw t1, 20(sp); \ - SAVESTK_0; \ - sw t0, 16(sp); \ - sw t1, 20(sp) - -# define SAVESTK_7 lw t0, 16(sp); \ - lw t1, 20(sp); \ - lw t2, 24(sp); \ - SAVESTK_0; \ - sw t0, 16(sp); \ - sw t1, 20(sp); \ - sw t2, 24(sp) - -# define RESTORESTK addu sp, STKSPACE; cfi_adjust_cfa_offset(-STKSPACE) - - -# ifdef __PIC__ -/* We use jalr rather than jal. This means that the assembler will not - automatically restore $gp (in case libc has multiple GOTs) so we must - do it manually - which we have to do anyway since we don't use .cprestore. - It also shuts up the assembler warning about not using .cprestore. */ -# define PSEUDO_JMP(sym) la t9, sym; jalr t9; -# else -# define PSEUDO_JMP(sym) jal sym; -# endif - -# if IS_IN (libpthread) -# define CENABLE PSEUDO_JMP (__pthread_enable_asynccancel) -# define CDISABLE PSEUDO_JMP (__pthread_disable_asynccancel) -# elif IS_IN (librt) -# define CENABLE PSEUDO_JMP (__librt_enable_asynccancel) -# define CDISABLE PSEUDO_JMP (__librt_disable_asynccancel) -# else -# define CENABLE PSEUDO_JMP (__libc_enable_asynccancel) -# define CDISABLE PSEUDO_JMP (__libc_disable_asynccancel) -# endif - -# ifndef __ASSEMBLER__ -# define SINGLE_THREAD_P \ +# define SINGLE_THREAD_P \ __builtin_expect (THREAD_GETMEM (THREAD_SELF, \ header.multiple_threads) \ == 0, 1) -# else -# define SINGLE_THREAD_P(reg) \ - READ_THREAD_POINTER(reg); \ - lw reg, MULTIPLE_THREADS_OFFSET(reg) -#endif -#elif !defined __ASSEMBLER__ +#else # define SINGLE_THREAD_P 1 # define NO_CANCELLATION 1 #endif -#ifndef __ASSEMBLER__ -# define RTLD_SINGLE_THREAD_P \ +#define RTLD_SINGLE_THREAD_P \ __builtin_expect (THREAD_GETMEM (THREAD_SELF, \ header.multiple_threads) == 0, 1) -#endif diff --git a/sysdeps/unix/sysv/linux/nios2/sysdep-cancel.h b/sysdeps/unix/sysv/linux/nios2/sysdep-cancel.h index 47b92d9..7647363 100644 --- a/sysdeps/unix/sysv/linux/nios2/sysdep-cancel.h +++ b/sysdeps/unix/sysv/linux/nios2/sysdep-cancel.h @@ -18,124 +18,22 @@ #include #include -#ifndef __ASSEMBLER__ -# include -#endif +#include #if IS_IN (libc) || IS_IN (libpthread) || IS_IN (librt) -# undef PSEUDO -# define PSEUDO(name, syscall_name, args) \ - .type __##syscall_name##_nocancel, @function; \ - .globl __##syscall_name##_nocancel; \ - __##syscall_name##_nocancel: \ - cfi_startproc; \ - DO_CALL (syscall_name, args); \ - bne r7, zero, SYSCALL_ERROR_LABEL; \ - ret; \ - cfi_endproc; \ - .size __##syscall_name##_nocancel,.-__##syscall_name##_nocancel; \ - ENTRY (name) \ - SINGLE_THREAD_P(r2); \ - bne r2, zero, pseudo_cancel; \ - DO_CALL (syscall_name, args); \ - bne r7, zero, SYSCALL_ERROR_LABEL; \ - ret; \ - pseudo_cancel: \ - SAVESTK_##args; /* save syscall args and adjust stack */ \ - SAVEREG(ra, 0); /* save return address */ \ - SAVEREG(r22, 4); /* save GOT pointer */ \ - nextpc r22; \ -1: movhi r2, %hiadj(_gp_got - 1b); \ - addi r2, r2, %lo(_gp_got - 1b); \ - add r22, r22, r2; \ - CENABLE; \ - callr r3; \ - stw r2, 8(sp); /* save mask */ \ - LOADARGS_##args; \ - movi r2, SYS_ify(syscall_name); \ - trap; \ - stw r2, 12(sp); /* save syscall result */ \ - stw r7, 16(sp); /* save syscall error flag */ \ - ldw r4, 8(sp); /* pass mask as argument 1 */ \ - CDISABLE; \ - callr r3; \ - ldw r7, 16(sp); /* restore syscall error flag */ \ - ldw r2, 12(sp); /* restore syscall result */ \ - ldw ra, 0(sp); /* restore return address */ \ - ldw r22, 4(sp); /* restore GOT pointer */ \ - RESTORESTK_##args; \ - bne r7, zero, SYSCALL_ERROR_LABEL; - - -# undef PSEUDO_END -# define PSEUDO_END(sym) \ - SYSCALL_ERROR_HANDLER \ - END (sym) - -#define SAVEREG(REG, LOC) stw REG, LOC(sp); cfi_rel_offset (REG, LOC) -#define SAVESTK(X) subi sp, sp, X; cfi_adjust_cfa_offset(X) -#define SAVESTK_0 SAVESTK(20) -#define SAVEARG_1 SAVEREG(r4, 20) -#define SAVESTK_1 SAVESTK(24); SAVEARG_1 -#define SAVEARG_2 SAVEREG(r5, 24); SAVEARG_1 -#define SAVESTK_2 SAVESTK(28); SAVEARG_2 -#define SAVEARG_3 SAVEREG(r6, 28); SAVEARG_2 -#define SAVESTK_3 SAVESTK(32); SAVEARG_3 -#define SAVEARG_4 SAVEREG(r7, 32); SAVEARG_3 -#define SAVESTK_4 SAVESTK(36); SAVEARG_4 -#define SAVESTK_5 SAVESTK_4 -#define SAVESTK_6 SAVESTK_5 - -#define LOADARGS_0 -#define LOADARGS_1 ldw r4, 20(sp) -#define LOADARGS_2 LOADARGS_1; ldw r5, 24(sp) -#define LOADARGS_3 LOADARGS_2; ldw r6, 28(sp) -#define LOADARGS_4 LOADARGS_3; ldw r7, 32(sp) -#define LOADARGS_5 LOADARGS_4; ldw r8, 36(sp) -#define LOADARGS_6 LOADARGS_5; ldw r9, 40(sp) - -#define RESTORESTK(X) addi sp, sp, X; cfi_adjust_cfa_offset(-X) -#define RESTORESTK_0 RESTORESTK(20) -#define RESTORESTK_1 RESTORESTK(24) -#define RESTORESTK_2 RESTORESTK(28) -#define RESTORESTK_3 RESTORESTK(32) -#define RESTORESTK_4 RESTORESTK(36) -#define RESTORESTK_5 RESTORESTK(36) -#define RESTORESTK_6 RESTORESTK(36) - -# if IS_IN (libpthread) -# define CENABLE ldw r3, %call(__pthread_enable_asynccancel)(r22) -# define CDISABLE ldw r3, %call(__pthread_disable_asynccancel)(r22) -# elif IS_IN (librt) -# define CENABLE ldw r3, %call(__librt_enable_asynccancel)(r22) -# define CDISABLE ldw r3, %call(__librt_disable_asynccancel)(r22) -# elif IS_IN (libc) -# define CENABLE ldw r3, %call(__libc_enable_asynccancel)(r22) -# define CDISABLE ldw r3, %call(__libc_disable_asynccancel)(r22) -# else -# error Unsupported library -# endif - -# ifndef __ASSEMBLER__ -# define SINGLE_THREAD_P \ +# define SINGLE_THREAD_P \ __builtin_expect (THREAD_GETMEM (THREAD_SELF, \ header.multiple_threads) \ == 0, 1) -# else -# define SINGLE_THREAD_P(reg) \ - ldw reg, MULTIPLE_THREADS_OFFSET(r23) -#endif -#elif !defined __ASSEMBLER__ +#else # define SINGLE_THREAD_P 1 # define NO_CANCELLATION 1 #endif -#ifndef __ASSEMBLER__ -# define RTLD_SINGLE_THREAD_P \ +#define RTLD_SINGLE_THREAD_P \ __builtin_expect (THREAD_GETMEM (THREAD_SELF, \ header.multiple_threads) == 0, 1) -#endif diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep-cancel.h b/sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep-cancel.h deleted file mode 100644 index 35d3f05..0000000 --- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep-cancel.h +++ /dev/null @@ -1,118 +0,0 @@ -/* Cancellable system call stubs. Linux/PowerPC version. - Copyright (C) 2003-2017 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Franz Sirl , 2003. - - 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 -#ifndef __ASSEMBLER__ -# include -#endif - -#if IS_IN (libc) || IS_IN (libpthread) || IS_IN (librt) - -# undef PSEUDO -# define PSEUDO(name, syscall_name, args) \ - .section ".text"; \ - ENTRY (name) \ - SINGLE_THREAD_P; \ - bne- .Lpseudo_cancel; \ - .type __##syscall_name##_nocancel,@function; \ - .globl __##syscall_name##_nocancel; \ - __##syscall_name##_nocancel: \ - DO_CALL (SYS_ify (syscall_name)); \ - PSEUDO_RET; \ - .size __##syscall_name##_nocancel,.-__##syscall_name##_nocancel; \ - .Lpseudo_cancel: \ - stwu 1,-48(1); \ - cfi_adjust_cfa_offset (48); \ - mflr 9; \ - stw 9,52(1); \ - cfi_offset (lr, 4); \ - DOCARGS_##args; /* save syscall args around CENABLE. */ \ - CENABLE; \ - stw 3,16(1); /* store CENABLE return value (MASK). */ \ - UNDOCARGS_##args; /* restore syscall args. */ \ - DO_CALL (SYS_ify (syscall_name)); \ - mfcr 0; /* save CR/R3 around CDISABLE. */ \ - stw 3,8(1); \ - stw 0,12(1); \ - lwz 3,16(1); /* pass MASK to CDISABLE. */ \ - CDISABLE; \ - lwz 4,52(1); \ - lwz 0,12(1); /* restore CR/R3. */ \ - lwz 3,8(1); \ - mtlr 4; \ - mtcr 0; \ - addi 1,1,48; - -# define DOCARGS_0 -# define UNDOCARGS_0 - -# define DOCARGS_1 stw 3,20(1); DOCARGS_0 -# define UNDOCARGS_1 lwz 3,20(1); UNDOCARGS_0 - -# define DOCARGS_2 stw 4,24(1); DOCARGS_1 -# define UNDOCARGS_2 lwz 4,24(1); UNDOCARGS_1 - -# define DOCARGS_3 stw 5,28(1); DOCARGS_2 -# define UNDOCARGS_3 lwz 5,28(1); UNDOCARGS_2 - -# define DOCARGS_4 stw 6,32(1); DOCARGS_3 -# define UNDOCARGS_4 lwz 6,32(1); UNDOCARGS_3 - -# define DOCARGS_5 stw 7,36(1); DOCARGS_4 -# define UNDOCARGS_5 lwz 7,36(1); UNDOCARGS_4 - -# define DOCARGS_6 stw 8,40(1); DOCARGS_5 -# define UNDOCARGS_6 lwz 8,40(1); UNDOCARGS_5 - -# if IS_IN (libpthread) -# define CENABLE bl __pthread_enable_asynccancel@local -# define CDISABLE bl __pthread_disable_asynccancel@local -# elif IS_IN (libc) -# define CENABLE bl __libc_enable_asynccancel@local -# define CDISABLE bl __libc_disable_asynccancel@local -# elif IS_IN (librt) -# define CENABLE bl __librt_enable_asynccancel@local -# define CDISABLE bl __librt_disable_asynccancel@local -# else -# error Unsupported library -# endif - -# ifndef __ASSEMBLER__ -# define SINGLE_THREAD_P \ - __builtin_expect (THREAD_GETMEM (THREAD_SELF, \ - header.multiple_threads) == 0, 1) -# else -# define SINGLE_THREAD_P \ - lwz 10,MULTIPLE_THREADS_OFFSET(2); \ - cmpwi 10,0 -# endif - -#elif !defined __ASSEMBLER__ - -# define SINGLE_THREAD_P (1) -# define NO_CANCELLATION 1 - -#endif - -#ifndef __ASSEMBLER__ -# define RTLD_SINGLE_THREAD_P \ - __builtin_expect (THREAD_GETMEM (THREAD_SELF, \ - header.multiple_threads) == 0, 1) -#endif diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep-cancel.h b/sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep-cancel.h deleted file mode 100644 index cad13da..0000000 --- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep-cancel.h +++ /dev/null @@ -1,147 +0,0 @@ -/* Cancellable system call stubs. Linux/PowerPC64 version. - Copyright (C) 2003-2017 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Franz Sirl , 2003. - - 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 -#ifndef __ASSEMBLER__ -# include -#endif - -#if IS_IN (libc) || IS_IN (libpthread) || IS_IN (librt) - -# define DASHDASHPFX(str) __##str - -#if _CALL_ELF == 2 -#define CANCEL_FRAMESIZE (FRAME_MIN_SIZE+16+48) -#define CANCEL_PARM_SAVE (FRAME_MIN_SIZE+16) -#else -#define CANCEL_FRAMESIZE (FRAME_MIN_SIZE+16) -#define CANCEL_PARM_SAVE (CANCEL_FRAMESIZE+FRAME_PARM_SAVE) -#endif - -# undef PSEUDO -# define PSEUDO(name, syscall_name, args) \ - .section ".text"; \ - ENTRY (name) \ - SINGLE_THREAD_P; \ - bne- .Lpseudo_cancel; \ - .type DASHDASHPFX(syscall_name##_nocancel),@function; \ - .globl DASHDASHPFX(syscall_name##_nocancel); \ - DASHDASHPFX(syscall_name##_nocancel): \ - DO_CALL (SYS_ify (syscall_name)); \ - PSEUDO_RET; \ - .size DASHDASHPFX(syscall_name##_nocancel),.-DASHDASHPFX(syscall_name##_nocancel); \ - .Lpseudo_cancel: \ - stdu 1,-CANCEL_FRAMESIZE(1); \ - cfi_adjust_cfa_offset (CANCEL_FRAMESIZE); \ - mflr 9; \ - std 9,CANCEL_FRAMESIZE+FRAME_LR_SAVE(1); \ - cfi_offset (lr, FRAME_LR_SAVE); \ - DOCARGS_##args; /* save syscall args around CENABLE. */ \ - CENABLE; \ - std 3,FRAME_MIN_SIZE(1); /* store CENABLE return value (MASK). */ \ - UNDOCARGS_##args; /* restore syscall args. */ \ - DO_CALL (SYS_ify (syscall_name)); \ - mfcr 0; /* save CR/R3 around CDISABLE. */ \ - std 3,FRAME_MIN_SIZE+8(1); \ - std 0,CANCEL_FRAMESIZE+FRAME_CR_SAVE(1); \ - cfi_offset (cr, FRAME_CR_SAVE); \ - ld 3,FRAME_MIN_SIZE(1); /* pass MASK to CDISABLE. */ \ - CDISABLE; \ - ld 9,CANCEL_FRAMESIZE+FRAME_LR_SAVE(1); \ - ld 0,CANCEL_FRAMESIZE+FRAME_CR_SAVE(1); /* restore CR/R3. */ \ - ld 3,FRAME_MIN_SIZE+8(1); \ - mtlr 9; \ - mtcr 0; \ - addi 1,1,CANCEL_FRAMESIZE; \ - cfi_adjust_cfa_offset (-CANCEL_FRAMESIZE); \ - cfi_restore (lr); \ - cfi_restore (cr) - -# define DOCARGS_0 -# define UNDOCARGS_0 - -# define DOCARGS_1 std 3,CANCEL_PARM_SAVE(1); DOCARGS_0 -# define UNDOCARGS_1 ld 3,CANCEL_PARM_SAVE(1); UNDOCARGS_0 - -# define DOCARGS_2 std 4,CANCEL_PARM_SAVE+8(1); DOCARGS_1 -# define UNDOCARGS_2 ld 4,CANCEL_PARM_SAVE+8(1); UNDOCARGS_1 - -# define DOCARGS_3 std 5,CANCEL_PARM_SAVE+16(1); DOCARGS_2 -# define UNDOCARGS_3 ld 5,CANCEL_PARM_SAVE+16(1); UNDOCARGS_2 - -# define DOCARGS_4 std 6,CANCEL_PARM_SAVE+24(1); DOCARGS_3 -# define UNDOCARGS_4 ld 6,CANCEL_PARM_SAVE+24(1); UNDOCARGS_3 - -# define DOCARGS_5 std 7,CANCEL_PARM_SAVE+32(1); DOCARGS_4 -# define UNDOCARGS_5 ld 7,CANCEL_PARM_SAVE+32(1); UNDOCARGS_4 - -# define DOCARGS_6 std 8,CANCEL_PARM_SAVE+40(1); DOCARGS_5 -# define UNDOCARGS_6 ld 8,CANCEL_PARM_SAVE+40(1); UNDOCARGS_5 - -# if IS_IN (libpthread) -# ifdef SHARED -# define CENABLE bl JUMPTARGET(__pthread_enable_asynccancel) -# define CDISABLE bl JUMPTARGET(__pthread_disable_asynccancel) -# else -# define CENABLE bl JUMPTARGET(__pthread_enable_asynccancel); nop -# define CDISABLE bl JUMPTARGET(__pthread_disable_asynccancel); nop -# endif -# elif IS_IN (libc) -# ifdef SHARED -# define CENABLE bl JUMPTARGET(__libc_enable_asynccancel) -# define CDISABLE bl JUMPTARGET(__libc_disable_asynccancel) -# else -# define CENABLE bl JUMPTARGET(__libc_enable_asynccancel); nop -# define CDISABLE bl JUMPTARGET(__libc_disable_asynccancel); nop -# endif -# elif IS_IN (librt) -# ifdef SHARED -# define CENABLE bl JUMPTARGET(__librt_enable_asynccancel) -# define CDISABLE bl JUMPTARGET(__librt_disable_asynccancel) -# else -# define CENABLE bl JUMPTARGET(__librt_enable_asynccancel); nop -# define CDISABLE bl JUMPTARGET(__librt_disable_asynccancel); nop -# endif -# else -# error Unsupported library -# endif - -# ifndef __ASSEMBLER__ -# define SINGLE_THREAD_P \ - __builtin_expect (THREAD_GETMEM (THREAD_SELF, \ - header.multiple_threads) == 0, 1) -# else -# define SINGLE_THREAD_P \ - lwz 10,MULTIPLE_THREADS_OFFSET(13); \ - cmpwi 10,0 -# endif - -#elif !defined __ASSEMBLER__ - -# define SINGLE_THREAD_P (1) -# define NO_CANCELLATION 1 - -#endif - -#ifndef __ASSEMBLER__ -# define RTLD_SINGLE_THREAD_P \ - __builtin_expect (THREAD_GETMEM (THREAD_SELF, \ - header.multiple_threads) == 0, 1) -#endif diff --git a/sysdeps/unix/sysv/linux/powerpc/sysdep-cancel.h b/sysdeps/unix/sysv/linux/powerpc/sysdep-cancel.h new file mode 100644 index 0000000..85af880 --- /dev/null +++ b/sysdeps/unix/sysv/linux/powerpc/sysdep-cancel.h @@ -0,0 +1,38 @@ +/* Cancellable system call stubs. Linux/PowerPC version. + Copyright (C) 2015 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 + +#if IS_IN (libc) || IS_IN (libpthread) || IS_IN (librt) + +# define SINGLE_THREAD_P \ + __builtin_expect (THREAD_GETMEM (THREAD_SELF, \ + header.multiple_threads) == 0, 1) + +#else + +# define SINGLE_THREAD_P (1) +# define NO_CANCELLATION 1 + +#endif + +#define RTLD_SINGLE_THREAD_P \ + __builtin_expect (THREAD_GETMEM (THREAD_SELF, \ + header.multiple_threads) == 0, 1) diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/sysdep-cancel.h b/sysdeps/unix/sysv/linux/s390/s390-32/sysdep-cancel.h index b1e80bc..82763b7 100644 --- a/sysdeps/unix/sysv/linux/s390/s390-32/sysdep-cancel.h +++ b/sysdeps/unix/sysv/linux/s390/s390-32/sysdep-cancel.h @@ -24,116 +24,17 @@ #if IS_IN (libc) || IS_IN (libpthread) || IS_IN (librt) -# undef PSEUDO -# define PSEUDO(name, syscall_name, args) \ - .text; \ -L(pseudo_cancel): \ - cfi_startproc; \ - STM_##args \ - stm %r12,%r15,48(%r15); \ - cfi_offset (%r15, -36); \ - cfi_offset (%r14, -40); \ - cfi_offset (%r13, -44); \ - cfi_offset (%r12, -48); \ - lr %r14,%r15; \ - ahi %r15,-96; \ - cfi_adjust_cfa_offset (96); \ - st %r14,0(%r15); \ - basr %r13,0; \ -0: l %r1,1f-0b(%r13); \ - bas %r14,0(%r1,%r13); \ - lr %r0,%r2; \ - LM_##args \ - .if SYS_ify (syscall_name) < 256; \ - svc SYS_ify (syscall_name); \ - .else; \ - lhi %r1,SYS_ify (syscall_name); \ - svc 0; \ - .endif; \ - LR7_##args \ - l %r1,2f-0b(%r13); \ - lr %r12,%r2; \ - lr %r2,%r0; \ - bas %r14,0(%r1,%r13); \ - lr %r2,%r12; \ - lm %r12,%r15,48+96(%r15); \ - cfi_endproc; \ - j L(pseudo_check); \ -1: .long CENABLE-0b; \ -2: .long CDISABLE-0b; \ -ENTRY(name) \ - SINGLE_THREAD_P(%r1) \ - jne L(pseudo_cancel); \ -.type __##syscall_name##_nocancel,@function; \ -.globl __##syscall_name##_nocancel; \ -__##syscall_name##_nocancel: \ - DO_CALL(syscall_name, args); \ -L(pseudo_check): \ - lhi %r4,-4095; \ - clr %r2,%r4; \ - jnl SYSCALL_ERROR_LABEL; \ -.size __##syscall_name##_nocancel,.-__##syscall_name##_nocancel; \ -L(pseudo_end): - -# if IS_IN (libpthread) -# define CENABLE __pthread_enable_asynccancel -# define CDISABLE __pthread_disable_asynccancel -# elif IS_IN (libc) -# define CENABLE __libc_enable_asynccancel -# define CDISABLE __libc_disable_asynccancel -# elif IS_IN (librt) -# define CENABLE __librt_enable_asynccancel -# define CDISABLE __librt_disable_asynccancel -# else -# error Unsupported library -# endif - -#define STM_0 /* Nothing */ -#define STM_1 st %r2,8(%r15); -#define STM_2 stm %r2,%r3,8(%r15); -#define STM_3 stm %r2,%r4,8(%r15); -#define STM_4 stm %r2,%r5,8(%r15); -#define STM_5 stm %r2,%r5,8(%r15); -#define STM_6 stm %r2,%r7,8(%r15); - -#define LM_0 /* Nothing */ -#define LM_1 l %r2,8+96(%r15); -#define LM_2 lm %r2,%r3,8+96(%r15); -#define LM_3 lm %r2,%r4,8+96(%r15); -#define LM_4 lm %r2,%r5,8+96(%r15); -#define LM_5 lm %r2,%r5,8+96(%r15); -#define LM_6 lm %r2,%r5,8+96(%r15); \ - cfi_offset (%r7, -68); \ - l %r7,96+96(%r15); - -#define LR7_0 /* Nothing */ -#define LR7_1 /* Nothing */ -#define LR7_2 /* Nothing */ -#define LR7_3 /* Nothing */ -#define LR7_4 /* Nothing */ -#define LR7_5 /* Nothing */ -#define LR7_6 l %r7,28+96(%r15); \ - cfi_restore (%r7); - -# ifndef __ASSEMBLER__ -# define SINGLE_THREAD_P \ +# define SINGLE_THREAD_P \ __builtin_expect (THREAD_GETMEM (THREAD_SELF, \ header.multiple_threads) == 0, 1) -# else -# define SINGLE_THREAD_P(reg) \ - ear reg,%a0; \ - icm reg,15,MULTIPLE_THREADS_OFFSET(reg); -# endif -#elif !defined __ASSEMBLER__ +#else # define SINGLE_THREAD_P (1) # define NO_CANCELLATION 1 #endif -#ifndef __ASSEMBLER__ -# define RTLD_SINGLE_THREAD_P \ +#define RTLD_SINGLE_THREAD_P \ __builtin_expect (THREAD_GETMEM (THREAD_SELF, \ header.multiple_threads) == 0, 1) -#endif diff --git a/sysdeps/unix/sysv/linux/s390/s390-64/sysdep-cancel.h b/sysdeps/unix/sysv/linux/s390/s390-64/sysdep-cancel.h index 9b2c546..952d2af 100644 --- a/sysdeps/unix/sysv/linux/s390/s390-64/sysdep-cancel.h +++ b/sysdeps/unix/sysv/linux/s390/s390-64/sysdep-cancel.h @@ -18,135 +18,36 @@ #include #include -#ifndef __ASSEMBLER__ -# include -#endif +#include #if IS_IN (libc) || IS_IN (libpthread) || IS_IN (librt) -# undef PSEUDO -# define PSEUDO(name, syscall_name, args) \ - .text; \ -L(pseudo_cancel): \ - cfi_startproc; \ - STM_##args \ - stmg %r13,%r15,104(%r15); \ - cfi_offset (%r15,-40); \ - cfi_offset (%r14,-48); \ - cfi_offset (%r13,-56); \ - lgr %r14,%r15; \ - aghi %r15,-160; \ - cfi_adjust_cfa_offset (160); \ - stg %r14,0(%r15); \ - brasl %r14,CENABLE; \ - lgr %r0,%r2; \ - LM_##args \ - .if SYS_ify (syscall_name) < 256; \ - svc SYS_ify (syscall_name); \ - .else; \ - lghi %r1,SYS_ify (syscall_name); \ - svc 0; \ - .endif; \ - LR7_##args \ - lgr %r13,%r2; \ - lgr %r2,%r0; \ - brasl %r14,CDISABLE; \ - lgr %r2,%r13; \ - lmg %r13,%r15,104+160(%r15); \ - cfi_endproc; \ - j L(pseudo_check); \ -ENTRY(name) \ - SINGLE_THREAD_P \ - jne L(pseudo_cancel); \ -.type __##syscall_name##_nocancel,@function; \ -.globl __##syscall_name##_nocancel; \ -__##syscall_name##_nocancel: \ - DO_CALL(syscall_name, args); \ -L(pseudo_check): \ - lghi %r4,-4095; \ - clgr %r2,%r4; \ - jgnl SYSCALL_ERROR_LABEL; \ -.size __##syscall_name##_nocancel,.-__##syscall_name##_nocancel; \ -L(pseudo_end): - # if IS_IN (libpthread) -# define CENABLE __pthread_enable_asynccancel -# define CDISABLE __pthread_disable_asynccancel # define __local_multiple_threads __pthread_multiple_threads # elif IS_IN (libc) -# define CENABLE __libc_enable_asynccancel -# define CDISABLE __libc_disable_asynccancel # define __local_multiple_threads __libc_multiple_threads -# elif IS_IN (librt) -# define CENABLE __librt_enable_asynccancel -# define CDISABLE __librt_disable_asynccancel -# else -# error Unsupported library # endif -#define STM_0 /* Nothing */ -#define STM_1 stg %r2,16(%r15); -#define STM_2 stmg %r2,%r3,16(%r15); -#define STM_3 stmg %r2,%r4,16(%r15); -#define STM_4 stmg %r2,%r5,16(%r15); -#define STM_5 stmg %r2,%r5,16(%r15); -#define STM_6 stmg %r2,%r7,16(%r15); - -#define LM_0 /* Nothing */ -#define LM_1 lg %r2,16+160(%r15); -#define LM_2 lmg %r2,%r3,16+160(%r15); -#define LM_3 lmg %r2,%r4,16+160(%r15); -#define LM_4 lmg %r2,%r5,16+160(%r15); -#define LM_5 lmg %r2,%r5,16+160(%r15); -#define LM_6 lmg %r2,%r5,16+160(%r15); \ - cfi_offset (%r7, -104); \ - lg %r7,160+160(%r15); - -#define LR7_0 /* Nothing */ -#define LR7_1 /* Nothing */ -#define LR7_2 /* Nothing */ -#define LR7_3 /* Nothing */ -#define LR7_4 /* Nothing */ -#define LR7_5 /* Nothing */ -#define LR7_6 lg %r7,56+160(%r15); \ - cfi_restore (%r7); - # if IS_IN (libpthread) || IS_IN (libc) -# ifndef __ASSEMBLER__ extern int __local_multiple_threads attribute_hidden; -# define SINGLE_THREAD_P \ +# define SINGLE_THREAD_P \ __builtin_expect (__local_multiple_threads == 0, 1) -# else -# define SINGLE_THREAD_P \ - larl %r1,__local_multiple_threads; \ - icm %r0,15,0(%r1); -# endif # else -# ifndef __ASSEMBLER__ -# define SINGLE_THREAD_P \ +# define SINGLE_THREAD_P \ __builtin_expect (THREAD_GETMEM (THREAD_SELF, \ header.multiple_threads) == 0, 1) -# else -# define SINGLE_THREAD_P \ - ear %r1,%a0; \ - sllg %r1,%r1,32; \ - ear %r1,%a1; \ - icm %r1,15,MULTIPLE_THREADS_OFFSET(%r1); -# endif # endif -#elif !defined __ASSEMBLER__ +#else # define SINGLE_THREAD_P (1) # define NO_CANCELLATION 1 #endif -#ifndef __ASSEMBLER__ -# define RTLD_SINGLE_THREAD_P \ +#define RTLD_SINGLE_THREAD_P \ __builtin_expect (THREAD_GETMEM (THREAD_SELF, \ header.multiple_threads) == 0, 1) -#endif diff --git a/sysdeps/unix/sysv/linux/sh/sysdep-cancel.h b/sysdeps/unix/sysv/linux/sh/sysdep-cancel.h index 5645cad..1ea501b 100644 --- a/sysdeps/unix/sysv/linux/sh/sysdep-cancel.h +++ b/sysdeps/unix/sysv/linux/sh/sysdep-cancel.h @@ -23,147 +23,17 @@ #if IS_IN (libc) || IS_IN (libpthread) || IS_IN (librt) -# define _IMM12 #-12 -# define _IMM16 #-16 -# define _IMP16 #16 -# undef PSEUDO -# define PSEUDO(name, syscall_name, args) \ - .text; \ - ENTRY (name); \ - .Lpseudo_start: \ - SINGLE_THREAD_P; \ - bf .Lpseudo_cancel; \ - .type __##syscall_name##_nocancel,@function; \ - .globl __##syscall_name##_nocancel; \ - __##syscall_name##_nocancel: \ - DO_CALL (syscall_name, args); \ - mov r0,r1; \ - mov _IMM12,r2; \ - shad r2,r1; \ - not r1,r1; \ - tst r1,r1; \ - bt .Lsyscall_error; \ - bra .Lpseudo_end; \ - nop; \ - .size __##syscall_name##_nocancel,.-__##syscall_name##_nocancel; \ - .Lpseudo_cancel: \ - sts.l pr,@-r15; \ - cfi_adjust_cfa_offset (4); \ - cfi_rel_offset (pr, 0); \ - add _IMM16,r15; \ - cfi_adjust_cfa_offset (16); \ - SAVE_ARGS_##args; \ - CENABLE; \ - LOAD_ARGS_##args; \ - add _IMP16,r15; \ - cfi_adjust_cfa_offset (-16); \ - lds.l @r15+,pr; \ - cfi_adjust_cfa_offset (-4); \ - cfi_restore (pr); \ - DO_CALL(syscall_name, args); \ - SYSCALL_INST_PAD; \ - sts.l pr,@-r15; \ - cfi_adjust_cfa_offset (4); \ - cfi_rel_offset (pr, 0); \ - mov.l r0,@-r15; \ - cfi_adjust_cfa_offset (4); \ - cfi_rel_offset (r0, 0); \ - CDISABLE; \ - mov.l @r15+,r0; \ - cfi_adjust_cfa_offset (-4); \ - cfi_restore (r0); \ - lds.l @r15+,pr; \ - cfi_adjust_cfa_offset (-4); \ - cfi_restore (pr); \ - mov r0,r1; \ - mov _IMM12,r2; \ - shad r2,r1; \ - not r1,r1; \ - tst r1,r1; \ - bf .Lpseudo_end; \ - .Lsyscall_error: \ - SYSCALL_ERROR_HANDLER; \ - .Lpseudo_end: - -# undef PSEUDO_END -# define PSEUDO_END(sym) \ - END (sym) - -# define SAVE_ARGS_0 /* Nothing. */ -# define SAVE_ARGS_1 SAVE_ARGS_0; mov.l r4,@(0,r15); cfi_offset (r4,-4) -# define SAVE_ARGS_2 SAVE_ARGS_1; mov.l r5,@(4,r15); cfi_offset (r5,-8) -# define SAVE_ARGS_3 SAVE_ARGS_2; mov.l r6,@(8,r15); cfi_offset (r6,-12) -# define SAVE_ARGS_4 SAVE_ARGS_3; mov.l r7,@(12,r15); cfi_offset (r7,-16) -# define SAVE_ARGS_5 SAVE_ARGS_4 -# define SAVE_ARGS_6 SAVE_ARGS_5 - -# define LOAD_ARGS_0 /* Nothing. */ -# define LOAD_ARGS_1 LOAD_ARGS_0; mov.l @(0,r15),r4; cfi_restore (r4) -# define LOAD_ARGS_2 LOAD_ARGS_1; mov.l @(4,r15),r5; cfi_restore (r5) -# define LOAD_ARGS_3 LOAD_ARGS_2; mov.l @(8,r15),r6; cfi_restore (r6) -# define LOAD_ARGS_4 LOAD_ARGS_3; mov.l @(12,r15),r7; cfi_restore (r7) -# define LOAD_ARGS_5 LOAD_ARGS_4 -# define LOAD_ARGS_6 LOAD_ARGS_5 - -# if IS_IN (libpthread) -# define __local_enable_asynccancel __pthread_enable_asynccancel -# define __local_disable_asynccancel __pthread_disable_asynccancel -# elif IS_IN (libc) -# define __local_enable_asynccancel __libc_enable_asynccancel -# define __local_disable_asynccancel __libc_disable_asynccancel -# elif IS_IN (librt) -# define __local_enable_asynccancel __librt_enable_asynccancel -# define __local_disable_asynccancel __librt_disable_asynccancel -# else -# error Unsupported library -# endif - -# define CENABLE \ - mov.l 1f,r0; \ - bsrf r0; \ - nop; \ - 0: bra 2f; \ - mov r0,r2; \ - .align 2; \ - 1: .long __local_enable_asynccancel - 0b; \ - 2: - -# define CDISABLE \ - mov.l 1f,r0; \ - bsrf r0; \ - mov r2,r4; \ - 0: bra 2f; \ - nop; \ - .align 2; \ - 1: .long __local_disable_asynccancel - 0b; \ - 2: - -# ifndef __ASSEMBLER__ -# define SINGLE_THREAD_P \ +# define SINGLE_THREAD_P \ __builtin_expect (THREAD_GETMEM (THREAD_SELF, \ header.multiple_threads) == 0, 1) -# else -# define SINGLE_THREAD_P \ - stc gbr,r0; \ - mov.w 0f,r1; \ - sub r1,r0; \ - mov.l @(MULTIPLE_THREADS_OFFSET,r0),r0; \ - bra 1f; \ - tst r0,r0; \ - 0: .word TLS_PRE_TCB_SIZE; \ - 1: - -# endif -#elif !defined __ASSEMBLER__ +#else # define SINGLE_THREAD_P (1) # define NO_CANCELLATION 1 #endif -#ifndef __ASSEMBLER__ -# define RTLD_SINGLE_THREAD_P \ +#define RTLD_SINGLE_THREAD_P \ __builtin_expect (THREAD_GETMEM (THREAD_SELF, \ header.multiple_threads) == 0, 1) -#endif diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/sysdep-cancel.h b/sysdeps/unix/sysv/linux/sparc/sparc32/sysdep-cancel.h deleted file mode 100644 index c513212..0000000 --- a/sysdeps/unix/sysv/linux/sparc/sparc32/sysdep-cancel.h +++ /dev/null @@ -1,111 +0,0 @@ -/* Copyright (C) 2002-2017 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Jakub Jelinek , 2002. - - 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 -#ifndef __ASSEMBLER__ -# include -#endif - -#if IS_IN (libc) || IS_IN (libpthread) || IS_IN (librt) - -# undef PSEUDO -# define PSEUDO(name, syscall_name, args) \ - .text; \ - .globl __syscall_error; \ -ENTRY(name) \ - ld [%g7 + MULTIPLE_THREADS_OFFSET], %g1;\ - cmp %g1, 0; \ - bne 1f; \ -.type __##syscall_name##_nocancel,@function; \ -.globl __##syscall_name##_nocancel; \ -__##syscall_name##_nocancel: \ - mov SYS_ify(syscall_name), %g1; \ - ta 0x10; \ - bcc 8f; \ - mov %o7, %g1; \ - call __syscall_error; \ - mov %g1, %o7; \ -8: jmpl %o7 + 8, %g0; \ - nop; \ -.size __##syscall_name##_nocancel,.-__##syscall_name##_nocancel;\ -1: save %sp, -96, %sp; \ - cfi_def_cfa_register(%fp); \ - cfi_window_save; \ - cfi_register(%o7, %i7); \ - CENABLE; \ - nop; \ - mov %o0, %l0; \ - COPY_ARGS_##args \ - mov SYS_ify(syscall_name), %g1; \ - ta 0x10; \ - bcc 1f; \ - mov %o0, %l1; \ - CDISABLE; \ - mov %l0, %o0; \ - call __syscall_error; \ - mov %l1, %o0; \ - b 2f; \ - mov -1, %l1; \ -1: CDISABLE; \ - mov %l0, %o0; \ -2: jmpl %i7 + 8, %g0; \ - restore %g0, %l1, %o0; - - -# if IS_IN (libpthread) -# define CENABLE call __pthread_enable_asynccancel -# define CDISABLE call __pthread_disable_asynccancel -# elif IS_IN (libc) -# define CENABLE call __libc_enable_asynccancel -# define CDISABLE call __libc_disable_asynccancel -# elif IS_IN (librt) -# define CENABLE call __librt_enable_asynccancel -# define CDISABLE call __librt_disable_asynccancel -# else -# error Unsupported library -# endif - -#define COPY_ARGS_0 /* Nothing */ -#define COPY_ARGS_1 COPY_ARGS_0 mov %i0, %o0; -#define COPY_ARGS_2 COPY_ARGS_1 mov %i1, %o1; -#define COPY_ARGS_3 COPY_ARGS_2 mov %i2, %o2; -#define COPY_ARGS_4 COPY_ARGS_3 mov %i3, %o3; -#define COPY_ARGS_5 COPY_ARGS_4 mov %i4, %o4; -#define COPY_ARGS_6 COPY_ARGS_5 mov %i5, %o5; - -# ifndef __ASSEMBLER__ -# define SINGLE_THREAD_P \ - __builtin_expect (THREAD_GETMEM (THREAD_SELF, \ - header.multiple_threads) == 0, 1) -# else -# define SINGLE_THREAD_P ld [%g7 + MULTIPLE_THREADS_OFFSET], %g1 -# endif - -#elif !defined __ASSEMBLER__ - -# define SINGLE_THREAD_P (1) -# define NO_CANCELLATION 1 - -#endif - -#ifndef __ASSEMBLER__ -# define RTLD_SINGLE_THREAD_P \ - __builtin_expect (THREAD_GETMEM (THREAD_SELF, \ - header.multiple_threads) == 0, 1) -#endif diff --git a/sysdeps/unix/sysv/linux/sparc/sparc64/sysdep-cancel.h b/sysdeps/unix/sysv/linux/sparc/sparc64/sysdep-cancel.h deleted file mode 100644 index 45fbd73..0000000 --- a/sysdeps/unix/sysv/linux/sparc/sparc64/sysdep-cancel.h +++ /dev/null @@ -1,109 +0,0 @@ -/* Copyright (C) 2002-2017 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Jakub Jelinek , 2002. - - 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 -#ifndef __ASSEMBLER__ -# include -#endif - -#if IS_IN (libc) || IS_IN (libpthread) || IS_IN (librt) - -# undef PSEUDO -# define PSEUDO(name, syscall_name, args) \ - .text; \ - .globl __syscall_error; \ -ENTRY(name) \ - ld [%g7 + MULTIPLE_THREADS_OFFSET], %g1;\ - brnz,pn %g1, 1f; \ -.type __##syscall_name##_nocancel,@function; \ -.globl __##syscall_name##_nocancel; \ -__##syscall_name##_nocancel: \ - mov SYS_ify(syscall_name), %g1; \ - ta 0x6d; \ - bcc,pt %xcc, 8f; \ - mov %o7, %g1; \ - call __syscall_error; \ - mov %g1, %o7; \ -8: jmpl %o7 + 8, %g0; \ - nop; \ -.size __##syscall_name##_nocancel,.-__##syscall_name##_nocancel;\ -1: save %sp, -192, %sp; \ - cfi_def_cfa_register(%fp); \ - cfi_window_save; \ - cfi_register(%o7, %i7); \ - CENABLE; \ - nop; \ - mov %o0, %l0; \ - COPY_ARGS_##args \ - mov SYS_ify(syscall_name), %g1; \ - ta 0x6d; \ - bcc,pt %xcc, 1f; \ - mov %o0, %l1; \ - CDISABLE; \ - mov %l0, %o0; \ - call __syscall_error; \ - mov %l1, %o0; \ - ba,pt %xcc, 2f; \ - mov -1, %l1; \ -1: CDISABLE; \ - mov %l0, %o0; \ -2: jmpl %i7 + 8, %g0; \ - restore %g0, %l1, %o0; - -# if IS_IN (libpthread) -# define CENABLE call __pthread_enable_asynccancel -# define CDISABLE call __pthread_disable_asynccancel -# elif IS_IN (libc) -# define CENABLE call __libc_enable_asynccancel -# define CDISABLE call __libc_disable_asynccancel -# elif IS_IN (librt) -# define CENABLE call __librt_enable_asynccancel -# define CDISABLE call __librt_disable_asynccancel -# else -# error Unsupported library -# endif - -#define COPY_ARGS_0 /* Nothing */ -#define COPY_ARGS_1 COPY_ARGS_0 mov %i0, %o0; -#define COPY_ARGS_2 COPY_ARGS_1 mov %i1, %o1; -#define COPY_ARGS_3 COPY_ARGS_2 mov %i2, %o2; -#define COPY_ARGS_4 COPY_ARGS_3 mov %i3, %o3; -#define COPY_ARGS_5 COPY_ARGS_4 mov %i4, %o4; -#define COPY_ARGS_6 COPY_ARGS_5 mov %i5, %o5; - -# ifndef __ASSEMBLER__ -# define SINGLE_THREAD_P \ - __builtin_expect (THREAD_GETMEM (THREAD_SELF, \ - header.multiple_threads) == 0, 1) -# else -# define SINGLE_THREAD_P ld [%g7 + MULTIPLE_THREADS_OFFSET], %g1 -# endif - -#elif !defined __ASSEMBLER__ - -# define SINGLE_THREAD_P (1) -# define NO_CANCELLATION 1 - -#endif - -#ifndef __ASSEMBLER__ -# define RTLD_SINGLE_THREAD_P \ - __builtin_expect (THREAD_GETMEM (THREAD_SELF, \ - header.multiple_threads) == 0, 1) -#endif diff --git a/sysdeps/unix/sysv/linux/sparc/sysdep-cancel.h b/sysdeps/unix/sysv/linux/sparc/sysdep-cancel.h new file mode 100644 index 0000000..61bfa33 --- /dev/null +++ b/sysdeps/unix/sysv/linux/sparc/sysdep-cancel.h @@ -0,0 +1,38 @@ +/* Copyright (C) 2002-2015 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Jakub Jelinek , 2002. + + 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 + +#if IS_IN (libc) || IS_IN (libpthread) || IS_IN (librt) + +# define SINGLE_THREAD_P \ + __builtin_expect (THREAD_GETMEM (THREAD_SELF, \ + header.multiple_threads) == 0, 1) + +#else + +# define SINGLE_THREAD_P (1) +# define NO_CANCELLATION 1 + +#endif + +#define RTLD_SINGLE_THREAD_P \ + __builtin_expect (THREAD_GETMEM (THREAD_SELF, \ + header.multiple_threads) == 0, 1) diff --git a/sysdeps/unix/sysv/linux/tile/sysdep-cancel.h b/sysdeps/unix/sysv/linux/tile/sysdep-cancel.h index 092a90c..c8994db 100644 --- a/sysdeps/unix/sysv/linux/tile/sysdep-cancel.h +++ b/sysdeps/unix/sysv/linux/tile/sysdep-cancel.h @@ -18,137 +18,22 @@ #include #include -#ifndef __ASSEMBLER__ -# include -#endif +#include #if IS_IN (libc) || IS_IN (libpthread) || IS_IN (librt) -/* Allow hacking in some extra code if desired. */ -#ifndef PSEUDO_EXTRA -#define PSEUDO_EXTRA -#endif - -#undef PSEUDO -#define PSEUDO(name, syscall_name, args) \ - ENTRY(__##syscall_name##_nocancel); \ - PSEUDO_EXTRA \ - moveli TREG_SYSCALL_NR_NAME, SYS_ify(syscall_name); \ - swint1; \ - BNEZ r1, 0f; \ - jrp lr; \ - END(__##syscall_name##_nocancel); \ - ENTRY (name) \ - SINGLE_THREAD_P(r11); \ - BEQZ r11, L(pseudo_cancel); \ - PSEUDO_EXTRA \ - moveli TREG_SYSCALL_NR_NAME, SYS_ify(syscall_name); \ - swint1; \ - BNEZ r1, 0f; \ - jrp lr; \ - L(pseudo_cancel): \ - { \ - move r11, sp; \ - ST sp, lr; \ - ADDI_PTR sp, sp, -STKSPACE; \ - }; \ - cfi_offset (lr, 0); \ - cfi_def_cfa_offset (STKSPACE); \ - { \ - ADDI_PTR r12, sp, REGSIZE; \ - ADDI_PTR r13, sp, 2 * REGSIZE; /* set up for PUSHARGS_0 */ \ - }; \ - ST r12, r11; \ - PUSHARGS_##args /* save syscall args */ \ - CENABLE; \ - ADDI_PTR r12, sp, 10 * REGSIZE; \ - { \ - ST r12, r0; /* save mask */ \ - ADDI_PTR r13, sp, 2 * REGSIZE; /* set up for POPARGS_0 */ \ - }; \ - POPARGS_##args /* restore syscall args */ \ - PSEUDO_EXTRA \ - moveli TREG_SYSCALL_NR_NAME, SYS_ify(syscall_name); \ - swint1; \ - ADDI_PTR r12, sp, 12 * REGSIZE; \ - { \ - ST r12, r1; /* save syscall result */ \ - ADDI_PTR r12, sp, 11 * REGSIZE; \ - }; \ - { \ - ST r12, r0; \ - ADDI_PTR r13, sp, 10 * REGSIZE; \ - }; \ - LD r0, r13; /* pass mask as arg1 */ \ - CDISABLE; \ - { \ - ADDI_PTR lr, sp, STKSPACE; \ - ADDI_PTR r0, sp, 11 * REGSIZE; \ - }; \ - { \ - LD r0, r0; \ - ADDI_PTR r1, sp, 12 * REGSIZE; \ - }; \ - LD r1, r1; \ - { \ - LD lr, lr; \ - ADDI_PTR sp, sp, STKSPACE; \ - }; \ - cfi_def_cfa_offset (0); \ - BNEZ r1, 0f - -# define PUSHARGS_0 /* nothing to do */ -# define PUSHARGS_1 PUSHARGS_0 { ADDI_PTR r14, sp, 3 * REGSIZE; ST r13, r0 }; -# define PUSHARGS_2 PUSHARGS_1 { ADDI_PTR r13, sp, 4 * REGSIZE; ST r14, r1 }; -# define PUSHARGS_3 PUSHARGS_2 { ADDI_PTR r14, sp, 5 * REGSIZE; ST r13, r2 }; -# define PUSHARGS_4 PUSHARGS_3 { ADDI_PTR r13, sp, 6 * REGSIZE; ST r14, r3 }; -# define PUSHARGS_5 PUSHARGS_4 { ADDI_PTR r14, sp, 7 * REGSIZE; ST r13, r4 }; -# define PUSHARGS_6 PUSHARGS_5 { ADDI_PTR r13, sp, 8 * REGSIZE; ST r14, r5 }; -# define PUSHARGS_7 PUSHARGS_6 { ADDI_PTR r14, sp, 9 * REGSIZE; ST r13, r6 }; - -# define POPARGS_0 /* nothing to do */ -# define POPARGS_1 POPARGS_0 { ADDI_PTR r14, sp, 3 * REGSIZE; LD r0, r13 }; -# define POPARGS_2 POPARGS_1 { ADDI_PTR r13, sp, 4 * REGSIZE; LD r1, r14 }; -# define POPARGS_3 POPARGS_2 { ADDI_PTR r14, sp, 5 * REGSIZE; LD r2, r13 }; -# define POPARGS_4 POPARGS_3 { ADDI_PTR r13, sp, 6 * REGSIZE; LD r3, r14 }; -# define POPARGS_5 POPARGS_4 { ADDI_PTR r14, sp, 7 * REGSIZE; LD r4, r13 }; -# define POPARGS_6 POPARGS_5 { ADDI_PTR r13, sp, 8 * REGSIZE; LD r5, r14 }; -# define POPARGS_7 POPARGS_6 { ADDI_PTR r14, sp, 9 * REGSIZE; LD r6, r13 }; - -# define STKSPACE (13 * REGSIZE) - -# if IS_IN (libpthread) -# define CENABLE jal __pthread_enable_asynccancel -# define CDISABLE jal __pthread_disable_asynccancel -# elif IS_IN (librt) -# define CENABLE jal __librt_enable_asynccancel -# define CDISABLE jal __librt_disable_asynccancel -# else -# define CENABLE jal __libc_enable_asynccancel -# define CDISABLE jal __libc_disable_asynccancel -# endif - -# ifndef __ASSEMBLER__ -# define SINGLE_THREAD_P \ +# define SINGLE_THREAD_P \ __builtin_expect (THREAD_GETMEM (THREAD_SELF, \ header.multiple_threads) \ == 0, 1) -# else -# define SINGLE_THREAD_P(reg) \ - ADDLI_PTR reg, tp, MULTIPLE_THREADS_OFFSET; \ - LD reg, reg; \ - CMPEQI reg, reg, 0 -#endif -#elif !defined __ASSEMBLER__ +#else # define SINGLE_THREAD_P 1 # define NO_CANCELLATION 1 #endif -#ifndef __ASSEMBLER__ -# define RTLD_SINGLE_THREAD_P \ +#define RTLD_SINGLE_THREAD_P \ __builtin_expect (THREAD_GETMEM (THREAD_SELF, \ header.multiple_threads) == 0, 1) -#endif diff --git a/sysdeps/unix/sysv/linux/x86_64/sysdep-cancel.h b/sysdeps/unix/sysv/linux/x86_64/sysdep-cancel.h index 6598010..0979bde 100644 --- a/sysdeps/unix/sysv/linux/x86_64/sysdep-cancel.h +++ b/sysdeps/unix/sysv/linux/x86_64/sysdep-cancel.h @@ -24,86 +24,32 @@ #if IS_IN (libc) || IS_IN (libpthread) || IS_IN (librt) -/* The code to disable cancellation depends on the fact that the called - functions are special. They don't modify registers other than %rax - and %r11 if they return. Therefore we don't have to preserve other - registers around these calls. */ -# undef PSEUDO -# define PSEUDO(name, syscall_name, args) \ - .text; \ - ENTRY (name) \ - SINGLE_THREAD_P; \ - jne L(pseudo_cancel); \ - .type __##syscall_name##_nocancel,@function; \ - .globl __##syscall_name##_nocancel; \ - __##syscall_name##_nocancel: \ - DO_CALL (syscall_name, args); \ - cmpq $-4095, %rax; \ - jae SYSCALL_ERROR_LABEL; \ - ret; \ - .size __##syscall_name##_nocancel,.-__##syscall_name##_nocancel; \ - L(pseudo_cancel): \ - /* We always have to align the stack before calling a function. */ \ - subq $8, %rsp; cfi_adjust_cfa_offset (8); \ - CENABLE \ - /* The return value from CENABLE is argument for CDISABLE. */ \ - movq %rax, (%rsp); \ - DO_CALL (syscall_name, args); \ - movq (%rsp), %rdi; \ - /* Save %rax since it's the error code from the syscall. */ \ - movq %rax, %rdx; \ - CDISABLE \ - movq %rdx, %rax; \ - addq $8,%rsp; cfi_adjust_cfa_offset (-8); \ - cmpq $-4095, %rax; \ - jae SYSCALL_ERROR_LABEL - - # if IS_IN (libpthread) -# define CENABLE call __pthread_enable_asynccancel; -# define CDISABLE call __pthread_disable_asynccancel; # define __local_multiple_threads __pthread_multiple_threads # elif IS_IN (libc) -# define CENABLE call __libc_enable_asynccancel; -# define CDISABLE call __libc_disable_asynccancel; # define __local_multiple_threads __libc_multiple_threads # elif IS_IN (librt) -# define CENABLE call __librt_enable_asynccancel; -# define CDISABLE call __librt_disable_asynccancel; # else # error Unsupported library # endif # if IS_IN (libpthread) || IS_IN (libc) -# ifndef __ASSEMBLER__ extern int __local_multiple_threads attribute_hidden; -# define SINGLE_THREAD_P \ +# define SINGLE_THREAD_P \ __builtin_expect (__local_multiple_threads == 0, 1) -# else -# define SINGLE_THREAD_P cmpl $0, __local_multiple_threads(%rip) -# endif - # else - -# ifndef __ASSEMBLER__ -# define SINGLE_THREAD_P \ +# define SINGLE_THREAD_P \ __builtin_expect (THREAD_GETMEM (THREAD_SELF, \ header.multiple_threads) == 0, 1) -# else -# define SINGLE_THREAD_P cmpl $0, %fs:MULTIPLE_THREADS_OFFSET -# endif - # endif -#elif !defined __ASSEMBLER__ +#else # define SINGLE_THREAD_P (1) # define NO_CANCELLATION 1 #endif -#ifndef __ASSEMBLER__ -# define RTLD_SINGLE_THREAD_P \ +#define RTLD_SINGLE_THREAD_P \ __builtin_expect (THREAD_GETMEM (THREAD_SELF, \ header.multiple_threads) == 0, 1) -#endif