This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH] [BZ #19363] Use INTERNAL_SYSCALL_TIMES for Linux times
- From: "H.J. Lu" <hjl dot tools at gmail dot com>
- To: GNU C Library <libc-alpha at sourceware dot org>
- Date: Mon, 14 Dec 2015 20:33:59 -0800
- Subject: Re: [PATCH] [BZ #19363] Use INTERNAL_SYSCALL_TIMES for Linux times
- Authentication-results: sourceware.org; auth=none
- References: <20151215032733 dot GA14426 at gmail dot com> <20151215035917 dot GF11489 at vapier dot lan>
On Mon, Dec 14, 2015 at 7:59 PM, Mike Frysinger <vapier@gentoo.org> 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...) \
--
H.J.