From patchwork Mon Nov 9 20:18:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 40981 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A990B3971C78; Mon, 9 Nov 2020 20:18:42 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A990B3971C78 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1604953122; bh=WzJKGp1i1+nzPr3pCBVvM4zLmi8zQ9Lv7t2k2FHck+A=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=nOKVpDxQtk8Rqh8AS+RPCyBB000Gomlqw49oovFlUGIFkNvwAPKTmp8VHbOj0A8WK 4UEYD1z6EytMNnO+kqewbr80JnPmeu674QxGeWO3DvP6xCd1IDEu5k8EJCa/TvZ2oS xu0BPJH48znWnXUwckWfoTaQM1UfidoOdVgdk6uQ= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-qt1-x844.google.com (mail-qt1-x844.google.com [IPv6:2607:f8b0:4864:20::844]) by sourceware.org (Postfix) with ESMTPS id E6178385EC57 for ; Mon, 9 Nov 2020 20:18:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org E6178385EC57 Received: by mail-qt1-x844.google.com with SMTP id v11so6582665qtq.12 for ; Mon, 09 Nov 2020 12:18:36 -0800 (PST) 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:mime-version:content-transfer-encoding; bh=WzJKGp1i1+nzPr3pCBVvM4zLmi8zQ9Lv7t2k2FHck+A=; b=uFTTpR50RN7WPM+w/66J4o5EvZ3T5pPnMInmhZLIylCE5DMm9bLiXxrlbG+4GIF/Db ZAEdgCVJPkpD2+wFPMcxa0oESLflLdupvDBjY4IYoZjVD7G1KVNRbbHtwURw8SdoOhcm UdwQJkimH9uNf4kwknFCJoHqZxwU6pcW/jflGe+8LDQmBrgzeELou6lFxat7UvnrGbNj ZDnprSIH6lnTrqn2mgyTqOOu0qXcpBs6uvjc7Bn0JyrN7IBBTPE6Brh0qQjYZ3ESB9PP 12MIWTICdLtYnIuC7FQQgE302gSTWBw9DhrdhGBpmOZpf/pqbISvw0C6y5Tt4Rvc50xQ bFkw== X-Gm-Message-State: AOAM533UCGMW1E32Iz0eBIxpQgKN8erAEXONy8elTlB75eZw1uzNSgYU cQysqRo3/CBI6vgvRBbnQ1lKO1JbLmOYbA== X-Google-Smtp-Source: ABdhPJx/QyB7Cz38pr0rpytFPmGGjnKGJL9/k5x8iGURpyDRTjNWkYmSA1ipIQsl2xTbgsVGpNQRdg== X-Received: by 2002:aed:3147:: with SMTP id 65mr15280222qtg.295.1604953115917; Mon, 09 Nov 2020 12:18:35 -0800 (PST) Received: from localhost.localdomain ([177.194.48.209]) by smtp.googlemail.com with ESMTPSA id z2sm6843407qkl.22.2020.11.09.12.18.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Nov 2020 12:18:35 -0800 (PST) To: libc-alpha@sourceware.org Subject: [PATCH 01/23] linux: Remove INTERNAL_SYSCALL_ERRNO Date: Mon, 9 Nov 2020 17:18:04 -0300 Message-Id: <20201109201826.120534-2-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201109201826.120534-1-adhemerval.zanella@linaro.org> References: <20201109201826.120534-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-14.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Adhemerval Zanella via Libc-alpha From: Adhemerval Zanella Netto Reply-To: Adhemerval Zanella Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" All architectures now returns the error code on the INTERNAL_SYSCALL value and follow the Linux de-facto ABI (error are signaled with a value between -4096UL and -1UL). This make the INTERNAL_SYSCALL_ERRNO superflous and some implementations already checks for either values different than 0 or for an specific errno in the failure case. Checked on x86_64-linux-gnu and powerpc64le-linux-gnu. --- nptl/allocatestack.c | 2 +- nptl/nptl-init.c | 2 +- nptl/pthread_cancel.c | 2 +- nptl/pthread_getaffinity.c | 2 +- nptl/pthread_mutex_trylock.c | 3 +-- nptl/pthread_setaffinity.c | 2 +- nptl/pthread_sigmask.c | 2 +- sysdeps/nptl/lowlevellock-futex.h | 2 +- sysdeps/unix/sysv/linux/createthread.c | 2 +- sysdeps/unix/sysv/linux/dl-write.c | 5 +---- sysdeps/unix/sysv/linux/fcntl_nocancel.c | 3 +-- sysdeps/unix/sysv/linux/libc_fatal.c | 3 +-- sysdeps/unix/sysv/linux/mq_unlink.c | 7 +++---- sysdeps/unix/sysv/linux/not-errno.h | 4 ++-- sysdeps/unix/sysv/linux/personality.c | 10 +--------- sysdeps/unix/sysv/linux/posix_fadvise.c | 4 +--- sysdeps/unix/sysv/linux/posix_fadvise64.c | 4 +--- sysdeps/unix/sysv/linux/posix_fallocate.c | 4 ++-- sysdeps/unix/sysv/linux/posix_fallocate64.c | 4 ++-- sysdeps/unix/sysv/linux/posix_madvise.c | 3 +-- sysdeps/unix/sysv/linux/pthread_kill.c | 3 +-- sysdeps/unix/sysv/linux/pthread_sigqueue.c | 3 +-- sysdeps/unix/sysv/linux/s390/s390-32/posix_fadvise64.c | 4 +--- sysdeps/unix/sysv/linux/shmat.c | 2 +- sysdeps/unix/sysv/linux/sysdep-vdso.h | 4 ++-- sysdeps/unix/sysv/linux/sysdep.h | 5 +---- sysdeps/unix/sysv/linux/timer_create.c | 2 +- sysdeps/unix/sysv/linux/times.c | 2 +- 28 files changed, 34 insertions(+), 61 deletions(-) diff --git a/nptl/allocatestack.c b/nptl/allocatestack.c index 4b45f8c884..a9e9d39354 100644 --- a/nptl/allocatestack.c +++ b/nptl/allocatestack.c @@ -1174,7 +1174,7 @@ __nptl_setxid (struct xid_command *cmdp) int error = 0; if (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (result))) { - error = INTERNAL_SYSCALL_ERRNO (result); + error = -result; __set_errno (error); result = -1; } diff --git a/nptl/nptl-init.c b/nptl/nptl-init.c index 95c60a524a..8aef4c83b5 100644 --- a/nptl/nptl-init.c +++ b/nptl/nptl-init.c @@ -192,7 +192,7 @@ sighandler_setxid (int sig, siginfo_t *si, void *ctx) __xidcmd->id[1], __xidcmd->id[2]); int error = 0; if (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (result))) - error = INTERNAL_SYSCALL_ERRNO (result); + error = -result; __nptl_setxid_error (__xidcmd, error); /* Reset the SETXID flag. */ diff --git a/nptl/pthread_cancel.c b/nptl/pthread_cancel.c index 88c1ab8f6a..7daf4f8c15 100644 --- a/nptl/pthread_cancel.c +++ b/nptl/pthread_cancel.c @@ -70,7 +70,7 @@ __pthread_cancel (pthread_t th) int val = INTERNAL_SYSCALL_CALL (tgkill, pid, pd->tid, SIGCANCEL); if (INTERNAL_SYSCALL_ERROR_P (val)) - result = INTERNAL_SYSCALL_ERRNO (val); + result = -val; break; } diff --git a/nptl/pthread_getaffinity.c b/nptl/pthread_getaffinity.c index 6ebd1ded2d..ffeb878c7c 100644 --- a/nptl/pthread_getaffinity.c +++ b/nptl/pthread_getaffinity.c @@ -34,7 +34,7 @@ __pthread_getaffinity_np (pthread_t th, size_t cpusetsize, cpu_set_t *cpuset) int res = INTERNAL_SYSCALL_CALL (sched_getaffinity, pd->tid, MIN (INT_MAX, cpusetsize), cpuset); if (INTERNAL_SYSCALL_ERROR_P (res)) - return INTERNAL_SYSCALL_ERRNO (res); + return -res; /* Clean the rest of the memory the kernel didn't do. */ memset ((char *) cpuset + res, '\0', cpusetsize - res); diff --git a/nptl/pthread_mutex_trylock.c b/nptl/pthread_mutex_trylock.c index 2130f52529..5c294a3eea 100644 --- a/nptl/pthread_mutex_trylock.c +++ b/nptl/pthread_mutex_trylock.c @@ -301,8 +301,7 @@ __pthread_mutex_trylock (pthread_mutex_t *mutex) __lll_private_flag (FUTEX_TRYLOCK_PI, private), 0, 0); - if (INTERNAL_SYSCALL_ERROR_P (e) - && INTERNAL_SYSCALL_ERRNO (e) == EWOULDBLOCK) + if (INTERNAL_SYSCALL_ERROR_P (e) && e == -EWOULDBLOCK) { /* The kernel has not yet finished the mutex owner death. We do not need to ensure ordering wrt another memory diff --git a/nptl/pthread_setaffinity.c b/nptl/pthread_setaffinity.c index b0bd90c324..aaaa4f0194 100644 --- a/nptl/pthread_setaffinity.c +++ b/nptl/pthread_setaffinity.c @@ -34,7 +34,7 @@ __pthread_setaffinity_new (pthread_t th, size_t cpusetsize, cpuset); return (INTERNAL_SYSCALL_ERROR_P (res) - ? INTERNAL_SYSCALL_ERRNO (res) + ? -res : 0); } versioned_symbol (libpthread, __pthread_setaffinity_new, diff --git a/nptl/pthread_sigmask.c b/nptl/pthread_sigmask.c index 7b65ae1f27..1d6d753af4 100644 --- a/nptl/pthread_sigmask.c +++ b/nptl/pthread_sigmask.c @@ -42,7 +42,7 @@ __pthread_sigmask (int how, const sigset_t *newmask, sigset_t *oldmask) oldmask, __NSIG_BYTES); return (INTERNAL_SYSCALL_ERROR_P (result) - ? INTERNAL_SYSCALL_ERRNO (result) + ? -result : 0); } libc_hidden_def (__pthread_sigmask) diff --git a/sysdeps/nptl/lowlevellock-futex.h b/sysdeps/nptl/lowlevellock-futex.h index 2209ca76a1..dd36997021 100644 --- a/sysdeps/nptl/lowlevellock-futex.h +++ b/sysdeps/nptl/lowlevellock-futex.h @@ -70,7 +70,7 @@ long int __ret = INTERNAL_SYSCALL (futex, nargs, futexp, op, \ __VA_ARGS__); \ (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (__ret)) \ - ? -INTERNAL_SYSCALL_ERRNO (__ret) : 0); \ + ? __ret : 0); \ }) /* For most of these macros, the return value is never really used. diff --git a/sysdeps/unix/sysv/linux/createthread.c b/sysdeps/unix/sysv/linux/createthread.c index 6588893ba5..01cf2ff42a 100644 --- a/sysdeps/unix/sysv/linux/createthread.c +++ b/sysdeps/unix/sysv/linux/createthread.c @@ -132,7 +132,7 @@ create_thread (struct pthread *pd, const struct pthread_attr *attr, pid_t pid = __getpid (); INTERNAL_SYSCALL_CALL (tgkill, pid, pd->tid, SIGCANCEL); - return INTERNAL_SYSCALL_ERRNO (res); + return -res; } } diff --git a/sysdeps/unix/sysv/linux/dl-write.c b/sysdeps/unix/sysv/linux/dl-write.c index 1c6298fb41..cce5a55e68 100644 --- a/sysdeps/unix/sysv/linux/dl-write.c +++ b/sysdeps/unix/sysv/linux/dl-write.c @@ -23,8 +23,5 @@ ssize_t _dl_write (int fd, const void *buffer, size_t length) { - long int r = INTERNAL_SYSCALL_CALL (write, fd, buffer, length); - if (INTERNAL_SYSCALL_ERROR_P (r)) - r = - INTERNAL_SYSCALL_ERRNO (r); - return r; + return INTERNAL_SYSCALL_CALL (write, fd, buffer, length); } diff --git a/sysdeps/unix/sysv/linux/fcntl_nocancel.c b/sysdeps/unix/sysv/linux/fcntl_nocancel.c index ed9211001f..1bf3030f75 100644 --- a/sysdeps/unix/sysv/linux/fcntl_nocancel.c +++ b/sysdeps/unix/sysv/linux/fcntl_nocancel.c @@ -56,8 +56,7 @@ __fcntl64_nocancel_adjusted (int fd, int cmd, void *arg) if (!INTERNAL_SYSCALL_ERROR_P (res)) return fex.type == F_OWNER_GID ? -fex.pid : fex.pid; - return INLINE_SYSCALL_ERROR_RETURN_VALUE - (INTERNAL_SYSCALL_ERRNO (res)); + return INLINE_SYSCALL_ERROR_RETURN_VALUE (-res); } return INLINE_SYSCALL_CALL (fcntl64, fd, cmd, (void *) arg); diff --git a/sysdeps/unix/sysv/linux/libc_fatal.c b/sysdeps/unix/sysv/linux/libc_fatal.c index 7e22c0fc32..35a20ca0fd 100644 --- a/sysdeps/unix/sysv/linux/libc_fatal.c +++ b/sysdeps/unix/sysv/linux/libc_fatal.c @@ -25,8 +25,7 @@ writev_for_fatal (int fd, const struct iovec *iov, size_t niov, size_t total) ssize_t cnt; do cnt = INTERNAL_SYSCALL_CALL (writev, fd, iov, niov); - while (INTERNAL_SYSCALL_ERROR_P (cnt) - && INTERNAL_SYSCALL_ERRNO (cnt) == EINTR); + while (INTERNAL_SYSCALL_ERROR_P (cnt) && cnt == -EINTR); return cnt == total; } #define WRITEV_FOR_FATAL writev_for_fatal diff --git a/sysdeps/unix/sysv/linux/mq_unlink.c b/sysdeps/unix/sysv/linux/mq_unlink.c index 85fb5d0951..ed7858dc9d 100644 --- a/sysdeps/unix/sysv/linux/mq_unlink.c +++ b/sysdeps/unix/sysv/linux/mq_unlink.c @@ -32,10 +32,9 @@ mq_unlink (const char *name) return just EACCES. */ if (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (ret))) { - ret = INTERNAL_SYSCALL_ERRNO (ret); - if (ret == EPERM) - ret = EACCES; - return INLINE_SYSCALL_ERROR_RETURN_VALUE (ret); + if (ret == -EPERM) + ret = -EACCES; + return INLINE_SYSCALL_ERROR_RETURN_VALUE (-ret); } return ret; diff --git a/sysdeps/unix/sysv/linux/not-errno.h b/sysdeps/unix/sysv/linux/not-errno.h index 394dabeb93..fc0eda09d9 100644 --- a/sysdeps/unix/sysv/linux/not-errno.h +++ b/sysdeps/unix/sysv/linux/not-errno.h @@ -32,7 +32,7 @@ __access_noerrno (const char *pathname, int mode) res = INTERNAL_SYSCALL_CALL (faccessat, AT_FDCWD, pathname, mode); #endif if (INTERNAL_SYSCALL_ERROR_P (res)) - return INTERNAL_SYSCALL_ERRNO (res); + return -res; return 0; } @@ -42,6 +42,6 @@ __kill_noerrno (pid_t pid, int sig) int res; res = INTERNAL_SYSCALL_CALL (kill, pid, sig); if (INTERNAL_SYSCALL_ERROR_P (res)) - return INTERNAL_SYSCALL_ERRNO (res); + return -res; return 0; } diff --git a/sysdeps/unix/sysv/linux/personality.c b/sysdeps/unix/sysv/linux/personality.c index e45fffa1c2..75f9d0adb2 100644 --- a/sysdeps/unix/sysv/linux/personality.c +++ b/sysdeps/unix/sysv/linux/personality.c @@ -35,14 +35,6 @@ __personality (unsigned long persona) persona = (unsigned int) persona; #endif - long int ret = INTERNAL_SYSCALL_CALL (personality, persona); - - /* Starting with kernel commit v2.6.29-6609-g11d06b2, the personality syscall - never fails. However, 32-bit kernels might flag valid values as errors, so - we need to reverse the error setting. We can't use the raw result as some - arches split the return/error values. */ - if (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (ret))) - ret = -INTERNAL_SYSCALL_ERRNO (ret); - return ret; + return INTERNAL_SYSCALL_CALL (personality, persona); } weak_alias (__personality, personality) diff --git a/sysdeps/unix/sysv/linux/posix_fadvise.c b/sysdeps/unix/sysv/linux/posix_fadvise.c index bada96b697..1191ab3db5 100644 --- a/sysdeps/unix/sysv/linux/posix_fadvise.c +++ b/sysdeps/unix/sysv/linux/posix_fadvise.c @@ -60,8 +60,6 @@ posix_fadvise (int fd, off_t offset, off_t len, int advise) SYSCALL_LL (len), advise); # endif # endif - if (INTERNAL_SYSCALL_ERROR_P (ret)) - return INTERNAL_SYSCALL_ERRNO (ret); - return 0; + return INTERNAL_SYSCALL_ERROR_P (ret) ? -ret : 0; } #endif /* __OFF_T_MATCHES_OFF64_T */ diff --git a/sysdeps/unix/sysv/linux/posix_fadvise64.c b/sysdeps/unix/sysv/linux/posix_fadvise64.c index 9787ab4c7c..e3726a6a8a 100644 --- a/sysdeps/unix/sysv/linux/posix_fadvise64.c +++ b/sysdeps/unix/sysv/linux/posix_fadvise64.c @@ -48,9 +48,7 @@ __posix_fadvise64_l64 (int fd, off64_t offset, off64_t len, int advise) __ALIGNMENT_ARG SYSCALL_LL64 (offset), SYSCALL_LL64 (len), advise); #endif - if (!INTERNAL_SYSCALL_ERROR_P (ret)) - return 0; - return INTERNAL_SYSCALL_ERRNO (ret); + return INTERNAL_SYSCALL_ERROR_P (ret) ? -ret : 0; } /* The type of the len argument was changed from size_t to off_t in diff --git a/sysdeps/unix/sysv/linux/posix_fallocate.c b/sysdeps/unix/sysv/linux/posix_fallocate.c index 7238b00038..87532668cd 100644 --- a/sysdeps/unix/sysv/linux/posix_fallocate.c +++ b/sysdeps/unix/sysv/linux/posix_fallocate.c @@ -30,7 +30,7 @@ posix_fallocate (int fd, __off_t offset, __off_t len) SYSCALL_LL (offset), SYSCALL_LL (len)); if (! INTERNAL_SYSCALL_ERROR_P (res)) return 0; - if (INTERNAL_SYSCALL_ERRNO (res) != EOPNOTSUPP) - return INTERNAL_SYSCALL_ERRNO (res); + if (res != -EOPNOTSUPP) + return -res; return internal_fallocate (fd, offset, len); } diff --git a/sysdeps/unix/sysv/linux/posix_fallocate64.c b/sysdeps/unix/sysv/linux/posix_fallocate64.c index 2de63ac277..0340357e57 100644 --- a/sysdeps/unix/sysv/linux/posix_fallocate64.c +++ b/sysdeps/unix/sysv/linux/posix_fallocate64.c @@ -32,8 +32,8 @@ __posix_fallocate64_l64 (int fd, __off64_t offset, __off64_t len) SYSCALL_LL64 (offset), SYSCALL_LL64 (len)); if (! INTERNAL_SYSCALL_ERROR_P (res)) return 0; - if (INTERNAL_SYSCALL_ERRNO (res) != EOPNOTSUPP) - return INTERNAL_SYSCALL_ERRNO (res); + if (-res != EOPNOTSUPP) + return -res; return internal_fallocate64 (fd, offset, len); } libc_hidden_def (__posix_fallocate64_l64) diff --git a/sysdeps/unix/sysv/linux/posix_madvise.c b/sysdeps/unix/sysv/linux/posix_madvise.c index 0e49f3b7ac..5fe2e5f653 100644 --- a/sysdeps/unix/sysv/linux/posix_madvise.c +++ b/sysdeps/unix/sysv/linux/posix_madvise.c @@ -31,6 +31,5 @@ posix_madvise (void *addr, size_t len, int advice) if (advice == POSIX_MADV_DONTNEED) return 0; - int result = INTERNAL_SYSCALL_CALL (madvise, addr, len, advice); - return INTERNAL_SYSCALL_ERRNO (result); + return -INTERNAL_SYSCALL_CALL (madvise, addr, len, advice); } diff --git a/sysdeps/unix/sysv/linux/pthread_kill.c b/sysdeps/unix/sysv/linux/pthread_kill.c index 4dfe08ffcd..defdeaecac 100644 --- a/sysdeps/unix/sysv/linux/pthread_kill.c +++ b/sysdeps/unix/sysv/linux/pthread_kill.c @@ -51,7 +51,6 @@ __pthread_kill (pthread_t threadid, int signo) pid_t pid = __getpid (); int val = INTERNAL_SYSCALL_CALL (tgkill, pid, tid, signo); - return (INTERNAL_SYSCALL_ERROR_P (val) - ? INTERNAL_SYSCALL_ERRNO (val) : 0); + return INTERNAL_SYSCALL_ERROR_P (val) ? -val : 0; } strong_alias (__pthread_kill, pthread_kill) diff --git a/sysdeps/unix/sysv/linux/pthread_sigqueue.c b/sysdeps/unix/sysv/linux/pthread_sigqueue.c index 4b32be2d64..fbbd9fee20 100644 --- a/sysdeps/unix/sysv/linux/pthread_sigqueue.c +++ b/sysdeps/unix/sysv/linux/pthread_sigqueue.c @@ -63,8 +63,7 @@ pthread_sigqueue (pthread_t threadid, int signo, const union sigval value) /* We have a special syscall to do the work. */ int val = INTERNAL_SYSCALL_CALL (rt_tgsigqueueinfo, pid, tid, signo, &info); - return (INTERNAL_SYSCALL_ERROR_P (val) - ? INTERNAL_SYSCALL_ERRNO (val) : 0); + return INTERNAL_SYSCALL_ERROR_P (val) ? -val : 0; #else return ENOSYS; #endif diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/posix_fadvise64.c b/sysdeps/unix/sysv/linux/s390/s390-32/posix_fadvise64.c index b556a6caae..6199589307 100644 --- a/sysdeps/unix/sysv/linux/s390/s390-32/posix_fadvise64.c +++ b/sysdeps/unix/sysv/linux/s390/s390-32/posix_fadvise64.c @@ -43,9 +43,7 @@ __posix_fadvise64_l64 (int fd, off64_t offset, off64_t len, int advise) parameters.len = len; parameters.advise = advise; int ret = INTERNAL_SYSCALL_CALL (fadvise64_64, ¶meters); - if (!INTERNAL_SYSCALL_ERROR_P (ret)) - return 0; - return INTERNAL_SYSCALL_ERRNO (ret); + return INTERNAL_SYSCALL_ERROR_P (ret) ? -ret : 0; } #include diff --git a/sysdeps/unix/sysv/linux/shmat.c b/sysdeps/unix/sysv/linux/shmat.c index 89df350d84..d5a65c06c1 100644 --- a/sysdeps/unix/sysv/linux/shmat.c +++ b/sysdeps/unix/sysv/linux/shmat.c @@ -36,7 +36,7 @@ shmat (int shmid, const void *shmaddr, int shmflg) resultvar = INTERNAL_SYSCALL_CALL (ipc, IPCOP_shmat, shmid, shmflg, &raddr, shmaddr); if (INTERNAL_SYSCALL_ERROR_P (resultvar)) - return (void *) INLINE_SYSCALL_ERROR_RETURN_VALUE (INTERNAL_SYSCALL_ERRNO (resultvar)); + return (void *) INLINE_SYSCALL_ERROR_RETURN_VALUE (-resultvar); return raddr; #endif diff --git a/sysdeps/unix/sysv/linux/sysdep-vdso.h b/sysdeps/unix/sysv/linux/sysdep-vdso.h index a9215494dc..88db076184 100644 --- a/sysdeps/unix/sysv/linux/sysdep-vdso.h +++ b/sysdeps/unix/sysv/linux/sysdep-vdso.h @@ -38,7 +38,7 @@ sc_ret = INTERNAL_VSYSCALL_CALL (vdsop, nr, ##args); \ if (!INTERNAL_SYSCALL_ERROR_P (sc_ret)) \ goto out; \ - if (INTERNAL_SYSCALL_ERRNO (sc_ret) != ENOSYS) \ + if (sc_ret != -ENOSYS) \ goto iserr; \ } \ \ @@ -46,7 +46,7 @@ if (INTERNAL_SYSCALL_ERROR_P (sc_ret)) \ { \ iserr: \ - __set_errno (INTERNAL_SYSCALL_ERRNO (sc_ret)); \ + __set_errno (-sc_ret); \ sc_ret = -1L; \ } \ out: \ diff --git a/sysdeps/unix/sysv/linux/sysdep.h b/sysdeps/unix/sysv/linux/sysdep.h index 5e7b6c5765..4e25e51470 100644 --- a/sysdeps/unix/sysv/linux/sysdep.h +++ b/sysdeps/unix/sysv/linux/sysdep.h @@ -42,13 +42,10 @@ ({ \ long int sc_ret = INTERNAL_SYSCALL (name, nr, args); \ __glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (sc_ret)) \ - ? SYSCALL_ERROR_LABEL (INTERNAL_SYSCALL_ERRNO (sc_ret)) \ + ? SYSCALL_ERROR_LABEL (-sc_ret) \ : sc_ret; \ }) -#undef INTERNAL_SYSCALL_ERRNO -#define INTERNAL_SYSCALL_ERRNO(val) (-(val)) - /* Set error number and return -1. A target may choose to return the internal function, __syscall_error, which sets errno and returns -1. We use -1l, instead of -1, so that it can be casted to (void *). */ diff --git a/sysdeps/unix/sysv/linux/timer_create.c b/sysdeps/unix/sysv/linux/timer_create.c index 18fb00c6e6..d8289d1dc7 100644 --- a/sysdeps/unix/sysv/linux/timer_create.c +++ b/sysdeps/unix/sysv/linux/timer_create.c @@ -127,7 +127,7 @@ timer_create (clockid_t clock_id, struct sigevent *evp, timer_t *timerid) if (INTERNAL_SYSCALL_ERROR_P (res)) { free (newp); - __set_errno (INTERNAL_SYSCALL_ERRNO (res)); + __set_errno (-res); return -1; } diff --git a/sysdeps/unix/sysv/linux/times.c b/sysdeps/unix/sysv/linux/times.c index e3db9cb400..b5eb6404c9 100644 --- a/sysdeps/unix/sysv/linux/times.c +++ b/sysdeps/unix/sysv/linux/times.c @@ -25,7 +25,7 @@ __times (struct tms *buf) { clock_t ret = INTERNAL_SYSCALL_CALL (times, buf); if (INTERNAL_SYSCALL_ERROR_P (ret) - && __glibc_unlikely (INTERNAL_SYSCALL_ERRNO (ret) == EFAULT) + && __glibc_unlikely (ret == -EFAULT) && buf) { /* This might be an error or not. For architectures which have no From patchwork Mon Nov 9 20:18:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 40982 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 3C2283972446; Mon, 9 Nov 2020 20:18:43 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3C2283972446 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1604953123; bh=2SGCGCmp+kstSZnGmGmGbHKWMT5smKHTUUvFSu3ROz0=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=fFVJfCj93eAR6l/14X9Bh0Be2HbqMoG6PdJHEuLAIgSg+k0p6VPtLsRlJbqnGX+dx 3D/zK5A+qawB8D/EBHBO6kDo0GYgiUbiETPegchHGjpm9cEEEucMjGTDAYGdom9FCQ M2swv4ut6nX4NUZN8C5phLwf3v8jfsvZU5yC0Boc= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-qt1-x843.google.com (mail-qt1-x843.google.com [IPv6:2607:f8b0:4864:20::843]) by sourceware.org (Postfix) with ESMTPS id 01EBD3857C56 for ; Mon, 9 Nov 2020 20:18:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 01EBD3857C56 Received: by mail-qt1-x843.google.com with SMTP id h12so6961261qtc.9 for ; Mon, 09 Nov 2020 12:18:38 -0800 (PST) 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:mime-version:content-transfer-encoding; bh=2SGCGCmp+kstSZnGmGmGbHKWMT5smKHTUUvFSu3ROz0=; b=mq7TMbTpqnYYucqPsXEtTnwrd9JJzXHWX1Onu8fa98pRjLfOIxsM6okVdxANp9eDuU 22/Z7UpqbYTKCZAsbsK5Bm2Z2bwBA8mM9QuwseJapv5cwUxcJC2hRNPn+bbmaXqccSO9 qlWnpcYyknZersFpPb+ZvtdpsYQ6s35pGu49uj9H5Wgj4F3dL/Ry0oQAXPmsbVZHZiLz 1hxhS4eckOyY2i4tzXGD18tpNH1yZHDet5kYvljovMpXLXggoDVMJ0Kh6uAZzp4Q5qoI Wt4GCc3YAwW79Wb1KKcrf+/EYtkiDT5AW2bUTf/jQnxL6h+8uFEcyRS3Xw3VR+aqybm6 C7SQ== X-Gm-Message-State: AOAM533+d9+DrO8LsR3oDR/gOMegduvdMbE/zxa/GALvU6W+XiTdDpIQ NBBKFjNu1Kf5257MZxTTIQX+eWLJnx2rmg== X-Google-Smtp-Source: ABdhPJzJJJgswNTFCaK56OcNBJ2vWdtlVcNeF5d+O5h9gW2tJGJljwfDDtI9wt3Zwq0bJO3khNfaSQ== X-Received: by 2002:a05:622a:1cb:: with SMTP id t11mr15379535qtw.378.1604953117596; Mon, 09 Nov 2020 12:18:37 -0800 (PST) Received: from localhost.localdomain ([177.194.48.209]) by smtp.googlemail.com with ESMTPSA id z2sm6843407qkl.22.2020.11.09.12.18.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Nov 2020 12:18:36 -0800 (PST) To: libc-alpha@sourceware.org Subject: [PATCH 02/23] linux: Replace INTERNAL_SYSCALL_ERROR_P macro with a inline function Date: Mon, 9 Nov 2020 17:18:05 -0300 Message-Id: <20201109201826.120534-3-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201109201826.120534-1-adhemerval.zanella@linaro.org> References: <20201109201826.120534-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-14.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Adhemerval Zanella via Libc-alpha From: Adhemerval Zanella Netto Reply-To: Adhemerval Zanella Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" It also allows simplify some posix and pthread implementations. Checked on x86_64-linux-gnu and i686-linux-gnu. --- nptl/allocatestack.c | 4 ++-- nptl/nptl-init.c | 4 ++-- nptl/pthread_cancel.c | 2 +- nptl/pthread_getaffinity.c | 2 +- nptl/pthread_mutex_trylock.c | 2 +- nptl/pthread_setaffinity.c | 9 ++------- nptl/pthread_sigmask.c | 8 ++------ sysdeps/arc/nptl/tls.h | 2 +- sysdeps/csky/nptl/tls.h | 2 +- sysdeps/m68k/nptl/tls.h | 2 +- sysdeps/mips/nptl/tls.h | 2 +- sysdeps/nptl/lowlevellock-futex.h | 7 +------ sysdeps/powerpc/nofpu/sfp-machine.h | 2 +- sysdeps/unix/sysv/linux/arm/tls.h | 2 +- sysdeps/unix/sysv/linux/clock_nanosleep.c | 2 +- sysdeps/unix/sysv/linux/createthread.c | 4 ++-- sysdeps/unix/sysv/linux/dl-origin.c | 2 +- sysdeps/unix/sysv/linux/fcntl_nocancel.c | 2 +- sysdeps/unix/sysv/linux/fstatat.c | 2 +- sysdeps/unix/sysv/linux/fstatat64.c | 2 +- sysdeps/unix/sysv/linux/generic/dl-origin.c | 2 +- sysdeps/unix/sysv/linux/hppa/____longjmp_chk.c | 2 +- sysdeps/unix/sysv/linux/libc_fatal.c | 2 +- sysdeps/unix/sysv/linux/m68k/____longjmp_chk.c | 2 +- sysdeps/unix/sysv/linux/m68k/getpagesize.c | 2 +- sysdeps/unix/sysv/linux/mq_unlink.c | 2 +- sysdeps/unix/sysv/linux/not-errno.h | 14 +++----------- sysdeps/unix/sysv/linux/nscd_setup_thread.c | 2 +- sysdeps/unix/sysv/linux/posix_fadvise.c | 17 ++++++++--------- sysdeps/unix/sysv/linux/posix_fadvise64.c | 11 +++++------ sysdeps/unix/sysv/linux/posix_fallocate.c | 4 +--- sysdeps/unix/sysv/linux/posix_fallocate64.c | 4 +--- sysdeps/unix/sysv/linux/pthread_kill.c | 3 +-- sysdeps/unix/sysv/linux/pthread_sigqueue.c | 4 +--- sysdeps/unix/sysv/linux/riscv/syscall.c | 2 +- .../sysv/linux/s390/s390-32/____longjmp_chk.c | 2 +- .../sysv/linux/s390/s390-32/posix_fadvise64.c | 3 +-- .../sysv/linux/s390/s390-64/____longjmp_chk.c | 2 +- sysdeps/unix/sysv/linux/shmat.c | 2 +- sysdeps/unix/sysv/linux/sysdep-vdso.h | 4 ++-- sysdeps/unix/sysv/linux/sysdep.h | 14 ++++++++++---- sysdeps/unix/sysv/linux/timer_create.c | 2 +- sysdeps/unix/sysv/linux/times.c | 5 ++++- sysdeps/unix/sysv/linux/x86_64/x32/times.c | 9 ++++++--- 44 files changed, 80 insertions(+), 100 deletions(-) diff --git a/nptl/allocatestack.c b/nptl/allocatestack.c index a9e9d39354..1e34623a86 100644 --- a/nptl/allocatestack.c +++ b/nptl/allocatestack.c @@ -1043,7 +1043,7 @@ setxid_signal_thread (struct xid_command *cmdp, struct pthread *t) val = INTERNAL_SYSCALL_CALL (tgkill, pid, t->tid, SIGSETXID); /* If this failed, it must have had not started yet or else exited. */ - if (!INTERNAL_SYSCALL_ERROR_P (val)) + if (!syscall_error (val)) { atomic_increment (&cmdp->cntr); return 1; @@ -1172,7 +1172,7 @@ __nptl_setxid (struct xid_command *cmdp) result = INTERNAL_SYSCALL_NCS (cmdp->syscall_no, 3, cmdp->id[0], cmdp->id[1], cmdp->id[2]); int error = 0; - if (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (result))) + if (__glibc_unlikely (syscall_error (result))) { error = -result; __set_errno (error); diff --git a/nptl/nptl-init.c b/nptl/nptl-init.c index 8aef4c83b5..38a3bbea56 100644 --- a/nptl/nptl-init.c +++ b/nptl/nptl-init.c @@ -191,7 +191,7 @@ sighandler_setxid (int sig, siginfo_t *si, void *ctx) result = INTERNAL_SYSCALL_NCS (__xidcmd->syscall_no, 3, __xidcmd->id[0], __xidcmd->id[1], __xidcmd->id[2]); int error = 0; - if (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (result))) + if (__glibc_unlikely (syscall_error (result))) error = -result; __nptl_setxid_error (__xidcmd, error); @@ -243,7 +243,7 @@ __pthread_initialize_minimal_internal (void) __data.__list.__next)); int res = INTERNAL_SYSCALL_CALL (set_robust_list, &pd->robust_head, sizeof (struct robust_list_head)); - if (INTERNAL_SYSCALL_ERROR_P (res)) + if (syscall_error (res)) set_robust_list_not_avail (); } diff --git a/nptl/pthread_cancel.c b/nptl/pthread_cancel.c index 7daf4f8c15..855ecef87b 100644 --- a/nptl/pthread_cancel.c +++ b/nptl/pthread_cancel.c @@ -69,7 +69,7 @@ __pthread_cancel (pthread_t th) int val = INTERNAL_SYSCALL_CALL (tgkill, pid, pd->tid, SIGCANCEL); - if (INTERNAL_SYSCALL_ERROR_P (val)) + if (syscall_error (val)) result = -val; break; diff --git a/nptl/pthread_getaffinity.c b/nptl/pthread_getaffinity.c index ffeb878c7c..a9e7071e62 100644 --- a/nptl/pthread_getaffinity.c +++ b/nptl/pthread_getaffinity.c @@ -33,7 +33,7 @@ __pthread_getaffinity_np (pthread_t th, size_t cpusetsize, cpu_set_t *cpuset) int res = INTERNAL_SYSCALL_CALL (sched_getaffinity, pd->tid, MIN (INT_MAX, cpusetsize), cpuset); - if (INTERNAL_SYSCALL_ERROR_P (res)) + if (syscall_error (res)) return -res; /* Clean the rest of the memory the kernel didn't do. */ diff --git a/nptl/pthread_mutex_trylock.c b/nptl/pthread_mutex_trylock.c index 5c294a3eea..492f011cae 100644 --- a/nptl/pthread_mutex_trylock.c +++ b/nptl/pthread_mutex_trylock.c @@ -301,7 +301,7 @@ __pthread_mutex_trylock (pthread_mutex_t *mutex) __lll_private_flag (FUTEX_TRYLOCK_PI, private), 0, 0); - if (INTERNAL_SYSCALL_ERROR_P (e) && e == -EWOULDBLOCK) + if (e == -EWOULDBLOCK) { /* The kernel has not yet finished the mutex owner death. We do not need to ensure ordering wrt another memory diff --git a/nptl/pthread_setaffinity.c b/nptl/pthread_setaffinity.c index aaaa4f0194..bcf8ac1376 100644 --- a/nptl/pthread_setaffinity.c +++ b/nptl/pthread_setaffinity.c @@ -28,14 +28,9 @@ __pthread_setaffinity_new (pthread_t th, size_t cpusetsize, const cpu_set_t *cpuset) { const struct pthread *pd = (const struct pthread *) th; - int res; - res = INTERNAL_SYSCALL_CALL (sched_setaffinity, pd->tid, cpusetsize, - cpuset); - - return (INTERNAL_SYSCALL_ERROR_P (res) - ? -res - : 0); + return -INTERNAL_SYSCALL_CALL (sched_setaffinity, pd->tid, cpusetsize, + cpuset); } versioned_symbol (libpthread, __pthread_setaffinity_new, pthread_setaffinity_np, GLIBC_2_3_4); diff --git a/nptl/pthread_sigmask.c b/nptl/pthread_sigmask.c index 1d6d753af4..7939a6cfe6 100644 --- a/nptl/pthread_sigmask.c +++ b/nptl/pthread_sigmask.c @@ -38,12 +38,8 @@ __pthread_sigmask (int how, const sigset_t *newmask, sigset_t *oldmask) } /* We know that realtime signals are available if NPTL is used. */ - int result = INTERNAL_SYSCALL_CALL (rt_sigprocmask, how, newmask, - oldmask, __NSIG_BYTES); - - return (INTERNAL_SYSCALL_ERROR_P (result) - ? -result - : 0); + return -INTERNAL_SYSCALL_CALL (rt_sigprocmask, how, newmask, oldmask, + __NSIG_BYTES); } libc_hidden_def (__pthread_sigmask) diff --git a/sysdeps/arc/nptl/tls.h b/sysdeps/arc/nptl/tls.h index 184b550ab5..de9cd9c3ca 100644 --- a/sysdeps/arc/nptl/tls.h +++ b/sysdeps/arc/nptl/tls.h @@ -81,7 +81,7 @@ typedef struct long result_var; \ __builtin_set_thread_pointer (tcbp); \ result_var = INTERNAL_SYSCALL_CALL (arc_settls, (tcbp));\ - INTERNAL_SYSCALL_ERROR_P (result_var) \ + syscall_error (result_var) \ ? "settls syscall error" : NULL; \ }) diff --git a/sysdeps/csky/nptl/tls.h b/sysdeps/csky/nptl/tls.h index bcca9674a1..dd864cdc7c 100644 --- a/sysdeps/csky/nptl/tls.h +++ b/sysdeps/csky/nptl/tls.h @@ -99,7 +99,7 @@ typedef struct ({ long int result_var; \ result_var = INTERNAL_SYSCALL_CALL (set_thread_area, \ (char *) (tcbp) + TLS_TCB_OFFSET); \ - INTERNAL_SYSCALL_ERROR_P (result_var) \ + syscall_error (result_var) \ ? "unknown error" : NULL; }) /* Return the address of the dtv for the current thread. */ diff --git a/sysdeps/m68k/nptl/tls.h b/sysdeps/m68k/nptl/tls.h index 68ea952e79..77b7afe67f 100644 --- a/sysdeps/m68k/nptl/tls.h +++ b/sysdeps/m68k/nptl/tls.h @@ -99,7 +99,7 @@ typedef struct \ _sys_result = INTERNAL_SYSCALL_CALL (set_thread_area, \ ((void *) (tcbp)) + TLS_TCB_OFFSET); \ - INTERNAL_SYSCALL_ERROR_P (_sys_result) ? "unknown error" : NULL; }) + syscall_error (_sys_result) ? "unknown error" : NULL; }) # define TLS_DEFINE_INIT_TP(tp, pd) \ void *tp = (void *) (pd) + TLS_TCB_OFFSET + TLS_PRE_TCB_SIZE diff --git a/sysdeps/mips/nptl/tls.h b/sysdeps/mips/nptl/tls.h index 8b55f19c37..e91c0074e8 100644 --- a/sysdeps/mips/nptl/tls.h +++ b/sysdeps/mips/nptl/tls.h @@ -123,7 +123,7 @@ typedef struct ({ long int result_var; \ result_var = INTERNAL_SYSCALL_CALL (set_thread_area, \ (char *) (tcbp) + TLS_TCB_OFFSET); \ - INTERNAL_SYSCALL_ERROR_P (result_var) \ + syscall_error (result_var) \ ? "unknown error" : NULL; }) /* Value passed to 'clone' for initialization of the thread register. */ diff --git a/sysdeps/nptl/lowlevellock-futex.h b/sysdeps/nptl/lowlevellock-futex.h index dd36997021..c6a0908ff1 100644 --- a/sysdeps/nptl/lowlevellock-futex.h +++ b/sysdeps/nptl/lowlevellock-futex.h @@ -66,12 +66,7 @@ # endif # define lll_futex_syscall(nargs, futexp, op, ...) \ - ({ \ - long int __ret = INTERNAL_SYSCALL (futex, nargs, futexp, op, \ - __VA_ARGS__); \ - (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (__ret)) \ - ? __ret : 0); \ - }) + INTERNAL_SYSCALL (futex, nargs, futexp, op, __VA_ARGS__) /* For most of these macros, the return value is never really used. Nevertheless, the protocol is that each one returns a negated errno diff --git a/sysdeps/powerpc/nofpu/sfp-machine.h b/sysdeps/powerpc/nofpu/sfp-machine.h index 8489c0f1c0..110a3bf547 100644 --- a/sysdeps/powerpc/nofpu/sfp-machine.h +++ b/sysdeps/powerpc/nofpu/sfp-machine.h @@ -70,7 +70,7 @@ libc_hidden_proto (__feraiseexcept_soft) \ _spefscr = fegetenv_register (); \ _r = INTERNAL_SYSCALL_CALL (prctl, PR_GET_FPEXC, &_ftrapex); \ - if (INTERNAL_SYSCALL_ERROR_P (_r)) \ + if (syscall_error (_r)) \ _ftrapex = 0; \ } \ while (0) diff --git a/sysdeps/unix/sysv/linux/arm/tls.h b/sysdeps/unix/sysv/linux/arm/tls.h index 57b583dbd8..4155d6c030 100644 --- a/sysdeps/unix/sysv/linux/arm/tls.h +++ b/sysdeps/unix/sysv/linux/arm/tls.h @@ -33,7 +33,7 @@ # define TLS_INIT_TP(tcbp) \ ({ long int result_var; \ result_var = INTERNAL_SYSCALL_CALL (set_tls, (tcbp)); \ - INTERNAL_SYSCALL_ERROR_P (result_var) \ + syscall_error (result_var) \ ? "unknown error" : NULL; }) #endif /* __ASSEMBLER__ */ diff --git a/sysdeps/unix/sysv/linux/clock_nanosleep.c b/sysdeps/unix/sysv/linux/clock_nanosleep.c index 6ad3321435..ace1191d90 100644 --- a/sysdeps/unix/sysv/linux/clock_nanosleep.c +++ b/sysdeps/unix/sysv/linux/clock_nanosleep.c @@ -57,7 +57,7 @@ __clock_nanosleep_time64 (clockid_t clock_id, int flags, const struct __timespec struct timespec ts32 = valid_timespec64_to_timespec (*req); r = INTERNAL_SYSCALL_CANCEL (clock_nanosleep, clock_id, flags, &ts32, &tr32); - if (INTERNAL_SYSCALL_ERROR_P (r)) + if (syscall_error (r)) { if (r == -EINTR && rem != NULL && (flags & TIMER_ABSTIME) == 0) *rem = valid_timespec_to_timespec64 (tr32); diff --git a/sysdeps/unix/sysv/linux/createthread.c b/sysdeps/unix/sysv/linux/createthread.c index 01cf2ff42a..1c224155f8 100644 --- a/sysdeps/unix/sysv/linux/createthread.c +++ b/sysdeps/unix/sysv/linux/createthread.c @@ -123,7 +123,7 @@ create_thread (struct pthread *pd, const struct pthread_attr *attr, attr->extension->cpusetsize, attr->extension->cpuset); - if (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (res))) + if (__glibc_unlikely (syscall_error (res))) err_out: { /* The operation failed. We have to kill the thread. @@ -144,7 +144,7 @@ create_thread (struct pthread *pd, const struct pthread_attr *attr, res = INTERNAL_SYSCALL_CALL (sched_setscheduler, pd->tid, pd->schedpolicy, &pd->schedparam); - if (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (res))) + if (__glibc_unlikely (syscall_error (res))) goto err_out; } } diff --git a/sysdeps/unix/sysv/linux/dl-origin.c b/sysdeps/unix/sysv/linux/dl-origin.c index 515ed6fc8c..00cba11495 100644 --- a/sysdeps/unix/sysv/linux/dl-origin.c +++ b/sysdeps/unix/sysv/linux/dl-origin.c @@ -40,7 +40,7 @@ _dl_get_origin (void) len = INTERNAL_SYSCALL_CALL (readlink, "/proc/self/exe", linkval, sizeof (linkval)); - if (! INTERNAL_SYSCALL_ERROR_P (len) && len > 0 && linkval[0] != '[') + if (! syscall_error (len) && len > 0 && linkval[0] != '[') { /* We can use this value. */ assert (linkval[0] == '/'); diff --git a/sysdeps/unix/sysv/linux/fcntl_nocancel.c b/sysdeps/unix/sysv/linux/fcntl_nocancel.c index 1bf3030f75..a16fc75cb7 100644 --- a/sysdeps/unix/sysv/linux/fcntl_nocancel.c +++ b/sysdeps/unix/sysv/linux/fcntl_nocancel.c @@ -53,7 +53,7 @@ __fcntl64_nocancel_adjusted (int fd, int cmd, void *arg) { struct f_owner_ex fex; int res = INTERNAL_SYSCALL_CALL (fcntl64, fd, F_GETOWN_EX, &fex); - if (!INTERNAL_SYSCALL_ERROR_P (res)) + if (!syscall_error (res)) return fex.type == F_OWNER_GID ? -fex.pid : fex.pid; return INLINE_SYSCALL_ERROR_RETURN_VALUE (-res); diff --git a/sysdeps/unix/sysv/linux/fstatat.c b/sysdeps/unix/sysv/linux/fstatat.c index db49e3155c..a61fffa6e7 100644 --- a/sysdeps/unix/sysv/linux/fstatat.c +++ b/sysdeps/unix/sysv/linux/fstatat.c @@ -80,7 +80,7 @@ __fstatat (int fd, const char *file, struct stat *buf, int flag) # endif /* __nr_fstatat64 */ # endif /* STAT_IS_KERNEL_STAT */ - return INTERNAL_SYSCALL_ERROR_P (r) + return syscall_error (r) ? INLINE_SYSCALL_ERROR_RETURN_VALUE (-r) : 0; } diff --git a/sysdeps/unix/sysv/linux/fstatat64.c b/sysdeps/unix/sysv/linux/fstatat64.c index 44347603b4..6e12cf2456 100644 --- a/sysdeps/unix/sysv/linux/fstatat64.c +++ b/sysdeps/unix/sysv/linux/fstatat64.c @@ -102,7 +102,7 @@ __fstatat64_time64 (int fd, const char *file, struct __stat64_t64 *buf, # endif #endif - return INTERNAL_SYSCALL_ERROR_P (r) + return syscall_error (r) ? INLINE_SYSCALL_ERROR_RETURN_VALUE (-r) : 0; } diff --git a/sysdeps/unix/sysv/linux/generic/dl-origin.c b/sysdeps/unix/sysv/linux/generic/dl-origin.c index 1ab02bbf10..f90b59b1ef 100644 --- a/sysdeps/unix/sysv/linux/generic/dl-origin.c +++ b/sysdeps/unix/sysv/linux/generic/dl-origin.c @@ -41,7 +41,7 @@ _dl_get_origin (void) len = INTERNAL_SYSCALL_CALL (readlinkat, AT_FDCWD, "/proc/self/exe", linkval, sizeof (linkval)); - if (! INTERNAL_SYSCALL_ERROR_P (len) && len > 0 && linkval[0] != '[') + if (! syscall_error (len) && len > 0 && linkval[0] != '[') { /* We can use this value. */ assert (linkval[0] == '/'); diff --git a/sysdeps/unix/sysv/linux/hppa/____longjmp_chk.c b/sysdeps/unix/sysv/linux/hppa/____longjmp_chk.c index eae0a7fe31..541c05fcf4 100644 --- a/sysdeps/unix/sysv/linux/hppa/____longjmp_chk.c +++ b/sysdeps/unix/sysv/linux/hppa/____longjmp_chk.c @@ -35,7 +35,7 @@ that we are jumping *out* of the alternate stack. Note that \ the check for that is the same as that for _STACK_GROWS_UP \ as for _STACK_GROWS_DOWN. */ \ - if (!INTERNAL_SYSCALL_ERROR_P (result) \ + if (!syscall_error (result) \ && ((oss.ss_flags & SS_ONSTACK) == 0 \ || ((unsigned long) oss.ss_sp + oss.ss_size \ - (unsigned long) (sp)) < oss.ss_size)) \ diff --git a/sysdeps/unix/sysv/linux/libc_fatal.c b/sysdeps/unix/sysv/linux/libc_fatal.c index 35a20ca0fd..52fcd9761b 100644 --- a/sysdeps/unix/sysv/linux/libc_fatal.c +++ b/sysdeps/unix/sysv/linux/libc_fatal.c @@ -25,7 +25,7 @@ writev_for_fatal (int fd, const struct iovec *iov, size_t niov, size_t total) ssize_t cnt; do cnt = INTERNAL_SYSCALL_CALL (writev, fd, iov, niov); - while (INTERNAL_SYSCALL_ERROR_P (cnt) && cnt == -EINTR); + while (syscall_error (cnt) && cnt == -EINTR); return cnt == total; } #define WRITEV_FOR_FATAL writev_for_fatal diff --git a/sysdeps/unix/sysv/linux/m68k/____longjmp_chk.c b/sysdeps/unix/sysv/linux/m68k/____longjmp_chk.c index 1e9c5259ab..7a3ed27a5c 100644 --- a/sysdeps/unix/sysv/linux/m68k/____longjmp_chk.c +++ b/sysdeps/unix/sysv/linux/m68k/____longjmp_chk.c @@ -26,7 +26,7 @@ { \ stack_t oss; \ int result = INTERNAL_SYSCALL_CALL (sigaltstack, NULL, &oss); \ - if (!INTERNAL_SYSCALL_ERROR_P (result) \ + if (!syscall_error (result) \ && ((oss.ss_flags & SS_ONSTACK) == 0 \ || ((unsigned long) oss.ss_sp + oss.ss_size \ - (unsigned long) (sp)) < oss.ss_size)) \ diff --git a/sysdeps/unix/sysv/linux/m68k/getpagesize.c b/sysdeps/unix/sysv/linux/m68k/getpagesize.c index 99c83313d2..99ab5772b3 100644 --- a/sysdeps/unix/sysv/linux/m68k/getpagesize.c +++ b/sysdeps/unix/sysv/linux/m68k/getpagesize.c @@ -35,7 +35,7 @@ __getpagesize (void) result = INTERNAL_SYSCALL_CALL (getpagesize); /* The only possible error is ENOSYS. */ - if (!INTERNAL_SYSCALL_ERROR_P (result)) + if (!syscall_error (result)) return result; return 4096; diff --git a/sysdeps/unix/sysv/linux/mq_unlink.c b/sysdeps/unix/sysv/linux/mq_unlink.c index ed7858dc9d..4964eb9028 100644 --- a/sysdeps/unix/sysv/linux/mq_unlink.c +++ b/sysdeps/unix/sysv/linux/mq_unlink.c @@ -30,7 +30,7 @@ mq_unlink (const char *name) /* While unlink can return either EPERM or EACCES, mq_unlink should return just EACCES. */ - if (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (ret))) + if (__glibc_unlikely (syscall_error (ret))) { if (ret == -EPERM) ret = -EACCES; diff --git a/sysdeps/unix/sysv/linux/not-errno.h b/sysdeps/unix/sysv/linux/not-errno.h index fc0eda09d9..07330a83ca 100644 --- a/sysdeps/unix/sysv/linux/not-errno.h +++ b/sysdeps/unix/sysv/linux/not-errno.h @@ -25,23 +25,15 @@ static inline int __access_noerrno (const char *pathname, int mode) { - int res; #ifdef __NR_access - res = INTERNAL_SYSCALL_CALL (access, pathname, mode); + return -INTERNAL_SYSCALL_CALL (access, pathname, mode); #else - res = INTERNAL_SYSCALL_CALL (faccessat, AT_FDCWD, pathname, mode); + return -INTERNAL_SYSCALL_CALL (faccessat, AT_FDCWD, pathname, mode); #endif - if (INTERNAL_SYSCALL_ERROR_P (res)) - return -res; - return 0; } static inline int __kill_noerrno (pid_t pid, int sig) { - int res; - res = INTERNAL_SYSCALL_CALL (kill, pid, sig); - if (INTERNAL_SYSCALL_ERROR_P (res)) - return -res; - return 0; + return -INTERNAL_SYSCALL_CALL (kill, pid, sig); } diff --git a/sysdeps/unix/sysv/linux/nscd_setup_thread.c b/sysdeps/unix/sysv/linux/nscd_setup_thread.c index 2ba64ebea5..fe70da0b5e 100644 --- a/sysdeps/unix/sysv/linux/nscd_setup_thread.c +++ b/sysdeps/unix/sysv/linux/nscd_setup_thread.c @@ -36,7 +36,7 @@ setup_thread (struct database_dyn *db) since none of the threads ever terminates. */ int r = INTERNAL_SYSCALL_CALL (set_tid_address, &db->head->nscd_certainly_running); - if (!INTERNAL_SYSCALL_ERROR_P (r)) + if (!syscall_error (r)) /* We know the kernel can reset this field when nscd terminates. So, set the field to a nonzero value which indicates that nscd is certainly running and clients can skip the test. */ diff --git a/sysdeps/unix/sysv/linux/posix_fadvise.c b/sysdeps/unix/sysv/linux/posix_fadvise.c index 1191ab3db5..3d6bf4b972 100644 --- a/sysdeps/unix/sysv/linux/posix_fadvise.c +++ b/sysdeps/unix/sysv/linux/posix_fadvise.c @@ -42,24 +42,23 @@ int posix_fadvise (int fd, off_t offset, off_t len, int advise) { # if defined (__NR_fadvise64) && !defined (__ASSUME_FADVISE64_AS_64_64) - int ret = INTERNAL_SYSCALL_CALL (fadvise64, fd, - __ALIGNMENT_ARG SYSCALL_LL (offset), - len, advise); + return -INTERNAL_SYSCALL_CALL (fadvise64, fd, + __ALIGNMENT_ARG SYSCALL_LL (offset), + len, advise); # else # ifdef __ASSUME_FADVISE64_64_6ARG - int ret = INTERNAL_SYSCALL_CALL (fadvise64_64, fd, advise, - SYSCALL_LL (offset), SYSCALL_LL (len)); + return -INTERNAL_SYSCALL_CALL (fadvise64_64, fd, advise, + SYSCALL_LL (offset), SYSCALL_LL (len)); # else # ifndef __NR_fadvise64_64 # define __NR_fadvise64_64 __NR_fadvise64 # endif - int ret = INTERNAL_SYSCALL_CALL (fadvise64_64, fd, - __ALIGNMENT_ARG SYSCALL_LL (offset), - SYSCALL_LL (len), advise); + return -INTERNAL_SYSCALL_CALL (fadvise64_64, fd, + __ALIGNMENT_ARG SYSCALL_LL (offset), + SYSCALL_LL (len), advise); # endif # endif - return INTERNAL_SYSCALL_ERROR_P (ret) ? -ret : 0; } #endif /* __OFF_T_MATCHES_OFF64_T */ diff --git a/sysdeps/unix/sysv/linux/posix_fadvise64.c b/sysdeps/unix/sysv/linux/posix_fadvise64.c index e3726a6a8a..6ef425cf22 100644 --- a/sysdeps/unix/sysv/linux/posix_fadvise64.c +++ b/sysdeps/unix/sysv/linux/posix_fadvise64.c @@ -41,14 +41,13 @@ int __posix_fadvise64_l64 (int fd, off64_t offset, off64_t len, int advise) { #ifdef __ASSUME_FADVISE64_64_6ARG - int ret = INTERNAL_SYSCALL_CALL (fadvise64_64, fd, advise, - SYSCALL_LL64 (offset), SYSCALL_LL64 (len)); + return -INTERNAL_SYSCALL_CALL (fadvise64_64, fd, advise, + SYSCALL_LL64 (offset), SYSCALL_LL64 (len)); #else - int ret = INTERNAL_SYSCALL_CALL (fadvise64_64, fd, - __ALIGNMENT_ARG SYSCALL_LL64 (offset), - SYSCALL_LL64 (len), advise); + return -INTERNAL_SYSCALL_CALL (fadvise64_64, fd, + __ALIGNMENT_ARG SYSCALL_LL64 (offset), + SYSCALL_LL64 (len), advise); #endif - return INTERNAL_SYSCALL_ERROR_P (ret) ? -ret : 0; } /* The type of the len argument was changed from size_t to off_t in diff --git a/sysdeps/unix/sysv/linux/posix_fallocate.c b/sysdeps/unix/sysv/linux/posix_fallocate.c index 87532668cd..3c8f7cafeb 100644 --- a/sysdeps/unix/sysv/linux/posix_fallocate.c +++ b/sysdeps/unix/sysv/linux/posix_fallocate.c @@ -28,9 +28,7 @@ posix_fallocate (int fd, __off_t offset, __off_t len) { int res = INTERNAL_SYSCALL_CALL (fallocate, fd, 0, SYSCALL_LL (offset), SYSCALL_LL (len)); - if (! INTERNAL_SYSCALL_ERROR_P (res)) - return 0; - if (res != -EOPNOTSUPP) + if (! syscall_error (res) || -res != EOPNOTSUPP) return -res; return internal_fallocate (fd, offset, len); } diff --git a/sysdeps/unix/sysv/linux/posix_fallocate64.c b/sysdeps/unix/sysv/linux/posix_fallocate64.c index 0340357e57..910f83384c 100644 --- a/sysdeps/unix/sysv/linux/posix_fallocate64.c +++ b/sysdeps/unix/sysv/linux/posix_fallocate64.c @@ -30,9 +30,7 @@ __posix_fallocate64_l64 (int fd, __off64_t offset, __off64_t len) { int res = INTERNAL_SYSCALL_CALL (fallocate, fd, 0, SYSCALL_LL64 (offset), SYSCALL_LL64 (len)); - if (! INTERNAL_SYSCALL_ERROR_P (res)) - return 0; - if (-res != EOPNOTSUPP) + if (! syscall_error (res) || -res != EOPNOTSUPP) return -res; return internal_fallocate64 (fd, offset, len); } diff --git a/sysdeps/unix/sysv/linux/pthread_kill.c b/sysdeps/unix/sysv/linux/pthread_kill.c index defdeaecac..525383f960 100644 --- a/sysdeps/unix/sysv/linux/pthread_kill.c +++ b/sysdeps/unix/sysv/linux/pthread_kill.c @@ -50,7 +50,6 @@ __pthread_kill (pthread_t threadid, int signo) /* We have a special syscall to do the work. */ pid_t pid = __getpid (); - int val = INTERNAL_SYSCALL_CALL (tgkill, pid, tid, signo); - return INTERNAL_SYSCALL_ERROR_P (val) ? -val : 0; + return -INTERNAL_SYSCALL_CALL (tgkill, pid, tid, signo); } strong_alias (__pthread_kill, pthread_kill) diff --git a/sysdeps/unix/sysv/linux/pthread_sigqueue.c b/sysdeps/unix/sysv/linux/pthread_sigqueue.c index fbbd9fee20..814f449b63 100644 --- a/sysdeps/unix/sysv/linux/pthread_sigqueue.c +++ b/sysdeps/unix/sysv/linux/pthread_sigqueue.c @@ -61,9 +61,7 @@ pthread_sigqueue (pthread_t threadid, int signo, const union sigval value) info.si_value = value; /* We have a special syscall to do the work. */ - int val = INTERNAL_SYSCALL_CALL (rt_tgsigqueueinfo, pid, tid, signo, - &info); - return INTERNAL_SYSCALL_ERROR_P (val) ? -val : 0; + return -INTERNAL_SYSCALL_CALL (rt_tgsigqueueinfo, pid, tid, signo, &info); #else return ENOSYS; #endif diff --git a/sysdeps/unix/sysv/linux/riscv/syscall.c b/sysdeps/unix/sysv/linux/riscv/syscall.c index a99375c054..4ebb759b72 100644 --- a/sysdeps/unix/sysv/linux/riscv/syscall.c +++ b/sysdeps/unix/sysv/linux/riscv/syscall.c @@ -27,7 +27,7 @@ syscall (long int syscall_number, long int arg1, long int arg2, long int arg3, ret = INTERNAL_SYSCALL_NCS (syscall_number, 7, arg1, arg2, arg3, arg4, arg5, arg6, arg7); - if (INTERNAL_SYSCALL_ERROR_P (ret)) + if (syscall_error (ret)) return __syscall_error (ret); return ret; diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/____longjmp_chk.c b/sysdeps/unix/sysv/linux/s390/s390-32/____longjmp_chk.c index 1f214173fe..7cb3a69e90 100644 --- a/sysdeps/unix/sysv/linux/s390/s390-32/____longjmp_chk.c +++ b/sysdeps/unix/sysv/linux/s390/s390-32/____longjmp_chk.c @@ -40,7 +40,7 @@ { \ stack_t oss; \ int res = INTERNAL_SYSCALL_CALL (sigaltstack, NULL, &oss); \ - if (!INTERNAL_SYSCALL_ERROR_P (res)) \ + if (!syscall_error (res)) \ { \ if ((oss.ss_flags & SS_ONSTACK) == 0 \ || ((uintptr_t) (oss.ss_sp + oss.ss_size) - new_sp \ diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/posix_fadvise64.c b/sysdeps/unix/sysv/linux/s390/s390-32/posix_fadvise64.c index 6199589307..75c1318d83 100644 --- a/sysdeps/unix/sysv/linux/s390/s390-32/posix_fadvise64.c +++ b/sysdeps/unix/sysv/linux/s390/s390-32/posix_fadvise64.c @@ -42,8 +42,7 @@ __posix_fadvise64_l64 (int fd, off64_t offset, off64_t len, int advise) parameters.offset = offset; parameters.len = len; parameters.advise = advise; - int ret = INTERNAL_SYSCALL_CALL (fadvise64_64, ¶meters); - return INTERNAL_SYSCALL_ERROR_P (ret) ? -ret : 0; + return -INTERNAL_SYSCALL_CALL (fadvise64_64, ¶meters); } #include diff --git a/sysdeps/unix/sysv/linux/s390/s390-64/____longjmp_chk.c b/sysdeps/unix/sysv/linux/s390/s390-64/____longjmp_chk.c index bc74408135..84c6d13655 100644 --- a/sysdeps/unix/sysv/linux/s390/s390-64/____longjmp_chk.c +++ b/sysdeps/unix/sysv/linux/s390/s390-64/____longjmp_chk.c @@ -40,7 +40,7 @@ { \ stack_t oss; \ int res = INTERNAL_SYSCALL_CALL (sigaltstack, NULL, &oss); \ - if (!INTERNAL_SYSCALL_ERROR_P (res)) \ + if (!syscall_error (res)) \ { \ if ((oss.ss_flags & SS_ONSTACK) == 0 \ || ((uintptr_t) (oss.ss_sp + oss.ss_size) - new_sp \ diff --git a/sysdeps/unix/sysv/linux/shmat.c b/sysdeps/unix/sysv/linux/shmat.c index d5a65c06c1..98291fe972 100644 --- a/sysdeps/unix/sysv/linux/shmat.c +++ b/sysdeps/unix/sysv/linux/shmat.c @@ -35,7 +35,7 @@ shmat (int shmid, const void *shmaddr, int shmflg) resultvar = INTERNAL_SYSCALL_CALL (ipc, IPCOP_shmat, shmid, shmflg, &raddr, shmaddr); - if (INTERNAL_SYSCALL_ERROR_P (resultvar)) + if (syscall_error (resultvar)) return (void *) INLINE_SYSCALL_ERROR_RETURN_VALUE (-resultvar); return raddr; diff --git a/sysdeps/unix/sysv/linux/sysdep-vdso.h b/sysdeps/unix/sysv/linux/sysdep-vdso.h index 88db076184..7c578808c6 100644 --- a/sysdeps/unix/sysv/linux/sysdep-vdso.h +++ b/sysdeps/unix/sysv/linux/sysdep-vdso.h @@ -36,14 +36,14 @@ if (vdsop != NULL) \ { \ sc_ret = INTERNAL_VSYSCALL_CALL (vdsop, nr, ##args); \ - if (!INTERNAL_SYSCALL_ERROR_P (sc_ret)) \ + if (!syscall_error (sc_ret)) \ goto out; \ if (sc_ret != -ENOSYS) \ goto iserr; \ } \ \ sc_ret = INTERNAL_SYSCALL_CALL (name, ##args); \ - if (INTERNAL_SYSCALL_ERROR_P (sc_ret)) \ + if (syscall_error (sc_ret)) \ { \ iserr: \ __set_errno (-sc_ret); \ diff --git a/sysdeps/unix/sysv/linux/sysdep.h b/sysdeps/unix/sysv/linux/sysdep.h index 4e25e51470..3fa29dd588 100644 --- a/sysdeps/unix/sysv/linux/sysdep.h +++ b/sysdeps/unix/sysv/linux/sysdep.h @@ -22,9 +22,13 @@ #include #include -#undef INTERNAL_SYSCALL_ERROR_P -#define INTERNAL_SYSCALL_ERROR_P(val) \ - ((unsigned long int) (val) > -4096UL) +#ifndef __ASSEMBLER__ +static inline _Bool +syscall_error (unsigned long int val) +{ + return val > -4096UL; +} +#endif #ifndef SYSCALL_ERROR_LABEL # define SYSCALL_ERROR_LABEL(sc_err) \ @@ -34,6 +38,7 @@ }) #endif +#ifndef __ASSEMBLER__ /* Define a macro which expands into the inline wrapper code for a system call. It sets the errno and returns -1 on a failure, or the syscall return value otherwise. */ @@ -41,10 +46,11 @@ #define INLINE_SYSCALL(name, nr, args...) \ ({ \ long int sc_ret = INTERNAL_SYSCALL (name, nr, args); \ - __glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (sc_ret)) \ + __glibc_unlikely (syscall_error (sc_ret)) \ ? SYSCALL_ERROR_LABEL (-sc_ret) \ : sc_ret; \ }) +#endif /* Set error number and return -1. A target may choose to return the internal function, __syscall_error, which sets errno and returns -1. diff --git a/sysdeps/unix/sysv/linux/timer_create.c b/sysdeps/unix/sysv/linux/timer_create.c index d8289d1dc7..1f5f2b95da 100644 --- a/sysdeps/unix/sysv/linux/timer_create.c +++ b/sysdeps/unix/sysv/linux/timer_create.c @@ -124,7 +124,7 @@ timer_create (clockid_t clock_id, struct sigevent *evp, timer_t *timerid) int res; res = INTERNAL_SYSCALL_CALL (timer_create, syscall_clockid, &sev, &newp->ktimerid); - if (INTERNAL_SYSCALL_ERROR_P (res)) + if (syscall_error (res)) { free (newp); __set_errno (-res); diff --git a/sysdeps/unix/sysv/linux/times.c b/sysdeps/unix/sysv/linux/times.c index b5eb6404c9..0b47979bfd 100644 --- a/sysdeps/unix/sysv/linux/times.c +++ b/sysdeps/unix/sysv/linux/times.c @@ -19,12 +19,15 @@ #include #include +#ifndef SYSCALL_ERROR +# define SYSCALL_ERROR(__val) syscall_error(__val) +#endif clock_t __times (struct tms *buf) { clock_t ret = INTERNAL_SYSCALL_CALL (times, buf); - if (INTERNAL_SYSCALL_ERROR_P (ret) + if (syscall_error (ret) && __glibc_unlikely (ret == -EFAULT) && buf) { diff --git a/sysdeps/unix/sysv/linux/x86_64/x32/times.c b/sysdeps/unix/sysv/linux/x86_64/x32/times.c index 864c123117..f540447b0a 100644 --- a/sysdeps/unix/sysv/linux/x86_64/x32/times.c +++ b/sysdeps/unix/sysv/linux/x86_64/x32/times.c @@ -33,8 +33,11 @@ (long long int) resultvar; \ }) -#undef INTERNAL_SYSCALL_ERROR_P -#define INTERNAL_SYSCALL_ERROR_P(val) \ - ((unsigned long long int) (val) >= -4095LL) +static inline _Bool +syscall_error_u64 (unsigned long long int val) +{ + return val > -4096ULL; +} +#define SYSCALL_ERROR(__val) syscall_error_u64 (__val) #include From patchwork Mon Nov 9 20:18:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 40984 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id E01963973016; Mon, 9 Nov 2020 20:18:45 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E01963973016 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1604953125; bh=RtnMgyBnLrCaoYGBdYIG/7FxutgZ4VoQaejzJZdlRHI=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=vhsE3kH2IleRKoZFjZw/upUNaouCL5JXWARklfq2HY49RguaaEDLQi3MXhM4lPu3l Zzt8l14V7/4YO/pJYGY/fUkmoxR1KsdfEv3IOnkYe3ro0ten59bFsRNLrUwMrCWJPN eLglOsQMQF8d9gf6vXHSlaaIZ55cUTEaKeWWn2zM= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-qk1-x741.google.com (mail-qk1-x741.google.com [IPv6:2607:f8b0:4864:20::741]) by sourceware.org (Postfix) with ESMTPS id CC983396ECAD for ; Mon, 9 Nov 2020 20:18:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org CC983396ECAD Received: by mail-qk1-x741.google.com with SMTP id q5so5050377qkc.12 for ; Mon, 09 Nov 2020 12:18:40 -0800 (PST) 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:mime-version:content-transfer-encoding; bh=RtnMgyBnLrCaoYGBdYIG/7FxutgZ4VoQaejzJZdlRHI=; b=kMvN2ldNsU8dip9BKF25L8n+RGBK+FOPnvU3KuITBV/nwUTB3SFtdUIl6sI5EbrtG0 Egu530i57j1BxIM4qS53RGFzlDmJADLk2wHGWRE7TZYsIsf5Qdip5LHepaRRbs28s2mK 6uFSSCJqQxdI7tV/FpRMpqx/qED53x6ze2cF9axH8qFnvpxWkSCa5RMxVfulLrv2NUEl aB4pepbXosHxKopkM1VE4G4fJ/mkGbedyskEAvbZ4bIHO1PIY4JefIxzVAiWxEQ2n0xB 7UkM4wL817MM5/8IPMu5qQFqkW31SlgC0yy91hRq6r+vEk2CIrTB2Ilik9K8buoBQYCk 8ssw== X-Gm-Message-State: AOAM532Cat23ON2ipa8e6EXfo6FBqobJXdeL7M4ncHpUpoqVxdHcCPVB xViPGPZ/ukOrIdmRdgJYr6KzPw6I5vd+lw== X-Google-Smtp-Source: ABdhPJzEjhHatjuo6ZI8NXBC1l0fefbf9ZRXw92f956e5Sy0JZkITY/cRzzU4QD2n6zYAWzzfKiYIQ== X-Received: by 2002:a37:ac02:: with SMTP id e2mr10978455qkm.243.1604953119253; Mon, 09 Nov 2020 12:18:39 -0800 (PST) Received: from localhost.localdomain ([177.194.48.209]) by smtp.googlemail.com with ESMTPSA id z2sm6843407qkl.22.2020.11.09.12.18.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Nov 2020 12:18:38 -0800 (PST) To: libc-alpha@sourceware.org Subject: [PATCH 03/23] Remove tls.h inclusion from internal errno.h Date: Mon, 9 Nov 2020 17:18:06 -0300 Message-Id: <20201109201826.120534-4-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201109201826.120534-1-adhemerval.zanella@linaro.org> References: <20201109201826.120534-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-14.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Adhemerval Zanella via Libc-alpha From: Adhemerval Zanella Netto Reply-To: Adhemerval Zanella Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" The tls.h inclusion is not really required and limits possible definition on more arch specific headers. This is a cleanup to allow inline functions on sysdep.h, more specifically on i386 and ia64 which requires to access some tls definitions its own. No semantic changes expected, checked with a build against all affected ABIs. --- include/errno.h | 2 -- io/lchmod.c | 4 +--- malloc/reallocarray.c | 1 + misc/ustat.c | 1 + nss/nss_fgetent_r.c | 1 + posix/execl.c | 1 + posix/execle.c | 1 + posix/execlp.c | 1 + posix/spawn_faction_addchdir.c | 2 +- pwd/putpwent.c | 1 + signal/sigempty.c | 1 + signal/sigismem.c | 1 + sysdeps/generic/internal-signals.h | 1 + sysdeps/ieee754/ldbl-128ibm/mpn2ldbl.c | 3 --- sysdeps/mach/hurd/mmap64.c | 1 + sysdeps/mach/hurd/waitid.c | 1 + sysdeps/microblaze/backtrace.c | 1 + sysdeps/nptl/futex-internal.h | 1 + sysdeps/unix/sysv/linux/adjtime.c | 1 + sysdeps/unix/sysv/linux/clock_getcpuclockid.c | 1 + sysdeps/unix/sysv/linux/faccessat.c | 6 +----- sysdeps/unix/sysv/linux/ftime.c | 1 + sysdeps/unix/sysv/linux/ftruncate64.c | 1 - sysdeps/unix/sysv/linux/generic/chmod.c | 4 +--- sysdeps/unix/sysv/linux/generic/chown.c | 4 +--- sysdeps/unix/sysv/linux/generic/dup2.c | 3 +-- sysdeps/unix/sysv/linux/generic/epoll_create.c | 5 +---- sysdeps/unix/sysv/linux/generic/inotify_init.c | 5 +---- sysdeps/unix/sysv/linux/generic/lchown.c | 4 +--- sysdeps/unix/sysv/linux/generic/link.c | 3 +-- sysdeps/unix/sysv/linux/generic/pipe.c | 3 +-- sysdeps/unix/sysv/linux/generic/readlink.c | 2 +- sysdeps/unix/sysv/linux/generic/rmdir.c | 4 +--- sysdeps/unix/sysv/linux/generic/symlink.c | 3 +-- sysdeps/unix/sysv/linux/generic/unlink.c | 4 +--- sysdeps/unix/sysv/linux/generic/wordsize-32/fstatfs.c | 2 +- sysdeps/unix/sysv/linux/generic/wordsize-32/overflow.h | 1 + sysdeps/unix/sysv/linux/generic/wordsize-32/sendfile.c | 2 ++ sysdeps/unix/sysv/linux/generic/wordsize-32/statfs.c | 2 +- sysdeps/unix/sysv/linux/getentropy.c | 1 + sysdeps/unix/sysv/linux/getrlimit.c | 3 +-- sysdeps/unix/sysv/linux/getrlimit64.c | 1 + sysdeps/unix/sysv/linux/gettimeofday.c | 7 ++++--- sysdeps/unix/sysv/linux/hppa/sysdep.h | 2 ++ sysdeps/unix/sysv/linux/internal-signals.h | 1 + sysdeps/unix/sysv/linux/libc_fatal.c | 2 ++ sysdeps/unix/sysv/linux/microblaze/sysdep.h | 2 ++ sysdeps/unix/sysv/linux/mknodat.c | 1 + sysdeps/unix/sysv/linux/netlink_assert_response.c | 1 + sysdeps/unix/sysv/linux/posix_fadvise64.c | 1 + sysdeps/unix/sysv/linux/prlimit.c | 4 +--- sysdeps/unix/sysv/linux/readahead.c | 2 +- sysdeps/unix/sysv/linux/s390/s390-32/utmp32.c | 2 +- sysdeps/unix/sysv/linux/s390/s390-32/utmpx32.c | 2 +- sysdeps/unix/sysv/linux/semop.c | 2 +- sysdeps/unix/sysv/linux/setrlimit.c | 3 +-- sysdeps/unix/sysv/linux/setrlimit64.c | 1 + sysdeps/unix/sysv/linux/settimezone.c | 1 + sysdeps/unix/sysv/linux/shmget.c | 3 ++- sysdeps/unix/sysv/linux/socketcall.h | 2 ++ sysdeps/unix/sysv/linux/speed.c | 2 +- sysdeps/unix/sysv/linux/statx.c | 2 +- sysdeps/unix/sysv/linux/sysctl.c | 1 + sysdeps/unix/sysv/linux/sysdep.h | 1 + sysdeps/unix/sysv/linux/truncate64.c | 1 - sysdeps/unix/sysv/linux/ustat.c | 2 +- sysdeps/unix/sysv/linux/xmknod.c | 1 + sysdeps/unix/sysv/linux/xmknodat.c | 1 + sysdeps/unix/sysv/linux/xstatconv.c | 1 + sysdeps/x86_64/stackinfo.h | 10 ++++++++-- 70 files changed, 82 insertions(+), 70 deletions(-) diff --git a/include/errno.h b/include/errno.h index 457114b27a..c361a785c2 100644 --- a/include/errno.h +++ b/include/errno.h @@ -22,8 +22,6 @@ extern int rtld_errno attribute_hidden; # elif IS_IN_LIB && !IS_IN (rtld) -# include - # undef errno # if IS_IN (libc) # define errno __libc_errno diff --git a/io/lchmod.c b/io/lchmod.c index 8b788034ee..3a0f714576 100644 --- a/io/lchmod.c +++ b/io/lchmod.c @@ -16,10 +16,8 @@ License along with the GNU C Library; if not, see . */ -#include #include -#include -#include +#include /* Change the protections of FILE to MODE. */ int diff --git a/malloc/reallocarray.c b/malloc/reallocarray.c index aca689e2c5..20b0215220 100644 --- a/malloc/reallocarray.c +++ b/malloc/reallocarray.c @@ -17,6 +17,7 @@ not, see . */ #include +#include #include void * diff --git a/misc/ustat.c b/misc/ustat.c index a1b057f640..ad75c5c1bf 100644 --- a/misc/ustat.c +++ b/misc/ustat.c @@ -23,6 +23,7 @@ # include # include +# include struct ustat { diff --git a/nss/nss_fgetent_r.c b/nss/nss_fgetent_r.c index 8f7c5b5cc7..7fecde7e8f 100644 --- a/nss/nss_fgetent_r.c +++ b/nss/nss_fgetent_r.c @@ -18,6 +18,7 @@ #include #include +#include int __nss_fgetent_r (FILE *fp, void *result, char *buffer, size_t buffer_length, diff --git a/posix/execl.c b/posix/execl.c index 8d319a4528..61aef66126 100644 --- a/posix/execl.c +++ b/posix/execl.c @@ -19,6 +19,7 @@ #include #include #include +#include /* Execute PATH with all arguments after PATH until a NULL pointer and environment from `environ'. */ diff --git a/posix/execle.c b/posix/execle.c index 7539ce6b8d..f6608ee112 100644 --- a/posix/execle.c +++ b/posix/execle.c @@ -19,6 +19,7 @@ #include #include #include +#include /* Execute PATH with all arguments after PATH until a NULL pointer, and the argument after that for environment. */ diff --git a/posix/execlp.c b/posix/execlp.c index 9eaca5fd25..4761962176 100644 --- a/posix/execlp.c +++ b/posix/execlp.c @@ -19,6 +19,7 @@ #include #include #include +#include /* Execute FILE, searching in the `PATH' environment variable if it contains no slashes, with all arguments after FILE until a diff --git a/posix/spawn_faction_addchdir.c b/posix/spawn_faction_addchdir.c index 6558628547..20a3ba92ab 100644 --- a/posix/spawn_faction_addchdir.c +++ b/posix/spawn_faction_addchdir.c @@ -19,7 +19,7 @@ #include #include #include - +#include #include "spawn_int.h" int diff --git a/pwd/putpwent.c b/pwd/putpwent.c index a6673acbf2..baf312a6fe 100644 --- a/pwd/putpwent.c +++ b/pwd/putpwent.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #define _S(x) x ?: "" diff --git a/signal/sigempty.c b/signal/sigempty.c index 31b1145027..01848c82d5 100644 --- a/signal/sigempty.c +++ b/signal/sigempty.c @@ -18,6 +18,7 @@ #include #include #include +#include /* Clear all signals from SET. */ int diff --git a/signal/sigismem.c b/signal/sigismem.c index 728d58f7a3..c788ca83b1 100644 --- a/signal/sigismem.c +++ b/signal/sigismem.c @@ -17,6 +17,7 @@ #include #include +#include #include /* Return 1 if SIGNO is in SET, 0 if not. */ diff --git a/sysdeps/generic/internal-signals.h b/sysdeps/generic/internal-signals.h index 73a0c29d82..cd675e4fd4 100644 --- a/sysdeps/generic/internal-signals.h +++ b/sysdeps/generic/internal-signals.h @@ -22,6 +22,7 @@ #include #include #include +#include static inline bool __is_internal_signal (int sig) diff --git a/sysdeps/ieee754/ldbl-128ibm/mpn2ldbl.c b/sysdeps/ieee754/ldbl-128ibm/mpn2ldbl.c index f77253e520..6ced407e26 100644 --- a/sysdeps/ieee754/ldbl-128ibm/mpn2ldbl.c +++ b/sysdeps/ieee754/ldbl-128ibm/mpn2ldbl.c @@ -20,9 +20,6 @@ #include #include -/* Need to set this when including gmp headers after system headers. */ -#define HAVE_ALLOCA 1 - #include "gmp.h" #include "gmp-impl.h" diff --git a/sysdeps/mach/hurd/mmap64.c b/sysdeps/mach/hurd/mmap64.c index 6d8566b5b1..23d7ca7f34 100644 --- a/sysdeps/mach/hurd/mmap64.c +++ b/sysdeps/mach/hurd/mmap64.c @@ -18,6 +18,7 @@ #include #include #include +#include /* Map addresses starting near ADDR and extending for LEN bytes. From OFFSET into the file FD describes according to PROT and FLAGS. If ADDR diff --git a/sysdeps/mach/hurd/waitid.c b/sysdeps/mach/hurd/waitid.c index dce72339dd..044a1dd8e3 100644 --- a/sysdeps/mach/hurd/waitid.c +++ b/sysdeps/mach/hurd/waitid.c @@ -19,6 +19,7 @@ #include #include +#include int __waitid (idtype_t idtype, id_t id, siginfo_t *infop, int options) diff --git a/sysdeps/microblaze/backtrace.c b/sysdeps/microblaze/backtrace.c index 8af5a4d7f5..f4a4b69df5 100644 --- a/sysdeps/microblaze/backtrace.c +++ b/sysdeps/microblaze/backtrace.c @@ -17,6 +17,7 @@ . */ #include +#include #include #include #include diff --git a/sysdeps/nptl/futex-internal.h b/sysdeps/nptl/futex-internal.h index cd356e4fa8..c27d0cdac8 100644 --- a/sysdeps/nptl/futex-internal.h +++ b/sysdeps/nptl/futex-internal.h @@ -23,6 +23,7 @@ #include #include #include +#include #include /* This file defines futex operations used internally in glibc. A futex diff --git a/sysdeps/unix/sysv/linux/adjtime.c b/sysdeps/unix/sysv/linux/adjtime.c index 6d1d1b6af2..8e7c8cc5da 100644 --- a/sysdeps/unix/sysv/linux/adjtime.c +++ b/sysdeps/unix/sysv/linux/adjtime.c @@ -19,6 +19,7 @@ #include #include #include +#include #define MAX_SEC (INT_MAX / 1000000L - 2) #define MIN_SEC (INT_MIN / 1000000L + 2) diff --git a/sysdeps/unix/sysv/linux/clock_getcpuclockid.c b/sysdeps/unix/sysv/linux/clock_getcpuclockid.c index 7d2e6d6bfe..1eb780a164 100644 --- a/sysdeps/unix/sysv/linux/clock_getcpuclockid.c +++ b/sysdeps/unix/sysv/linux/clock_getcpuclockid.c @@ -20,6 +20,7 @@ #include #include #include "kernel-posix-cpu-timers.h" +#include #include int diff --git a/sysdeps/unix/sysv/linux/faccessat.c b/sysdeps/unix/sysv/linux/faccessat.c index b697053da1..5d078371b5 100644 --- a/sysdeps/unix/sysv/linux/faccessat.c +++ b/sysdeps/unix/sysv/linux/faccessat.c @@ -16,14 +16,10 @@ License along with the GNU C Library; if not, see . */ -#include #include -#include -#include -#include #include #include -#include +#include #include diff --git a/sysdeps/unix/sysv/linux/ftime.c b/sysdeps/unix/sysv/linux/ftime.c index 1755fcf967..2f43b7650d 100644 --- a/sysdeps/unix/sysv/linux/ftime.c +++ b/sysdeps/unix/sysv/linux/ftime.c @@ -18,6 +18,7 @@ #include #include +#include #include int diff --git a/sysdeps/unix/sysv/linux/ftruncate64.c b/sysdeps/unix/sysv/linux/ftruncate64.c index 606a0e86e0..3d43a5a90f 100644 --- a/sysdeps/unix/sysv/linux/ftruncate64.c +++ b/sysdeps/unix/sysv/linux/ftruncate64.c @@ -17,7 +17,6 @@ #include #include -#include #ifndef __NR_ftruncate64 # define __NR_ftruncate64 __NR_ftruncate diff --git a/sysdeps/unix/sysv/linux/generic/chmod.c b/sysdeps/unix/sysv/linux/generic/chmod.c index b9631a9103..802e4006ee 100644 --- a/sysdeps/unix/sysv/linux/generic/chmod.c +++ b/sysdeps/unix/sysv/linux/generic/chmod.c @@ -16,11 +16,9 @@ License along with the GNU C Library. If not, see . */ -#include -#include #include -#include #include +#include /* Change the protections of FILE to MODE. */ int diff --git a/sysdeps/unix/sysv/linux/generic/chown.c b/sysdeps/unix/sysv/linux/generic/chown.c index d676eefab4..57a81834db 100644 --- a/sysdeps/unix/sysv/linux/generic/chown.c +++ b/sysdeps/unix/sysv/linux/generic/chown.c @@ -16,11 +16,9 @@ License along with the GNU C Library. If not, see . */ -#include -#include #include #include -#include +#include /* Change the owner and group of FILE. */ int diff --git a/sysdeps/unix/sysv/linux/generic/dup2.c b/sysdeps/unix/sysv/linux/generic/dup2.c index 32592f9450..dfa348b375 100644 --- a/sysdeps/unix/sysv/linux/generic/dup2.c +++ b/sysdeps/unix/sysv/linux/generic/dup2.c @@ -16,10 +16,9 @@ License along with the GNU C Library. If not, see . */ -#include #include -#include #include +#include /* Duplicate FD to FD2, closing the old FD2 and making FD2 be open the same file as FD is. Return FD2 or -1. */ diff --git a/sysdeps/unix/sysv/linux/generic/epoll_create.c b/sysdeps/unix/sysv/linux/generic/epoll_create.c index e3eac4a7ac..1715c6d9bf 100644 --- a/sysdeps/unix/sysv/linux/generic/epoll_create.c +++ b/sysdeps/unix/sysv/linux/generic/epoll_create.c @@ -16,11 +16,8 @@ License along with the GNU C Library. If not, see . */ -#include -#include -#include -#include #include +#include libc_hidden_proto (epoll_create) diff --git a/sysdeps/unix/sysv/linux/generic/inotify_init.c b/sysdeps/unix/sysv/linux/generic/inotify_init.c index 7f84124850..25a323f7e7 100644 --- a/sysdeps/unix/sysv/linux/generic/inotify_init.c +++ b/sysdeps/unix/sysv/linux/generic/inotify_init.c @@ -16,11 +16,8 @@ License along with the GNU C Library. If not, see . */ -#include -#include -#include -#include #include +#include libc_hidden_proto (inotify_init) diff --git a/sysdeps/unix/sysv/linux/generic/lchown.c b/sysdeps/unix/sysv/linux/generic/lchown.c index a483241fd3..379079e8ca 100644 --- a/sysdeps/unix/sysv/linux/generic/lchown.c +++ b/sysdeps/unix/sysv/linux/generic/lchown.c @@ -16,11 +16,9 @@ License along with the GNU C Library. If not, see . */ -#include -#include #include #include -#include +#include /* Change the owner and group of FILE. */ int diff --git a/sysdeps/unix/sysv/linux/generic/link.c b/sysdeps/unix/sysv/linux/generic/link.c index a038ba1408..1baa6b5e6a 100644 --- a/sysdeps/unix/sysv/linux/generic/link.c +++ b/sysdeps/unix/sysv/linux/generic/link.c @@ -16,10 +16,9 @@ License along with the GNU C Library. If not, see . */ -#include -#include #include #include +#include /* Make a link to FROM called TO. */ int diff --git a/sysdeps/unix/sysv/linux/generic/pipe.c b/sysdeps/unix/sysv/linux/generic/pipe.c index 5d4a95f3e7..52f3231cb8 100644 --- a/sysdeps/unix/sysv/linux/generic/pipe.c +++ b/sysdeps/unix/sysv/linux/generic/pipe.c @@ -16,9 +16,8 @@ License along with the GNU C Library. If not, see . */ -#include #include -#include +#include /* Create a one-way communication channel (__pipe). If successful, two file descriptors are stored in PIPEDES; diff --git a/sysdeps/unix/sysv/linux/generic/readlink.c b/sysdeps/unix/sysv/linux/generic/readlink.c index 721f84e3dd..6f690a9750 100644 --- a/sysdeps/unix/sysv/linux/generic/readlink.c +++ b/sysdeps/unix/sysv/linux/generic/readlink.c @@ -16,9 +16,9 @@ License along with the GNU C Library. If not, see . */ -#include #include #include +#include /* Read the contents of the symbolic link PATH into no more than LEN bytes of BUF. The contents are not null-terminated. diff --git a/sysdeps/unix/sysv/linux/generic/rmdir.c b/sysdeps/unix/sysv/linux/generic/rmdir.c index e357a10e8d..f9d721f3db 100644 --- a/sysdeps/unix/sysv/linux/generic/rmdir.c +++ b/sysdeps/unix/sysv/linux/generic/rmdir.c @@ -16,11 +16,9 @@ License along with the GNU C Library. If not, see . */ -#include -#include #include #include - +#include /* Remove the directory PATH. */ int diff --git a/sysdeps/unix/sysv/linux/generic/symlink.c b/sysdeps/unix/sysv/linux/generic/symlink.c index cddc11acf0..2c358f54c9 100644 --- a/sysdeps/unix/sysv/linux/generic/symlink.c +++ b/sysdeps/unix/sysv/linux/generic/symlink.c @@ -16,10 +16,9 @@ License along with the GNU C Library. If not, see . */ -#include -#include #include #include +#include /* Make a link to FROM called TO. */ int diff --git a/sysdeps/unix/sysv/linux/generic/unlink.c b/sysdeps/unix/sysv/linux/generic/unlink.c index 7908d0a576..8df55753a0 100644 --- a/sysdeps/unix/sysv/linux/generic/unlink.c +++ b/sysdeps/unix/sysv/linux/generic/unlink.c @@ -16,11 +16,9 @@ License along with the GNU C Library. If not, see . */ -#include -#include #include #include - +#include /* Remove the link named NAME. */ int diff --git a/sysdeps/unix/sysv/linux/generic/wordsize-32/fstatfs.c b/sysdeps/unix/sysv/linux/generic/wordsize-32/fstatfs.c index 93d9d94a0a..f80b56b303 100644 --- a/sysdeps/unix/sysv/linux/generic/wordsize-32/fstatfs.c +++ b/sysdeps/unix/sysv/linux/generic/wordsize-32/fstatfs.c @@ -16,10 +16,10 @@ License along with the GNU C Library. If not, see . */ -#include #include #include #include +#include #if !STATFS_IS_STATFS64 #include "overflow.h" diff --git a/sysdeps/unix/sysv/linux/generic/wordsize-32/overflow.h b/sysdeps/unix/sysv/linux/generic/wordsize-32/overflow.h index c5e028625a..e200f6319b 100644 --- a/sysdeps/unix/sysv/linux/generic/wordsize-32/overflow.h +++ b/sysdeps/unix/sysv/linux/generic/wordsize-32/overflow.h @@ -19,6 +19,7 @@ #include #include +#include /* Test for overflows of structures where we ask the kernel to fill them in with standard 64-bit syscalls but return them through APIs that diff --git a/sysdeps/unix/sysv/linux/generic/wordsize-32/sendfile.c b/sysdeps/unix/sysv/linux/generic/wordsize-32/sendfile.c index c556a37cd4..72e2d49d1a 100644 --- a/sysdeps/unix/sysv/linux/generic/wordsize-32/sendfile.c +++ b/sysdeps/unix/sysv/linux/generic/wordsize-32/sendfile.c @@ -17,7 +17,9 @@ . */ #include +#include #include +#include /* Send COUNT bytes from file associated with IN_FD starting at OFFSET to descriptor OUT_FD. */ diff --git a/sysdeps/unix/sysv/linux/generic/wordsize-32/statfs.c b/sysdeps/unix/sysv/linux/generic/wordsize-32/statfs.c index 7421501b4a..4484341075 100644 --- a/sysdeps/unix/sysv/linux/generic/wordsize-32/statfs.c +++ b/sysdeps/unix/sysv/linux/generic/wordsize-32/statfs.c @@ -19,7 +19,7 @@ #include #include #include -#include +#include #if !STATFS_IS_STATFS64 #include "overflow.h" diff --git a/sysdeps/unix/sysv/linux/getentropy.c b/sysdeps/unix/sysv/linux/getentropy.c index 2f3a4e4692..02cf46ff42 100644 --- a/sysdeps/unix/sysv/linux/getentropy.c +++ b/sysdeps/unix/sysv/linux/getentropy.c @@ -20,6 +20,7 @@ #include #include #include +#include /* Write LENGTH bytes of randomness starting at BUFFER. Return 0 on success and -1 on failure. */ diff --git a/sysdeps/unix/sysv/linux/getrlimit.c b/sysdeps/unix/sysv/linux/getrlimit.c index ecb34dd742..339d943bd2 100644 --- a/sysdeps/unix/sysv/linux/getrlimit.c +++ b/sysdeps/unix/sysv/linux/getrlimit.c @@ -16,9 +16,8 @@ License along with the GNU C Library. If not, see . */ -#include #include -#include +#include #include #if !__RLIM_T_MATCHES_RLIM64_T diff --git a/sysdeps/unix/sysv/linux/getrlimit64.c b/sysdeps/unix/sysv/linux/getrlimit64.c index 0f9a2f4936..e06ffd1a16 100644 --- a/sysdeps/unix/sysv/linux/getrlimit64.c +++ b/sysdeps/unix/sysv/linux/getrlimit64.c @@ -18,6 +18,7 @@ #include #include +#include #include /* Add this redirection so the strong_alias for __RLIM_T_MATCHES_RLIM64_T diff --git a/sysdeps/unix/sysv/linux/gettimeofday.c b/sysdeps/unix/sysv/linux/gettimeofday.c index cb57bc9cf2..1c92e6d643 100644 --- a/sysdeps/unix/sysv/linux/gettimeofday.c +++ b/sysdeps/unix/sysv/linux/gettimeofday.c @@ -16,15 +16,16 @@ License along with the GNU C Library; if not, see . */ +#include +#include + /* Optimize the function call by setting the PLT directly to vDSO symbol. */ #ifdef USE_IFUNC_GETTIMEOFDAY -# include -# include # include # include # ifdef SHARED -# include +# include # include static int diff --git a/sysdeps/unix/sysv/linux/hppa/sysdep.h b/sysdeps/unix/sysv/linux/hppa/sysdep.h index 7f8da30d23..531fe2beed 100644 --- a/sysdeps/unix/sysv/linux/hppa/sysdep.h +++ b/sysdeps/unix/sysv/linux/hppa/sysdep.h @@ -28,6 +28,8 @@ /* Defines RTLD_PRIVATE_ERRNO. */ #include +#include + /* In order to get __set_errno() definition in INLINE_SYSCALL. */ #ifndef __ASSEMBLER__ #include diff --git a/sysdeps/unix/sysv/linux/internal-signals.h b/sysdeps/unix/sysv/linux/internal-signals.h index 35f2de04c5..8455ca8de1 100644 --- a/sysdeps/unix/sysv/linux/internal-signals.h +++ b/sysdeps/unix/sysv/linux/internal-signals.h @@ -23,6 +23,7 @@ #include #include #include +#include #include /* The signal used for asynchronous cancelation. */ diff --git a/sysdeps/unix/sysv/linux/libc_fatal.c b/sysdeps/unix/sysv/linux/libc_fatal.c index 52fcd9761b..486c65e600 100644 --- a/sysdeps/unix/sysv/linux/libc_fatal.c +++ b/sysdeps/unix/sysv/linux/libc_fatal.c @@ -18,6 +18,8 @@ #include #include +#include +#include static bool writev_for_fatal (int fd, const struct iovec *iov, size_t niov, size_t total) diff --git a/sysdeps/unix/sysv/linux/microblaze/sysdep.h b/sysdeps/unix/sysv/linux/microblaze/sysdep.h index d500172114..6fd96adbf0 100644 --- a/sysdeps/unix/sysv/linux/microblaze/sysdep.h +++ b/sysdeps/unix/sysv/linux/microblaze/sysdep.h @@ -26,6 +26,8 @@ /* Defines RTLD_PRIVATE_ERRNO. */ #include +#include + /* In order to get __set_errno() definition in INLINE_SYSCALL. */ #ifndef __ASSEMBLER__ # include diff --git a/sysdeps/unix/sysv/linux/mknodat.c b/sysdeps/unix/sysv/linux/mknodat.c index fdb8f1951a..279a4404f5 100644 --- a/sysdeps/unix/sysv/linux/mknodat.c +++ b/sysdeps/unix/sysv/linux/mknodat.c @@ -19,6 +19,7 @@ #include #include #include +#include int __mknodat (int fd, const char *path, mode_t mode, dev_t dev) diff --git a/sysdeps/unix/sysv/linux/netlink_assert_response.c b/sysdeps/unix/sysv/linux/netlink_assert_response.c index 5fc0920bb0..5bacf7377f 100644 --- a/sysdeps/unix/sysv/linux/netlink_assert_response.c +++ b/sysdeps/unix/sysv/linux/netlink_assert_response.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include "netlinkaccess.h" diff --git a/sysdeps/unix/sysv/linux/posix_fadvise64.c b/sysdeps/unix/sysv/linux/posix_fadvise64.c index 6ef425cf22..4a1fc0225b 100644 --- a/sysdeps/unix/sysv/linux/posix_fadvise64.c +++ b/sysdeps/unix/sysv/linux/posix_fadvise64.c @@ -17,6 +17,7 @@ #include #include +#include #include int __posix_fadvise64_l64 (int fd, off64_t offset, off64_t len, int advise); diff --git a/sysdeps/unix/sysv/linux/prlimit.c b/sysdeps/unix/sysv/linux/prlimit.c index aa74a52eb7..e12eb4e9bc 100644 --- a/sysdeps/unix/sysv/linux/prlimit.c +++ b/sysdeps/unix/sysv/linux/prlimit.c @@ -15,10 +15,8 @@ License along with the GNU C Library; if not, see . */ -#include #include -#include - +#include int prlimit (__pid_t pid, enum __rlimit_resource resource, diff --git a/sysdeps/unix/sysv/linux/readahead.c b/sysdeps/unix/sysv/linux/readahead.c index a189c3ac79..ad01a0aed8 100644 --- a/sysdeps/unix/sysv/linux/readahead.c +++ b/sysdeps/unix/sysv/linux/readahead.c @@ -17,7 +17,7 @@ . */ #include -#include +#include #include ssize_t diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/utmp32.c b/sysdeps/unix/sysv/linux/s390/s390-32/utmp32.c index e4b82512f6..fa4b244728 100644 --- a/sysdeps/unix/sysv/linux/s390/s390-32/utmp32.c +++ b/sysdeps/unix/sysv/linux/s390/s390-32/utmp32.c @@ -19,7 +19,7 @@ #include #include #include -#include +#include #include "utmp32.h" #include "utmp-convert.h" diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/utmpx32.c b/sysdeps/unix/sysv/linux/s390/s390-32/utmpx32.c index 3f78fa62db..bdfe396d59 100644 --- a/sysdeps/unix/sysv/linux/s390/s390-32/utmpx32.c +++ b/sysdeps/unix/sysv/linux/s390/s390-32/utmpx32.c @@ -19,7 +19,7 @@ #include #include #include -#include +#include #include "utmp32.h" #include "utmp-convert.h" diff --git a/sysdeps/unix/sysv/linux/semop.c b/sysdeps/unix/sysv/linux/semop.c index e955f0cd31..ab790ea40f 100644 --- a/sysdeps/unix/sysv/linux/semop.c +++ b/sysdeps/unix/sysv/linux/semop.c @@ -17,9 +17,9 @@ . */ #include +#include #include #include -#include /* Perform user-defined atomical operation of array of semaphores. */ diff --git a/sysdeps/unix/sysv/linux/setrlimit.c b/sysdeps/unix/sysv/linux/setrlimit.c index 8611d577a4..6648fad5c0 100644 --- a/sysdeps/unix/sysv/linux/setrlimit.c +++ b/sysdeps/unix/sysv/linux/setrlimit.c @@ -16,9 +16,8 @@ License along with the GNU C Library. If not, see . */ -#include #include -#include +#include #include #if !__RLIM_T_MATCHES_RLIM64_T diff --git a/sysdeps/unix/sysv/linux/setrlimit64.c b/sysdeps/unix/sysv/linux/setrlimit64.c index e4c5bab437..02c94e3c73 100644 --- a/sysdeps/unix/sysv/linux/setrlimit64.c +++ b/sysdeps/unix/sysv/linux/setrlimit64.c @@ -18,6 +18,7 @@ #include #include +#include #include /* Add this redirection so the strong_alias for __RLIM_T_MATCHES_RLIM64_T diff --git a/sysdeps/unix/sysv/linux/settimezone.c b/sysdeps/unix/sysv/linux/settimezone.c index fa463866f3..163956275f 100644 --- a/sysdeps/unix/sysv/linux/settimezone.c +++ b/sysdeps/unix/sysv/linux/settimezone.c @@ -18,6 +18,7 @@ #include #include +#include #include /* Set the system-wide timezone. diff --git a/sysdeps/unix/sysv/linux/shmget.c b/sysdeps/unix/sysv/linux/shmget.c index 71de81c365..6ea788351b 100644 --- a/sysdeps/unix/sysv/linux/shmget.c +++ b/sysdeps/unix/sysv/linux/shmget.c @@ -16,9 +16,10 @@ License along with the GNU C Library; if not, see . */ +#include +#include #include #include -#include /* Return an identifier for an shared memory segment of at least size SIZE which is associated with KEY. */ diff --git a/sysdeps/unix/sysv/linux/socketcall.h b/sysdeps/unix/sysv/linux/socketcall.h index 75c2a6404d..b9975f92b4 100644 --- a/sysdeps/unix/sysv/linux/socketcall.h +++ b/sysdeps/unix/sysv/linux/socketcall.h @@ -19,6 +19,8 @@ #ifndef _SYS_SOCKETCALL_H #define _SYS_SOCKETCALL_H 1 +#include + /* Define unique numbers for the operations permitted on socket. Linux uses a single system call for all these functions. The relevant code file is /usr/include/linux/net.h. diff --git a/sysdeps/unix/sysv/linux/speed.c b/sysdeps/unix/sysv/linux/speed.c index c02a06a379..d7d74ddb67 100644 --- a/sysdeps/unix/sysv/linux/speed.c +++ b/sysdeps/unix/sysv/linux/speed.c @@ -19,7 +19,7 @@ #include #include #include - +#include /* This is a gross hack around a kernel bug. If the cfsetispeed functions is called with the SPEED argument set to zero this means use the same diff --git a/sysdeps/unix/sysv/linux/statx.c b/sysdeps/unix/sysv/linux/statx.c index 9721fc12a5..cea6eefb7e 100644 --- a/sysdeps/unix/sysv/linux/statx.c +++ b/sysdeps/unix/sysv/linux/statx.c @@ -18,7 +18,7 @@ #include #include - +#include #include "statx_generic.c" int diff --git a/sysdeps/unix/sysv/linux/sysctl.c b/sysdeps/unix/sysv/linux/sysctl.c index 389b958226..479ba386bd 100644 --- a/sysdeps/unix/sysv/linux/sysctl.c +++ b/sysdeps/unix/sysv/linux/sysctl.c @@ -17,6 +17,7 @@ . */ #include +#include #include #if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_32) diff --git a/sysdeps/unix/sysv/linux/sysdep.h b/sysdeps/unix/sysv/linux/sysdep.h index 3fa29dd588..9750c0418e 100644 --- a/sysdeps/unix/sysv/linux/sysdep.h +++ b/sysdeps/unix/sysv/linux/sysdep.h @@ -20,6 +20,7 @@ #include #include +#include #include #ifndef __ASSEMBLER__ diff --git a/sysdeps/unix/sysv/linux/truncate64.c b/sysdeps/unix/sysv/linux/truncate64.c index d4b46574dc..ac43a2b542 100644 --- a/sysdeps/unix/sysv/linux/truncate64.c +++ b/sysdeps/unix/sysv/linux/truncate64.c @@ -17,7 +17,6 @@ #include #include -#include #ifndef __NR_truncate64 # define __NR_truncate64 __NR_truncate diff --git a/sysdeps/unix/sysv/linux/ustat.c b/sysdeps/unix/sysv/linux/ustat.c index 51f20a2a73..e38b792705 100644 --- a/sysdeps/unix/sysv/linux/ustat.c +++ b/sysdeps/unix/sysv/linux/ustat.c @@ -23,7 +23,7 @@ #if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_28) # include -# include +# include # ifndef DEV_TO_KDEV # define DEV_TO_KDEV(__dev) \ diff --git a/sysdeps/unix/sysv/linux/xmknod.c b/sysdeps/unix/sysv/linux/xmknod.c index 82bb0bd953..10e874a514 100644 --- a/sysdeps/unix/sysv/linux/xmknod.c +++ b/sysdeps/unix/sysv/linux/xmknod.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_33) diff --git a/sysdeps/unix/sysv/linux/xmknodat.c b/sysdeps/unix/sysv/linux/xmknodat.c index fae3fe54d1..17ffea16c9 100644 --- a/sysdeps/unix/sysv/linux/xmknodat.c +++ b/sysdeps/unix/sysv/linux/xmknodat.c @@ -17,6 +17,7 @@ #include #include +#include #include #if SHLIB_COMPAT(libc, GLIBC_2_4, GLIBC_2_33) diff --git a/sysdeps/unix/sysv/linux/xstatconv.c b/sysdeps/unix/sysv/linux/xstatconv.c index 3622a82cd0..b100e07783 100644 --- a/sysdeps/unix/sysv/linux/xstatconv.c +++ b/sysdeps/unix/sysv/linux/xstatconv.c @@ -19,6 +19,7 @@ #include #include #include +#include #if STAT_IS_KERNEL_STAT diff --git a/sysdeps/x86_64/stackinfo.h b/sysdeps/x86_64/stackinfo.h index 7bcb3b1499..4a4e54cd76 100644 --- a/sysdeps/x86_64/stackinfo.h +++ b/sysdeps/x86_64/stackinfo.h @@ -23,6 +23,12 @@ #include +#ifdef __ILP32__ +# define RSP_REG "esp" +#else +# define RSP_REG "rsp" +#endif + /* On x86_64 the stack grows down. */ #define _STACK_GROWS_DOWN 1 @@ -34,10 +40,10 @@ for which they need to act as barriers as well, hence the additional (unnecessary) parameters. */ #define stackinfo_get_sp() \ - ({ void *p__; asm volatile ("mov %%" RSP_LP ", %0" : "=r" (p__)); p__; }) + ({ void *p__; asm volatile ("mov %%" RSP_REG ", %0" : "=r" (p__)); p__; }) #define stackinfo_sub_sp(ptr) \ ({ ptrdiff_t d__; \ - asm volatile ("sub %%" RSP_LP " , %0" : "=r" (d__) : "0" (ptr)); \ + asm volatile ("sub %%" RSP_REG " , %0" : "=r" (d__) : "0" (ptr)); \ d__; }) #endif /* stackinfo.h */ From patchwork Mon Nov 9 20:18:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 40983 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 582E8397280C; Mon, 9 Nov 2020 20:18:45 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 582E8397280C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1604953125; bh=Ggx3bLadphqHIHAOga6PxAtohcmcEf0rnzHH6lfMbhA=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=fyQ8KZcTpd2nUwHYaHwPOyAKINRFBguyamod6EVG+jBPEPv8P72blAxIfQ/9JcBIu RoVFK+jxMGLOw1Lm4DFR5tbwg2rLrpW1PryVu0RqPR3dL5xxNcKL4PZDRLLzZOGaOh GuZDYrsTXxlT7dCroxEsHnCrB+Bt/3aDuoZkq7tI= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-qt1-x844.google.com (mail-qt1-x844.google.com [IPv6:2607:f8b0:4864:20::844]) by sourceware.org (Postfix) with ESMTPS id 4F4A7397200C for ; Mon, 9 Nov 2020 20:18:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 4F4A7397200C Received: by mail-qt1-x844.google.com with SMTP id g15so3243028qtq.13 for ; Mon, 09 Nov 2020 12:18:41 -0800 (PST) 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:mime-version:content-transfer-encoding; bh=Ggx3bLadphqHIHAOga6PxAtohcmcEf0rnzHH6lfMbhA=; b=YWtWkxbIq7kXHkYnfYIH1R5jofqpUuVqlsj/m/z8m/BBqN2G8MrrFalVemxhg5NBR/ pagRNMSrILMWr0ttakegZQBpG3qZ41xg2iLbAsXTdxm+tOtimVfs0gPsKqUENE9n7l+i yuAazPCNNJ6Dh54I4jRCruN6bXYI25wzz4AdnglJoesTDOfiXXcEcDWn9vol45G0jzHP /uo4cjmHFsvuMOX+VY9HYXiN8IyYf8f/Z0sdZuIrwP/CJllSN6r3tTYdvTngKvuiPyrZ 2oYWrpr7OphFWI+tOehzmUzmQoEx2le5EZEWs0rWOVT5FDQFMPD91UxofZxJRtrJgZ5/ 9UhQ== X-Gm-Message-State: AOAM533dMPFCEDS32z/OrQy65bko9zwKl1IulykFJSFu3k6PBv5kRpi/ k1Pr9YnrYXOVw06qcaC44GTjeufgDKTSlA== X-Google-Smtp-Source: ABdhPJwAKcnjVYHBtJVKcwblDdTTNkyd9CVO7ckPqjili01ofv/lrWfJgGaN9MrDb4NjC6AnRO3lFg== X-Received: by 2002:ac8:4d99:: with SMTP id a25mr4511007qtw.122.1604953120653; Mon, 09 Nov 2020 12:18:40 -0800 (PST) Received: from localhost.localdomain ([177.194.48.209]) by smtp.googlemail.com with ESMTPSA id z2sm6843407qkl.22.2020.11.09.12.18.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Nov 2020 12:18:40 -0800 (PST) To: libc-alpha@sourceware.org Subject: [PATCH 04/23] linux: Add syscall_ret and use it on INLINE_SYSCALL Date: Mon, 9 Nov 2020 17:18:07 -0300 Message-Id: <20201109201826.120534-5-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201109201826.120534-1-adhemerval.zanella@linaro.org> References: <20201109201826.120534-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-14.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Adhemerval Zanella via Libc-alpha From: Adhemerval Zanella Netto Reply-To: Adhemerval Zanella Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" It check the resulting value from INTERNAL_SYSCALL_CALL and sets the errno accordingly. Checked on x86_64-linux-gnu and i686-linux-gnu. --- sysdeps/unix/sysv/linux/fstatat.c | 4 +--- sysdeps/unix/sysv/linux/fstatat64.c | 4 +--- sysdeps/unix/sysv/linux/mq_unlink.c | 11 +++-------- sysdeps/unix/sysv/linux/sysdep-vdso.h | 26 +++++-------------------- sysdeps/unix/sysv/linux/sysdep.h | 28 ++++++++++++--------------- 5 files changed, 22 insertions(+), 51 deletions(-) diff --git a/sysdeps/unix/sysv/linux/fstatat.c b/sysdeps/unix/sysv/linux/fstatat.c index a61fffa6e7..5ba1b99372 100644 --- a/sysdeps/unix/sysv/linux/fstatat.c +++ b/sysdeps/unix/sysv/linux/fstatat.c @@ -80,9 +80,7 @@ __fstatat (int fd, const char *file, struct stat *buf, int flag) # endif /* __nr_fstatat64 */ # endif /* STAT_IS_KERNEL_STAT */ - return syscall_error (r) - ? INLINE_SYSCALL_ERROR_RETURN_VALUE (-r) - : 0; + return syscall_ret (r); } weak_alias (__fstatat, fstatat) diff --git a/sysdeps/unix/sysv/linux/fstatat64.c b/sysdeps/unix/sysv/linux/fstatat64.c index 6e12cf2456..a788940390 100644 --- a/sysdeps/unix/sysv/linux/fstatat64.c +++ b/sysdeps/unix/sysv/linux/fstatat64.c @@ -102,9 +102,7 @@ __fstatat64_time64 (int fd, const char *file, struct __stat64_t64 *buf, # endif #endif - return syscall_error (r) - ? INLINE_SYSCALL_ERROR_RETURN_VALUE (-r) - : 0; + return syscall_ret (r); } #if __TIMESIZE != 64 hidden_def (__fstatat64_time64) diff --git a/sysdeps/unix/sysv/linux/mq_unlink.c b/sysdeps/unix/sysv/linux/mq_unlink.c index 4964eb9028..701bc86438 100644 --- a/sysdeps/unix/sysv/linux/mq_unlink.c +++ b/sysdeps/unix/sysv/linux/mq_unlink.c @@ -30,12 +30,7 @@ mq_unlink (const char *name) /* While unlink can return either EPERM or EACCES, mq_unlink should return just EACCES. */ - if (__glibc_unlikely (syscall_error (ret))) - { - if (ret == -EPERM) - ret = -EACCES; - return INLINE_SYSCALL_ERROR_RETURN_VALUE (-ret); - } - - return ret; + if (ret == -EPERM) + ret = -EACCES; + return syscall_ret (ret); } diff --git a/sysdeps/unix/sysv/linux/sysdep-vdso.h b/sysdeps/unix/sysv/linux/sysdep-vdso.h index 7c578808c6..9f59198444 100644 --- a/sysdeps/unix/sysv/linux/sysdep-vdso.h +++ b/sysdeps/unix/sysv/linux/sysdep-vdso.h @@ -28,29 +28,13 @@ #define INLINE_VSYSCALL(name, nr, args...) \ ({ \ - __label__ out; \ - __label__ iserr; \ - long int sc_ret; \ - \ + long int sc_ret = -ENOSYS; \ __typeof (GLRO(dl_vdso_##name)) vdsop = GLRO(dl_vdso_##name); \ if (vdsop != NULL) \ - { \ - sc_ret = INTERNAL_VSYSCALL_CALL (vdsop, nr, ##args); \ - if (!syscall_error (sc_ret)) \ - goto out; \ - if (sc_ret != -ENOSYS) \ - goto iserr; \ - } \ - \ - sc_ret = INTERNAL_SYSCALL_CALL (name, ##args); \ - if (syscall_error (sc_ret)) \ - { \ - iserr: \ - __set_errno (-sc_ret); \ - sc_ret = -1L; \ - } \ - out: \ - sc_ret; \ + sc_ret = INTERNAL_VSYSCALL_CALL (vdsop, nr, ##args); \ + if (sc_ret == -ENOSYS) \ + sc_ret = INTERNAL_SYSCALL_CALL (name, ##args); \ + syscall_ret (sc_ret); \ }) #endif /* SYSDEP_VDSO_LINUX_H */ diff --git a/sysdeps/unix/sysv/linux/sysdep.h b/sysdeps/unix/sysv/linux/sysdep.h index 9750c0418e..66bac892a5 100644 --- a/sysdeps/unix/sysv/linux/sysdep.h +++ b/sysdeps/unix/sysv/linux/sysdep.h @@ -29,28 +29,24 @@ syscall_error (unsigned long int val) { return val > -4096UL; } -#endif -#ifndef SYSCALL_ERROR_LABEL -# define SYSCALL_ERROR_LABEL(sc_err) \ - ({ \ - __set_errno (sc_err); \ - -1L; \ - }) -#endif +static inline long int +syscall_ret (unsigned long int val) +{ + if (syscall_error (val)) + { + __set_errno (-val); + return -1; + } + return val; +} -#ifndef __ASSEMBLER__ /* Define a macro which expands into the inline wrapper code for a system call. It sets the errno and returns -1 on a failure, or the syscall return value otherwise. */ #undef INLINE_SYSCALL -#define INLINE_SYSCALL(name, nr, args...) \ - ({ \ - long int sc_ret = INTERNAL_SYSCALL (name, nr, args); \ - __glibc_unlikely (syscall_error (sc_ret)) \ - ? SYSCALL_ERROR_LABEL (-sc_ret) \ - : sc_ret; \ - }) +#define INLINE_SYSCALL(...) \ + syscall_ret (INTERNAL_SYSCALL (__VA_ARGS__)) #endif /* Set error number and return -1. A target may choose to return the From patchwork Mon Nov 9 20:18:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 40987 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D55903973052; Mon, 9 Nov 2020 20:18:48 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D55903973052 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1604953128; bh=ahl2PpGREnnjQSkprODoSKMJYV5bZSQhT6Tov1ImNvk=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=NlI8fXmTZXAKgWOcOCMafIXnb0dNHzenUlaLQDCDP1U+bLFMnBMXfj3ZsjcbOiMWj Pf05vL4UBOT6NIuyZVLPV7YnRdzf1nZFap3kXTKT7PwHIOGpAePsH4+VtBKONSlYZP fW2y40NsfJ7jW1HhdLeRzERucKX2CS4M93rRxpnU= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-qk1-x744.google.com (mail-qk1-x744.google.com [IPv6:2607:f8b0:4864:20::744]) by sourceware.org (Postfix) with ESMTPS id 71EAD39724A0 for ; Mon, 9 Nov 2020 20:18:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 71EAD39724A0 Received: by mail-qk1-x744.google.com with SMTP id v143so4703443qkb.2 for ; Mon, 09 Nov 2020 12:18:43 -0800 (PST) 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:mime-version:content-transfer-encoding; bh=ahl2PpGREnnjQSkprODoSKMJYV5bZSQhT6Tov1ImNvk=; b=U+Gnm/1FTKh8BYQiT+y25jDFjzvN8dseRUsuAIHqosNmdpE9gQ92+rRREuEQgR1elO oY5cMZ2itHAgvx3UeuujEYOySeRG1zrvOyBAVEVtD5mYzstDVTnX/YDWYct40EbDNoqa 1AJJRyKXlSwnjtPg13n6K3JhwtdMPJQ0nNZgk/B6gMMBwNJZ1J/SZ2u4OVVe1LubFRR8 q3dYa48tG3J32EZurCy1MFt+0lx7Mux0OrCPVFYWpFhvD3bZ5u/6ic5/o0AN8ghB+4Uy 6dp4ORVRNiljYVxqeMRzqKE4ycUlaS0yYDWHbq9iUQSHwiXa+Aj1b5mX7bEP9+5iyRdP grjQ== X-Gm-Message-State: AOAM53092sOUa/Hz3lGxV1M62+Iq+SYtE2jWeE3XACLdv9PzAEYYr9jo vy+Vfu8nYZIplMM9/SBrlv77dzSLWZZXyA== X-Google-Smtp-Source: ABdhPJxjlQHUhNCaD4B/kyJSXYhzvmHKjmsvLeIHRbPjqFkf4G7A6deoLHnfwBAA8J4jHVgXcKlpQg== X-Received: by 2002:a37:8245:: with SMTP id e66mr10930076qkd.389.1604953122115; Mon, 09 Nov 2020 12:18:42 -0800 (PST) Received: from localhost.localdomain ([177.194.48.209]) by smtp.googlemail.com with ESMTPSA id z2sm6843407qkl.22.2020.11.09.12.18.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Nov 2020 12:18:41 -0800 (PST) To: libc-alpha@sourceware.org Subject: [PATCH 05/23] linux: Replace INLINE_SYSCALL_ERROR_RETURN_VALUE with __syscall_error Date: Mon, 9 Nov 2020 17:18:08 -0300 Message-Id: <20201109201826.120534-6-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201109201826.120534-1-adhemerval.zanella@linaro.org> References: <20201109201826.120534-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-14.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Adhemerval Zanella via Libc-alpha From: Adhemerval Zanella Netto Reply-To: Adhemerval Zanella Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" The INLINE_SYSCALL_ERROR_RETURN_VALUE macro was added as a way to optimize i686 errno setting when {INTERNAL,INLINE}_SYSCALL is called (since calling__x86.get_pc_thunk.reg to load PC into reg to access errno is costly for the cases where there is no error). However this i686 optimizations was also remove by fcb78a55058f, which consolidate INLINE_SYSCALL semantic and removed i686 INLINE_SYSCALL_ERROR_RETURN_VALUE definition. This patch adds this optimization back, but in a more generic way. Each architecture/ABI might select how __syscall_error is emitted, either by using a static inline or using a external call. To avoid the potential PLT call overhead, for the latter __syscall_error is added on each library that issues {INTERNAL,INLINE}_SYSCALL as a hidden symbol (and this follow the idea of moving all the libpthread and librt to libc). No semantic changes expected, checked with a build against all affected ABIs. --- sysdeps/unix/sysv/linux/Makefile | 9 ++++- sysdeps/unix/sysv/linux/aarch64/sysdep.c | 1 - sysdeps/unix/sysv/linux/adjtime.c | 2 +- sysdeps/unix/sysv/linux/alpha/fxstat64.c | 2 +- sysdeps/unix/sysv/linux/alpha/lxstat64.c | 2 +- sysdeps/unix/sysv/linux/alpha/xstat64.c | 2 +- sysdeps/unix/sysv/linux/arc/sysdep.c | 8 ++-- sysdeps/unix/sysv/linux/arc/sysdep.h | 5 --- sysdeps/unix/sysv/linux/faccessat.c | 4 +- sysdeps/unix/sysv/linux/fchmodat.c | 2 +- sysdeps/unix/sysv/linux/fcntl_nocancel.c | 2 +- sysdeps/unix/sysv/linux/fstatat.c | 4 +- sysdeps/unix/sysv/linux/fstatat64.c | 2 +- sysdeps/unix/sysv/linux/futimens.c | 2 +- sysdeps/unix/sysv/linux/fxstat.c | 2 +- sysdeps/unix/sysv/linux/fxstat64.c | 2 +- sysdeps/unix/sysv/linux/fxstatat.c | 2 +- sysdeps/unix/sysv/linux/fxstatat64.c | 2 +- sysdeps/unix/sysv/linux/getdents.c | 2 +- sysdeps/unix/sysv/linux/hppa/sysdep.c | 2 - sysdeps/unix/sysv/linux/i386/brk.c | 2 +- sysdeps/unix/sysv/linux/i386/sysdep.c | 1 - sysdeps/unix/sysv/linux/i386/sysdep.h | 3 -- sysdeps/unix/sysv/linux/lxstat.c | 2 +- sysdeps/unix/sysv/linux/lxstat64.c | 2 +- .../unix/sysv/linux/mips/mips64/fxstatat64.c | 2 +- sysdeps/unix/sysv/linux/mknodat.c | 2 +- sysdeps/unix/sysv/linux/mmap.c | 2 +- sysdeps/unix/sysv/linux/mmap64.c | 2 +- sysdeps/unix/sysv/linux/mq_open.c | 2 +- sysdeps/unix/sysv/linux/mq_unlink.c | 2 +- sysdeps/unix/sysv/linux/powerpc/sysdep.c | 1 - sysdeps/unix/sysv/linux/prlimit.c | 4 +- sysdeps/unix/sysv/linux/setegid.c | 2 +- sysdeps/unix/sysv/linux/seteuid.c | 2 +- sysdeps/unix/sysv/linux/shmat.c | 2 +- sysdeps/unix/sysv/linux/speed.c | 4 +- sysdeps/unix/sysv/linux/syscall_error.c | 30 +++++++++++++++ sysdeps/unix/sysv/linux/sysdep.h | 37 ++++++++++++------- sysdeps/unix/sysv/linux/tcsendbrk.c | 2 +- sysdeps/unix/sysv/linux/tcsetattr.c | 2 +- sysdeps/unix/sysv/linux/ustat.c | 4 +- sysdeps/unix/sysv/linux/utimensat.c | 2 +- sysdeps/unix/sysv/linux/xmknod.c | 2 +- sysdeps/unix/sysv/linux/xmknodat.c | 2 +- sysdeps/unix/sysv/linux/xstat.c | 2 +- sysdeps/unix/sysv/linux/xstat64.c | 2 +- sysdeps/unix/sysv/linux/xstatconv.c | 12 +++--- 48 files changed, 113 insertions(+), 80 deletions(-) create mode 100644 sysdeps/unix/sysv/linux/syscall_error.c diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile index 09604e128b..241b5f2c53 100644 --- a/sysdeps/unix/sysv/linux/Makefile +++ b/sysdeps/unix/sysv/linux/Makefile @@ -41,7 +41,7 @@ update-syscall-lists: arch-syscall.h endif ifeq ($(subdir),csu) -sysdep_routines += errno-loc +sysdep_routines += errno-loc syscall_error endif ifeq ($(subdir),assert) @@ -283,7 +283,8 @@ tests += tst-fallocate tst-fallocate64 tst-o_path-locks endif ifeq ($(subdir),elf) -sysdep-rtld-routines += dl-brk dl-sbrk dl-getcwd dl-openat64 dl-opendir +sysdep-rtld-routines += dl-brk dl-sbrk dl-getcwd dl-openat64 dl-opendir \ + syscall_error libof-lddlibc4 = lddlibc4 @@ -295,6 +296,8 @@ endif ifeq ($(subdir),rt) CFLAGS-mq_send.c += -fexceptions CFLAGS-mq_receive.c += -fexceptions +librt-routines += syscall_error +librt-shared-only-routines += syscall_error endif ifeq ($(subdir),nscd) @@ -303,5 +306,7 @@ CFLAGS-gai.c += -DNEED_NETLINK endif ifeq ($(subdir),nptl) +libpthread-routines += syscall_error +libpthread-shared-only-routines += syscall_error tests += tst-align-clone tst-getpid1 endif diff --git a/sysdeps/unix/sysv/linux/aarch64/sysdep.c b/sysdeps/unix/sysv/linux/aarch64/sysdep.c index b6c01e1aec..6b88f3484f 100644 --- a/sysdeps/unix/sysv/linux/aarch64/sysdep.c +++ b/sysdeps/unix/sysv/linux/aarch64/sysdep.c @@ -16,7 +16,6 @@ License along with the GNU C Library. If not, see . */ -#include #include long __syscall_error (long err); diff --git a/sysdeps/unix/sysv/linux/adjtime.c b/sysdeps/unix/sysv/linux/adjtime.c index 8e7c8cc5da..1a1a37acd3 100644 --- a/sysdeps/unix/sysv/linux/adjtime.c +++ b/sysdeps/unix/sysv/linux/adjtime.c @@ -37,7 +37,7 @@ __adjtime64 (const struct __timeval64 *itv, struct __timeval64 *otv) tmp.tv_sec = itv->tv_sec + itv->tv_usec / 1000000L; tmp.tv_usec = itv->tv_usec % 1000000L; if (tmp.tv_sec > MAX_SEC || tmp.tv_sec < MIN_SEC) - return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL); + return __syscall_error (-EINVAL); tntx.offset = tmp.tv_usec + tmp.tv_sec * 1000000L; tntx.modes = ADJ_OFFSET_SINGLESHOT; } diff --git a/sysdeps/unix/sysv/linux/alpha/fxstat64.c b/sysdeps/unix/sysv/linux/alpha/fxstat64.c index bcfb55050c..806ef66598 100644 --- a/sysdeps/unix/sysv/linux/alpha/fxstat64.c +++ b/sysdeps/unix/sysv/linux/alpha/fxstat64.c @@ -40,7 +40,7 @@ __fxstat64 (int vers, int fd, struct stat64 *buf) int r = INTERNAL_SYSCALL_CALL (fstat, fd, &kbuf); if (r == 0) return __xstat_conv (vers, &kbuf, buf); - return INLINE_SYSCALL_ERROR_RETURN_VALUE (-r); + return __syscall_error (r); } } } diff --git a/sysdeps/unix/sysv/linux/alpha/lxstat64.c b/sysdeps/unix/sysv/linux/alpha/lxstat64.c index 7424b2f621..0499b0f8f1 100644 --- a/sysdeps/unix/sysv/linux/alpha/lxstat64.c +++ b/sysdeps/unix/sysv/linux/alpha/lxstat64.c @@ -41,7 +41,7 @@ __lxstat64 (int vers, const char *name, struct stat64 *buf) int r = INTERNAL_SYSCALL_CALL (lstat, name, &kbuf); if (r == 0) return __xstat_conv (vers, &kbuf, buf); - return INLINE_SYSCALL_ERROR_RETURN_VALUE (-r); + return __syscall_error (r); } } } diff --git a/sysdeps/unix/sysv/linux/alpha/xstat64.c b/sysdeps/unix/sysv/linux/alpha/xstat64.c index 59f7ddae7f..b08ade68d4 100644 --- a/sysdeps/unix/sysv/linux/alpha/xstat64.c +++ b/sysdeps/unix/sysv/linux/alpha/xstat64.c @@ -41,7 +41,7 @@ __xstat64 (int vers, const char *name, struct stat64 *buf) int r = INTERNAL_SYSCALL_CALL (stat, name, &kbuf); if (r == 0) return __xstat_conv (vers, &kbuf, buf); - return INLINE_SYSCALL_ERROR_RETURN_VALUE (-r); + return __syscall_error (r); } } } diff --git a/sysdeps/unix/sysv/linux/arc/sysdep.c b/sysdeps/unix/sysv/linux/arc/sysdep.c index f33d646798..fe904d723b 100644 --- a/sysdeps/unix/sysv/linux/arc/sysdep.c +++ b/sysdeps/unix/sysv/linux/arc/sysdep.c @@ -16,9 +16,11 @@ License along with the GNU C Library; if not, see . */ -#include #include +extern long int __syscall_error (long int); +libc_hidden_proto (__syscall_error) + /* All syscall handlers land here to avoid generated code bloat due to GOT reference to errno_location or it's equivalent. */ long int @@ -28,6 +30,4 @@ __syscall_error (long int err_no) return -1; } -#if IS_IN (libc) -hidden_def (__syscall_error) -#endif +libc_hidden_def (__syscall_error) diff --git a/sysdeps/unix/sysv/linux/arc/sysdep.h b/sysdeps/unix/sysv/linux/arc/sysdep.h index 8465a2f623..4ab44f6925 100644 --- a/sysdeps/unix/sysv/linux/arc/sysdep.h +++ b/sysdeps/unix/sysv/linux/arc/sysdep.h @@ -134,11 +134,6 @@ L (call_syscall_err): ASM_LINE_SEP \ # define SINGLE_THREAD_BY_GLOBAL 1 -# if IS_IN (libc) -extern long int __syscall_error (long int); -hidden_proto (__syscall_error) -# endif - # define ARC_TRAP_INSN "trap_s 0 \n\t" # undef INTERNAL_SYSCALL_NCS diff --git a/sysdeps/unix/sysv/linux/faccessat.c b/sysdeps/unix/sysv/linux/faccessat.c index 5d078371b5..a54cc65767 100644 --- a/sysdeps/unix/sysv/linux/faccessat.c +++ b/sysdeps/unix/sysv/linux/faccessat.c @@ -34,7 +34,7 @@ faccessat (int fd, const char *file, int mode, int flag) return ret; if (flag & ~(AT_SYMLINK_NOFOLLOW | AT_EACCESS)) - return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL); + return __syscall_error (-EINVAL); if ((flag == 0 || ((flag & ~AT_EACCESS) == 0 && ! __libc_enable_secure))) return INLINE_SYSCALL (faccessat, 3, fd, file, mode); @@ -70,6 +70,6 @@ faccessat (int fd, const char *file, int mode, int flag) if (granted == mode) return 0; - return INLINE_SYSCALL_ERROR_RETURN_VALUE (EACCES); + return __syscall_error (-EACCES); #endif /* !__ASSUME_FACCESSAT2 */ } diff --git a/sysdeps/unix/sysv/linux/fchmodat.c b/sysdeps/unix/sysv/linux/fchmodat.c index 5531f1aa6f..f1408b6f6a 100644 --- a/sysdeps/unix/sysv/linux/fchmodat.c +++ b/sysdeps/unix/sysv/linux/fchmodat.c @@ -31,7 +31,7 @@ fchmodat (int fd, const char *file, mode_t mode, int flag) if (flag == 0) return INLINE_SYSCALL (fchmodat, 3, fd, file, mode); else if (flag != AT_SYMLINK_NOFOLLOW) - return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL); + return __syscall_error (-EINVAL); else { /* The kernel system call does not have a mode argument. diff --git a/sysdeps/unix/sysv/linux/fcntl_nocancel.c b/sysdeps/unix/sysv/linux/fcntl_nocancel.c index a16fc75cb7..2e2ae72a9d 100644 --- a/sysdeps/unix/sysv/linux/fcntl_nocancel.c +++ b/sysdeps/unix/sysv/linux/fcntl_nocancel.c @@ -56,7 +56,7 @@ __fcntl64_nocancel_adjusted (int fd, int cmd, void *arg) if (!syscall_error (res)) return fex.type == F_OWNER_GID ? -fex.pid : fex.pid; - return INLINE_SYSCALL_ERROR_RETURN_VALUE (-res); + return __syscall_error (res); } return INLINE_SYSCALL_CALL (fcntl64, fd, cmd, (void *) arg); diff --git a/sysdeps/unix/sysv/linux/fstatat.c b/sysdeps/unix/sysv/linux/fstatat.c index 5ba1b99372..ba58232472 100644 --- a/sysdeps/unix/sysv/linux/fstatat.c +++ b/sysdeps/unix/sysv/linux/fstatat.c @@ -35,7 +35,7 @@ __fstatat (int fd, const char *file, struct stat *buf, int flag) if (r == 0 && (buf->__st_ino_pad != 0 || buf->__st_size_pad != 0 || buf->__st_blocks_pad != 0)) - return INLINE_SYSCALL_ERROR_RETURN_VALUE (EOVERFLOW); + return __syscall_error (-EOVERFLOW); # else # ifdef __NR_fstatat64 /* Old KABIs with old non-LFS support, e.g. arm, i386, hppa, m68k, mips32, @@ -47,7 +47,7 @@ __fstatat (int fd, const char *file, struct stat *buf, int flag) if (! in_ino_t_range (st64.st_ino) || ! in_off_t_range (st64.st_size) || ! in_blkcnt_t_range (st64.st_blocks)) - return INLINE_SYSCALL_ERROR_RETURN_VALUE (EOVERFLOW); + return __syscall_error (-EOVERFLOW); /* Clear internal pad and reserved fields. */ memset (buf, 0, sizeof (*buf)); diff --git a/sysdeps/unix/sysv/linux/fstatat64.c b/sysdeps/unix/sysv/linux/fstatat64.c index a788940390..831a5b8e54 100644 --- a/sysdeps/unix/sysv/linux/fstatat64.c +++ b/sysdeps/unix/sysv/linux/fstatat64.c @@ -47,7 +47,7 @@ __fstatat64_time64 (int fd, const char *file, struct __stat64_t64 *buf, return 0; } if (-r != ENOSYS) - return INLINE_SYSCALL_ERROR_RETURN_VALUE (-r); + return __syscall_error (r); #endif #if XSTAT_IS_XSTAT64 diff --git a/sysdeps/unix/sysv/linux/futimens.c b/sysdeps/unix/sysv/linux/futimens.c index 2c698b4e85..756a61a935 100644 --- a/sysdeps/unix/sysv/linux/futimens.c +++ b/sysdeps/unix/sysv/linux/futimens.c @@ -32,7 +32,7 @@ int __futimens64 (int fd, const struct __timespec64 tsp64[2]) { if (fd < 0) - return INLINE_SYSCALL_ERROR_RETURN_VALUE (EBADF); + return __syscall_error (-EBADF); return __utimensat64_helper (fd, NULL, &tsp64[0], 0); } diff --git a/sysdeps/unix/sysv/linux/fxstat.c b/sysdeps/unix/sysv/linux/fxstat.c index 649bb95252..fabf8e66f8 100644 --- a/sysdeps/unix/sysv/linux/fxstat.c +++ b/sysdeps/unix/sysv/linux/fxstat.c @@ -52,7 +52,7 @@ __fxstat (int vers, int fd, struct stat *buf) default: { # if STAT_IS_KERNEL_STAT - return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL); + return __syscall_error (-EINVAL); # else struct stat64 buf64; int r = INLINE_SYSCALL_CALL (fstat64, fd, &buf64); diff --git a/sysdeps/unix/sysv/linux/fxstat64.c b/sysdeps/unix/sysv/linux/fxstat64.c index 4bd926bf01..5a81f87e2a 100644 --- a/sysdeps/unix/sysv/linux/fxstat64.c +++ b/sysdeps/unix/sysv/linux/fxstat64.c @@ -50,7 +50,7 @@ ___fxstat64 (int vers, int fd, struct stat64 *buf) and x86_64. */ if (vers == _STAT_VER_KERNEL || vers == _STAT_VER_LINUX) return INLINE_SYSCALL_CALL (fstat, fd, buf); - return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL); + return __syscall_error (-EINVAL); # else /* New 32-bit kABIs with only 64-bit time_t support, e.g. arc, riscv32. */ struct statx tmp; diff --git a/sysdeps/unix/sysv/linux/fxstatat.c b/sysdeps/unix/sysv/linux/fxstatat.c index 2083e18eac..b3a1750e1b 100644 --- a/sysdeps/unix/sysv/linux/fxstatat.c +++ b/sysdeps/unix/sysv/linux/fxstatat.c @@ -41,7 +41,7 @@ __fxstatat (int vers, int fd, const char *file, struct stat *st, int flag) int r = INLINE_SYSCALL_CALL (fstatat64, fd, file, st, flag); return r ?: stat_overflow (st); } - return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL); + return __syscall_error (-EINVAL); #else /* Old kABIs with old non-LFS support, e.g. arm, i386, hppa, m68k, mips32, microblaze, s390, sh, powerpc32, and sparc32. */ diff --git a/sysdeps/unix/sysv/linux/fxstatat64.c b/sysdeps/unix/sysv/linux/fxstatat64.c index 8a505451d9..a0bdb137f1 100644 --- a/sysdeps/unix/sysv/linux/fxstatat64.c +++ b/sysdeps/unix/sysv/linux/fxstatat64.c @@ -63,7 +63,7 @@ __fxstatat64 (int vers, int fd, const char *file, struct stat64 *st, int flag) if (vers == _STAT_VER_LINUX) return INLINE_SYSCALL_CALL (fstatat64, fd, file, st, flag); #endif - return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL); + return __syscall_error (-EINVAL); } compat_symbol (libc, __fxstatat64, __fxstatat64, GLIBC_2_4); diff --git a/sysdeps/unix/sysv/linux/getdents.c b/sysdeps/unix/sysv/linux/getdents.c index a76be2e5e7..a5041e4ebb 100644 --- a/sysdeps/unix/sysv/linux/getdents.c +++ b/sysdeps/unix/sysv/linux/getdents.c @@ -98,7 +98,7 @@ __getdents (int fd, void *buf0, size_t nbytes) __lseek64 (fd, last_offset, SEEK_SET); return outp->b - buf; } - return INLINE_SYSCALL_ERROR_RETURN_VALUE (EOVERFLOW); + return __syscall_error (-EOVERFLOW); } last_offset = d_off; diff --git a/sysdeps/unix/sysv/linux/hppa/sysdep.c b/sysdeps/unix/sysv/linux/hppa/sysdep.c index 8f05bfc9c9..8c06b6fc80 100644 --- a/sysdeps/unix/sysv/linux/hppa/sysdep.c +++ b/sysdeps/unix/sysv/linux/hppa/sysdep.c @@ -15,8 +15,6 @@ License along with the GNU C Library. If not, see . */ -#include -#include #include /* This routine is jumped to by all the syscall handlers, to stash diff --git a/sysdeps/unix/sysv/linux/i386/brk.c b/sysdeps/unix/sysv/linux/i386/brk.c index 021b6d37a0..900fb0a031 100644 --- a/sysdeps/unix/sysv/linux/i386/brk.c +++ b/sysdeps/unix/sysv/linux/i386/brk.c @@ -39,7 +39,7 @@ __brk (void *addr) void *newbrk = (void *) INTERNAL_SYSCALL_CALL (brk, addr); __curbrk = newbrk; if (newbrk < addr) - return INLINE_SYSCALL_ERROR_RETURN_VALUE (ENOMEM); + return __syscall_error (-ENOMEM); return 0; } weak_alias (__brk, brk) diff --git a/sysdeps/unix/sysv/linux/i386/sysdep.c b/sysdeps/unix/sysv/linux/i386/sysdep.c index 0a9058d505..e6228406dd 100644 --- a/sysdeps/unix/sysv/linux/i386/sysdep.c +++ b/sysdeps/unix/sysv/linux/i386/sysdep.c @@ -16,7 +16,6 @@ . */ #include -#include /* This routine is jumped to by all the syscall handlers, to stash an error number into errno. ERROR is the negative error number diff --git a/sysdeps/unix/sysv/linux/i386/sysdep.h b/sysdeps/unix/sysv/linux/i386/sysdep.h index bfb5de3b45..4680013de4 100644 --- a/sysdeps/unix/sysv/linux/i386/sysdep.h +++ b/sysdeps/unix/sysv/linux/i386/sysdep.h @@ -236,9 +236,6 @@ #else /* !__ASSEMBLER__ */ -extern int __syscall_error (int) - attribute_hidden __attribute__ ((__regparm__ (1))); - #ifndef OPTIMIZE_FOR_GCC_5 /* We need some help from the assembler to generate optimal code. We define some macros here which later will be used. */ diff --git a/sysdeps/unix/sysv/linux/lxstat.c b/sysdeps/unix/sysv/linux/lxstat.c index 913618eab9..c86cfb349a 100644 --- a/sysdeps/unix/sysv/linux/lxstat.c +++ b/sysdeps/unix/sysv/linux/lxstat.c @@ -53,7 +53,7 @@ __lxstat (int vers, const char *name, struct stat *buf) default: { # if STAT_IS_KERNEL_STAT - return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL); + return __syscall_error (-EINVAL); # else struct stat64 buf64; int r = INLINE_SYSCALL_CALL (lstat64, name, &buf64); diff --git a/sysdeps/unix/sysv/linux/lxstat64.c b/sysdeps/unix/sysv/linux/lxstat64.c index 277b54b305..3e0fb8b25d 100644 --- a/sysdeps/unix/sysv/linux/lxstat64.c +++ b/sysdeps/unix/sysv/linux/lxstat64.c @@ -81,7 +81,7 @@ ___lxstat64 (int vers, const char *name, struct stat64 *buf) # endif /* STAT_IS_KERNEL_STAT */ #endif /* XSTAT_IS_XSTAT64 */ - return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL); + return __syscall_error (-EINVAL); } #if SHLIB_COMPAT(libc, GLIBC_2_1, GLIBC_2_2) diff --git a/sysdeps/unix/sysv/linux/mips/mips64/fxstatat64.c b/sysdeps/unix/sysv/linux/mips/mips64/fxstatat64.c index f40a2c5aa8..6bea711cd0 100644 --- a/sysdeps/unix/sysv/linux/mips/mips64/fxstatat64.c +++ b/sysdeps/unix/sysv/linux/mips/mips64/fxstatat64.c @@ -35,7 +35,7 @@ __fxstatat64 (int vers, int fd, const char *file, struct stat64 *st, int flag) int r = INLINE_SYSCALL_CALL (newfstatat, fd, file, &kst, flag);; return r ?: __xstat64_conv (vers, &kst, st); } - return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL); + return __syscall_error (-EINVAL); } compat_symbol (libc, __fxstatat64, __fxstatat64, GLIBC_2_4); diff --git a/sysdeps/unix/sysv/linux/mknodat.c b/sysdeps/unix/sysv/linux/mknodat.c index 279a4404f5..aa298483d5 100644 --- a/sysdeps/unix/sysv/linux/mknodat.c +++ b/sysdeps/unix/sysv/linux/mknodat.c @@ -28,7 +28,7 @@ __mknodat (int fd, const char *path, mode_t mode, dev_t dev) 32-bit. */ unsigned int k_dev = dev; if (k_dev != dev) - return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL); + return __syscall_error (-EINVAL); return INLINE_SYSCALL_CALL (mknodat, fd, path, mode, k_dev); } diff --git a/sysdeps/unix/sysv/linux/mmap.c b/sysdeps/unix/sysv/linux/mmap.c index 22f276bb14..9952625219 100644 --- a/sysdeps/unix/sysv/linux/mmap.c +++ b/sysdeps/unix/sysv/linux/mmap.c @@ -36,7 +36,7 @@ __mmap (void *addr, size_t len, int prot, int flags, int fd, off_t offset) MMAP_CHECK_PAGE_UNIT (); if (offset & MMAP_OFF_LOW_MASK) - return (void *) INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL); + return (void *) __syscall_error (-EINVAL); #ifdef __NR_mmap2 return (void *) MMAP_CALL (mmap2, addr, len, prot, flags, fd, diff --git a/sysdeps/unix/sysv/linux/mmap64.c b/sysdeps/unix/sysv/linux/mmap64.c index 8074deb466..0eed429e48 100644 --- a/sysdeps/unix/sysv/linux/mmap64.c +++ b/sysdeps/unix/sysv/linux/mmap64.c @@ -49,7 +49,7 @@ __mmap64 (void *addr, size_t len, int prot, int flags, int fd, off64_t offset) MMAP_CHECK_PAGE_UNIT (); if (offset & MMAP_OFF_MASK) - return (void *) INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL); + return (void *) __syscall_error (-EINVAL); MMAP_PREPARE (addr, len, prot, flags, fd, offset); #ifdef __NR_mmap2 diff --git a/sysdeps/unix/sysv/linux/mq_open.c b/sysdeps/unix/sysv/linux/mq_open.c index c88dc580e4..542f9b7097 100644 --- a/sysdeps/unix/sysv/linux/mq_open.c +++ b/sysdeps/unix/sysv/linux/mq_open.c @@ -33,7 +33,7 @@ mqd_t __mq_open (const char *name, int oflag, ...) { if (name[0] != '/') - return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL); + return __syscall_error (-EINVAL); mode_t mode = 0; struct mq_attr *attr = NULL; diff --git a/sysdeps/unix/sysv/linux/mq_unlink.c b/sysdeps/unix/sysv/linux/mq_unlink.c index 701bc86438..741c4e5776 100644 --- a/sysdeps/unix/sysv/linux/mq_unlink.c +++ b/sysdeps/unix/sysv/linux/mq_unlink.c @@ -24,7 +24,7 @@ int mq_unlink (const char *name) { if (name[0] != '/') - return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL); + return __syscall_error (-EINVAL); int ret = INTERNAL_SYSCALL_CALL (mq_unlink, name + 1); diff --git a/sysdeps/unix/sysv/linux/powerpc/sysdep.c b/sysdeps/unix/sysv/linux/powerpc/sysdep.c index 37f0f1f53e..1bf5ea6f62 100644 --- a/sysdeps/unix/sysv/linux/powerpc/sysdep.c +++ b/sysdeps/unix/sysv/linux/powerpc/sysdep.c @@ -15,7 +15,6 @@ License along with the GNU C Library; if not, see . */ -#include #include /* This routine is jumped to by all the syscall handlers, to stash diff --git a/sysdeps/unix/sysv/linux/prlimit.c b/sysdeps/unix/sysv/linux/prlimit.c index e12eb4e9bc..0a8e6a519e 100644 --- a/sysdeps/unix/sysv/linux/prlimit.c +++ b/sysdeps/unix/sysv/linux/prlimit.c @@ -58,7 +58,7 @@ prlimit (__pid_t pid, enum __rlimit_resource resource, { if ((new_rlimit == NULL) && (old_rlimit64_mem.rlim_cur != RLIM64_INFINITY)) - return INLINE_SYSCALL_ERROR_RETURN_VALUE (EOVERFLOW); + return __syscall_error (-EOVERFLOW); old_rlimit->rlim_cur = RLIM_INFINITY; } old_rlimit->rlim_max = old_rlimit64_mem.rlim_max; @@ -66,7 +66,7 @@ prlimit (__pid_t pid, enum __rlimit_resource resource, { if ((new_rlimit == NULL) && (old_rlimit64_mem.rlim_max != RLIM64_INFINITY)) - return INLINE_SYSCALL_ERROR_RETURN_VALUE (EOVERFLOW); + return __syscall_error (-EOVERFLOW); old_rlimit->rlim_max = RLIM_INFINITY; } } diff --git a/sysdeps/unix/sysv/linux/setegid.c b/sysdeps/unix/sysv/linux/setegid.c index ce8bead278..ea135b9084 100644 --- a/sysdeps/unix/sysv/linux/setegid.c +++ b/sysdeps/unix/sysv/linux/setegid.c @@ -26,7 +26,7 @@ setegid (gid_t gid) int result; if (gid == (gid_t) ~0) - return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL); + return __syscall_error (-EINVAL); #ifdef __NR_setresgid32 result = INLINE_SETXID_SYSCALL (setresgid32, 3, -1, gid, -1); diff --git a/sysdeps/unix/sysv/linux/seteuid.c b/sysdeps/unix/sysv/linux/seteuid.c index 4519ac2db6..5259adee85 100644 --- a/sysdeps/unix/sysv/linux/seteuid.c +++ b/sysdeps/unix/sysv/linux/seteuid.c @@ -26,7 +26,7 @@ seteuid (uid_t uid) int result; if (uid == (uid_t) ~0) - return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL); + return __syscall_error (-EINVAL); #ifdef __NR_setresuid32 result = INLINE_SETXID_SYSCALL (setresuid32, 3, -1, uid, -1); diff --git a/sysdeps/unix/sysv/linux/shmat.c b/sysdeps/unix/sysv/linux/shmat.c index 98291fe972..3a1f483f09 100644 --- a/sysdeps/unix/sysv/linux/shmat.c +++ b/sysdeps/unix/sysv/linux/shmat.c @@ -36,7 +36,7 @@ shmat (int shmid, const void *shmaddr, int shmflg) resultvar = INTERNAL_SYSCALL_CALL (ipc, IPCOP_shmat, shmid, shmflg, &raddr, shmaddr); if (syscall_error (resultvar)) - return (void *) INLINE_SYSCALL_ERROR_RETURN_VALUE (-resultvar); + return (void *) __syscall_error (resultvar); return raddr; #endif diff --git a/sysdeps/unix/sysv/linux/speed.c b/sysdeps/unix/sysv/linux/speed.c index d7d74ddb67..9df2f250c6 100644 --- a/sysdeps/unix/sysv/linux/speed.c +++ b/sysdeps/unix/sysv/linux/speed.c @@ -56,7 +56,7 @@ cfsetospeed (struct termios *termios_p, speed_t speed) { if ((speed & ~CBAUD) != 0 && (speed < B57600 || speed > __MAX_BAUD)) - return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL); + return __syscall_error (-EINVAL); #if _HAVE_STRUCT_TERMIOS_C_OSPEED termios_p->c_ospeed = speed; @@ -78,7 +78,7 @@ cfsetispeed (struct termios *termios_p, speed_t speed) { if ((speed & ~CBAUD) != 0 && (speed < B57600 || speed > __MAX_BAUD)) - return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL); + return __syscall_error (-EINVAL); #if _HAVE_STRUCT_TERMIOS_C_ISPEED termios_p->c_ispeed = speed; diff --git a/sysdeps/unix/sysv/linux/syscall_error.c b/sysdeps/unix/sysv/linux/syscall_error.c new file mode 100644 index 0000000000..e7818a36da --- /dev/null +++ b/sysdeps/unix/sysv/linux/syscall_error.c @@ -0,0 +1,30 @@ +/* Linux wrappers for setting errno. + Copyright (C) 2020 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include + +#ifdef SYSCALL_ERROR_FUNC +long int +SYSCALL_ERROR_FUNC_ATTR +__syscall_error (long int error) +{ + __set_errno (-error); + return -1L; +} +#endif diff --git a/sysdeps/unix/sysv/linux/sysdep.h b/sysdeps/unix/sysv/linux/sysdep.h index 66bac892a5..6c0d1f9f6f 100644 --- a/sysdeps/unix/sysv/linux/sysdep.h +++ b/sysdeps/unix/sysv/linux/sysdep.h @@ -30,14 +30,34 @@ syscall_error (unsigned long int val) return val > -4096UL; } +/* The errno setting might be set either inline or with a helper function. + For some ABIs (x86_64 for instance), handling it inline might generate + less code; while for others (i686) a function call is preferable. + + To use the helper function the ABI must define SYSCALL_ERROR_FUNC, it will + build a hidden function on each shared object that issue direct syscall + with {INLINE,INTERNAL}_SYSCALL_CALL. */ + +#ifdef SYSCALL_ERROR_FUNC +# ifndef SYSCALL_ERROR_FUNC_ATTR +# define SYSCALL_ERROR_FUNC_ATTR +# endif +long int __syscall_error (long int err) attribute_hidden + SYSCALL_ERROR_FUNC_ATTR; +#else +static inline long int +__syscall_error (long int err) +{ + __set_errno (-err); + return -1L; +} +#endif + static inline long int syscall_ret (unsigned long int val) { if (syscall_error (val)) - { - __set_errno (-val); - return -1; - } + return __syscall_error (val); return val; } @@ -49,15 +69,6 @@ syscall_ret (unsigned long int val) syscall_ret (INTERNAL_SYSCALL (__VA_ARGS__)) #endif -/* Set error number and return -1. A target may choose to return the - internal function, __syscall_error, which sets errno and returns -1. - We use -1l, instead of -1, so that it can be casted to (void *). */ -#define INLINE_SYSCALL_ERROR_RETURN_VALUE(err) \ - ({ \ - __set_errno (err); \ - -1l; \ - }) - /* Provide a dummy argument that can be used to force register alignment for register pairs if required by the syscall ABI. */ #ifdef __ASSUME_ALIGNED_REGISTER_PAIRS diff --git a/sysdeps/unix/sysv/linux/tcsendbrk.c b/sysdeps/unix/sysv/linux/tcsendbrk.c index 5d81d86bb2..d77acd064d 100644 --- a/sysdeps/unix/sysv/linux/tcsendbrk.c +++ b/sysdeps/unix/sysv/linux/tcsendbrk.c @@ -39,6 +39,6 @@ tcsendbreak (int fd, int duration) /* ioctl can't send a break of any other duration for us. This could be changed to use trickery (e.g. lower speed and send a '\0') to send the break, but for now just return an error. */ - return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL); + return __syscall_error (-EINVAL); #endif } diff --git a/sysdeps/unix/sysv/linux/tcsetattr.c b/sysdeps/unix/sysv/linux/tcsetattr.c index 50b2b0af8a..978e182e17 100644 --- a/sysdeps/unix/sysv/linux/tcsetattr.c +++ b/sysdeps/unix/sysv/linux/tcsetattr.c @@ -58,7 +58,7 @@ __tcsetattr (int fd, int optional_actions, const struct termios *termios_p) cmd = TCSETSF; break; default: - return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL); + return __syscall_error (-EINVAL); } k_termios.c_iflag = termios_p->c_iflag & ~IBAUD0; diff --git a/sysdeps/unix/sysv/linux/ustat.c b/sysdeps/unix/sysv/linux/ustat.c index e38b792705..1df6f28794 100644 --- a/sysdeps/unix/sysv/linux/ustat.c +++ b/sysdeps/unix/sysv/linux/ustat.c @@ -31,7 +31,7 @@ unsigned long long int k_dev; \ k_dev = dev & ((1ULL << 32) - 1); \ if (k_dev != dev) \ - return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL); \ + return __syscall_error (-EINVAL); \ (unsigned int) k_dev; \ }) # endif @@ -50,7 +50,7 @@ __old_ustat (dev_t dev, struct ustat *ubuf) # ifdef __NR_ustat return INLINE_SYSCALL_CALL (ustat, DEV_TO_KDEV (dev), ubuf); # else - return INLINE_SYSCALL_ERROR_RETURN_VALUE (ENOSYS); + return __syscall_error (-ENOSYS); # endif } compat_symbol (libc, __old_ustat, ustat, GLIBC_2_0); diff --git a/sysdeps/unix/sysv/linux/utimensat.c b/sysdeps/unix/sysv/linux/utimensat.c index aef34916e8..15a40a6174 100644 --- a/sysdeps/unix/sysv/linux/utimensat.c +++ b/sysdeps/unix/sysv/linux/utimensat.c @@ -71,7 +71,7 @@ __utimensat64 (int fd, const char *file, const struct __timespec64 tsp64[2], int flags) { if (file == NULL) - return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL); + return __syscall_error (-EINVAL); return __utimensat64_helper (fd, file, &tsp64[0], flags); } diff --git a/sysdeps/unix/sysv/linux/xmknod.c b/sysdeps/unix/sysv/linux/xmknod.c index 10e874a514..c3b31f9c97 100644 --- a/sysdeps/unix/sysv/linux/xmknod.c +++ b/sysdeps/unix/sysv/linux/xmknod.c @@ -31,7 +31,7 @@ attribute_compat_text_section __xmknod (int vers, const char *path, mode_t mode, dev_t *dev) { if (vers != _MKNOD_VER) - return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL); + return __syscall_error (-EINVAL); return __mknodat (AT_FDCWD, path, mode, *dev); } diff --git a/sysdeps/unix/sysv/linux/xmknodat.c b/sysdeps/unix/sysv/linux/xmknodat.c index 17ffea16c9..9b2bdd872f 100644 --- a/sysdeps/unix/sysv/linux/xmknodat.c +++ b/sysdeps/unix/sysv/linux/xmknodat.c @@ -28,7 +28,7 @@ int __xmknodat (int vers, int fd, const char *file, mode_t mode, dev_t *dev) { if (vers != _MKNOD_VER) - return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL); + return __syscall_error (-EINVAL); return __mknodat (fd, file, mode, *dev); } diff --git a/sysdeps/unix/sysv/linux/xstat.c b/sysdeps/unix/sysv/linux/xstat.c index 3eb2d8c51b..1394d6235c 100644 --- a/sysdeps/unix/sysv/linux/xstat.c +++ b/sysdeps/unix/sysv/linux/xstat.c @@ -52,7 +52,7 @@ __xstat (int vers, const char *name, struct stat *buf) default: { # if STAT_IS_KERNEL_STAT - return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL); + return __syscall_error (-EINVAL); # else struct stat64 buf64; int r = INLINE_SYSCALL_CALL (stat64, name, &buf64); diff --git a/sysdeps/unix/sysv/linux/xstat64.c b/sysdeps/unix/sysv/linux/xstat64.c index dd4f808c7a..06579c9d63 100644 --- a/sysdeps/unix/sysv/linux/xstat64.c +++ b/sysdeps/unix/sysv/linux/xstat64.c @@ -78,7 +78,7 @@ ___xstat64 (int vers, const char *name, struct stat64 *buf) # endif /* STAT_IS_KERNEL_STAT */ #endif /* XSTAT_IS_XSTAT64 */ - return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL); + return __syscall_error (-EINVAL); } #if XSTAT_IS_XSTAT64 diff --git a/sysdeps/unix/sysv/linux/xstatconv.c b/sysdeps/unix/sysv/linux/xstatconv.c index b100e07783..552e762fda 100644 --- a/sysdeps/unix/sysv/linux/xstatconv.c +++ b/sysdeps/unix/sysv/linux/xstatconv.c @@ -96,7 +96,7 @@ __xstat_conv (int vers, struct kernel_stat *kbuf, void *ubuf) break; default: - return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL); + return __syscall_error (-EINVAL); } return 0; @@ -169,7 +169,7 @@ __xstat64_conv (int vers, struct kernel_stat *kbuf, void *ubuf) _STAT_VER_KERNEL does not make sense. */ case _STAT_VER_KERNEL: default: - return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL); + return __syscall_error (-EINVAL); } return 0; @@ -192,7 +192,7 @@ __xstat32_conv (int vers, struct stat64 *kbuf, struct stat *buf) buf->st_ino = kbuf->st_ino; if (sizeof (buf->st_ino) != sizeof (kbuf->st_ino) && buf->st_ino != kbuf->st_ino) - return INLINE_SYSCALL_ERROR_RETURN_VALUE (EOVERFLOW); + return __syscall_error (-EOVERFLOW); buf->st_mode = kbuf->st_mode; buf->st_nlink = kbuf->st_nlink; buf->st_uid = kbuf->st_uid; @@ -205,13 +205,13 @@ __xstat32_conv (int vers, struct stat64 *kbuf, struct stat *buf) /* Check for overflow. */ if (sizeof (buf->st_size) != sizeof (kbuf->st_size) && buf->st_size != kbuf->st_size) - return INLINE_SYSCALL_ERROR_RETURN_VALUE (EOVERFLOW); + return __syscall_error (-EOVERFLOW); buf->st_blksize = kbuf->st_blksize; buf->st_blocks = kbuf->st_blocks; /* Check for overflow. */ if (sizeof (buf->st_blocks) != sizeof (kbuf->st_blocks) && buf->st_blocks != kbuf->st_blocks) - return INLINE_SYSCALL_ERROR_RETURN_VALUE (EOVERFLOW); + return __syscall_error (-EOVERFLOW); #ifdef _HAVE_STAT_NSEC buf->st_atim.tv_sec = kbuf->st_atim.tv_sec; buf->st_atim.tv_nsec = kbuf->st_atim.tv_nsec; @@ -247,7 +247,7 @@ __xstat32_conv (int vers, struct stat64 *kbuf, struct stat *buf) _STAT_VER_KERNEL does not make sense. */ case _STAT_VER_KERNEL: default: - return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL); + return __syscall_error (-EINVAL); } return 0; From patchwork Mon Nov 9 20:18:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 40985 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 744B23973030; Mon, 9 Nov 2020 20:18:46 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 744B23973030 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1604953126; bh=kMdryxSuQJM0J4lvN3hdlZemkM7r49fx48/fVwUi228=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=bk05xLLeUMLS4vP/lH86enNuO+L+4DQpeg66Cyq+99De+NvicDl0tFtT/px7TipLv fZ10oLpF2a/sp28jIykQyhVDBeTKG1cVT7va6r7BVN/ColrRHDlj+OA+jXIVzNV4EN tGXHgp6+BR0RK2+UJTD4NoGd8kjX4XMTBNfrqfGc= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-qt1-x841.google.com (mail-qt1-x841.google.com [IPv6:2607:f8b0:4864:20::841]) by sourceware.org (Postfix) with ESMTPS id 4B90739724AB for ; Mon, 9 Nov 2020 20:18:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 4B90739724AB Received: by mail-qt1-x841.google.com with SMTP id i7so6963576qti.6 for ; Mon, 09 Nov 2020 12:18:44 -0800 (PST) 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:mime-version:content-transfer-encoding; bh=kMdryxSuQJM0J4lvN3hdlZemkM7r49fx48/fVwUi228=; b=C0uxekN1uSamIOCNSi3FYhw36BK1urZ0i1A1gMNS0lIVN441LZLXCx68Wnjr8CS7Gv T5Gnzhg8ElQKVFKAfm5cSVbUDYKpk6hY2KvL2AN3uX4unhLwBipfBZvAmdjCI4/QUYxT DwYWBhyGe1XX14qBB3rypwvmjnfh0nIHI/CTENZg4YnumnuxTxQ0cN37xjiu2DA2kp5Z Hbvrl8tibDo0o+Qkq8RKnbd6KnfX6QRc5Hybta0Tt1KRceej5ePOyDcz4/fHrCWDCQGI 6tPiU9WTrqXeN9QlH8Wx4mZu2f+PEs5zzH1K7ZS/rnpJUZVdHuVPcxcrJxjXiVSeUgIG qJJw== X-Gm-Message-State: AOAM532wPR7+xR8sA16qGQ+eBoPnIhi6ORnslbrjEmmDYt+j2zXKkElf cvYaIx9euCvPiZ7YgcAeQuaMc49g5/j+iw== X-Google-Smtp-Source: ABdhPJy5JA0vb3sXioZQgm84kZYcjxa3+/Qk2/qd5EqKNCXL+Zdc2By/B28Fs5Q9XqlL6i2VelP76g== X-Received: by 2002:ac8:7445:: with SMTP id h5mr14061839qtr.334.1604953123688; Mon, 09 Nov 2020 12:18:43 -0800 (PST) Received: from localhost.localdomain ([177.194.48.209]) by smtp.googlemail.com with ESMTPSA id z2sm6843407qkl.22.2020.11.09.12.18.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Nov 2020 12:18:43 -0800 (PST) To: libc-alpha@sourceware.org Subject: [PATCH 06/23] linux: Use generic __syscall_error for aarch64 Date: Mon, 9 Nov 2020 17:18:09 -0300 Message-Id: <20201109201826.120534-7-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201109201826.120534-1-adhemerval.zanella@linaro.org> References: <20201109201826.120534-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-13.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_NUMSUBJECT, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, URIBL_BLACK autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Adhemerval Zanella via Libc-alpha From: Adhemerval Zanella Netto Reply-To: Adhemerval Zanella Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" The auto-generated syscalls calls the __syscall_error, although setting using inline function generates slight less code: --- sizes-aarch64-linux-gnu.outline +++ sizes-aarch64-linux-gnu.inline text data bss dec hex filename 1388874 19096 14520 1422490 15b49a libc.so - 138509 7136 344 145989 23a45 elf/ld.so - 98439 1636 16656 116731 1c7fb nptl/libpthread.so - 23942 1236 248 25426 6352 rt/librt.so + 138449 7136 344 145929 23a09 elf/ld.so + 98567 1636 16656 116859 1c87b nptl/libpthread.so + 23918 1236 248 25402 633a rt/librt.so Checked on aarch64-linux-gnu. --- sysdeps/unix/sysv/linux/aarch64/sysdep.c | 32 ------------------------ sysdeps/unix/sysv/linux/aarch64/sysdep.h | 2 ++ 2 files changed, 2 insertions(+), 32 deletions(-) delete mode 100644 sysdeps/unix/sysv/linux/aarch64/sysdep.c diff --git a/sysdeps/unix/sysv/linux/aarch64/sysdep.c b/sysdeps/unix/sysv/linux/aarch64/sysdep.c deleted file mode 100644 index 6b88f3484f..0000000000 --- a/sysdeps/unix/sysv/linux/aarch64/sysdep.c +++ /dev/null @@ -1,32 +0,0 @@ -/* Copyright (C) 2011-2020 Free Software Foundation, Inc. - - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library. If not, see - . */ - -#include - -long __syscall_error (long err); -hidden_proto (__syscall_error) - -/* This routine is jumped to by all the syscall handlers, to stash - an error number into errno. */ -long -__syscall_error (long err) -{ - __set_errno (- err); - return -1; -} -hidden_def (__syscall_error) diff --git a/sysdeps/unix/sysv/linux/aarch64/sysdep.h b/sysdeps/unix/sysv/linux/aarch64/sysdep.h index 319a7c7ac5..e1cda79449 100644 --- a/sysdeps/unix/sysv/linux/aarch64/sysdep.h +++ b/sysdeps/unix/sysv/linux/aarch64/sysdep.h @@ -19,6 +19,8 @@ #ifndef _LINUX_AARCH64_SYSDEP_H #define _LINUX_AARCH64_SYSDEP_H 1 +#define SYSCALL_ERROR_FUNC + #include #include #include From patchwork Mon Nov 9 20:18:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 40986 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 4CD3B397280B; Mon, 9 Nov 2020 20:18:48 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4CD3B397280B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1604953128; bh=N28nCWgD7hZNuYhY9dw+EmsJ9hSktJ3CliMvRNs2LMw=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=pwC5sesVey1bPwkOYhW4FS+qul5uL0jImYTRXy8Ajd5rZphWLGMtlBSId6QNs5t8o i/p64f9+4AkT7YicvIcZRSwEzGmd2wlAMstALagPtv1sUHjPBpO8hmedKU+zB3npfi myZjcTVLsWbHeZnXG/Qfu8L4VVdatC2CX9Mh31bs= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-qt1-x841.google.com (mail-qt1-x841.google.com [IPv6:2607:f8b0:4864:20::841]) by sourceware.org (Postfix) with ESMTPS id B3AB739724AB for ; Mon, 9 Nov 2020 20:18:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org B3AB739724AB Received: by mail-qt1-x841.google.com with SMTP id j31so6951811qtb.8 for ; Mon, 09 Nov 2020 12:18:45 -0800 (PST) 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:mime-version:content-transfer-encoding; bh=N28nCWgD7hZNuYhY9dw+EmsJ9hSktJ3CliMvRNs2LMw=; b=ZEXJd6B97m5ayss0HimuZkqpkpPez3jD+w3JhHTXUQ3cNnWrdhQ39uaJsr3LrOLT4S R6MGe1lkaHcLM5VbcFp+a9tGp4j9RwVr6EyLovA/GDc3pSAoEaMmidXv0CBme7g+CtBP eBd3WSJAXSSN8ps/2zgARc/CLCvcKxPvdU/JmRb/HUjSoEr46CZfyi4He6NbThxBj8gl QR0AzARADeQMQvNX40nwgGAVR2xOUNMNNpX5jSGYFo137etb99EUXKWTSFBosceg1hGM 7Zw7iLvsjWqYD4Y3hEXCjjfhwHuK+aXB0plP52H/9YuT/pR8CGw9yLoLCWwAa1j1K0J+ 5d9A== X-Gm-Message-State: AOAM533KVX+ZmtL9q9FnB2Xqz6kxm8JwoxtIKqBXV5x04myA/7VkdoPH BVjXzebQd3sHCq1Zj2iM1Igl7VFntTJNvA== X-Google-Smtp-Source: ABdhPJyV+eA8krKvtwADjNF2APX4VqQQciV/s1eof9/7LamjE4SITTuTPOSPZs0UDDPhEg+eJni0Kg== X-Received: by 2002:ac8:5653:: with SMTP id 19mr10876460qtt.136.1604953125058; Mon, 09 Nov 2020 12:18:45 -0800 (PST) Received: from localhost.localdomain ([177.194.48.209]) by smtp.googlemail.com with ESMTPSA id z2sm6843407qkl.22.2020.11.09.12.18.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Nov 2020 12:18:44 -0800 (PST) To: libc-alpha@sourceware.org Subject: [PATCH 07/23] linux: Use generic __syscall_error for i386 Date: Mon, 9 Nov 2020 17:18:10 -0300 Message-Id: <20201109201826.120534-8-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201109201826.120534-1-adhemerval.zanella@linaro.org> References: <20201109201826.120534-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-13.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_NUMSUBJECT, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, URIBL_BLACK autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Adhemerval Zanella via Libc-alpha From: Adhemerval Zanella Netto Reply-To: Adhemerval Zanella Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" The auto-generated syscalls calls the __syscall_error, and for i686 it results in much less compat code: --- sizes-i686-linux-gnu.outline +++ sizes-i686-linux-gnu.inline text data bss dec hex filename -1933727 11324 10172 1955223 1dd597 libc.so - 175366 4768 184 180318 2c05e elf/ld.so - 109851 832 8408 119091 1d133 nptl/libpthread.so - 27983 628 184 28795 707b rt/librt.so +1937875 11324 10172 1959371 1de5cb libc.so + 175790 4768 184 180742 2c206 elf/ld.so + 110179 832 8408 119419 1d27b nptl/libpthread.so + 28139 628 184 28951 7117 rt/librt.so This patch enabled SYSCALL_ERROR_FUNC with the expected abi by also defining SYSCALL_ERROR_FUNC_ATTR. Checked on i686-linux-gnu. --- sysdeps/unix/sysv/linux/i386/Makefile | 13 ------------ sysdeps/unix/sysv/linux/i386/sysdep.c | 29 --------------------------- sysdeps/unix/sysv/linux/i386/sysdep.h | 3 +++ 3 files changed, 3 insertions(+), 42 deletions(-) delete mode 100644 sysdeps/unix/sysv/linux/i386/sysdep.c diff --git a/sysdeps/unix/sysv/linux/i386/Makefile b/sysdeps/unix/sysv/linux/i386/Makefile index da716e2c1b..983b02e081 100644 --- a/sysdeps/unix/sysv/linux/i386/Makefile +++ b/sysdeps/unix/sysv/linux/i386/Makefile @@ -28,22 +28,9 @@ gen-as-const-headers += ucontext_i.sym endif ifeq ($(subdir),csu) -sysdep-dl-routines += sysdep ifeq (yes,$(build-shared)) sysdep_routines += divdi3 shared-only-routines += divdi3 CPPFLAGS-divdi3.c = -Din_divdi3_c endif endif - -ifeq ($(subdir),nptl) -# pull in __syscall_error routine -libpthread-routines += sysdep -libpthread-shared-only-routines += sysdep -endif - -ifeq ($(subdir),rt) -# pull in __syscall_error routine -librt-routines += sysdep -librt-shared-only-routines += sysdep -endif diff --git a/sysdeps/unix/sysv/linux/i386/sysdep.c b/sysdeps/unix/sysv/linux/i386/sysdep.c deleted file mode 100644 index e6228406dd..0000000000 --- a/sysdeps/unix/sysv/linux/i386/sysdep.c +++ /dev/null @@ -1,29 +0,0 @@ -/* Copyright (C) 2015-2020 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - . */ - -#include - -/* This routine is jumped to by all the syscall handlers, to stash - an error number into errno. ERROR is the negative error number - returned from the x86 kernel. */ -int -__attribute__ ((__regparm__ (1))) -__syscall_error (int error) -{ - __set_errno (-error); - return -1; -} diff --git a/sysdeps/unix/sysv/linux/i386/sysdep.h b/sysdeps/unix/sysv/linux/i386/sysdep.h index 4680013de4..977dc1ab42 100644 --- a/sysdeps/unix/sysv/linux/i386/sysdep.h +++ b/sysdeps/unix/sysv/linux/i386/sysdep.h @@ -19,6 +19,9 @@ #ifndef _LINUX_I386_SYSDEP_H #define _LINUX_I386_SYSDEP_H 1 +#define SYSCALL_ERROR_FUNC +#define SYSCALL_ERROR_FUNC_ATTR __attribute__ ((__regparm__ (1))) + /* There is some commonality. */ #include #include From patchwork Mon Nov 9 20:18:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 40988 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 63CD93973056; Mon, 9 Nov 2020 20:18:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 63CD93973056 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1604953129; bh=++HMeDOAkSjxgUePLEy5rvM6XJSAqf0j2oVe+EF/HOI=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=kMyqo6eQ+6/CaRgCLpZyYMyLQXSOQVKkQeWL9iThMrNB7mM2edSJEcTvoLN0gxCtP TMXbaRxKXny5ujiqz4mpJVmUpa/Cy5dy9lob0l02oBL1MICMq6pssR8aERXiphPzrJ KdqoClD3UbhxelqxP7cOhq2+rmrVBHYr/rD5MNoU= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-qt1-x844.google.com (mail-qt1-x844.google.com [IPv6:2607:f8b0:4864:20::844]) by sourceware.org (Postfix) with ESMTPS id 57BC73973008 for ; Mon, 9 Nov 2020 20:18:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 57BC73973008 Received: by mail-qt1-x844.google.com with SMTP id n63so6971236qte.4 for ; Mon, 09 Nov 2020 12:18:47 -0800 (PST) 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:mime-version:content-transfer-encoding; bh=++HMeDOAkSjxgUePLEy5rvM6XJSAqf0j2oVe+EF/HOI=; b=UE6zsqwAH+yIFuqMY95SFZEGRykVmxFtlcKGM+vMPRRidpxNFrsSsljRRr0GYfkXKW HdCdZIgn7dNYcxDatqkO4fyPOFupX91Pq2W26N0zjTEt1/2Oc0reuH3wxSOoZd1GelFL SSYQv8k19vOwwtvuObpb5IaD2gj9zA4EKxZemZ301yG33iJ/wXZTI7GzrtYoOd/7b5DJ ScblNALOtJyj64iMgXRZRdPPfLT0JSkCToZ9Mc1LyZHsXSYS31bYNUNvwwoNgXzsRKIJ i+spe8XBBnaNGGrq0PP6QDLZ6qOLf1nGc6++3IkFXVo1kT6qGT8DqnW4pPI1NtkkrzHh urIQ== X-Gm-Message-State: AOAM531EWTyYL6ULa5ctvQqhgGXsI74cTYCrkynNXa0pJYA+18r4uyWU YXcWd3gJjIw3gJR+pGjUVZsOgsiU0p3XQQ== X-Google-Smtp-Source: ABdhPJyppIeVBM1YHTx9c5dwaXuXNjelZjL1FpTz5J7dnLPhKqMnqz1j/WI3sUKFT6mgZDQ8osoW9Q== X-Received: by 2002:ac8:3890:: with SMTP id f16mr15066841qtc.372.1604953126676; Mon, 09 Nov 2020 12:18:46 -0800 (PST) Received: from localhost.localdomain ([177.194.48.209]) by smtp.googlemail.com with ESMTPSA id z2sm6843407qkl.22.2020.11.09.12.18.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Nov 2020 12:18:45 -0800 (PST) To: libc-alpha@sourceware.org Subject: [PATCH 08/23] linux: Use generic __syscall_error for arc Date: Mon, 9 Nov 2020 17:18:11 -0300 Message-Id: <20201109201826.120534-9-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201109201826.120534-1-adhemerval.zanella@linaro.org> References: <20201109201826.120534-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-13.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, URIBL_BLACK autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Adhemerval Zanella via Libc-alpha From: Adhemerval Zanella Netto Reply-To: Adhemerval Zanella Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" Moving to intra DSO calls generates slight better code and avoid a GLIBC_PRIVATE symbol (only librt increases because it issues syscalls only in specific places). --- sizes-arc-linux-gnuhf.before +++ sizes-arc-linux-gnuhf.after text data bss dec hex filename - 962196 9400 8116 979712 ef300 libc.so - 110145 3724 192 114061 1bd8d elf/ld.so - 75099 796 8348 84243 14913 nptl/libpthread.so - 18882 600 156 19638 4cb6 rt/librt.so + 961186 9400 8116 978702 eef0e libc.so + 109745 3724 192 113661 1bbfd elf/ld.so + 75463 796 8348 84607 14a7f nptl/libpthread.so + 18704 596 156 19456 4c00 rt/librt.so Checked with build for arc-linux-gnuabihf. --- sysdeps/arc/Versions | 3 --- sysdeps/unix/sysv/linux/arc/sysdep.c | 33 ---------------------------- sysdeps/unix/sysv/linux/arc/sysdep.h | 14 +++--------- 3 files changed, 3 insertions(+), 47 deletions(-) delete mode 100644 sysdeps/unix/sysv/linux/arc/sysdep.c diff --git a/sysdeps/arc/Versions b/sysdeps/arc/Versions index 6ac7b8e495..ff157421a5 100644 --- a/sysdeps/arc/Versions +++ b/sysdeps/arc/Versions @@ -2,7 +2,4 @@ libc { GLIBC_2.32 { __mcount; } - GLIBC_PRIVATE { - __syscall_error; - } } diff --git a/sysdeps/unix/sysv/linux/arc/sysdep.c b/sysdeps/unix/sysv/linux/arc/sysdep.c deleted file mode 100644 index fe904d723b..0000000000 --- a/sysdeps/unix/sysv/linux/arc/sysdep.c +++ /dev/null @@ -1,33 +0,0 @@ -/* ARC wrapper for setting errno. - Copyright (C) 2020 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - . */ - -#include - -extern long int __syscall_error (long int); -libc_hidden_proto (__syscall_error) - -/* All syscall handlers land here to avoid generated code bloat due to - GOT reference to errno_location or it's equivalent. */ -long int -__syscall_error (long int err_no) -{ - __set_errno (-err_no); - return -1; -} - -libc_hidden_def (__syscall_error) diff --git a/sysdeps/unix/sysv/linux/arc/sysdep.h b/sysdeps/unix/sysv/linux/arc/sysdep.h index 4ab44f6925..9e43399f1e 100644 --- a/sysdeps/unix/sysv/linux/arc/sysdep.h +++ b/sysdeps/unix/sysv/linux/arc/sysdep.h @@ -19,6 +19,8 @@ #ifndef _LINUX_ARC_SYSDEP_H #define _LINUX_ARC_SYSDEP_H 1 +#define SYSCALL_ERROR_FUNC + #include #include @@ -103,22 +105,12 @@ # define PSEUDO_END_ERRVAL(name) \ END (name) - -/* To reduce the code footprint, we confine the actual errno access - to single place in __syscall_error(). - This takes raw kernel error value, sets errno and returns -1. */ -# if IS_IN (libc) -# define CALL_ERRNO_SETTER_C bl PLTJMP(HIDDEN_JUMPTARGET(__syscall_error)) -# else -# define CALL_ERRNO_SETTER_C bl PLTJMP(__syscall_error) -# endif - # define SYSCALL_ERROR_HANDLER \ L (call_syscall_err): ASM_LINE_SEP \ push_s blink ASM_LINE_SEP \ cfi_adjust_cfa_offset (4) ASM_LINE_SEP \ cfi_rel_offset (blink, 0) ASM_LINE_SEP \ - CALL_ERRNO_SETTER_C ASM_LINE_SEP \ + bl __syscall_error ASM_LINE_SEP \ pop_s blink ASM_LINE_SEP \ cfi_adjust_cfa_offset (-4) ASM_LINE_SEP \ cfi_restore (blink) ASM_LINE_SEP \ From patchwork Mon Nov 9 20:18:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 40989 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 7ABC23973032; Mon, 9 Nov 2020 20:18:52 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7ABC23973032 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1604953132; bh=wIgHNeEYSwzpg9M9PIgwNXAbTuiY2ZDHCabRnv087pM=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=HcyYwBsfMrIouSnQyYE540zoBR4p3hKYHguw3lFc0dfLBCSwPXMTr1UGYzNhCnv+U Z4VL89N3QZuuHjZr1kMkBHx2Rqehn97khHvv6J0UGi8oE+qQ1JEG3Z0ZR7faRWD+WA PqnzWL68PcBmfwgN/ScLBDkywON79yYE+nsDfxXc= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-qt1-x82f.google.com (mail-qt1-x82f.google.com [IPv6:2607:f8b0:4864:20::82f]) by sourceware.org (Postfix) with ESMTPS id 64C293973058 for ; Mon, 9 Nov 2020 20:18:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 64C293973058 Received: by mail-qt1-x82f.google.com with SMTP id g17so6977724qts.5 for ; Mon, 09 Nov 2020 12:18:49 -0800 (PST) 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:mime-version:content-transfer-encoding; bh=wIgHNeEYSwzpg9M9PIgwNXAbTuiY2ZDHCabRnv087pM=; b=mj9V6PFSIQ11bbkmPDjBqQyb4YCteygbQbgg0pulyuMSQVbztGkyMHFF8IcXcVeHTg MfRkS/xNbFpX7G3+FLWUMyuzxfqTLMGwD7/p+1q0xL6V5zOCm4MAP49CeUZPCzWOUH3P uENA+hcLJPRwHfjweQkldrIonlIrjbStXv2LRt7VD3voIOP+Iu/b75rYGh7WaqO1JQRM htyw6eziSnlpSpb5P7sKZKq/GxhgGDI+pqj/9vXsjJ73Zd3JXxrtel7dRzrZsoGRj/Dl yHd1kghxFGIM8O8Vybw1jhOVCV3BeY3txnWiQxIrMJGEanEt2fkVFdQmLQFBXZ4etIeG KU4Q== X-Gm-Message-State: AOAM532W0z5W8ErS7pKT7RHcGIAofrI3VaWdq8aVMT5QI8OHs+Ae0joM Tf5zZRliqgi6JfdT/6HsOVRfkiU3IH2NDQ== X-Google-Smtp-Source: ABdhPJyKAKMtQpiCUUSdSncoxf2I7TFHitOZm5Hkd/+Vz8vcCf0t3lKML2MdKm2htkeEyI5b1k2N/A== X-Received: by 2002:a05:622a:246:: with SMTP id c6mr13308661qtx.70.1604953128014; Mon, 09 Nov 2020 12:18:48 -0800 (PST) Received: from localhost.localdomain ([177.194.48.209]) by smtp.googlemail.com with ESMTPSA id z2sm6843407qkl.22.2020.11.09.12.18.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Nov 2020 12:18:47 -0800 (PST) To: libc-alpha@sourceware.org Subject: [PATCH 09/23] linux: Use generic __syscall_error for powerpc Date: Mon, 9 Nov 2020 17:18:12 -0300 Message-Id: <20201109201826.120534-10-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201109201826.120534-1-adhemerval.zanella@linaro.org> References: <20201109201826.120534-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-13.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, URIBL_BLACK autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Adhemerval Zanella via Libc-alpha From: Adhemerval Zanella Netto Reply-To: Adhemerval Zanella Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" The powerpc kABI returns a positive value on 'r3' register for failure case (the syscall error is signaled on CR0), different than usual Linux kABI with return a negative value in range of [-4096,0). The arch specific__syscall_error thus has a different ABI than the generic one, which requires fixing both the inline syscall wrappers and some assembly implementation that calls __syscall_error directly. Using an inline function for __syscall_error is slight better for powerpc64{le} and only a small code increase on powerpc32: --- sizes-powerpc-linux-gnu.outline +++ sizes-powerpc-linux-gnu.inline @@ -1,8 +1,8 @@ text data bss dec hex filename -1759918 19900 9348 1789166 1b4cee libc.so - 176605 7516 188 184309 2cff5 elf/ld.so - 131959 1776 8352 142087 22b07 nptl/libpthread.so - 32058 872 160 33090 8142 rt/librt.so +1767602 19900 9348 1796850 1b6af2 libc.so + 177221 7516 188 184925 2d25d elf/ld.so + 132575 1776 8352 142703 22d6f nptl/libpthread.so + 32350 872 160 33382 8266 rt/librt.so --- sizes-powerpc64-linux-gnu.outline +++ sizes-powerpc64-linux-gnu.inline @@ -1,8 +1,8 @@ text data bss dec hex filename -2035762 95184 15048 2145994 20beca libc.so - 258573 13104 504 272181 42735 elf/ld.so - 154913 8240 18656 181809 2c631 nptl/libpthread.so - 36875 2404 3704 42983 a7e7 rt/librt.so +2031758 95184 15048 2141990 20af26 libc.so + 257881 13104 504 271489 42481 elf/ld.so + 154349 8240 18656 181245 2c3fd nptl/libpthread.so + 36511 2404 3704 42619 a67b rt/librt.so --- sizes-powerpc64le-linux-gnu.outline +++ sizes-powerpc64le-linux-gnu.inline @@ -1,8 +1,8 @@ text data bss dec hex filename -2031374 22464 14872 2068710 1f90e6 libc.so - 208066 7832 416 216314 34cfa elf/ld.so - 137717 1248 17328 156293 26285 nptl/libpthread.so - 31918 716 728 33362 8252 rt/librt.so +2027838 22464 14872 2065174 1f8316 libc.so + 207426 7832 416 215674 34a7a elf/ld.so + 137149 1248 17328 155725 2604d nptl/libpthread.so + 31490 716 728 32934 80a6 rt/librt.so Checked on powerpc-linux-gnu, powerpc64-linux-gnu, and powerpc64le-linux-gnu. --- sysdeps/powerpc/powerpc32/sysdep.h | 1 + sysdeps/powerpc/powerpc64/sysdep.h | 7 +++-- sysdeps/unix/sysv/linux/powerpc/Makefile | 7 ----- .../unix/sysv/linux/powerpc/powerpc32/brk.S | 1 + .../unix/sysv/linux/powerpc/powerpc32/clone.S | 3 +- .../sysv/linux/powerpc/powerpc32/getcontext.S | 2 ++ .../linux/powerpc/powerpc32/makecontext.S | 2 +- .../powerpc/powerpc32/nofpu/getcontext.S | 2 +- .../powerpc/powerpc32/nofpu/setcontext.S | 2 +- .../powerpc/powerpc32/nofpu/swapcontext.S | 2 +- .../sysv/linux/powerpc/powerpc32/setcontext.S | 3 +- .../linux/powerpc/powerpc32/swapcontext.S | 3 +- sysdeps/unix/sysv/linux/powerpc/rt-sysdep.c | 1 - sysdeps/unix/sysv/linux/powerpc/sysdep.c | 27 ------------------ sysdeps/unix/sysv/linux/powerpc/sysdep.h | 2 ++ sysdeps/unix/sysv/linux/sparc/sysdep.c | 28 ++++++++++++++++++- 16 files changed, 48 insertions(+), 45 deletions(-) delete mode 100644 sysdeps/unix/sysv/linux/powerpc/rt-sysdep.c delete mode 100644 sysdeps/unix/sysv/linux/powerpc/sysdep.c diff --git a/sysdeps/powerpc/powerpc32/sysdep.h b/sysdeps/powerpc/powerpc32/sysdep.h index 829eec266a..47d3aa4339 100644 --- a/sysdeps/powerpc/powerpc32/sysdep.h +++ b/sysdeps/powerpc/powerpc32/sysdep.h @@ -113,6 +113,7 @@ GOT_LABEL: ; \ #define PSEUDO_RET \ bnslr+; \ + neg 3,3; \ b __syscall_error@local #define ret PSEUDO_RET diff --git a/sysdeps/powerpc/powerpc64/sysdep.h b/sysdeps/powerpc/powerpc64/sysdep.h index d557098898..e7496a979a 100644 --- a/sysdeps/powerpc/powerpc64/sysdep.h +++ b/sysdeps/powerpc/powerpc64/sysdep.h @@ -277,13 +277,13 @@ LT_LABELSUFFIX(name,_name_end): ; \ DO_CALL (SYS_ify (syscall_name)) #ifdef SHARED -#define TAIL_CALL_SYSCALL_ERROR \ +#define _TAIL_CALL_SYSCALL_ERROR \ b JUMPTARGET (NOTOC (__syscall_error)) #else /* Static version might be linked into a large app with a toc exceeding 64k. We can't put a toc adjusting stub on a plain branch, so can't tail call __syscall_error. */ -#define TAIL_CALL_SYSCALL_ERROR \ +#define _TAIL_CALL_SYSCALL_ERROR \ .ifdef .Local_syscall_error; \ b .Local_syscall_error; \ .else; \ @@ -303,6 +303,9 @@ LT_LABELSUFFIX(name,_name_end): ; \ blr; \ .endif #endif +#define TAIL_CALL_SYSCALL_ERROR \ + neg 3,3; \ + _TAIL_CALL_SYSCALL_ERROR #define PSEUDO_RET \ bnslr+; \ diff --git a/sysdeps/unix/sysv/linux/powerpc/Makefile b/sysdeps/unix/sysv/linux/powerpc/Makefile index cc2f804d86..9610edd305 100644 --- a/sysdeps/unix/sysv/linux/powerpc/Makefile +++ b/sysdeps/unix/sysv/linux/powerpc/Makefile @@ -3,11 +3,6 @@ abi-32-condition := __WORDSIZE == 32 abi-64-v1-condition := __WORDSIZE == 64 && _CALL_ELF != 2 abi-64-v2-condition := __WORDSIZE == 64 && _CALL_ELF == 2 -ifeq ($(subdir),rt) -librt-routines += rt-sysdep -librt-shared-only-routines += rt-sysdep -endif - ifeq ($(subdir),stdlib) gen-as-const-headers += ucontext_i.sym endif @@ -31,8 +26,6 @@ tests += test-powerpc-linux-sysconf endif ifeq ($(subdir),nptl) -libpthread-routines += sysdep libpthread-sysdep_routines += elision-lock elision-unlock elision-timed \ elision-trylock -libpthread-shared-only-routines += sysdep endif diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/brk.S b/sysdeps/unix/sysv/linux/powerpc/powerpc32/brk.S index f3b960795e..8cbe17ef1e 100644 --- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/brk.S +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/brk.S @@ -46,6 +46,7 @@ ENTRY (__brk) li r3,0 blelr+ li r3,ENOMEM + neg r3,r3 b __syscall_error@local END (__brk) diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/clone.S b/sysdeps/unix/sysv/linux/powerpc/powerpc32/clone.S index ba0faaf69c..41e5e5fe2e 100644 --- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/clone.S +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/clone.S @@ -83,10 +83,11 @@ L(parent): lmw r28,16(r1) addi r1,r1,32 bnslr+ + neg r3,r3 b __syscall_error@local L(badargs): - li r3,EINVAL + li r3,-EINVAL b __syscall_error@local cfi_startproc diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/getcontext.S b/sysdeps/unix/sysv/linux/powerpc/powerpc32/getcontext.S index 9f65033b7e..c7c78d63c5 100644 --- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/getcontext.S +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/getcontext.S @@ -41,6 +41,7 @@ ENTRY (__getcontext) li r3,0 blr 1: + neg r3,r3 b __syscall_error@local END(__getcontext) @@ -69,6 +70,7 @@ compat_symbol (libc, __novec_getcontext, getcontext, GLIBC_2_3_3) compat_text_section ENTRY (__getcontext_stub) li r3,ENOSYS + neg r3,r3 b __syscall_error@local END (__getcontext_stub) .previous diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/makecontext.S b/sysdeps/unix/sysv/linux/powerpc/powerpc32/makecontext.S index 873edf14a8..43cc88cb9f 100644 --- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/makecontext.S +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/makecontext.S @@ -216,7 +216,7 @@ compat_symbol (libc, __novec_makecontext, makecontext, GLIBC_2_3_3) compat_text_section ENTRY (__makecontext_stub) - li r3,ENOSYS + li r3,-ENOSYS b __syscall_error@local END (__makecontext_stub) .previous diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/getcontext.S b/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/getcontext.S index 3cbbd32c31..a2126f4627 100644 --- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/getcontext.S +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/getcontext.S @@ -48,7 +48,7 @@ compat_symbol (libc, __novec_getcontext, getcontext, GLIBC_2_3_3) compat_text_section ENTRY (__getcontext_stub) - li r3,ENOSYS + li r3,-ENOSYS b __syscall_error@local END (__getcontext_stub) .previous diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/setcontext.S b/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/setcontext.S index 5adf7fb5ba..b9f9c21b66 100644 --- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/setcontext.S +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/setcontext.S @@ -48,7 +48,7 @@ compat_symbol (libc, __novec_setcontext, setcontext, GLIBC_2_3_3) compat_text_section ENTRY (__setcontext_stub) - li r3,ENOSYS + li r3,-ENOSYS b __syscall_error@local END (__setcontext_stub) .previous diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/swapcontext.S b/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/swapcontext.S index e4aec0ff96..d7263e5fb8 100644 --- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/swapcontext.S +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/swapcontext.S @@ -48,7 +48,7 @@ compat_symbol (libc, __novec_swapcontext, swapcontext, GLIBC_2_3_3) compat_text_section ENTRY (__swapcontext_stub) - li r3,ENOSYS + li r3,-ENOSYS b __syscall_error@local END (__swapcontext_stub) .previous diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/setcontext.S b/sysdeps/unix/sysv/linux/powerpc/powerpc32/setcontext.S index 7bcb2d990b..3cb5021917 100644 --- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/setcontext.S +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/setcontext.S @@ -42,6 +42,7 @@ ENTRY (__setcontext) li r3,0 blr 1: + neg r3,r3 b __syscall_error@local END(__setcontext) @@ -70,7 +71,7 @@ compat_symbol (libc, __novec_setcontext, setcontext, GLIBC_2_3_3) compat_text_section ENTRY (__setcontext_stub) - li r3,ENOSYS + li r3,-ENOSYS b __syscall_error@local END (__setcontext_stub) .previous diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/swapcontext.S b/sysdeps/unix/sysv/linux/powerpc/powerpc32/swapcontext.S index cd359d4a8a..53190028c5 100644 --- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/swapcontext.S +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/swapcontext.S @@ -40,6 +40,7 @@ ENTRY (__swapcontext) li r3,0 blr 1: + neg r3,r3 b __syscall_error@local END(__swapcontext) @@ -68,7 +69,7 @@ compat_symbol (libc, __novec_swapcontext, swapcontext, GLIBC_2_3_3) compat_text_section ENTRY (__swapcontext_stub) - li r3,ENOSYS + li r3,-ENOSYS b __syscall_error@local END (__swapcontext_stub) .previous diff --git a/sysdeps/unix/sysv/linux/powerpc/rt-sysdep.c b/sysdeps/unix/sysv/linux/powerpc/rt-sysdep.c deleted file mode 100644 index 3ff55952e2..0000000000 --- a/sysdeps/unix/sysv/linux/powerpc/rt-sysdep.c +++ /dev/null @@ -1 +0,0 @@ -#include diff --git a/sysdeps/unix/sysv/linux/powerpc/sysdep.c b/sysdeps/unix/sysv/linux/powerpc/sysdep.c deleted file mode 100644 index 1bf5ea6f62..0000000000 --- a/sysdeps/unix/sysv/linux/powerpc/sysdep.c +++ /dev/null @@ -1,27 +0,0 @@ -/* Copyright (C) 1997-2020 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - . */ - -#include - -/* This routine is jumped to by all the syscall handlers, to stash - an error number into errno. */ -int -__syscall_error (int err_no) -{ - __set_errno (err_no); - return -1; -} diff --git a/sysdeps/unix/sysv/linux/powerpc/sysdep.h b/sysdeps/unix/sysv/linux/powerpc/sysdep.h index b2bca598b9..31fa148ded 100644 --- a/sysdeps/unix/sysv/linux/powerpc/sysdep.h +++ b/sysdeps/unix/sysv/linux/powerpc/sysdep.h @@ -19,6 +19,8 @@ #ifndef _LINUX_POWERPC_SYSDEP_H #define _LINUX_POWERPC_SYSDEP_H 1 +#define SYSCALL_ERROR_FUNC + #include #include #include diff --git a/sysdeps/unix/sysv/linux/sparc/sysdep.c b/sysdeps/unix/sysv/linux/sparc/sysdep.c index f86414570d..1bf5ea6f62 100644 --- a/sysdeps/unix/sysv/linux/sparc/sysdep.c +++ b/sysdeps/unix/sysv/linux/sparc/sysdep.c @@ -1 +1,27 @@ -#include +/* Copyright (C) 1997-2020 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include + +/* This routine is jumped to by all the syscall handlers, to stash + an error number into errno. */ +int +__syscall_error (int err_no) +{ + __set_errno (err_no); + return -1; +} From patchwork Mon Nov 9 20:18:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 40990 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 0AB3539724AB; Mon, 9 Nov 2020 20:18:54 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0AB3539724AB DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1604953134; bh=LtQgCurgM+1eGCaad+41dQ3com5lMz12+k1UcydOYB8=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=Lj8sNU2YsmekNk87LCcSZR61kPwGvZ2L9oTGg5n2OJ6Q+l8ygUH6ElNuLnpGF4gY/ drl6MlObnAoEePLnCmF5Q0vek4UidaFAVVKGarcpUy945y3rrgNV9QqSrk0wv8Zhod tWWdSAUv852+/3WtmOUkeObhIYYYl/2utfN+tpQA= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-qt1-x843.google.com (mail-qt1-x843.google.com [IPv6:2607:f8b0:4864:20::843]) by sourceware.org (Postfix) with ESMTPS id ACCEE397300F for ; Mon, 9 Nov 2020 20:18:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org ACCEE397300F Received: by mail-qt1-x843.google.com with SMTP id 7so2588806qtp.1 for ; Mon, 09 Nov 2020 12:18:50 -0800 (PST) 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:mime-version:content-transfer-encoding; bh=LtQgCurgM+1eGCaad+41dQ3com5lMz12+k1UcydOYB8=; b=TiAiONU5XDzFBOId8cL6VGj02qoPaPzKZyaXQtTs6zWQy6olO0GCKK+EwonSTHoygA bYsKen5xF61IgVQFbC3oZoHLYY9fyQR54fzrS54LDGucncB65w46BT55t/pSDGG64QZF ENIiYfmIyWsp69tQmu9O1Ffs8Hl620WMgMJxTY7BbpAjlHLX8WJ/vjFtvcrJa1MaZfcC fOmOtmMgASV8vjDuOOKPvx6sPZ7zPZFo/MF4Hi74eP0kuiE22rWzX3hHNkZGHHpS2VdV IQJqy95ZLdNQwrtfCBI+dGbuL84w+2tweAIHESfxZhE10HqptcUJAU7JmTsd1TF4INIV xs+A== X-Gm-Message-State: AOAM53160NUm3OIo4W7aAG/Y+uMQnVfL5XL1ZaCRQ71yKtdupo5ogGVb s3URNkmqOsooJlTBohGE7IHHaMKJNU+EHQ== X-Google-Smtp-Source: ABdhPJxnnEhLgwxFJUfAka+7F0QosZqfAhBDapx5ZctU7eIU/x8T0vrCheo307cd1efEUAALTuU20Q== X-Received: by 2002:aed:3147:: with SMTP id 65mr15281199qtg.295.1604953129814; Mon, 09 Nov 2020 12:18:49 -0800 (PST) Received: from localhost.localdomain ([177.194.48.209]) by smtp.googlemail.com with ESMTPSA id z2sm6843407qkl.22.2020.11.09.12.18.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Nov 2020 12:18:49 -0800 (PST) To: libc-alpha@sourceware.org Subject: [PATCH 10/23] linux: Use generic __syscall_error for sparc Date: Mon, 9 Nov 2020 17:18:13 -0300 Message-Id: <20201109201826.120534-11-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201109201826.120534-1-adhemerval.zanella@linaro.org> References: <20201109201826.120534-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-13.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, URIBL_BLACK autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Adhemerval Zanella via Libc-alpha From: Adhemerval Zanella Netto Reply-To: Adhemerval Zanella Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" The sparc kABI returns a positive errno value in 'o0' register for failure case (the syscall error is signal on conditional register), different than usual Linux kABI with return a negative value in range of [-4096,0). The __syscall_error thus has a different ABI than the generic one, which requires fixing both the inline syscall wrappers and some assembly implementation that calls __syscall_error directly. Using inline function for __syscall_error does not yield any gain: --- sizes-sparc64-linux-gnu.outline +++ sizes-sparc64-linux-gnu.inline text data bss dec hex filename -1469609 20464 14496 1504569 16f539 libc.so - 152853 6960 352 160165 271a5 elf/ld.so - 101586 1220 16672 119478 1d2b6 nptl/libpthread.so - 27282 836 2296 30414 76ce rt/librt.so +1473545 20464 14496 1508505 170499 libc.so + 153077 6960 352 160389 27285 elf/ld.so + 102578 1220 16672 120470 1d696 nptl/libpthread.so + 27474 836 2296 30606 778e rt/librt.so --- sizes-sparcv9-linux-gnu.outline +++ sizes-sparcv9-linux-gnu.inline text data bss dec hex filename -1557171 11208 9440 1577819 18135b libc.so - 149507 4448 192 154147 25a23 elf/ld.so - 101518 588 8356 110462 1af7e nptl/libpthread.so - 26546 404 160 27110 69e6 rt/librt.so +1563315 11208 9440 1583963 182b5b libc.so + 149795 4448 192 154435 25b43 elf/ld.so + 102286 588 8356 111230 1b27e nptl/libpthread.so + 26930 404 160 27494 6b66 rt/librt.so Checked on sparc64-linux-gnu and sparcv9-linux-gnu. --- sysdeps/unix/sysv/linux/sparc/Makefile | 9 ++----- sysdeps/unix/sysv/linux/sparc/rt-sysdep.c | 1 - sysdeps/unix/sysv/linux/sparc/sparc32/pipe.S | 1 + .../unix/sysv/linux/sparc/sparc32/syscall.S | 1 + .../unix/sysv/linux/sparc/sparc32/sysdep.h | 1 + sysdeps/unix/sysv/linux/sparc/sparc32/vfork.S | 1 + sysdeps/unix/sysv/linux/sparc/sparc64/pipe.S | 1 + .../unix/sysv/linux/sparc/sparc64/syscall.S | 1 + .../unix/sysv/linux/sparc/sparc64/sysdep.h | 1 + sysdeps/unix/sysv/linux/sparc/sparc64/vfork.S | 1 + sysdeps/unix/sysv/linux/sparc/sysdep.c | 27 ------------------- sysdeps/unix/sysv/linux/sparc/sysdep.h | 2 ++ 12 files changed, 12 insertions(+), 35 deletions(-) delete mode 100644 sysdeps/unix/sysv/linux/sparc/rt-sysdep.c delete mode 100644 sysdeps/unix/sysv/linux/sparc/sysdep.c diff --git a/sysdeps/unix/sysv/linux/sparc/Makefile b/sysdeps/unix/sysv/linux/sparc/Makefile index 1475039677..3a47cd2da4 100644 --- a/sysdeps/unix/sysv/linux/sparc/Makefile +++ b/sysdeps/unix/sysv/linux/sparc/Makefile @@ -2,11 +2,6 @@ abi-variants := 32 64 abi-32-condition := __WORDSIZE == 32 abi-64-condition := __WORDSIZE == 64 -ifeq ($(subdir),rt) -librt-routines += rt-sysdep -librt-shared-only-routines += rt-sysdep -endif - ifeq ($(subdir),sysvipc) sysdep_routines += getshmlba endif @@ -17,6 +12,6 @@ endif ifeq ($(subdir),nptl) # pull in __syscall_error routine -libpthread-routines += sysdep sigreturn_stub -libpthread-shared-only-routines += sysdep sigreturn_stub +libpthread-routines += sigreturn_stub +libpthread-shared-only-routines += sigreturn_stub endif diff --git a/sysdeps/unix/sysv/linux/sparc/rt-sysdep.c b/sysdeps/unix/sysv/linux/sparc/rt-sysdep.c deleted file mode 100644 index 3ff55952e2..0000000000 --- a/sysdeps/unix/sysv/linux/sparc/rt-sysdep.c +++ /dev/null @@ -1 +0,0 @@ -#include diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/pipe.S b/sysdeps/unix/sysv/linux/sparc/sparc32/pipe.S index 0b10f1522b..d693527e7b 100644 --- a/sysdeps/unix/sysv/linux/sparc/sparc32/pipe.S +++ b/sysdeps/unix/sysv/linux/sparc/sparc32/pipe.S @@ -26,6 +26,7 @@ ENTRY(__libc_pipe) ta 0x10 bcc 1f mov %o7, %g1 + neg %o0, %o0 call __syscall_error mov %g1, %o7 1: st %o0, [%o2] /* PIPEDES[0] = %o0; */ diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/syscall.S b/sysdeps/unix/sysv/linux/sparc/sparc32/syscall.S index 90c639f043..a2b608179a 100644 --- a/sysdeps/unix/sysv/linux/sparc/sparc32/syscall.S +++ b/sysdeps/unix/sysv/linux/sparc/sparc32/syscall.S @@ -30,6 +30,7 @@ ENTRY(syscall) ta 0x10 bcc 1f mov %o7, %g1 + neg %o0, %o0 call __syscall_error mov %g1, %o7 1: retl diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/sysdep.h b/sysdeps/unix/sysv/linux/sparc/sparc32/sysdep.h index 2c3754770b..3e7671c391 100644 --- a/sysdeps/unix/sysv/linux/sparc/sparc32/sysdep.h +++ b/sysdeps/unix/sysv/linux/sparc/sparc32/sysdep.h @@ -65,6 +65,7 @@ ENTRY(name); \ #ifndef PIC # define SYSCALL_ERROR_HANDLER \ mov %o7, %g1; \ + neg %o0, %o0; \ call __syscall_error; \ mov %g1, %o7; #else diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/vfork.S b/sysdeps/unix/sysv/linux/sparc/sparc32/vfork.S index be48386016..c8d26a49a7 100644 --- a/sysdeps/unix/sysv/linux/sparc/sparc32/vfork.S +++ b/sysdeps/unix/sysv/linux/sparc/sparc32/vfork.S @@ -26,6 +26,7 @@ ENTRY(__libc_vfork) ta 0x10 bcc 2f mov %o7, %g1 + neg %o0, %o0 call __syscall_error mov %g1, %o7 2: sub %o1, 1, %o1 diff --git a/sysdeps/unix/sysv/linux/sparc/sparc64/pipe.S b/sysdeps/unix/sysv/linux/sparc/sparc64/pipe.S index 072a1936ea..ba75629261 100644 --- a/sysdeps/unix/sysv/linux/sparc/sparc64/pipe.S +++ b/sysdeps/unix/sysv/linux/sparc/sparc64/pipe.S @@ -27,6 +27,7 @@ ENTRY(__libc_pipe) ta 0x6d bcc,pt %xcc, 1f mov %o7, %g1 + neg %o0, %o0 call __syscall_error mov %g1, %o7 1: st %o0, [%o2] /* PIPEDES[0] = %o0; */ diff --git a/sysdeps/unix/sysv/linux/sparc/sparc64/syscall.S b/sysdeps/unix/sysv/linux/sparc/sparc64/syscall.S index fca114371f..63a28f65ee 100644 --- a/sysdeps/unix/sysv/linux/sparc/sparc64/syscall.S +++ b/sysdeps/unix/sysv/linux/sparc/sparc64/syscall.S @@ -32,6 +32,7 @@ ENTRY(syscall) bcc,pt %xcc, 1f mov %o7, %g1 + neg %o0, %o0 call __syscall_error mov %g1, %o7 1: retl diff --git a/sysdeps/unix/sysv/linux/sparc/sparc64/sysdep.h b/sysdeps/unix/sysv/linux/sparc/sparc64/sysdep.h index 2010faf50f..329ec144cf 100644 --- a/sysdeps/unix/sysv/linux/sparc/sparc64/sysdep.h +++ b/sysdeps/unix/sysv/linux/sparc/sparc64/sysdep.h @@ -65,6 +65,7 @@ ENTRY(name); \ #ifndef PIC # define SYSCALL_ERROR_HANDLER \ mov %o7, %g1; \ + neg %o0, %o0; \ call __syscall_error; \ mov %g1, %o7; #else diff --git a/sysdeps/unix/sysv/linux/sparc/sparc64/vfork.S b/sysdeps/unix/sysv/linux/sparc/sparc64/vfork.S index 56a491f3de..0a34a3e68c 100644 --- a/sysdeps/unix/sysv/linux/sparc/sparc64/vfork.S +++ b/sysdeps/unix/sysv/linux/sparc/sparc64/vfork.S @@ -26,6 +26,7 @@ ENTRY(__libc_vfork) ta 0x6d bcc,pt %xcc, 2f mov %o7, %g1 + neg %o0, %o0 call __syscall_error mov %g1, %o7 2: sub %o1, 1, %o1 diff --git a/sysdeps/unix/sysv/linux/sparc/sysdep.c b/sysdeps/unix/sysv/linux/sparc/sysdep.c deleted file mode 100644 index 1bf5ea6f62..0000000000 --- a/sysdeps/unix/sysv/linux/sparc/sysdep.c +++ /dev/null @@ -1,27 +0,0 @@ -/* Copyright (C) 1997-2020 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - . */ - -#include - -/* This routine is jumped to by all the syscall handlers, to stash - an error number into errno. */ -int -__syscall_error (int err_no) -{ - __set_errno (err_no); - return -1; -} diff --git a/sysdeps/unix/sysv/linux/sparc/sysdep.h b/sysdeps/unix/sysv/linux/sparc/sysdep.h index aec4326cc9..8970ecc1ae 100644 --- a/sysdeps/unix/sysv/linux/sparc/sysdep.h +++ b/sysdeps/unix/sysv/linux/sparc/sysdep.h @@ -19,6 +19,8 @@ #ifndef _LINUX_SPARC_SYSDEP_H #define _LINUX_SPARC_SYSDEP_H 1 +#define SYSCALL_ERROR_FUNC + #include #include #include From patchwork Mon Nov 9 20:18:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 40991 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 8FA9C397306E; Mon, 9 Nov 2020 20:18:54 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8FA9C397306E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1604953134; bh=2yrHsqcnbEmYuRbPAqq3fhCvCQJziXzUsqZQzZWq6wQ=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=Vc6lNwHxCpV1pqCh+TYrtoawNNLe9cYN7epqyZHhiZIeqwlyhxHAuLkDgLTd+AUmT WX0f1LzGwVtjMkuYtQLFnnvq0rL4KV4fGMOO5EsiQ1mKdU/2I9oRyKxIN1kM1gVSbL ItxO9KF1xBS6bmeXRlnirjYyMTBjklHDvVIC75LY= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-qk1-x742.google.com (mail-qk1-x742.google.com [IPv6:2607:f8b0:4864:20::742]) by sourceware.org (Postfix) with ESMTPS id E64E33896C3F for ; Mon, 9 Nov 2020 20:18:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org E64E33896C3F Received: by mail-qk1-x742.google.com with SMTP id d9so2167631qke.8 for ; Mon, 09 Nov 2020 12:18:51 -0800 (PST) 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:mime-version:content-transfer-encoding; bh=2yrHsqcnbEmYuRbPAqq3fhCvCQJziXzUsqZQzZWq6wQ=; b=cPndVuLgxJDZs5DJw5izp4wDkU3mAsxeABvDmJ7nZTGHuWPkqPhcSMvfYVZNbrrakw uf6HvXDyq3pkImNsKmlxcIZ9prCCNh8oE7NC6MNFa6Wef+5sZFWjClUzBINvlVjY06Wz FmT6afKSGTAt19M0UDvpFDrBzdwopknAuhL7rWX5v25x20DTHUDEFM6URC0MYS3JJh0E pnMWezoT4yGR6Xz+fvp00I0K2r+Q85Sdu9VgiHGkh3XpoMtfR8vlJTexWPnQBS6dNONE 6fP6CGHv/BR4IOo8f/+cPTCsQf0VkwCW9lHMrw1rvEbbYnObiGd6sJA5synX3r5X93cM LI8A== X-Gm-Message-State: AOAM532J4j4VRdvTnBxyJNe/Y09NCw3lzp1zDJxmf8HXPsaY3fechdXn V5WWuHI2YVqULY4B8x7IuGB0Nsx/S+M6Jg== X-Google-Smtp-Source: ABdhPJxSjCg6n4Dm0mWsiqSWMbC2dTelXJo6BocgH7FuPTxM3u7apUz/FlVmCDUFynhd0cqjG3qRXA== X-Received: by 2002:a37:68d5:: with SMTP id d204mr8923266qkc.198.1604953131306; Mon, 09 Nov 2020 12:18:51 -0800 (PST) Received: from localhost.localdomain ([177.194.48.209]) by smtp.googlemail.com with ESMTPSA id z2sm6843407qkl.22.2020.11.09.12.18.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Nov 2020 12:18:50 -0800 (PST) To: libc-alpha@sourceware.org Subject: [PATCH 11/23] linux: Use generic __syscall_error for hppa Date: Mon, 9 Nov 2020 17:18:14 -0300 Message-Id: <20201109201826.120534-12-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201109201826.120534-1-adhemerval.zanella@linaro.org> References: <20201109201826.120534-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-13.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, URIBL_BLACK autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Adhemerval Zanella via Libc-alpha From: Adhemerval Zanella Netto Reply-To: Adhemerval Zanella Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" HPPA issues inline error handling for auto-generated syscall, the __syscall_error is used solely on clone implementation and it differs from generic implementation by passing positive errno numbers. Also, inline error handling does not really produce the most compat code. --- sizes-hppa-linux-gnu.outline +++ sizes-hppa-linux-gnu.inline text data bss dec hex filename -1576515 22028 9424 1607967 18891f libc.so - 174755 15524 448 190727 2e907 elf/ld.so - 132799 1296 8364 142459 22c7b nptl/libpthread.so - 30993 788 236 32017 7d11 rt/librt.so +1579367 22028 9424 1610819 189443 libc.so + 174835 15524 448 190807 2e957 elf/ld.so + 133055 1296 8364 142715 22d7b nptl/libpthread.so + 31297 788 236 32321 7e41 rt/librt.so Checked on hppa-linux-gnu. --- sysdeps/unix/sysv/linux/hppa/clone.S | 6 ++++-- sysdeps/unix/sysv/linux/hppa/sysdep.c | 27 --------------------------- sysdeps/unix/sysv/linux/hppa/sysdep.h | 2 ++ 3 files changed, 6 insertions(+), 29 deletions(-) delete mode 100644 sysdeps/unix/sysv/linux/hppa/sysdep.c diff --git a/sysdeps/unix/sysv/linux/hppa/clone.S b/sysdeps/unix/sysv/linux/hppa/clone.S index 4eda812dd0..fcfafe1d2b 100644 --- a/sysdeps/unix/sysv/linux/hppa/clone.S +++ b/sysdeps/unix/sysv/linux/hppa/clone.S @@ -124,7 +124,8 @@ ENTRY(__clone) .LerrorRest: /* Something bad happened -- no child created */ bl __syscall_error, %rp - sub %r0, %ret0, %arg0 + copy %ret0, %arg0 + ldw -84(%sp), %rp /* Return after setting errno, ret0 is set to -1 by __syscall_error. */ bv %r0(%rp) @@ -133,7 +134,8 @@ ENTRY(__clone) .LerrorSanity: /* Sanity checks failed, return -1, and set errno to EINVAL. */ bl __syscall_error, %rp - ldi EINVAL, %arg0 + ldi -EINVAL, %arg0 + ldw -84(%sp), %rp bv %r0(%rp) ldwm -64(%sp), %r4 diff --git a/sysdeps/unix/sysv/linux/hppa/sysdep.c b/sysdeps/unix/sysv/linux/hppa/sysdep.c deleted file mode 100644 index 8c06b6fc80..0000000000 --- a/sysdeps/unix/sysv/linux/hppa/sysdep.c +++ /dev/null @@ -1,27 +0,0 @@ -/* Copyright (C) 1997-2020 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library. If not, see - . */ - -#include - -/* This routine is jumped to by all the syscall handlers, to stash - an error number into errno. */ -int -__syscall_error (int err_no) -{ - __set_errno (err_no); - return -1; -} diff --git a/sysdeps/unix/sysv/linux/hppa/sysdep.h b/sysdeps/unix/sysv/linux/hppa/sysdep.h index 531fe2beed..a1165da81e 100644 --- a/sysdeps/unix/sysv/linux/hppa/sysdep.h +++ b/sysdeps/unix/sysv/linux/hppa/sysdep.h @@ -21,6 +21,8 @@ #ifndef _LINUX_HPPA_SYSDEP_H #define _LINUX_HPPA_SYSDEP_H 1 +#define SYSCALL_ERROR_FUNC + #include #include #include From patchwork Mon Nov 9 20:18:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 40992 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 922DA3973077; Mon, 9 Nov 2020 20:18:56 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 922DA3973077 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1604953136; bh=y/1xZ/UyxF1Y0SWG3qLmCRC6jjiTZSNEeqtcs3noPUY=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=R27UBydsOVxs6tovh2/Mue9KVW9CU1+s6W+FfQ1wpPiCmXF6GcExOhUerIubmGlyJ J0Z2Ram7eOlouehGiea1zY4xWiXTt5mSLBpkFwXLb2/YMP/ee9WoKoRlMAjDh2GyPw MpbUHwLOaTysJ+o43931a0KtHB2RV7URmU6oFaCM= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-qt1-x841.google.com (mail-qt1-x841.google.com [IPv6:2607:f8b0:4864:20::841]) by sourceware.org (Postfix) with ESMTPS id 61BFB397304E for ; Mon, 9 Nov 2020 20:18:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 61BFB397304E Received: by mail-qt1-x841.google.com with SMTP id 3so6970084qtx.3 for ; Mon, 09 Nov 2020 12:18:53 -0800 (PST) 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:mime-version:content-transfer-encoding; bh=y/1xZ/UyxF1Y0SWG3qLmCRC6jjiTZSNEeqtcs3noPUY=; b=I+WmD9eHrnqjWF7to1AG1yNNjIENaKYK1aoYwl5LYHkVyFrbWNdgMg7j5lma9RyB19 oXjd2/V3oS5BTmo2+mKEWLNmViNma1kpT7HN9wCozCtCpzrtOtyZgnfygD2TV23mWOQs lgeW160YRQV5Bi9KZDO2D2yeacWhnS2sg4hkByOrJS1PkenmRk5oj2XFtvk4YVUzazji WdOlasCXsCMVlw2awjZvRsXvTOgnKN0pnRm6+NLWxjuG7h15yu1uKQUt6UhtZDi5YC6x ew8ct8ZjbzAORdSnrKIFXRhugWVb2cXWkhE7Bo8SDR70fla8gJBFMd1P/ApyyPOvqD/s QpiQ== X-Gm-Message-State: AOAM531B1cEaBAF0GAc1uL2dVsJKaG7eBs2FVbacLSOJZY9a2YaIUL3U etvA98vrDDhZKG03vxhJSgDPe2TetuCUpg== X-Google-Smtp-Source: ABdhPJzdcQOvb29Cfrw8mJkvijYB7ci4ZmIhawY7rckiOl1ikqCLcFhN8h8YyigFbo+dl6j+oAXOWg== X-Received: by 2002:ac8:5411:: with SMTP id b17mr14918878qtq.281.1604953132617; Mon, 09 Nov 2020 12:18:52 -0800 (PST) Received: from localhost.localdomain ([177.194.48.209]) by smtp.googlemail.com with ESMTPSA id z2sm6843407qkl.22.2020.11.09.12.18.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Nov 2020 12:18:52 -0800 (PST) To: libc-alpha@sourceware.org Subject: [PATCH 12/23] linux: Use generic __syscall_error for arm Date: Mon, 9 Nov 2020 17:18:15 -0300 Message-Id: <20201109201826.120534-13-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201109201826.120534-1-adhemerval.zanella@linaro.org> References: <20201109201826.120534-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, KAM_STOCKGEN, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, URIBL_BLACK autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Adhemerval Zanella via Libc-alpha From: Adhemerval Zanella Netto Reply-To: Adhemerval Zanella Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" The auto-generated syscalls issue the __syscall_erro and the ARM resulting binary using inline __syscall_error results in a large code size: --- sizes-arm-linux-gnueabihf.outline +++ sizes-arm-linux-gnueabihf.inline @@ -1,5 +1,5 @@ text data bss dec hex filename -1260061 9912 9256 1279229 1384fd libc.so - 143107 4336 208 147651 240c3 elf/ld.so - 97335 844 8352 106531 1a023 nptl/libpthread.so - 22516 656 160 23332 5b24 rt/librt.so +1265565 9912 9256 1284733 139a7d libc.so + 143491 4336 208 148035 24243 elf/ld.so + 98103 844 8352 107299 1a323 nptl/libpthread.so + 22996 656 160 23812 5d04 rt/librt.so The assembly sysdep.S is replaced the by the generic syscall_error.c. Checked on arm-linux-gnueabihf. --- sysdeps/unix/arm/sysdep.S | 62 ---------------------------- sysdeps/unix/sysv/linux/arm/sysdep.S | 33 --------------- sysdeps/unix/sysv/linux/arm/sysdep.h | 2 + 3 files changed, 2 insertions(+), 95 deletions(-) delete mode 100644 sysdeps/unix/arm/sysdep.S delete mode 100644 sysdeps/unix/sysv/linux/arm/sysdep.S diff --git a/sysdeps/unix/arm/sysdep.S b/sysdeps/unix/arm/sysdep.S deleted file mode 100644 index 5c9022a869..0000000000 --- a/sysdeps/unix/arm/sysdep.S +++ /dev/null @@ -1,62 +0,0 @@ -/* Copyright (C) 1991-2020 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library. If not, see - . */ - -#include -#include - -#if IS_IN (rtld) -# include /* Defines RTLD_PRIVATE_ERRNO. */ -#endif - -#include - -#undef syscall_error -__syscall_error: -#if defined (EWOULDBLOCK_sys) && EWOULDBLOCK_sys != EAGAIN - /* We translate the system's EWOULDBLOCK error into EAGAIN. - The GNU C library always defines EWOULDBLOCK==EAGAIN. - EWOULDBLOCK_sys is the original number. */ - cmp r0, $EWOULDBLOCK_sys /* Is it the old EWOULDBLOCK? */ - it eq - moveq r0, $EAGAIN /* Yes; translate it to EAGAIN. */ -#endif - -#if !IS_IN (rtld) - mov r1, r0 - GET_TLS (r2) - ldr r2, 1f -#ifdef __thumb__ -2: add r2, r2, pc - ldr r2, [r2] -#else -2: ldr r2, [pc, r2] -#endif - str r1, [r0, r2] - mvn r0, #0 - DO_RET(lr) - -1: .word errno(gottpoff) + (. - 2b - PC_OFS) -#elif RTLD_PRIVATE_ERRNO - LDST_PCREL(str, r0, r1, C_SYMBOL_NAME(rtld_errno)) - mvn r0, #0 - DO_RET(r14) -#else -#error "Unsupported non-TLS case" -#endif - -#undef __syscall_error -END (__syscall_error) diff --git a/sysdeps/unix/sysv/linux/arm/sysdep.S b/sysdeps/unix/sysv/linux/arm/sysdep.S deleted file mode 100644 index 94c877b31d..0000000000 --- a/sysdeps/unix/sysv/linux/arm/sysdep.S +++ /dev/null @@ -1,33 +0,0 @@ -/* Copyright (C) 1995-2020 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library. If not, see - . */ - -#include - - .text - -/* The syscall stubs jump here when they detect an error. - The code for Linux is almost identical to the canonical Unix - code, except that the error number in R0 is negated. */ - -#undef CALL_MCOUNT -#define CALL_MCOUNT /* Don't insert the profiling call, it clobbers R0. */ - -ENTRY (__syscall_error) - rsb r0, r0, $0 - -#define __syscall_error __syscall_error_1 -#include diff --git a/sysdeps/unix/sysv/linux/arm/sysdep.h b/sysdeps/unix/sysv/linux/arm/sysdep.h index e2985cffd7..b771db4508 100644 --- a/sysdeps/unix/sysv/linux/arm/sysdep.h +++ b/sysdeps/unix/sysv/linux/arm/sysdep.h @@ -20,6 +20,8 @@ #ifndef _LINUX_ARM_SYSDEP_H #define _LINUX_ARM_SYSDEP_H 1 +#define SYSCALL_ERROR_FUNC + /* There is some commonality. */ #include #include From patchwork Mon Nov 9 20:18:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 40993 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 1E3A8397307F; Mon, 9 Nov 2020 20:18:58 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1E3A8397307F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1604953138; bh=TQIOiSQ5DeVsfYviHj/TofC1BzAIfAwt4dD4VUva3c0=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=RYYWa5a6kC/l89VF3iis1n3XAu+5+Yp5Yz0KhPp+i8GfL73Y/chTaQwvgA3Vj0NiQ 4fJaPA2WTf8F+njd7gZ3a7DDPuS1z7KTEvTdLrntvR1QIh229uGLdW3thZkJVwlpop /eZ9CuVvCKJO8j6s8xrqeqMMOSw4VwAOkLM/+lU8= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-qk1-x72d.google.com (mail-qk1-x72d.google.com [IPv6:2607:f8b0:4864:20::72d]) by sourceware.org (Postfix) with ESMTPS id E49753973070 for ; Mon, 9 Nov 2020 20:18:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org E49753973070 Received: by mail-qk1-x72d.google.com with SMTP id u4so6502666qkk.10 for ; Mon, 09 Nov 2020 12:18:54 -0800 (PST) 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:mime-version:content-transfer-encoding; bh=TQIOiSQ5DeVsfYviHj/TofC1BzAIfAwt4dD4VUva3c0=; b=pQqGBh7XudhyQeOK2b4z7weU/ZvjYL6fzXQ/obu6zHJZqTCXyn+AzfJyJmr89dN/gl nLhmGAlFnXXZ6eFmzA76O7eMGugjwRi+qndph/WZmjeGzJ+QO7YhzszYb0T5zWmy6BEO QEDG6o2YxzAW9fpUSABXdZ9iOdNQKSYkxYZs0SC/QbypI2qPLtZK3cpWFQxzACv28Abp qFiZojezkoooDlCJuhGjXdiEp2xz2jJHDxo2xGsc5M6dvNaJHhcelk1O58S9zVmM31+p 9a4j8q2J8StcyKKb/KpJc9D2V9SmAHwCofx5s1Y/BFpXTCFiccIDxHDXrIf3EZbZTWrr xRrA== X-Gm-Message-State: AOAM533JGGcG77PgictDh3S24AllPfdpkwRax+mYQew36rU7C2PLXLmT vzoyZrJo7y03F/GmcChwHI6CwpyJ5cAAEA== X-Google-Smtp-Source: ABdhPJyqfJByX6AS8TbmLaUWqjhzMdtUOA7ndsgmKMtpEpCqX+ANMzwEAFHmz7cI5s450303XvEl5g== X-Received: by 2002:a37:6107:: with SMTP id v7mr15246712qkb.145.1604953134084; Mon, 09 Nov 2020 12:18:54 -0800 (PST) Received: from localhost.localdomain ([177.194.48.209]) by smtp.googlemail.com with ESMTPSA id z2sm6843407qkl.22.2020.11.09.12.18.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Nov 2020 12:18:53 -0800 (PST) To: libc-alpha@sourceware.org Subject: [PATCH 13/23] linux: Use generic __syscall_error for x86_64 Date: Mon, 9 Nov 2020 17:18:16 -0300 Message-Id: <20201109201826.120534-14-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201109201826.120534-1-adhemerval.zanella@linaro.org> References: <20201109201826.120534-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_NUMSUBJECT, KAM_SHORT, KAM_STOCKGEN, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, URIBL_BLACK autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Adhemerval Zanella via Libc-alpha From: Adhemerval Zanella Netto Reply-To: Adhemerval Zanella Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" The auto-generated syscalls issue the __syscall_error only for static objects, so a arch specific syscall_error is added. The size of using extern __syscall_error is just slight better for static case: --- size-fstatat64.o.inline +++ size-fstatat64.o.outline @@ -1,2 +1,2 @@ text data bss dec hex filename - 100 0 0 100 64 io/fstatat64.o + 94 0 0 94 5e io/fstatat64.o For shared objects the inline __syscall_error does generate more compact code: --- sizes-x86_64-linux-gnu.inline +++ sizes-x86_64-linux-gnu.outline @@ -1,5 +1,5 @@ text data bss dec hex filename -1774028 20520 15896 1810444 1ba00c libc.so - 167499 7280 392 175171 2ac43 elf/ld.so - 99261 1640 16728 117629 1cb7d nptl/libpthread.so - 24751 1188 2400 28339 6eb3 rt/librt.so +1776260 20520 15896 1812676 1ba8c4 libc.so + 167758 7280 392 175430 2ad46 elf/ld.so + 100221 1640 16728 118589 1cf3d nptl/libpthread.so + 24927 1188 2400 28515 6f63 rt/librt.so A possible option might be to use the same strategy for both static and PIC code, which allow to remove the arch-specific syscall_error.c with a slight increase of code size in static library. Checked on x86_64-linux-gnu. --- sysdeps/unix/sysv/linux/sysdep.h | 8 +++ .../unix/sysv/linux/x86_64/syscall_error.c | 5 ++ sysdeps/unix/sysv/linux/x86_64/sysdep.S | 40 --------------- sysdeps/unix/x86_64/sysdep.S | 49 ------------------- 4 files changed, 13 insertions(+), 89 deletions(-) create mode 100644 sysdeps/unix/sysv/linux/x86_64/syscall_error.c delete mode 100644 sysdeps/unix/sysv/linux/x86_64/sysdep.S delete mode 100644 sysdeps/unix/x86_64/sysdep.S diff --git a/sysdeps/unix/sysv/linux/sysdep.h b/sysdeps/unix/sysv/linux/sysdep.h index 6c0d1f9f6f..4f5b978838 100644 --- a/sysdeps/unix/sysv/linux/sysdep.h +++ b/sysdeps/unix/sysv/linux/sysdep.h @@ -24,6 +24,14 @@ #include #ifndef __ASSEMBLER__ +/* The errno setting might be set either inline or with a help function. For + some ABIs (x86_64), setting inline might generate less code; while for + others (i686) function call is preferable. + + To use the helper function an ABI might define SYSCALL_ERROR_FUNC, it will + build a hidden function on each shared object that issues direct syscall + with {INLINE,INTERNAL}_SYSCALL_CALL. */ + static inline _Bool syscall_error (unsigned long int val) { diff --git a/sysdeps/unix/sysv/linux/x86_64/syscall_error.c b/sysdeps/unix/sysv/linux/x86_64/syscall_error.c new file mode 100644 index 0000000000..40528f8ae9 --- /dev/null +++ b/sysdeps/unix/sysv/linux/x86_64/syscall_error.c @@ -0,0 +1,5 @@ +/* The auto-generated syscalls calls __syscall_error for static objects. */ +#ifndef SHARED +# define SYSCALL_ERROR_FUNC +#endif +#include diff --git a/sysdeps/unix/sysv/linux/x86_64/sysdep.S b/sysdeps/unix/sysv/linux/x86_64/sysdep.S deleted file mode 100644 index 2d3592296d..0000000000 --- a/sysdeps/unix/sysv/linux/x86_64/sysdep.S +++ /dev/null @@ -1,40 +0,0 @@ -/* Copyright (C) 2001-2020 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - . */ - -#include - -/* The following code is only used in the shared library when we - compile the reentrant version. Otherwise each system call defines - each own version. */ - -#ifndef PIC - -/* The syscall stubs jump here when they detect an error. - The code for Linux is almost identical to the canonical Unix - code, except that the error number in %rax is negated. */ - -#undef CALL_MCOUNT -#define CALL_MCOUNT /* Don't insert the profiling call, it clobbers %rax. */ - - .text -ENTRY (__syscall_error) - neg %RAX_LP - -#define __syscall_error __syscall_error_1 -#include - -#endif /* !PIC */ diff --git a/sysdeps/unix/x86_64/sysdep.S b/sysdeps/unix/x86_64/sysdep.S deleted file mode 100644 index 2278fce9e4..0000000000 --- a/sysdeps/unix/x86_64/sysdep.S +++ /dev/null @@ -1,49 +0,0 @@ -/* Copyright (C) 2001-2020 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - . */ - -#include -#include -#include - -#if IS_IN (rtld) -# include /* Defines RTLD_PRIVATE_ERRNO. */ -#endif - -.globl C_SYMBOL_NAME(errno) -.globl syscall_error - -__syscall_error: -#if defined (EWOULDBLOCK_sys) && EWOULDBLOCK_sys != EAGAIN - /* We translate the system's EWOULDBLOCK error into EAGAIN. - The GNU C library always defines EWOULDBLOCK==EAGAIN. - EWOULDBLOCK_sys is the original number. */ - cmp $EWOULDBLOCK_sys, %RAX_LP /* Is it the old EWOULDBLOCK? */ - jne notb /* Branch if not. */ - movl $EAGAIN, %eax /* Yes; translate it to EAGAIN. */ -notb: -#endif -#ifdef PIC - movq C_SYMBOL_NAME(errno@GOTTPOFF)(%rip), %rcx - movl %eax, %fs:0(%rcx) -#else - movl %eax, %fs:C_SYMBOL_NAME(errno@TPOFF) -#endif - or $-1, %RAX_LP - ret - -#undef __syscall_error -END (__syscall_error) From patchwork Mon Nov 9 20:18:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 40994 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 16CE5397308E; Mon, 9 Nov 2020 20:19:00 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 16CE5397308E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1604953140; bh=9R6zYH6Keq9LU9J1DEnIDv7FEiLaBiIsIurLXE1EvW4=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=c2GZWZTMuitwMxgOvuAl1iIJH3KJ0tdKOx9YX5oQmZowGh6eAbng+YW+lY53LOM/x mQXs+iamAsHFXbAu5uAVvfnLsm3uwLoHMEVB/PFXVHK0dX5YtziTRhBzmXcbThJxMg K3UTPs4lIzEUEF8GpicyjtXXNhyRxF26fIhw7V8o= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-qt1-x82d.google.com (mail-qt1-x82d.google.com [IPv6:2607:f8b0:4864:20::82d]) by sourceware.org (Postfix) with ESMTPS id 3DFFB3973072 for ; Mon, 9 Nov 2020 20:18:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 3DFFB3973072 Received: by mail-qt1-x82d.google.com with SMTP id v11so6583547qtq.12 for ; Mon, 09 Nov 2020 12:18:56 -0800 (PST) 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:mime-version:content-transfer-encoding; bh=9R6zYH6Keq9LU9J1DEnIDv7FEiLaBiIsIurLXE1EvW4=; b=j5sfeE9d2ClZf16skPIR1s6f5mdc639UV7AMYsH2YViYfDFSIGvWUBmXRi/lNNUEy4 cvd7e7LAYBRiPZ9up3gdYeH5dswUaNpsVkXA5G0ydyd8FmZQdiCEmfn7YdK0iLeZVs11 Jh9rQfPsIxtGq8ldSKC4VkE+M4iMdrZJKTo5/qOJISGSXkSQRAiHuBc/dKsX6fgoeBlz XSl11ndGQLijsYN4eiw68xGNIhqhl3mLnbtH0JS705gqL5R8P4OWTYL48aS5rhdGvkjV aE1AZOIZ6wDOH3Z+K+GtkiczgleGT7xw7NYgqmgeGq1X4qot72JDSVE8C1Jt6aqzm86Y TIkQ== X-Gm-Message-State: AOAM532SabJ5TVEbwlKPX7ENR+YbEsVIkiKORx94sCwoDsNRvI1a+YI7 1vdmNNRNfVE2RQDca0anDj59Aqn0EHRE3g== X-Google-Smtp-Source: ABdhPJwNfyp25dARK0hJnHz7Yjhby4CVl8XYMVBM7ugxQ5M7nyEfRq5TkKulbjferlh+i4qdWpY0Mg== X-Received: by 2002:ac8:6898:: with SMTP id m24mr15121332qtq.157.1604953135476; Mon, 09 Nov 2020 12:18:55 -0800 (PST) Received: from localhost.localdomain ([177.194.48.209]) by smtp.googlemail.com with ESMTPSA id z2sm6843407qkl.22.2020.11.09.12.18.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Nov 2020 12:18:55 -0800 (PST) To: libc-alpha@sourceware.org Subject: [PATCH 14/23] linux: Use generic __syscall_error for s390 Date: Mon, 9 Nov 2020 17:18:17 -0300 Message-Id: <20201109201826.120534-15-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201109201826.120534-1-adhemerval.zanella@linaro.org> References: <20201109201826.120534-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-13.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_NUMSUBJECT, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, URIBL_BLACK autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Adhemerval Zanella via Libc-alpha From: Adhemerval Zanella Netto Reply-To: Adhemerval Zanella Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" The auto-generated syscalls issue the __syscall_error only for static objects, so an arch specific syscall_error is added. However the size of using inline __syscall_error is slight better even for static case: --- size-fstatat64.inline +++ size-fstatat64.outline @@ -1,2 +1,2 @@ text data bss dec hex filename - 120 0 0 120 78 io/fstatat64.o + 128 0 0 128 80 io/fstatat64.o For shared objects the inline syscall generates slight large code (specially for libc.so). --- sizes-s390x-linux-gnu.outline +++ sizes-s390x-linux-gnu.inline text data bss dec hex filename -1755806 20232 14544 1790582 1b5276 libc.so - 169705 6696 336 176737 2b261 elf/ld.so - 111982 1664 16680 130326 1fd16 nptl/libpthread.so - 29703 1132 2296 33131 816b rt/librt.so +1756334 20232 14544 1791110 1b5486 libc.so + 169385 6696 336 176417 2b121 elf/ld.so + 112198 1664 16680 130542 1fdee nptl/libpthread.so + 29719 1132 2296 33147 817b rt/librt.so Checked on s390x-linux-gnu and s390-linux-gnu. --- sysdeps/s390/nptl/Makefile | 5 -- sysdeps/unix/sysv/linux/s390/Makefile | 5 -- sysdeps/unix/sysv/linux/s390/rt-sysdep.S | 1 - sysdeps/unix/sysv/linux/s390/s390-32/sysdep.S | 74 ------------------ sysdeps/unix/sysv/linux/s390/s390-64/sysdep.S | 75 ------------------- sysdeps/unix/sysv/linux/s390/syscall_error.c | 5 ++ 6 files changed, 5 insertions(+), 160 deletions(-) delete mode 100644 sysdeps/unix/sysv/linux/s390/rt-sysdep.S delete mode 100644 sysdeps/unix/sysv/linux/s390/s390-32/sysdep.S delete mode 100644 sysdeps/unix/sysv/linux/s390/s390-64/sysdep.S create mode 100644 sysdeps/unix/sysv/linux/s390/syscall_error.c diff --git a/sysdeps/s390/nptl/Makefile b/sysdeps/s390/nptl/Makefile index d34cb27699..7869dd571c 100644 --- a/sysdeps/s390/nptl/Makefile +++ b/sysdeps/s390/nptl/Makefile @@ -18,8 +18,3 @@ ifeq ($(subdir),csu) gen-as-const-headers += tcb-offsets.sym endif - -ifeq ($(subdir),nptl) -libpthread-routines += sysdep -libpthread-shared-only-routines += sysdep -endif diff --git a/sysdeps/unix/sysv/linux/s390/Makefile b/sysdeps/unix/sysv/linux/s390/Makefile index d9db1b5422..0d88f8d7ff 100644 --- a/sysdeps/unix/sysv/linux/s390/Makefile +++ b/sysdeps/unix/sysv/linux/s390/Makefile @@ -2,11 +2,6 @@ abi-variants := 32 64 abi-32-condition := __WORDSIZE == 32 abi-64-condition := __WORDSIZE == 64 -ifeq ($(subdir),rt) -librt-routines += rt-sysdep -librt-shared-only-routines += rt-sysdep -endif - ifeq ($(subdir),stdlib) gen-as-const-headers += ucontext_i.sym endif diff --git a/sysdeps/unix/sysv/linux/s390/rt-sysdep.S b/sysdeps/unix/sysv/linux/s390/rt-sysdep.S deleted file mode 100644 index f966bf1e59..0000000000 --- a/sysdeps/unix/sysv/linux/s390/rt-sysdep.S +++ /dev/null @@ -1 +0,0 @@ -#include diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/sysdep.S b/sysdeps/unix/sysv/linux/s390/s390-32/sysdep.S deleted file mode 100644 index f8a6b7901d..0000000000 --- a/sysdeps/unix/sysv/linux/s390/s390-32/sysdep.S +++ /dev/null @@ -1,74 +0,0 @@ -/* Copyright (C) 2000-2020 Free Software Foundation, Inc. - Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com). - 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 - -/* The following code is only used in the shared library when we - compile the reentrant version. Otherwise each system call defines - each own version. */ - -/* The syscall stubs jump here when they detect an error. */ - -#undef CALL_MCOUNT -#define CALL_MCOUNT - - .text -ENTRY(__syscall_error) -#ifndef PIC -# if IS_IN (libc) -# define SYSCALL_ERROR_ERRNO __libc_errno -# else -# define SYSCALL_ERROR_ERRNO errno -# endif - basr %r1,0 -0: l %r1,1f-0b(%r1) - ear %r3,%a0 - lcr %r2,%r2 - st %r2,0(%r1,%r3) - lhi %r2,-1 - br %r14 -1: .long SYSCALL_ERROR_ERRNO@ntpoff -#else -# if RTLD_PRIVATE_ERRNO - basr %r1,0 -0: al %r1,1f-0b(%r1) - lcr %r2,%r2 - st %r2,0(%r1) - lhi %r2,-1 - br %r14 -1: .long rtld_errno - 0b -# else -# if IS_IN (libc) -# define SYSCALL_ERROR_ERRNO __libc_errno -# else -# define SYSCALL_ERROR_ERRNO errno -# endif - basr %r1,0 -0: al %r1,1f-0b(%r1) - ear %r3,%a0 - l %r1,SYSCALL_ERROR_ERRNO@gotntpoff(%r1) - lcr %r2,%r2 - st %r2,0(%r1,%r3) - lhi %r2,-1 - br %r14 -1: .long _GLOBAL_OFFSET_TABLE_-0b -# endif -#endif - -END (__syscall_error) diff --git a/sysdeps/unix/sysv/linux/s390/s390-64/sysdep.S b/sysdeps/unix/sysv/linux/s390/s390-64/sysdep.S deleted file mode 100644 index 98c8dd3913..0000000000 --- a/sysdeps/unix/sysv/linux/s390/s390-64/sysdep.S +++ /dev/null @@ -1,75 +0,0 @@ -/* Copyright (C) 2001-2020 Free Software Foundation, Inc. - Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com). - 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 - - -/* The following code is only used in the shared library when we - compile the reentrant version. Otherwise each system call defines - each own version. */ - -/* The syscall stubs jump here when they detect an error. */ - -#undef CALL_MCOUNT -#define CALL_MCOUNT - -.text -ENTRY(__syscall_error) -#ifndef PIC -# if IS_IN (libc) -# define SYSCALL_ERROR_ERRNO __libc_errno -# else -# define SYSCALL_ERROR_ERRNO errno -# endif - basr %r1,0 -0: lg %r1,1f-0b(%r1) - ear %r3,%a0 - sllg %r3,%r3,32 - ear %r3,%a1 - lcr %r2,%r2 - st %r2,0(%r1,%r3) - lghi %r2,-1 - br %r14 -1: .quad SYSCALL_ERROR_ERRNO@ntpoff -#else -# if RTLD_PRIVATE_ERRNO - larl %r1,rtld_errno - lcr %r2,%r2 - st %r2,0(%r1) - lghi %r2,-1 - br %r14 -# else -# if IS_IN (libc) -# define SYSCALL_ERROR_ERRNO __libc_errno -# else -# define SYSCALL_ERROR_ERRNO errno -# endif - larl %r1,_GLOBAL_OFFSET_TABLE_ - lg %r1,SYSCALL_ERROR_ERRNO@gotntpoff(%r1) - ear %r3,%a0 - sllg %r3,%r3,32 - ear %r3,%a1 - lcr %r2,%r2 - st %r2,0(%r1,%r3) - lghi %r2,-1 - br %r14 -# endif -#endif - -END (__syscall_error) diff --git a/sysdeps/unix/sysv/linux/s390/syscall_error.c b/sysdeps/unix/sysv/linux/s390/syscall_error.c new file mode 100644 index 0000000000..40528f8ae9 --- /dev/null +++ b/sysdeps/unix/sysv/linux/s390/syscall_error.c @@ -0,0 +1,5 @@ +/* The auto-generated syscalls calls __syscall_error for static objects. */ +#ifndef SHARED +# define SYSCALL_ERROR_FUNC +#endif +#include From patchwork Mon Nov 9 20:18:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 40995 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 1DC5339730A4; Mon, 9 Nov 2020 20:19:01 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1DC5339730A4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1604953141; bh=coemqb/z0cZupdX9MjHeXnTYM8yyRJM/ZScl0OPZqnU=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=sJqI/iJeidwPeFV17nOBuPepg6Af0DwKwr2YgRzfGHldBZbX+hAQNgs1NhNU4LX9X 0h1HHLyVXbzhvexauv+9mu8XlysKChDFMLcfDThVKhmqZnQ5IT/+5hXHY9vRpZl5SL ssIoQoGDHTv3rAj48otVWeOFDHWenhA7nP0YVKD8= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-qt1-x831.google.com (mail-qt1-x831.google.com [IPv6:2607:f8b0:4864:20::831]) by sourceware.org (Postfix) with ESMTPS id A9B733972800 for ; Mon, 9 Nov 2020 20:18:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org A9B733972800 Received: by mail-qt1-x831.google.com with SMTP id p12so6967782qtp.7 for ; Mon, 09 Nov 2020 12:18:57 -0800 (PST) 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:mime-version:content-transfer-encoding; bh=coemqb/z0cZupdX9MjHeXnTYM8yyRJM/ZScl0OPZqnU=; b=BLHAcNAvPGyvsfoWNz5ct1GuBf2tcPPqA53Jul+Wd2rJlrpZebofK+UVD2TeJVaNvn LzkRdMeCOS6GXG6wFh2ps5PECh5qlHfSLjJgTs/sH3Y5Hhyyd6uzkHZkGAUTV32vj+nr dILvEiu3dWHCCp/07PMEMX+R4K+r3Tp19YY9mgGmt3DsAitQOMCCBAEn1uh7pGbyBGIC UA7WwUe4ZT6yWELxbXIHv3qz+PU02kvTFMH/hXOSoiRLkrwFlsEVLDU17wJ2Cue1Ylk6 T6jqp99loLexvVzu+dUWfKQQLvygt+eiMWhiji51sSOPeHQW4OgsoXWr1HWplp8B6L0y 9ACQ== X-Gm-Message-State: AOAM531v4Y9m/XVpz4as7GtW7irAOD+eim3NhAH34I0jEAdPrBWUVGWO YF0Vh0mm/Y71/JGOTC1x4Aeiut8QrX30aw== X-Google-Smtp-Source: ABdhPJzNKM2ZAOAzW5Kgm37vGybjzmVVkNE2cNDx3RAHQal0rV1Suh1oXO8rUoXJPRSAWv7UfzRJbA== X-Received: by 2002:ac8:b87:: with SMTP id h7mr14767427qti.87.1604953136862; Mon, 09 Nov 2020 12:18:56 -0800 (PST) Received: from localhost.localdomain ([177.194.48.209]) by smtp.googlemail.com with ESMTPSA id z2sm6843407qkl.22.2020.11.09.12.18.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Nov 2020 12:18:56 -0800 (PST) To: libc-alpha@sourceware.org Subject: [PATCH 15/23] linux: Use generic __syscall_error for sh Date: Mon, 9 Nov 2020 17:18:18 -0300 Message-Id: <20201109201826.120534-16-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201109201826.120534-1-adhemerval.zanella@linaro.org> References: <20201109201826.120534-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, KAM_STOCKGEN, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, URIBL_BLACK autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Adhemerval Zanella via Libc-alpha From: Adhemerval Zanella Netto Reply-To: Adhemerval Zanella Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" Although the auto-generated syscall sets errno directly for dynamic case, using a function call generates more compact code: --- sizes-sh4-linux-gnu.outline +++ sizes-sh4-linux-gnu.inline text data bss dec hex filename -1242446 9948 9240 1261634 134042 libc.so - 122480 3764 176 126420 1edd4 elf/ld.so - 91548 804 8348 100700 1895c nptl/libpthread.so - 23613 608 160 24381 5f3d rt/librt.so +1244638 9948 9240 1263826 1348d2 libc.so + 122416 3764 176 126356 1ed94 elf/ld.so + 91460 804 8348 100612 18904 nptl/libpthread.so + 23805 608 160 24573 5ffd rt/librt.so It also removes the PLT call done by the generic unix syscall.S which calls __errno_location instead of the accessing it directly (as done by C implementation through syscall_error.c). Checked with some basic tests to see if errno is set correctly on both static and dynamic binaries with auto-generated syscals and C implementation (which uses INTERNAL_SYSCALL_CALL). --- sysdeps/unix/sh/sysdep.S | 115 ----------------------- sysdeps/unix/sysv/linux/sh/localplt.data | 1 - sysdeps/unix/sysv/linux/sh/sysdep.S | 32 ------- sysdeps/unix/sysv/linux/sh/sysdep.h | 2 + 4 files changed, 2 insertions(+), 148 deletions(-) delete mode 100644 sysdeps/unix/sh/sysdep.S delete mode 100644 sysdeps/unix/sysv/linux/sh/sysdep.S diff --git a/sysdeps/unix/sh/sysdep.S b/sysdeps/unix/sh/sysdep.S deleted file mode 100644 index dc9a230ee0..0000000000 --- a/sysdeps/unix/sh/sysdep.S +++ /dev/null @@ -1,115 +0,0 @@ -/* Copyright (C) 1999-2020 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - . */ - -#include -#include - -ENTRY(__syscall_error) -#if defined (EWOULDBLOCK_sys) && EWOULDBLOCK_sys != EAGAIN - /* We translate the system's EWOULDBLOCK error into EAGAIN. - The GNU C library always defines EWOULDBLOCK==EAGAIN. - EWOULDBLOCK_sys is the original number. */ - mov.l .L1, r1 - cmp/eq r1, r0 - bf skip - nop - mov.l .L2, r0 -skip: -#endif - /* Store it in errno... */ -#ifndef SHARED -#ifndef _LIBC_REENTRANT - mov.l .L3, r1 - mov.l r0, @r1 -#else - mov.l .L3, r1 - sts.l pr, @-r15 - cfi_adjust_cfa_offset (4) - cfi_rel_offset (pr, 0) - mov.l r0, @-r15 - cfi_adjust_cfa_offset (4) - jsr @r1 - nop - mov.l @r15+, r1 - cfi_adjust_cfa_offset (-4) - lds.l @r15+, pr - cfi_adjust_cfa_offset (-4) - cfi_restore (pr) - mov.l r1, @r0 -#endif -#else - mov.l r12, @-r15 - cfi_adjust_cfa_offset (4) - cfi_rel_offset (r12, 0) -#ifndef _LIBC_REENTRANT - mov r0, r2 - mov.l 0f, r12 - mova 0f, r0 - add r0, r12 - mov.l .L3, r0 - mov.l @(r0,r12), r1 - mov.l r2, @r1 -#else - mov.l r0, @-r15 - cfi_adjust_cfa_offset (4) - sts.l pr, @-r15 - cfi_adjust_cfa_offset (4) - cfi_rel_offset (pr, 0) - mov.l 0f, r12 - mova 0f, r0 - add r0, r12 - mov.l .L3, r1 - mova .L3, r0 - add r0, r1 - jsr @r1 - nop - lds.l @r15+, pr - cfi_adjust_cfa_offset (-4) - cfi_restore (pr) - mov.l @r15+, r1 - cfi_adjust_cfa_offset (-4) - mov.l r1, @r0 -#endif - mov.l @r15+, r12 - cfi_adjust_cfa_offset (-4) - cfi_restore (r12) -#endif - /* And just kick back a -1. */ - rts - mov #-1, r0 - - .align 2 -#if defined (EWOULDBLOCK_sys) && EWOULDBLOCK_sys != EAGAIN -.L1: .long EWOULDBLOCK_sys -.L2: .long EAGAIN -#endif -#ifndef SHARED -#ifndef _LIBC_REENTRANT -.L3: .long C_SYMBOL_NAME(errno) -#else -.L3: .long C_SYMBOL_NAME(__errno_location) -#endif -#else -0: - .long _GLOBAL_OFFSET_TABLE_ -#ifndef _LIBC_REENTRANT -.L3: .long C_SYMBOL_NAME(errno@GOT) -#else -.L3: .long C_SYMBOL_NAME(__errno_location@PLT) -#endif -#endif -END(__syscall_error) diff --git a/sysdeps/unix/sysv/linux/sh/localplt.data b/sysdeps/unix/sysv/linux/sh/localplt.data index 3225177c50..9d8154648b 100644 --- a/sysdeps/unix/sysv/linux/sh/localplt.data +++ b/sysdeps/unix/sysv/linux/sh/localplt.data @@ -8,7 +8,6 @@ libc.so: memalign libc.so: realloc libc.so: _Unwind_Find_FDE libc.so: _exit -libc.so: __errno_location libm.so: matherr # Generated by the compiler because there is no trap insn pattern. libc.so: abort ? diff --git a/sysdeps/unix/sysv/linux/sh/sysdep.S b/sysdeps/unix/sysv/linux/sh/sysdep.S deleted file mode 100644 index 85ff3f900e..0000000000 --- a/sysdeps/unix/sysv/linux/sh/sysdep.S +++ /dev/null @@ -1,32 +0,0 @@ -/* Copyright (C) 1995-2020 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - . */ - -#include - -/* The syscall stubs jump here when they detect an error. - The code for Linux is almost identical to the canonical Unix - code, except that the error number in R0 is negated. */ - -#undef CALL_MCOUNT -#define CALL_MCOUNT /* Don't insert the profiling call, it clobbers R0. */ - -ENTRY (__syscall_error) - neg r4, r0 - cfi_endproc - -#define __syscall_error __syscall_error_1 -#include diff --git a/sysdeps/unix/sysv/linux/sh/sysdep.h b/sysdeps/unix/sysv/linux/sh/sysdep.h index 60a5032ce4..511406b5dc 100644 --- a/sysdeps/unix/sysv/linux/sh/sysdep.h +++ b/sysdeps/unix/sysv/linux/sh/sysdep.h @@ -20,6 +20,8 @@ #ifndef _LINUX_SH_SYSDEP_H #define _LINUX_SH_SYSDEP_H 1 +#define SYSCALL_ERROR_FUNC + /* There is some commonality. */ #include #include From patchwork Mon Nov 9 20:18:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 40996 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A0DB639730AE; Mon, 9 Nov 2020 20:19:01 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A0DB639730AE DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1604953141; bh=LTpERs/IStPPoHYMeQh1+/oO6sAXSJ6wLj24t6fmhG8=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=mapHL8DoH8DTQADqr9kZ/a0Zh5kpR/Vuxa2iN/xdwvo7cZ7nwHN0oVwY+Afag/ojz JmHigWJrddsGfl8FpTpyGzBrUw96KiBoYnxej4ICNxaXD7AtW8/j5IHoApG7xVnQG3 2dMCLysBymbsL6I0fe/8V4q9Xg07C04nESeTV/vg= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-qt1-x841.google.com (mail-qt1-x841.google.com [IPv6:2607:f8b0:4864:20::841]) by sourceware.org (Postfix) with ESMTPS id C7C9E3973081 for ; Mon, 9 Nov 2020 20:18:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org C7C9E3973081 Received: by mail-qt1-x841.google.com with SMTP id i7so6964233qti.6 for ; Mon, 09 Nov 2020 12:18:58 -0800 (PST) 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:mime-version:content-transfer-encoding; bh=LTpERs/IStPPoHYMeQh1+/oO6sAXSJ6wLj24t6fmhG8=; b=fE6AIfyldyhzwd/3jJFKAxPw1goYXGk+XFTFlR538HIHbAiHsZdLAHRzwRkKHYQV6g AN58abFoIIIOiqpXgQZJ0OLq2+kDmry9PrUAXfOqCB6ZCFYivCwvxHTrX5kvlDLbEE46 l34NZhuP5207WKhkHG340B+ZQFWzU8e+d8ESMjtsNX5p0LfpvT2DduaqrvnYHKgm5Ffa HIn7APEBpL0rTIIyordfanFTYGcUPXe43z8mEdscAVAzZ8Z/XOlYWQdT/9UcFzFgI/ti nO0nv+umhmHTwCPFvsQvxfcS1bUzDSbTydIUWE9OnRsup/SaCxckeVlzSDCEe4ihhUgH O96Q== X-Gm-Message-State: AOAM530epgqfeLp37vtRoq8B2m+KOJbPayVJsn8fJT8AHFo3Q2p5yMyP OMYH8QxqO8SZNq6MxLivufS/9jdcr73OeQ== X-Google-Smtp-Source: ABdhPJz92ZE0YEPjJXHwOWoV0F8HlzfWVIxb7CeLMgZ24O+SISXG6uHi0OXYYnnESQyFxgF3E8Cwyg== X-Received: by 2002:ac8:23fb:: with SMTP id r56mr14386154qtr.371.1604953138193; Mon, 09 Nov 2020 12:18:58 -0800 (PST) Received: from localhost.localdomain ([177.194.48.209]) by smtp.googlemail.com with ESMTPSA id z2sm6843407qkl.22.2020.11.09.12.18.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Nov 2020 12:18:57 -0800 (PST) To: libc-alpha@sourceware.org Subject: [PATCH 16/23] linux: Use generic __syscall_error for microblaze Date: Mon, 9 Nov 2020 17:18:19 -0300 Message-Id: <20201109201826.120534-17-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201109201826.120534-1-adhemerval.zanella@linaro.org> References: <20201109201826.120534-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-13.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, URIBL_BLACK autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Adhemerval Zanella via Libc-alpha From: Adhemerval Zanella Netto Reply-To: Adhemerval Zanella Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" Although the auto-generated syscall sets errno directly for dynamic case, using a function call generates more compact code: --- sizes-microblaze-linux-gnu.inline +++ sizes-microblaze-linux-gnu.outline text data bss dec hex filename -1835305 52738 9216 1897259 1cf32b libc.so - 188644 7236 176 196056 2fdd8 elf/ld.so - 121772 5872 8356 136000 21340 nptl/libpthread.so - 30836 1724 160 32720 7fd0 rt/librt.so +1831025 52714 9216 1892955 1ce25b libc.so + 188904 7240 176 196320 2fee0 elf/ld.so + 121540 5864 8356 135760 21250 nptl/libpthread.so + 30640 1720 160 32520 7f08 rt/librt.so Checked with a cross make check for microblaze-linux-gnu. --- sysdeps/unix/sysv/linux/microblaze/Makefile | 6 ---- sysdeps/unix/sysv/linux/microblaze/sysdep.S | 39 --------------------- sysdeps/unix/sysv/linux/microblaze/sysdep.h | 2 ++ 3 files changed, 2 insertions(+), 45 deletions(-) delete mode 100644 sysdeps/unix/sysv/linux/microblaze/sysdep.S diff --git a/sysdeps/unix/sysv/linux/microblaze/Makefile b/sysdeps/unix/sysv/linux/microblaze/Makefile index d178bc6f34..614553204f 100644 --- a/sysdeps/unix/sysv/linux/microblaze/Makefile +++ b/sysdeps/unix/sysv/linux/microblaze/Makefile @@ -1,9 +1,3 @@ ifeq ($(subdir),resource) sysdep_routines += backtrace_linux endif - -ifeq ($(subdir),nptl) -# pull in __syscall_error routine -libpthread-routines += sysdep -libpthread-shared-only-routines += sysdep -endif diff --git a/sysdeps/unix/sysv/linux/microblaze/sysdep.S b/sysdeps/unix/sysv/linux/microblaze/sysdep.S deleted file mode 100644 index c3157880d8..0000000000 --- a/sysdeps/unix/sysv/linux/microblaze/sysdep.S +++ /dev/null @@ -1,39 +0,0 @@ -/* Copyright (C) 2009-2020 Free Software Foundation, Inc. - - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public License as - published by the Free Software Foundation; either version 2.1 of the - License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - . */ - -#include - - -/* The following code is only used in the shared library when we - compile the reentrant version. Otherwise each system call defines - each own version. */ - -#ifndef PIC - -/* The syscall stubs jump here when they detect an error. */ - -# undef CALL_MCOUNT -# define CALL_MCOUNT /* Don't insert the profiling call, it clobbers %d0. */ - - .text -ENTRY (__syscall_error) - rsubk r3,r3,r0 - rtsd r15,8 - addik r3,r0,-1 /* delay slot. */ -END (__syscall_error) -#endif /* PIC. */ diff --git a/sysdeps/unix/sysv/linux/microblaze/sysdep.h b/sysdeps/unix/sysv/linux/microblaze/sysdep.h index 6fd96adbf0..2beaba9247 100644 --- a/sysdeps/unix/sysv/linux/microblaze/sysdep.h +++ b/sysdeps/unix/sysv/linux/microblaze/sysdep.h @@ -19,6 +19,8 @@ #ifndef _LINUX_MICROBLAZE_SYSDEP_H #define _LINUX_MICROBLAZE_SYSDEP_H 1 +#define SYSCALL_ERROR_FUNC + #include #include #include From patchwork Mon Nov 9 20:18:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 40997 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 314DD397306D; Mon, 9 Nov 2020 20:19:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 314DD397306D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1604953143; bh=wjP8ci4O1Y0ir56v74MAt0XOwh2pQomJOkouxEhKuzc=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=mWDMhmI0d8eHDc7+ZIlE6ycaWcC1gB4nEDWvJXL5AzFTQRgz7GeOcapA9+pnulONZ sXOInQ+5qyH5QpT1OrezDChQDA2QktSstBPzJDDDg1yHFZgio+hIcgfOQDptDVinQY cqCnk3lSEC5AtnEQvLw3H41MY1lkyWmbC8OQ92tE= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-qt1-x842.google.com (mail-qt1-x842.google.com [IPv6:2607:f8b0:4864:20::842]) by sourceware.org (Postfix) with ESMTPS id 365D13973096 for ; Mon, 9 Nov 2020 20:19:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 365D13973096 Received: by mail-qt1-x842.google.com with SMTP id h12so6962133qtc.9 for ; Mon, 09 Nov 2020 12:19:00 -0800 (PST) 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:mime-version:content-transfer-encoding; bh=wjP8ci4O1Y0ir56v74MAt0XOwh2pQomJOkouxEhKuzc=; b=GrRRYCeLnpijOAFEJWO01Xumlq4HGYzx3IyJyOkY7ugQN1I6M31Cjh74DrwSd4wY3z SYGYQqhXpUU3DQZKAtp0dW6oK/utIYLsnFYstZae/ExKqO/nnbsGQGqSD0l92QnpX4Ha u2fCFn7OjzFYrB4c2wqTkAPDT1bTPth+7nKLR8bBSXVcddKq7h6PHj7XhkN60zy7ro5C o4QS/XHBSpHElwh8r4z+MZFLPbGPoPHEtPWJyS/CI48aWbpdtJuNDne+sdoIsxlQ07gW h7td9mlc+8SHfas7o+54phrlKDSFSaYCMGfBboOb4e5AE4TdRs5bvLHQ5qa9kT0OOkvq nE0Q== X-Gm-Message-State: AOAM532/aq05hzBjJN/TippNzEWDcAekLjqXG8j780W7Hx3SFei5dfO6 7T+nNPJNEB9GEKcCI9zmrNwQTEtPH6WXuQ== X-Google-Smtp-Source: ABdhPJxr7hyX7BLauy0tsu45BP0SLh6p0PSBvOx49fH7OMLNAeOS0kq3hugnuBe4dmHIqEt7OAGGnw== X-Received: by 2002:aed:2aa2:: with SMTP id t31mr4492853qtd.375.1604953139510; Mon, 09 Nov 2020 12:18:59 -0800 (PST) Received: from localhost.localdomain ([177.194.48.209]) by smtp.googlemail.com with ESMTPSA id z2sm6843407qkl.22.2020.11.09.12.18.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Nov 2020 12:18:59 -0800 (PST) To: libc-alpha@sourceware.org Subject: [PATCH 17/23] linux: Use generic __syscall_error for ia64 Date: Mon, 9 Nov 2020 17:18:20 -0300 Message-Id: <20201109201826.120534-18-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201109201826.120534-1-adhemerval.zanella@linaro.org> References: <20201109201826.120534-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-13.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_NUMSUBJECT, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, URIBL_BLACK autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Adhemerval Zanella via Libc-alpha From: Adhemerval Zanella Netto Reply-To: Adhemerval Zanella Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" Although the auto-generated syscall issues __syscall_errno, using an inline function generates much more compact code: --- sizes-ia64-linux-gnu.inline +++ sizes-ia64-linux-gnu.outline text data bss dec hex filename -2940053 20776 14424 2975253 2d6615 libc.so - 301887 23190 1968 327045 4fd85 elf/ld.so - 203203 2472 16640 222315 3646b nptl/libpthread.so - 47153 1764 2272 51189 c7f5 rt/librt.so +2947445 20776 14424 2982645 2d82f5 libc.so + 302591 23190 1968 327749 50045 elf/ld.so + 204987 2472 16640 224099 36b63 nptl/libpthread.so + 47609 1764 2272 51645 c9bd rt/librt.so Checked with a cross make check for ia64-linux-gnu. --- sysdeps/ia64/nptl/Makefile | 5 -- sysdeps/unix/sysv/linux/ia64/Makefile | 5 -- sysdeps/unix/sysv/linux/ia64/rt-sysdep.S | 1 - sysdeps/unix/sysv/linux/ia64/syscall_error.c | 3 + sysdeps/unix/sysv/linux/ia64/sysdep.S | 58 -------------------- 5 files changed, 3 insertions(+), 69 deletions(-) delete mode 100644 sysdeps/unix/sysv/linux/ia64/rt-sysdep.S create mode 100644 sysdeps/unix/sysv/linux/ia64/syscall_error.c delete mode 100644 sysdeps/unix/sysv/linux/ia64/sysdep.S diff --git a/sysdeps/ia64/nptl/Makefile b/sysdeps/ia64/nptl/Makefile index d34cb27699..7869dd571c 100644 --- a/sysdeps/ia64/nptl/Makefile +++ b/sysdeps/ia64/nptl/Makefile @@ -18,8 +18,3 @@ ifeq ($(subdir),csu) gen-as-const-headers += tcb-offsets.sym endif - -ifeq ($(subdir),nptl) -libpthread-routines += sysdep -libpthread-shared-only-routines += sysdep -endif diff --git a/sysdeps/unix/sysv/linux/ia64/Makefile b/sysdeps/unix/sysv/linux/ia64/Makefile index 97fc7df0b1..57917e78db 100644 --- a/sysdeps/unix/sysv/linux/ia64/Makefile +++ b/sysdeps/unix/sysv/linux/ia64/Makefile @@ -17,11 +17,6 @@ ifeq ($(subdir),elf) sysdep-dl-routines += dl-static endif -ifeq ($(subdir),rt) -librt-routines += rt-sysdep -librt-shared-only-routines += rt-sysdep -endif - ifeq ($(subdir),nptl) libpthread-sysdep_routines += __ia64_longjmp unwind_longjmp __sigstack_longjmp endif diff --git a/sysdeps/unix/sysv/linux/ia64/rt-sysdep.S b/sysdeps/unix/sysv/linux/ia64/rt-sysdep.S deleted file mode 100644 index f966bf1e59..0000000000 --- a/sysdeps/unix/sysv/linux/ia64/rt-sysdep.S +++ /dev/null @@ -1 +0,0 @@ -#include diff --git a/sysdeps/unix/sysv/linux/ia64/syscall_error.c b/sysdeps/unix/sysv/linux/ia64/syscall_error.c new file mode 100644 index 0000000000..60fa99a158 --- /dev/null +++ b/sysdeps/unix/sysv/linux/ia64/syscall_error.c @@ -0,0 +1,3 @@ +/* The auto-generated syscalls calls __syscall_error. */ +#define SYSCALL_ERROR_FUNC +#include diff --git a/sysdeps/unix/sysv/linux/ia64/sysdep.S b/sysdeps/unix/sysv/linux/ia64/sysdep.S deleted file mode 100644 index 75fc3d6456..0000000000 --- a/sysdeps/unix/sysv/linux/ia64/sysdep.S +++ /dev/null @@ -1,58 +0,0 @@ -/* Copyright (C) 1999-2020 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by David Mosberger-Tang . - - 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 - -ENTRY(__syscall_error) -#if RTLD_PRIVATE_ERRNO - /* - * Note that the gp has to be set properly for this to work. - * As long as all syscalls are in the same load unit - * (executable or shared library) as this routine, we should - * be fine. Otherwise, we would have to first load the global - * pointer register from __gp. - */ - addl r2=@gprel(rtld_errno),gp - ;; - st4 [r2]=r8 - mov r8=-1 -#else -# if IS_IN (libc) -# define SYSCALL_ERROR_ERRNO __libc_errno -# else -# define SYSCALL_ERROR_ERRNO errno -# endif - addl r2=@ltoff(@tprel(SYSCALL_ERROR_ERRNO)), gp;; - ld8 r2=[r2] - mov r3=r8;; - mov r8=-1 - add r2=r2,r13;; - st4 [r2]=r3 -#endif - ret // ret is #define'd in syscall.h! -END(__syscall_error) - -ENTRY(__ia64_syscall) - mov r15=r37 /* syscall number */ - break __IA64_BREAK_SYSCALL - cmp.eq p6,p0=-1,r10 /* r10 = -1 on error */ -(p6) br.cond.spnt.few __syscall_error - ret -PSEUDO_END(__ia64_syscall) From patchwork Mon Nov 9 20:18:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 40998 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 1A934397305F; Mon, 9 Nov 2020 20:19:05 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1A934397305F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1604953145; bh=4Fqj3uzk2ptlKVB4mKaKcs7Yb0NVR+EgWT8QaRwfCGU=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=AYg6Io25zf7atdtX0Uz+Z7eK/3SDpo3Uq1w0Q0kb2cMqAQV13vkaVUH5DQZ/WqJFb 2sBAy62B81aZCT9rgsFfF0yEL6FC/bzS21hapmeI9XJeOFqqFMfqm905SJNT2QDcH3 IBfttEjrStkqGJab2rjEUqvFOt7Qm9TQGwvMXi7Q= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-qt1-x844.google.com (mail-qt1-x844.google.com [IPv6:2607:f8b0:4864:20::844]) by sourceware.org (Postfix) with ESMTPS id 8CA1839730A9 for ; Mon, 9 Nov 2020 20:19:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 8CA1839730A9 Received: by mail-qt1-x844.google.com with SMTP id 7so2589253qtp.1 for ; Mon, 09 Nov 2020 12:19:01 -0800 (PST) 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:mime-version:content-transfer-encoding; bh=4Fqj3uzk2ptlKVB4mKaKcs7Yb0NVR+EgWT8QaRwfCGU=; b=Q9+Ko6x9eWQ6r0ugSXIGedX4ZqzG9mdDVZzmrtSHhYhPq1zdiXHzcXPSqRsuPjtBF8 zn2WTpbTT9IPhPhTdLOplqvirQInOnPxdftygrjKItFXdgNyEitzz8zX4nClKeOo4MJO 04AEm1N60+mn5Dc8tngQhWAMfxiVih20QacUT05/FwRhhCZVDXeug+VGxLQEIdUGu6xG 5+x0mQJfDpCQvWm8wdrKY7FZJSnrnvygc22Y8dO9lWusE8N43Srv79flZxCCeJxO+Dls whoaAierhMQvGAVEuSedlXszQZ0Ue05qzDS2ENZnhBeykzqojCboYz+TjLy124uT0wk9 iHqA== X-Gm-Message-State: AOAM531/0frwq/c7VaUnMKtk6nWNef6/IkwhzqzQV6qTa6ia7PoL/ekD ZpyV80ykswzYkjT0qazAyF8tvHpsjbcJhA== X-Google-Smtp-Source: ABdhPJxlN8ejQ5rAYFaaFIBJ8NfQqkaqDYgQb6t2P71Fdx/XIS6x+qavIPg0R44ENvssDgPZ4tZgZA== X-Received: by 2002:aed:38c8:: with SMTP id k66mr14863014qte.385.1604953140903; Mon, 09 Nov 2020 12:19:00 -0800 (PST) Received: from localhost.localdomain ([177.194.48.209]) by smtp.googlemail.com with ESMTPSA id z2sm6843407qkl.22.2020.11.09.12.18.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Nov 2020 12:19:00 -0800 (PST) To: libc-alpha@sourceware.org Subject: [PATCH 18/23] linux: Use generic __syscall_error for m68k Date: Mon, 9 Nov 2020 17:18:21 -0300 Message-Id: <20201109201826.120534-19-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201109201826.120534-1-adhemerval.zanella@linaro.org> References: <20201109201826.120534-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-13.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, URIBL_BLACK autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Adhemerval Zanella via Libc-alpha From: Adhemerval Zanella Netto Reply-To: Adhemerval Zanella Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" Although the auto-generated syscall sets errno directly for dynamic case, using a function call generates more compact code: --- sizes-m68k-linux-gnu.inline +++ sizes-m68k-linux-gnu.outline text data bss dec hex filename -1283686 20376 9304 1313366 140a56 libc.so - 119206 5960 184 125350 1e9a6 elf/ld.so - 87078 1456 8360 96894 17a7e nptl/libpthread.so - 23918 888 160 24966 6186 rt/librt.so +1277602 20376 9304 1307282 13f292 libc.so + 119174 5960 184 125318 1e986 elf/ld.so + 86314 1456 8360 96130 17782 nptl/libpthread.so + 23562 888 160 24610 6022 rt/librt.so Checked with some basic tests to see if errno is set correctly on both static and dynamic binaries with auto-generated syscals and C implementation (which uses INTERNAL_SYSCALL_CALL). --- sysdeps/unix/sysv/linux/m68k/sysdep.S | 50 --------------------------- sysdeps/unix/sysv/linux/m68k/sysdep.h | 11 +++--- 2 files changed, 6 insertions(+), 55 deletions(-) delete mode 100644 sysdeps/unix/sysv/linux/m68k/sysdep.S diff --git a/sysdeps/unix/sysv/linux/m68k/sysdep.S b/sysdeps/unix/sysv/linux/m68k/sysdep.S deleted file mode 100644 index 1313ab17c3..0000000000 --- a/sysdeps/unix/sysv/linux/m68k/sysdep.S +++ /dev/null @@ -1,50 +0,0 @@ -/* Copyright (C) 1996-2020 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library. If not, see - . */ - -#include - - -/* The following code is only used in the shared library when we - compile the reentrant version. Otherwise each system call defines - each own version. */ - -#ifndef PIC - -/* The syscall stubs jump here when they detect an error. */ - -#undef CALL_MCOUNT -#define CALL_MCOUNT /* Don't insert the profiling call, it clobbers %d0. */ - - .text -ENTRY (__syscall_error) - neg.l %d0 -#ifndef _LIBC_REENTRANT - move.l %d0, errno -#else - move.l %d0, -(%sp) - cfi_adjust_cfa_offset (4) - jbsr __errno_location - move.l (%sp)+, (%a0) - cfi_adjust_cfa_offset (-4) -#endif - move.l #-1, %d0 - /* Copy return value to %a0 for syscalls that are declared to - return a pointer. */ - move.l %d0, %a0 - rts -END (__syscall_error) -#endif /* PIC */ diff --git a/sysdeps/unix/sysv/linux/m68k/sysdep.h b/sysdeps/unix/sysv/linux/m68k/sysdep.h index 3e0ab605de..2f59c0a2f4 100644 --- a/sysdeps/unix/sysv/linux/m68k/sysdep.h +++ b/sysdeps/unix/sysv/linux/m68k/sysdep.h @@ -17,6 +17,8 @@ License along with the GNU C Library. If not, see . */ +#define SYSCALL_ERROR_FUNC + #include #include @@ -45,11 +47,7 @@ /* We don't want the label for the error handler to be visible in the symbol table when we define it here. */ #undef SYSCALL_ERROR_LABEL -#ifdef PIC #define SYSCALL_ERROR_LABEL .Lsyscall_error -#else -#define SYSCALL_ERROR_LABEL __syscall_error -#endif #undef PSEUDO #define PSEUDO(name, syscall_name, args) \ @@ -137,7 +135,10 @@ SYSCALL_ERROR_LABEL: \ rts; # endif /* _LIBC_REENTRANT */ #else -# define SYSCALL_ERROR_HANDLER /* Nothing here; code in sysdep.S is used. */ +# define SYSCALL_ERROR_HANDLER \ +SYSCALL_ERROR_LABEL: \ + move.l %d0,4(%sp); \ + bra.l __syscall_error #endif /* PIC */ /* Linux takes system call arguments in registers: From patchwork Mon Nov 9 20:18:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 40999 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 1B95539730B2; Mon, 9 Nov 2020 20:19:06 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1B95539730B2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1604953146; bh=BPWJ6ObjyMApRK1a1jcZfuWj1v05Ec4MX86rzVQ+IYk=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=qD09eYeTVbjGR2NtOhJC8mISgpVC7LeBaUEgRZr4VphnzNfd05H1E2Rp9NEc8lA4q 2L1PQPauzrju9o8rUtGYF4E6jZLFFeXD/jWeTCPflENPisS+oXfGnAnJpFjDOHnC40 76Z3G/gtaoJN8ysT+JGnu408HsN9VGunUQRoejMI= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-qt1-x841.google.com (mail-qt1-x841.google.com [IPv6:2607:f8b0:4864:20::841]) by sourceware.org (Postfix) with ESMTPS id 005B63857C56 for ; Mon, 9 Nov 2020 20:19:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 005B63857C56 Received: by mail-qt1-x841.google.com with SMTP id j31so6952548qtb.8 for ; Mon, 09 Nov 2020 12:19:02 -0800 (PST) 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:mime-version:content-transfer-encoding; bh=BPWJ6ObjyMApRK1a1jcZfuWj1v05Ec4MX86rzVQ+IYk=; b=tfMk2rGqYvLKl2JtVJusQp3vqTKCQ0UGkkfYr7tWfZLqccRnsLVv4xVMy9Eoujhz0j 3+yimsBmfb4VE9xjEMLI/zrFESMJbhGG7ltA91xVkE7kYhPeynTIRgwxVCDj0LnoF6YK buaxeJkFChLMxVM+RAYll90BaWDlfA48d5KgaWrrHW11V0aDkoswdNKK9O6sb/E/aVCL T3zRvhblkNWou7xCfXxDw+FZ2Bhp4CHYmcL8fqi8Dbn4PD7ZGxRdHk2Znq4IlJ4zcpr+ dZNbrsm2R5onxl+yb45rGXHSidwUwPIILLbA2col9LcF/eKscvCov54/EG+nVAojR/2L b3IQ== X-Gm-Message-State: AOAM533LS4ozViA/UNJ/gN9l1n39exc8b0Ji6yVsM8rJF3ZmiWCKj6i1 8OHS5S2ln16m4+vUEfbAlNHNufHqruGTCQ== X-Google-Smtp-Source: ABdhPJzwhjk1/mOV9woelvVobim1UlbZbJ+db1ZSQqMWKUeF/4/uRlDJ6oCm7oZPworxuGjtj2WBWQ== X-Received: by 2002:ac8:7110:: with SMTP id z16mr14717307qto.14.1604953142216; Mon, 09 Nov 2020 12:19:02 -0800 (PST) Received: from localhost.localdomain ([177.194.48.209]) by smtp.googlemail.com with ESMTPSA id z2sm6843407qkl.22.2020.11.09.12.19.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Nov 2020 12:19:01 -0800 (PST) To: libc-alpha@sourceware.org Subject: [PATCH 19/23] linux: Use generic __syscall_error for csky Date: Mon, 9 Nov 2020 17:18:22 -0300 Message-Id: <20201109201826.120534-20-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201109201826.120534-1-adhemerval.zanella@linaro.org> References: <20201109201826.120534-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-13.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, URIBL_BLACK autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Adhemerval Zanella via Libc-alpha From: Adhemerval Zanella Netto Reply-To: Adhemerval Zanella Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" Although the auto-generated syscall issue __syscall_error, using an inline function generates slight more compact code: --- sizes-csky-linux-gnuabiv2-soft.outline +++ sizes-csky-linux-gnuabiv2-soft.inline text data bss dec hex filename -1210010 10408 9212 1229630 12c33e libc.so - 121439 3876 184 125499 1ea3b elf/ld.so - 93074 920 8348 102342 18fc6 nptl/libpthread.so - 24971 648 156 25775 64af rt/librt.so +1209202 10408 9212 1228822 12c016 libc.so + 121171 3876 184 125231 1e92f elf/ld.so + 93630 920 8348 102898 191f2 nptl/libpthread.so + 24967 648 156 25771 64ab rt/librt.so Checked with a cross make check for csky-linux-gnuabiv2-soft. --- sysdeps/unix/sysv/linux/csky/abiv2/sysdep.S | 65 --------------------- sysdeps/unix/sysv/linux/csky/sysdep.h | 2 + 2 files changed, 2 insertions(+), 65 deletions(-) delete mode 100644 sysdeps/unix/sysv/linux/csky/abiv2/sysdep.S diff --git a/sysdeps/unix/sysv/linux/csky/abiv2/sysdep.S b/sysdeps/unix/sysv/linux/csky/abiv2/sysdep.S deleted file mode 100644 index fe6b600bdc..0000000000 --- a/sysdeps/unix/sysv/linux/csky/abiv2/sysdep.S +++ /dev/null @@ -1,65 +0,0 @@ -/* syscall error handlers. C-SKY ABIV2 version. - Copyright (C) 2018-2020 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library. If not, see - . */ - -#include - -/* The syscall stubs jump here when they detect an error. - The code for Linux is almost identical to the canonical Unix - code, except that the error number in R0 is negated. */ - -#undef CALL_MCOUNT -#define CALL_MCOUNT /* Don't insert the profiling call, it clobbers R0. */ - - .text -ENTRY (__syscall_error) - movi a1, 0 - rsub a0, a0, a1 - -#if !IS_IN (rtld) - mov a1, a0 - mov a0, tls - - grs t1, .Lgetpc1 -.Lgetpc1: - lrw t0, errno@gottpoff - add t1, t1, t0 - ldw t1, (t1) - add t1, a0 - stw a1, (t1) - bmaski a0, 0 - rts -#elif RTLD_PRIVATE_ERRNO /* !IS_IN (rtld) */ -# ifdef __PIC__ - grs t1, .Lgetpc2 -.Lgetpc2: - lrw t0, .Lgetpc2@GOTPC - addu t1, t1, t0 - lrw t0, rtld_errno@PLT - ldr.w t0, (t1, t0 << 0) -# else - lrw t0, rtld_errno -# endif /* __PIC__ */ - stw a0, (t0) - bmaski a0, 0 - rts -#else -# error "Unsupported non-TLS case" -#endif /* RTLD_PRIVATE_ERRNO */ - -#undef __syscall_error -END (__syscall_error) diff --git a/sysdeps/unix/sysv/linux/csky/sysdep.h b/sysdeps/unix/sysv/linux/csky/sysdep.h index 7e8e89dd42..c8a7dd77ad 100644 --- a/sysdeps/unix/sysv/linux/csky/sysdep.h +++ b/sysdeps/unix/sysv/linux/csky/sysdep.h @@ -19,6 +19,8 @@ #ifndef _LINUX_CSKY_SYSDEP_H #define _LINUX_CSKY_SYSDEP_H 1 +#define SYSCALL_ERROR_FUNC + /* There is some commonality. */ #include #include From patchwork Mon Nov 9 20:18:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 41000 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 9E22A39730CA; Mon, 9 Nov 2020 20:19:06 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9E22A39730CA DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1604953146; bh=32cHR3K9rnmigI3ULicjauqIkNzMCoSegfmHevR4GLY=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=RCVMvlVmg68fmC/PGu6NHE5I1UxDZG9tENy1+zg1rTg4fRoqFPKfGldSLZR8v+6qW n4XMD2hwFFJDJBPMFegcckUbWxrkO513dUbCPoFbiy4CmpqTh7NuVoPArL02lbj0sF i5j/lXtsr8e/VkKil0YYkUlcfedxV7Gbh/ZIpNMk= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-qt1-x841.google.com (mail-qt1-x841.google.com [IPv6:2607:f8b0:4864:20::841]) by sourceware.org (Postfix) with ESMTPS id 43E5439730A9 for ; Mon, 9 Nov 2020 20:19:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 43E5439730A9 Received: by mail-qt1-x841.google.com with SMTP id 7so2589372qtp.1 for ; Mon, 09 Nov 2020 12:19:04 -0800 (PST) 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:mime-version:content-transfer-encoding; bh=32cHR3K9rnmigI3ULicjauqIkNzMCoSegfmHevR4GLY=; b=k2S9rkPo2ch3UUjuG1NLcUSrIUy9KqjM0MgDT/dQgcgnFNd5XbbihwmProAxy3yABr tsmtoAxo42+xCJXGuDEnIeFEXxhGf9uIlHhu+Uw/VBz/ot7pexDc2juYDXLfvoALf6dH BEil887StblZCgg/HvR+/Uyt4EcUSTu6xmpxtQrm9Uf7YE9uDlKOk1Y+3pT/cuXZnas5 tkIrr0xPZkQ/bivUqHLwZ6ZDJfNZv/8Jqca98M1Jaeh1piK1FYTtS8U1MubI2Ko/OkQj jtJ+MBeAH2UF3Vwe2rOLyW/FT6wY7Yc/gEmZnwVMt2QrAtsFDTd5naKqPW1i98xpwFFY wtzw== X-Gm-Message-State: AOAM532DzjAPGP698xBtSdfJW81CZdJFsQwVJ4iieYwDJ0e7pseqnxQd Alb7mX73dDFqDLJDReMwNL7GmeSiVQ9gxA== X-Google-Smtp-Source: ABdhPJypoLMZGHbm7LHoU3JIr275JvG//L7RtUGMlIC78RErfvSrlyaoVgZFHPAIl1H0IskrUx1WBQ== X-Received: by 2002:aed:32c4:: with SMTP id z62mr3414978qtd.50.1604953143529; Mon, 09 Nov 2020 12:19:03 -0800 (PST) Received: from localhost.localdomain ([177.194.48.209]) by smtp.googlemail.com with ESMTPSA id z2sm6843407qkl.22.2020.11.09.12.19.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Nov 2020 12:19:03 -0800 (PST) To: libc-alpha@sourceware.org Subject: [PATCH 20/23] linux: Use generic __syscall_error for riscv Date: Mon, 9 Nov 2020 17:18:23 -0300 Message-Id: <20201109201826.120534-21-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201109201826.120534-1-adhemerval.zanella@linaro.org> References: <20201109201826.120534-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-13.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, URIBL_BLACK autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Adhemerval Zanella via Libc-alpha From: Adhemerval Zanella Netto Reply-To: Adhemerval Zanella Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" The outline __syscall_error already generate the most compact code for riscv64 and riscv32: --- sizes-riscv32-linux-gnu-rv32imafdc-ilp32d.outline +++ sizes-riscv32-linux-gnu-rv32imafdc-ilp32d.inline text data bss dec hex filename - 973220 9460 8840 991520 f2120 libc.so - 98209 4124 176 102509 1906d elf/ld.so - 71063 800 8348 80211 13953 nptl/libpthread.so - 17011 608 168 17787 457b rt/librt.so + 974466 9460 8840 992766 f25fe libc.so + 98331 4124 176 102631 190e7 elf/ld.so + 70939 800 8348 80087 138d7 nptl/libpthread.so + 17095 608 168 17871 45cf rt/librt.so --- sizes-riscv64-linux-gnu-rv64imafdc-lp64d.outline +++ sizes-riscv64-linux-gnu-rv64imafdc-lp64d.inline text data bss dec hex filename -1030902 18632 14472 1064006 103c46 libc.so - 98320 6232 336 104888 199b8 elf/ld.so - 76588 1596 16664 94848 17280 nptl/libpthread.so - 18016 1156 232 19404 4bcc rt/librt.so +1031680 18632 14472 1064784 103f50 libc.so + 98374 6232 336 104942 199ee elf/ld.so + 76544 1596 16664 94804 17254 nptl/libpthread.so + 18106 1156 232 19494 4c26 rt/librt.so Checked with some basic tests to see if errno is set correctly on both static and dynamic binaries with auto-generated syscals and C implementation (which uses INTERNAL_SYSCALL_CALL). --- sysdeps/riscv/nptl/Makefile | 5 --- sysdeps/riscv/nptl/nptl-sysdep.S | 2 - sysdeps/unix/sysv/linux/riscv/sysdep.S | 51 -------------------------- sysdeps/unix/sysv/linux/riscv/sysdep.h | 2 + 4 files changed, 2 insertions(+), 58 deletions(-) delete mode 100644 sysdeps/riscv/nptl/nptl-sysdep.S delete mode 100644 sysdeps/unix/sysv/linux/riscv/sysdep.S diff --git a/sysdeps/riscv/nptl/Makefile b/sysdeps/riscv/nptl/Makefile index 1af6fa6a55..3f6428b0de 100644 --- a/sysdeps/riscv/nptl/Makefile +++ b/sysdeps/riscv/nptl/Makefile @@ -19,8 +19,3 @@ ifeq ($(subdir),csu) gen-as-const-headers += tcb-offsets.sym endif - -ifeq ($(subdir),nptl) -libpthread-sysdep_routines += nptl-sysdep -libpthread-shared-only-routines += nptl-sysdep -endif diff --git a/sysdeps/riscv/nptl/nptl-sysdep.S b/sysdeps/riscv/nptl/nptl-sysdep.S deleted file mode 100644 index 3f5c2a364a..0000000000 --- a/sysdeps/riscv/nptl/nptl-sysdep.S +++ /dev/null @@ -1,2 +0,0 @@ -/* Pull in __syscall_error. */ -#include diff --git a/sysdeps/unix/sysv/linux/riscv/sysdep.S b/sysdeps/unix/sysv/linux/riscv/sysdep.S deleted file mode 100644 index 64daa84aac..0000000000 --- a/sysdeps/unix/sysv/linux/riscv/sysdep.S +++ /dev/null @@ -1,51 +0,0 @@ -/* syscall error handlers - Copyright (C) 2011-2020 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library. If not, see - . */ - -#include - -#if IS_IN (libc) -# define errno __libc_errno -#endif - -ENTRY (__syscall_error) - mv t0, ra - /* Fall through to __syscall_set_errno. */ -END (__syscall_error) - -/* Non-standard calling convention: argument in a0, return address in t0, - and clobber only t1. */ -ENTRY (__syscall_set_errno) - /* We got here because a0 < 0, but only codes in the range [-4095, -1] - represent errors. Otherwise, just return the result normally. */ - li t1, -4096 - bleu a0, t1, 1f - neg a0, a0 -#if RTLD_PRIVATE_ERRNO - sw a0, rtld_errno, t1 -#elif defined(__PIC__) - la.tls.ie t1, errno - add t1, t1, tp - sw a0, 0(t1) -#else - lui t1, %tprel_hi(errno) - add t1, t1, tp, %tprel_add(errno) - sw a0, %tprel_lo(errno)(t1) -#endif - li a0, -1 -1: jr t0 -END (__syscall_set_errno) diff --git a/sysdeps/unix/sysv/linux/riscv/sysdep.h b/sysdeps/unix/sysv/linux/riscv/sysdep.h index e94afbf106..1bcd942e31 100644 --- a/sysdeps/unix/sysv/linux/riscv/sysdep.h +++ b/sysdeps/unix/sysv/linux/riscv/sysdep.h @@ -19,6 +19,8 @@ #ifndef _LINUX_RISCV_SYSDEP_H #define _LINUX_RISCV_SYSDEP_H 1 +#define SYSCALL_ERROR_FUNC + #include #include From patchwork Mon Nov 9 20:18:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 41001 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 2A3823896C3F; Mon, 9 Nov 2020 20:19:08 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2A3823896C3F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1604953148; bh=TcTFrCeFZ5ryiItulKtbdvg6p5MzaW/ftChGUIRsaL0=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=IMfe6pkRGi1UqvesW6vzT2od1VNJhYNUSvPnH/mlPRaspZuX8ZdRXNw0GnmqLsmYA X5mmuWYgO/moNlFnb17KAC7HEj+d3CzIIIC0R2AItbXJCkOSXraqJ323EhhtRq7XVC kGXrsJp18Huqmst1eIYc0klibq4K8bfuq6gQuFVg= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-qt1-x844.google.com (mail-qt1-x844.google.com [IPv6:2607:f8b0:4864:20::844]) by sourceware.org (Postfix) with ESMTPS id 79CAB39730BC for ; Mon, 9 Nov 2020 20:19:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 79CAB39730BC Received: by mail-qt1-x844.google.com with SMTP id g17so6978327qts.5 for ; Mon, 09 Nov 2020 12:19:05 -0800 (PST) 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:mime-version:content-transfer-encoding; bh=TcTFrCeFZ5ryiItulKtbdvg6p5MzaW/ftChGUIRsaL0=; b=SNbwlKkNfX8KM6qfA+xTa2vYoVgnzoHMaEAMNlXOscFG8pVHaldbe34XSYfsk2WXdH jmmOfNr5eUgBBuoIsP/iVlgSgV8LuzNaSwPbIfJB1k5GKjE/Z820E2Qq50ooaPuqWNvM 6Cw04uiYGOSKkmSTprRIKQaK/mR6MPei2GJnkaeqeijhf+r/z46WD5ycThgGMst2mYsV ASf/vR1KuXqgA4rGumimLTit0CPQPMEmq0nkwp5UZdcjmO0DKA9JU8MBDiL9rwy+o7Aq XZgOvi3rUM4kd7w14/XVn3Ppc3tSEGclffKwQEyQZTv79gYIpjiUZuCUflOhlnCO9yE1 b/9A== X-Gm-Message-State: AOAM532qZZYswJrjouj2G1fpcFCicorqC4PDyTTK6qFiU2/E/Q5TuBP2 tX61lhLvHzfgS+6+sa8LwKeKJkJPsyIISA== X-Google-Smtp-Source: ABdhPJxgiZ5VckpBicqx1vJc/ylIYq3o4YrDCDmCPwDp4FZE1QSPVBtn+ddIFxDwOvGRAqmrNAedoA== X-Received: by 2002:ac8:4d99:: with SMTP id a25mr4512575qtw.122.1604953144849; Mon, 09 Nov 2020 12:19:04 -0800 (PST) Received: from localhost.localdomain ([177.194.48.209]) by smtp.googlemail.com with ESMTPSA id z2sm6843407qkl.22.2020.11.09.12.19.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Nov 2020 12:19:04 -0800 (PST) To: libc-alpha@sourceware.org Subject: [PATCH 21/23] linux: Use generic __syscall_error for nios2 Date: Mon, 9 Nov 2020 17:18:24 -0300 Message-Id: <20201109201826.120534-22-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201109201826.120534-1-adhemerval.zanella@linaro.org> References: <20201109201826.120534-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-13.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_NUMSUBJECT, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, URIBL_BLACK autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Adhemerval Zanella via Libc-alpha From: Adhemerval Zanella Netto Reply-To: Adhemerval Zanella Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" The usage of __syscall_error function on dynamic objects only increases the total size slightly: --- sizes-nios2-linux-gnu.inline +++ sizes-nios2-linux-gnu.outline text data bss dec hex filename -1425296 78844 9224 1513364 171794 libc.so - 143824 8138 184 152146 25252 elf/ld.so - 101762 9260 8356 119378 1d252 nptl/libpthread.so - 26183 2392 160 28735 703f rt/librt.so +1425592 80724 9224 1515540 172014 libc.so + 143960 8142 184 152286 252de elf/ld.so + 102278 10552 8356 121186 1d962 nptl/libpthread.so + 26175 2396 160 28731 703b rt/librt.so And since the port already issues the function call for static object it simplifies the implementation since it avoid add an arch-specific syscall_error.c. Checked with cross make check for nios2-linux-gnu. --- sysdeps/unix/sysv/linux/nios2/sysdep.S | 50 -------------------------- sysdeps/unix/sysv/linux/nios2/sysdep.h | 2 ++ 2 files changed, 2 insertions(+), 50 deletions(-) delete mode 100644 sysdeps/unix/sysv/linux/nios2/sysdep.S diff --git a/sysdeps/unix/sysv/linux/nios2/sysdep.S b/sysdeps/unix/sysv/linux/nios2/sysdep.S deleted file mode 100644 index 6efbb5aff6..0000000000 --- a/sysdeps/unix/sysv/linux/nios2/sysdep.S +++ /dev/null @@ -1,50 +0,0 @@ -/* Static library error handling code fragment for Nios II. - Copyright (C) 2015-2020 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public License as - published by the Free Software Foundation; either version 2.1 of the - License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - . */ - -#include - -/* The following code is only used in the static library. In the shared - library, the error handling code is at the end of each function. */ - -#ifndef PIC - -/* In the static library, the syscall stubs jump here when they detect - an error. */ - -# undef CALL_MCOUNT -# define CALL_MCOUNT /* Don't insert the profiling call, it clobbers r2. */ - -# if IS_IN (libc) -# define SYSCALL_ERROR_ERRNO __libc_errno -# else -# define SYSCALL_ERROR_ERRNO errno -# endif - .text -ENTRY (__syscall_error) - nextpc r3 -1: - movhi r8, %hiadj(_gp_got - 1b) - addi r8, r8, %lo(_gp_got - 1b) - add r3, r3, r8 - ldw r3, %tls_ie(SYSCALL_ERROR_ERRNO)(r3) - add r3, r23, r3 - stw r2, 0(r3) - movi r2, -1 - ret -END (__syscall_error) -#endif diff --git a/sysdeps/unix/sysv/linux/nios2/sysdep.h b/sysdeps/unix/sysv/linux/nios2/sysdep.h index 520c9460a2..882762785b 100644 --- a/sysdeps/unix/sysv/linux/nios2/sysdep.h +++ b/sysdeps/unix/sysv/linux/nios2/sysdep.h @@ -19,6 +19,8 @@ #ifndef _LINUX_NIOS2_SYSDEP_H #define _LINUX_NIOS2_SYSDEP_H 1 +#define SYSCALL_ERROR_FUNC + #include #include #include From patchwork Mon Nov 9 20:18:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 41003 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id ABCC639730BC; Mon, 9 Nov 2020 20:19:10 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org ABCC639730BC DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1604953150; bh=4kfgwFK2CsGX4XwYSIb1SrYpPQBBQTe/aEPPiEsoHmQ=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=o9uHDY6XwAXG2aezbnBtazuHD7Mm4U6Cx4gHv4ObAfTzKm2h7pK/A0zaU+o7Aj8Xj BZ/iAXvH4vhhMBUhorn4dK/22fuUV4sv5DVsnO2+C/MIG3ZeKtg09oV2UfGe1o1Ayn becSAhpxp/A+xnCmoG0itER5Uk0MyDh42I3+2X5g= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-qt1-x843.google.com (mail-qt1-x843.google.com [IPv6:2607:f8b0:4864:20::843]) by sourceware.org (Postfix) with ESMTPS id E546039730A2 for ; Mon, 9 Nov 2020 20:19:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org E546039730A2 Received: by mail-qt1-x843.google.com with SMTP id 7so2589482qtp.1 for ; Mon, 09 Nov 2020 12:19:06 -0800 (PST) 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:mime-version:content-transfer-encoding; bh=4kfgwFK2CsGX4XwYSIb1SrYpPQBBQTe/aEPPiEsoHmQ=; b=VQONt3W71mgNZMFrMVDrZkwU7IHuKIdYvxIcVGv8u6Oy0S34q3vc99TLAkBNGzV0GU BnyvMjwAZeZ5aVxiyuamaQ9cWietXii0GTnaqQlEAvoQ1w6VG6cNtWL/IL7LhnhBc3Yh cVvb2e0rxoo9q5a8jN8K/oIiBJjDl+NOH+t/9Lucw1o7697zAPfje8BIRNzJXsbjsgDJ 7NxC3nqVBpaLXmcsdkWH+KNU3ae3E8+b//m50JBQ1gl1ebYXHolqTvS32VXWAl6rBQ7L QPr88JPakfzMPpxE9w73ruBhKi2lT7/p7Qd2QinxIvYZq07opJqO7uzuMJVI46ubGnCD DMtg== X-Gm-Message-State: AOAM531Fnwmt85ynjKetU066snVxF3yPx+PIc2H2f2VVGmdF/cwAyo4M NV4ucVzuBEDelduUmJa32evyUwnhzNLcDg== X-Google-Smtp-Source: ABdhPJzrOrb8xuHukPfoPI9EKI+QbdnzI3GAd5HAwK4YPH8aC90EV7Sx83U7V7JcQNMcs4m6g6FFUg== X-Received: by 2002:ac8:ecb:: with SMTP id w11mr14693156qti.113.1604953146300; Mon, 09 Nov 2020 12:19:06 -0800 (PST) Received: from localhost.localdomain ([177.194.48.209]) by smtp.googlemail.com with ESMTPSA id z2sm6843407qkl.22.2020.11.09.12.19.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Nov 2020 12:19:05 -0800 (PST) To: libc-alpha@sourceware.org Subject: [PATCH 22/23] linux: Use generic __syscall_error for alpha Date: Mon, 9 Nov 2020 17:18:25 -0300 Message-Id: <20201109201826.120534-23-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201109201826.120534-1-adhemerval.zanella@linaro.org> References: <20201109201826.120534-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-14.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Adhemerval Zanella via Libc-alpha From: Adhemerval Zanella Netto Reply-To: Adhemerval Zanella Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" Alpha __syscall_error uses an optimization to avoid load de GP register and assumes small code size (-fpic). Its implementation is moved to arch-specific one (syscall_error_asm.S) to avoid rewritting the inline asm wrapper to call the generic __syscall_error. Checked on alpha-linux-gnu. --- sysdeps/unix/alpha/Makefile | 8 ++++++-- sysdeps/unix/alpha/rt-sysdep.S | 1 - sysdeps/unix/alpha/{sysdep.S => syscall_error_asm.S} | 8 ++++---- sysdeps/unix/sysv/linux/alpha/Makefile | 3 +-- sysdeps/unix/sysv/linux/alpha/sysdep.h | 4 ++-- 5 files changed, 13 insertions(+), 11 deletions(-) delete mode 100644 sysdeps/unix/alpha/rt-sysdep.S rename sysdeps/unix/alpha/{sysdep.S => syscall_error_asm.S} (94%) diff --git a/sysdeps/unix/alpha/Makefile b/sysdeps/unix/alpha/Makefile index 0660847f15..823ff2d90f 100644 --- a/sysdeps/unix/alpha/Makefile +++ b/sysdeps/unix/alpha/Makefile @@ -1,4 +1,8 @@ +ifeq ($(subdir),csu) +sysdep_routines += syscall_error_asm +endif + ifeq ($(subdir),rt) -librt-sysdep_routines += rt-sysdep -librt-shared-only-routines += rt-sysdep +librt-routines += syscall_error_asm +librt-shared-only-routines += syscall_error_asm endif diff --git a/sysdeps/unix/alpha/rt-sysdep.S b/sysdeps/unix/alpha/rt-sysdep.S deleted file mode 100644 index f966bf1e59..0000000000 --- a/sysdeps/unix/alpha/rt-sysdep.S +++ /dev/null @@ -1 +0,0 @@ -#include diff --git a/sysdeps/unix/alpha/sysdep.S b/sysdeps/unix/alpha/syscall_error_asm.S similarity index 94% rename from sysdeps/unix/alpha/sysdep.S rename to sysdeps/unix/alpha/syscall_error_asm.S index 67968623ac..ddc86c56d6 100644 --- a/sysdeps/unix/alpha/sysdep.S +++ b/sysdeps/unix/alpha/syscall_error_asm.S @@ -35,9 +35,9 @@ #endif .align 4 - .globl __syscall_error - .ent __syscall_error -__syscall_error: + .globl __syscall_error_asm + .ent __syscall_error_asm +__syscall_error_asm: /* When building a shared library, we branch here without having loaded the GP. Nor, since it was a direct branch, have we loaded PV with our address. @@ -62,4 +62,4 @@ __syscall_error: stl t0, 0(t1) ret - .end __syscall_error + .end __syscall_error_asm diff --git a/sysdeps/unix/sysv/linux/alpha/Makefile b/sysdeps/unix/sysv/linux/alpha/Makefile index 92484bbe65..20c673b644 100644 --- a/sysdeps/unix/sysv/linux/alpha/Makefile +++ b/sysdeps/unix/sysv/linux/alpha/Makefile @@ -31,8 +31,7 @@ libm-routines += multc3 divtc3 endif # math ifeq ($(subdir),nptl) -# pull in __syscall_error routine, sigaction stubs. -libpthread-routines += sysdep rt_sigaction +libpthread-routines += rt_sigaction libpthread-shared-only-routines += sysdep rt_sigaction endif diff --git a/sysdeps/unix/sysv/linux/alpha/sysdep.h b/sysdeps/unix/sysv/linux/alpha/sysdep.h index 7daf445068..86bab2ed4c 100644 --- a/sysdeps/unix/sysv/linux/alpha/sysdep.h +++ b/sysdeps/unix/sysv/linux/alpha/sysdep.h @@ -102,14 +102,14 @@ $syscall_error: \ ret # define SYSCALL_ERROR_FALLTHRU #elif defined(PIC) -# define SYSCALL_ERROR_LABEL __syscall_error !samegp +# define SYSCALL_ERROR_LABEL __syscall_error_asm !samegp # define SYSCALL_ERROR_HANDLER # define SYSCALL_ERROR_FALLTHRU br SYSCALL_ERROR_LABEL #else # define SYSCALL_ERROR_LABEL $syscall_error # define SYSCALL_ERROR_HANDLER \ $syscall_error: \ - jmp $31, __syscall_error + jmp $31, __syscall_error_asm # define SYSCALL_ERROR_FALLTHRU #endif /* RTLD_PRIVATE_ERRNO */ From patchwork Mon Nov 9 20:18:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 41002 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 3CD8139730D7; Mon, 9 Nov 2020 20:19:11 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3CD8139730D7 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1604953151; bh=QUWIlBsU577cs8TSjCCkFB50iJBBMTJprKIiEue0kKc=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=pvU7NznyikOTYIaEAc6fO7hARpPiWDWefNlue180u4AUWkCypHhJmdS+rZR1ikdDX AlT8Nn5N6AMO5ib+alwR5uGrgls6WTzHT8ZM6g9fRQRezmRs7s/10hhsqMvg2+TgsM vGRBJtu91NKBba3TNu4Fmw3pbZGJYXjuOW2OP+Eo= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-qk1-x743.google.com (mail-qk1-x743.google.com [IPv6:2607:f8b0:4864:20::743]) by sourceware.org (Postfix) with ESMTPS id 63D7739730BC for ; Mon, 9 Nov 2020 20:19:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 63D7739730BC Received: by mail-qk1-x743.google.com with SMTP id d28so4142872qka.11 for ; Mon, 09 Nov 2020 12:19:08 -0800 (PST) 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:mime-version:content-transfer-encoding; bh=QUWIlBsU577cs8TSjCCkFB50iJBBMTJprKIiEue0kKc=; b=UyD94K3G/qq0C533Bwy+be0vU/jkcLVEv2k23FaT1k6vW5/Mj24xBAW5FZS5+F6BDC fmzzlHi6SuwAdKauhrVpiXGFS1ZTJ04EBsGt9BH7bXQ2jV24or4+66SAGWQRbXuLvJne M82RJAOiJ0BhyeIFVsIv/yoDQwpa6o3GPoowqoxuajG+6xgfDJu09AxULJaD5m/tUWMr QJ+ldisWtL5uQqZWg7yZMkyJsnFe22PiTq2bMex0tzODu5j/Y3Gheh2wuQNzgPv6m2pl lfFbMcKVwkPAR7Zt4Fq8icCIl9pGDehZgHjidw67FWs4sgprI6sPld6GRZhVSN1UgyQN yZnA== X-Gm-Message-State: AOAM531bbKRGt89FPqrxCE8+PsL68+tkREGPzFQPnQGLsP0nsOxw8qNc feWK8WZyHZsJQF3mjG2xoXwH82Emo6FObg== X-Google-Smtp-Source: ABdhPJy4ca8wbeccOdqPZFFfm3xUwhwIHTKHeQOECtcuq/ysr81vujaotkCyfygGNb2nMtrGFaQR5A== X-Received: by 2002:a37:a481:: with SMTP id n123mr15331066qke.114.1604953147641; Mon, 09 Nov 2020 12:19:07 -0800 (PST) Received: from localhost.localdomain ([177.194.48.209]) by smtp.googlemail.com with ESMTPSA id z2sm6843407qkl.22.2020.11.09.12.19.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Nov 2020 12:19:07 -0800 (PST) To: libc-alpha@sourceware.org Subject: [PATCH 23/23] linux: Use generic __syscall_error for mips Date: Mon, 9 Nov 2020 17:18:26 -0300 Message-Id: <20201109201826.120534-24-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201109201826.120534-1-adhemerval.zanella@linaro.org> References: <20201109201826.120534-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-13.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, URIBL_BLACK autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Adhemerval Zanella via Libc-alpha From: Adhemerval Zanella Netto Reply-To: Adhemerval Zanella Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" The mips kABI returns a positive value on 'v0 ($2)' register for failure case, different than usual Linux kABI with return a negative value in range of [-4096,0). To adjust mips to use the generic __syscall_error requires to change both the inline syscall and some assembly implementation that call __syscall_error directly. Also, using an extern call to __syscall_error on mips results in more code size: --- sizes-mips64-linux-gnu.inline +++ sizes-mips64-linux-gnu.outline text data bss dec hex filename -1706692 39428 15584 1761704 1ae1a8 libc.so - 164384 7904 396 172684 2a28c elf/ld.so - 126357 1912 16720 144989 2365d nptl/libpthread.so - 30260 988 272 31520 7b20 rt/librt.so +1708116 39436 15584 1763136 1ae740 libc.so + 164592 7904 396 172892 2a35c elf/ld.so + 127093 1920 16720 145733 23945 nptl/libpthread.so + 30380 988 272 31640 7b98 rt/librt.so --- sizes-mips-linux-gnu.inline +++ sizes-mips-linux-gnu.outline text data bss dec hex filename -1644339 21129 10824 1676292 199404 libc.so - 173460 4856 264 178580 2b994 elf/ld.so - 120945 1016 8420 130381 1fd4d nptl/libpthread.so - 30822 560 192 31574 7b56 rt/librt.so +1644411 21137 10824 1676372 199454 libc.so + 173652 4856 264 178772 2ba54 elf/ld.so + 121357 1020 8420 130797 1feed nptl/libpthread.so + 30830 560 192 31582 7b5e rt/librt.so The inline __syscall_error is used on C syscall implementations and a arch-specific syscall_error.c is added to handle the auto-generated ones. Checked on mips64-linux-gnu and mips-linux-gnu. --- sysdeps/mips/Makefile | 5 - sysdeps/mips/nptl/Makefile | 5 - sysdeps/mips/nptl/nptl-sysdep.S | 2 - sysdeps/unix/mips/mips32/sysdep.h | 5 +- sysdeps/unix/mips/mips64/sysdep.h | 3 +- sysdeps/unix/mips/rt-sysdep.S | 1 - sysdeps/unix/mips/sysdep.S | 99 ------------------- sysdeps/unix/sysv/linux/mips/clone.S | 1 + sysdeps/unix/sysv/linux/mips/getcontext.S | 1 + .../unix/sysv/linux/mips/mips64/n64/ioctl.S | 3 +- sysdeps/unix/sysv/linux/mips/mips64/syscall.S | 3 +- sysdeps/unix/sysv/linux/mips/setcontext.S | 1 + sysdeps/unix/sysv/linux/mips/swapcontext.S | 1 + sysdeps/unix/sysv/linux/mips/syscall_error.c | 3 + sysdeps/unix/sysv/linux/mips/vfork.S | 1 + 15 files changed, 17 insertions(+), 117 deletions(-) delete mode 100644 sysdeps/mips/nptl/nptl-sysdep.S delete mode 100644 sysdeps/unix/mips/rt-sysdep.S delete mode 100644 sysdeps/unix/mips/sysdep.S create mode 100644 sysdeps/unix/sysv/linux/mips/syscall_error.c diff --git a/sysdeps/mips/Makefile b/sysdeps/mips/Makefile index 6ad69e9ef9..70c599ec95 100644 --- a/sysdeps/mips/Makefile +++ b/sysdeps/mips/Makefile @@ -7,11 +7,6 @@ ifeq ($(subdir),setjmp) sysdep_routines += setjmp_aux endif -ifeq ($(subdir),rt) -librt-sysdep_routines += rt-sysdep -librt-shared-only-routines += rt-sysdep -endif - ifeq ($(subdir),csu) CPPFLAGS-crti.S += $(pic-ccflag) CPPFLAGS-crtn.S += $(pic-ccflag) diff --git a/sysdeps/mips/nptl/Makefile b/sysdeps/mips/nptl/Makefile index e9d279a530..eb5d51c450 100644 --- a/sysdeps/mips/nptl/Makefile +++ b/sysdeps/mips/nptl/Makefile @@ -18,8 +18,3 @@ ifeq ($(subdir),csu) gen-as-const-headers += tcb-offsets.sym endif - -ifeq ($(subdir),nptl) -libpthread-sysdep_routines += nptl-sysdep -libpthread-shared-only-routines += nptl-sysdep -endif diff --git a/sysdeps/mips/nptl/nptl-sysdep.S b/sysdeps/mips/nptl/nptl-sysdep.S deleted file mode 100644 index 3f5c2a364a..0000000000 --- a/sysdeps/mips/nptl/nptl-sysdep.S +++ /dev/null @@ -1,2 +0,0 @@ -/* Pull in __syscall_error. */ -#include diff --git a/sysdeps/unix/mips/mips32/sysdep.h b/sysdeps/unix/mips/mips32/sysdep.h index b09367347e..8f3d561abf 100644 --- a/sysdeps/unix/mips/mips32/sysdep.h +++ b/sysdeps/unix/mips/mips32/sysdep.h @@ -26,7 +26,8 @@ .align 2; \ .set nomips16; \ cfi_startproc; \ - 99: la t9,__syscall_error; \ + 99: subu a0, zero, v0; \ + la t9,__syscall_error; \ jr t9; \ cfi_endproc; \ ENTRY(name) \ @@ -44,7 +45,7 @@ L(syse1): .align 2; \ cfi_startproc; \ 99: j __syscall_error; \ - nop; \ + subu a0, zero, v0; \ cfi_endproc; \ ENTRY(name) \ .set noreorder; \ diff --git a/sysdeps/unix/mips/mips64/sysdep.h b/sysdeps/unix/mips/mips64/sysdep.h index fb5f27daf3..ff14bcceec 100644 --- a/sysdeps/unix/mips/mips64/sysdep.h +++ b/sysdeps/unix/mips/mips64/sysdep.h @@ -30,6 +30,7 @@ .set nomips16; \ cfi_startproc; \ 99:; \ + dsubu a0, zero, v0; \ .set noat; \ .cpsetup t9, $1, name; \ cfi_register (gp, $1); \ @@ -51,7 +52,7 @@ L(syse1): .set nomips16; \ cfi_startproc; \ 99: j __syscall_error; \ - nop; \ + dsubu a0, zero, v0; \ cfi_endproc; \ ENTRY(name) \ .set noreorder; \ diff --git a/sysdeps/unix/mips/rt-sysdep.S b/sysdeps/unix/mips/rt-sysdep.S deleted file mode 100644 index f966bf1e59..0000000000 --- a/sysdeps/unix/mips/rt-sysdep.S +++ /dev/null @@ -1 +0,0 @@ -#include diff --git a/sysdeps/unix/mips/sysdep.S b/sysdeps/unix/mips/sysdep.S deleted file mode 100644 index 744d1620b3..0000000000 --- a/sysdeps/unix/mips/sysdep.S +++ /dev/null @@ -1,99 +0,0 @@ -/* Copyright (C) 1992-2020 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Brendan Kehoe (brendan@zen.org). - - 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 - - .set nomips16 - -#ifdef _LIBC_REENTRANT - -LOCALSZ= 3 -FRAMESZ= (((NARGSAVE+LOCALSZ)*SZREG)+ALSZ)&ALMASK -RAOFF= FRAMESZ-(1*SZREG) -GPOFF= FRAMESZ-(2*SZREG) -V0OFF= FRAMESZ-(3*SZREG) - -ENTRY(__syscall_error) -#ifdef __PIC__ - .set noat - SETUP_GPX (AT) - .set at -#endif - PTR_SUBU sp, FRAMESZ - .set noat - SETUP_GPX64(GPOFF,AT) - .set at -#ifdef __PIC__ - SAVE_GP(GPOFF) -#endif - REG_S v0, V0OFF(sp) - REG_S ra, RAOFF(sp) - -#if defined (EWOULDBLOCK_sys) && EWOULDBLOCK_sys != EAGAIN - /* We translate the system's EWOULDBLOCK error into EAGAIN. - The GNU C library always defines EWOULDBLOCK==EAGAIN. - EWOULDBLOCK_sys is the original number. */ - bne v0, EWOULDBLOCK_sys, L(skip) - nop - li v0, EAGAIN -L(skip): -#endif - /* Find our per-thread errno address */ - jal __errno_location - - /* Store the error value. */ - REG_L t0, V0OFF(sp) - sw t0, 0(v0) - - /* And just kick back a -1. */ - REG_L ra, RAOFF(sp) - RESTORE_GP64 - PTR_ADDU sp, FRAMESZ - li v0, -1 - j ra - END(__syscall_error) - -#else /* _LIBC_REENTRANT */ - - -ENTRY(__syscall_error) -#ifdef __PIC__ - SETUP_GPX (AT) -#endif - SETUP_GPX64 (t9, AT) - -#if defined (EWOULDBLOCK_sys) && EWOULDBLOCK_sys != EAGAIN - /* We translate the system's EWOULDBLOCK error into EAGAIN. - The GNU C library always defines EWOULDBLOCK==EAGAIN. - EWOULDBLOCK_sys is the original number. */ - bne v0, EWOULDBLOCK_sys, L(skip) - li v0, EAGAIN -L(skip): -#endif - /* Store it in errno... */ - sw v0, errno - - /* And just kick back a -1. */ - li v0, -1 - - RESTORE_GP64 - j ra - END(__syscall_error) -#endif /* _LIBC_REENTRANT */ diff --git a/sysdeps/unix/sysv/linux/mips/clone.S b/sysdeps/unix/sysv/linux/mips/clone.S index 6a5ec84870..3dd181b6f9 100644 --- a/sysdeps/unix/sysv/linux/mips/clone.S +++ b/sysdeps/unix/sysv/linux/mips/clone.S @@ -102,6 +102,7 @@ NESTED(__clone,4*SZREG,sp) /* Something bad happened -- no child created */ L(error): cfi_restore_state + INT_SUBU a0, zero, v0 #ifdef __PIC__ PTR_LA t9,__syscall_error RESTORE_GP64_STACK diff --git a/sysdeps/unix/sysv/linux/mips/getcontext.S b/sysdeps/unix/sysv/linux/mips/getcontext.S index 69f62d4a75..edb5063647 100644 --- a/sysdeps/unix/sysv/linux/mips/getcontext.S +++ b/sysdeps/unix/sysv/linux/mips/getcontext.S @@ -140,6 +140,7 @@ NESTED (__getcontext, FRAMESZ, ra) 99: cfi_restore_state + INT_SUBU a0, zero, v0 #ifdef __PIC__ PTR_LA t9, JUMPTARGET (__syscall_error) RESTORE_GP64_STACK diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n64/ioctl.S b/sysdeps/unix/sysv/linux/mips/mips64/n64/ioctl.S index ed58abe7e9..c911abee2a 100644 --- a/sysdeps/unix/sysv/linux/mips/mips64/n64/ioctl.S +++ b/sysdeps/unix/sysv/linux/mips/mips64/n64/ioctl.S @@ -31,7 +31,8 @@ ENTRY (__ioctl) ret L(error): - SETUP_GP64_REG (a0, __ioctl) + INT_SUBU a0, zero, v0 + SETUP_GP64_REG (v0, __ioctl) PTR_LA t9, __syscall_error RESTORE_GP64_REG jr t9 diff --git a/sysdeps/unix/sysv/linux/mips/mips64/syscall.S b/sysdeps/unix/sysv/linux/mips/mips64/syscall.S index a9baff3c17..8fc6caea71 100644 --- a/sysdeps/unix/sysv/linux/mips/mips64/syscall.S +++ b/sysdeps/unix/sysv/linux/mips/mips64/syscall.S @@ -55,7 +55,8 @@ NESTED (syscall, SZREG, ra) ret L(error): - SETUP_GP64_REG (a0, syscall) + INT_SUBU a0, zero, v0 + SETUP_GP64_REG (v0, syscall) PTR_LA t9, __syscall_error RESTORE_GP64_REG jr t9 diff --git a/sysdeps/unix/sysv/linux/mips/setcontext.S b/sysdeps/unix/sysv/linux/mips/setcontext.S index 3609af7780..cd058c4390 100644 --- a/sysdeps/unix/sysv/linux/mips/setcontext.S +++ b/sysdeps/unix/sysv/linux/mips/setcontext.S @@ -149,6 +149,7 @@ NESTED (__setcontext, FRAMESZ, ra) jr t9 99: + INT_SUBU a0, zero, v0 #ifdef __PIC__ PTR_LA t9, JUMPTARGET (__syscall_error) RESTORE_GP64_STACK diff --git a/sysdeps/unix/sysv/linux/mips/swapcontext.S b/sysdeps/unix/sysv/linux/mips/swapcontext.S index bcc66be068..ca3bcddfb7 100644 --- a/sysdeps/unix/sysv/linux/mips/swapcontext.S +++ b/sysdeps/unix/sysv/linux/mips/swapcontext.S @@ -200,6 +200,7 @@ NESTED (__swapcontext, FRAMESZ, ra) jr t9 99: + INT_SUBU a0, zero, v0; #ifdef __PIC__ PTR_LA t9, JUMPTARGET (__syscall_error) RESTORE_GP64_STACK diff --git a/sysdeps/unix/sysv/linux/mips/syscall_error.c b/sysdeps/unix/sysv/linux/mips/syscall_error.c new file mode 100644 index 0000000000..ee8b2e9f0d --- /dev/null +++ b/sysdeps/unix/sysv/linux/mips/syscall_error.c @@ -0,0 +1,3 @@ +/* The auto-generated syscalls call __syscall_error. */ +#define SYSCALL_ERROR_FUNC +#include diff --git a/sysdeps/unix/sysv/linux/mips/vfork.S b/sysdeps/unix/sysv/linux/mips/vfork.S index ba3c64ae1e..f579ffe46f 100644 --- a/sysdeps/unix/sysv/linux/mips/vfork.S +++ b/sysdeps/unix/sysv/linux/mips/vfork.S @@ -76,6 +76,7 @@ NESTED(__libc_vfork,FRAMESZ,sp) /* Something bad happened -- no child created. */ L(error): cfi_restore_state + INT_SUBU a0, zero, v0 #ifdef __PIC__ PTR_LA t9, __syscall_error RESTORE_GP64_REG