about summary refs log tree commit diff
path: root/sysdeps
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps')
-rw-r--r--sysdeps/generic/dl-cache.c3
-rw-r--r--sysdeps/generic/netinet/in.h4
-rw-r--r--sysdeps/libm-ieee754/w_cabs.c26
-rw-r--r--sysdeps/libm-ieee754/w_cabsf.c17
-rw-r--r--sysdeps/libm-ieee754/w_cabsl.c18
-rw-r--r--sysdeps/m68k/fpu/__math.h25
-rw-r--r--sysdeps/powerpc/Implies2
-rw-r--r--sysdeps/powerpc/__longjmp.S66
-rw-r--r--sysdeps/powerpc/__math.h89
-rw-r--r--sysdeps/powerpc/bsd-_setjmp.S29
-rw-r--r--sysdeps/powerpc/dl-machine.h529
-rw-r--r--sysdeps/powerpc/elf/start.c111
-rw-r--r--sysdeps/powerpc/ffs.c38
-rw-r--r--sysdeps/powerpc/fpu_control.h77
-rw-r--r--sysdeps/powerpc/jmp_buf.h19
-rw-r--r--sysdeps/powerpc/setjmp.S66
-rw-r--r--sysdeps/powerpc/strlen.S52
-rw-r--r--sysdeps/unix/sysv/linux/i386/sigaction.c57
-rw-r--r--sysdeps/unix/sysv/linux/netinet/in.h4
-rw-r--r--sysdeps/unix/sysv/linux/poll.c16
-rw-r--r--sysdeps/unix/sysv/linux/powerpc/Dist4
-rw-r--r--sysdeps/unix/sysv/linux/powerpc/_exit.S26
-rw-r--r--sysdeps/unix/sysv/linux/powerpc/brk.c47
-rw-r--r--sysdeps/unix/sysv/linux/powerpc/clone.S74
-rw-r--r--sysdeps/unix/sysv/linux/powerpc/init-first.h27
-rw-r--r--sysdeps/unix/sysv/linux/powerpc/ioctl-types.h1
-rw-r--r--sysdeps/unix/sysv/linux/powerpc/profil.c2
-rw-r--r--sysdeps/unix/sysv/linux/powerpc/sigreturn.S26
-rw-r--r--sysdeps/unix/sysv/linux/powerpc/socket.S83
-rw-r--r--sysdeps/unix/sysv/linux/powerpc/syscall.S32
-rw-r--r--sysdeps/unix/sysv/linux/powerpc/syscall.h357
-rw-r--r--sysdeps/unix/sysv/linux/powerpc/syscalls.list3
-rw-r--r--sysdeps/unix/sysv/linux/powerpc/sysdep.c33
-rw-r--r--sysdeps/unix/sysv/linux/powerpc/sysdep.h53
-rw-r--r--sysdeps/unix/sysv/linux/powerpc/termbits.h356
-rw-r--r--sysdeps/unix/sysv/linux/syscalls.list2
36 files changed, 2275 insertions, 99 deletions
diff --git a/sysdeps/generic/dl-cache.c b/sysdeps/generic/dl-cache.c
index 7b471787f4..c704fd869d 100644
--- a/sysdeps/generic/dl-cache.c
+++ b/sysdeps/generic/dl-cache.c
@@ -77,7 +77,8 @@ _dl_load_cache_lookup (const char *name)
     }
 
   for (i = 0; i < cache->nlibs; ++i)
-    if (cache->libs[i].flags == 1 && /* ELF library entry.  */
+    if ((cache->libs[i].flags == 1 ||
+	 cache->libs[i].flags == 3) && /* ELF library entry.  */
 	/* Make sure string table indices are not bogus before using them.  */
 	cache->libs[i].key < cachesize - sizeof *cache &&
 	cache->libs[i].value < cachesize - sizeof *cache &&
diff --git a/sysdeps/generic/netinet/in.h b/sysdeps/generic/netinet/in.h
index 5531fc2ece..a59f584085 100644
--- a/sysdeps/generic/netinet/in.h
+++ b/sysdeps/generic/netinet/in.h
@@ -128,13 +128,13 @@ struct in_addr
 /* Address to send to all hosts.  */
 #define	INADDR_BROADCAST	((unsigned) 0xffffffff)
 /* Address indicating an error return.  */
-#define	INADDR_NONE		0xffffffff
+#define	INADDR_NONE		((unsigned) 0xffffffff)
 
 /* Network number for local host loopback.  */
 #define	IN_LOOPBACKNET	127
 /* Address to loopback in software to local host.  */
 #ifndef INADDR_LOOPBACK
-#define	INADDR_LOOPBACK	0x7f000001	/* Internet address 127.0.0.1.  */
+#define	INADDR_LOOPBACK	((unsigned) 0x7f000001)	/* Inet address 127.0.0.1.  */
 #endif
 
 
diff --git a/sysdeps/libm-ieee754/w_cabs.c b/sysdeps/libm-ieee754/w_cabs.c
deleted file mode 100644
index bf62f22be3..0000000000
--- a/sysdeps/libm-ieee754/w_cabs.c
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * cabs() wrapper for hypot().
- *
- * Written by J.T. Conklin, <jtc@wimsey.com>
- * Placed into the Public Domain, 1994.
- */
-
-#include <math.h>
-
-double
-__cabs(z)
-	struct __cabs_complex z;
-{
-	return __hypot(z.x, z.y);
-}
-weak_alias (__cabs, cabs)
-
-#ifdef NO_LONG_DOUBLE
-double
-__cabsl(z)
-	struct __cabs_complexl z;
-{
-	return __hypotl(z.x, z.y);
-}
-weak_alias (__cabsl, cabsl)
-#endif
diff --git a/sysdeps/libm-ieee754/w_cabsf.c b/sysdeps/libm-ieee754/w_cabsf.c
deleted file mode 100644
index 20ff5b7744..0000000000
--- a/sysdeps/libm-ieee754/w_cabsf.c
+++ /dev/null
@@ -1,17 +0,0 @@
-/*
- * cabsf() wrapper for hypotf().
- * 
- * Written by J.T. Conklin, <jtc@wimsey.com>
- * Placed into the Public Domain, 1994.
- */
-
-#include "math.h"
-#include "math_private.h"
-
-float
-__cabsf(z)
-	struct __cabs_complexf z;
-{
-	return __hypotf(z.x, z.y);
-}
-weak_alias (__cabsf, cabsf)
diff --git a/sysdeps/libm-ieee754/w_cabsl.c b/sysdeps/libm-ieee754/w_cabsl.c
deleted file mode 100644
index 21ef860a95..0000000000
--- a/sysdeps/libm-ieee754/w_cabsl.c
+++ /dev/null
@@ -1,18 +0,0 @@
-/*
- * cabsl() wrapper for hypotl().
- *
- * Written by J.T. Conklin, <jtc@wimsey.com>
- * Conversion to long double by Ulrich Drepper,
- * Cygnus Support, drepper@cygnus.com.
- * Placed into the Public Domain, 1994.
- */
-
-#include <math.h>
-
-long double
-__cabsl(z)
-	struct __cabs_complexl z;
-{
-	return __hypotl(z.x, z.y);
-}
-weak_alias (__cabsl, cabsl)
diff --git a/sysdeps/m68k/fpu/__math.h b/sysdeps/m68k/fpu/__math.h
index 1a29a56d92..fe01c254d7 100644
--- a/sysdeps/m68k/fpu/__math.h
+++ b/sysdeps/m68k/fpu/__math.h
@@ -43,7 +43,7 @@
    suffixed with f and l for the float and long double version, resp).  OP
    is the name of the fpu operation (without leading f).  */
 
-#ifdef __USE_MISC
+#if defined __USE_MISC || defined __USE_ISOC9X
 #define	__inline_mathop(func, op)			\
   __inline_mathop1(double, func, op)			\
   __inline_mathop1(float, __CONCAT(func,f), op)		\
@@ -81,7 +81,6 @@ __inline_mathop(__sin, sin)
 __inline_mathop(__tan, tan)
 __inline_mathop(__tanh, tanh)
 __inline_mathop(__fabs, abs)
-__inline_mathop(__sqrt, sqrt)
 
 __inline_mathop(__rint, int)
 __inline_mathop(__expm1, etoxm1)
@@ -89,6 +88,9 @@ __inline_mathop(__log1p, lognp1)
 __inline_mathop(__logb, log2)
 __inline_mathop(__significand, getman)
 
+__inline_mathop(__log2, log2)
+__inline_mathop(__exp2, twotox)
+
 #if !defined __NO_MATH_INLINES && defined __OPTIMIZE__
 
 __inline_mathop(atan, atan)
@@ -96,10 +98,8 @@ __inline_mathop(cos, cos)
 __inline_mathop(sin, sin)
 __inline_mathop(tan, tan)
 __inline_mathop(tanh, tanh)
-__inline_mathop(fabs, abs)
-__inline_mathop(sqrt, sqrt)
 
-#if defined(__USE_MISC) || defined(__USE_XOPEN_EXTENDED)
+#if defined __USE_MISC || defined __USE_XOPEN_EXTENDED || defined __USE_ISOC9X
 __inline_mathop(rint, int)
 __inline_mathop(expm1, etoxm1)
 __inline_mathop(log1p, lognp1)
@@ -110,6 +110,11 @@ __inline_mathop(logb, log2)
 __inline_mathop(significand, getman)
 #endif
 
+#ifdef __USE_ISOC9X
+__inline_mathop(log2, log2)
+__inline_mathop(exp2, twotox)
+#endif
+
 #endif /* !__NO_MATH_INLINES && __OPTIMIZE__ */
 
 /* This macro contains the definition for the rest of the inline
@@ -375,11 +380,13 @@ __inline_forward_c(int,finite, (double __value), (__value))
 __inline_forward_c(double,scalbn, (double __x, int __n), (__x, __n))
 #endif
 #if defined __USE_MISC || defined __USE_XOPEN
+#ifndef __USE_ISOC9X /* Conflict with macro of same name.  */
 __inline_forward_c(int,isnan, (double __value), (__value))
+#endif
 __inline_forward_c(int,ilogb, (double __value), (__value))
 #endif
 
-#ifdef __USE_MISC
+#if defined __USE_MISC || defined __USE_ISOC9X
 
 __inline_forward(float,frexpf, (float __value, int *__expptr),
 		 (__value, __expptr))
@@ -387,11 +394,13 @@ __inline_forward_c(float,floorf, (float __x), (__x))
 __inline_forward_c(float,ceilf, (float __x), (__x))
 __inline_forward(float,modff, (float __value, float *__iptr),
 		 (__value, __iptr))
+#ifdef __USE_MISC
 __inline_forward_c(int,isinff, (float __value), (__value))
 __inline_forward_c(int,finitef, (float __value), (__value))
 __inline_forward_c(float,scalbnf, (float __x, int __n), (__x, __n))
 __inline_forward_c(int,isnanf, (float __value), (__value))
 __inline_forward_c(int,ilogbf, (float __value), (__value))
+#endif
 
 __inline_forward(long double,frexpl, (long double __value, int *__expptr),
 		 (__value, __expptr))
@@ -400,14 +409,16 @@ __inline_forward_c(long double,ceill, (long double __x), (__x))
 __inline_forward(long double,modfl,
 		 (long double __value, long double *__iptr),
 		 (__value, __iptr))
+#ifdef __USE_MISC
 __inline_forward_c(int,isinfl, (long double __value), (__value))
 __inline_forward_c(int,finitel, (long double __value), (__value))
 __inline_forward_c(long double,scalbnl, (long double __x, int __n),
 		   (__x, __n))
 __inline_forward_c(int,isnanl, (long double __value), (__value))
 __inline_forward_c(int,ilogbl, (long double __value), (__value))
+#endif
 
-#endif /* __USE_MISC */
+#endif /* Use misc or ISO C9X */
 
 #undef __inline_forward
 #undef __inline_forward_c
diff --git a/sysdeps/powerpc/Implies b/sysdeps/powerpc/Implies
new file mode 100644
index 0000000000..d6acf04a82
--- /dev/null
+++ b/sysdeps/powerpc/Implies
@@ -0,0 +1,2 @@
+wordsize-32
+ieee754
diff --git a/sysdeps/powerpc/__longjmp.S b/sysdeps/powerpc/__longjmp.S
new file mode 100644
index 0000000000..928b5c540a
--- /dev/null
+++ b/sysdeps/powerpc/__longjmp.S
@@ -0,0 +1,66 @@
+/* longjmp for PowerPC.
+   Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public License as
+   published by the Free Software Foundation; either version 2 of the
+   License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  If not,
+   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
+
+#include <sysdep.h>
+#define _ASM
+#include <jmp_buf.h>
+
+ENTRY (__longjmp)
+	lwz 1,(JB_GPR1*4)(3)
+	lwz 2,(JB_GPR2*4)(3)
+	lwz 0,(JB_LR*4)(3)
+	lwz 14,((JB_GPRS+0)*4)(3)
+	lfd 14,((JB_FPRS+0*2)*4)(3)
+	lwz 15,((JB_GPRS+1)*4)(3)
+	lfd 15,((JB_FPRS+1*2)*4)(3)
+	lwz 16,((JB_GPRS+2)*4)(3)
+	lfd 16,((JB_FPRS+2*2)*4)(3)
+	lwz 17,((JB_GPRS+3)*4)(3)
+	lfd 17,((JB_FPRS+3*2)*4)(3)
+	lwz 18,((JB_GPRS+4)*4)(3)
+	lfd 18,((JB_FPRS+4*2)*4)(3)
+	lwz 19,((JB_GPRS+5)*4)(3)
+	lfd 19,((JB_FPRS+5*2)*4)(3)
+	lwz 20,((JB_GPRS+6)*4)(3)
+	lfd 20,((JB_FPRS+6*2)*4)(3)
+	mtlr 0
+	lwz 21,((JB_GPRS+7)*4)(3)
+	lfd 21,((JB_FPRS+7*2)*4)(3)
+	lwz 22,((JB_GPRS+8)*4)(3)
+	lfd 22,((JB_FPRS+8*2)*4)(3)
+	lwz 23,((JB_GPRS+9)*4)(3)
+	lfd 23,((JB_FPRS+9*2)*4)(3)
+	lwz 24,((JB_GPRS+10)*4)(3)
+	lfd 24,((JB_FPRS+10*2)*4)(3)
+	lwz 25,((JB_GPRS+11)*4)(3)
+	lfd 25,((JB_FPRS+11*2)*4)(3)
+	lwz 26,((JB_GPRS+12)*4)(3)
+	lfd 26,((JB_FPRS+12*2)*4)(3)
+	lwz 27,((JB_GPRS+13)*4)(3)
+	lfd 27,((JB_FPRS+13*2)*4)(3)
+	lwz 28,((JB_GPRS+14)*4)(3)
+	lfd 28,((JB_FPRS+14*2)*4)(3)
+	lwz 29,((JB_GPRS+15)*4)(3)
+	lfd 29,((JB_FPRS+15*2)*4)(3)
+	lwz 30,((JB_GPRS+16)*4)(3)
+	lfd 30,((JB_FPRS+16*2)*4)(3)
+	lwz 31,((JB_GPRS+17)*4)(3)
+	lfd 31,((JB_FPRS+17*2)*4)(3)
+	blr
+END (__longjmp)
diff --git a/sysdeps/powerpc/__math.h b/sysdeps/powerpc/__math.h
new file mode 100644
index 0000000000..9dc19a91a5
--- /dev/null
+++ b/sysdeps/powerpc/__math.h
@@ -0,0 +1,89 @@
+/* Inline math functions for powerpc.
+   Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public License as
+   published by the Free Software Foundation; either version 2 of the
+   License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  If not,
+   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
+
+#ifndef __MATH_H
+#define __MATH_H
+
+#ifdef __GNUC__
+#ifndef __NO_MATH_INLINES
+
+#ifdef __cplusplus
+#define        __MATH_INLINE __inline
+#else
+#define        __MATH_INLINE extern __inline
+#endif
+
+__MATH_INLINE double __sgn1 (double __x);
+__MATH_INLINE double
+__sgn1 (double __x)
+{
+  return __x >= 0.0 ? 1.0 : -1.0;
+}
+
+/* We'd want to use this if it was implemented in hardware, but
+   how can we tell? */
+#if 0
+__MATH_INLINE double sqrt (double __x);
+__MATH_INLINE double
+sqrt (double __x)
+{
+  register double __value;
+  __asm
+    ("fsqrt %0,%1"
+     : "=f" (__value) : "f" (__x));
+
+  return __value;
+}
+#endif
+
+__MATH_INLINE double fabs (double __x);
+__MATH_INLINE double
+fabs (double __x)
+{
+  register double __value;
+  __asm
+    ("fabs %0,%1"
+     : "=f" (__value) : "f" (__x));
+
+  return __value;
+}
+
+/* Optimized versions for some non-standardized functions.  */
+#ifdef __USE_MISC
+
+__MATH_INLINE double hypot (double __x, double __y);
+__MATH_INLINE double
+hypot (double __x, double __y)
+{
+  return sqrt (__x * __x + __y * __y);
+}
+
+__MATH_INLINE double __sgn (double __x);
+__MATH_INLINE double
+sgn (double __x)
+{
+  return (__x == 0.0 ? 0.0 : (__x > 0.0 ? 1.0 : -1.0));
+}
+
+#endif /* __USE_MISC  */
+
+#endif /* __NO_MATH_INLINES  */
+#endif /* __GNUC__  */
+
+#endif /* __MATH_H  */
diff --git a/sysdeps/powerpc/bsd-_setjmp.S b/sysdeps/powerpc/bsd-_setjmp.S
new file mode 100644
index 0000000000..90171ea616
--- /dev/null
+++ b/sysdeps/powerpc/bsd-_setjmp.S
@@ -0,0 +1,29 @@
+/* BSD `_setjmp' entry point to `sigsetjmp (..., 0)'.  PowerPC version.
+   Copyright (C) 1994, 1997 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public License as
+   published by the Free Software Foundation; either version 2 of the
+   License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  If not,
+   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
+
+/* This just does a tail-call to `__sigsetjmp (ARG, 0)'.
+   We cannot do it in C because it must be a tail-call, so frame-unwinding
+   in setjmp doesn't clobber the state restored by longjmp.  */
+
+#include <sysdep.h>
+
+ENTRY (_setjmp)
+	li 4,0				/* Set second argument to 0.  */
+	b C_SYMBOL_NAME(__sigsetjmp)
+END (_setjmp)
diff --git a/sysdeps/powerpc/dl-machine.h b/sysdeps/powerpc/dl-machine.h
new file mode 100644
index 0000000000..a60a29723d
--- /dev/null
+++ b/sysdeps/powerpc/dl-machine.h
@@ -0,0 +1,529 @@
+/* Machine-dependent ELF dynamic relocation inline functions.  PowerPC version.
+   Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public License as
+   published by the Free Software Foundation; either version 2 of the
+   License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  If not,
+   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
+
+#define ELF_MACHINE_NAME "powerpc"
+
+#include <assert.h>
+#include <string.h>
+#include <link.h>
+
+/* stuff for the PLT */
+#define PLT_INITIAL_ENTRY_WORDS 18
+#define PLT_LONGBRANCH_ENTRY_WORDS 10
+#define OPCODE_ADDI(rd,ra,simm) \
+  (0x38000000 | (rd) << 21 | (ra) << 16 | (simm) & 0xffff)
+#define OPCODE_ADDIS(rd,ra,simm) \
+  (0x3c000000 | (rd) << 21 | (ra) << 16 | (simm) & 0xffff)
+#define OPCODE_ADD(rd,ra,rb) \
+  (0x7c000214 | (rd) << 21 | (ra) << 16 | (rb) << 11)
+#define OPCODE_B(target) (0x48000000 | (target) & 0x03fffffc)
+#define OPCODE_BA(target) (0x48000002 | (target) & 0x03fffffc)
+#define OPCODE_BCTR() 0x4e800420
+#define OPCODE_LWZ(rd,d,ra) \
+  (0x80000000 | (rd) << 21 | (ra) << 16 | (d) & 0xffff)
+#define OPCODE_MTCTR(rd) (0x7C0903A6 | (rd) << 21)
+#define OPCODE_RLWINM(ra,rs,sh,mb,me) \
+  (0x54000000 | (rs) << 21 | (ra) << 16 | (sh) << 11 | (mb) << 6 | (me) << 1)
+
+#define OPCODE_LI(rd,simm)    OPCODE_ADDI(rd,0,simm)
+#define OPCODE_SLWI(ra,rs,sh) OPCODE_RLWINM(ra,rs,sh,0,31-sh)
+
+
+/* Return nonzero iff E_MACHINE is compatible with the running host.  */
+static inline int
+elf_machine_matches_host (Elf32_Half e_machine)
+{
+  return e_machine == EM_PPC;
+}
+
+
+/* Return the link-time address of _DYNAMIC, the first value in the GOT.  */
+static inline Elf32_Addr
+elf_machine_dynamic (void)
+{
+  Elf32_Addr *got;
+  asm (" bl _GLOBAL_OFFSET_TABLE_-4@local"
+       : "=l"(got));
+  return *got;
+}
+
+/* Return the run-time load address of the shared object.  */
+static inline Elf32_Addr
+elf_machine_load_address (void)
+{
+  unsigned *got;
+  unsigned *branchaddr;
+
+  /* This is much harder than you'd expect.  Possibly I'm missing something.
+     The 'obvious' way:
+
+       Apparently, "bcl 20,31,$+4" is what should be used to load LR
+       with the address of the next instruction.
+       I think this is so that machines that do bl/blr pairing don't
+       get confused.
+
+     asm ("bcl 20,31,0f ;"
+          "0: mflr 0 ;"
+          "lis %0,0b@ha;"
+          "addi %0,%0,0b@l;"
+          "subf %0,%0,0"
+          : "=b" (addr) : : "r0", "lr");
+
+     doesn't work, because the linker doesn't have to (and in fact doesn't)
+     update the @ha and @l references; the loader (which runs after this
+     code) will do that.
+
+     Instead, we use the following trick:
+
+     The linker puts the _link-time_ address of _DYNAMIC at the first
+     word in the GOT. We could branch to that address, if we wanted,
+     by using an @local reloc; the linker works this out, so it's safe
+     to use now. We can't, of course, actually branch there, because
+     we'd cause an illegal instruction exception; so we need to compute
+     the address ourselves. That gives us the following code: */
+
+  /* Get address of the 'b _DYNAMIC@local'...  */
+  asm ("bl 0f ;"
+       "b _DYNAMIC@local;"
+       "0:"
+       : "=l"(branchaddr));
+
+  /* ... and the address of the GOT.  */
+  asm (" bl _GLOBAL_OFFSET_TABLE_-4@local"
+       : "=l"(got));
+
+  /* So now work out the difference between where the branch actually points,
+     and the offset of that location in memory from the start of the file.  */
+  return (Elf32_Addr)branchaddr - *got +
+    (*branchaddr & 0x3fffffc |
+     (int)(*branchaddr << 6 & 0x80000000) >> 6);
+}
+
+#define ELF_MACHINE_BEFORE_RTLD_RELOC(dynamic_info) /* nothing */
+
+/* Perform the relocation specified by RELOC and SYM (which is fully resolved).
+   LOADADDR is the load address of the object; INFO is an array indexed
+   by DT_* of the .dynamic section info.  */
+
+#ifdef RESOLVE
+
+static inline void
+elf_machine_rela (struct link_map *map, const Elf32_Rela *reloc,
+		  const Elf32_Sym *sym, const struct r_found_version *version)
+{
+  Elf32_Addr *const reloc_addr = (Elf32_Addr *)(map->l_addr + reloc->r_offset);
+  Elf32_Word loadbase, finaladdr;
+  const int rinfo = ELF32_R_TYPE (reloc->r_info);
+
+  if (rinfo == R_PPC_NONE)
+    return;
+
+  if (sym && ELF32_ST_TYPE (sym->st_info) == STT_SECTION ||
+      rinfo == R_PPC_RELATIVE)
+    {
+      /* Has already been relocated.  */
+      loadbase = map->l_addr;
+      finaladdr = loadbase + reloc->r_addend;
+    }
+  else
+    {
+      assert (sym != NULL);
+      if (rinfo == R_PPC_JMP_SLOT)
+	loadbase = (Elf32_Word) (char *) RESOLVE (&sym,
+						  version, DL_LOOKUP_NOPLT);
+      else
+	loadbase = (Elf32_Word) (char *) RESOLVE (&sym, version, 0);
+      if (sym == NULL)
+	{
+	  /* Weak symbol that wasn't actually defined anywhere.  */
+	  assert (loadbase == 0);
+	  finaladdr = reloc->r_addend;
+	}
+      else
+	finaladdr = (loadbase + (Elf32_Word)(char *)sym->st_value
+		     + reloc->r_addend);
+    }
+
+  switch (rinfo)
+    {
+    case R_PPC_UADDR16:
+    case R_PPC_ADDR16_LO:
+    case R_PPC_ADDR16:
+      *(Elf32_Half*) reloc_addr = finaladdr;
+      break;
+
+    case R_PPC_ADDR16_HI:
+      *(Elf32_Half*) reloc_addr = finaladdr >> 16;
+      break;
+
+    case R_PPC_ADDR16_HA:
+      *(Elf32_Half*) reloc_addr = finaladdr + 0x8000 >> 16;
+      break;
+
+    case R_PPC_REL24:
+      {
+	Elf32_Sword delta = finaladdr - (Elf32_Word) (char *) reloc_addr;
+	assert (delta << 6 >> 6 == delta);
+	*reloc_addr = *reloc_addr & 0xfc000003 | delta & 0x3fffffc;
+      }
+      break;
+
+    case R_PPC_UADDR32:
+    case R_PPC_GLOB_DAT:
+    case R_PPC_ADDR32:
+    case R_PPC_RELATIVE:
+      *reloc_addr = finaladdr;
+      break;
+
+    case R_PPC_ADDR24:
+      *reloc_addr = *reloc_addr & 0xfc000003 | finaladdr & 0x3fffffc;
+      break;
+
+    case R_PPC_REL14_BRTAKEN:
+    case R_PPC_REL14_BRNTAKEN:
+    case R_PPC_REL14:
+      {
+	Elf32_Sword delta = finaladdr - (Elf32_Word) (char *) reloc_addr;
+	*reloc_addr = *reloc_addr & 0xffdf0003 | delta & 0xfffc;
+	if (rinfo == R_PPC_REL14_BRTAKEN && delta >= 0 ||
+	    rinfo == R_PPC_REL14_BRNTAKEN && delta < 0)
+	  *reloc_addr |= 0x00200000;
+      }
+      break;
+
+    case R_PPC_COPY:
+      {
+	/* Can't use memcpy (because we can't call any functions here).  */
+	int i;
+	for (i = 0; i < sym->st_size; ++i)
+	  ((unsigned char *) reloc_addr)[i] =
+	    ((unsigned char *)finaladdr)[i];
+      }
+      break;
+
+    case R_PPC_REL32:
+      *reloc_addr = finaladdr - (Elf32_Word) (char *) reloc_addr;
+      break;
+
+    case R_PPC_JMP_SLOT:
+      if (finaladdr <= 0x01fffffc || finaladdr >= 0xfe000000)
+	*reloc_addr = OPCODE_BA (finaladdr);
+      else
+	{
+	  Elf32_Sword delta = finaladdr - (Elf32_Word) (char *) reloc_addr;
+	  if (delta <= 0x01fffffc && delta >= 0xfe000000)
+	    *reloc_addr = OPCODE_B (delta);
+	  else
+	    {
+	      Elf32_Word *plt =
+		(Elf32_Word *) ((char *) map->l_addr
+				+ map->l_info[DT_PLTGOT]->d_un.d_val);
+	      Elf32_Word index =((reloc_addr - plt - PLT_INITIAL_ENTRY_WORDS)
+				 / 2);
+	      int num_plt_entries = (map->l_info[DT_PLTRELSZ]->d_un.d_val
+				     / sizeof (Elf32_Rela));
+	      int rel_offset_words = (PLT_INITIAL_ENTRY_WORDS
+				      + num_plt_entries * 2);
+
+	      if (index >= (1 << 13))
+		{
+		  /* Indexes greater than or equal to 2^13 have 4
+		     words available instead of two.  */
+		  plt[index * 2 + PLT_INITIAL_ENTRY_WORDS] =
+		    OPCODE_LI (11, finaladdr);
+		  plt[index * 2 + 1 + PLT_INITIAL_ENTRY_WORDS] =
+		    OPCODE_ADDIS (11, 11, finaladdr + 0x8000 >> 16);
+		  plt[index * 2 + 2 + PLT_INITIAL_ENTRY_WORDS] =
+		    OPCODE_MTCTR (11);
+		  plt[index * 2 + 2 + PLT_INITIAL_ENTRY_WORDS] =
+		    OPCODE_BCTR ();
+		}
+	      else
+		{
+		  plt[index * 2 + PLT_INITIAL_ENTRY_WORDS] =
+		    OPCODE_LI (11, index * 4);
+		  plt[index * 2 + 1 + PLT_INITIAL_ENTRY_WORDS] =
+		    OPCODE_B(-(4 * (index * 2 + 1 + PLT_INITIAL_ENTRY_WORDS
+				    + PLT_LONGBRANCH_ENTRY_WORDS)));
+		  plt[index + rel_offset_words] = finaladdr;
+		}
+	    }
+	}
+      break;
+
+    default:
+      assert (! "unexpected dynamic reloc type");
+    }
+}
+
+#define ELF_MACHINE_NO_REL 1
+
+#endif
+
+/* Nonzero iff TYPE describes relocation of a PLT entry, so
+   PLT entries should not be allowed to define the value.  */
+#define elf_machine_pltrel_p(type) ((type) == R_PPC_JMP_SLOT)
+
+/* Set up the loaded object described by L so its unrelocated PLT
+   entries will jump to the on-demand fixup code in dl-runtime.c.  */
+
+/* This code does not presently work if there are more than 2^13 PLT
+   entries. */
+static inline void
+elf_machine_runtime_setup (struct link_map *map, int lazy)
+{
+  Elf32_Word *plt;
+  int i;
+  Elf32_Word num_plt_entries;
+  Elf32_Word rel_offset_words;
+  extern void _dl_runtime_resolve (void);
+
+  if (map->l_info[DT_JMPREL])
+    {
+      /* Fill in the PLT. Its initial contents are directed to a
+	 function earlier in the PLT which arranges for the dynamic
+	 linker to be called back.  */
+      plt = (Elf32_Word *) ((char *) map->l_addr +
+			    map->l_info[DT_PLTGOT]->d_un.d_val);
+      num_plt_entries = (map->l_info[DT_PLTRELSZ]->d_un.d_val
+			 / sizeof (Elf32_Rela));
+      rel_offset_words = PLT_INITIAL_ENTRY_WORDS + num_plt_entries * 2;
+
+      if (lazy)
+	for (i = 0; i < num_plt_entries; i++)
+	  if (i >= (1 << 13))
+	  {
+	    plt[i * 2 + (i - (1 << 13)) * 2 + PLT_INITIAL_ENTRY_WORDS] =
+	      OPCODE_LI (11, i * 4);
+	    plt[i * 2 + (i - (1 << 13)) * 2 + 1 + PLT_INITIAL_ENTRY_WORDS] =
+	      OPCODE_ADDIS (11, 11, i * 4 + 0x8000 >> 16);
+	    plt[i * 2 + (i - (1 << 13)) * 2 + 2 + PLT_INITIAL_ENTRY_WORDS] =
+	      OPCODE_B (-(4 * ( i * 2 + 1 + PLT_INITIAL_ENTRY_WORDS)));
+	  }
+	  else
+	  {
+	    plt[i * 2 + PLT_INITIAL_ENTRY_WORDS] = OPCODE_LI (11, i * 4);
+	    plt[i * 2 + 1 + PLT_INITIAL_ENTRY_WORDS] =
+	      OPCODE_B (-(4 * (i * 2 + 1 + PLT_INITIAL_ENTRY_WORDS)));
+	  }
+
+      /* Multiply index of entry, by 0xC.  */
+      plt[0] = OPCODE_SLWI (12, 11, 1);
+      plt[1] = OPCODE_ADD (11, 12, 11);
+      if ((Elf32_Word) (char *) _dl_runtime_resolve <= 0x01fffffc ||
+	  (Elf32_Word) (char *) _dl_runtime_resolve >= 0xfe000000)
+	{
+	  plt[2] = OPCODE_LI (12, (Elf32_Word) (char *) map);
+	  plt[3] = OPCODE_ADDIS (12, 12,
+				 (Elf32_Word) (char *) map + 0x8000 >> 16);
+	  plt[4] = OPCODE_BA ((Elf32_Word) (char *) _dl_runtime_resolve);
+	}
+      else
+	{
+	  plt[2] = OPCODE_LI (12, (Elf32_Word) (char *) _dl_runtime_resolve);
+	  plt[3] = OPCODE_ADDIS (12, 12, 0x8000 +
+				 ((Elf32_Word) (char *) _dl_runtime_resolve
+				  >> 16));
+	  plt[4] = OPCODE_MTCTR (12);
+	  plt[5] = OPCODE_LI (12, (Elf32_Word) (char *) map);
+	  plt[6] = OPCODE_ADDIS (12, 12, ((Elf32_Word) (char *) map
+					  + 0x8000 >> 16));
+	  plt[7] = OPCODE_BCTR ();
+	}
+      plt[PLT_LONGBRANCH_ENTRY_WORDS] =
+	OPCODE_ADDIS (11, 11, ((Elf32_Word) (char*) (plt+rel_offset_words)
+			       + 0x8000 >> 16));
+      plt[PLT_LONGBRANCH_ENTRY_WORDS+1] =
+	OPCODE_LWZ (11, (Elf32_Word) (char*) (plt + rel_offset_words), 11);
+      plt[PLT_LONGBRANCH_ENTRY_WORDS+2] = OPCODE_MTCTR (11);
+      plt[PLT_LONGBRANCH_ENTRY_WORDS+3] = OPCODE_BCTR ();
+    }
+}
+
+static inline void
+elf_machine_lazy_rel (struct link_map *map, const Elf32_Rela *reloc)
+{
+  if (ELF32_R_TYPE (reloc->r_info) != R_PPC_JMP_SLOT)
+      assert (! "unexpected PLT reloc type");
+
+  /* elf_machine_runtime_setup handles this. */
+}
+
+/* The PLT uses Elf32_Rela relocs.  */
+#define elf_machine_relplt elf_machine_rela
+
+  /* This code is used in dl-runtime.c to call the `fixup' function
+     and then redirect to the address it returns.  */
+#define ELF_MACHINE_RUNTIME_TRAMPOLINE asm ("\
+	.section \".text\"
+	.globl _dl_runtime_resolve
+_dl_runtime_resolve:
+	stwu 1,-48(1)
+	mflr 0
+	stw 3,16(1)
+	stw 4,20(1)
+	stw 0,52(1)
+	stw 5,24(1)
+	mfcr 0
+	stw 6,28(1)
+	stw 7,32(1)
+	stw 8,36(1)
+	stw 9,40(1)
+	stw 10,44(1)
+	stw 0,12(1)
+	mr 3,12
+	mr 4,11
+	bl fixup
+	mtctr 3
+	lwz 0,52(1)
+	lwz 10,44(1)
+	lwz 9,40(1)
+	mtlr 0
+	lwz 0,12(1)
+	lwz 8,36(1)
+	lwz 7,32(1)
+	lwz 6,28(1)
+	mtcrf 0xFF,0
+	lwz 5,24(1)
+	lwz 4,20(1)
+	lwz 3,16(1)
+	addi 1,1,48
+	bctr
+");
+
+/* Initial entry point code for the dynamic linker.
+   The C function `_dl_start' is the real entry point;
+   its return value is the user program's entry point.  */
+
+/* FIXME! We don't make provision for calling _dl_fini,
+   because Linux/PPC is somewhat broken. */
+#define RTLD_START \
+asm ("\
+	.text
+        .align 2
+	.globl _start
+        .type _start,@function
+_start:
+ # We start with the following on the stack, from top:
+ # argc (4 bytes)
+ # arguments for program (terminated by NULL)
+ # environment variables (terminated by NULL)
+ # arguments for the program loader
+
+ # Call _dl_start with one parameter pointing at argc
+        mr 3,1
+ #  (we have to frob the stack pointer a bit to allow room for
+ #   _dl_start to save the link register)
+        li 4,0
+        addi 1,1,-16
+        stw 4,0(1)
+        bl _dl_start@local
+
+ # Now, we do our main work of calling initialisation procedures.
+ # The ELF ABI doesn't say anything about parameters for these,
+ # so we just pass argc, argv, and the environment.
+ # Changing these is strongly discouraged (not least because argc is
+ # passed by value!).
+
+ #  put our GOT pointer in r31
+        bl _GLOBAL_OFFSET_TABLE_-4@local
+        mflr 31
+ #  the address of _start in r30
+        mr 30,3
+ #  &_dl_argc in 29, &_dl_argv in 27, and _dl_default_scope in 28
+	lwz 28,_dl_default_scope@got(31)
+	lwz 29,_dl_argc@got(31)
+	lwz 27,_dl_argv@got(31)
+0:
+ #  call initfunc = _dl_init_next(_dl_default_scope[2])
+	lwz 3,8(28)
+	bl _dl_init_next@plt
+ # if initfunc is NULL, we exit the loop
+	mr. 0,3
+	beq 1f
+ # call initfunc(_dl_argc, _dl_argv, _dl_argv+_dl_argc+1)
+	mtlr 0
+	lwz 3,0(29)
+	lwz 4,0(27)
+	slwi 5,3,2
+	add 5,4,5
+	addi 5,5,4
+	blrl
+ # and loop.
+	b 0b
+1:
+ # Now, to conform to the ELF ABI, we have to:
+ # pass argv (actually _dl_argv) in r4
+	lwz 4,0(27)
+ # pass argc (actually _dl_argc) in r3
+	lwz 3,0(29)
+ # pass envp (actually _dl_argv+_dl_argc+1) in r5
+	slwi 5,3,2
+	add 5,4,5
+	addi 5,5,4
+ # pass the auxilary vector in r6. This is passed just after _envp.
+	addi 6,5,-4
+2:	lwzu 0,4(6)
+	cmpwi 1,0,0
+	bne 2b
+	addi 6,6,4
+ # pass a termination function pointer (in this case _dl_fini) in r7
+	lwz 7,_dl_fini@got(31)
+ # now, call the start function in r30...
+	mtctr 30
+ # pass the stack pointer in r1 (so far so good), pointing to a NULL value
+ # (this lets our startup code distinguish between a program linked statically,
+ # which linux will call with argc on top of the stack which will hopefully
+ # never be zero, and a dynamically linked program which will always have
+ # a NULL on the top of the stack).
+ # Take the opportunity to clear LR, so anyone who accidentally returns
+ # from _start gets SEGV.
+	li 0,0
+	stw 0,0(1)
+	mtlr 0
+ # and also clear _dl_starting_up
+	lwz 26,_dl_starting_up@got(31)
+	stw 0,0(3)
+ # go do it!
+	bctr
+");
+
+#define ELF_PREFERRED_ADDRESS_DATA static ElfW(Addr) _dl_preferred_address = 0;
+#define ELF_PREFERRED_ADDRESS(loader, maplength, mapstartpref) \
+( {									      \
+   ElfW(Addr) prefd;							      \
+   if (mapstartpref != 0 && _dl_preferred_address == 0)			      \
+     _dl_preferred_address = mapstartpref;				      \
+   if (mapstartpref != 0)						      \
+     prefd = mapstartpref;						      \
+   else if (_dl_preferred_address < maplength + 0x50000)		      \
+     prefd = 0;								      \
+   else									      \
+     prefd = _dl_preferred_address =					      \
+	  (_dl_preferred_address - maplength - 0x10000) &		      \
+           ~(_dl_pagesize - 1);						      \
+   prefd;								      \
+} )
+#define ELF_FIXED_ADDRESS(loader, mapstart) \
+( {									      \
+   if (mapstart != 0 && _dl_preferred_address == 0)			      \
+     _dl_preferred_address = mapstart;					      \
+} )
+
+#define ELF_FIXUP_RETURNS_ADDRESS 1
diff --git a/sysdeps/powerpc/elf/start.c b/sysdeps/powerpc/elf/start.c
new file mode 100644
index 0000000000..9b1cf1c026
--- /dev/null
+++ b/sysdeps/powerpc/elf/start.c
@@ -0,0 +1,111 @@
+/* Startup code compliant to the ELF PowerPC ABI.
+   Copyright (C) 1997 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public License as
+   published by the Free Software Foundation; either version 2 of the
+   License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  If not,
+   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
+
+/* This is SVR4/PPC ABI compliant, and works under Linux when
+   statically linked.  */
+
+#include <unistd.h>
+#include <stdlib.h>
+
+/* Just a little assembler stub before gcc gets its hands on our
+   stack pointer... */
+asm ("\
+	.text
+	.globl _start
+_start:
+ # save the stack pointer, in case we're statically linked under Linux
+        mr 8,1
+ # set up an initial stack frame, and clear the LR
+        addi 1,1,-16
+        clrrwi 1,1,4
+        li 0,0
+        stw 0,0(1)
+        mtlr 0
+ # set r13 to point at the 'small data area'
+        lis 13,_SDA_BASE_@ha
+        addi 13,13,_SDA_BASE_@l
+ # and continue below.
+        b __start1
+");
+
+/* Define a symbol for the first piece of initialized data.  */
+int __data_start = 0;
+weak_alias (__data_start, data_start)
+
+/* these probably should go, at least go somewhere else
+   (sysdeps/mach/something?). */
+void (*_mach_init_routine) (void);
+void (*_thread_init_routine) (void);
+
+void __libc_init_first (int argc, char **argv, char **envp);
+int main (int argc, char **argv, char **envp, void *auxvec);
+#ifdef HAVE_INITFINI
+void _init (void);
+void _fini (void);
+#endif
+
+
+static void __start1(int argc, char **argv, char **envp,
+		     void *auxvec, void (*exitfn) (void), char **arguments)
+     __attribute__ ((unused));
+static void
+__start1(int argc, char **argv, char **envp,
+	 void *auxvec, void (*exitfn) (void),
+	 char **arguments)
+{
+  /* the PPC SVR4 ABI says that the top thing on the stack will
+     be a NULL pointer, so if not we assume that we're being called
+     as a statically-linked program by Linux. */
+  int abi_compliant_startup = *arguments == NULL;
+
+  if (!abi_compliant_startup)
+  {
+    argc = *(int *) arguments;
+    argv = arguments+1;
+    envp = argv+argc+1;
+    auxvec = envp;
+    while (auxvec != NULL)
+      auxvec++;
+    auxvec++;
+    exitfn = NULL;
+  }
+
+  if (exitfn != NULL)
+    atexit (exitfn);
+
+  /* libc init routine, in case we are statically linked
+     (otherwise ld.so will have called it when it loaded libc, but
+     calling it twice doesn't hurt). */
+  __libc_init_first (argc, argv, envp);
+
+#ifdef HAVE_INITFINI
+  /* ELF constructors/destructors */
+  atexit (_fini);
+  _init ();
+#endif
+
+  /* Stuff so we can build Mach/Linux executables (like vmlinux).  */
+  if (_mach_init_routine != 0)
+    _mach_init_routine ();
+  if (_thread_init_routine != 0)
+    _thread_init_routine ();
+
+  /* the rest of the program */
+  exit (main (argc, argv, envp, auxvec));
+}
diff --git a/sysdeps/powerpc/ffs.c b/sysdeps/powerpc/ffs.c
new file mode 100644
index 0000000000..d9d7f267af
--- /dev/null
+++ b/sysdeps/powerpc/ffs.c
@@ -0,0 +1,38 @@
+/* Find first set bit in a word, counted from least significant end.
+   For PowerPC.
+   Copyright (C) 1991, 1992, 1997 Free Software Foundation, Inc.
+   Contributed by Torbjorn Granlund (tege@sics.se).
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public License as
+   published by the Free Software Foundation; either version 2 of the
+   License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  If not,
+   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
+
+#include <bstring.h>
+
+#undef	ffs
+
+#ifdef	__GNUC__
+
+int
+ffs (int x)
+{
+  int cnt;
+
+  asm ("cntlzw %0,%1" : "=r" (cnt) : "r" (x & -x));
+  return 32 - cnt;
+}
+
+#else
+#include <sysdeps/generic/ffs.c>
+#endif
diff --git a/sysdeps/powerpc/fpu_control.h b/sysdeps/powerpc/fpu_control.h
new file mode 100644
index 0000000000..b31e0eeefd
--- /dev/null
+++ b/sysdeps/powerpc/fpu_control.h
@@ -0,0 +1,77 @@
+/* FPU control word definitions.  PowerPC version.
+   Copyright (C) 1996, 1997 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public License as
+   published by the Free Software Foundation; either version 2 of the
+   License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  If not,
+   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
+
+#ifndef _FPU_CONTROL_H
+#define _FPU_CONTROL_H
+
+/* rounding control */
+#define _FPU_RC_NEAREST 0x00   /* RECOMMENDED */
+#define _FPU_RC_DOWN    0x03
+#define _FPU_RC_UP      0x02
+#define _FPU_RC_ZERO    0x01
+
+#define _FPU_MASK_NI  0x04 /* non-ieee mode */
+
+/* masking of interrupts */
+#define _FPU_MASK_ZM  0x10 /* zero divide */
+#define _FPU_MASK_OM  0x40 /* overflow */
+#define _FPU_MASK_UM  0x20 /* underflow */
+#define _FPU_MASK_XM  0x08 /* inexact */
+#define _FPU_MASK_IM  0x80 /* invalid operation */
+#define _FPU_MASK_VXCVI 0x100 /* invalid operation for integer convert */
+#define _FPU_MASK_VXSQRT 0x200 /* invalid operation for square root */
+#define _FPU_MASK_VXSOFT 0x400 /* invalid operation raised by software */
+
+#define _FPU_RESERVED 0xfffff800 /* These bits are reserved are not changed. */
+
+/* The fdlibm code requires no interrupts for exceptions.  Don't
+   change the rounding mode, it would break long double I/O!  */
+#define _FPU_DEFAULT  0x00000000 /* Default value.  */
+
+/* IEEE:  same as above, but (some) exceptions;
+   we leave the 'inexact' exception off.
+ */
+#define _FPU_IEEE     0x000003f0
+
+/* Type of the control word.  */
+typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__SI__)));
+
+/* Macros for accessing the hardware control word.  */
+#define _FPU_GETCW(cw) ( { \
+  fpu_control_t tmp[2] __attribute__ ((__aligned__(8))); \
+  __asm__ ("mffs 0; stfd 0,%0" : "=m" (*tmp) : : "fr0"); \
+  tmp[1]; } )
+#define _FPU_SETCW(cw) { \
+  fpu_control_t tmp[2] __attribute__ ((__aligned__(8))); \
+  tmp[0] = 0xFFF80000; /* arbitrary, more-or-less */ \
+  tmp[1] = cw; \
+  __asm__ ("lfd 0,%0; mtfsf 255,0" : : "m" (*tmp) : "fr0"); \
+}
+
+/* Default control word set at startup.  */
+extern fpu_control_t __fpu_control;
+
+__BEGIN_DECLS
+
+/* Called at startup.  It can be used to manipulate fpu control register.  */
+extern void __setfpucw __P ((fpu_control_t));
+
+__END_DECLS
+
+#endif /* _FPU_CONTROL_H */
diff --git a/sysdeps/powerpc/jmp_buf.h b/sysdeps/powerpc/jmp_buf.h
new file mode 100644
index 0000000000..df832b157c
--- /dev/null
+++ b/sysdeps/powerpc/jmp_buf.h
@@ -0,0 +1,19 @@
+/* Define the machine-dependent type `jmp_buf'.  PowerPC version.  */
+
+/* The previous jmp_buf.h had __jmp_buf defined as a structure.
+   We use an array of 'long int' instead, to make writing the
+   assembler easier. Naturally, user code should not depend on
+   either representation. */
+
+#if	defined (__USE_MISC) || defined (_ASM)
+#define JB_GPR1  0   /* also known as the stack pointer */
+#define JB_GPR2  1
+#define JB_LR    2
+#define JB_GPRS  3   /* GPRs 14 through 31 are saved, 18 in total */
+#define JB_UNUSED 21 /* it's sometimes faster to store doubles word-aligned */
+#define JB_FPRS  22  /* FPRs 14 through 31 are saved, 18*2 words total */
+#endif
+
+#ifndef	_ASM
+typedef long int __jmp_buf[58];
+#endif
diff --git a/sysdeps/powerpc/setjmp.S b/sysdeps/powerpc/setjmp.S
new file mode 100644
index 0000000000..a2c0b8c53d
--- /dev/null
+++ b/sysdeps/powerpc/setjmp.S
@@ -0,0 +1,66 @@
+/* setjmp for PowerPC.
+   Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public License as
+   published by the Free Software Foundation; either version 2 of the
+   License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  If not,
+   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
+
+#include <sysdep.h>
+#define _ASM
+#include <jmp_buf.h>
+
+ENTRY (__sigsetjmp)
+	stw 1,(JB_GPR1*4)(3)
+	mflr 0
+	stw 2,(JB_GPR2*4)(3)
+	stw 14,((JB_GPRS+0)*4)(3)
+	stfd 14,((JB_FPRS+0*2)*4)(3)
+	stw 0,(JB_LR*4)(3)
+	stw 15,((JB_GPRS+1)*4)(3)
+	stfd 15,((JB_FPRS+1*2)*4)(3)
+	stw 16,((JB_GPRS+2)*4)(3)
+	stfd 16,((JB_FPRS+2*2)*4)(3)
+	stw 17,((JB_GPRS+3)*4)(3)
+	stfd 17,((JB_FPRS+3*2)*4)(3)
+	stw 18,((JB_GPRS+4)*4)(3)
+	stfd 18,((JB_FPRS+4*2)*4)(3)
+	stw 19,((JB_GPRS+5)*4)(3)
+	stfd 19,((JB_FPRS+5*2)*4)(3)
+	stw 20,((JB_GPRS+6)*4)(3)
+	stfd 20,((JB_FPRS+6*2)*4)(3)
+	stw 21,((JB_GPRS+7)*4)(3)
+	stfd 21,((JB_FPRS+7*2)*4)(3)
+	stw 22,((JB_GPRS+8)*4)(3)
+	stfd 22,((JB_FPRS+8*2)*4)(3)
+	stw 23,((JB_GPRS+9)*4)(3)
+	stfd 23,((JB_FPRS+9*2)*4)(3)
+	stw 24,((JB_GPRS+10)*4)(3)
+	stfd 24,((JB_FPRS+10*2)*4)(3)
+	stw 25,((JB_GPRS+11)*4)(3)
+	stfd 25,((JB_FPRS+11*2)*4)(3)
+	stw 26,((JB_GPRS+12)*4)(3)
+	stfd 26,((JB_FPRS+12*2)*4)(3)
+	stw 27,((JB_GPRS+13)*4)(3)
+	stfd 27,((JB_FPRS+13*2)*4)(3)
+	stw 28,((JB_GPRS+14)*4)(3)
+	stfd 28,((JB_FPRS+14*2)*4)(3)
+	stw 29,((JB_GPRS+15)*4)(3)
+	stfd 29,((JB_FPRS+15*2)*4)(3)
+	stw 30,((JB_GPRS+16)*4)(3)
+	stfd 30,((JB_FPRS+16*2)*4)(3)
+	stw 31,((JB_GPRS+17)*4)(3)
+	stfd 31,((JB_FPRS+17*2)*4)(3)
+	b __sigjmp_save
+END (__sigsetjmp)
diff --git a/sysdeps/powerpc/strlen.S b/sysdeps/powerpc/strlen.S
new file mode 100644
index 0000000000..95eaf94de1
--- /dev/null
+++ b/sysdeps/powerpc/strlen.S
@@ -0,0 +1,52 @@
+/* Optimized strlen implementation for PowerPC.
+   Copyright (C) 1997 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public License as
+   published by the Free Software Foundation; either version 2 of the
+   License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  If not,
+   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
+
+	.section	".text"
+	.align 2
+	.globl strlen
+	.type	 strlen,@function
+strlen:
+	rlwinm 7,3,0,0,29
+	lis 8,0x7f7f
+	lwz 11,0(7)
+	ori 8,8,32639
+	rlwinm 4,3,3,27,28
+	li 9,-1
+	or 10,11,8
+	and 0,11,8
+	srw 9,9,4
+	add 0,0,8
+	nor 0,10,0
+	and. 11,0,9
+	bc 4,2,.L2
+.L3:
+	lwzu 11,4(7)
+	or 10,11,8
+	and 0,11,8
+	add 0,0,8
+	nor. 11,10,0
+	bc 12,2,.L3
+.L2:
+	subf 0,3,7
+	cntlzw 3,11
+	srwi 3,3,3
+	add 3,0,3
+	blr
+.Lfe1:
+	.size	 strlen,.Lfe1-strlen
diff --git a/sysdeps/unix/sysv/linux/i386/sigaction.c b/sysdeps/unix/sysv/linux/i386/sigaction.c
index f3ecd4bd15..3f9d9463a0 100644
--- a/sysdeps/unix/sysv/linux/i386/sigaction.c
+++ b/sysdeps/unix/sysv/linux/i386/sigaction.c
@@ -1,42 +1,49 @@
 /* POSIX.1 `sigaction' call for Linux/i386.
-Copyright (C) 1991, 1995, 1996 Free Software Foundation, Inc.
-This file is part of the GNU C Library.
+   Copyright (C) 1991, 1995, 1996, 1997 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
 
-The GNU C Library is free software; you can redistribute it and/or
-modify it under the terms of the GNU Library General Public License as
-published by the Free Software Foundation; either version 2 of the
-License, or (at your option) any later version.
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public License as
+   published by the Free Software Foundation; either version 2 of the
+   License, or (at your option) any later version.
 
-The GNU C Library is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-Library General Public License for more details.
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
 
-You should have received a copy of the GNU Library General Public
-License along with the GNU C Library; see the file COPYING.LIB.  If
-not, write to the Free Software Foundation, Inc., 675 Mass Ave,
-Cambridge, MA 02139, USA.  */
+   You should have received a copy of the GNU Library General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  If not,
+   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
 
 #include <sysdep.h>
 #include <errno.h>
 #include <stddef.h>
 #include <signal.h>
 
+/* The difference here is that the sigaction structure used in the
+   kernel is not the same as we use in the libc.  Therefore we must
+   translate it here.  */
+#include <kernel_sigaction.h>
+
 
 /* If ACT is not NULL, change the action for SIG to *ACT.
    If OACT is not NULL, put the old action for SIG in *OACT.  */
 int
 __sigaction (int sig, const struct sigaction *act, struct sigaction *oact)
 {
-  struct sigaction newact;
+  struct kernel_sigaction k_newact, k_oldact;
   int result;
 
   if (act)
     {
-      newact = *act;
-      newact.sa_restorer = ((act->sa_flags & SA_NOMASK)
-			    ? &&restore_nomask : &&restore);
-      act = &newact;
+      k_newact.sa_handler = act->sa_handler;
+      k_newact.sa_mask = act->sa_mask.__val[0];
+      k_newact.sa_flags = act->sa_flags;
+
+      k_newact.sa_restorer = ((act->sa_flags & SA_NOMASK)
+			      ? &&restore_nomask : &&restore);
     }
 
   asm volatile ("pushl %%ebx\n"
@@ -44,13 +51,23 @@ __sigaction (int sig, const struct sigaction *act, struct sigaction *oact)
 		"int $0x80\n"
 		"popl %%ebx"
 		: "=a" (result)
-		: "0" (SYS_ify (sigaction)), "r" (sig), "c" (act), "d" (oact));
+		: "0" (SYS_ify (sigaction)), "r" (sig),
+		  "c" (act ? &k_newact : 0), "d" (oact ? &k_oldact : 0));
 
   if (result < 0)
     {
       __set_errno (-result);
       return -1;
     }
+
+  if (oact)
+    {
+      oact->sa_handler = k_oldact.sa_handler;
+      oact->sa_mask.__val[0] = k_oldact.sa_mask;
+      oact->sa_flags = k_oldact.sa_flags;
+      oact->sa_restorer = k_oldact.sa_restorer;
+    }
+
   return 0;
 
  restore:
diff --git a/sysdeps/unix/sysv/linux/netinet/in.h b/sysdeps/unix/sysv/linux/netinet/in.h
index 5b6cc78821..bbc625435c 100644
--- a/sysdeps/unix/sysv/linux/netinet/in.h
+++ b/sysdeps/unix/sysv/linux/netinet/in.h
@@ -127,13 +127,13 @@ struct in_addr
 /* Address to send to all hosts.  */
 #define	INADDR_BROADCAST	((unsigned) 0xffffffff)
 /* Address indicating an error return.  */
-#define	INADDR_NONE		0xffffffff
+#define	INADDR_NONE		((unsigned) 0xffffffff)
 
 /* Network number for local host loopback.  */
 #define	IN_LOOPBACKNET	127
 /* Address to loopback in software to local host.  */
 #ifndef INADDR_LOOPBACK
-#define	INADDR_LOOPBACK	0x7f000001	/* Internet address 127.0.0.1.  */
+#define	INADDR_LOOPBACK	((unsigned) 0x7f000001)	/* Inet address 127.0.0.1.  */
 #endif
 
 
diff --git a/sysdeps/unix/sysv/linux/poll.c b/sysdeps/unix/sysv/linux/poll.c
index 337b85005f..875c3b48f8 100644
--- a/sysdeps/unix/sysv/linux/poll.c
+++ b/sysdeps/unix/sysv/linux/poll.c
@@ -22,7 +22,9 @@
 
 extern int __syscall_poll __P ((struct pollfd *fds, unsigned int nfds,
 				int timeout));
-extern int __emulate_poll __P ((struct pollfd *fds, unsigned long int nfds,
+weak_extern (__syscall_poll)
+
+static int __emulate_poll __P ((struct pollfd *fds, unsigned long int nfds,
 				int timeout));
 
 /* The real implementation.  */
@@ -33,13 +35,17 @@ poll (fds, nfds, timeout)
      int timeout;
 {
   static int must_emulate = 0;
+  int (*syscall) __P ((struct pollfd *, unsigned int, int)) = __syscall_poll;
 
   if (!must_emulate)
     {
-      int retval = __syscall_poll (fds, nfds, timeout);
+      if (syscall)
+	{
+	  int retval = __syscall_poll (fds, nfds, timeout);
 
-      if (retval >= 0 || errno != ENOSYS)
-	return retval;
+	  if (retval >= 0 || errno != ENOSYS)
+	    return retval;
+	}
 
       must_emulate = 1;
     }
@@ -49,5 +55,5 @@ poll (fds, nfds, timeout)
 
 
 /* Get the emulation code.  */
-#define poll(fds, nfds, timeout) __emulate_poll (fds, nfds, timeout)
+#define poll(fds, nfds, timeout) static __emulate_poll (fds, nfds, timeout)
 #include <sysdeps/unix/bsd/poll.c>
diff --git a/sysdeps/unix/sysv/linux/powerpc/Dist b/sysdeps/unix/sysv/linux/powerpc/Dist
new file mode 100644
index 0000000000..3df65c325c
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/powerpc/Dist
@@ -0,0 +1,4 @@
+clone.S
+ioctl-types.h
+termbits.h
+termios.h
diff --git a/sysdeps/unix/sysv/linux/powerpc/_exit.S b/sysdeps/unix/sysv/linux/powerpc/_exit.S
new file mode 100644
index 0000000000..a1ca375d54
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/powerpc/_exit.S
@@ -0,0 +1,26 @@
+/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public License as
+   published by the Free Software Foundation; either version 2 of the
+   License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  If not,
+   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
+
+#include <sysdep.h>
+
+/* The 'exit' syscall does not return.  */
+
+	.text
+ENTRY(_exit)
+	DO_CALL (SYS_ify (exit))
+PSEUDO_END (_exit)
diff --git a/sysdeps/unix/sysv/linux/powerpc/brk.c b/sysdeps/unix/sysv/linux/powerpc/brk.c
new file mode 100644
index 0000000000..e9826bd098
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/powerpc/brk.c
@@ -0,0 +1,47 @@
+/* brk system call for Linux/ppc.
+   Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public License as
+   published by the Free Software Foundation; either version 2 of the
+   License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  If not,
+   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
+
+#include <sysdep.h>
+#include <errno.h>
+
+void *__curbrk;
+
+int
+__brk (void *addr)
+{
+  register void *syscall_arg asm ("r3") = addr;
+  register int syscall_number asm ("r0") = SYS_ify (brk);
+  register void *newbrk asm ("r3");
+  asm ("sc"
+       : "=r" (newbrk)
+       : "r" (syscall_arg), "r" (syscall_number)
+       : "r4","r5","r6","r7","r8","r9","r10","r11","r12",
+         "ctr", "mq", "cr0", "cr1", "cr6", "cr7");
+
+  __curbrk = newbrk;
+
+  if (newbrk < addr)
+    {
+      __set_errno (ENOMEM);
+      return -1;
+    }
+
+  return 0;
+}
+weak_alias (__brk, brk)
diff --git a/sysdeps/unix/sysv/linux/powerpc/clone.S b/sysdeps/unix/sysv/linux/powerpc/clone.S
new file mode 100644
index 0000000000..e5fa16d8c5
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/powerpc/clone.S
@@ -0,0 +1,74 @@
+/* Wrapper around clone system call.
+   Copyright (C) 1997 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public License as
+   published by the Free Software Foundation; either version 2 of the
+   License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  If not,
+   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
+
+#include <sysdep.h>
+#define _ERRNO_H	1
+#include <errnos.h>
+
+/* This is the only really unusual system call in PPC linux, but not
+   because of any weirdness in the system call itself; because of
+   all the freaky stuff we have to do to make the call useful.  */
+
+/* int clone(int (*fn)(void *arg), void *child_stack, int flags, void *arg); */
+
+ENTRY(clone)
+	/* Set up stack frame, save registers.  */
+	stwu 1,-20(1)
+	stw 31,16(1)
+
+	/* Check for child_stack == NULL, fn == NULL.  */
+	mr. 31,4
+	cmpwi 1,3,0
+	cror 2+0*4,2+0*4,2+1*4
+	beq- 0,badargs
+
+	/* Save 'fn' and its argument on the new stack.  */
+	stw 3,0(4)
+	stw 6,4(4)
+
+	/* 'flags' argument is (only) parameter to clone syscall.  */
+	mr 3,5
+
+	/* Do the call.  */
+	DO_CALL(SYS_ify(clone))
+	bso- error
+	beq child
+
+	/* Parent.  Restore registers & return.  */
+	lwz 31,20(1)
+	addi 1,1,20
+	blr
+
+child:
+	/* Get address of procedure to call.  */
+	lwz 0,0(31)
+	/* Set up argument register.  */
+	lwz 3,4(31)
+	mtlr 0
+	/* Switch to new stack.  */
+	mr 1,31
+	/* Call procedure.  */
+	blrl
+	/* Call _exit with result from procedure.  */
+	DO_CALL (SYS_ify (exit))
+
+badargs:
+	li 3,-EINVAL
+error:
+	b __syscall_error
diff --git a/sysdeps/unix/sysv/linux/powerpc/init-first.h b/sysdeps/unix/sysv/linux/powerpc/init-first.h
new file mode 100644
index 0000000000..df702380fa
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/powerpc/init-first.h
@@ -0,0 +1,27 @@
+/* Copyright (C) 1997 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public License as
+   published by the Free Software Foundation; either version 2 of the
+   License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  If not,
+   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
+
+/* The job of this fragment it to find argc and friends for INIT.
+   They are passed to this routine by either the program loader
+   code in start.c, or by by dlopen.*/
+
+#define SYSDEP_CALL_INIT(NAME, INIT)					      \
+void NAME (int argc, char **argv, char **envp)				      \
+{									      \
+  INIT (argc, argv, envp);						      \
+}
diff --git a/sysdeps/unix/sysv/linux/powerpc/ioctl-types.h b/sysdeps/unix/sysv/linux/powerpc/ioctl-types.h
new file mode 100644
index 0000000000..9e2695652e
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/powerpc/ioctl-types.h
@@ -0,0 +1 @@
+#include <termios.h>
diff --git a/sysdeps/unix/sysv/linux/powerpc/profil.c b/sysdeps/unix/sysv/linux/powerpc/profil.c
new file mode 100644
index 0000000000..6ab8065da3
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/powerpc/profil.c
@@ -0,0 +1,2 @@
+/* For now.  */
+#include <sysdeps/stub/profil.c>
diff --git a/sysdeps/unix/sysv/linux/powerpc/sigreturn.S b/sysdeps/unix/sysv/linux/powerpc/sigreturn.S
new file mode 100644
index 0000000000..748c26761f
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/powerpc/sigreturn.S
@@ -0,0 +1,26 @@
+/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public License as
+   published by the Free Software Foundation; either version 2 of the
+   License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  If not,
+   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
+
+#include <sysdep.h>
+
+/* The 'sigreturn' syscall does not return.  */
+
+	.text
+ENTRY(__sigreturn)
+	DO_CALL(SYS_ify(sigreturn))
+PSEUDO_END (__sigreturn)
diff --git a/sysdeps/unix/sysv/linux/powerpc/socket.S b/sysdeps/unix/sysv/linux/powerpc/socket.S
new file mode 100644
index 0000000000..32bb8f64cd
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/powerpc/socket.S
@@ -0,0 +1,83 @@
+/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public License as
+   published by the Free Software Foundation; either version 2 of the
+   License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  If not,
+   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
+
+#include <sysdep.h>
+#include <sys/socketcall.h>
+
+#define P(a, b) P2(a, b)
+#define P2(a, b) a##b
+
+/* The socket-oriented system calls are handled unusally in Linux.
+   They are all gated through the single `socketcall' system call number.
+   `socketcall' takes two arguments: the first is the subcode, specifying
+   which socket function is being called; and the second is a pointer to
+   the arguments to the specific function.
+
+   The .S files for the other calls just #define socket and #include this.
+   They also #define a 'number-of-arguments' word in NARGS, which
+   defaults to 3.  */
+
+#ifndef NARGS
+#ifdef socket
+#error NARGS not defined
+#endif
+#define NARGS 3
+#endif
+
+#define stackblock 20
+
+	.text
+ENTRY(P(__,socket))
+	stwu 1,-48(1)
+#if NARGS >= 1
+	stw 3,stackblock(1)
+#endif
+#if NARGS >= 2
+	stw 4,4+stackblock(1)
+#endif
+#if NARGS >= 3
+	stw 5,8+stackblock(1)
+#endif
+#if NARGS >= 4
+	stw 6,12+stackblock(1)
+#endif
+#if NARGS >= 5
+	stw 7,16+stackblock(1)
+#endif
+#if NARGS >= 6
+	stw 8,20+stackblock(1)
+#endif
+#if NARGS >= 7
+	stw 9,24+stackblock(1)
+#endif
+#if NARGS >= 8
+	stw 10,28+stackblock(1)
+#endif
+#if NARGS >= 9
+#error too many arguments!
+#endif
+	li 3,P(SOCKOP_,socket)
+	addi 4,1,stackblock
+	DO_CALL(SYS_ify(socketcall))
+	addi 1,1,48
+	bnslr
+	b __syscall_error
+
+PSEUDO_END (P(__,socket))
+
+weak_alias (P(__,socket), socket)
diff --git a/sysdeps/unix/sysv/linux/powerpc/syscall.S b/sysdeps/unix/sysv/linux/powerpc/syscall.S
new file mode 100644
index 0000000000..9b3f66682e
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/powerpc/syscall.S
@@ -0,0 +1,32 @@
+/* Copyright (C) 1991, 1992, 1997 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public License as
+   published by the Free Software Foundation; either version 2 of the
+   License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  If not,
+   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
+
+#include <sysdep.h>
+
+	.text
+ENTRY (syscall)
+	mr	0,3
+	mr	3,4
+	mr	4,5
+	mr	5,6
+	mr	6,7
+	mr	7,8
+	sc
+	bnslr
+	b __syscall_error
+PSEUDO_END (syscall)
diff --git a/sysdeps/unix/sysv/linux/powerpc/syscall.h b/sysdeps/unix/sysv/linux/powerpc/syscall.h
new file mode 100644
index 0000000000..c6bac3de5b
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/powerpc/syscall.h
@@ -0,0 +1,357 @@
+/* Copyright (C) 1997 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public License as
+   published by the Free Software Foundation; either version 2 of the
+   License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  If not,
+   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
+
+#ifndef _SYSCALL_H
+#define _SYSCALL_H	1
+
+/* normally, we'd get syscalls from asm/unistd.h under Linux, but this
+   is very broken under MkLinux/PPC, so we list them right here directly. */
+
+#define __NR_setup		  0
+#define __NR_exit		  1
+#define __NR_fork		  2
+#define __NR_read		  3
+#define __NR_write		  4
+#define __NR_open		  5
+#define __NR_close		  6
+#define __NR_waitpid		  7
+#define __NR_creat		  8
+#define __NR_link		  9
+#define __NR_unlink		 10
+#define __NR_execve		 11
+#define __NR_chdir		 12
+#define __NR_time		 13
+#define __NR_mknod		 14
+#define __NR_chmod		 15
+#define __NR_chown		 16
+#define __NR_break		 17
+#define __NR_oldstat		 18
+#define __NR_lseek		 19
+#define __NR_getpid		 20
+#define __NR_mount		 21
+#define __NR_umount		 22
+#define __NR_setuid		 23
+#define __NR_getuid		 24
+#define __NR_stime		 25
+#define __NR_ptrace		 26
+#define __NR_alarm		 27
+#define __NR_oldfstat		 28
+#define __NR_pause		 29
+#define __NR_utime		 30
+#define __NR_stty		 31
+#define __NR_gtty		 32
+#define __NR_access		 33
+#define __NR_nice		 34
+#define __NR_ftime		 35
+#define __NR_sync		 36
+#define __NR_kill		 37
+#define __NR_rename		 38
+#define __NR_mkdir		 39
+#define __NR_rmdir		 40
+#define __NR_dup		 41
+#define __NR_pipe		 42
+#define __NR_times		 43
+#define __NR_prof		 44
+#define __NR_brk		 45
+#define __NR_setgid		 46
+#define __NR_getgid		 47
+#define __NR_signal		 48
+#define __NR_geteuid		 49
+#define __NR_getegid		 50
+#define __NR_acct		 51
+#define __NR_phys		 52
+#define __NR_lock		 53
+#define __NR_ioctl		 54
+#define __NR_fcntl		 55
+#define __NR_mpx		 56
+#define __NR_setpgid		 57
+#define __NR_ulimit		 58
+#define __NR_oldolduname	 59
+#define __NR_umask		 60
+#define __NR_chroot		 61
+#define __NR_ustat		 62
+#define __NR_dup2		 63
+#define __NR_getppid		 64
+#define __NR_getpgrp		 65
+#define __NR_setsid		 66
+#define __NR_sigaction		 67
+#define __NR_sgetmask		 68
+#define __NR_ssetmask		 69
+#define __NR_setreuid		 70
+#define __NR_setregid		 71
+#define __NR_sigsuspend		 72
+#define __NR_sigpending		 73
+#define __NR_sethostname	 74
+#define __NR_setrlimit		 75
+#define __NR_getrlimit		 76
+#define __NR_getrusage		 77
+#define __NR_gettimeofday	 78
+#define __NR_settimeofday	 79
+#define __NR_getgroups		 80
+#define __NR_setgroups		 81
+#define __NR_select		 82
+#define __NR_symlink		 83
+#define __NR_oldlstat		 84
+#define __NR_readlink		 85
+#define __NR_uselib		 86
+#define __NR_swapon		 87
+#define __NR_reboot		 88
+#define __NR_readdir		 89
+#define __NR_mmap		 90
+#define __NR_munmap		 91
+#define __NR_truncate		 92
+#define __NR_ftruncate		 93
+#define __NR_fchmod		 94
+#define __NR_fchown		 95
+#define __NR_getpriority	 96
+#define __NR_setpriority	 97
+#define __NR_profil		 98
+#define __NR_statfs		 99
+#define __NR_fstatfs		100
+#define __NR_ioperm		101
+#define __NR_socketcall		102
+#define __NR_syslog		103
+#define __NR_setitimer		104
+#define __NR_getitimer		105
+#define __NR_stat		106
+#define __NR_lstat		107
+#define __NR_fstat		108
+#define __NR_olduname		109
+#define __NR_iopl		110
+#define __NR_vhangup		111
+#define __NR_idle		112
+#define __NR_vm86		113
+#define __NR_wait4		114
+#define __NR_swapoff		115
+#define __NR_sysinfo		116
+#define __NR_ipc		117
+#define __NR_fsync		118
+#define __NR_sigreturn		119
+#define __NR_clone		120
+#define __NR_setdomainname	121
+#define __NR_uname		122
+#define __NR_modify_ldt		123
+#define __NR_adjtimex		124
+#define __NR_mprotect		125
+#define __NR_sigprocmask	126
+#define __NR_create_module	127
+#define __NR_init_module	128
+#define __NR_delete_module	129
+#define __NR_get_kernel_syms	130
+#define __NR_quotactl		131
+#define __NR_getpgid		132
+#define __NR_fchdir		133
+#define __NR_bdflush		134
+#define __NR_sysfs		135
+#define __NR_personality	136
+#define __NR_afs_syscall	137 /* Syscall for Andrew File System */
+#define __NR_setfsuid		138
+#define __NR_setfsgid		139
+#define __NR__llseek		140
+#define __NR_getdents		141
+#define __NR__newselect		142
+#define __NR_flock		143
+#define __NR_msync		144
+#define __NR_readv              145
+#define __NR_writev             146
+#define __NR_getsid             147
+#define __NR_fdatasync          148
+#define __NR__sysctl            149
+#define __NR_mlock              150
+#define __NR_munlock            151
+#define __NR_mlockall           152
+#define __NR_munlockall         153
+#define __NR_sched_setparam     154
+#define __NR_sched_getparam     155
+#define __NR_sched_setscheduler 156
+#define __NR_sched_getscheduler 157
+#define __NR_sched_yield        158
+#define __NR_sched_get_priority_max 159
+#define __NR_sched_get_priority_min 160
+#define __NR_sched_rr_get_interval 161
+#define __NR_nanosleep          162
+#define __NR_mremap             163
+
+#ifndef _LIBC
+#define SYS_setup		  0
+#define SYS_exit		  1
+#define SYS_fork		  2
+#define SYS_read		  3
+#define SYS_write		  4
+#define SYS_open		  5
+#define SYS_close		  6
+#define SYS_waitpid		  7
+#define SYS_creat		  8
+#define SYS_link		  9
+#define SYS_unlink		 10
+#define SYS_execve		 11
+#define SYS_chdir		 12
+#define SYS_time		 13
+#define SYS_mknod		 14
+#define SYS_chmod		 15
+#define SYS_chown		 16
+#define SYS_break		 17
+#define SYS_oldstat		 18
+#define SYS_lseek		 19
+#define SYS_getpid		 20
+#define SYS_mount		 21
+#define SYS_umount		 22
+#define SYS_setuid		 23
+#define SYS_getuid		 24
+#define SYS_stime		 25
+#define SYS_ptrace		 26
+#define SYS_alarm		 27
+#define SYS_oldfstat		 28
+#define SYS_pause		 29
+#define SYS_utime		 30
+#define SYS_stty		 31
+#define SYS_gtty		 32
+#define SYS_access		 33
+#define SYS_nice		 34
+#define SYS_ftime		 35
+#define SYS_sync		 36
+#define SYS_kill		 37
+#define SYS_rename		 38
+#define SYS_mkdir		 39
+#define SYS_rmdir		 40
+#define SYS_dup		 41
+#define SYS_pipe		 42
+#define SYS_times		 43
+#define SYS_prof		 44
+#define SYS_brk		 45
+#define SYS_setgid		 46
+#define SYS_getgid		 47
+#define SYS_signal		 48
+#define SYS_geteuid		 49
+#define SYS_getegid		 50
+#define SYS_acct		 51
+#define SYS_phys		 52
+#define SYS_lock		 53
+#define SYS_ioctl		 54
+#define SYS_fcntl		 55
+#define SYS_mpx		 56
+#define SYS_setpgid		 57
+#define SYS_ulimit		 58
+#define SYS_oldolduname	 59
+#define SYS_umask		 60
+#define SYS_chroot		 61
+#define SYS_ustat		 62
+#define SYS_dup2		 63
+#define SYS_getppid		 64
+#define SYS_getpgrp		 65
+#define SYS_setsid		 66
+#define SYS_sigaction		 67
+#define SYS_sgetmask		 68
+#define SYS_ssetmask		 69
+#define SYS_setreuid		 70
+#define SYS_setregid		 71
+#define SYS_sigsuspend		 72
+#define SYS_sigpending		 73
+#define SYS_sethostname	 74
+#define SYS_setrlimit		 75
+#define SYS_getrlimit		 76
+#define SYS_getrusage		 77
+#define SYS_gettimeofday	 78
+#define SYS_settimeofday	 79
+#define SYS_getgroups		 80
+#define SYS_setgroups		 81
+#define SYS_select		 82
+#define SYS_symlink		 83
+#define SYS_oldlstat		 84
+#define SYS_readlink		 85
+#define SYS_uselib		 86
+#define SYS_swapon		 87
+#define SYS_reboot		 88
+#define SYS_readdir		 89
+#define SYS_mmap		 90
+#define SYS_munmap		 91
+#define SYS_truncate		 92
+#define SYS_ftruncate		 93
+#define SYS_fchmod		 94
+#define SYS_fchown		 95
+#define SYS_getpriority	 96
+#define SYS_setpriority	 97
+#define SYS_profil		 98
+#define SYS_statfs		 99
+#define SYS_fstatfs		100
+#define SYS_ioperm		101
+#define SYS_socketcall		102
+#define SYS_syslog		103
+#define SYS_setitimer		104
+#define SYS_getitimer		105
+#define SYS_stat		106
+#define SYS_lstat		107
+#define SYS_fstat		108
+#define SYS_olduname		109
+#define SYS_iopl		110
+#define SYS_vhangup		111
+#define SYS_idle		112
+#define SYS_vm86		113
+#define SYS_wait4		114
+#define SYS_swapoff		115
+#define SYS_sysinfo		116
+#define SYS_ipc		117
+#define SYS_fsync		118
+#define SYS_sigreturn		119
+#define SYS_clone		120
+#define SYS_setdomainname	121
+#define SYS_uname		122
+#define SYS_modify_ldt		123
+#define SYS_adjtimex		124
+#define SYS_mprotect		125
+#define SYS_sigprocmask	126
+#define SYS_create_module	127
+#define SYS_init_module	128
+#define SYS_delete_module	129
+#define SYS_get_kernel_syms	130
+#define SYS_quotactl		131
+#define SYS_getpgid		132
+#define SYS_fchdir		133
+#define SYS_bdflush		134
+#define SYS_sysfs		135
+#define SYS_personality	136
+#define SYS_afs_syscall	137 /* Syscall for Andrew File System */
+#define SYS_setfsuid		138
+#define SYS_setfsgid		139
+#define SYS__llseek		140
+#define SYS_getdents		141
+#define SYS__newselect		142
+#define SYS_flock		143
+#define SYS_msync		144
+#define SYS_readv              145
+#define SYS_writev             146
+#define SYS_getsid             147
+#define SYS_fdatasync          148
+#define SYS__sysctl            149
+#define SYS_mlock              150
+#define SYS_munlock            151
+#define SYS_mlockall           152
+#define SYS_munlockall         153
+#define SYS_sched_setparam     154
+#define SYS_sched_getparam     155
+#define SYS_sched_setscheduler 156
+#define SYS_sched_getscheduler 157
+#define SYS_sched_yield        158
+#define SYS_sched_get_priority_max 159
+#define SYS_sched_get_priority_min 160
+#define SYS_sched_rr_get_interval 161
+#define SYS_nanosleep          162
+#define SYS_mremap             163
+#endif
+
+#endif
diff --git a/sysdeps/unix/sysv/linux/powerpc/syscalls.list b/sysdeps/unix/sysv/linux/powerpc/syscalls.list
new file mode 100644
index 0000000000..7883d70719
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/powerpc/syscalls.list
@@ -0,0 +1,3 @@
+# File name	Caller	Syscall name	# args	Strong name	Weak names
+
+s_llseek	llseek	_llseek		5	__sys_llseek
diff --git a/sysdeps/unix/sysv/linux/powerpc/sysdep.c b/sysdeps/unix/sysv/linux/powerpc/sysdep.c
new file mode 100644
index 0000000000..3896111005
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/powerpc/sysdep.c
@@ -0,0 +1,33 @@
+/* Copyright (C) 1997 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public License as
+   published by the Free Software Foundation; either version 2 of the
+   License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  If not,
+   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
+
+#include <sysdep.h>
+#include <errno.h>
+
+/* This routine is jumped to by all the syscall handlers, to stash
+   an error number into errno.  */
+int
+__syscall_error (int err_no)
+{
+  __set_errno (err_no);
+  return -1;
+}
+
+/* We also have to have a 'real' definition of errno.  */
+#undef errno
+int errno = 0;
diff --git a/sysdeps/unix/sysv/linux/powerpc/sysdep.h b/sysdeps/unix/sysv/linux/powerpc/sysdep.h
new file mode 100644
index 0000000000..c08e3d8060
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/powerpc/sysdep.h
@@ -0,0 +1,53 @@
+/* Copyright (C) 1992, 1997 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public License as
+   published by the Free Software Foundation; either version 2 of the
+   License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  If not,
+   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
+
+#include <sysdeps/unix/sysdep.h>
+
+/* For Linux we can use the system call table in the header file
+	/usr/include/asm/unistd.h
+   of the kernel.  But these symbols do not follow the SYS_* syntax
+   so we have to redefine the `SYS_ify' macro here.  */
+#undef SYS_ify
+#ifdef __STDC__
+# define SYS_ify(syscall_name)	__NR_##syscall_name
+#else
+# define SYS_ify(syscall_name)	__NR_/**/syscall_name
+#endif
+
+#ifdef ASSEMBLER
+
+#define ENTRY(name)                                                           \
+  .globl name;							              \
+  .type name,@function;						              \
+  .align 2;								      \
+  C_LABEL(name)
+
+#define DO_CALL(syscall)				      		      \
+    li 0,syscall;						              \
+    sc
+
+#define PSEUDO(name, syscall_name, args)                                      \
+  .text;								      \
+  ENTRY (name)                                                                \
+    DO_CALL (SYS_ify (syscall_name));				              \
+    bnslr; \
+    b __syscall_error
+
+#define ret	/* Nothing (should be 'blr', but never reached).  */
+
+#endif	/* ASSEMBLER */
diff --git a/sysdeps/unix/sysv/linux/powerpc/termbits.h b/sysdeps/unix/sysv/linux/powerpc/termbits.h
new file mode 100644
index 0000000000..d1b0a3e3cb
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/powerpc/termbits.h
@@ -0,0 +1,356 @@
+/* Copyright (C) 1997 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public License as
+   published by the Free Software Foundation; either version 2 of the
+   License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  If not,
+   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
+
+#ifndef _TERMBITS_H
+#define _TERMBITS_H
+
+#include <linux/posix_types.h>
+
+typedef unsigned char	cc_t;
+typedef unsigned int	speed_t;
+typedef unsigned int	tcflag_t;
+
+/*
+ * termios type and macro definitions.  Be careful about adding stuff
+ * to this file since it's used in GNU libc and there are strict rules
+ * concerning namespace pollution.
+ */
+
+#define NCCS 19
+struct termios {
+	tcflag_t c_iflag;		/* input mode flags */
+	tcflag_t c_oflag;		/* output mode flags */
+	tcflag_t c_cflag;		/* control mode flags */
+	tcflag_t c_lflag;		/* local mode flags */
+	cc_t c_cc[NCCS];		/* control characters */
+	cc_t c_line;			/* line discipline (== c_cc[19]) */
+	speed_t c_ispeed;		/* input speed */
+	speed_t c_ospeed;		/* output speed */
+};
+
+/* c_cc characters */
+#define VINTR 	0
+#define VQUIT 	1
+#define VERASE 	2
+#define VKILL	3
+#define VEOF	4
+#define VMIN	5
+#define VEOL	6
+#define VTIME	7
+#define VEOL2	8
+#define VSWTC	9
+
+#define VWERASE 	10
+#define VREPRINT	11
+#define VSUSP 		12
+#define VSTART		13
+#define VSTOP		14
+#define VLNEXT		15
+#define VDISCARD	16
+
+/* c_iflag bits */
+#define IGNBRK	0000001
+#define BRKINT	0000002
+#define IGNPAR	0000004
+#define PARMRK	0000010
+#define INPCK	0000020
+#define ISTRIP	0000040
+#define INLCR	0000100
+#define IGNCR	0000200
+#define ICRNL	0000400
+#define IXON	0001000
+#define IXOFF	0002000
+#if !defined(KERNEL) || defined(__USE_BSD)
+  /* POSIX.1 doesn't want these... */
+# define IXANY		0004000
+# define IUCLC		0010000
+# define IMAXBEL	0020000
+#endif
+
+/* c_oflag bits */
+#define OPOST	0000001
+#define ONLCR	0000002
+#define OLCUC	0000004
+
+#define OCRNL	0000010
+#define ONOCR	0000020
+#define ONLRET	0000040
+
+#define OFILL	00000100
+#define OFDEL	00000200
+#define NLDLY	00001400
+#define   NL0	00000000
+#define   NL1	00000400
+#define   NL2	00001000
+#define   NL3	00001400
+#define TABDLY	00006000
+#define   TAB0	00000000
+#define   TAB1	00002000
+#define   TAB2	00004000
+#define   TAB3	00006000
+#define CRDLY	00030000
+#define   CR0	00000000
+#define   CR1	00010000
+#define   CR2	00020000
+#define   CR3	00030000
+#define FFDLY	00040000
+#define   FF0	00000000
+#define   FF1	00040000
+#define BSDLY	00100000
+#define   BS0	00000000
+#define   BS1	00100000
+#define VTDLY	00200000
+#define   VT0	00000000
+#define   VT1	00200000
+#define XTABS	01000000 /* Hmm.. Linux/i386 considers this part of TABDLY.. */
+
+/* c_cflag bit meaning */
+#define CBAUD	0000377
+#define  B0	0000000		/* hang up */
+#define  B50	0000001
+#define  B75	0000002
+#define  B110	0000003
+#define  B134	0000004
+#define  B150	0000005
+#define  B200	0000006
+#define  B300	0000007
+#define  B600	0000010
+#define  B1200	0000011
+#define  B1800	0000012
+#define  B2400	0000013
+#define  B4800	0000014
+#define  B9600	0000015
+#define  B19200	0000016
+#define  B38400	0000017
+#define EXTA B19200
+#define EXTB B38400
+#define CBAUDEX 0000020
+#define  B57600   00020
+#define  B115200  00021
+#define  B230400  00022
+#define  B460800  00023
+
+#define CSIZE	00001400
+#define   CS5	00000000
+#define   CS6	00000400
+#define   CS7	00001000
+#define   CS8	00001400
+
+#define CSTOPB	00002000
+#define CREAD	00004000
+#define PARENB	00010000
+#define PARODD	00020000
+#define HUPCL	00040000
+
+#define CLOCAL	00100000
+#define CRTSCTS	  020000000000		/* flow control */
+
+/* c_lflag bits */
+#define ISIG	0x00000080
+#define ICANON	0x00000100
+#define XCASE	0x00004000
+#define ECHO	0x00000008
+#define ECHOE	0x00000002
+#define ECHOK	0x00000004
+#define ECHONL	0x00000010
+#define NOFLSH	0x80000000
+#define TOSTOP	0x00400000
+#define ECHOCTL	0x00000040
+#define ECHOPRT	0x00000020
+#define ECHOKE	0x00000001
+#define FLUSHO	0x00800000
+#define PENDIN	0x20000000
+#define IEXTEN	0x00000400
+
+/* Values for the ACTION argument to `tcflow'.  */
+#define	TCOOFF		0
+#define	TCOON		1
+#define	TCIOFF		2
+#define	TCION		3
+
+/* Values for the QUEUE_SELECTOR argument to `tcflush'.  */
+#define	TCIFLUSH	0
+#define	TCOFLUSH	1
+#define	TCIOFLUSH	2
+
+/* Values for the OPTIONAL_ACTIONS argument to `tcsetattr'.  */
+#define	TCSANOW		0
+#define	TCSADRAIN	1
+#define	TCSAFLUSH	2
+
+struct sgttyb {
+	char	sg_ispeed;
+	char	sg_ospeed;
+	char	sg_erase;
+	char	sg_kill;
+	short	sg_flags;
+};
+
+struct tchars {
+	char	t_intrc;
+	char	t_quitc;
+	char	t_startc;
+	char	t_stopc;
+	char	t_eofc;
+	char	t_brkc;
+};
+
+struct ltchars {
+	char	t_suspc;
+	char	t_dsuspc;
+	char	t_rprntc;
+	char	t_flushc;
+	char	t_werasc;
+	char	t_lnextc;
+};
+
+#define FIOCLEX		_IO('f', 1)
+#define FIONCLEX	_IO('f', 2)
+#define FIOASYNC	_IOW('f', 125, int)
+#define FIONBIO		_IOW('f', 126, int)
+#define FIONREAD	_IOR('f', 127, int)
+#define TIOCINQ		FIONREAD
+
+#define TIOCGETP	_IOR('t', 8, struct sgttyb)
+#define TIOCSETP	_IOW('t', 9, struct sgttyb)
+#define TIOCSETN	_IOW('t', 10, struct sgttyb)	/* TIOCSETP wo flush */
+
+#define TIOCSETC	_IOW('t', 17, struct tchars)
+#define TIOCGETC	_IOR('t', 18, struct tchars)
+#define TCGETS		_IOR('t', 19, struct termios)
+#define TCSETS		_IOW('t', 20, struct termios)
+#define TCSETSW		_IOW('t', 21, struct termios)
+#define TCSETSF		_IOW('t', 22, struct termios)
+
+#define TCGETA		_IOR('t', 23, struct termio)
+#define TCSETA		_IOW('t', 24, struct termio)
+#define TCSETAW		_IOW('t', 25, struct termio)
+#define TCSETAF		_IOW('t', 28, struct termio)
+
+#define TCSBRK		_IO('t', 29)
+#define TCXONC		_IO('t', 30)
+#define TCFLSH		_IO('t', 31)
+
+#define TIOCSWINSZ	_IOW('t', 103, struct winsize)
+#define TIOCGWINSZ	_IOR('t', 104, struct winsize)
+#define	TIOCSTART	_IO('t', 110)		/* start output, like ^Q */
+#define	TIOCSTOP	_IO('t', 111)		/* stop output, like ^S */
+#define TIOCOUTQ        _IOR('t', 115, int)     /* output queue size */
+
+#define TIOCGLTC	_IOR('t', 116, struct ltchars)
+#define TIOCSLTC	_IOW('t', 117, struct ltchars)
+#define TIOCSPGRP	_IOW('t', 118, int)
+#define TIOCGPGRP	_IOR('t', 119, int)
+
+#define TIOCEXCL	0x540C
+#define TIOCNXCL	0x540D
+#define TIOCSCTTY	0x540E
+
+#define TIOCSTI		0x5412
+#define TIOCMGET	0x5415
+#define TIOCMBIS	0x5416
+#define TIOCMBIC	0x5417
+#define TIOCMSET	0x5418
+#define TIOCGSOFTCAR	0x5419
+#define TIOCSSOFTCAR	0x541A
+#define TIOCLINUX	0x541C
+#define TIOCCONS	0x541D
+#define TIOCGSERIAL	0x541E
+#define TIOCSSERIAL	0x541F
+#define TIOCPKT		0x5420
+
+#define TIOCNOTTY	0x5422
+#define TIOCSETD	0x5423
+#define TIOCGETD	0x5424
+#define TCSBRKP		0x5425	/* Needed for POSIX tcsendbreak() */
+#define TIOCTTYGSTRUCT	0x5426  /* For debugging only */
+
+#define TIOCSERCONFIG	0x5453
+#define TIOCSERGWILD	0x5454
+#define TIOCSERSWILD	0x5455
+#define TIOCGLCKTRMIOS	0x5456
+#define TIOCSLCKTRMIOS	0x5457
+#define TIOCSERGSTRUCT	0x5458 /* For debugging only */
+#define TIOCSERGETLSR   0x5459 /* Get line status register */
+#define TIOCSERGETMULTI 0x545A /* Get multiport config  */
+#define TIOCSERSETMULTI 0x545B /* Set multiport config */
+
+#define TIOCMIWAIT	0x545C	/* wait for a change on serial input line(s) */
+#define TIOCGICOUNT	0x545D	/* read serial port inline interrupt counts */
+
+/* Used for packet mode */
+#define TIOCPKT_DATA		 0
+#define TIOCPKT_FLUSHREAD	 1
+#define TIOCPKT_FLUSHWRITE	 2
+#define TIOCPKT_STOP		 4
+#define TIOCPKT_START		 8
+#define TIOCPKT_NOSTOP		16
+#define TIOCPKT_DOSTOP		32
+
+struct winsize {
+	unsigned short ws_row;
+	unsigned short ws_col;
+	unsigned short ws_xpixel;
+	unsigned short ws_ypixel;
+};
+
+#define NCC 10
+struct termio {
+	unsigned short c_iflag;		/* input mode flags */
+	unsigned short c_oflag;		/* output mode flags */
+	unsigned short c_cflag;		/* control mode flags */
+	unsigned short c_lflag;		/* local mode flags */
+	unsigned char c_line;		/* line discipline */
+	unsigned char c_cc[NCC];	/* control characters */
+};
+
+/* c_cc characters */
+#define _VINTR	0
+#define _VQUIT	1
+#define _VERASE	2
+#define _VKILL	3
+#define _VEOF	4
+#define _VMIN	5
+#define _VEOL	6
+#define _VTIME	7
+#define _VEOL2	8
+#define _VSWTC	9
+
+/* modem lines */
+#define TIOCM_LE	0x001
+#define TIOCM_DTR	0x002
+#define TIOCM_RTS	0x004
+#define TIOCM_ST	0x008
+#define TIOCM_SR	0x010
+#define TIOCM_CTS	0x020
+#define TIOCM_CAR	0x040
+#define TIOCM_RNG	0x080
+#define TIOCM_DSR	0x100
+#define TIOCM_CD	TIOCM_CAR
+#define TIOCM_RI	TIOCM_RNG
+
+/* ioctl (fd, TIOCSERGETLSR, &result) where result may be as below */
+#define TIOCSER_TEMT    0x01	/* Transmitter physically empty */
+
+/* line disciplines */
+#define N_TTY		0
+#define N_SLIP		1
+#define N_MOUSE		2
+#define N_PPP		3
+
+#endif /* _TERMBITS_H */
diff --git a/sysdeps/unix/sysv/linux/syscalls.list b/sysdeps/unix/sysv/linux/syscalls.list
index 867e3bce3e..4e92f6d35c 100644
--- a/sysdeps/unix/sysv/linux/syscalls.list
+++ b/sysdeps/unix/sysv/linux/syscalls.list
@@ -30,10 +30,10 @@ nanosleep	-	nanosleep	2	__libc_nanosleep	__nanosleep nanosleep
 pause		-	pause		0	__libc_pause	pause
 personality	init-first personality	1	__personality	personality
 pipe		-	pipe		1	__pipe		pipe
-s_poll		EXTRA	poll		3	__syscall_poll
 query_module	EXTRA	query_module	5	query_module
 s_getdents	EXTRA	getdents	3	__getdents
 s_getpriority	getpriority getpriority	2	__syscall_getpriority
+s_poll		poll	poll		3	__syscall_poll
 s_ptrace	ptrace	ptrace		4	__syscall_ptrace
 s_reboot	EXTRA	reboot		3	__syscall_reboot
 s_sigaction	sigaction sigaction	3	__syscall_sigaction