ce426f
From 51a8476450158fb522c791c73b7b56dc30a741fc Mon Sep 17 00:00:00 2001
ce426f
From: Anton Blanchard <anton@samba.org>
ce426f
Date: Tue, 15 Jan 2013 12:50:46 -0600
ce426f
Subject: [PATCH 14/42] PowerPC: Rename __kernel_vdso_get_tbfreq to
ce426f
 __kernel_get_tbfreq.
ce426f
ce426f
In order for the __kernel_get_tbfreq vDSO call to work the
ce426f
INTERNAL_VSYSCALL_NCS macro needed to be updated to prevent it from
ce426f
assuming an integer return type (since the timebase frequency is a 64-bit
ce426f
value) by specifying the type of the return type as a macro parameter.  The
ce426f
macro then specifically declares the return value as a 'register' (or
ce426f
implied pair) of the denoted type.  The compiler is then informed that this
ce426f
register (or implied pair) is to be used for the return value.
ce426f
(cherry picked from commit 471a1672d4d55124de4db8273829f96cc14d424a)
ce426f
---
ce426f
 sysdeps/unix/sysv/linux/powerpc/get_clockfreq.c    |  3 ++-
ce426f
 sysdeps/unix/sysv/linux/powerpc/init-first.c       |  2 +-
ce426f
 sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep.h | 28 +++++++++++----------
ce426f
 sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep.h | 29 +++++++++++-----------
ce426f
 5 files changed, 55 insertions(+), 29 deletions(-)
ce426f
ce426f
diff --git glibc-2.17-c758a686/sysdeps/unix/sysv/linux/powerpc/get_clockfreq.c glibc-2.17-c758a686/sysdeps/unix/sysv/linux/powerpc/get_clockfreq.c
ce426f
index a863a27..021594c 100644
ce426f
--- glibc-2.17-c758a686/sysdeps/unix/sysv/linux/powerpc/get_clockfreq.c
ce426f
+++ glibc-2.17-c758a686/sysdeps/unix/sysv/linux/powerpc/get_clockfreq.c
ce426f
@@ -41,7 +41,8 @@ __get_clockfreq (void)
ce426f
   /* If we can use the vDSO to obtain the timebase even better.  */
ce426f
 #ifdef SHARED
ce426f
   INTERNAL_SYSCALL_DECL (err);
ce426f
-  timebase_freq = INTERNAL_VSYSCALL_NO_SYSCALL_FALLBACK (get_tbfreq, err, 0);
ce426f
+  timebase_freq =
ce426f
+    INTERNAL_VSYSCALL_NO_SYSCALL_FALLBACK (get_tbfreq, err, hp_timing_t, 0);
ce426f
   if (INTERNAL_SYSCALL_ERROR_P (timebase_freq, err)
ce426f
       && INTERNAL_SYSCALL_ERRNO (timebase_freq, err) == ENOSYS)
ce426f
 #endif
ce426f
diff --git glibc-2.17-c758a686/sysdeps/unix/sysv/linux/powerpc/init-first.c glibc-2.17-c758a686/sysdeps/unix/sysv/linux/powerpc/init-first.c
ce426f
index 6bcb7d5..5587e2a 100644
ce426f
--- glibc-2.17-c758a686/sysdeps/unix/sysv/linux/powerpc/init-first.c
ce426f
+++ glibc-2.17-c758a686/sysdeps/unix/sysv/linux/powerpc/init-first.c
ce426f
@@ -41,7 +41,7 @@ _libc_vdso_platform_setup (void)
ce426f
 
ce426f
   __vdso_clock_getres = _dl_vdso_vsym ("__kernel_clock_getres", &linux2615);
ce426f
 
ce426f
-  __vdso_get_tbfreq = _dl_vdso_vsym ("__kernel_vdso_get_tbfreq", &linux2615);
ce426f
+  __vdso_get_tbfreq = _dl_vdso_vsym ("__kernel_get_tbfreq", &linux2615);
ce426f
 
ce426f
   __vdso_getcpu = _dl_vdso_vsym ("__kernel_getcpu", &linux2615);
ce426f
 }
ce426f
diff --git glibc-2.17-c758a686/sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep.h glibc-2.17-c758a686/sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep.h
ce426f
index da25c01..fa4116e 100644
ce426f
--- glibc-2.17-c758a686/sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep.h
ce426f
+++ glibc-2.17-c758a686/sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep.h
ce426f
@@ -60,7 +60,8 @@
ce426f
 									      \
ce426f
     if (__vdso_##name != NULL)						      \
ce426f
       {									      \
ce426f
-	sc_ret = INTERNAL_VSYSCALL_NCS (__vdso_##name, sc_err, nr, ##args);   \
ce426f
+	sc_ret =							      \
ce426f
+	  INTERNAL_VSYSCALL_NCS (__vdso_##name, sc_err, long int, nr, ##args);\
ce426f
 	if (!INTERNAL_SYSCALL_ERROR_P (sc_ret, sc_err))			      \
ce426f
 	  goto out;							      \
ce426f
 	if (INTERNAL_SYSCALL_ERRNO (sc_ret, sc_err) != ENOSYS)		      \
ce426f
@@ -90,7 +91,8 @@
ce426f
 									      \
ce426f
     if (__vdso_##name != NULL)						      \
ce426f
       {									      \
ce426f
-	v_ret = INTERNAL_VSYSCALL_NCS (__vdso_##name, err, nr, ##args);	      \
ce426f
+	v_ret =								      \
ce426f
+	  INTERNAL_VSYSCALL_NCS (__vdso_##name, err, long int, nr, ##args);   \
ce426f
 	if (!INTERNAL_SYSCALL_ERROR_P (v_ret, err)			      \
ce426f
 	    || INTERNAL_SYSCALL_ERRNO (v_ret, err) != ENOSYS)		      \
ce426f
 	  goto out;							      \
ce426f
@@ -104,12 +106,12 @@
ce426f
   INTERNAL_SYSCALL (name, err, nr, ##args)
ce426f
 # endif
ce426f
 
ce426f
-# define INTERNAL_VSYSCALL_NO_SYSCALL_FALLBACK(name, err, nr, args...)	      \
ce426f
+# define INTERNAL_VSYSCALL_NO_SYSCALL_FALLBACK(name, err, type, nr, args...)  \
ce426f
   ({									      \
ce426f
-    long int sc_ret = ENOSYS;						      \
ce426f
+    type sc_ret = ENOSYS;						      \
ce426f
 									      \
ce426f
     if (__vdso_##name != NULL)						      \
ce426f
-      sc_ret = INTERNAL_VSYSCALL_NCS (__vdso_##name, err, nr, ##args);	      \
ce426f
+      sc_ret = INTERNAL_VSYSCALL_NCS (__vdso_##name, err, type, nr, ##args);  \
ce426f
     else								      \
ce426f
       err = 1 << 28;							      \
ce426f
     sc_ret;								      \
ce426f
@@ -126,7 +128,7 @@
ce426f
    function call, with the exception of LR (which is needed for the
ce426f
    "sc; bnslr+" sequence) and CR (where only CR0.SO is clobbered to signal
ce426f
    an error return status).  */
ce426f
-# define INTERNAL_VSYSCALL_NCS(funcptr, err, nr, args...) \
ce426f
+# define INTERNAL_VSYSCALL_NCS(funcptr, err, type, nr, args...) \
ce426f
   ({									      \
ce426f
     register void *r0  __asm__ ("r0");					      \
ce426f
     register long int r3  __asm__ ("r3");				      \
ce426f
@@ -139,18 +141,18 @@
ce426f
     register long int r10 __asm__ ("r10");				      \
ce426f
     register long int r11 __asm__ ("r11");				      \
ce426f
     register long int r12 __asm__ ("r12");				      \
ce426f
+    register type rval  __asm__ ("r3");					      \
ce426f
     LOADARGS_##nr (funcptr, args);					      \
ce426f
     __asm__ __volatile__						      \
ce426f
       ("mtctr %0\n\t"							      \
ce426f
        "bctrl\n\t"							      \
ce426f
        "mfcr %0"							      \
ce426f
-       : "=&r" (r0),							      \
ce426f
-	 "=&r" (r3), "=&r" (r4), "=&r" (r5),  "=&r" (r6),  "=&r" (r7),	      \
ce426f
-	 "=&r" (r8), "=&r" (r9), "=&r" (r10), "=&r" (r11), "=&r" (r12)	      \
ce426f
-       : ASM_INPUT_##nr							      \
ce426f
-       : "cr0", "ctr", "lr", "memory");					      \
ce426f
+       : "+r" (r0), "+r" (r3), "+r" (r4), "+r" (r5),  "+r" (r6),  "+r" (r7),  \
ce426f
+	 "+r" (r8), "+r" (r9), "+r" (r10), "+r" (r11), "+r" (r12)	      \
ce426f
+       : : "cr0", "ctr", "lr", "memory");				      \
ce426f
     err = (long int) r0;						      \
ce426f
-    (int) r3;								      \
ce426f
+    __asm__ __volatile__ ("" : "=r" (rval) : "r" (r3), "r" (r4));	      \
ce426f
+    rval;								      \
ce426f
   })
ce426f
 
ce426f
 # undef INLINE_SYSCALL
ce426f
@@ -191,7 +193,7 @@
ce426f
     register long int r10 __asm__ ("r10");				\
ce426f
     register long int r11 __asm__ ("r11");				\
ce426f
     register long int r12 __asm__ ("r12");				\
ce426f
-    LOADARGS_##nr(name, args);					\
ce426f
+    LOADARGS_##nr(name, args);						\
ce426f
     __asm__ __volatile__						\
ce426f
       ("sc   \n\t"							\
ce426f
        "mfcr %0"							\
ce426f
diff --git glibc-2.17-c758a686/sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep.h glibc-2.17-c758a686/sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep.h
ce426f
index 059cf70..b4cdbbb 100644
ce426f
--- glibc-2.17-c758a686/sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep.h
ce426f
+++ glibc-2.17-c758a686/sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep.h
ce426f
@@ -75,7 +75,8 @@
ce426f
 									      \
ce426f
     if (__vdso_##name != NULL)						      \
ce426f
       {									      \
ce426f
-	sc_ret = INTERNAL_VSYSCALL_NCS (__vdso_##name, sc_err, nr, ##args);   \
ce426f
+	sc_ret =							      \
ce426f
+	  INTERNAL_VSYSCALL_NCS (__vdso_##name, sc_err, long int, nr, ##args);\
ce426f
 	if (!INTERNAL_SYSCALL_ERROR_P (sc_ret, sc_err))			      \
ce426f
 	  goto out;							      \
ce426f
 	if (INTERNAL_SYSCALL_ERRNO (sc_ret, sc_err) != ENOSYS)		      \
ce426f
@@ -105,7 +106,8 @@
ce426f
 									      \
ce426f
     if (__vdso_##name != NULL)						      \
ce426f
       {									      \
ce426f
-	v_ret = INTERNAL_VSYSCALL_NCS (__vdso_##name, err, nr, ##args);	      \
ce426f
+	v_ret =								      \
ce426f
+	  INTERNAL_VSYSCALL_NCS (__vdso_##name, err, long int, nr, ##args);   \
ce426f
 	if (!INTERNAL_SYSCALL_ERROR_P (v_ret, err)			      \
ce426f
 	    || INTERNAL_SYSCALL_ERRNO (v_ret, err) != ENOSYS)		      \
ce426f
 	  goto out;							      \
ce426f
@@ -121,12 +123,12 @@
ce426f
 
ce426f
 /* This version is for internal uses when there is no desire
ce426f
    to set errno */
ce426f
-#define INTERNAL_VSYSCALL_NO_SYSCALL_FALLBACK(name, err, nr, args...)	      \
ce426f
+#define INTERNAL_VSYSCALL_NO_SYSCALL_FALLBACK(name, err, type, nr, args...)   \
ce426f
   ({									      \
ce426f
-    long int sc_ret = ENOSYS;						      \
ce426f
+    type sc_ret = ENOSYS;						      \
ce426f
 									      \
ce426f
     if (__vdso_##name != NULL)						      \
ce426f
-      sc_ret = INTERNAL_VSYSCALL_NCS (__vdso_##name, err, nr, ##args);	      \
ce426f
+      sc_ret = INTERNAL_VSYSCALL_NCS (__vdso_##name, err, type, nr, ##args);  \
ce426f
     else								      \
ce426f
       err = 1 << 28;							      \
ce426f
     sc_ret;								      \
ce426f
@@ -142,7 +144,7 @@
ce426f
    gave back in the non-error (CR0.SO cleared) case, otherwise (CR0.SO set)
ce426f
    the negation of the return value in the kernel gets reverted.  */
ce426f
 
ce426f
-#define INTERNAL_VSYSCALL_NCS(funcptr, err, nr, args...) \
ce426f
+#define INTERNAL_VSYSCALL_NCS(funcptr, err, type, nr, args...) \
ce426f
   ({									\
ce426f
     register void *r0  __asm__ ("r0");					\
ce426f
     register long int r3  __asm__ ("r3");				\
ce426f
@@ -151,20 +153,19 @@
ce426f
     register long int r6  __asm__ ("r6");				\
ce426f
     register long int r7  __asm__ ("r7");				\
ce426f
     register long int r8  __asm__ ("r8");				\
ce426f
+    register type rval  __asm__ ("r3");				        \
ce426f
     LOADARGS_##nr (funcptr, args);					\
ce426f
     __asm__ __volatile__						\
ce426f
       ("mtctr %0\n\t"							\
ce426f
        "bctrl\n\t"							\
ce426f
        "mfcr  %0\n\t"							\
ce426f
        "0:"								\
ce426f
-       : "=&r" (r0),							\
ce426f
-         "=&r" (r3), "=&r" (r4), "=&r" (r5),				\
ce426f
-         "=&r" (r6), "=&r" (r7), "=&r" (r8)				\
ce426f
-       : ASM_INPUT_##nr							\
ce426f
-       : "r9", "r10", "r11", "r12",					\
ce426f
-         "cr0", "ctr", "lr", "memory");					\
ce426f
-	  err = (long int) r0;						\
ce426f
-    r3;								\
ce426f
+       : "+r" (r0), "+r" (r3), "+r" (r4), "+r" (r5),  "+r" (r6),        \
ce426f
+         "+r" (r7), "+r" (r8)						\
ce426f
+       : : "r9", "r10", "r11", "r12", "cr0", "ctr", "lr", "memory");	\
ce426f
+    err = (long int) r0;						\
ce426f
+    __asm__ __volatile__ ("" : "=r" (rval) : "r" (r3));		        \
ce426f
+    rval;								\
ce426f
   })
ce426f
 
ce426f
 #undef INLINE_SYSCALL
ce426f
-- 
ce426f
1.7.11.7
ce426f