From patchwork Tue Dec 15 04:33:59 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "H.J. Lu" X-Patchwork-Id: 10010 Received: (qmail 18542 invoked by alias); 15 Dec 2015 04:34:03 -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 18528 invoked by uid 89); 15 Dec 2015 04:34:02 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.6 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-oi0-f51.google.com MIME-Version: 1.0 X-Received: by 10.202.214.13 with SMTP id n13mr26863247oig.66.1450154039934; Mon, 14 Dec 2015 20:33:59 -0800 (PST) In-Reply-To: <20151215035917.GF11489@vapier.lan> References: <20151215032733.GA14426@gmail.com> <20151215035917.GF11489@vapier.lan> Date: Mon, 14 Dec 2015 20:33:59 -0800 Message-ID: Subject: Re: [PATCH] [BZ #19363] Use INTERNAL_SYSCALL_TIMES for Linux times From: "H.J. Lu" To: GNU C Library On Mon, Dec 14, 2015 at 7:59 PM, Mike Frysinger wrote: > On 14 Dec 2015 19:27, H.J. Lu wrote: >> + clock_t ret = INTERNAL_SYSCALL_TIMES(err, buf); > > needs a space before the ( > >> +/* Incline Linux times system calls. */ > > "incline" ? i don't understand what you mean. > >> +# define INTERNAL_SYSCALL_TIMES(err, buf) \ > > no space after the # I will fix them. >> + ({ \ >> + unsigned long long int resultvar; \ >> + LOAD_ARGS_1 (buf) \ >> + LOAD_REGS_1 \ >> + asm volatile ( \ >> + "syscall\n\t" \ >> + : "=a" (resultvar) \ >> + : "0" (__NR_times) ASM_ARGS_1 : "memory", "cc", "r11", "cx"); \ > > should the cc/r11/cx be made into a sysdep define ? > -mike I don't feel strongly about it. Glibc folks work on x86-64 system calls know what they are doing. But I don't mind the patch like this: diff --git a/sysdeps/unix/sysv/linux/x86_64/sysdep.h b/sysdeps/unix/sysv/linux/x86_64/sysdep.h index fc132f6..c364d08 100644 --- a/sysdeps/unix/sysv/linux/x86_64/sysdep.h +++ b/sysdeps/unix/sysv/linux/x86_64/sysdep.h @@ -218,6 +218,9 @@ # undef INTERNAL_SYSCALL_DECL # define INTERNAL_SYSCALL_DECL(err) do { } while (0) +/* Registers clobbered by syscall. */ +# define REGISTERS_CLOBBERED_BY_SYSCALL "cc", "r11", "cx" + # define INTERNAL_SYSCALL_NCS(name, err, nr, args...) \ ({ \ unsigned long int resultvar; \ @@ -226,7 +229,7 @@ asm volatile ( \ "syscall\n\t" \ : "=a" (resultvar) \ - : "0" (name) ASM_ARGS_##nr : "memory", "cc", "r11", "cx"); \ + : "0" (name) ASM_ARGS_##nr : "memory", REGISTERS_CLOBBERED_BY_SYSCALL); \ (long int) resultvar; }) # undef INTERNAL_SYSCALL # define INTERNAL_SYSCALL(name, err, nr, args...) \ @@ -240,7 +243,7 @@ asm volatile ( \ "syscall\n\t" \ : "=a" (resultvar) \ - : "0" (name) ASM_ARGS_##nr : "memory", "cc", "r11", "cx"); \ + : "0" (name) ASM_ARGS_##nr : "memory", REGISTERS_CLOBBERED_BY_SYSCALL); \ (long int) resultvar; }) # undef INTERNAL_SYSCALL_TYPES # define INTERNAL_SYSCALL_TYPES(name, err, nr, args...) \