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