From patchwork Fri Nov 13 16:58: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: 41049 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 7E24339450C5; Fri, 13 Nov 2020 16:58:53 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7E24339450C5 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1605286733; bh=6ndiiTgWbSNFjMkOWrqLqUpG6Ns/X4G+JiCUr8I+2wI=; 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=heb7KTd+CPLdjha/QWBElhC0NoSc2tPKzOozXwjGZH3S7z0d4jFSx8V190nE6oD2i l8NlqchvDPe8kDFss5RBFI19/mNQC5XieuX7XI5Id9Kz8NBzyJByx1TsXE+DHVPPrQ lu5xeZz4B+9Whctu9cRppb+iP4FY+T0yldRHPCBE= 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 452783945047 for ; Fri, 13 Nov 2020 16:58:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 452783945047 Received: by mail-qk1-x741.google.com with SMTP id 199so9386699qkg.9 for ; Fri, 13 Nov 2020 08:58: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=6ndiiTgWbSNFjMkOWrqLqUpG6Ns/X4G+JiCUr8I+2wI=; b=d4dpL/+/UDYrRxVBcOYCSCoTElYV7dnHXYnmkbnr/f+YYDT5zOkVz1m/pouFONtUOu ZUZnUCgBB2jvCUsiT9qylQ6qUJEriDIXANqihwSvd1SSDZWbmJzQvOfJnTCEffuCWuXH 7mzFRLHl0GENQozbGSxYKQOLWO/sGG8UPUfqMnFSkx9/4kXabuhjFbSMmb99PTEP0dh0 B8Eg3wMivO4zUT2tLFVSl/+5L8GVSRlzVdP/74d8GS848LhTJ3huw10Nfov/L+bdz7yr Nxrq2lqDkihLxoc+zPn2W254lVNZlDzhaPLqtOkh0TqQlff4nV9GFJFWh16hT1b/losM WAgw== X-Gm-Message-State: AOAM530s8SIhnQ1jajznr7XXrUblhaiUSVMMnHXYRzeyrjP5oKKvBbEd Kclj71kjdlHtnxxsOl6GZBHC3oEaX6MFCQ== X-Google-Smtp-Source: ABdhPJwUYPq7jrqk5YGOjtfTNYFW4GnYUbvtrAXA52pJJv7sG1TMhbzo3/WD4a+FNvvT7wTsJsqk0w== X-Received: by 2002:a37:2cc2:: with SMTP id s185mr2905288qkh.118.1605286723363; Fri, 13 Nov 2020 08:58:43 -0800 (PST) Received: from localhost.localdomain ([177.194.48.209]) by smtp.googlemail.com with ESMTPSA id s16sm7363931qkg.5.2020.11.13.08.58.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Nov 2020 08:58:42 -0800 (PST) To: libc-alpha@sourceware.org Subject: [PATCH v2 01/23] linux: Remove INTERNAL_SYSCALL_ERRNO Date: Fri, 13 Nov 2020 13:58:15 -0300 Message-Id: <20201113165837.121629-2-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201113165837.121629-1-adhemerval.zanella@linaro.org> References: <20201113165837.121629-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-13.9 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 4aa1231bec..cbf9cda989 100644 --- a/nptl/nptl-init.c +++ b/nptl/nptl-init.c @@ -191,7 +191,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 6f568eed51..e9e0fde23d 100644 --- a/sysdeps/unix/sysv/linux/libc_fatal.c +++ b/sysdeps/unix/sysv/linux/libc_fatal.c @@ -27,8 +27,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 7323c82a07..e6f2d5c1fd 100644 --- a/sysdeps/unix/sysv/linux/posix_fadvise64.c +++ b/sysdeps/unix/sysv/linux/posix_fadvise64.c @@ -49,9 +49,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..517fee14f4 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 71ecc19cd5..a47f47526d 100644 --- a/sysdeps/unix/sysv/linux/sysdep.h +++ b/sysdeps/unix/sysv/linux/sysdep.h @@ -43,13 +43,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 Fri Nov 13 16:58: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: 41051 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 91C9939450CD; Fri, 13 Nov 2020 16:58:55 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 91C9939450CD DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1605286735; bh=tZpqbmRbSbGezdHQWgDNcxrS25ilnI8ZoYcgL2S39og=; 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=GIBIwQ9LioWkCrZJWLPy9EyMVut0hr10mP85wo34TN6DC3RMEpPYV0qTk8Y6oWgva iwY76HKkeCTzhZ0vPvwFa9xxfSlTVTwWf8bjQ2cP7O1751JdABmp4vLi/x370tiz9u e/2NJPUkeJsVUANBC8h4AihnCGDVCZRBpVnnTuuA= 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 D06F6385481A for ; Fri, 13 Nov 2020 16:58:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org D06F6385481A Received: by mail-qk1-x741.google.com with SMTP id d9so9389619qke.8 for ; Fri, 13 Nov 2020 08:58: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=tZpqbmRbSbGezdHQWgDNcxrS25ilnI8ZoYcgL2S39og=; b=tmzhQ4xy1g9pPqqQNETcrHMcseCvHRGn6DmkJjEm/Wc9xSnZ8SHnOsB9jyTtl+Jv/7 qqTYgB2CDdSCZxaauwyIUCWkckO0mrPNdUOrMV2fQMiJJISeyaQ2j1kH4zLD8C1l5NJq Bf9c4LiPXNigPb3vYSuFGmWtNXsPvzgJWHaNwWDZ44AIv9XVJwIZjPpzmTNZcTwXBhwl VkjseA3BueIpQSTeD7vxX3Tpo/TD2ruIT5Uv5+x8kzanIqk4n+hSArTZWS1YV7iTKzsG FijSnZ/rikt7I++hZjBOTt+PVfCmeLtCxRK61VDaM319a9nCIFjGKIL4Pi12ooWAgbSy HHGw== X-Gm-Message-State: AOAM533l6kGWZuOG3YLpGowKIrYpeU9v8X+AYzmo5/clNL12LWOhPyg2 C3CNB2gF+4T2cN3uppQcnxSil6eVyvQjCA== X-Google-Smtp-Source: ABdhPJwfhlHJUFfMfqAej6iXM3vxOOVAcVH3QBPPn/5Yj5sHpPPMq14CV1U3c50CWXxYdfBrXhKFXw== X-Received: by 2002:a05:620a:15db:: with SMTP id o27mr2797317qkm.21.1605286724875; Fri, 13 Nov 2020 08:58:44 -0800 (PST) Received: from localhost.localdomain ([177.194.48.209]) by smtp.googlemail.com with ESMTPSA id s16sm7363931qkg.5.2020.11.13.08.58.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Nov 2020 08:58:44 -0800 (PST) To: libc-alpha@sourceware.org Subject: [PATCH v2 02/23] linux: Remove INTERNAL_SYSCALL_ERROR_P Date: Fri, 13 Nov 2020 13:58:16 -0300 Message-Id: <20201113165837.121629-3-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201113165837.121629-1-adhemerval.zanella@linaro.org> References: <20201113165837.121629-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-13.9 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 usages can be replaced by either checking for equal to zero (success) or negative (failure). The possible outliers (lseek on x32) are already handled by specific implementations. 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 | 4 +--- sysdeps/csky/nptl/tls.h | 8 +++----- sysdeps/m68k/nptl/tls.h | 8 +++----- sysdeps/mips/nptl/tls.h | 8 +++----- sysdeps/nptl/lowlevellock-futex.h | 7 +------ sysdeps/powerpc/nofpu/sfp-machine.h | 2 +- sysdeps/unix/sysv/linux/arm/tls.h | 6 ++---- 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 | 4 +--- sysdeps/unix/sysv/linux/fstatat64.c | 4 +--- 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 | 7 +------ 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 | 6 +++--- sysdeps/unix/sysv/linux/sysdep-vdso.h | 4 ++-- sysdeps/unix/sysv/linux/sysdep.h | 8 +++----- sysdeps/unix/sysv/linux/timer_create.c | 2 +- sysdeps/unix/sysv/linux/times.c | 4 +--- sysdeps/unix/sysv/linux/x86_64/x32/times.c | 4 ---- 44 files changed, 73 insertions(+), 132 deletions(-) diff --git a/nptl/allocatestack.c b/nptl/allocatestack.c index a9e9d39354..15d8d5098d 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 (val == 0) { 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 (result < 0)) { error = -result; __set_errno (error); diff --git a/nptl/nptl-init.c b/nptl/nptl-init.c index cbf9cda989..d1a242503c 100644 --- a/nptl/nptl-init.c +++ b/nptl/nptl-init.c @@ -190,7 +190,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 (result < 0)) error = -result; __nptl_setxid_error (__xidcmd, error); @@ -242,7 +242,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 (res < 0) set_robust_list_not_avail (); } diff --git a/nptl/pthread_cancel.c b/nptl/pthread_cancel.c index 7daf4f8c15..2927af8375 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 (val < 0) result = -val; break; diff --git a/nptl/pthread_getaffinity.c b/nptl/pthread_getaffinity.c index ffeb878c7c..3ee5f54c3d 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 (res < 0) 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..ca01db01b4 100644 --- a/sysdeps/arc/nptl/tls.h +++ b/sysdeps/arc/nptl/tls.h @@ -78,10 +78,8 @@ typedef struct /* Code to initially initialize the thread pointer. */ # define TLS_INIT_TP(tcbp) \ ({ \ - long result_var; \ __builtin_set_thread_pointer (tcbp); \ - result_var = INTERNAL_SYSCALL_CALL (arc_settls, (tcbp));\ - INTERNAL_SYSCALL_ERROR_P (result_var) \ + INTERNAL_SYSCALL_CALL (arc_settls, (tcbp)) < 0 \ ? "settls syscall error" : NULL; \ }) diff --git a/sysdeps/csky/nptl/tls.h b/sysdeps/csky/nptl/tls.h index bcca9674a1..60a59898c4 100644 --- a/sysdeps/csky/nptl/tls.h +++ b/sysdeps/csky/nptl/tls.h @@ -96,11 +96,9 @@ typedef struct special attention since 'errno' is not yet available and if the operation can cause a failure 'errno' must not be touched. */ # define TLS_INIT_TP(tcbp) \ - ({ long int result_var; \ - result_var = INTERNAL_SYSCALL_CALL (set_thread_area, \ - (char *) (tcbp) + TLS_TCB_OFFSET); \ - INTERNAL_SYSCALL_ERROR_P (result_var) \ - ? "unknown error" : NULL; }) + ({ result_var = INTERNAL_SYSCALL_CALL (set_thread_area, \ + (char *) (tcbp) + TLS_TCB_OFFSET) < 0 \ + ? "unknown error" : NULL; }) /* Return the address of the dtv for the current thread. */ # define THREAD_DTV() \ diff --git a/sysdeps/m68k/nptl/tls.h b/sysdeps/m68k/nptl/tls.h index 68ea952e79..53cf33fbb9 100644 --- a/sysdeps/m68k/nptl/tls.h +++ b/sysdeps/m68k/nptl/tls.h @@ -95,11 +95,9 @@ typedef struct operation can cause a failure 'errno' must not be touched. */ # define TLS_INIT_TP(tcbp) \ ({ \ - int _sys_result; \ - \ - _sys_result = INTERNAL_SYSCALL_CALL (set_thread_area, \ - ((void *) (tcbp)) + TLS_TCB_OFFSET); \ - INTERNAL_SYSCALL_ERROR_P (_sys_result) ? "unknown error" : NULL; }) + INTERNAL_SYSCALL_CALL (set_thread_area, \ + ((void *) (tcbp)) + TLS_TCB_OFFSET) < 0; \ + "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..a6986192dd 100644 --- a/sysdeps/mips/nptl/tls.h +++ b/sysdeps/mips/nptl/tls.h @@ -120,11 +120,9 @@ typedef struct special attention since 'errno' is not yet available and if the operation can cause a failure 'errno' must not be touched. */ # define TLS_INIT_TP(tcbp) \ - ({ long int result_var; \ - result_var = INTERNAL_SYSCALL_CALL (set_thread_area, \ - (char *) (tcbp) + TLS_TCB_OFFSET); \ - INTERNAL_SYSCALL_ERROR_P (result_var) \ - ? "unknown error" : NULL; }) + ({ INTERNAL_SYSCALL_CALL (set_thread_area, \ + (char *) (tcbp) + TLS_TCB_OFFSET) < 0 \ + ? "unknown error" : NULL; }) /* Value passed to 'clone' for initialization of the thread register. */ # define TLS_DEFINE_INIT_TP(tp, pd) \ 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..ab15254944 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 (r < 0) \ _ftrapex = 0; \ } \ while (0) diff --git a/sysdeps/unix/sysv/linux/arm/tls.h b/sysdeps/unix/sysv/linux/arm/tls.h index 57b583dbd8..69c8f0d1fa 100644 --- a/sysdeps/unix/sysv/linux/arm/tls.h +++ b/sysdeps/unix/sysv/linux/arm/tls.h @@ -31,10 +31,8 @@ special attention since 'errno' is not yet available and if the operation can cause a failure 'errno' must not be touched. */ # define TLS_INIT_TP(tcbp) \ - ({ long int result_var; \ - result_var = INTERNAL_SYSCALL_CALL (set_tls, (tcbp)); \ - INTERNAL_SYSCALL_ERROR_P (result_var) \ - ? "unknown error" : NULL; }) + ({ INTERNAL_SYSCALL_CALL (set_tls, (tcbp)) < 0 \ + ? "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..ee757d6215 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 (r < 0) { 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..fa86a173aa 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 (res < 0)) 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 (res < 0)) goto err_out; } } diff --git a/sysdeps/unix/sysv/linux/dl-origin.c b/sysdeps/unix/sysv/linux/dl-origin.c index 515ed6fc8c..165b14e08d 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 (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..fb3e7a614c 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 (res == 0) 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..87e5c0fc8f 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 INTERNAL_SYSCALL_ERROR_P (r) - ? INLINE_SYSCALL_ERROR_RETURN_VALUE (-r) - : 0; + return r == 0 ? 0 : INLINE_SYSCALL_ERROR_RETURN_VALUE (-r); } weak_alias (__fstatat, fstatat) diff --git a/sysdeps/unix/sysv/linux/fstatat64.c b/sysdeps/unix/sysv/linux/fstatat64.c index 44347603b4..71216e43f5 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 INTERNAL_SYSCALL_ERROR_P (r) - ? INLINE_SYSCALL_ERROR_RETURN_VALUE (-r) - : 0; + return r == 0 ? 0 : INLINE_SYSCALL_ERROR_RETURN_VALUE (-r); } #if __TIMESIZE != 64 hidden_def (__fstatat64_time64) diff --git a/sysdeps/unix/sysv/linux/generic/dl-origin.c b/sysdeps/unix/sysv/linux/generic/dl-origin.c index 1ab02bbf10..f705c92acb 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 (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..7f2c90adb1 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 (result == 0 \ && ((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 e9e0fde23d..29bc0444e9 100644 --- a/sysdeps/unix/sysv/linux/libc_fatal.c +++ b/sysdeps/unix/sysv/linux/libc_fatal.c @@ -27,7 +27,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 (cnt < 0 && 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..3d3b495dca 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 (result == 0 \ && ((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..6d9d90ab24 100644 --- a/sysdeps/unix/sysv/linux/m68k/getpagesize.c +++ b/sysdeps/unix/sysv/linux/m68k/getpagesize.c @@ -33,12 +33,7 @@ __getpagesize (void) if (GLRO(dl_pagesize) != 0) return GLRO(dl_pagesize); - result = INTERNAL_SYSCALL_CALL (getpagesize); - /* The only possible error is ENOSYS. */ - if (!INTERNAL_SYSCALL_ERROR_P (result)) - return result; - - return 4096; + return INTERNAL_SYSCALL_CALL (getpagesize); } libc_hidden_def (__getpagesize) weak_alias (__getpagesize, getpagesize) diff --git a/sysdeps/unix/sysv/linux/mq_unlink.c b/sysdeps/unix/sysv/linux/mq_unlink.c index ed7858dc9d..bfba6ccfec 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 (ret < 0) { 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..eeb4b0d13f 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 (r == 0) /* 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 e6f2d5c1fd..4a1fc0225b 100644 --- a/sysdeps/unix/sysv/linux/posix_fadvise64.c +++ b/sysdeps/unix/sysv/linux/posix_fadvise64.c @@ -42,14 +42,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..af8dc8fb8c 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 (res == 0 || 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 517fee14f4..704fe63794 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 (res == 0 || 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..f45924d895 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 (ret < 0) 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..c1e01a61f3 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 (res == 0) \ { \ 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..c42dc5e56a 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 (res == 0) \ { \ 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..40c3416ec5 100644 --- a/sysdeps/unix/sysv/linux/shmat.c +++ b/sysdeps/unix/sysv/linux/shmat.c @@ -35,9 +35,9 @@ 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 (-resultvar); + if (resultvar == 0) + return raddr; - return raddr; + return (void *) INLINE_SYSCALL_ERROR_RETURN_VALUE (-resultvar); #endif } diff --git a/sysdeps/unix/sysv/linux/sysdep-vdso.h b/sysdeps/unix/sysv/linux/sysdep-vdso.h index 88db076184..17ed99d495 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 (sc_ret == 0) \ goto out; \ if (sc_ret != -ENOSYS) \ goto iserr; \ } \ \ sc_ret = INTERNAL_SYSCALL_CALL (name, ##args); \ - if (INTERNAL_SYSCALL_ERROR_P (sc_ret)) \ + if (sc_ret < 0) \ { \ iserr: \ __set_errno (-sc_ret); \ diff --git a/sysdeps/unix/sysv/linux/sysdep.h b/sysdeps/unix/sysv/linux/sysdep.h index a47f47526d..d09e5ee532 100644 --- a/sysdeps/unix/sysv/linux/sysdep.h +++ b/sysdeps/unix/sysv/linux/sysdep.h @@ -23,10 +23,6 @@ #include #include -#undef INTERNAL_SYSCALL_ERROR_P -#define INTERNAL_SYSCALL_ERROR_P(val) \ - ((unsigned long int) (val) > -4096UL) - #ifndef SYSCALL_ERROR_LABEL # define SYSCALL_ERROR_LABEL(sc_err) \ ({ \ @@ -35,6 +31,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. */ @@ -42,10 +39,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 (sc_ret > -4096UL) \ ? 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..9bf68f5ad7 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 (res < 0) { free (newp); __set_errno (-res); diff --git a/sysdeps/unix/sysv/linux/times.c b/sysdeps/unix/sysv/linux/times.c index b5eb6404c9..9ef95b7d8b 100644 --- a/sysdeps/unix/sysv/linux/times.c +++ b/sysdeps/unix/sysv/linux/times.c @@ -19,13 +19,11 @@ #include #include - clock_t __times (struct tms *buf) { clock_t ret = INTERNAL_SYSCALL_CALL (times, buf); - if (INTERNAL_SYSCALL_ERROR_P (ret) - && __glibc_unlikely (ret == -EFAULT) + if (__glibc_unlikely (ret == -EFAULT) && buf) { /* This might be an error or not. For architectures which have no diff --git a/sysdeps/unix/sysv/linux/x86_64/x32/times.c b/sysdeps/unix/sysv/linux/x86_64/x32/times.c index 864c123117..e207fb1cf2 100644 --- a/sysdeps/unix/sysv/linux/x86_64/x32/times.c +++ b/sysdeps/unix/sysv/linux/x86_64/x32/times.c @@ -33,8 +33,4 @@ (long long int) resultvar; \ }) -#undef INTERNAL_SYSCALL_ERROR_P -#define INTERNAL_SYSCALL_ERROR_P(val) \ - ((unsigned long long int) (val) >= -4095LL) - #include From patchwork Fri Nov 13 16:58: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: 41050 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 0F37439450CF; Fri, 13 Nov 2020 16:58:55 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0F37439450CF DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1605286735; bh=kroHMMfqAyXY00dqd7j61NLTGqXg3gTRA4gVP4APF2k=; 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=VTFlbNmrUv5liYWYyuuMP1mcJ0ktS8pLlvntwWLfyF0UB/6Fvyf9aB8bh5Ya0i8xw NGoTgwxgEAR7jtDREyvCVHhD6RFJWD61PRVi4/dIGJNe0ub95m8HeC5A+WMY0Qj8CS UEqb510EKQQM84e3wKqBACbign2U8TEt0iSdfXwE= 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 3AAF23945047 for ; Fri, 13 Nov 2020 16:58:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 3AAF23945047 Received: by mail-qt1-x844.google.com with SMTP id j31so7113608qtb.8 for ; Fri, 13 Nov 2020 08:58:52 -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=kroHMMfqAyXY00dqd7j61NLTGqXg3gTRA4gVP4APF2k=; b=qFT2stkZZ6Fb05LnCZQBMcIS9GNcHmlEBuJmQpq+rXZc6T8fKJI4fJyaKeiTzsmUyf snW3uFO5kkhSAfrpM0iFeBDz25j6TrO/adtsM6XnB+Wn0UOriFTi3+5AxQozVkca46yO NCN1atc8nsuMdVCop9lX5xPeDSQTLfoIwRmqRERdwlcs73I4ek/N9A6+rneB2XO5uJbe v3uww9mrpldJo5IumQ9yJuUnpRJHCdrZWHxvSOYTtT7MFpI0DmLAWelcuczkwwnCKu04 TrsTKFAP9ZctP16cvvvtzs+0+R6FTpSX6wonpw2gDZTXxfQaPqoWs6k8FNeQPbak+1fI 0aXg== X-Gm-Message-State: AOAM533PBBjpVodvbAHwkK70+ctcb/cO/ZQKylaDqcOPEMZtOK9sWzCb heUz1qmeJ6qQYtYWEwZbVukgVvxdK1YoNQ== X-Google-Smtp-Source: ABdhPJxMCyseg/oPyC23Lz//GmKSOyCfviaNUvv2Z8ZkYGfWp1oz1GCRDLJFSdePyStbtQ0T3R8iPg== X-Received: by 2002:ac8:5046:: with SMTP id h6mr2843101qtm.349.1605286726607; Fri, 13 Nov 2020 08:58:46 -0800 (PST) Received: from localhost.localdomain ([177.194.48.209]) by smtp.googlemail.com with ESMTPSA id s16sm7363931qkg.5.2020.11.13.08.58.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Nov 2020 08:58:45 -0800 (PST) To: libc-alpha@sourceware.org Subject: [PATCH v2 03/23] linux: Add syscall_ret and use it on INLINE_SYSCALL Date: Fri, 13 Nov 2020 13:58:17 -0300 Message-Id: <20201113165837.121629-4-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201113165837.121629-1-adhemerval.zanella@linaro.org> References: <20201113165837.121629-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-13.9 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 | 2 +- sysdeps/unix/sysv/linux/fstatat64.c | 2 +- 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, 23 insertions(+), 46 deletions(-) diff --git a/sysdeps/unix/sysv/linux/fstatat.c b/sysdeps/unix/sysv/linux/fstatat.c index 87e5c0fc8f..5ba1b99372 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 r == 0 ? 0 : INLINE_SYSCALL_ERROR_RETURN_VALUE (-r); + 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 71216e43f5..a788940390 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 r == 0 ? 0 : INLINE_SYSCALL_ERROR_RETURN_VALUE (-r); + 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 bfba6ccfec..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 (ret < 0) - { - 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 17ed99d495..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 (sc_ret == 0) \ - goto out; \ - if (sc_ret != -ENOSYS) \ - goto iserr; \ - } \ - \ - sc_ret = INTERNAL_SYSCALL_CALL (name, ##args); \ - if (sc_ret < 0) \ - { \ - 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 d09e5ee532..e423b5e7b1 100644 --- a/sysdeps/unix/sysv/linux/sysdep.h +++ b/sysdeps/unix/sysv/linux/sysdep.h @@ -23,26 +23,24 @@ #include #include -#ifndef SYSCALL_ERROR_LABEL -# define SYSCALL_ERROR_LABEL(sc_err) \ - ({ \ - __set_errno (sc_err); \ - -1L; \ - }) -#endif - #ifndef __ASSEMBLER__ +static inline long int +syscall_ret (unsigned long int val) +{ + if (val > -4096UL) + { + __set_errno (-val); + return -1; + } + return val; +} + /* 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 (sc_ret > -4096UL) \ - ? 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 Fri Nov 13 16:58: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: 41053 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 08D0239450FD; Fri, 13 Nov 2020 16:58:59 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 08D0239450FD DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1605286739; bh=/7J+OwGLt7Jhiy3f6WjVvX1+v1e+qVGjw3ipbw8p1+E=; 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=KdOPefqrTA+aHyWApnSUoOqDT4HyROV2Dm1NDxURATSTeiB+zWUbtAB6l7kA+FFOl KMt5FQ5if6UVYfKCPbXssB52Lgv3BkjQri9LLq3hsOOOavyAqo7jfvkDW9Iwp2vKYn GuvEHB46TS4nUIZC5MjcRIucpmDtZgzjfnDK6vP0= 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 AB49039450C6 for ; Fri, 13 Nov 2020 16:58:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org AB49039450C6 Received: by mail-qk1-x744.google.com with SMTP id l2so9426151qkf.0 for ; Fri, 13 Nov 2020 08:58: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=/7J+OwGLt7Jhiy3f6WjVvX1+v1e+qVGjw3ipbw8p1+E=; b=Fum0Es+KRCVHKrN+dNmE16BWerz8Wqo0xxGemnoCpWp1n1SzLn4qwdauOssjuuqnGr SNg0ijOE94CNA1TRXCslK5HOaFIAdOLwB7HyvbH73p/VukqJd9J76maruklsqBMk9ILz A3irabby+Sdep20O/ANK8EfQergh/r0BoYbNg7kDZnWD12rncM+lsFVMROyKSFDHA9cs JZkuNKsJXjD4793mc4PKtBoTuy4K8dSKGyv40NpWKcftjeVKUfuva3wd0JWu1KrmEALf 29/8WfUPTUR+jddu/akkJviu1ER+DeBiO/X/1fHwbjozW96iJhDq+9Hgzvifeq7E4Bkm yI+Q== X-Gm-Message-State: AOAM532Ta11PTyKC+sv+OBfkKqqLziudfgrZLXfaIsxMLYfB7VEtOPqz CSC+1Zwu988mNRB0EODBUFAxkoHMq9UnZg== X-Google-Smtp-Source: ABdhPJxBDyjGU67EK6EDHxatrhU7z0NciUIPVGDmDZXN03BLF9arXf4h4vr0cPDdl0axwt3LsrLhjw== X-Received: by 2002:a37:793:: with SMTP id 141mr3052574qkh.215.1605286728219; Fri, 13 Nov 2020 08:58:48 -0800 (PST) Received: from localhost.localdomain ([177.194.48.209]) by smtp.googlemail.com with ESMTPSA id s16sm7363931qkg.5.2020.11.13.08.58.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Nov 2020 08:58:47 -0800 (PST) To: libc-alpha@sourceware.org Subject: [PATCH v2 04/23] linux: Replace INLINE_SYSCALL_ERROR_RETURN_VALUE with __syscall_error Date: Fri, 13 Nov 2020 13:58:18 -0300 Message-Id: <20201113165837.121629-5-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201113165837.121629-1-adhemerval.zanella@linaro.org> References: <20201113165837.121629-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-13.9 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/csky/nptl/tls.h | 4 +-- sysdeps/m68k/nptl/tls.h | 7 ++-- 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 +- sysdeps/unix/sysv/linux/m68k/getpagesize.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/syscall_error.h | 32 +++++++++++++++++ sysdeps/unix/sysv/linux/sysdep.h | 35 ++++++++++++------- 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 +++---- 52 files changed, 148 insertions(+), 88 deletions(-) create mode 100644 sysdeps/unix/sysv/linux/syscall_error.c create mode 100644 sysdeps/unix/sysv/linux/syscall_error.h diff --git a/sysdeps/csky/nptl/tls.h b/sysdeps/csky/nptl/tls.h index 60a59898c4..f8ee464db3 100644 --- a/sysdeps/csky/nptl/tls.h +++ b/sysdeps/csky/nptl/tls.h @@ -96,8 +96,8 @@ typedef struct special attention since 'errno' is not yet available and if the operation can cause a failure 'errno' must not be touched. */ # define TLS_INIT_TP(tcbp) \ - ({ result_var = INTERNAL_SYSCALL_CALL (set_thread_area, \ - (char *) (tcbp) + TLS_TCB_OFFSET) < 0 \ + ({ INTERNAL_SYSCALL_CALL (set_thread_area, \ + (char *) (tcbp) + TLS_TCB_OFFSET) < 0 \ ? "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 53cf33fbb9..bc98f42916 100644 --- a/sysdeps/m68k/nptl/tls.h +++ b/sysdeps/m68k/nptl/tls.h @@ -94,10 +94,9 @@ typedef struct special attention since 'errno' is not yet available and if the operation can cause a failure 'errno' must not be touched. */ # define TLS_INIT_TP(tcbp) \ - ({ \ - INTERNAL_SYSCALL_CALL (set_thread_area, \ - ((void *) (tcbp)) + TLS_TCB_OFFSET) < 0; \ - "unknown error" : NULL; }) + ({ INTERNAL_SYSCALL_CALL (set_thread_area, \ + ((void *) (tcbp)) + TLS_TCB_OFFSET) < 0 \ + ? "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/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 fb3e7a614c..d4554ea9bf 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 (res == 0) 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/m68k/getpagesize.c b/sysdeps/unix/sysv/linux/m68k/getpagesize.c index 6d9d90ab24..d80bc7e870 100644 --- a/sysdeps/unix/sysv/linux/m68k/getpagesize.c +++ b/sysdeps/unix/sysv/linux/m68k/getpagesize.c @@ -28,8 +28,6 @@ int __getpagesize (void) { - int result; - if (GLRO(dl_pagesize) != 0) return GLRO(dl_pagesize); 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 40c3416ec5..bf9c142ae5 100644 --- a/sysdeps/unix/sysv/linux/shmat.c +++ b/sysdeps/unix/sysv/linux/shmat.c @@ -38,6 +38,6 @@ shmat (int shmid, const void *shmaddr, int shmflg) if (resultvar == 0) return raddr; - return (void *) INLINE_SYSCALL_ERROR_RETURN_VALUE (-resultvar); + return (void *) __syscall_error (resultvar); #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..b5647f89d3 --- /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 + +#if 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/syscall_error.h b/sysdeps/unix/sysv/linux/syscall_error.h new file mode 100644 index 0000000000..6523eb5269 --- /dev/null +++ b/sysdeps/unix/sysv/linux/syscall_error.h @@ -0,0 +1,32 @@ +/* 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 + . */ + +#ifndef _SYSCALL_ERROR_H +#define _SYSCALL_ERROR_H + +/* Each architecture might how __syscall_error is called, either by defining + an inline function (default) or by calling a hidden function. Check the + sysdep.h file for the implementation. */ +#define SYSCALL_ERROR_FUNC 0 + +/* Any function attribute used to define the __syscall_error in case of + __SYSCALL_ERROR_FUNC (for instance by using a different calling covention + for intra-DSO calls. */ +#define SYSCALL_ERROR_FUNC_ATTR + +#endif diff --git a/sysdeps/unix/sysv/linux/sysdep.h b/sysdeps/unix/sysv/linux/sysdep.h index e423b5e7b1..474c4e209e 100644 --- a/sysdeps/unix/sysv/linux/sysdep.h +++ b/sysdeps/unix/sysv/linux/sysdep.h @@ -20,18 +20,36 @@ #include #include +#include #include #include #ifndef __ASSEMBLER__ +/* 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. */ + +# if SYSCALL_ERROR_FUNC +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 (val > -4096UL) - { - __set_errno (-val); - return -1; - } + return __syscall_error (val); return val; } @@ -43,15 +61,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 Fri Nov 13 16:58: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: 41052 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 13EBE39450EB; Fri, 13 Nov 2020 16:58:58 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 13EBE39450EB DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1605286738; bh=08Zz7SorYOmOG5WMY8l2130g8p9+wFALxhjSUTcOyxM=; 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=xaIwWP3qRp1H8X0wxgE7iZkWlyiGX/mACZM2uS5QmEPtFQBdxImB9mfL6sNCfyryF tDalvOot47srW/s/Krgm/cW+EYjBbEAxKiays3XwzvW29KaBIxei3jW4fVVowDpe5T cB5FhcQdi2v/aTM9bPVOmVh5DrP/qEU/iiKbxISg= 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 44171394504C for ; Fri, 13 Nov 2020 16:58:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 44171394504C Received: by mail-qk1-x744.google.com with SMTP id r7so9422892qkf.3 for ; Fri, 13 Nov 2020 08:58:55 -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=08Zz7SorYOmOG5WMY8l2130g8p9+wFALxhjSUTcOyxM=; b=SJodYOoL94pkqX+tDUbtiOytDGPyFGjpDPlnhyeDoI4ZyomvxYTpHQ+X4z1US9npOw JkGB2m6GxHS/+A/5Fk+7SfQ1jiKUyzJyh5a5gDRUzrx99qVmZNGUUjEgIQCG8cENrAgB aBZr+KpqzGvOHPbDG+rFPy4KSj6oYeUwnQuDBpjn9cZlJ65J5emEg9rQmjfOQO8i0gBb GArMa/X5nhxOd/wevcVvPBzg767/m4Y5llIny4q7ZiSl//0eY6R87bT71AaPviy4/9iW 1uwTeXIO6KVjgnUtNV3KRd3jh0rl1BEEuLgUMB3RThww7sSffLkexQQlibtyJV+2HEx4 rNrw== X-Gm-Message-State: AOAM533lQfbcvt6PWs7yfp0ReRVftzkOUdpDYYd+d7jGnfC1TtiY8Gv3 JucRL+DkeoCkH9BTaoq8Lme8tvGCZ1utsA== X-Google-Smtp-Source: ABdhPJyyvgUbDovW0b5S0W9BkOaGhQJpHcSErdj1ZZ92ZKtRR8e6bEngZS9SygtwSk2QyTSZLbn6zg== X-Received: by 2002:a05:620a:228f:: with SMTP id o15mr3023052qkh.206.1605286729619; Fri, 13 Nov 2020 08:58:49 -0800 (PST) Received: from localhost.localdomain ([177.194.48.209]) by smtp.googlemail.com with ESMTPSA id s16sm7363931qkg.5.2020.11.13.08.58.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Nov 2020 08:58:49 -0800 (PST) To: libc-alpha@sourceware.org Subject: [PATCH v2 05/23] linux: Use generic __syscall_error for aarch64 Date: Fri, 13 Nov 2020 13:58:19 -0300 Message-Id: <20201113165837.121629-6-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201113165837.121629-1-adhemerval.zanella@linaro.org> References: <20201113165837.121629-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.9 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. --- .../aarch64/{sysdep.c => syscall_error.h} | 23 +++++++------------ 1 file changed, 8 insertions(+), 15 deletions(-) rename sysdeps/unix/sysv/linux/aarch64/{sysdep.c => syscall_error.h} (63%) diff --git a/sysdeps/unix/sysv/linux/aarch64/sysdep.c b/sysdeps/unix/sysv/linux/aarch64/syscall_error.h similarity index 63% rename from sysdeps/unix/sysv/linux/aarch64/sysdep.c rename to sysdeps/unix/sysv/linux/aarch64/syscall_error.h index 6b88f3484f..a45e02dbe4 100644 --- a/sysdeps/unix/sysv/linux/aarch64/sysdep.c +++ b/sysdeps/unix/sysv/linux/aarch64/syscall_error.h @@ -1,5 +1,5 @@ -/* Copyright (C) 2011-2020 Free Software Foundation, Inc. - +/* Linux wrappers for setting errno. AArch64 version. + 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 @@ -13,20 +13,13 @@ 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 + License along with the GNU C Library; if not, see . */ -#include +#ifndef _SYSCALL_ERROR_H +#define _SYSCALL_ERROR_H -long __syscall_error (long err); -hidden_proto (__syscall_error) +#define SYSCALL_ERROR_FUNC 1 +#define SYSCALL_ERROR_FUNC_ATTR -/* 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) +#endif From patchwork Fri Nov 13 16:58: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: 41054 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 A0D223945C04; Fri, 13 Nov 2020 16:58:59 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A0D223945C04 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1605286739; bh=qiHFKES/dlkNOEz4VgfCO4Rx2LcSqpsGMRJy2aNDdb0=; 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=uF1vfvRVkQ7eYOKj7+1+FZbZT2E6LUrT9gr228AhKRE9qUy52LKs8CrOiOGzCMjpy CwU5oDnYZU09V9uFOHqMvg83eovTXxszJMSk4v6L9QiZ7Sjor63V4H2ANwXAAyOdVJ 40mStqspljqSjb/kGqgOkB7UmCC2KXHgMO4lWzHc= 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 A4A3439450D7 for ; Fri, 13 Nov 2020 16:58:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org A4A3439450D7 Received: by mail-qk1-x743.google.com with SMTP id n132so9416920qke.1 for ; Fri, 13 Nov 2020 08:58: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=qiHFKES/dlkNOEz4VgfCO4Rx2LcSqpsGMRJy2aNDdb0=; b=qtwXtqbWU7u9OLBcjDVu6w7fJWJm0RR/IHiyhvpWurK4lw0GFrjvhKmtx+ggWO+o0I q+98+LROOwj3Uv8K4qt+uMXdBli37nV3Zf9L+OWcLtkTHcnwsBy5CKglFcqdipOQSwaq rryliUNXjFidkXaNv7iu8C9kZlxgqX/Eg7P/z8F7oEtBi2i1VmFzfTHzt60FrdO6IiHL 9fXDV93lD9tPSxHAuAmBCwQQKAD8v5ePYoOQoINyr6YUbB/xM1AhvJHt75quYF99D//7 A0vbbZGXnN+mceSxNeK/8WdgdBVMtGvYB09Nuz1vKYcPqH2LQ6Ad2+9daGEa5LAUiopK rO+g== X-Gm-Message-State: AOAM531KjVJ/a7xaq2LPlsMSEKREZMduTbi+Sr/s5Ybt+x/pp66RM81p bLWJDJGhDM5D8fHhdDV3jc1wp4LkQO1/wA== X-Google-Smtp-Source: ABdhPJza6DeymY04SgRzJfoF/PNuOKSxwzqMi/1LuWj+PPH4eYL6Ij8/hHxnslxteRBVDIYE37zO3w== X-Received: by 2002:a37:58c6:: with SMTP id m189mr2983723qkb.129.1605286731061; Fri, 13 Nov 2020 08:58:51 -0800 (PST) Received: from localhost.localdomain ([177.194.48.209]) by smtp.googlemail.com with ESMTPSA id s16sm7363931qkg.5.2020.11.13.08.58.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Nov 2020 08:58:50 -0800 (PST) To: libc-alpha@sourceware.org Subject: [PATCH v2 06/23] linux: Use generic __syscall_error for i386 Date: Fri, 13 Nov 2020 13:58:20 -0300 Message-Id: <20201113165837.121629-7-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201113165837.121629-1-adhemerval.zanella@linaro.org> References: <20201113165837.121629-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.9 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 ------------ .../linux/i386/{sysdep.c => syscall_error.h} | 20 ++++++++----------- 2 files changed, 8 insertions(+), 25 deletions(-) rename sysdeps/unix/sysv/linux/i386/{sysdep.c => syscall_error.h} (67%) 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/syscall_error.h similarity index 67% rename from sysdeps/unix/sysv/linux/i386/sysdep.c rename to sysdeps/unix/sysv/linux/i386/syscall_error.h index e6228406dd..0b63c07a4e 100644 --- a/sysdeps/unix/sysv/linux/i386/sysdep.c +++ b/sysdeps/unix/sysv/linux/i386/syscall_error.h @@ -1,4 +1,5 @@ -/* Copyright (C) 2015-2020 Free Software Foundation, Inc. +/* Linux wrappers for setting errno. i386 version. + 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 @@ -15,15 +16,10 @@ License along with the GNU C Library; if not, see . */ -#include +#ifndef _SYSCALL_ERROR_H +#define _SYSCALL_ERROR_H -/* 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; -} +#define SYSCALL_ERROR_FUNC 1 +#define SYSCALL_ERROR_FUNC_ATTR __attribute__ ((__regparm__ (1))) + +#endif From patchwork Fri Nov 13 16:58: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: 41055 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 AD2CC39450F4; Fri, 13 Nov 2020 16:59:01 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AD2CC39450F4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1605286741; bh=G55LUaoorN8z5ckcfr0DxIlqORlmUd3ZXyKja7ArvF0=; 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=mq8qVnIqRfVlnc6e9KvtpIBdoYgZ2VRJLfP4fHR23ppYTZoDtCPHqb6aEllqF4APE HyFwSXe2Arws4lVKbvxpXhZk8FA970Ebv49Xy6k54eC9eXBAfNNKNbMejx8v/C7LAw 5K3ufnDlpYezbu1tdNKsr+F8vjOFtJSxl7tiuifI= 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 1EB1B39450ED for ; Fri, 13 Nov 2020 16:58:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 1EB1B39450ED Received: by mail-qt1-x843.google.com with SMTP id n63so7126317qte.4 for ; Fri, 13 Nov 2020 08:58: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=G55LUaoorN8z5ckcfr0DxIlqORlmUd3ZXyKja7ArvF0=; b=g1FD/6loTG+uAy0zut/O1x1HqMa/adSDfKGpvCHyDNsdQWHxHbh1ZMb9j+q7sF3CJQ hcmxG8OvzEF9ICOgEZFcuXLXHXBnKx+46Kw7vuGYvmPRHnU1zkWKld8mZKeui5Zo8CuK RP5flbE9qA7A1NHC7qlb1Sww+TQpNQov5EFKFtTT5BVZOo6wKn82mHkyyKsOdhWmnqnr iAFVfQ4bnfZBlkJyW/3V5bST33R4XoszAIF5gVcG8GTtfof31Sal7n4mK5jYotVpdXyh AA507+RvPmMtxNp0OdhmEwCpl/NLCdeAApSkAtdbSKJW/bU/0jJOud1T+B/lgUfz+umB vzBA== X-Gm-Message-State: AOAM530BpmVZ+FbpbYCbhGDC1MAd3W8qSe/vvBZrwUS33pH8UEcFQdXk LFd1iOgpGEOirtDGlsCMk/TRXA4wzmcxWQ== X-Google-Smtp-Source: ABdhPJw5gmGJ8lTlTw1BvT7Ghzf10RErJdyaXfldshEOIv89t/OTzWRz02WHoByNDzlHQdPVoXMlUA== X-Received: by 2002:ac8:4250:: with SMTP id r16mr2946821qtm.225.1605286732561; Fri, 13 Nov 2020 08:58:52 -0800 (PST) Received: from localhost.localdomain ([177.194.48.209]) by smtp.googlemail.com with ESMTPSA id s16sm7363931qkg.5.2020.11.13.08.58.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Nov 2020 08:58:52 -0800 (PST) To: libc-alpha@sourceware.org Subject: [PATCH v2 07/23] linux: Use generic __syscall_error for arc Date: Fri, 13 Nov 2020 13:58:21 -0300 Message-Id: <20201113165837.121629-8-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201113165837.121629-1-adhemerval.zanella@linaro.org> References: <20201113165837.121629-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 --- .../linux/arc/{sysdep.c => syscall_error.h} | 20 ++++++------------- sysdeps/unix/sysv/linux/arc/sysdep.h | 12 +---------- 3 files changed, 7 insertions(+), 28 deletions(-) rename sysdeps/unix/sysv/linux/arc/{sysdep.c => syscall_error.h} (67%) 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/syscall_error.h similarity index 67% rename from sysdeps/unix/sysv/linux/arc/sysdep.c rename to sysdeps/unix/sysv/linux/arc/syscall_error.h index fe904d723b..a45e02dbe4 100644 --- a/sysdeps/unix/sysv/linux/arc/sysdep.c +++ b/sysdeps/unix/sysv/linux/arc/syscall_error.h @@ -1,4 +1,4 @@ -/* ARC wrapper for setting errno. +/* Linux wrappers for setting errno. AArch64 version. Copyright (C) 2020 Free Software Foundation, Inc. This file is part of the GNU C Library. @@ -16,18 +16,10 @@ License along with the GNU C Library; if not, see . */ -#include +#ifndef _SYSCALL_ERROR_H +#define _SYSCALL_ERROR_H -extern long int __syscall_error (long int); -libc_hidden_proto (__syscall_error) +#define SYSCALL_ERROR_FUNC 1 +#define SYSCALL_ERROR_FUNC_ATTR -/* 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) +#endif diff --git a/sysdeps/unix/sysv/linux/arc/sysdep.h b/sysdeps/unix/sysv/linux/arc/sysdep.h index 4ab44f6925..7b36b72963 100644 --- a/sysdeps/unix/sysv/linux/arc/sysdep.h +++ b/sysdeps/unix/sysv/linux/arc/sysdep.h @@ -103,22 +103,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 Fri Nov 13 16:58: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: 41056 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 3E9AC3945C09; Fri, 13 Nov 2020 16:59:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3E9AC3945C09 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1605286743; bh=Ha1OFpnKpKdyLh4t8mdXMtT2L2i8+gh/eyZg/WM2EAw=; 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=Kk3rByTtwSrjTI4AvxTKH8tnK6q7TC4f2YrBTlxYvZBqEhJ/3SH0QV9PZsW6Y4L6S PpStIjZJUwmXhA6e1m0AFLmWM7t9Mk3F+kaQhm1fE49RknKRVxrKg6vOzVC+5qB3jq 5WZAKIEmKZ6VI8oHNjvRpEk0fcGy9D9vcSrMPIyY= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-qk1-x72e.google.com (mail-qk1-x72e.google.com [IPv6:2607:f8b0:4864:20::72e]) by sourceware.org (Postfix) with ESMTPS id ED6973945C07 for ; Fri, 13 Nov 2020 16:58:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org ED6973945C07 Received: by mail-qk1-x72e.google.com with SMTP id t191so9407827qka.4 for ; Fri, 13 Nov 2020 08:58:59 -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=Ha1OFpnKpKdyLh4t8mdXMtT2L2i8+gh/eyZg/WM2EAw=; b=TJ02a/JPax1hT//mhrZZz+MxldnhcYcNm2BM0WlWTyOpqffQnvkdMqipkmMe1dLw83 HK0UThjjeruTfUpu3ejWE4yXbO53t6ZXJhBqHssUoYnTV7LgkDONdvjJS0WdDboadpu0 QCPL+gZC8lbNkqzvSjC4GFkux4dk23cU9NQJwZaP9FoKlkCs03Dj63fZQExTMucLx5wU hbOzoKJx5M7NlpHsVgjX5XntyoMYoyo9BZAnbFADespJBkAIAMEIv+j+LT8Z9sC5Y+cz ZYJ/EtsjyKF3GvZgQyALB2T/F3+UgmOOWNBIvkMXLyaszcQE3O3OqF/vla3ypNDiUp8B JCeg== X-Gm-Message-State: AOAM533o8nyfgHa8/n6G+2q1+3FacUF9WJZY6AZJr/ntU3EWPmVAGOc0 ta4rzMmWlM7KuEF0Gpoaact5f1nS5BYJeg== X-Google-Smtp-Source: ABdhPJz2COMG3pjcWpsv5quvF2balnVewOXQBSIkrSu14NvpmjANK4hvbfCVCvrltxl1jREu3eou/g== X-Received: by 2002:a05:620a:408f:: with SMTP id f15mr2868521qko.276.1605286734244; Fri, 13 Nov 2020 08:58:54 -0800 (PST) Received: from localhost.localdomain ([177.194.48.209]) by smtp.googlemail.com with ESMTPSA id s16sm7363931qkg.5.2020.11.13.08.58.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Nov 2020 08:58:53 -0800 (PST) To: libc-alpha@sourceware.org Subject: [PATCH v2 08/23] linux: Use generic __syscall_error for powerpc Date: Fri, 13 Nov 2020 13:58:22 -0300 Message-Id: <20201113165837.121629-9-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201113165837.121629-1-adhemerval.zanella@linaro.org> References: <20201113165837.121629-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 - .../powerpc/{sysdep.c => syscall_error.h} | 18 ++++++------ sysdeps/unix/sysv/linux/sparc/sysdep.c | 28 ++++++++++++++++++- 15 files changed, 54 insertions(+), 28 deletions(-) delete mode 100644 sysdeps/unix/sysv/linux/powerpc/rt-sysdep.c rename sysdeps/unix/sysv/linux/powerpc/{sysdep.c => syscall_error.h} (74%) 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/syscall_error.h similarity index 74% rename from sysdeps/unix/sysv/linux/powerpc/sysdep.c rename to sysdeps/unix/sysv/linux/powerpc/syscall_error.h index 1bf5ea6f62..924f12435d 100644 --- a/sysdeps/unix/sysv/linux/powerpc/sysdep.c +++ b/sysdeps/unix/sysv/linux/powerpc/syscall_error.h @@ -1,4 +1,5 @@ -/* Copyright (C) 1997-2020 Free Software Foundation, Inc. +/* Linux wrappers for setting errno. PowerPC version. + 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 @@ -15,13 +16,10 @@ License along with the GNU C Library; if not, see . */ -#include +#ifndef _SYSCALL_ERROR_H +#define _SYSCALL_ERROR_H -/* 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; -} +#define SYSCALL_ERROR_FUNC 1 +#define SYSCALL_ERROR_FUNC_ATTR + +#endif 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 Fri Nov 13 16:58: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: 41057 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 DCF803945C15; Fri, 13 Nov 2020 16:59:04 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DCF803945C15 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1605286744; bh=03XM0kntEgYMQVgp2KLRo/PXVJ0qwwAnY5HCvjwT11E=; 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=mb3joNfP/ts2kuq2TDjA6APh6UOBYjhsQ6vciSXdafO9fYPnYKdd628fSYCVTIBUy t0/nNdfOPXCYapy+i6kQALFvcURGR/L4X1ZG5AyLRIRm7bzvdopipqy8nWLJ/3nvCs U6GDbprhAZmmCTVzVU+ZANHbUya/Ow+ap6CzYdTQ= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-qv1-xf42.google.com (mail-qv1-xf42.google.com [IPv6:2607:f8b0:4864:20::f42]) by sourceware.org (Postfix) with ESMTPS id 582DF39450C2 for ; Fri, 13 Nov 2020 16:59:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 582DF39450C2 Received: by mail-qv1-xf42.google.com with SMTP id a15so2747147qvk.5 for ; Fri, 13 Nov 2020 08:59: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=03XM0kntEgYMQVgp2KLRo/PXVJ0qwwAnY5HCvjwT11E=; b=hNvQWMjwhDz10oGwLVH8bz/HMmxiFPzIz/hWZ7OmunHxctlZOi6G26B5hUDscq/JFi UmceBvZhDy1kiuD17gPQGZmSm5jOkpASIj4zQuDKqbCNtdYxCxV2++eHKb6tTLU2Oj0V Z4kXpD8D34iWNIDWng+kDcNsrU7m0IfY0xFLqayeVZ84t23kN6ACZ1HglIn+kqepwvpK awQvG6RouTFUdW5q8mlbmyE/vxu+lwT2QUqXLkY7Ezq57I+7EgwSw7VMHRk+ete/Ixbk pPIGl05vjNvAptrlvAcmYuqGD6ubt1IK9MvsKH9oGsisAz5b0INkU2nXHnwgrXO6dbS1 jXTg== X-Gm-Message-State: AOAM531+kHj68YDUI3k0FDBRSA/cVmkWj7OMrdGBlvUq877milNqMUNz ghbWl2zMyIgIWM2KXvODJRNrIf8HUdsPRw== X-Google-Smtp-Source: ABdhPJx8/1Aw3h2VrSQdyX8fAcg/4lXoTpq2A1uonX2CsvAFjzyNW9X56JxPEcxpEB89jsih4wxwtw== X-Received: by 2002:a05:6214:2e1:: with SMTP id h1mr3220580qvu.60.1605286735659; Fri, 13 Nov 2020 08:58:55 -0800 (PST) Received: from localhost.localdomain ([177.194.48.209]) by smtp.googlemail.com with ESMTPSA id s16sm7363931qkg.5.2020.11.13.08.58.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Nov 2020 08:58:55 -0800 (PST) To: libc-alpha@sourceware.org Subject: [PATCH v2 09/23] linux: Use generic __syscall_error for sparc Date: Fri, 13 Nov 2020 13:58:23 -0300 Message-Id: <20201113165837.121629-10-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201113165837.121629-1-adhemerval.zanella@linaro.org> References: <20201113165837.121629-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 + sysdeps/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 + sysdeps/unix/sysv/linux/sparc/sparc64/sysdep.h | 1 + sysdeps/unix/sysv/linux/sparc/sparc64/vfork.S | 1 + .../linux/sparc/{sysdep.c => syscall_error.h} | 18 ++++++++---------- 11 files changed, 18 insertions(+), 18 deletions(-) delete mode 100644 sysdeps/unix/sysv/linux/sparc/rt-sysdep.c rename sysdeps/unix/sysv/linux/sparc/{sysdep.c => syscall_error.h} (74%) 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/syscall_error.h similarity index 74% rename from sysdeps/unix/sysv/linux/sparc/sysdep.c rename to sysdeps/unix/sysv/linux/sparc/syscall_error.h index 1bf5ea6f62..6a9fac278a 100644 --- a/sysdeps/unix/sysv/linux/sparc/sysdep.c +++ b/sysdeps/unix/sysv/linux/sparc/syscall_error.h @@ -1,4 +1,5 @@ -/* Copyright (C) 1997-2020 Free Software Foundation, Inc. +/* Linux wrappers for setting errno. SPARC version. + 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 @@ -15,13 +16,10 @@ License along with the GNU C Library; if not, see . */ -#include +#ifndef _SYSCALL_ERROR_H +#define _SYSCALL_ERROR_H -/* 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; -} +#define SYSCALL_ERROR_FUNC 1 +#define SYSCALL_ERROR_FUNC_ATTR + +#endif From patchwork Fri Nov 13 16:58: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: 41058 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 E230E3945C2B; Fri, 13 Nov 2020 16:59:05 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E230E3945C2B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1605286745; bh=tS1xXVGvADoLlo6G1On+zOY4+Ju8VEbk/yBnFtvplps=; 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=bIhy5fOkPEda3VqJVy/Nlpv4a7kq2OccTLXm0OO2JG8NC1uoTrbNqPpjhgKSq0LvP +JIkRey3vtYEpBKhbBQwGIfyJCogznrwkVh9U7D00+jZ4w+iyRc5ywxWIRsJh/f4jP gHJy1LkJ8zBx1TSGuBNxVAivWkWhHuqD+rTwLKCg= 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 C7AE53945C07 for ; Fri, 13 Nov 2020 16:59:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org C7AE53945C07 Received: by mail-qk1-x744.google.com with SMTP id d28so9370126qka.11 for ; Fri, 13 Nov 2020 08:59: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=tS1xXVGvADoLlo6G1On+zOY4+Ju8VEbk/yBnFtvplps=; b=Hb+aO00pIf68KLLfw1lxvCaemUlmz/q5LKnuTHypgELVF+UR9n3XvzIRXvC8Frtcug bNqVZ0UI2qRMnIqBJlusG6vH0Qqt2OcvQJ9ny50WSf41/r3NvGQOqR77+9ZjVUKGtSbC H4ZJQJgVpFFJZs/9xFOh//LWDCKqglh0Q4ypWRCGv9ejV4ZJSfl390R1oVxbzFIuGV1D oEH21bwllbUvL6NXSjhIg9Pcv2dtB3HVYxZg0+msMmvGFl9OWhALrRAYgZnXrAV301Da krxXLgMYjOXNtSKRgCFIDx8TIc3P3ff7GIWzymVfP0ukipcSZ0xVmIpkYTGPEJ8/t8dM qEJw== X-Gm-Message-State: AOAM532at4NKB4Q0X31qeYQtD/GUSEpjUmGsx7GfabhJSfPEVukc5tnC xWehhTZxwDVGaTOdgfnKubdfbiayrLpTrQ== X-Google-Smtp-Source: ABdhPJzbJW+pqlvN7oQi7Ecweu13qr3kj+fvT1Lm3Sc7I9lYFd8ZEUP9mLelfwGR8uc0w+18nbkvFA== X-Received: by 2002:a37:a546:: with SMTP id o67mr3073723qke.167.1605286736966; Fri, 13 Nov 2020 08:58:56 -0800 (PST) Received: from localhost.localdomain ([177.194.48.209]) by smtp.googlemail.com with ESMTPSA id s16sm7363931qkg.5.2020.11.13.08.58.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Nov 2020 08:58:56 -0800 (PST) To: libc-alpha@sourceware.org Subject: [PATCH v2 10/23] linux: Use generic __syscall_error for hppa Date: Fri, 13 Nov 2020 13:58:24 -0300 Message-Id: <20201113165837.121629-11-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201113165837.121629-1-adhemerval.zanella@linaro.org> References: <20201113165837.121629-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 ++++-- .../linux/hppa/{sysdep.c => syscall_error.h} | 20 +++++++++---------- 2 files changed, 13 insertions(+), 13 deletions(-) rename sysdeps/unix/sysv/linux/hppa/{sysdep.c => syscall_error.h} (68%) 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/syscall_error.h similarity index 68% rename from sysdeps/unix/sysv/linux/hppa/sysdep.c rename to sysdeps/unix/sysv/linux/hppa/syscall_error.h index 8c06b6fc80..f5947ccd7c 100644 --- a/sysdeps/unix/sysv/linux/hppa/sysdep.c +++ b/sysdeps/unix/sysv/linux/hppa/syscall_error.h @@ -1,4 +1,5 @@ -/* Copyright (C) 1997-2020 Free Software Foundation, Inc. +/* Linux wrappers for setting errno. HPPA version. + 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 @@ -12,16 +13,13 @@ 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 + License along with the GNU C Library; if not, see . */ -#include +#ifndef _SYSCALL_ERROR_H +#define _SYSCALL_ERROR_H -/* 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; -} +#define SYSCALL_ERROR_FUNC 1 +#define SYSCALL_ERROR_FUNC_ATTR + +#endif From patchwork Fri Nov 13 16:58: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: 41059 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 73AFD39450E7; Fri, 13 Nov 2020 16:59:06 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 73AFD39450E7 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1605286746; bh=wDxhOkqNx5XFzCF8BG6uS8gAKfMKVIJqmesQZW0hRDY=; 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=I7V3I/SRHL8xwLWGRaAIEIdcP3n3oPnLHUZlwKhq8GabqyGM2cynr1Dgl6/XjB2f9 Gf8ORp+lOdbepeXpmR78RFI8nhyYXrojnOcyFtxh2cBEn9uPKEmYe2JHFpmNXGOStG o58Aj2EjuIsnd0Jyq6SrLJOuo/SrKY1GtZpmLmWw= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-qv1-xf42.google.com (mail-qv1-xf42.google.com [IPv6:2607:f8b0:4864:20::f42]) by sourceware.org (Postfix) with ESMTPS id 132793945060 for ; Fri, 13 Nov 2020 16:59:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 132793945060 Received: by mail-qv1-xf42.google.com with SMTP id e5so4912157qvs.1 for ; Fri, 13 Nov 2020 08:59: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=wDxhOkqNx5XFzCF8BG6uS8gAKfMKVIJqmesQZW0hRDY=; b=hqzzJIDhHxeCfV8gImsvJ2Kn3ntTwUQISWgWhBPZ92Rf59o0hPxvFl+YY6Mty9Mrwr P+zB37Xnc+8jA0Ng7v1Y/k3RXVMAm0wiEwRy2dKkZMLEUI9GdCZei8SZMGcajYrjG7n5 fgW8Qufn/7U8Y4EB91exFQ4L62HYpVKrjS4lBahw4pB9K1DPM622oOf8aaCyM099PEyM M+a8M/ziygG02/Q0tCVWTJ78270gyMORXZEQ0iZEzmX4NP8KUJ+Lb6OZLdpOYNrGbhtV REgzh54Zmuy+XsiBWJRGEFtQIfK3WQ8p4q2HD1syT2WySBGdGl7JRCG6iKDnUE7NFnWv 7/wA== X-Gm-Message-State: AOAM531+aUkCC6eFID0xxo8C4DcUEsseamc19We5XhUbBbegY6SLGmgm dmumEKAAHQZ3bLGWu6P89OoFEGqDGnzogA== X-Google-Smtp-Source: ABdhPJw+Ec0jX1eESaW6qkbYpIGnJmcBlhOr64DhOpw5xVjW4i9RCkFS3JeW+pcCPw/hpX2OdCGntw== X-Received: by 2002:a0c:f585:: with SMTP id k5mr3311321qvm.13.1605286738367; Fri, 13 Nov 2020 08:58:58 -0800 (PST) Received: from localhost.localdomain ([177.194.48.209]) by smtp.googlemail.com with ESMTPSA id s16sm7363931qkg.5.2020.11.13.08.58.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Nov 2020 08:58:57 -0800 (PST) To: libc-alpha@sourceware.org Subject: [PATCH v2 11/23] linux: Use generic __syscall_error for arm Date: Fri, 13 Nov 2020 13:58:25 -0300 Message-Id: <20201113165837.121629-12-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201113165837.121629-1-adhemerval.zanella@linaro.org> References: <20201113165837.121629-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.4 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 ------------------- .../linux/arm/{sysdep.S => syscall_error.h} | 24 +++---- 2 files changed, 8 insertions(+), 78 deletions(-) delete mode 100644 sysdeps/unix/arm/sysdep.S rename sysdeps/unix/sysv/linux/arm/{sysdep.S => syscall_error.h} (55%) 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/syscall_error.h similarity index 55% rename from sysdeps/unix/sysv/linux/arm/sysdep.S rename to sysdeps/unix/sysv/linux/arm/syscall_error.h index 94c877b31d..71f74e2bd3 100644 --- a/sysdeps/unix/sysv/linux/arm/sysdep.S +++ b/sysdeps/unix/sysv/linux/arm/syscall_error.h @@ -1,4 +1,5 @@ -/* Copyright (C) 1995-2020 Free Software Foundation, Inc. +/* Linux wrappers for setting errno. ARM version. + 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 @@ -12,22 +13,13 @@ 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 + License along with the GNU C Library; if not, see . */ -#include +#ifndef _SYSCALL_ERROR_H +#define _SYSCALL_ERROR_H - .text +#define SYSCALL_ERROR_FUNC 1 +#define SYSCALL_ERROR_FUNC_ATTR -/* 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 +#endif From patchwork Fri Nov 13 16:58: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: 41060 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 00CCD39450F9; Fri, 13 Nov 2020 16:59:09 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 00CCD39450F9 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1605286749; bh=u7kk517acl7gVyY3650KV/D59GWExHfMgRPQYUuoE1k=; 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=dCNffX/Wf0kczs+bIwn1NPHmRZjqNMBfgpqtRzScmiwjnC3VKvcUi5ZDHVrrc7l1T YjH2OIDjW4v3T+JNUhk3slLyQdUzs9kxY3u4bb2dgABjo6enugs3buR9Cf6TXttqe6 PcLM1KhFnEYTnCIHeELa61uI/PJiY5ZwkicqN+68= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-qt1-x82e.google.com (mail-qt1-x82e.google.com [IPv6:2607:f8b0:4864:20::82e]) by sourceware.org (Postfix) with ESMTPS id 00B463945C2E for ; Fri, 13 Nov 2020 16:59:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 00B463945C2E Received: by mail-qt1-x82e.google.com with SMTP id f93so7101123qtb.10 for ; Fri, 13 Nov 2020 08:59: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=u7kk517acl7gVyY3650KV/D59GWExHfMgRPQYUuoE1k=; b=JsaJ0yC8s5iSqcnRePKKpZU6JkeczGaRrtnnNnBJdRqukqt5GGjJdh9GXiBfDnoZBV YQGE7QWUn0pVzyN2+TqnjjzyaxYbv2g1r6DIag8vMbdlMHwncrYhGd5SALEpzX/DYOH0 ZGX50DlbjgyG30SIffIPeBHZevawlS/XQZwqR/6MIueywInrf/icxJma5Id4sWtQDMni A1YJwPPv0oHU1DEr/z3TMyzL5YKy3Idx4eGsK37JuZGoFqTtTLUNeWw4FDgMZfy4/61R 0oW2ht8KQPYpFdyfS3H/0fY56G+JNZqETYzaEfB1gBR7xYvmmxkPcTkG/KITIMzVR0RJ nnSg== X-Gm-Message-State: AOAM533VHe0XLAz0qK2oLyvoKJ23YHMsAZjwzDOsJDgD0fp7MhyFh2pk mzzSB0nZp+II5vNTjEg/F5pa0qt43IP8Gg== X-Google-Smtp-Source: ABdhPJxLcdj50XNa9PLhhqLQvW/B6rljKwvnPzNp7pbAiw8NKqmLiL143BxrTaQpATJQjp19XPV0IQ== X-Received: by 2002:ac8:5253:: with SMTP id y19mr2755847qtn.260.1605286739771; Fri, 13 Nov 2020 08:58:59 -0800 (PST) Received: from localhost.localdomain ([177.194.48.209]) by smtp.googlemail.com with ESMTPSA id s16sm7363931qkg.5.2020.11.13.08.58.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Nov 2020 08:58:59 -0800 (PST) To: libc-alpha@sourceware.org Subject: [PATCH v2 12/23] linux: Use generic __syscall_error for x86_64 Date: Fri, 13 Nov 2020 13:58:26 -0300 Message-Id: <20201113165837.121629-13-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201113165837.121629-1-adhemerval.zanella@linaro.org> References: <20201113165837.121629-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. --- .../unix/sysv/linux/x86_64/syscall_error.c | 7 +++ sysdeps/unix/sysv/linux/x86_64/sysdep.S | 40 --------------- sysdeps/unix/x86_64/sysdep.S | 49 ------------------- 3 files changed, 7 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/x86_64/syscall_error.c b/sysdeps/unix/sysv/linux/x86_64/syscall_error.c new file mode 100644 index 0000000000..de5491dc50 --- /dev/null +++ b/sysdeps/unix/sysv/linux/x86_64/syscall_error.c @@ -0,0 +1,7 @@ +/* The auto-generated syscalls calls __syscall_error for static objects. */ +#include +#ifndef SHARED +# undef SYSCALL_ERROR_FUNC +# define SYSCALL_ERROR_FUNC 1 +#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 Fri Nov 13 16:58:27 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: 41061 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 7ED6C39450FB; Fri, 13 Nov 2020 16:59:09 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7ED6C39450FB DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1605286749; bh=g7rlNkUkA5ez0wCziPE2B/2bIA7NVoJEwtGokAc0t0g=; 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=YKBX7+bW+3P7NDwSAp7q4QHsfOFlEx+L8vK7HtP3fMALdj0ndusXkvw2ybR6pXMKa LUMY8xUnoAEg7HsvAF+D5t91tVhJR/bMgiaHTzUvo7+IPvykbvAeNkGFY5PFqJPJH/ IIRwUFILiVOdPpDu7QRI0y4yx0jSkaQXBPHCnm0w= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-qt1-x833.google.com (mail-qt1-x833.google.com [IPv6:2607:f8b0:4864:20::833]) by sourceware.org (Postfix) with ESMTPS id D97C33945C26 for ; Fri, 13 Nov 2020 16:59:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org D97C33945C26 Received: by mail-qt1-x833.google.com with SMTP id 7so7156516qtp.1 for ; Fri, 13 Nov 2020 08:59: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=g7rlNkUkA5ez0wCziPE2B/2bIA7NVoJEwtGokAc0t0g=; b=qtwyfGSbX0p26LMviCYqGxflSykt61u7AMSszt6uosxt/disdt0dUBZHjNg/5zAqRQ Ge8Le8rwJ0jIG4dxBESy3hIvVjYELAvjxqeogwHB8LOIiyeD/D+OolfIRa34Fx/c1MLW ZCq7MZbW+60klNY88CEC6N17qpnko7we+UQbNMCbFG08w9XkIl0KkTkH1jbTzzyOUGbd au3iQwrL/PzVdjGH/BKt8QlQA9WQHhuq/59THVhzqSxE3Eh4IUrT3xNqg1C1WcZCrnho lOIWIHgHQ9Sf6nNIPIkSZG9RwUKnIPBszxB8S4jBq8Uf+yoX0Nyyf4AfF01ceCIsJFel pPuw== X-Gm-Message-State: AOAM533mWl6wa8o2e38/iA4hyyLHkiPXDqGyeLOhJi6d9m0BPphW+Vs3 jaHsFdbRPXXJKP/yh7wGJCk+VTGh7MYxVQ== X-Google-Smtp-Source: ABdhPJxsDl/sktMv9Ve7EFPlItrZgmPA3cML3cDcKzV4gdWGNXVUME9gcidSoFVxmxhlJ81hO+sJjA== X-Received: by 2002:aed:2c02:: with SMTP id f2mr3000689qtd.48.1605286741290; Fri, 13 Nov 2020 08:59:01 -0800 (PST) Received: from localhost.localdomain ([177.194.48.209]) by smtp.googlemail.com with ESMTPSA id s16sm7363931qkg.5.2020.11.13.08.59.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Nov 2020 08:59:00 -0800 (PST) To: libc-alpha@sourceware.org Subject: [PATCH v2 13/23] linux: Use generic __syscall_error for s390 Date: Fri, 13 Nov 2020 13:58:27 -0300 Message-Id: <20201113165837.121629-14-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201113165837.121629-1-adhemerval.zanella@linaro.org> References: <20201113165837.121629-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.9 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 | 7 ++ 6 files changed, 7 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..de5491dc50 --- /dev/null +++ b/sysdeps/unix/sysv/linux/s390/syscall_error.c @@ -0,0 +1,7 @@ +/* The auto-generated syscalls calls __syscall_error for static objects. */ +#include +#ifndef SHARED +# undef SYSCALL_ERROR_FUNC +# define SYSCALL_ERROR_FUNC 1 +#endif +#include From patchwork Fri Nov 13 16:58:28 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: 41062 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 7F48839450FF; Fri, 13 Nov 2020 16:59:11 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7F48839450FF DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1605286751; bh=B19qjK+PiZv3eDAw3pLAMkr/P4gKfIIvG3KtkqAYF8Y=; 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=aFFiHUppbN6GN6WTvwnQKDQyrJV8yynhYOTYylmM+e40ey4tduG5vMxZIzfwKbZmE rUlHo85AWoiIpKvR//c6uXE7AzkNfJOaA9yh6dDdqhoOWb8WBnxYcler0LHnCJhUF9 NemXf2dk0vS36bIJEhIBo8n9QMTTQRekqAoqRiMo= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-qv1-xf2b.google.com (mail-qv1-xf2b.google.com [IPv6:2607:f8b0:4864:20::f2b]) by sourceware.org (Postfix) with ESMTPS id 5147439450F3 for ; Fri, 13 Nov 2020 16:59:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 5147439450F3 Received: by mail-qv1-xf2b.google.com with SMTP id v20so1624175qvx.4 for ; Fri, 13 Nov 2020 08:59: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=B19qjK+PiZv3eDAw3pLAMkr/P4gKfIIvG3KtkqAYF8Y=; b=iejxAQ7xBibzyom4SgZBkFrKcuS6jQqYsJm9/fNc2Pik8sBphITaDfTy6nnei6zHMN fziPEppylvD4BROHXh0BpuuQJg5s51ClffChqI9Fo0cGZuX3f2G2BuTfVAf6QaWm23Nt pz1L2qqUJ+S0YKGZVvLdTg4KubVPI+Ui/ZuaLL49Cnp0qJm+l8CqPJspERmptZ12r+Gu i+cULMzzVdeoKM5ibYWCb8kvX6oKddHDrDzt+in1ZgP1PDSl2RedXBSFtgNevok3JcV9 /W6jF4p8dNkSTcS7mA64wwtSfnNJW4dStq4vHeVz4a8I34dy+kR+k9yOWHie+gWenxrC RtUg== X-Gm-Message-State: AOAM5321bbJ9OgOIr2ircnMLszds6GI73vllXxRt+N8RBDzrF/VJdt4A 8UR988U0h88hnCTD4JswyoF4JkK6bQDMDg== X-Google-Smtp-Source: ABdhPJxhkzizchKBiG3Yk2liXElZg5ZH0Xwvy4fO6jYQtpB3s+cBPczkVdn5EDRwnB34N0i9N3i7Bw== X-Received: by 2002:a0c:8c8a:: with SMTP id p10mr3456314qvb.54.1605286742656; Fri, 13 Nov 2020 08:59:02 -0800 (PST) Received: from localhost.localdomain ([177.194.48.209]) by smtp.googlemail.com with ESMTPSA id s16sm7363931qkg.5.2020.11.13.08.59.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Nov 2020 08:59:02 -0800 (PST) To: libc-alpha@sourceware.org Subject: [PATCH v2 14/23] linux: Use generic __syscall_error for sh Date: Fri, 13 Nov 2020 13:58:28 -0300 Message-Id: <20201113165837.121629-15-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201113165837.121629-1-adhemerval.zanella@linaro.org> References: <20201113165837.121629-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.4 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 - .../linux/sh/{sysdep.S => syscall_error.h} | 21 ++-- 3 files changed, 7 insertions(+), 130 deletions(-) delete mode 100644 sysdeps/unix/sh/sysdep.S rename sysdeps/unix/sysv/linux/sh/{sysdep.S => syscall_error.h} (60%) 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/syscall_error.h similarity index 60% rename from sysdeps/unix/sysv/linux/sh/sysdep.S rename to sysdeps/unix/sysv/linux/sh/syscall_error.h index 85ff3f900e..5b75619168 100644 --- a/sysdeps/unix/sysv/linux/sh/sysdep.S +++ b/sysdeps/unix/sysv/linux/sh/syscall_error.h @@ -1,4 +1,5 @@ -/* Copyright (C) 1995-2020 Free Software Foundation, Inc. +/* Linux wrappers for setting errno. SH version. + 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 @@ -15,18 +16,10 @@ License along with the GNU C Library; if not, see . */ -#include +#ifndef _SYSCALL_ERROR_H +#define _SYSCALL_ERROR_H -/* 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. */ +#define SYSCALL_ERROR_FUNC 1 +#define SYSCALL_ERROR_FUNC_ATTR -#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 +#endif From patchwork Fri Nov 13 16:58:29 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: 41063 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 11A243947417; Fri, 13 Nov 2020 16:59:12 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 11A243947417 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1605286752; bh=clwzeDyLzYaY2syjbHOEHSmcK+oGvDhhhAPqABJQ7Ag=; 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=gIzT/aAGui8ShKe+21Sj9QJzBy1AtgQUddgQkZALZq/iA8ya55mCmWtK1JV3HYt83 Wc5b6UlHeoUUd/4LdW2zrVDUCEVLTZ8l9SPUREjx5wFal6CQZDoaZA8c89MTkvN547 mFu9h8eWjuCvLzX/LHvaDbOQSXsJ0S5gY+diSMzU= 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 9648F3947403 for ; Fri, 13 Nov 2020 16:59:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 9648F3947403 Received: by mail-qt1-x843.google.com with SMTP id t5so7141644qtp.2 for ; Fri, 13 Nov 2020 08:59:09 -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=clwzeDyLzYaY2syjbHOEHSmcK+oGvDhhhAPqABJQ7Ag=; b=W4GffzlAAQS6mgCDsZawhNKTa1tf17XNCNydKLl8+6/6Gc+FYfdBUE3pOyjGw8s/JG V0K5YKVZNTl/0QA93OTT3SZPLg550QZGXk3FNMmp/pOmJD6i3Nak5wS7iT9NZsCPAAh2 MRhLYrB7Hr1Mg7sDmzsr3Tc7+CcP3rFRggjV8pQs3C0FicNDWhQ61NRVmkBpIxvSxDu7 GR6RaBOAchTfn6hjmw+1I7jLz4A9eUcUtmAPq+rfuzyqGGhdkYGA46eqTGNLNMwgcKdp icNC0PgJZ9WeoSnuuWMEn6oTP3m2o1FKk9BQdVseKWNEBWY6RQyyf6PBWF7kOvEJMWBx 7Dcw== X-Gm-Message-State: AOAM531OpdKkN7DsGHAJ39JI2oLsbn7veUCyVGsIp4V6zbqTrVknyWk1 r6RUQkxQv/V7V7Vri6pP9PfnVzyktS2Ewg== X-Google-Smtp-Source: ABdhPJz+eomIPOxmZj6qXIn45DdfFPBp2AGF063aF3D/UeGrHCfmsip5DLpuif5nLjQq/IkVMBbp9g== X-Received: by 2002:ac8:36bc:: with SMTP id a57mr2821500qtc.193.1605286744022; Fri, 13 Nov 2020 08:59:04 -0800 (PST) Received: from localhost.localdomain ([177.194.48.209]) by smtp.googlemail.com with ESMTPSA id s16sm7363931qkg.5.2020.11.13.08.59.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Nov 2020 08:59:03 -0800 (PST) To: libc-alpha@sourceware.org Subject: [PATCH v2 15/23] linux: Use generic __syscall_error for microblaze Date: Fri, 13 Nov 2020 13:58:29 -0300 Message-Id: <20201113165837.121629-16-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201113165837.121629-1-adhemerval.zanella@linaro.org> References: <20201113165837.121629-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 --- .../sysv/linux/microblaze/syscall_error.h | 25 ++++++++++++ sysdeps/unix/sysv/linux/microblaze/sysdep.S | 39 ------------------- 3 files changed, 25 insertions(+), 45 deletions(-) create mode 100644 sysdeps/unix/sysv/linux/microblaze/syscall_error.h 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/syscall_error.h b/sysdeps/unix/sysv/linux/microblaze/syscall_error.h new file mode 100644 index 0000000000..3632dfddd7 --- /dev/null +++ b/sysdeps/unix/sysv/linux/microblaze/syscall_error.h @@ -0,0 +1,25 @@ +/* Linux wrappers for setting errno. Microblaze version. + 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 + . */ + +#ifndef _SYSCALL_ERROR_H +#define _SYSCALL_ERROR_H + +#define SYSCALL_ERROR_FUNC 1 +#define SYSCALL_ERROR_FUNC_ATTR + +#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. */ From patchwork Fri Nov 13 16:58:30 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: 41064 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 99C2D3947411; Fri, 13 Nov 2020 16:59:13 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 99C2D3947411 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1605286753; bh=16rCmTjppid7RBBc2F/YsjJTy2YFJGHxKb5dD0u4zgQ=; 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=nnrP+n5AOOa1bsNQGuW8Oyc5D77hsGOh2CTQic8x4meJuIlagzeiZGvWOQDBBfBQ1 s3du/VS9nHeKCzLcNW7DvUp15Wh7THd/+W2L8Y/RdDhZkqn3AVBQBUDjyxiPi1pm7+ 2uJsz4xp7zheo5pDk+NjBhti52EYozKXlaIf3kfI= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-qv1-xf41.google.com (mail-qv1-xf41.google.com [IPv6:2607:f8b0:4864:20::f41]) by sourceware.org (Postfix) with ESMTPS id 024EF3947407 for ; Fri, 13 Nov 2020 16:59:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 024EF3947407 Received: by mail-qv1-xf41.google.com with SMTP id g19so4919434qvy.2 for ; Fri, 13 Nov 2020 08:59:10 -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=16rCmTjppid7RBBc2F/YsjJTy2YFJGHxKb5dD0u4zgQ=; b=lIQkEpGKqcMX4wl3qZZ4UtftueTX+MpWjnLUkU5D6X3m80dlkVgeDtjR28tFLCzG5k 8u5HZwQiZxgBIbiNYjktJjL32BVNubejKT8vCCFRTDgMrA7RrWXgaLTYUC+C7CdGNg4E 7lHrqQVjpaO+lO8ACt2dBNME5aIU5Vrqu49HWfQeK7srVCiyP9j5esSvNvARMjP9UQuj zReKzpCsbNaJPdCo4XvXvwZaDovkNeFJR90+2+ZGsU/feh0Jc0b0dCPgPnJTQeIjkJF9 XdZFMa/z9QFjlinyYPxpgGPreWqnLkMjCiI0Tad88znovw0q64U3xiIbikWrznT59fGN 5G5g== X-Gm-Message-State: AOAM532nAy3BE7zaOcvXK2xOVeY14Lsi+5NRxQv/QdQfVuP0kR9kgBpm dPbPEaPrl9B1s/HyhoE0z8q5b5hrXdKopA== X-Google-Smtp-Source: ABdhPJx97IGR1WnRz8gc0ZjUI5HsgKph8KXkce2jkbyjq6R2kBiJrgQ8Lxucp/kKvziPZsJPlR/YSQ== X-Received: by 2002:a0c:f951:: with SMTP id i17mr3322609qvo.22.1605286745339; Fri, 13 Nov 2020 08:59:05 -0800 (PST) Received: from localhost.localdomain ([177.194.48.209]) by smtp.googlemail.com with ESMTPSA id s16sm7363931qkg.5.2020.11.13.08.59.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Nov 2020 08:59:04 -0800 (PST) To: libc-alpha@sourceware.org Subject: [PATCH v2 16/23] linux: Use generic __syscall_error for ia64 Date: Fri, 13 Nov 2020 13:58:30 -0300 Message-Id: <20201113165837.121629-17-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201113165837.121629-1-adhemerval.zanella@linaro.org> References: <20201113165837.121629-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.9 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 | 5 ++ sysdeps/unix/sysv/linux/ia64/sysdep.S | 58 -------------------- 5 files changed, 5 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..2cd3e3a200 --- /dev/null +++ b/sysdeps/unix/sysv/linux/ia64/syscall_error.c @@ -0,0 +1,5 @@ +/* The auto-generated syscalls calls __syscall_error. */ +#include +#undef SYSCALL_ERROR_FUNC +#define SYSCALL_ERROR_FUNC 1 +#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 Fri Nov 13 16:58:31 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: 41065 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 2A24A3947426; Fri, 13 Nov 2020 16:59:15 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2A24A3947426 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1605286755; bh=VUaeP8V3YzyC66zGIf6NSJ2uNPnzESD9gKiypBmyEjo=; 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=PRRPXSJIDtaDBwXkyx4tCGROU/VS3DajkeRMFFxaXcyfu85hBPUoYhkgHra2M6VFt eDhFHSbEfSCpdrL9rhlMEhp9FMkHtMV3dW/67QZP7S7ZWtop4MsZ9+Gc/o3yvuVZkf KLMxPzOUqebSvledekkvSp6jxUvDc+Cc402fQAE0= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-qk1-x730.google.com (mail-qk1-x730.google.com [IPv6:2607:f8b0:4864:20::730]) by sourceware.org (Postfix) with ESMTPS id 560E9394741D for ; Fri, 13 Nov 2020 16:59:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 560E9394741D Received: by mail-qk1-x730.google.com with SMTP id d28so9370748qka.11 for ; Fri, 13 Nov 2020 08:59:12 -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=VUaeP8V3YzyC66zGIf6NSJ2uNPnzESD9gKiypBmyEjo=; b=f7U2JF6+LDjfN75Zm3JkS6fNJV5Doqhyo+xjBCUTaQk0XMAY5gSh+S2K0lHT1H63y9 6DWf7sZ8tgoEAPvYaHhNiZ3n+RdaL4DZCAkkDyZoL7un3aivKYSdRZSLmMCk1XF2SrRU DWStd4x6UF+7bw0wacVQqZAu9YVkgiz8g7JqSl8C2H5LEKkLwRT/CXvPQIhJoUrzLu6g vPus8/baQpufD6UrraMnEYKC2Wd9140RxOwrD2ECTRq1W7isn8UnRJuqGW/e/sWA1FQy njXeHm1HGEgygDMG7LL8OGLuoqaxNKVXjzqqOyrZ1ZjNf4xctGkVPwDAsrEhmGOVuaVy LCNw== X-Gm-Message-State: AOAM532kkVr8nW6XQfIuBfAZJK0MLXUGFdfwm0ggBAig2AsHdQSEyrSF yPEqLPTDXBuYdmNA2KhykRQD9RtB76vmMg== X-Google-Smtp-Source: ABdhPJwPQg/E7MfIxQReSooGD/1P+mrhe4icXn3a5WvYh+9ITInBfwEd86CbuRJIewaqQARh8XBMtQ== X-Received: by 2002:a37:a14a:: with SMTP id k71mr3005664qke.33.1605286746708; Fri, 13 Nov 2020 08:59:06 -0800 (PST) Received: from localhost.localdomain ([177.194.48.209]) by smtp.googlemail.com with ESMTPSA id s16sm7363931qkg.5.2020.11.13.08.59.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Nov 2020 08:59:06 -0800 (PST) To: libc-alpha@sourceware.org Subject: [PATCH v2 17/23] linux: Use generic __syscall_error for m68k Date: Fri, 13 Nov 2020 13:58:31 -0300 Message-Id: <20201113165837.121629-18-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201113165837.121629-1-adhemerval.zanella@linaro.org> References: <20201113165837.121629-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/syscall_error.h | 25 ++++++++++ sysdeps/unix/sysv/linux/m68k/sysdep.S | 50 -------------------- sysdeps/unix/sysv/linux/m68k/sysdep.h | 9 ++-- 3 files changed, 29 insertions(+), 55 deletions(-) create mode 100644 sysdeps/unix/sysv/linux/m68k/syscall_error.h delete mode 100644 sysdeps/unix/sysv/linux/m68k/sysdep.S diff --git a/sysdeps/unix/sysv/linux/m68k/syscall_error.h b/sysdeps/unix/sysv/linux/m68k/syscall_error.h new file mode 100644 index 0000000000..4ea7cbdad5 --- /dev/null +++ b/sysdeps/unix/sysv/linux/m68k/syscall_error.h @@ -0,0 +1,25 @@ +/* Linux wrappers for setting errno. m68k version. + 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 + . */ + +#ifndef _SYSCALL_ERROR_H +#define _SYSCALL_ERROR_H + +#define SYSCALL_ERROR_FUNC 1 +#define SYSCALL_ERROR_FUNC_ATTR + +#endif 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..24835be910 100644 --- a/sysdeps/unix/sysv/linux/m68k/sysdep.h +++ b/sysdeps/unix/sysv/linux/m68k/sysdep.h @@ -45,11 +45,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 +133,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 Fri Nov 13 16:58:32 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: 41066 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 2E2E3394743A; Fri, 13 Nov 2020 16:59:16 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2E2E3394743A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1605286756; bh=x8biNJz6/aUBuBixY75wcgT3YhL/rm9G5NAoYuy+PN4=; 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=EEq4SPCCDWtk3lQun+H186BqzNo7+j8QelHC/alYtNjnkoAivqqQqRIW3FN04jQf7 rcnIJUYeSw0ON0wcB2pX9oIqAMQ/kwcDunloVGfFJiJssXJpHkTvMiykTGDKGmzAsT 8EOHlv0ZaTtcEjGkbD7Yz1YJ2kWWrAaNUSgJqY+o= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-qv1-xf33.google.com (mail-qv1-xf33.google.com [IPv6:2607:f8b0:4864:20::f33]) by sourceware.org (Postfix) with ESMTPS id A5DF33947425 for ; Fri, 13 Nov 2020 16:59:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org A5DF33947425 Received: by mail-qv1-xf33.google.com with SMTP id b11so4901299qvr.9 for ; Fri, 13 Nov 2020 08:59:13 -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=x8biNJz6/aUBuBixY75wcgT3YhL/rm9G5NAoYuy+PN4=; b=hqDlCaLyCqYwjj3OYIB4u8phKDhYTUoVxlkBNuhIkhhNbmdCSUXl0ia92BYx43AZnr zzhP+OqAd0olqrTl7a9d97wNJXQcWbJprFYnf7fQTr/IAADogqg91UwW0LLoUB0tBuml 4Px1cAypbG/54v4WA+J0W0UGmN2UPY2MmhEkdvBQNWS4RuY8LOmgaHbreo21ltcF6MHb DrbeNPicDimPCQGzHRvbPORqiaujUvJlwFDpLjkb6Bv2GNX6Uv5oR3cJX7yPh+nGGomU mO7dGj0VaCvGzOcBwjS2b7muR7i2DjUyvS/dAIre+tiAtWZHPFsXvayuAHbsEtCkLq2V Ye7A== X-Gm-Message-State: AOAM531DB7lUdEVvuW8Xz9ctnam3ABzRcpc9DW3xmiLV933X0XK+asn3 TKvRlle/0p28rZqNRZaKiKaRW63z2bMqCA== X-Google-Smtp-Source: ABdhPJy+xhLz/S02KsoWslAPWXt1HFXKgU2JJdSxHNGAgN5aM8eAl7baKmcmogGbSEESKiiOueiQbA== X-Received: by 2002:a05:6214:9c4:: with SMTP id dp4mr2957851qvb.44.1605286748093; Fri, 13 Nov 2020 08:59:08 -0800 (PST) Received: from localhost.localdomain ([177.194.48.209]) by smtp.googlemail.com with ESMTPSA id s16sm7363931qkg.5.2020.11.13.08.59.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Nov 2020 08:59:07 -0800 (PST) To: libc-alpha@sourceware.org Subject: [PATCH v2 18/23] linux: Use generic __syscall_error for csky Date: Fri, 13 Nov 2020 13:58:32 -0300 Message-Id: <20201113165837.121629-19-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201113165837.121629-1-adhemerval.zanella@linaro.org> References: <20201113165837.121629-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/syscall_error.h | 25 ++++++++ 2 files changed, 25 insertions(+), 65 deletions(-) delete mode 100644 sysdeps/unix/sysv/linux/csky/abiv2/sysdep.S create mode 100644 sysdeps/unix/sysv/linux/csky/syscall_error.h 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/syscall_error.h b/sysdeps/unix/sysv/linux/csky/syscall_error.h new file mode 100644 index 0000000000..dbdd6ab44f --- /dev/null +++ b/sysdeps/unix/sysv/linux/csky/syscall_error.h @@ -0,0 +1,25 @@ +/* Linux wrappers for setting errno. CSKY version. + 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 + . */ + +#ifndef _SYSCALL_ERROR_H +#define _SYSCALL_ERROR_H + +#define SYSCALL_ERROR_FUNC 1 +#define SYSCALL_ERROR_FUNC_ATTR + +#endif From patchwork Fri Nov 13 16:58:33 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: 41067 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 B939F3947407; Fri, 13 Nov 2020 16:59:18 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B939F3947407 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1605286758; bh=wz2LksJaPC29verM8T1VCdm1oYhxwR1PY+U+GXZsyxE=; 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=uoHqobzUTup5eZEFZK4FLJbRC+7nt++VWAAfwUo1D7eE0vcR/WRovERy7/itdlplc 1q+8361y3Tl543Rd3OQ91v7lZB8nB1EcHjw7LoxWDWvbMIyU97x1+mWMPV/NnbWXil zyhg7EkbbCEVl3XurBK8zItMAdjimqqBuvyt6gGM= 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 0383639450F2 for ; Fri, 13 Nov 2020 16:59:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 0383639450F2 Received: by mail-qk1-x744.google.com with SMTP id v143so9427568qkb.2 for ; Fri, 13 Nov 2020 08:59:15 -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=wz2LksJaPC29verM8T1VCdm1oYhxwR1PY+U+GXZsyxE=; b=QZEehx3dn96Zwii/x5JFkiFTe0aDrXMN09E1i4Fuu8YulL9+D4Pgafary3FuZFX6Zz pkIAow06vrXs2/M25KYKP0sGZ70pt6XerHwWe+q0HDdzCs85+T7FJa5Fg7IhCpcTomU2 5EvMnfyskhRWD6eEGapUi6l1vkvD8Bl0BVCoRLROtV8+0eWcXNdsiczjS2dwcsebc55r n7FdFBJghIKcrUWDmj3A/I3KBF9A60d//m88djYi3bk8wNklJo5zrA2ZLdoae3iuqdkq QWUX1Eafldfd8v9OOsPcwILSTuPCsE283Kvfh7MEdW+dLWUkATIn9dN+qLjNCsZZDkuM K0Dw== X-Gm-Message-State: AOAM533W0weF6jMBaIEgcmLXbAGBTF7bcMjgpSKAHhG4Hu1ca2xks1I8 h0Himz7udIqmgAFe3MX4sGQ0HYh2uXLfuw== X-Google-Smtp-Source: ABdhPJwdjlgAdxzMLoMLU8P0lPdvA5vrWKfW/u0p3Nfw2mEhJnG57AaCLskCvpPoq8617SNVhlXCRw== X-Received: by 2002:a37:2cc2:: with SMTP id s185mr2907016qkh.118.1605286749425; Fri, 13 Nov 2020 08:59:09 -0800 (PST) Received: from localhost.localdomain ([177.194.48.209]) by smtp.googlemail.com with ESMTPSA id s16sm7363931qkg.5.2020.11.13.08.59.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Nov 2020 08:59:08 -0800 (PST) To: libc-alpha@sourceware.org Subject: [PATCH v2 19/23] linux: Use generic __syscall_error for riscv Date: Fri, 13 Nov 2020 13:58:33 -0300 Message-Id: <20201113165837.121629-20-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201113165837.121629-1-adhemerval.zanella@linaro.org> References: <20201113165837.121629-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/syscall_error.h | 25 +++++++++ sysdeps/unix/sysv/linux/riscv/sysdep.S | 51 ------------------- 4 files changed, 25 insertions(+), 58 deletions(-) delete mode 100644 sysdeps/riscv/nptl/nptl-sysdep.S create mode 100644 sysdeps/unix/sysv/linux/riscv/syscall_error.h 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/syscall_error.h b/sysdeps/unix/sysv/linux/riscv/syscall_error.h new file mode 100644 index 0000000000..932f34aa0f --- /dev/null +++ b/sysdeps/unix/sysv/linux/riscv/syscall_error.h @@ -0,0 +1,25 @@ +/* Linux wrappers for setting errno. RISCV version. + 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 + . */ + +#ifndef _SYSCALL_ERROR_H +#define _SYSCALL_ERROR_H + +#define SYSCALL_ERROR_FUNC 1 +#define SYSCALL_ERROR_FUNC_ATTR + +#endif 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) From patchwork Fri Nov 13 16:58:34 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: 41068 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 479EA394743E; Fri, 13 Nov 2020 16:59:19 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 479EA394743E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1605286759; bh=OVh46OXkdIRSZo0zCB0/OZDkefuZA/xoIL47VBBdamw=; 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=d2IGyDdfl8gLKYOPJoj8htJMB7+aJa/W+H+VGBOs8aOkCMATdbRxzsdKNoIkPUZUp Y0TmretGKi41DGkYlyi0HSlZklhtNB00uunYR4dSE/rGcI2pdebGUJaZTqKArvhiwQ wfZg76a8FVQCfCV+gTo1N9j+NmLYszRNoqlLv+xo= 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 4CF833947403 for ; Fri, 13 Nov 2020 16:59:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 4CF833947403 Received: by mail-qk1-x741.google.com with SMTP id d9so9391051qke.8 for ; Fri, 13 Nov 2020 08:59:16 -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=OVh46OXkdIRSZo0zCB0/OZDkefuZA/xoIL47VBBdamw=; b=jCRcPO9T9mqGQ0tOJBmxedQKkLkJmliB+OPinymXIZ1/0/FIO5XA9gOaa6U5qCC3+c xVH/BZ7hpc6/taV4nBRHhy+y6Bp7FWTeJrqIAaqjlDmvxdx08kaTE8JtUJfMUenHKOYq DX5L9GyTbgs9zpsHuZxZ/dblHAlEFRCM0YFfdU8qRs0Zosu1la8aOeGCeLPmdBoz/1xd ddJVF+Toolp4lCJ2Zjl8utz/OPtnW6TY0+J8Lf61nShf2xP8lkGy4i9TIgZctXIeqOdq oIS2kUVEsVzWf9YFK1C3v/5RTpGwtq6aPzDYKCx4T1SFF6oRFMnCl1DwOiVqDNuEdLNw 7vLA== X-Gm-Message-State: AOAM530tnx/8qkk3pRCUm+AQlvaBVsvRO/WXEcIWrbAww+OaDziIanw6 vUu2PPkiNKcFuB67hNaq0UXxleLAeLH8Kg== X-Google-Smtp-Source: ABdhPJzbNAmgMDKUtrBVNMvTiCZwBbtuId/YwZf5Str5ml1EO4d20VYEw+3m0GprKbI6id7l0i2SjA== X-Received: by 2002:a37:a0c1:: with SMTP id j184mr2502988qke.364.1605286750773; Fri, 13 Nov 2020 08:59:10 -0800 (PST) Received: from localhost.localdomain ([177.194.48.209]) by smtp.googlemail.com with ESMTPSA id s16sm7363931qkg.5.2020.11.13.08.59.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Nov 2020 08:59:10 -0800 (PST) To: libc-alpha@sourceware.org Subject: [PATCH v2 20/23] linux: Use generic __syscall_error for nios2 Date: Fri, 13 Nov 2020 13:58:34 -0300 Message-Id: <20201113165837.121629-21-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201113165837.121629-1-adhemerval.zanella@linaro.org> References: <20201113165837.121629-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.9 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/syscall_error.h | 25 ++++++++++ sysdeps/unix/sysv/linux/nios2/sysdep.S | 50 ------------------- 2 files changed, 25 insertions(+), 50 deletions(-) create mode 100644 sysdeps/unix/sysv/linux/nios2/syscall_error.h delete mode 100644 sysdeps/unix/sysv/linux/nios2/sysdep.S diff --git a/sysdeps/unix/sysv/linux/nios2/syscall_error.h b/sysdeps/unix/sysv/linux/nios2/syscall_error.h new file mode 100644 index 0000000000..c13958a07d --- /dev/null +++ b/sysdeps/unix/sysv/linux/nios2/syscall_error.h @@ -0,0 +1,25 @@ +/* Linux wrappers for setting errno. NIOS2 version. + 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 + . */ + +#ifndef _SYSCALL_ERROR_H +#define _SYSCALL_ERROR_H + +#define SYSCALL_ERROR_FUNC 1 +#define SYSCALL_ERROR_FUNC_ATTR + +#endif 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 From patchwork Fri Nov 13 16:58:35 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: 41069 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 D3C5D3947C05; Fri, 13 Nov 2020 16:59:19 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D3C5D3947C05 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1605286759; 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=SA6eyuMqEaTzGyrVwsuFdW7YrTNswkUHkKkcsULqJulwb3XGEiUjO2Q00t0urDu4z x6+M8ojPtZiiJk7SOQIlVKa+EDzKWJwSgO0P5RxQeCbw4lntVXS8PnPEL/aY7KDdfH L8RvfKy4HCqUIj+oTjMefniBCDZDD8kogOUpJHLc= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-qv1-xf42.google.com (mail-qv1-xf42.google.com [IPv6:2607:f8b0:4864:20::f42]) by sourceware.org (Postfix) with ESMTPS id AF4A139450F2 for ; Fri, 13 Nov 2020 16:59:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org AF4A139450F2 Received: by mail-qv1-xf42.google.com with SMTP id g19so4919625qvy.2 for ; Fri, 13 Nov 2020 08:59:17 -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=MBiuo48jWUivtT72IMgi6y2CYtew2oGeFquskjxcitcwMTRjWZFTXB1IRSre5Ss+g3 61bB+hjr4pPxv0iPtDH52oVbci/jsIotr1CU+aX3FxkqwvJbLr/SlCOCsR4QwXGPWwke T6GBpASC/Q5rVnpWr+ek8urOYmRZTgQ0h0KMqut6edLBfXuB0qZ5SAnrpexskpRFDkAL mWzsGV0bzNCf0sCtUwhEzVEJYuN74WnZa3LpLP/WyltVECT/o14TIThLOQ92oS1Sw8KO GOb7V8bjP/sxBynhl4+yQg04kukuXqbvgbBj0qB2hZw/T/gAy/4t41cCM1EY750u6MHy ikww== X-Gm-Message-State: AOAM530PqglXFwxfpqNDMkUERe/qOUSFzHPlEz106lk8gw7KRi/0iRao yvUYNEE4Q673ag3By5L1bhkkby8hoJhTmw== X-Google-Smtp-Source: ABdhPJwjO0kYTEPQIa+iBaT64+mbADSb3OS7k5Lk7ZBL/1/a+pte5li7Wq6g/KTUDQyhYITAexUDOg== X-Received: by 2002:a05:6214:12ed:: with SMTP id w13mr3231466qvv.23.1605286752167; Fri, 13 Nov 2020 08:59:12 -0800 (PST) Received: from localhost.localdomain ([177.194.48.209]) by smtp.googlemail.com with ESMTPSA id s16sm7363931qkg.5.2020.11.13.08.59.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Nov 2020 08:59:11 -0800 (PST) To: libc-alpha@sourceware.org Subject: [PATCH v2 21/23] linux: Use generic __syscall_error for alpha Date: Fri, 13 Nov 2020 13:58:35 -0300 Message-Id: <20201113165837.121629-22-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201113165837.121629-1-adhemerval.zanella@linaro.org> References: <20201113165837.121629-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-13.9 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 Fri Nov 13 16:58:36 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: 41070 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 D36013947412; Fri, 13 Nov 2020 16:59:22 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D36013947412 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1605286762; bh=/XJ5NPRtqkkhJRkPLk6JrO9tIcCox9H25pot+msm2aI=; 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=adAZeKCsNHjbuk+u5lMrG3kELs0t6HzhP1lI6yQvbnVYEqXZlTpSG1jXn9xTISTH1 6s1DT6JnTFkO+hhal7I82qNKhFgnHrEP0CrE+/QOAVH88UGHMtqGeRef5MV8g5P/Lv K04jy+G1LNL73bgGULnTVFDO5dgGHxNkZDIP7oUo= 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 42A6C394743D for ; Fri, 13 Nov 2020 16:59:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 42A6C394743D Received: by mail-qt1-x841.google.com with SMTP id n63so7127295qte.4 for ; Fri, 13 Nov 2020 08:59:19 -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=/XJ5NPRtqkkhJRkPLk6JrO9tIcCox9H25pot+msm2aI=; b=lRVvP1QAVPXmBJHh6+totqurL8m8moxrNVkykAeK+o34foniSVCfYMy0CZaFCCL+Z7 o3dh9P3P91Fre0ihsKVhKTNshRCGwLi0WgtugyEaylOpzbIrTAfgiyQTVFbaBa1ScAOU dA6bQaVw/7FbZhK642RcaAam7P0fYn26SLRz/0LWW+M3oUACtPDl6l0Jva/3wj3LZsSi tjvfNR3gSi8vfZZo8NSZPb8P2qrasOa5En9/lbtv3c+sxod2i2oblPDk2PugYBNP3aNY myuEjGxhlGwE1Ew6dOw/RrqiPL0sdD1Bu6JKOR/tN/Pb6HJkH1U44WwBFxZbgiClNwhn sXSQ== X-Gm-Message-State: AOAM5317KjD0uZBiwi5SIU1SN+7WhGJCzXcpPfbtQly6Ws7lIfjjwzWx +HvJ8+NFc+3C7sB0P8Iarha4NHCCRCbJeg== X-Google-Smtp-Source: ABdhPJy7tlE0qgnKTbpcotcnttNncb/5+BB4/YgU4b4PtfHM5XVw9UPutq2w9IpsaM9uEUNP7E7jFw== X-Received: by 2002:ac8:5901:: with SMTP id 1mr3006973qty.350.1605286753599; Fri, 13 Nov 2020 08:59:13 -0800 (PST) Received: from localhost.localdomain ([177.194.48.209]) by smtp.googlemail.com with ESMTPSA id s16sm7363931qkg.5.2020.11.13.08.59.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Nov 2020 08:59:13 -0800 (PST) To: libc-alpha@sourceware.org Subject: [PATCH v2 22/23] linux: Use generic __syscall_error for mips Date: Fri, 13 Nov 2020 13:58:36 -0300 Message-Id: <20201113165837.121629-23-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201113165837.121629-1-adhemerval.zanella@linaro.org> References: <20201113165837.121629-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 | 5 + sysdeps/unix/sysv/linux/mips/vfork.S | 1 + 15 files changed, 19 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..b6026395b2 --- /dev/null +++ b/sysdeps/unix/sysv/linux/mips/syscall_error.c @@ -0,0 +1,5 @@ +/* The auto-generated syscalls call __syscall_error. */ +#include +#undef SYSCALL_ERROR_FUNC +#define SYSCALL_ERROR_FUNC 1 +#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 From patchwork Fri Nov 13 16:58:37 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: 41071 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 62C963945062; Fri, 13 Nov 2020 16:59:23 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 62C963945062 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1605286763; bh=0u0pfD6b99iORjlEl2Ln+4CbMUMqK1l8QD6i+cGM8b8=; 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=XOZk4mvPx9tE1VdSLI/hbaCrdVios/flKg1eY6N0hD3tjCi6ifFTUQIM7iSAL+vtk 53QkPK/ZZ3eKnHwGSGs3HYv+WRyfpqDnzgHAUy83QheyEQRdvHuLqh9kiCvAgDg6LO /WRgILk0pF2F02+qiSzSD7qMRzI4gyBaI4IHVyKU= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-qv1-xf42.google.com (mail-qv1-xf42.google.com [IPv6:2607:f8b0:4864:20::f42]) by sourceware.org (Postfix) with ESMTPS id 92E483947C0D for ; Fri, 13 Nov 2020 16:59:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 92E483947C0D Received: by mail-qv1-xf42.google.com with SMTP id v20so1624545qvx.4 for ; Fri, 13 Nov 2020 08:59:20 -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=0u0pfD6b99iORjlEl2Ln+4CbMUMqK1l8QD6i+cGM8b8=; b=Lk6qQnK1HcgEzYnTutx9bavznxTUwiaqQ48cGY594FI2QqXEv2LLKmVQMsdS5LjuT4 doYK7xvkt9KcnXs1vANdZe/+Xa8Yac7fCQwGFYztzBsJ9zBix65jLgVq8/gv4WQhzMlv URGIQGzbh3wdhAI+6PA4FzQrSxB8DcbPDU8ZNdjnWQ3Nzl/8VqVtiHlgxYUy68m4rnmb ETGLKaU41ovTiFPItsZgfH8EXee3oEFZdygm9Q6zmI9Mbw872SUf0iP3SlYKM819q0kS wqkIRciyQLEqXz+b6N/3Xg0a7Zb7IHpn1zan8TXC7Nfy7Vt/EKYhS/uvvoqFOJyH9YSp /Oiw== X-Gm-Message-State: AOAM531ptLSIQyroMigfvnshhJyV34dnP6z7F+4BUjpsWhGkcWFL9yUW zdlHIgcIOeMW0HlzWhnVLh/lrCb6BxgiHA== X-Google-Smtp-Source: ABdhPJxwC9Dr5KWgf7Gafy94Q+2p8OkKbdtfid54EDamin8SMMg1Gqe4fsLpjDfQbLF6FFIl3xaG9g== X-Received: by 2002:ad4:47b0:: with SMTP id a16mr3257317qvz.22.1605286754920; Fri, 13 Nov 2020 08:59:14 -0800 (PST) Received: from localhost.localdomain ([177.194.48.209]) by smtp.googlemail.com with ESMTPSA id s16sm7363931qkg.5.2020.11.13.08.59.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Nov 2020 08:59:14 -0800 (PST) To: libc-alpha@sourceware.org Subject: [PATCH v2 23/23] linux: Make SYSCALL_ERROR_FUNC as default Date: Fri, 13 Nov 2020 13:58:37 -0300 Message-Id: <20201113165837.121629-24-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201113165837.121629-1-adhemerval.zanella@linaro.org> References: <20201113165837.121629-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-13.9 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" It is the more common option overall, only alpha, ia64, mips, and x86_64 inline the __syscall_erro call. --- .../unix/sysv/linux/aarch64/syscall_error.h | 25 ------------------- .../sysv/linux/{arm => alpha}/syscall_error.h | 4 +-- sysdeps/unix/sysv/linux/arc/syscall_error.h | 25 ------------------- sysdeps/unix/sysv/linux/i386/syscall_error.h | 25 ------------------- .../sysv/linux/{hppa => ia64}/syscall_error.h | 4 +-- .../sysv/linux/microblaze/syscall_error.h | 25 ------------------- .../sysv/linux/{m68k => mips}/syscall_error.h | 4 +-- sysdeps/unix/sysv/linux/nios2/syscall_error.h | 25 ------------------- .../unix/sysv/linux/powerpc/syscall_error.h | 25 ------------------- sysdeps/unix/sysv/linux/riscv/syscall_error.h | 25 ------------------- sysdeps/unix/sysv/linux/sh/syscall_error.h | 25 ------------------- sysdeps/unix/sysv/linux/sparc/syscall_error.h | 25 ------------------- sysdeps/unix/sysv/linux/syscall_error.h | 4 +-- .../linux/{csky => x86_64}/syscall_error.h | 4 +-- 14 files changed, 10 insertions(+), 235 deletions(-) delete mode 100644 sysdeps/unix/sysv/linux/aarch64/syscall_error.h rename sysdeps/unix/sysv/linux/{arm => alpha}/syscall_error.h (90%) delete mode 100644 sysdeps/unix/sysv/linux/arc/syscall_error.h delete mode 100644 sysdeps/unix/sysv/linux/i386/syscall_error.h rename sysdeps/unix/sysv/linux/{hppa => ia64}/syscall_error.h (90%) delete mode 100644 sysdeps/unix/sysv/linux/microblaze/syscall_error.h rename sysdeps/unix/sysv/linux/{m68k => mips}/syscall_error.h (90%) delete mode 100644 sysdeps/unix/sysv/linux/nios2/syscall_error.h delete mode 100644 sysdeps/unix/sysv/linux/powerpc/syscall_error.h delete mode 100644 sysdeps/unix/sysv/linux/riscv/syscall_error.h delete mode 100644 sysdeps/unix/sysv/linux/sh/syscall_error.h delete mode 100644 sysdeps/unix/sysv/linux/sparc/syscall_error.h rename sysdeps/unix/sysv/linux/{csky => x86_64}/syscall_error.h (90%) diff --git a/sysdeps/unix/sysv/linux/aarch64/syscall_error.h b/sysdeps/unix/sysv/linux/aarch64/syscall_error.h deleted file mode 100644 index a45e02dbe4..0000000000 --- a/sysdeps/unix/sysv/linux/aarch64/syscall_error.h +++ /dev/null @@ -1,25 +0,0 @@ -/* Linux wrappers for setting errno. AArch64 version. - 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 - . */ - -#ifndef _SYSCALL_ERROR_H -#define _SYSCALL_ERROR_H - -#define SYSCALL_ERROR_FUNC 1 -#define SYSCALL_ERROR_FUNC_ATTR - -#endif diff --git a/sysdeps/unix/sysv/linux/arm/syscall_error.h b/sysdeps/unix/sysv/linux/alpha/syscall_error.h similarity index 90% rename from sysdeps/unix/sysv/linux/arm/syscall_error.h rename to sysdeps/unix/sysv/linux/alpha/syscall_error.h index 71f74e2bd3..28ca78de91 100644 --- a/sysdeps/unix/sysv/linux/arm/syscall_error.h +++ b/sysdeps/unix/sysv/linux/alpha/syscall_error.h @@ -1,4 +1,4 @@ -/* Linux wrappers for setting errno. ARM version. +/* Linux wrappers for setting errno. Alpha version. Copyright (C) 2020 Free Software Foundation, Inc. This file is part of the GNU C Library. @@ -19,7 +19,7 @@ #ifndef _SYSCALL_ERROR_H #define _SYSCALL_ERROR_H -#define SYSCALL_ERROR_FUNC 1 +#define SYSCALL_ERROR_FUNC 0 #define SYSCALL_ERROR_FUNC_ATTR #endif diff --git a/sysdeps/unix/sysv/linux/arc/syscall_error.h b/sysdeps/unix/sysv/linux/arc/syscall_error.h deleted file mode 100644 index a45e02dbe4..0000000000 --- a/sysdeps/unix/sysv/linux/arc/syscall_error.h +++ /dev/null @@ -1,25 +0,0 @@ -/* Linux wrappers for setting errno. AArch64 version. - 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 - . */ - -#ifndef _SYSCALL_ERROR_H -#define _SYSCALL_ERROR_H - -#define SYSCALL_ERROR_FUNC 1 -#define SYSCALL_ERROR_FUNC_ATTR - -#endif diff --git a/sysdeps/unix/sysv/linux/i386/syscall_error.h b/sysdeps/unix/sysv/linux/i386/syscall_error.h deleted file mode 100644 index 0b63c07a4e..0000000000 --- a/sysdeps/unix/sysv/linux/i386/syscall_error.h +++ /dev/null @@ -1,25 +0,0 @@ -/* Linux wrappers for setting errno. i386 version. - 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 - . */ - -#ifndef _SYSCALL_ERROR_H -#define _SYSCALL_ERROR_H - -#define SYSCALL_ERROR_FUNC 1 -#define SYSCALL_ERROR_FUNC_ATTR __attribute__ ((__regparm__ (1))) - -#endif diff --git a/sysdeps/unix/sysv/linux/hppa/syscall_error.h b/sysdeps/unix/sysv/linux/ia64/syscall_error.h similarity index 90% rename from sysdeps/unix/sysv/linux/hppa/syscall_error.h rename to sysdeps/unix/sysv/linux/ia64/syscall_error.h index f5947ccd7c..82d37a0d35 100644 --- a/sysdeps/unix/sysv/linux/hppa/syscall_error.h +++ b/sysdeps/unix/sysv/linux/ia64/syscall_error.h @@ -1,4 +1,4 @@ -/* Linux wrappers for setting errno. HPPA version. +/* Linux wrappers for setting errno. IA64 version. Copyright (C) 2020 Free Software Foundation, Inc. This file is part of the GNU C Library. @@ -19,7 +19,7 @@ #ifndef _SYSCALL_ERROR_H #define _SYSCALL_ERROR_H -#define SYSCALL_ERROR_FUNC 1 +#define SYSCALL_ERROR_FUNC 0 #define SYSCALL_ERROR_FUNC_ATTR #endif diff --git a/sysdeps/unix/sysv/linux/microblaze/syscall_error.h b/sysdeps/unix/sysv/linux/microblaze/syscall_error.h deleted file mode 100644 index 3632dfddd7..0000000000 --- a/sysdeps/unix/sysv/linux/microblaze/syscall_error.h +++ /dev/null @@ -1,25 +0,0 @@ -/* Linux wrappers for setting errno. Microblaze version. - 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 - . */ - -#ifndef _SYSCALL_ERROR_H -#define _SYSCALL_ERROR_H - -#define SYSCALL_ERROR_FUNC 1 -#define SYSCALL_ERROR_FUNC_ATTR - -#endif diff --git a/sysdeps/unix/sysv/linux/m68k/syscall_error.h b/sysdeps/unix/sysv/linux/mips/syscall_error.h similarity index 90% rename from sysdeps/unix/sysv/linux/m68k/syscall_error.h rename to sysdeps/unix/sysv/linux/mips/syscall_error.h index 4ea7cbdad5..2e3536c0ab 100644 --- a/sysdeps/unix/sysv/linux/m68k/syscall_error.h +++ b/sysdeps/unix/sysv/linux/mips/syscall_error.h @@ -1,4 +1,4 @@ -/* Linux wrappers for setting errno. m68k version. +/* Linux wrappers for setting errno. MIPS version. Copyright (C) 2020 Free Software Foundation, Inc. This file is part of the GNU C Library. @@ -19,7 +19,7 @@ #ifndef _SYSCALL_ERROR_H #define _SYSCALL_ERROR_H -#define SYSCALL_ERROR_FUNC 1 +#define SYSCALL_ERROR_FUNC 0 #define SYSCALL_ERROR_FUNC_ATTR #endif diff --git a/sysdeps/unix/sysv/linux/nios2/syscall_error.h b/sysdeps/unix/sysv/linux/nios2/syscall_error.h deleted file mode 100644 index c13958a07d..0000000000 --- a/sysdeps/unix/sysv/linux/nios2/syscall_error.h +++ /dev/null @@ -1,25 +0,0 @@ -/* Linux wrappers for setting errno. NIOS2 version. - 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 - . */ - -#ifndef _SYSCALL_ERROR_H -#define _SYSCALL_ERROR_H - -#define SYSCALL_ERROR_FUNC 1 -#define SYSCALL_ERROR_FUNC_ATTR - -#endif diff --git a/sysdeps/unix/sysv/linux/powerpc/syscall_error.h b/sysdeps/unix/sysv/linux/powerpc/syscall_error.h deleted file mode 100644 index 924f12435d..0000000000 --- a/sysdeps/unix/sysv/linux/powerpc/syscall_error.h +++ /dev/null @@ -1,25 +0,0 @@ -/* Linux wrappers for setting errno. PowerPC version. - 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 - . */ - -#ifndef _SYSCALL_ERROR_H -#define _SYSCALL_ERROR_H - -#define SYSCALL_ERROR_FUNC 1 -#define SYSCALL_ERROR_FUNC_ATTR - -#endif diff --git a/sysdeps/unix/sysv/linux/riscv/syscall_error.h b/sysdeps/unix/sysv/linux/riscv/syscall_error.h deleted file mode 100644 index 932f34aa0f..0000000000 --- a/sysdeps/unix/sysv/linux/riscv/syscall_error.h +++ /dev/null @@ -1,25 +0,0 @@ -/* Linux wrappers for setting errno. RISCV version. - 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 - . */ - -#ifndef _SYSCALL_ERROR_H -#define _SYSCALL_ERROR_H - -#define SYSCALL_ERROR_FUNC 1 -#define SYSCALL_ERROR_FUNC_ATTR - -#endif diff --git a/sysdeps/unix/sysv/linux/sh/syscall_error.h b/sysdeps/unix/sysv/linux/sh/syscall_error.h deleted file mode 100644 index 5b75619168..0000000000 --- a/sysdeps/unix/sysv/linux/sh/syscall_error.h +++ /dev/null @@ -1,25 +0,0 @@ -/* Linux wrappers for setting errno. SH version. - 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 - . */ - -#ifndef _SYSCALL_ERROR_H -#define _SYSCALL_ERROR_H - -#define SYSCALL_ERROR_FUNC 1 -#define SYSCALL_ERROR_FUNC_ATTR - -#endif diff --git a/sysdeps/unix/sysv/linux/sparc/syscall_error.h b/sysdeps/unix/sysv/linux/sparc/syscall_error.h deleted file mode 100644 index 6a9fac278a..0000000000 --- a/sysdeps/unix/sysv/linux/sparc/syscall_error.h +++ /dev/null @@ -1,25 +0,0 @@ -/* Linux wrappers for setting errno. SPARC version. - 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 - . */ - -#ifndef _SYSCALL_ERROR_H -#define _SYSCALL_ERROR_H - -#define SYSCALL_ERROR_FUNC 1 -#define SYSCALL_ERROR_FUNC_ATTR - -#endif diff --git a/sysdeps/unix/sysv/linux/syscall_error.h b/sysdeps/unix/sysv/linux/syscall_error.h index 6523eb5269..3c9737b734 100644 --- a/sysdeps/unix/sysv/linux/syscall_error.h +++ b/sysdeps/unix/sysv/linux/syscall_error.h @@ -20,9 +20,9 @@ #define _SYSCALL_ERROR_H /* Each architecture might how __syscall_error is called, either by defining - an inline function (default) or by calling a hidden function. Check the + an inline function or by calling a hidden function (default). Check the sysdep.h file for the implementation. */ -#define SYSCALL_ERROR_FUNC 0 +#define SYSCALL_ERROR_FUNC 1 /* Any function attribute used to define the __syscall_error in case of __SYSCALL_ERROR_FUNC (for instance by using a different calling covention diff --git a/sysdeps/unix/sysv/linux/csky/syscall_error.h b/sysdeps/unix/sysv/linux/x86_64/syscall_error.h similarity index 90% rename from sysdeps/unix/sysv/linux/csky/syscall_error.h rename to sysdeps/unix/sysv/linux/x86_64/syscall_error.h index dbdd6ab44f..94ae05cf58 100644 --- a/sysdeps/unix/sysv/linux/csky/syscall_error.h +++ b/sysdeps/unix/sysv/linux/x86_64/syscall_error.h @@ -1,4 +1,4 @@ -/* Linux wrappers for setting errno. CSKY version. +/* Linux wrappers for setting errno. x86_64 version. Copyright (C) 2020 Free Software Foundation, Inc. This file is part of the GNU C Library. @@ -19,7 +19,7 @@ #ifndef _SYSCALL_ERROR_H #define _SYSCALL_ERROR_H -#define SYSCALL_ERROR_FUNC 1 +#define SYSCALL_ERROR_FUNC 0 #define SYSCALL_ERROR_FUNC_ATTR #endif