From patchwork Fri Sep 26 19:48:53 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 393939 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id B0522140188 for ; Sat, 27 Sep 2014 05:49:11 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:message-id:date:from:mime-version:to:subject :references:in-reply-to:content-type:content-transfer-encoding; q=dns; s=default; b=JPX/A+4SSlMUIfIjUH7wJm5TTE6j0b/+KmiTWa4K+ul 76nXlL2KCzCg7BiVln9/Q4q8RbV0RKjWrREusenIskNy9jQfgnZn+9DXq+xmPlo0 84hcs8VgOihFTlrLsdDIW0pFA0/7yYMMO6zarHiNnFQPxAnPs506LwMVrewKhmlc = DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:message-id:date:from:mime-version:to:subject :references:in-reply-to:content-type:content-transfer-encoding; s=default; bh=4WHfjgy3mLz5PHS24TB5I71oiJ8=; b=pyXPa3a1mgwxhN5DG Lue0E0wLB1IBs2cLF997oY3qVF6Iy8HvEibfHCWrlFedWNoMvtHf9v9sDLBmapvG +XCfANHPFhMhpbKsCAudLi0JdtlwBP1kYZ4wXyQPJSEUFnaDJN19wN6rcUbmI1BF KhYdI4jjkev2/xd6731+B0pp3A= Received: (qmail 19160 invoked by alias); 26 Sep 2014 19:49:04 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 19096 invoked by uid 89); 26 Sep 2014 19:49:04 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.8 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, UNSUBSCRIBE_BODY autolearn=no version=3.3.2 X-HELO: e24smtp05.br.ibm.com Message-ID: <5425C325.7090902@linux.vnet.ibm.com> Date: Fri, 26 Sep 2014 16:48:53 -0300 From: Adhemerval Zanella User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.5.0 MIME-Version: 1.0 To: "GNU C. Library" Subject: [PATCH 1/7] Use inline syscalls for non-cancellable versions References: <5425BCED.5060900@linux.vnet.ibm.com> In-Reply-To: <5425BCED.5060900@linux.vnet.ibm.com> X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 14092619-1798-0000-0000-00000094ADB0 This patch uses inline calls (through INLINE_SYSCALL macro) to define the non-cancellable functions macros to avoid use of the syscall_nocancel entrypoint. Tested on powerpc64, powerpc32, and x86_64. --- * sysdeps/unix/sysv/linux/not-cancel.h (open_not_cancel): Rewrite to be an inline implementation regardless of library is built within. (open_not_cancel_2): Likewise. (__read_nocancel): Likewise. (__write_nocancel): Likewise. (openat_not_cancel): Likewise. (openat_not_cancel_3): Likewise. (openat64_not_cancel): Likewise. (openat64_not_cancel_3): Likewise. (__close_nocancel): Likewise. (pause_not_cancel): Likewise. (nanosleep_not_cancel): Likewise. (sigsuspend_not_cancel): Likewise. --- diff --git a/sysdeps/unix/sysv/linux/not-cancel.h b/sysdeps/unix/sysv/linux/not-cancel.h index 14f5e8b..1bef315 100644 --- a/sysdeps/unix/sysv/linux/not-cancel.h +++ b/sysdeps/unix/sysv/linux/not-cancel.h @@ -17,48 +17,50 @@ License along with the GNU C Library; if not, see . */ -#include +#ifndef NOT_CANCEL_H +# define NOT_CANCEL_H -#if !defined NOT_IN_libc || defined IS_IN_libpthread || defined IS_IN_librt -extern int __open_nocancel (const char *, int, ...) attribute_hidden; -extern int __close_nocancel (int) attribute_hidden; -extern int __read_nocancel (int, void *, size_t) attribute_hidden; -extern int __write_nocancel (int, const void *, size_t) attribute_hidden; -extern pid_t __waitpid_nocancel (pid_t, int *, int) attribute_hidden; -extern int __openat_nocancel (int fd, const char *fname, int oflag, - mode_t mode) attribute_hidden; -extern int __openat64_nocancel (int fd, const char *fname, int oflag, - mode_t mode) attribute_hidden; -#else -# define __open_nocancel(name, ...) __open (name, __VA_ARGS__) -# define __close_nocancel(fd) __close (fd) -# define __read_nocancel(fd, buf, len) __read (fd, buf, len) -# define __write_nocancel(fd, buf, len) __write (fd, buf, len) -# define __waitpid_nocancel(pid, stat_loc, options) \ - __waitpid (pid, stat_loc, options) -# define __openat_nocancel(fd, fname, oflag, mode) \ - openat (fd, fname, oflag, mode) -# define __openat64_nocancel(fd, fname, oflag, mode) \ - openat64 (fd, fname, oflag, mode) -#endif +#include +#include /* Uncancelable open. */ #define open_not_cancel(name, flags, mode) \ - __open_nocancel (name, flags, mode) + ({ int __ret = INLINE_SYSCALL (open, 3, name, flags, mode); \ + __ret; }) #define open_not_cancel_2(name, flags) \ - __open_nocancel (name, flags) + ({ int __ret = INLINE_SYSCALL (open, 2, name, flags); \ + __ret; }) + +/* Uncancelable read. */ +#define __read_nocancel(fd, buf, len) \ + ({ ssize_t __ret = INLINE_SYSCALL (read, 3, fd, buf, len); \ + __ret; }) + +/* Uncancelable write. */ +#define __write_nocancel(fd, buf, len) \ + ({ ssize_t __ret = INLINE_SYSCALL (write, 3, fd, buf, len); \ + __ret; }) /* Uncancelable openat. */ #define openat_not_cancel(fd, fname, oflag, mode) \ - __openat_nocancel (fd, fname, oflag, mode) + ({ int __ret = INLINE_SYSCALL (openat, 4, fd, fname, oflag, mode); \ + __ret; }) #define openat_not_cancel_3(fd, fname, oflag) \ - __openat_nocancel (fd, fname, oflag, 0) + ({ int __ret = INLINE_SYSCALL (openat, 3, fd, fname, oflag); \ + __ret; }) #define openat64_not_cancel(fd, fname, oflag, mode) \ - __openat64_nocancel (fd, fname, oflag, mode) + ({ int __ret = INLINE_SYSCALL (openat, 4, fd, fname, \ + oflag | O_LARGEFILE, mode); \ + __ret; }) #define openat64_not_cancel_3(fd, fname, oflag) \ - __openat64_nocancel (fd, fname, oflag, 0) + ({ int __ret = INLINE_SYSCALL (openat, 3, fd, fname, \ + oflag | O_LARGEFILE); \ + __ret; }) /* Uncancelable close. */ +#define __close_nocancel(fd) \ + ({ int __ret = INLINE_SYSCALL (close, 1, fd); \ + __ret; }) #define close_not_cancel(fd) \ __close_nocancel (fd) #define close_not_cancel_no_status(fd) \ @@ -83,17 +85,29 @@ extern int __openat64_nocancel (int fd, const char *fname, int oflag, __fcntl_nocancel (fd, cmd, val) /* Uncancelable waitpid. */ -#define waitpid_not_cancel(pid, stat_loc, options) \ +#define waitpid_nocancel(pid, stat_loc, options) \ INLINE_SYSCALL (wait4, 4, pid, stat_loc, options, NULL) +#define waitpid_not_cancel(pid, stat_loc, options) \ + waitpid_nocancel(pid, stat_loc, options) /* Uncancelable pause. */ #define pause_not_cancel() \ - __pause_nocancel () + ({ sigset_t set; \ + int __rc = INLINE_SYSCALL (rt_sigprocmask, 4, SIG_BLOCK, NULL, &set, \ + _NSIG / 8); \ + if (__rc == 0) \ + __rc = INLINE_SYSCALL (rt_sigsuspend, 2, &set, _NSIG / 8); \ + __rc; \ + }) /* Uncancelable nanosleep. */ #define nanosleep_not_cancel(requested_time, remaining) \ - __nanosleep_nocancel (requested_time, remaining) + ({ int __ret = INLINE_SYSCALL (nanosleep, 2, requested_time, remaining); \ + __ret; }) /* Uncancelable sigsuspend. */ #define sigsuspend_not_cancel(set) \ - __sigsuspend_nocancel (set) + ({ int __ret = INLINE_SYSCALL (rt_sigsuspend, 2, set, _NSIG / 8); \ + __ret; }) + +#endif /* NOT_CANCEL_H */