#endif
#include <sysdep-vdso.h>
+#if defined __clang__ && defined __powerpc64__
+/* On ppc, sched_getcpu's body eventually expands into asm code
+ that does a bctrl, but clang does not recognize the need to save
+ the link register, so calls loop infinitely instead of returning.
+ As workaround, make a dummy function call that forces a link
+ register save. */
+volatile int sched_getcpu_dummy_glob;
+
+void __attribute__((noinline)) sched_getcpu_dummy ()
+{
+ sched_getcpu_dummy_glob = 45;
+}
+#endif
+
int
sched_getcpu (void)
{
#ifdef __NR_getcpu
unsigned int cpu;
+#if defined __clang__ && defined __powerpc64__
+ sched_getcpu_dummy ();
+#endif
int r = INLINE_VSYSCALL (getcpu, 3, &cpu, NULL, NULL);
return r == -1 ? r : cpu;