From 2512c847453c24b928c34beed88902fbb6877b7a Mon Sep 17 00:00:00 2001
From: Eric Andersen <andersen@codepoet.org>
Date: Thu, 27 Sep 2001 05:24:26 +0000
Subject: Update to accomodate the header file changes

---
 libc/Makefile                               |   2 +-
 libc/inet/getnetbyad.c                      |   5 +-
 libc/inet/resolv.c                          |  45 +++-
 libc/inet/rpc/bindresvport.c                |   2 +-
 libc/inet/rpc/svc.c                         |   2 +
 libc/inet/socketcalls.c                     |  22 +-
 libc/misc/lsearch/lsearch.c                 |   2 +-
 libc/misc/mntent/mntent.c                   |   2 +-
 libc/misc/sysvipc/ftok.c                    |   2 +-
 libc/misc/sysvipc/shm.c                     |   1 +
 libc/misc/time/ctime.c                      |   1 +
 libc/misc/time/ctime_r.c                    |   1 +
 libc/misc/time/localtime.c                  |   1 +
 libc/misc/time/localtime_r.c                |   1 +
 libc/misc/time/utimes.c                     |   5 +-
 libc/misc/utmp/utent.c                      |  12 +-
 libc/pwd_grp/config.h                       |   9 +
 libc/pwd_grp/fgetgrent.c                    |   1 +
 libc/pwd_grp/fgetpwent.c                    |   1 +
 libc/pwd_grp/getgrgid.c                     |   1 +
 libc/pwd_grp/getgrnam.c                     |   1 +
 libc/pwd_grp/getpwnam.c                     |   1 +
 libc/pwd_grp/getpwuid.c                     |   1 +
 libc/pwd_grp/grent.c                        |   1 +
 libc/pwd_grp/pwent.c                        |   1 +
 libc/signal/sigaddset.c                     |   3 +-
 libc/signal/sigblock.c                      |   1 -
 libc/signal/sigdelset.c                     |   6 +-
 libc/signal/siggtmsk.c                      |   1 -
 libc/signal/sigismem.c                      |   6 +-
 libc/signal/sigstmsk.c                      |   1 -
 libc/stdio/getline.c                        |   1 +
 libc/stdio/perror.c                         |   1 +
 libc/stdio/scanf.c                          |   1 +
 libc/stdlib/atexit.c                        |   1 +
 libc/stdlib/getpt.c                         |   2 +-
 libc/stdlib/grantpt.c                       |   2 +-
 libc/stdlib/malloc/malloc.c                 |   2 +-
 libc/stdlib/ptsname.c                       |   2 +-
 libc/stdlib/putenv.c                        |   3 +-
 libc/stdlib/setenv.c                        |   3 +-
 libc/stdlib/strto_ll.c                      |   1 +
 libc/stdlib/unix_grantpt.c                  |   2 +-
 libc/string/strsignal.c                     |   6 +-
 libc/sysdeps/linux/arm/bits/byteswap.h      |  43 ++--
 libc/sysdeps/linux/arm/bits/confname.h      | 245 ++++++++++++++++----
 libc/sysdeps/linux/arm/bits/dirent.h        |  31 +--
 libc/sysdeps/linux/arm/bits/dlfcn.h         |  18 +-
 libc/sysdeps/linux/arm/bits/errno.h         |  20 +-
 libc/sysdeps/linux/arm/bits/fcntl.h         |  93 +++++---
 libc/sysdeps/linux/arm/bits/huge_val.h      |  16 +-
 libc/sysdeps/linux/arm/bits/in.h            |  41 ++--
 libc/sysdeps/linux/arm/bits/ioctl-types.h   |  19 +-
 libc/sysdeps/linux/arm/bits/ioctls.h        |  16 +-
 libc/sysdeps/linux/arm/bits/ipc.h           |  36 +--
 libc/sysdeps/linux/arm/bits/local_lim.h     |  28 ++-
 libc/sysdeps/linux/arm/bits/mathcalls.h     |  30 +--
 libc/sysdeps/linux/arm/bits/mathdef.h       |  16 +-
 libc/sysdeps/linux/arm/bits/mman.h          |  16 +-
 libc/sysdeps/linux/arm/bits/msq.h           |  16 +-
 libc/sysdeps/linux/arm/bits/poll.h          |  21 +-
 libc/sysdeps/linux/arm/bits/posix1_lim.h    |  22 +-
 libc/sysdeps/linux/arm/bits/posix2_lim.h    |  37 ++-
 libc/sysdeps/linux/arm/bits/posix_opt.h     |  39 +++-
 libc/sysdeps/linux/arm/bits/resource.h      |  16 +-
 libc/sysdeps/linux/arm/bits/select.h        |  22 +-
 libc/sysdeps/linux/arm/bits/sem.h           |  16 +-
 libc/sysdeps/linux/arm/bits/setjmp.h        |  16 +-
 libc/sysdeps/linux/arm/bits/shm.h           |  53 +++--
 libc/sysdeps/linux/arm/bits/sigaction.h     |  22 +-
 libc/sysdeps/linux/arm/bits/sigcontext.h    |  16 +-
 libc/sysdeps/linux/arm/bits/siginfo.h       |  71 ++++--
 libc/sysdeps/linux/arm/bits/signum.h        |  16 +-
 libc/sysdeps/linux/arm/bits/sigset.h        |  20 +-
 libc/sysdeps/linux/arm/bits/sigstack.h      |  22 +-
 libc/sysdeps/linux/arm/bits/sigthread.h     |  15 +-
 libc/sysdeps/linux/arm/bits/sockaddr.h      |  25 +-
 libc/sysdeps/linux/arm/bits/socket.h        |  69 +++---
 libc/sysdeps/linux/arm/bits/stat.h          |  45 ++--
 libc/sysdeps/linux/arm/bits/statfs.h        |  21 +-
 libc/sysdeps/linux/arm/bits/stdio_lim.h     |  28 ++-
 libc/sysdeps/linux/arm/bits/termios.h       |  17 +-
 libc/sysdeps/linux/arm/bits/time.h          |  40 ++--
 libc/sysdeps/linux/arm/bits/types.h         |  57 ++---
 libc/sysdeps/linux/arm/bits/uio.h           |  16 +-
 libc/sysdeps/linux/arm/bits/waitflags.h     |  18 +-
 libc/sysdeps/linux/arm/bits/waitstatus.h    |  20 +-
 libc/sysdeps/linux/arm/bits/wordsize.h      |  16 +-
 libc/sysdeps/linux/arm/bits/xopen_lim.h     |  86 +++++--
 libc/sysdeps/linux/arm/setjmp.S             |   6 +-
 libc/sysdeps/linux/common/errno.c           |   4 +-
 libc/sysdeps/linux/common/getdnnm.c         |   3 +-
 libc/sysdeps/linux/common/getdtablesize.c   |   7 +-
 libc/sysdeps/linux/common/getpagesize.c     |   4 +-
 libc/sysdeps/linux/common/setegid.c         |   1 +
 libc/sysdeps/linux/common/seteuid.c         |   1 +
 libc/sysdeps/linux/common/statfix.c         |   6 +-
 libc/sysdeps/linux/common/statfix.h         |   2 +-
 libc/sysdeps/linux/common/syscalls.c        |  31 ++-
 libc/sysdeps/linux/common/wait.c            |   1 +
 libc/sysdeps/linux/common/waitpid.c         |   3 +-
 libc/sysdeps/linux/i386/Makefile            |   2 +
 libc/sysdeps/linux/i386/bits/byteswap.h     |  39 +++-
 libc/sysdeps/linux/i386/bits/cmathcalls.h   |  34 ++-
 libc/sysdeps/linux/i386/bits/confname.h     | 245 ++++++++++++++++----
 libc/sysdeps/linux/i386/bits/dirent.h       |  31 +--
 libc/sysdeps/linux/i386/bits/dlfcn.h        |  48 ++--
 libc/sysdeps/linux/i386/bits/elfclass.h     |   3 +
 libc/sysdeps/linux/i386/bits/environments.h |  48 ++--
 libc/sysdeps/linux/i386/bits/errno.h        |  28 +--
 libc/sysdeps/linux/i386/bits/fcntl.h        |  96 +++++---
 libc/sysdeps/linux/i386/bits/fenv.h         |  22 +-
 libc/sysdeps/linux/i386/bits/huge_val.h     |  79 ++++---
 libc/sysdeps/linux/i386/bits/in.h           |  41 ++--
 libc/sysdeps/linux/i386/bits/ioctl-types.h  |  19 +-
 libc/sysdeps/linux/i386/bits/ioctls.h       |  16 +-
 libc/sysdeps/linux/i386/bits/ipc.h          |  36 +--
 libc/sysdeps/linux/i386/bits/libc-lock.h    | 147 ++++++++++--
 libc/sysdeps/linux/i386/bits/local_lim.h    |  28 ++-
 libc/sysdeps/linux/i386/bits/locale.h       |  16 +-
 libc/sysdeps/linux/i386/bits/mathcalls.h    |  58 +++--
 libc/sysdeps/linux/i386/bits/mathdef.h      |  30 +--
 libc/sysdeps/linux/i386/bits/mathinline.h   | 343 +++++++++++++++-------------
 libc/sysdeps/linux/i386/bits/mman.h         |  36 ++-
 libc/sysdeps/linux/i386/bits/msq.h          |  47 ++--
 libc/sysdeps/linux/i386/bits/nan.h          |  16 +-
 libc/sysdeps/linux/i386/bits/netdb.h        |  33 +++
 libc/sysdeps/linux/i386/bits/poll.h         |  21 +-
 libc/sysdeps/linux/i386/bits/posix1_lim.h   |  22 +-
 libc/sysdeps/linux/i386/bits/posix2_lim.h   |  37 ++-
 libc/sysdeps/linux/i386/bits/posix_opt.h    |  47 +++-
 libc/sysdeps/linux/i386/bits/pthreadtypes.h |  26 ++-
 libc/sysdeps/linux/i386/bits/resource.h     |  32 +--
 libc/sysdeps/linux/i386/bits/sched.h        |  26 +--
 libc/sysdeps/linux/i386/bits/select.h       |  24 +-
 libc/sysdeps/linux/i386/bits/sem.h          |  29 ++-
 libc/sysdeps/linux/i386/bits/setjmp.h       |  19 +-
 libc/sysdeps/linux/i386/bits/shm.h          |  53 +++--
 libc/sysdeps/linux/i386/bits/sigaction.h    |  22 +-
 libc/sysdeps/linux/i386/bits/sigcontext.h   |  16 +-
 libc/sysdeps/linux/i386/bits/siginfo.h      |  71 ++++--
 libc/sysdeps/linux/i386/bits/signum.h       |  16 +-
 libc/sysdeps/linux/i386/bits/sigset.h       |  19 +-
 libc/sysdeps/linux/i386/bits/sigstack.h     |  22 +-
 libc/sysdeps/linux/i386/bits/sigthread.h    |  15 +-
 libc/sysdeps/linux/i386/bits/sockaddr.h     |  25 +-
 libc/sysdeps/linux/i386/bits/socket.h       |  69 +++---
 libc/sysdeps/linux/i386/bits/stat.h         |  45 ++--
 libc/sysdeps/linux/i386/bits/statfs.h       |  21 +-
 libc/sysdeps/linux/i386/bits/statvfs.h      |  51 +++--
 libc/sysdeps/linux/i386/bits/stdio-lock.h   |  15 +-
 libc/sysdeps/linux/i386/bits/stdio.h        |  41 ++--
 libc/sysdeps/linux/i386/bits/stdio_lim.h    |  28 ++-
 libc/sysdeps/linux/i386/bits/string.h       |  52 ++++-
 libc/sysdeps/linux/i386/bits/string2.h      |  88 ++++---
 libc/sysdeps/linux/i386/bits/stropts.h      |  46 ++--
 libc/sysdeps/linux/i386/bits/termios.h      |  17 +-
 libc/sysdeps/linux/i386/bits/time.h         |  46 ++--
 libc/sysdeps/linux/i386/bits/types.h        |  59 ++---
 libc/sysdeps/linux/i386/bits/uio.h          |  16 +-
 libc/sysdeps/linux/i386/bits/ustat.h        |  16 +-
 libc/sysdeps/linux/i386/bits/utmp.h         |  17 +-
 libc/sysdeps/linux/i386/bits/utmpx.h        |  25 +-
 libc/sysdeps/linux/i386/bits/utsname.h      |  16 +-
 libc/sysdeps/linux/i386/bits/waitflags.h    |  18 +-
 libc/sysdeps/linux/i386/bits/waitstatus.h   |  20 +-
 libc/sysdeps/linux/i386/bits/wordsize.h     |  16 +-
 libc/sysdeps/linux/i386/bits/xopen_lim.h    |  86 +++++--
 libc/sysdeps/linux/i386/longjmp.c           |   3 +-
 libc/sysdeps/linux/i386/sbrk.c              |   3 +-
 libc/sysdeps/linux/i386/setjmp.S            |   6 +-
 libc/sysdeps/linux/i386/vm86.h              |  34 +++
 libc/termios/tcsetattr.c                    |   2 +-
 libc/termios/termios.c                      |   1 +
 libc/unistd/sleep.c                         |   4 +-
 libc/unistd/sysconf.c                       |   7 +-
 176 files changed, 2971 insertions(+), 1783 deletions(-)
 create mode 100644 libc/sysdeps/linux/i386/bits/netdb.h
 create mode 100644 libc/sysdeps/linux/i386/vm86.h

diff --git a/libc/Makefile b/libc/Makefile
index c647984d4..4001f2b2c 100644
--- a/libc/Makefile
+++ b/libc/Makefile
@@ -54,7 +54,7 @@ shared: $(TOPDIR)lib/$(LIBNAME)
 		    -Wl,-soname,$(SHARED_MAJORNAME) -Wl,--whole-archive \
 		    ./$(LIBNAME) $(LDSO)  -Wl,-dynamic-linker,$(DYNAMIC_LINKER); \
 	fi
-	@rm -rf tmp
+	@/bin/true #rm -rf tmp
 	install -d $(TOPDIR)lib
 	rm -f $(TOPDIR)lib/$(SHARED_FULLNAME)
 	install -m 644 $(SHARED_FULLNAME) $(TOPDIR)lib
diff --git a/libc/inet/getnetbyad.c b/libc/inet/getnetbyad.c
index f1c2328f2..38fe03cc6 100644
--- a/libc/inet/getnetbyad.c
+++ b/libc/inet/getnetbyad.c
@@ -19,10 +19,7 @@
 
 extern int _net_stayopen;
 
-struct netent *
-getnetbyaddr(net, type)
-	register long net;
-	register int type;
+struct netent *getnetbyaddr (uint32_t net, int type)
 {
 	register struct netent *p;
 
diff --git a/libc/inet/resolv.c b/libc/inet/resolv.c
index 034bb80db..e5558fbde 100644
--- a/libc/inet/resolv.c
+++ b/libc/inet/resolv.c
@@ -50,7 +50,6 @@
 #include <arpa/inet.h>
 #include <stdlib.h>
 #include <unistd.h>
-#include <cfgfile.h>
 #include <resolv.h>
 #include <netdb.h>
 #include <ctype.h>
@@ -72,6 +71,31 @@
 #endif /* DEBUG */
 
 
+struct resolv_header {
+	int id;
+	int qr,opcode,aa,tc,rd,ra,rcode;
+	int qdcount;
+	int ancount;
+	int nscount;
+	int arcount;
+};
+
+struct resolv_question {
+	char * dotted;
+	int qtype;
+	int qclass;
+};
+
+struct resolv_answer {
+	char * dotted;
+	int atype;
+	int aclass;
+	int ttl;
+	int rdlength;
+	unsigned char * rdata;
+	int rdoffset;
+};
+
 extern int nameservers;
 extern char * nameserver[MAX_SERVERS];
 extern int searchdomains;
@@ -86,6 +110,22 @@ extern int resolve_mailbox(const char * address, int nscount,
 extern int dns_lookup(const char * name, int type, int nscount, 
 	char ** nsip, unsigned char ** outpacket, struct resolv_answer * a);
 
+int encode_dotted(const char * dotted, unsigned char * dest, int maxlen);
+int decode_dotted(const unsigned char * message, int offset, 
+	char * dest, int maxlen);
+int length_dotted(const unsigned char * message, int offset);
+int encode_header(struct resolv_header * h, unsigned char * dest, int maxlen);
+int decode_header(unsigned char * data, struct resolv_header * h);
+int encode_question(struct resolv_question * q,
+	unsigned char * dest, int maxlen);
+int decode_question(unsigned char * message, int offset,
+	struct resolv_question * q);
+int encode_answer(struct resolv_answer * a,
+	unsigned char * dest, int maxlen);
+int decode_answer(unsigned char * message, int offset,
+	struct resolv_answer * a);
+int length_question(unsigned char * message, int offset);
+extern int open_nameservers(void);
 
 
 #ifdef L_encodeh
@@ -1141,8 +1181,7 @@ int res_query(const char *dname, int class, int type,
 
 
 #ifdef L_gethostbyaddr
-
-struct hostent *gethostbyaddr(const char *addr, int len, int type)
+struct hostent *gethostbyaddr (const void *addr, __socklen_t len, int type)
 {
 	static struct hostent h;
 	static char namebuf[256];
diff --git a/libc/inet/rpc/bindresvport.c b/libc/inet/rpc/bindresvport.c
index e71dff7f4..800398ae4 100644
--- a/libc/inet/rpc/bindresvport.c
+++ b/libc/inet/rpc/bindresvport.c
@@ -75,7 +75,7 @@ struct sockaddr_in *sin;
 		if (port > ENDPORT) {
 			port = STARTPORT;
 		}
-		res = bind(sd, sin, sizeof(struct sockaddr_in));
+		res = bind(sd, (struct sockaddr *)sin, (socklen_t)sizeof(struct sockaddr_in));
 	}
 	return (res);
 }
diff --git a/libc/inet/rpc/svc.c b/libc/inet/rpc/svc.c
index 0436e3042..780a33725 100644
--- a/libc/inet/rpc/svc.c
+++ b/libc/inet/rpc/svc.c
@@ -40,11 +40,13 @@
  * Copyright (C) 1984, Sun Microsystems, Inc.
  */
 
+#define __USE_XOPEN
 #include <sys/errno.h>
 #include <rpc/rpc.h>
 #include <rpc/pmap_clnt.h>
 #ifdef __linux__
 #include <sys/types.h>
+#include <sys/select.h>
 #endif
 
 extern int errno;
diff --git a/libc/inet/socketcalls.c b/libc/inet/socketcalls.c
index 7b968cdb6..f73eeb0ec 100644
--- a/libc/inet/socketcalls.c
+++ b/libc/inet/socketcalls.c
@@ -3,10 +3,30 @@
 #include <errno.h>
 #include <syscall.h>
 #include <sys/socket.h>
-#include <sys/socketcall.h>
+
 
 extern int socketcall(int call, unsigned long *args);
 
+/* Various socketcall numbers */
+#define SYS_SOCKET      1
+#define SYS_BIND        2
+#define SYS_CONNECT     3
+#define SYS_LISTEN      4
+#define SYS_ACCEPT      5
+#define SYS_GETSOCKNAME 6
+#define SYS_GETPEERNAME 7
+#define SYS_SOCKETPAIR  8
+#define SYS_SEND        9
+#define SYS_RECV        10
+#define SYS_SENDTO      11
+#define SYS_RECVFROM    12
+#define SYS_SHUTDOWN    13
+#define SYS_SETSOCKOPT  14
+#define SYS_GETSOCKOPT  15
+#define SYS_SENDMSG     16
+#define SYS_RECVMSG     17
+
+
 #ifdef L_accept
 int accept(int s, struct sockaddr *addr, socklen_t * addrlen)
 {
diff --git a/libc/misc/lsearch/lsearch.c b/libc/misc/lsearch/lsearch.c
index aed4b1e7d..ace739211 100644
--- a/libc/misc/lsearch/lsearch.c
+++ b/libc/misc/lsearch/lsearch.c
@@ -8,6 +8,7 @@
  *  "It's not reality that's important, but how you perceive things."
  */
 
+#include <string.h>
 #include <stdio.h>
 
 char *lfind(key, base, num, size, cmp)
@@ -33,7 +34,6 @@ register unsigned int size;
 int (*cmp) ();
 {
 	register char *p;
-	char *memcpy();
 
 	if ((p = lfind(key, base, num, size, cmp)) == NULL) {
 		p = memcpy((base + (size * (*num))), key, size);
diff --git a/libc/misc/mntent/mntent.c b/libc/misc/mntent/mntent.c
index 2bdd3c7a6..9e8fda613 100644
--- a/libc/misc/mntent/mntent.c
+++ b/libc/misc/mntent/mntent.c
@@ -8,7 +8,7 @@
 struct mntent *getmntent(FILE * filep)
 {
 	char *cp, *sep = " \t\n";
-	static char buff[MNTMAXSTR];
+	static char buff[BUFSIZ];
 	static struct mntent mnt;
 
 	/* Loop on the file, skipping comment lines. - FvK 03/07/93 */
diff --git a/libc/misc/sysvipc/ftok.c b/libc/misc/sysvipc/ftok.c
index 06843edda..b0199acda 100644
--- a/libc/misc/sysvipc/ftok.c
+++ b/libc/misc/sysvipc/ftok.c
@@ -28,7 +28,7 @@ ftok (pathname, proj_id)
   struct stat st;
   key_t key;
 
-  if (_xstat (_STAT_VER, pathname, &st) < 0)
+  if (__xstat (_STAT_VER, pathname, &st) < 0)
     return (key_t) -1;
 
   key = ((st.st_ino & 0xffff) | ((st.st_dev & 0xff) << 16)
diff --git a/libc/misc/sysvipc/shm.c b/libc/misc/sysvipc/shm.c
index 5fdfe6ca7..c916993d0 100644
--- a/libc/misc/sysvipc/shm.c
+++ b/libc/misc/sysvipc/shm.c
@@ -17,6 +17,7 @@
    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.  */
 
+#include <stdlib.h>
 #include <errno.h>
 #include <sys/shm.h>
 #include "ipc.h"
diff --git a/libc/misc/time/ctime.c b/libc/misc/time/ctime.c
index ddcde6111..8783d284e 100644
--- a/libc/misc/time/ctime.c
+++ b/libc/misc/time/ctime.c
@@ -1,5 +1,6 @@
 
 #include <time.h>
+#include <sys/time.h>
 
 extern void __tm_conv();
 extern void __asctime();
diff --git a/libc/misc/time/ctime_r.c b/libc/misc/time/ctime_r.c
index 85677b681..b608098ae 100644
--- a/libc/misc/time/ctime_r.c
+++ b/libc/misc/time/ctime_r.c
@@ -1,5 +1,6 @@
 
 #include <time.h>
+#include <sys/time.h>
 
 extern void __tm_conv();
 extern void __asctime();
diff --git a/libc/misc/time/localtime.c b/libc/misc/time/localtime.c
index 1f538ab7a..bedbb8ea7 100644
--- a/libc/misc/time/localtime.c
+++ b/libc/misc/time/localtime.c
@@ -1,5 +1,6 @@
 
 #include <time.h>
+#include <sys/time.h>
 
 extern void __tm_conv();
 
diff --git a/libc/misc/time/localtime_r.c b/libc/misc/time/localtime_r.c
index d084f2b1e..139864506 100644
--- a/libc/misc/time/localtime_r.c
+++ b/libc/misc/time/localtime_r.c
@@ -1,5 +1,6 @@
 
 #include <time.h>
+#include <sys/time.h>
 
 extern void __tm_conv();
 
diff --git a/libc/misc/time/utimes.c b/libc/misc/time/utimes.c
index 364bf83e7..86dff6bea 100644
--- a/libc/misc/time/utimes.c
+++ b/libc/misc/time/utimes.c
@@ -1,7 +1,8 @@
+#include <stdlib.h>
 #include <utime.h>
 #include <sys/time.h>
 
-int utimes(const char *path, struct timeval tvp[2])
+int utimes (const char *file, const struct timeval tvp[2])
 {
 	struct utimbuf buf, *times;
 
@@ -12,5 +13,5 @@ int utimes(const char *path, struct timeval tvp[2])
 	}
 	else
 		times = NULL;
-	return utime(path, times);
+	return utime(file, times);
 }
diff --git a/libc/misc/utmp/utent.c b/libc/misc/utmp/utent.c
index f9d098fb3..220bd6db6 100644
--- a/libc/misc/utmp/utent.c
+++ b/libc/misc/utmp/utent.c
@@ -7,6 +7,7 @@
    have to call endutent() to close the file even if you've not called
    setutent -- getutid and family use the same file descriptor. */
 
+#include <stdio.h>
 #include <unistd.h>
 #include <fcntl.h>
 #include <paths.h>
@@ -53,7 +54,7 @@ struct utmp *getutent(void)
 	return __getutent(ut_fd);
 }
 
-struct utmp *getutid(struct utmp *utmp_entry)
+struct utmp *getutid (const struct utmp *utmp_entry)
 {
 	struct utmp *utmp;
 
@@ -78,7 +79,7 @@ struct utmp *getutid(struct utmp *utmp_entry)
 	return NULL;
 }
 
-struct utmp *getutline(struct utmp *utmp_entry)
+struct utmp *getutline(const struct utmp *utmp_entry)
 {
 	struct utmp *utmp;
 
@@ -102,7 +103,7 @@ struct utmp *getutline(struct utmp *utmp_entry)
 	return NULL;
 }
 
-struct utmp *pututline(struct utmp *utmp_entry)
+struct utmp *pututline (const struct utmp *utmp_entry)
 {
 	struct utmp *ut;
 
@@ -122,14 +123,15 @@ struct utmp *pututline(struct utmp *utmp_entry)
 			return NULL;
 	}
 
-	return utmp_entry;
+	return (struct utmp *)utmp_entry;
 }
 
-void utmpname(const char *new_ut_name)
+int utmpname (const char *new_ut_name)
 {
 	if (new_ut_name != NULL)
 		ut_name = new_ut_name;
 
 	if (ut_fd != -1)
 		close(ut_fd);
+	return 0;
 }
diff --git a/libc/pwd_grp/config.h b/libc/pwd_grp/config.h
index eb029a31a..5a5272999 100644
--- a/libc/pwd_grp/config.h
+++ b/libc/pwd_grp/config.h
@@ -22,6 +22,15 @@
 #ifndef _CONFIG_GRP_H
 #define _CONFIG_GRP_H
 
+#include <pwd.h>
+#include <grp.h>
+
+/* These are used internally to uClibc */
+extern struct group * __getgrent __P ((int grp_fd));
+
+extern int __getpwent_r(struct passwd * passwd, char * line_buff, 
+	size_t buflen, int pwd_fd);
+  
 /*
  * Define GR_SCALE_DYNAMIC if you want grp to dynamically scale its read buffer
  * so that lines of any length can be used.  On very very small systems,
diff --git a/libc/pwd_grp/fgetgrent.c b/libc/pwd_grp/fgetgrent.c
index 50aa01722..7c08ea68e 100644
--- a/libc/pwd_grp/fgetgrent.c
+++ b/libc/pwd_grp/fgetgrent.c
@@ -21,6 +21,7 @@
 #include <stdio.h>
 #include <errno.h>
 #include <grp.h>
+#include "config.h"
 
 struct group *fgetgrent(FILE * file)
 {
diff --git a/libc/pwd_grp/fgetpwent.c b/libc/pwd_grp/fgetpwent.c
index aab1ec744..ae43cdad8 100644
--- a/libc/pwd_grp/fgetpwent.c
+++ b/libc/pwd_grp/fgetpwent.c
@@ -21,6 +21,7 @@
 #include <errno.h>
 #include <stdio.h>
 #include <pwd.h>
+#include "config.h"
 
 #define PWD_BUFFER_SIZE 256
 
diff --git a/libc/pwd_grp/getgrgid.c b/libc/pwd_grp/getgrgid.c
index fa74a9644..70e7152ce 100644
--- a/libc/pwd_grp/getgrgid.c
+++ b/libc/pwd_grp/getgrgid.c
@@ -22,6 +22,7 @@
 #include <unistd.h>
 #include <fcntl.h>
 #include <grp.h>
+#include "config.h"
 
 struct group *getgrgid(const gid_t gid)
 {
diff --git a/libc/pwd_grp/getgrnam.c b/libc/pwd_grp/getgrnam.c
index 6f2634cee..705342489 100644
--- a/libc/pwd_grp/getgrnam.c
+++ b/libc/pwd_grp/getgrnam.c
@@ -23,6 +23,7 @@
 #include <errno.h>
 #include <fcntl.h>
 #include <grp.h>
+#include "config.h"
 
 struct group *getgrnam(const char *name)
 {
diff --git a/libc/pwd_grp/getpwnam.c b/libc/pwd_grp/getpwnam.c
index 5cb4f64f8..f5ad9ca1d 100644
--- a/libc/pwd_grp/getpwnam.c
+++ b/libc/pwd_grp/getpwnam.c
@@ -23,6 +23,7 @@
 #include <errno.h>
 #include <fcntl.h>
 #include <pwd.h>
+#include "config.h"
 
 
 #define PWD_BUFFER_SIZE 256
diff --git a/libc/pwd_grp/getpwuid.c b/libc/pwd_grp/getpwuid.c
index 307f840e1..101d668ae 100644
--- a/libc/pwd_grp/getpwuid.c
+++ b/libc/pwd_grp/getpwuid.c
@@ -22,6 +22,7 @@
 #include <unistd.h>
 #include <fcntl.h>
 #include <pwd.h>
+#include "config.h"
 
 
 #define PWD_BUFFER_SIZE 256
diff --git a/libc/pwd_grp/grent.c b/libc/pwd_grp/grent.c
index aab878a89..8e4af5143 100644
--- a/libc/pwd_grp/grent.c
+++ b/libc/pwd_grp/grent.c
@@ -27,6 +27,7 @@
 #include <unistd.h>
 #include <fcntl.h>
 #include <grp.h>
+#include "config.h"
 
 static int grp_fd = -1;
 
diff --git a/libc/pwd_grp/pwent.c b/libc/pwd_grp/pwent.c
index 6f81f1ea6..e4a17e2b3 100644
--- a/libc/pwd_grp/pwent.c
+++ b/libc/pwd_grp/pwent.c
@@ -23,6 +23,7 @@
 #include <errno.h>
 #include <pwd.h>
 #include <fcntl.h>
+#include "config.h"
 
 /*
  * setpwent(), endpwent(), and getpwent() are included in the same object
diff --git a/libc/signal/sigaddset.c b/libc/signal/sigaddset.c
index 269f7d367..8300dd7ca 100644
--- a/libc/signal/sigaddset.c
+++ b/libc/signal/sigaddset.c
@@ -16,9 +16,10 @@
    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.  */
 
+#include <stdlib.h>
 #include <errno.h>
 #include <features.h>
-#include "signal.h"
+#include <signal.h>
 
 
 /* Add SIGNO to SET.  */
diff --git a/libc/signal/sigblock.c b/libc/signal/sigblock.c
index 8edfe0df2..dd7a23f96 100644
--- a/libc/signal/sigblock.c
+++ b/libc/signal/sigblock.c
@@ -17,7 +17,6 @@ not, write to the Free Software Foundation, Inc., 675 Mass Ave,
 Cambridge, MA 02139, USA.  */
 
 #include <errno.h>
-#define __USE_BSD
 #include <signal.h>
 
 /* Block signals in MASK, returning the old mask.  */
diff --git a/libc/signal/sigdelset.c b/libc/signal/sigdelset.c
index 958f1d44a..6698ff6c4 100644
--- a/libc/signal/sigdelset.c
+++ b/libc/signal/sigdelset.c
@@ -16,8 +16,10 @@
    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.  */
 
-#include "errno.h"
-#include "signal.h"
+#include <stdlib.h>
+#include <errno.h>
+#include <features.h>
+#include <signal.h>
 
 /* Add SIGNO to SET.  */
 int sigdelset ( sigset_t *set, int signo)
diff --git a/libc/signal/siggtmsk.c b/libc/signal/siggtmsk.c
index 517cb49fb..1ee776b40 100644
--- a/libc/signal/siggtmsk.c
+++ b/libc/signal/siggtmsk.c
@@ -17,7 +17,6 @@ not, write to the Free Software Foundation, Inc., 675 Mass Ave,
 Cambridge, MA 02139, USA.  */
 
 #include <errno.h>
-#define __USE_BSD
 #include <signal.h>
 
 /* Get the mask of blocked signals.  */
diff --git a/libc/signal/sigismem.c b/libc/signal/sigismem.c
index 64b14f37e..89d88647d 100644
--- a/libc/signal/sigismem.c
+++ b/libc/signal/sigismem.c
@@ -16,10 +16,12 @@
    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.  */
 
-#include "errno.h"
+#include <stdlib.h>
+#include <errno.h>
+#include <features.h>
 #define _EXTERN_INLINE
 #define __USE_EXTERN_INLINES   1
-#include "signal.h"
+#include <signal.h>
 
 /* Return 1 if SIGNO is in SET, 0 if not.  */
 int sigismember ( const sigset_t *set, int signo)
diff --git a/libc/signal/sigstmsk.c b/libc/signal/sigstmsk.c
index 6b1876b32..c537d19c3 100644
--- a/libc/signal/sigstmsk.c
+++ b/libc/signal/sigstmsk.c
@@ -17,7 +17,6 @@ not, write to the Free Software Foundation, Inc., 675 Mass Ave,
 Cambridge, MA 02139, USA.  */
 
 #include <errno.h>
-#define __USE_BSD
 #include <signal.h>
 
 /* Set the mask of blocked signals to MASK, returning the old mask.  */
diff --git a/libc/stdio/getline.c b/libc/stdio/getline.c
index 870f6ed4a..8b3331703 100644
--- a/libc/stdio/getline.c
+++ b/libc/stdio/getline.c
@@ -22,6 +22,7 @@
  */
 
 #include <stddef.h>
+#include <sys/types.h>
 #define __USE_GNU
 #include <stdio.h>
 
diff --git a/libc/stdio/perror.c b/libc/stdio/perror.c
index 04cd688d8..33b5e08b0 100644
--- a/libc/stdio/perror.c
+++ b/libc/stdio/perror.c
@@ -1,3 +1,4 @@
+#include <string.h>
 #include <stdio.h>
 #include <errno.h>
 
diff --git a/libc/stdio/scanf.c b/libc/stdio/scanf.c
index 0b9e8007c..c8b487ed1 100644
--- a/libc/stdio/scanf.c
+++ b/libc/stdio/scanf.c
@@ -33,6 +33,7 @@
 
 #include <stdlib.h>
 #include <unistd.h>
+#define __USE_ISOC99
 #include <stdio.h>
 #include <ctype.h>
 #include <string.h>
diff --git a/libc/stdlib/atexit.c b/libc/stdlib/atexit.c
index 1ff8d9004..503e3da1f 100644
--- a/libc/stdlib/atexit.c
+++ b/libc/stdlib/atexit.c
@@ -20,6 +20,7 @@
  *      __stdio_close_all.
  */
 
+#include <unistd.h>
 #include <stdlib.h>
 #include <errno.h>
 
diff --git a/libc/stdlib/getpt.c b/libc/stdlib/getpt.c
index 74f009a95..0ee2d90d6 100644
--- a/libc/stdlib/getpt.c
+++ b/libc/stdlib/getpt.c
@@ -86,4 +86,4 @@ getpt (void)
 #define PTYNAME2 "0123456789abcdef";
 
 #define __getpt __bsd_getpt
-#include <bsd_getpt.c>
+#include "bsd_getpt.c"
diff --git a/libc/stdlib/grantpt.c b/libc/stdlib/grantpt.c
index 63f423b8f..7aa49fcd5 100644
--- a/libc/stdlib/grantpt.c
+++ b/libc/stdlib/grantpt.c
@@ -63,4 +63,4 @@ grantpt (int fd)
 }
 
 #define grantpt __unix_grantpt
-#include <unix_grantpt.c>
+#include "unix_grantpt.c"
diff --git a/libc/stdlib/malloc/malloc.c b/libc/stdlib/malloc/malloc.c
index 95dda3da5..432f893e8 100644
--- a/libc/stdlib/malloc/malloc.c
+++ b/libc/stdlib/malloc/malloc.c
@@ -53,9 +53,9 @@
  *   Converted INIT_BLOCK() and FREE_MEM_DEL_BLOCK() from macros to functions.
  */
 
+#include <features.h>
 #define _POSIX_SOURCE
 #define _XOPEN_SOURCE
-#include <features.h>
 #include <sys/types.h>
 #include <unistd.h>
 #include <limits.h>
diff --git a/libc/stdlib/ptsname.c b/libc/stdlib/ptsname.c
index 2fbc6be49..fd50da047 100644
--- a/libc/stdlib/ptsname.c
+++ b/libc/stdlib/ptsname.c
@@ -145,7 +145,7 @@ int ptsname_r (int fd, char *buf, size_t buflen)
       p[2] = '\0';
     }
 
-  if (_xstat (_STAT_VER, buf, &st) < 0)
+  if (__xstat (_STAT_VER, buf, &st) < 0)
     return errno;
 
   /* Check if the name we're about to return really corresponds to a
diff --git a/libc/stdlib/putenv.c b/libc/stdlib/putenv.c
index 5f27e57d7..b5a202bfd 100644
--- a/libc/stdlib/putenv.c
+++ b/libc/stdlib/putenv.c
@@ -9,8 +9,7 @@
 
 #define ADD_NUM 4
 
-int putenv(var)
-const char *var;
+int putenv (char *var)
 {
 	static char **mall_env = 0;
 	static int extras = 0;
diff --git a/libc/stdlib/setenv.c b/libc/stdlib/setenv.c
index 25eb641ba..d304cb4ac 100644
--- a/libc/stdlib/setenv.c
+++ b/libc/stdlib/setenv.c
@@ -122,7 +122,7 @@ do_return:
 }
 
 
-void unsetenv(const char *name)
+int unsetenv (const char *name)
 {
   register char **ep;
   register char **dp;
@@ -139,4 +139,5 @@ void unsetenv(const char *name)
   *dp = NULL;
 
   UNLOCK();
+  return 0;
 }
diff --git a/libc/stdlib/strto_ll.c b/libc/stdlib/strto_ll.c
index c3a5439b3..76a1a95b3 100644
--- a/libc/stdlib/strto_ll.c
+++ b/libc/stdlib/strto_ll.c
@@ -40,6 +40,7 @@
 #endif
 
 #include <stdlib.h>
+#define __USE_GNU
 #include <limits.h>
 #include <ctype.h>
 
diff --git a/libc/stdlib/unix_grantpt.c b/libc/stdlib/unix_grantpt.c
index c8d70ad64..3dce71b6f 100644
--- a/libc/stdlib/unix_grantpt.c
+++ b/libc/stdlib/unix_grantpt.c
@@ -106,7 +106,7 @@ grantpt (int fd)
   if (pts_name (fd, &buf, sizeof (_buf)))
     return -1;
 
-  if (_xstat (_STAT_VER, buf, &st) < 0)
+  if (__xstat (_STAT_VER, buf, &st) < 0)
     goto cleanup;
 
   /* Make sure that we own the device.  */
diff --git a/libc/string/strsignal.c b/libc/string/strsignal.c
index ba2524ffd..e482512f1 100644
--- a/libc/string/strsignal.c
+++ b/libc/string/strsignal.c
@@ -23,12 +23,12 @@
  */
 
 #define WANT_SIGLIST       1
-
-#include <string.h>
+#include <stdlib.h>
 #include <malloc.h>
 #include <signal.h>
-
 #include <limits.h>
+#define __USE_GNU
+#include <string.h>
 
 #if (INT_MAX >> 31)
 /* We're set up for 32 bit ints */
diff --git a/libc/sysdeps/linux/arm/bits/byteswap.h b/libc/sysdeps/linux/arm/bits/byteswap.h
index 6b5115658..7866abe9c 100644
--- a/libc/sysdeps/linux/arm/bits/byteswap.h
+++ b/libc/sysdeps/linux/arm/bits/byteswap.h
@@ -1,21 +1,21 @@
 /* Macros to swap the order of bytes in integer values.
-   Copyright (C) 1997, 1998 Free Software Foundation, Inc.
+   Copyright (C) 1997, 1998, 2000, 2001 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.
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 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.
+   Lesser 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.  */
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
 
 #if !defined _BYTESWAP_H && !defined _NETINET_IN_H
 # error "Never use <bits/byteswap.h> directly; include <byteswap.h> instead."
@@ -53,12 +53,27 @@ __bswap_32 (unsigned int __bsx)
 
 #if defined __GNUC__ && __GNUC__ >= 2
 /* Swap bytes in 64 bit value.  */
+# define __bswap_constant_64(x) \
+     ((((x) & 0xff00000000000000ull) >> 56)				      \
+      | (((x) & 0x00ff000000000000ull) >> 40)				      \
+      | (((x) & 0x0000ff0000000000ull) >> 24)				      \
+      | (((x) & 0x000000ff00000000ull) >> 8)				      \
+      | (((x) & 0x00000000ff000000ull) << 8)				      \
+      | (((x) & 0x0000000000ff0000ull) << 24)				      \
+      | (((x) & 0x000000000000ff00ull) << 40)				      \
+      | (((x) & 0x00000000000000ffull) << 56))
+
 # define __bswap_64(x) \
      (__extension__							      \
-      ({ union { unsigned long long int __ll;				      \
-		 unsigned long int __l[2]; } __v, __r;			      \
-	 __v.__ll = (x);						      \
-	 __r.__l[0] = __bswap_32 (__v.__l[1]);				      \
-	 __r.__l[1] = __bswap_32 (__v.__l[0]);				      \
+      ({ union { __extension__ unsigned long long int __ll;		      \
+		 unsigned int __l[2]; } __w, __r;			      \
+         if (__builtin_constant_p (x))					      \
+	   __r.__ll = __bswap_constant_64 (x);				      \
+	 else								      \
+	   {								      \
+	     __w.__ll = (x);						      \
+	     __r.__l[0] = __bswap_32 (__w.__l[1]);			      \
+	     __r.__l[1] = __bswap_32 (__w.__l[0]);			      \
+	   }								      \
 	 __r.__ll; }))
 #endif
diff --git a/libc/sysdeps/linux/arm/bits/confname.h b/libc/sysdeps/linux/arm/bits/confname.h
index a649e52f2..ba8868af4 100644
--- a/libc/sysdeps/linux/arm/bits/confname.h
+++ b/libc/sysdeps/linux/arm/bits/confname.h
@@ -1,21 +1,21 @@
 /* `sysconf', `pathconf', and `confstr' NAME values.  Generic version.
-   Copyright (C) 1993, 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
+   Copyright (C) 1993, 1995-1998, 2000, 2001 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.
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 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.
+   Lesser 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.  */
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
 
 #ifndef _UNISTD_H
 # error "Never use <bits/confname.h> directly; include <unistd.h> instead."
@@ -50,8 +50,20 @@ enum
 #define	_PC_PRIO_IO			_PC_PRIO_IO
     _PC_SOCK_MAXBUF,
 #define	_PC_SOCK_MAXBUF			_PC_SOCK_MAXBUF
-    _PC_FILESIZEBITS
+    _PC_FILESIZEBITS,
 #define _PC_FILESIZEBITS		_PC_FILESIZEBITS
+    _PC_REC_INCR_XFER_SIZE,
+#define _PC_REC_INCR_XFER_SIZE		_PC_REC_INCR_XFER_SIZE
+    _PC_REC_MAX_XFER_SIZE,
+#define _PC_REC_MAX_XFER_SIZE		_PC_REC_MAX_XFER_SIZE
+    _PC_REC_MIN_XFER_SIZE,
+#define _PC_REC_MIN_XFER_SIZE		_PC_REC_MIN_XFER_SIZE
+    _PC_REC_XFER_ALIGN,
+#define _PC_REC_XFER_ALIGN		_PC_REC_XFER_ALIGN
+    _PC_ALLOC_SIZE_MIN,
+#define _PC_ALLOC_SIZE_MIN		_PC_ALLOC_SIZE_MIN
+    _PC_SYMLINK_MAX
+#define _PC_SYMLINK_MAX			_PC_SYMLINK_MAX
   };
 
 /* Values for the argument to `sysconf'.  */
@@ -185,6 +197,8 @@ enum
 #define	_SC_SELECT			_SC_SELECT
     _SC_UIO_MAXIOV,
 #define	_SC_UIO_MAXIOV			_SC_UIO_MAXIOV
+    _SC_IOV_MAX = _SC_UIO_MAXIOV,
+#define _SC_IOV_MAX			_SC_IOV_MAX
     _SC_PII_INTERNET_STREAM,
 #define	_SC_PII_INTERNET_STREAM		_SC_PII_INTERNET_STREAM
     _SC_PII_INTERNET_DGRAM,
@@ -338,8 +352,114 @@ enum
     _SC_XOPEN_REALTIME_THREADS,
 #define _SC_XOPEN_REALTIME_THREADS	_SC_XOPEN_REALTIME_THREADS
 
-	/* MUST BE LAST VALUE!!! */
-	_UCLIBC_SYSCONF_NUM_VALID_ARGS
+    _SC_ADVISORY_INFO,
+#define _SC_ADVISORY_INFO		_SC_ADVISORY_INFO
+    _SC_BARRIERS,
+#define _SC_BARRIERS			_SC_BARRIERS
+    _SC_BASE,
+#define _SC_BASE			_SC_BASE
+    _SC_C_LANG_SUPPORT,
+#define _SC_C_LANG_SUPPORT		_SC_C_LANG_SUPPORT
+    _SC_C_LANG_SUPPORT_R,
+#define _SC_C_LANG_SUPPORT_R		_SC_C_LANG_SUPPORT_R
+    _SC_CLOCK_SELECTION,
+#define _SC_CLOCK_SELECTION		_SC_CLOCK_SELECTION
+    _SC_CPUTIME,
+#define _SC_CPUTIME			_SC_CPUTIME
+    _SC_THREAD_CPUTIME,
+#define _SC_THREAD_CPUTIME		_SC_THREAD_CPUTIME
+    _SC_DEVICE_IO,
+#define _SC_DEVICE_IO			_SC_DEVICE_IO
+    _SC_DEVICE_SPECIFIC,
+#define _SC_DEVICE_SPECIFIC		_SC_DEVICE_SPECIFIC
+    _SC_DEVICE_SPECIFIC_R,
+#define _SC_DEVICE_SPECIFIC_R		_SC_DEVICE_SPECIFIC_R
+    _SC_FD_MGMT,
+#define _SC_FD_MGMT			_SC_FD_MGMT
+    _SC_FIFO,
+#define _SC_FIFO			_SC_FIFO
+    _SC_PIPE,
+#define _SC_PIPE			_SC_PIPE
+    _SC_FILE_ATTRIBUTES,
+#define _SC_FILE_ATTRIBUTES		_SC_FILE_ATTRIBUTES
+    _SC_FILE_LOCKING,
+#define _SC_FILE_LOCKING		_SC_FILE_LOCKING
+    _SC_FILE_SYSTEM,
+#define _SC_FILE_SYSTEM			_SC_FILE_SYSTEM
+    _SC_MONOTONIC_CLOCK,
+#define _SC_MONOTONIC_CLOCK		_SC_MONOTONIC_CLOCK
+    _SC_MULTI_PROCESS,
+#define _SC_MULTI_PROCESS		_SC_MULTI_PROCESS
+    _SC_SINGLE_PROCESS,
+#define _SC_SINGLE_PROCESS		_SC_SINGLE_PROCESS
+    _SC_NETWORKING,
+#define _SC_NETWORKING			_SC_NETWORKING
+    _SC_READER_WRITER_LOCKS,
+#define _SC_READER_WRITER_LOCKS		_SC_READER_WRITER_LOCKS
+    _SC_SPIN_LOCKS,
+#define _SC_SPIN_LOCKS			_SC_SPIN_LOCKS
+    _SC_REGEXP,
+#define _SC_REGEXP			_SC_REGEXP
+    _SC_REGEX_VERSION,
+#define _SC_REGEX_VERSION		_SC_REGEX_VERSION
+    _SC_SHELL,
+#define _SC_SHELL			_SC_SHELL
+    _SC_SIGNALS,
+#define _SC_SIGNALS			_SC_SIGNALS
+    _SC_SPAWN,
+#define _SC_SPAWN			_SC_SPAWN
+    _SC_SPORADIC_SERVER,
+#define _SC_SPORADIC_SERVER		_SC_SPORADIC_SERVER
+    _SC_THREAD_SPORADIC_SERVER,
+#define _SC_THREAD_SPORADIC_SERVER	_SC_THREAD_SPORADIC_SERVER
+    _SC_SYSTEM_DATABASE,
+#define _SC_SYSTEM_DATABASE		_SC_SYSTEM_DATABASE
+    _SC_SYSTEM_DATABASE_R,
+#define _SC_SYSTEM_DATABASE_R		_SC_SYSTEM_DATABASE_R
+    _SC_TIMEOUTS,
+#define _SC_TIMEOUTS			_SC_TIMEOUTS
+    _SC_TYPED_MEMORY_OBJECTS,
+#define _SC_TYPED_MEMORY_OBJECTS	_SC_TYPED_MEMORY_OBJECTS
+    _SC_USER_GROUPS,
+#define _SC_USER_GROUPS			_SC_USER_GROUPS
+    _SC_USER_GROUPS_R,
+#define _SC_USER_GROUPS_R		_SC_USER_GROUPS_R
+    _SC_2_PBS,
+#define _SC_2_PBS			_SC_2_PBS
+    _SC_2_PBS_ACCOUNTING,
+#define _SC_2_PBS_ACCOUNTING		_SC_2_PBS_ACCOUNTING
+    _SC_2_PBS_LOCATE,
+#define _SC_2_PBS_LOCATE		_SC_2_PBS_LOCATE
+    _SC_2_PBS_MESSAGE,
+#define _SC_2_PBS_MESSAGE		_SC_2_PBS_MESSAGE
+    _SC_2_PBS_TRACK,
+#define _SC_2_PBS_TRACK			_SC_2_PBS_TRACK
+    _SC_SYMLOOP_MAX,
+#define _SC_SYMLOOP_MAX			_SC_SYMLOOP_MAX
+    _SC_STREAMS,
+#define _SC_STREAMS			_SC_STREAMS
+    _SC_2_PBS_CHECKPOINT,
+#define _SC_2_PBS_CHECKPOINT		_SC_2_PBS_CHECKPOINT
+
+    _SC_V6_ILP32_OFF32,
+#define _SC_V6_ILP32_OFF32		_SC_V6_ILP32_OFF32
+    _SC_V6_ILP32_OFFBIG,
+#define _SC_V6_ILP32_OFFBIG		_SC_V6_ILP32_OFFBIG
+    _SC_V6_LP64_OFF64,
+#define _SC_V6_LP64_OFF64		_SC_V6_LP64_OFF64
+    _SC_V6_LPBIG_OFFBIG,
+#define _SC_V6_LPBIG_OFFBIG		_SC_V6_LPBIG_OFFBIG
+
+    _SC_HOST_NAME_MAX,
+#define _SC_HOST_NAME_MAX		_SC_HOST_NAME_MAX
+    _SC_TRACE,
+#define _SC_TRACE			_SC_TRACE
+    _SC_TRACE_EVENT_FILTER,
+#define _SC_TRACE_EVENT_FILTER		_SC_TRACE_EVENT_FILTER
+    _SC_TRACE_INHERIT,
+#define _SC_TRACE_INHERIT		_SC_TRACE_INHERIT
+    _SC_TRACE_LOG
+#define _SC_TRACE_LOG			_SC_TRACE_LOG
   };
 
 #if (defined __USE_POSIX2 || defined __USE_UNIX98 \
@@ -348,64 +468,99 @@ enum
 /* Values for the NAME argument to `confstr'.  */
 enum
   {
-    _CS_PATH			/* The default search path.  */
+    _CS_PATH,			/* The default search path.  */
 #define _CS_PATH		_CS_PATH
 
-#if (defined __USE_FILE_OFFSET64 || defined __USE_LARGEFILE64 \
+# if (defined __USE_FILE_OFFSET64 || defined __USE_LARGEFILE64 \
      || defined __USE_LARGEFILE)
-    ,
     _CS_LFS_CFLAGS = 1000,
-# define _CS_LFS_CFLAGS		_CS_LFS_CFLAGS
+#  define _CS_LFS_CFLAGS		_CS_LFS_CFLAGS
     _CS_LFS_LDFLAGS,
-# define _CS_LFS_LDFLAGS	_CS_LFS_LDFLAGS
+#  define _CS_LFS_LDFLAGS	_CS_LFS_LDFLAGS
     _CS_LFS_LIBS,
-# define _CS_LFS_LIBS		_CS_LFS_LIBS
+#  define _CS_LFS_LIBS		_CS_LFS_LIBS
     _CS_LFS_LINTFLAGS,
-# define _CS_LFS_LINTFLAGS	_CS_LFS_LINTFLAGS
+#  define _CS_LFS_LINTFLAGS	_CS_LFS_LINTFLAGS
     _CS_LFS64_CFLAGS,
-# define _CS_LFS64_CFLAGS	_CS_LFS64_CFLAGS
+#  define _CS_LFS64_CFLAGS	_CS_LFS64_CFLAGS
     _CS_LFS64_LDFLAGS,
-# define _CS_LFS64_LDFLAGS	_CS_LFS64_LDFLAGS
+#  define _CS_LFS64_LDFLAGS	_CS_LFS64_LDFLAGS
     _CS_LFS64_LIBS,
-# define _CS_LFS64_LIBS		_CS_LFS64_LIBS
-    _CS_LFS64_LINTFLAGS
-# define _CS_LFS64_LINTFLAGS	_CS_LFS64_LINTFLAGS
-#endif
+#  define _CS_LFS64_LIBS		_CS_LFS64_LIBS
+    _CS_LFS64_LINTFLAGS,
+#  define _CS_LFS64_LINTFLAGS	_CS_LFS64_LINTFLAGS
+# endif
 
-#ifdef __USE_UNIX98
-    ,
+# ifdef __USE_UNIX98
     _CS_XBS5_ILP32_OFF32_CFLAGS = 1100,
-# define _CS_XBS5_ILP32_OFF32_CFLAGS _CS_XBS5_ILP32_OFF32_CFLAGS
+#  define _CS_XBS5_ILP32_OFF32_CFLAGS _CS_XBS5_ILP32_OFF32_CFLAGS
     _CS_XBS5_ILP32_OFF32_LDFLAGS,
-# define _CS_XBS5_ILP32_OFF32_LDFLAGS _CS_XBS5_ILP32_OFF32_LDFLAGS
+#  define _CS_XBS5_ILP32_OFF32_LDFLAGS _CS_XBS5_ILP32_OFF32_LDFLAGS
     _CS_XBS5_ILP32_OFF32_LIBS,
-# define _CS_XBS5_ILP32_OFF32_LIBS _CS_XBS5_ILP32_OFF32_LIBS
+#  define _CS_XBS5_ILP32_OFF32_LIBS _CS_XBS5_ILP32_OFF32_LIBS
     _CS_XBS5_ILP32_OFF32_LINTFLAGS,
-# define _CS_XBS5_ILP32_OFF32_LINTFLAGS _CS_XBS5_ILP32_OFF32_LINTFLAGS
+#  define _CS_XBS5_ILP32_OFF32_LINTFLAGS _CS_XBS5_ILP32_OFF32_LINTFLAGS
     _CS_XBS5_ILP32_OFFBIG_CFLAGS,
-# define _CS_XBS5_ILP32_OFFBIG_CFLAGS _CS_XBS5_ILP32_OFFBIG_CFLAGS
+#  define _CS_XBS5_ILP32_OFFBIG_CFLAGS _CS_XBS5_ILP32_OFFBIG_CFLAGS
     _CS_XBS5_ILP32_OFFBIG_LDFLAGS,
-# define _CS_XBS5_ILP32_OFFBIG_LDFLAGS _CS_XBS5_ILP32_OFFBIG_LDFLAGS
+#  define _CS_XBS5_ILP32_OFFBIG_LDFLAGS _CS_XBS5_ILP32_OFFBIG_LDFLAGS
     _CS_XBS5_ILP32_OFFBIG_LIBS,
-# define _CS_XBS5_ILP32_OFFBIG_LIBS _CS_XBS5_ILP32_OFFBIG_LIBS
+#  define _CS_XBS5_ILP32_OFFBIG_LIBS _CS_XBS5_ILP32_OFFBIG_LIBS
     _CS_XBS5_ILP32_OFFBIG_LINTFLAGS,
-# define _CS_XBS5_ILP32_OFFBIG_LINTFLAGS _CS_XBS5_ILP32_OFFBIG_LINTFLAGS
+#  define _CS_XBS5_ILP32_OFFBIG_LINTFLAGS _CS_XBS5_ILP32_OFFBIG_LINTFLAGS
     _CS_XBS5_LP64_OFF64_CFLAGS,
-# define _CS_XBS5_LP64_OFF64_CFLAGS _CS_XBS5_LP64_OFF64_CFLAGS
+#  define _CS_XBS5_LP64_OFF64_CFLAGS _CS_XBS5_LP64_OFF64_CFLAGS
     _CS_XBS5_LP64_OFF64_LDFLAGS,
-# define _CS_XBS5_LP64_OFF64_LDFLAGS _CS_XBS5_LP64_OFF64_LDFLAGS
+#  define _CS_XBS5_LP64_OFF64_LDFLAGS _CS_XBS5_LP64_OFF64_LDFLAGS
     _CS_XBS5_LP64_OFF64_LIBS,
-# define _CS_XBS5_LP64_OFF64_LIBS _CS_XBS5_LP64_OFF64_LIBS
+#  define _CS_XBS5_LP64_OFF64_LIBS _CS_XBS5_LP64_OFF64_LIBS
     _CS_XBS5_LP64_OFF64_LINTFLAGS,
-# define _CS_XBS5_LP64_OFF64_LINTFLAGS _CS_XBS5_LP64_OFF64_LINTFLAGS
+#  define _CS_XBS5_LP64_OFF64_LINTFLAGS _CS_XBS5_LP64_OFF64_LINTFLAGS
     _CS_XBS5_LPBIG_OFFBIG_CFLAGS,
-# define _CS_XBS5_LPBIG_OFFBIG_CFLAGS _CS_XBS5_LPBIG_OFFBIG_CFLAGS
+#  define _CS_XBS5_LPBIG_OFFBIG_CFLAGS _CS_XBS5_LPBIG_OFFBIG_CFLAGS
     _CS_XBS5_LPBIG_OFFBIG_LDFLAGS,
-# define _CS_XBS5_LPBIG_OFFBIG_LDFLAGS _CS_XBS5_LPBIG_OFFBIG_LDFLAGS
+#  define _CS_XBS5_LPBIG_OFFBIG_LDFLAGS _CS_XBS5_LPBIG_OFFBIG_LDFLAGS
     _CS_XBS5_LPBIG_OFFBIG_LIBS,
-# define _CS_XBS5_LPBIG_OFFBIG_LIBS _CS_XBS5_LPBIG_OFFBIG_LIBS
-    _CS_XBS5_LPBIG_OFFBIG_LINTFLAGS
-# define _CS_XBS5_LPBIG_OFFBIG_LINTFLAGS _CS_XBS5_LPBIG_OFFBIG_LINTFLAGS
-#endif
+#  define _CS_XBS5_LPBIG_OFFBIG_LIBS _CS_XBS5_LPBIG_OFFBIG_LIBS
+    _CS_XBS5_LPBIG_OFFBIG_LINTFLAGS,
+#  define _CS_XBS5_LPBIG_OFFBIG_LINTFLAGS _CS_XBS5_LPBIG_OFFBIG_LINTFLAGS
+# endif
+# ifdef __USE_XOPEN2K
+    _CS_POSIX_V6_ILP32_OFF32_CFLAGS,
+#  define _CS_POSIX_V6_ILP32_OFF32_CFLAGS _CS_POSIX_V6_ILP32_OFF32_CFLAGS
+    _CS_POSIX_V6_ILP32_OFF32_LDFLAGS,
+#  define _CS_POSIX_V6_ILP32_OFF32_LDFLAGS _CS_POSIX_V6_ILP32_OFF32_LDFLAGS
+    _CS_POSIX_V6_ILP32_OFF32_LIBS,
+#  define _CS_POSIX_V6_ILP32_OFF32_LIBS _CS_POSIX_V6_ILP32_OFF32_LIBS
+    _CS_POSIX_V6_ILP32_OFF32_LINTFLAGS,
+#  define _CS_POSIX_V6_ILP32_OFF32_LINTFLAGS _CS_POSIX_V6_ILP32_OFF32_LINTFLAGS
+    _CS_POSIX_V6_ILP32_OFFBIG_CFLAGS,
+#  define _CS_POSIX_V6_ILP32_OFFBIG_CFLAGS _CS_POSIX_V6_ILP32_OFFBIG_CFLAGS
+    _CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS,
+#  define _CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS _CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS
+    _CS_POSIX_V6_ILP32_OFFBIG_LIBS,
+#  define _CS_POSIX_V6_ILP32_OFFBIG_LIBS _CS_POSIX_V6_ILP32_OFFBIG_LIBS
+    _CS_POSIX_V6_ILP32_OFFBIG_LINTFLAGS,
+#  define _CS_POSIX_V6_ILP32_OFFBIG_LINTFLAGS _CS_POSIX_V6_ILP32_OFFBIG_LINTFLAGS
+    _CS_POSIX_V6_LP64_OFF64_CFLAGS,
+#  define _CS_POSIX_V6_LP64_OFF64_CFLAGS _CS_POSIX_V6_LP64_OFF64_CFLAGS
+    _CS_POSIX_V6_LP64_OFF64_LDFLAGS,
+#  define _CS_POSIX_V6_LP64_OFF64_LDFLAGS _CS_POSIX_V6_LP64_OFF64_LDFLAGS
+    _CS_POSIX_V6_LP64_OFF64_LIBS,
+#  define _CS_POSIX_V6_LP64_OFF64_LIBS _CS_POSIX_V6_LP64_OFF64_LIBS
+    _CS_POSIX_V6_LP64_OFF64_LINTFLAGS,
+#  define _CS_POSIX_V6_LP64_OFF64_LINTFLAGS _CS_POSIX_V6_LP64_OFF64_LINTFLAGS
+    _CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS,
+#  define _CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS _CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS
+    _CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS,
+#  define _CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS _CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS
+    _CS_POSIX_V6_LPBIG_OFFBIG_LIBS,
+#  define _CS_POSIX_V6_LPBIG_OFFBIG_LIBS _CS_POSIX_V6_LPBIG_OFFBIG_LIBS
+    _CS_POSIX_V6_LPBIG_OFFBIG_LINTFLAGS,
+#  define _CS_POSIX_V6_LPBIG_OFFBIG_LINTFLAGS _CS_POSIX_V6_LPBIG_OFFBIG_LINTFLAGS
+# endif
+
+    _CS_V6_WIDTH_RESTRICTED_ENVS
+# define _CS_V6_WIDTH_RESTRICTED_ENVS	_CS_V6_WIDTH_RESTRICTED_ENVS
   };
 #endif
diff --git a/libc/sysdeps/linux/arm/bits/dirent.h b/libc/sysdeps/linux/arm/bits/dirent.h
index 1754c7cbe..01fbf54dd 100644
--- a/libc/sysdeps/linux/arm/bits/dirent.h
+++ b/libc/sysdeps/linux/arm/bits/dirent.h
@@ -2,29 +2,19 @@
    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.
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 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.  */
-
-/*
- * June 25, 2001
- *
- * Removed d_type support for dirent and undefined _DIRENT_HAVE_D_TYPE;
- * i.e. match the kernel structs and avoid any translation for now.
- * Note: glibc fakes d_type for the dirent case.
- * Note: dirent64 still has the d_type field.
- */
+   Lesser General Public License for more details.
 
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
 
 #ifndef _DIRENT_H
 # error "Never use <bits/dirent.h> directly; include <dirent.h> instead."
@@ -40,6 +30,7 @@ struct dirent
     __off64_t d_off;
 #endif
     unsigned short int d_reclen;
+    //unsigned char d_type;
     char d_name[256];		/* We must not include limits.h! */
   };
 
@@ -49,7 +40,7 @@ struct dirent64
     __ino64_t d_ino;
     __off64_t d_off;
     unsigned short int d_reclen;
-    unsigned char d_type;
+    //unsigned char d_type;
     char d_name[256];		/* We must not include limits.h! */
   };
 #endif
@@ -59,4 +50,4 @@ struct dirent64
 #undef  _DIRENT_HAVE_D_NAMLEN
 #define _DIRENT_HAVE_D_RECLEN
 #define _DIRENT_HAVE_D_OFF
-#undef  _DIRENT_HAVE_D_TYPE
+#define _DIRENT_HAVE_D_TYPE
diff --git a/libc/sysdeps/linux/arm/bits/dlfcn.h b/libc/sysdeps/linux/arm/bits/dlfcn.h
index f724d0fdf..2525fa3d9 100644
--- a/libc/sysdeps/linux/arm/bits/dlfcn.h
+++ b/libc/sysdeps/linux/arm/bits/dlfcn.h
@@ -3,19 +3,19 @@
    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.
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 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.
+   Lesser 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.  */
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
 
 #ifndef _DLFCN_H
 # error "Never use <bits/dlfcn.h> directly; include <dlfcn.h> instead."
@@ -55,7 +55,5 @@
   (_dl_mcount_wrapper_check (fctp), (*(fctp)) args)
 
 /* This function calls the profiling functions.  */
-__BEGIN_DECLS
 extern void _dl_mcount_wrapper_check (void *__selfpc) __THROW;
-__END_DECLS
 #endif
diff --git a/libc/sysdeps/linux/arm/bits/errno.h b/libc/sysdeps/linux/arm/bits/errno.h
index ba3049599..ac59d4c9d 100644
--- a/libc/sysdeps/linux/arm/bits/errno.h
+++ b/libc/sysdeps/linux/arm/bits/errno.h
@@ -3,19 +3,19 @@
    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.
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 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.
+   Lesser 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.  */
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
 
 #ifdef _ERRNO_H
 
@@ -32,12 +32,11 @@
 # define ECANCELED	125
 
 # ifndef __ASSEMBLER__
-   __BEGIN_DECLS
 /* We now need a declaration of the `errno' variable.  */
 extern int errno;
 
 /* Function to get address of global `errno' variable.  */
-extern int *__errno_location (void) __attribute__ ((__const__));
+extern int *__errno_location (void) __THROW __attribute__ ((__const__));
 
 #  if defined _LIBC
 /* We wouldn't need a special macro anymore but it is history.  */
@@ -48,7 +47,6 @@ extern int *__errno_location (void) __attribute__ ((__const__));
 /* When using threads, errno is a per-thread value.  */
 #   define errno (*__errno_location ())
 #  endif
-   __END_DECLS
 # endif /* !__ASSEMBLER__ */
 #endif /* _ERRNO_H */
 
diff --git a/libc/sysdeps/linux/arm/bits/fcntl.h b/libc/sysdeps/linux/arm/bits/fcntl.h
index 0c94c6b9a..152858d9f 100644
--- a/libc/sysdeps/linux/arm/bits/fcntl.h
+++ b/libc/sysdeps/linux/arm/bits/fcntl.h
@@ -1,21 +1,21 @@
 /* O_*, F_*, FD_* bit values for Linux.
-   Copyright (C) 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
+   Copyright (C) 1995-1998, 2000 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.
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 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.
+   Lesser 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.  */
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
 
 #ifndef	_FCNTL_H
 # error "Never use <bits/fcntl.h> directly; include <fcntl.h> instead."
@@ -42,21 +42,21 @@
 #define O_ASYNC		020000
 
 #ifdef __USE_GNU
-# define O_DIRECTORY	040000	/* Must be a directory.  */
-# define O_NOFOLLOW	0100000	/* Do not follow links.  */
+# define O_DIRECTORY	040000	/* Must be a directory.	 */
+# define O_NOFOLLOW	0100000	/* Do not follow links.	 */
+# define O_DIRECT	0200000	/* Direct disk access.	*/
 #endif
 
-/* XXX missing */
 #ifdef __USE_LARGEFILE64
-# define O_LARGEFILE	0
+# define O_LARGEFILE	0400000
 #endif
 
 /* For now Linux has synchronisity options for data and read operations.
    We define the symbols here but let them do the same as O_SYNC since
-   this is a superset.  */
+   this is a superset.	*/
 #if defined __USE_POSIX199309 || defined __USE_UNIX98
 # define O_DSYNC	O_SYNC	/* Synchronize data.  */
-# define O_RSYNC	O_SYNC	/* Synchronize read operations.  */
+# define O_RSYNC	O_SYNC	/* Synchronize read operations.	 */
 #endif
 
 /* Values for the second argument to `fcntl'.  */
@@ -65,16 +65,21 @@
 #define F_SETFD		2	/* Set file descriptor flags.  */
 #define F_GETFL		3	/* Get file status flags.  */
 #define F_SETFL		4	/* Set file status flags.  */
-#define F_GETLK		5	/* Get record locking info.  */
-#define F_SETLK		6	/* Set record locking info (non-blocking).  */
-#define F_SETLKW	7	/* Set record locking info (blocking).  */
 
-/* XXX missing */
-#define F_GETLK64	5	/* Get record locking info.  */
-#define F_SETLK64	6	/* Set record locking info (non-blocking).  */
-#define F_SETLKW64	7	/* Set record locking info (blocking).  */
+#ifndef __USE_FILE_OFFSET64
+# define F_GETLK	5	/* Get record locking info.  */
+# define F_SETLK	6	/* Set record locking info (non-blocking).  */
+# define F_SETLKW	7	/* Set record locking info (blocking).	*/
+#else
+# define F_GETLK	F_GETLK64  /* Get record locking info.	*/
+# define F_SETLK	F_SETLK64  /* Set record locking info (non-blocking).*/
+# define F_SETLKW	F_SETLKW64 /* Set record locking info (blocking).  */
+#endif
+#define F_GETLK64	12	/* Get record locking info.  */
+#define F_SETLK64	13	/* Set record locking info (non-blocking).  */
+#define F_SETLKW64	14	/* Set record locking info (blocking).	*/
 
-#ifdef __USE_BSD
+#if defined __USE_BSD || defined __USE_XOPEN2K
 # define F_SETOWN	8	/* Get owner of socket (receiver of SIGIO).  */
 # define F_GETOWN	9	/* Set owner of socket (receiver of SIGIO).  */
 #endif
@@ -84,13 +89,19 @@
 # define F_GETSIG	11	/* Get number of signal to be sent.  */
 #endif
 
+#ifdef __USE_GNU
+# define F_SETLEASE	1024	/* Set a lease.	 */
+# define F_GETLEASE	1025	/* Enquire what lease is active.  */
+# define F_NOTIFY	1026	/* Request notfications on a directory.	 */
+#endif
+
 /* For F_[GET|SET]FL.  */
 #define FD_CLOEXEC	1	/* actually anything with low bit set goes */
 
 /* For posix fcntl() and `l_type' field of a `struct flock' for lockf().  */
 #define F_RDLCK		0	/* Read lock.  */
-#define F_WRLCK		1	/* Write lock.  */
-#define F_UNLCK		2	/* Remove lock.  */
+#define F_WRLCK		1	/* Write lock.	*/
+#define F_UNLCK		2	/* Remove lock.	 */
 
 /* for old implementation of bsd flock () */
 #define F_EXLCK		4	/* or 3 */
@@ -105,9 +116,27 @@
 # define LOCK_UN	8	/* remove lock */
 #endif
 
+#ifdef __USE_GNU
+# define LOCK_MAND	32	/* This is a mandatory flock:	*/
+# define LOCK_READ	64	/* ... which allows concurrent read operations.	 */
+# define LOCK_WRITE	128	/* ... which allows concurrent write operations.  */
+# define LOCK_RW	192	/* ... Which allows concurrent read & write operations.	 */
+#endif
+
+#ifdef __USE_GNU
+/* Types of directory notifications that may be requested with F_NOTIFY.  */
+# define DN_ACCESS	0x00000001	/* File accessed.  */
+# define DN_MODIFY	0x00000002	/* File modified.  */
+# define DN_CREATE	0x00000004	/* File created.  */
+# define DN_DELETE	0x00000008	/* File removed.  */
+# define DN_RENAME	0x00000010	/* File renamed.  */
+# define DN_ATTRIB	0x00000020	/* File changed attibutes.  */
+# define DN_MULTISHOT	0x80000000	/* Don't remove notifier.  */
+#endif
+
 struct flock
   {
-    short int l_type;	/* Type of lock: F_RDLCK, F_WRLCK, or F_UNLCK.  */
+    short int l_type;	/* Type of lock: F_RDLCK, F_WRLCK, or F_UNLCK.	*/
     short int l_whence;	/* Where `l_start' is relative to (like `lseek').  */
 #ifndef __USE_FILE_OFFSET64
     __off_t l_start;	/* Offset where the lock begins.  */
@@ -122,7 +151,7 @@ struct flock
 #ifdef __USE_LARGEFILE64
 struct flock64
   {
-    short int l_type;	/* Type of lock: F_RDLCK, F_WRLCK, or F_UNLCK.  */
+    short int l_type;	/* Type of lock: F_RDLCK, F_WRLCK, or F_UNLCK.	*/
     short int l_whence;	/* Where `l_start' is relative to (like `lseek').  */
     __off64_t l_start;	/* Offset where the lock begins.  */
     __off64_t l_len;	/* Size of the locked area; zero means until EOF.  */
@@ -139,3 +168,13 @@ struct flock64
 # define FNONBLOCK	O_NONBLOCK
 # define FNDELAY	O_NDELAY
 #endif /* Use BSD.  */
+
+/* Advise to `posix_fadvise'.  */
+#ifdef __USE_XOPEN2K
+# define POSIX_FADV_NORMAL	0 /* No further special treatment.  */
+# define POSIX_FADV_RANDOM	1 /* Expect random page references.  */
+# define POSIX_FADV_SEQUENTIAL	2 /* Expect sequential page references.	 */
+# define POSIX_FADV_WILLNEED	3 /* Will need these pages.  */
+# define POSIX_FADV_DONTNEED	4 /* Don't need these pages.  */
+# define POSIX_FADV_NOREUSE	5 /* Data will be accessed once.  */
+#endif
diff --git a/libc/sysdeps/linux/arm/bits/huge_val.h b/libc/sysdeps/linux/arm/bits/huge_val.h
index 841b4b0d6..625cdc5c3 100644
--- a/libc/sysdeps/linux/arm/bits/huge_val.h
+++ b/libc/sysdeps/linux/arm/bits/huge_val.h
@@ -5,19 +5,19 @@
    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.
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 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.
+   Lesser 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.  */
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
 
 #ifndef _MATH_H
 # error "Never use <bits/huge_val.h> directly; include <math.h> instead."
diff --git a/libc/sysdeps/linux/arm/bits/in.h b/libc/sysdeps/linux/arm/bits/in.h
index 38e2a2e00..e6cf57574 100644
--- a/libc/sysdeps/linux/arm/bits/in.h
+++ b/libc/sysdeps/linux/arm/bits/in.h
@@ -1,20 +1,20 @@
-/* Copyright (C) 1991,92,93,94,95,96,97,98,99 Free Software Foundation, Inc.
+/* Copyright (C) 1991-1999, 2000 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.
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 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.
+   Lesser 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.  */
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
 
 /* Linux version.  */
 
@@ -99,7 +99,7 @@ struct in_pktinfo
 #define IPV6_PKTINFO		2
 #define IPV6_HOPOPTS		3
 #define IPV6_DSTOPTS		4
-#define IPV6_RXSRCRT		5
+#define IPV6_RTHDR		5
 #define IPV6_PKTOPTIONS		6
 #define IPV6_CHECKSUM		7
 #define IPV6_HOPLIMIT		8
@@ -109,14 +109,21 @@ struct in_pktinfo
 #define IPV6_MULTICAST_IF	17
 #define IPV6_MULTICAST_HOPS	18
 #define IPV6_MULTICAST_LOOP	19
-#define IPV6_ADD_MEMBERSHIP	20
-#define IPV6_DROP_MEMBERSHIP	21
+#define IPV6_JOIN_GROUP		20
+#define IPV6_LEAVE_GROUP	21
 #define IPV6_ROUTER_ALERT	22
+#define IPV6_MTU_DISCOVER	23
+#define IPV6_MTU		24
+#define IPV6_RECVERR		25
 
 #define SCM_SRCRT		IPV6_RXSRCRT
 
-#define IPV6_RXHOPOPTS		IPV6_HOPOPTS	/* obsolete name */
-#define IPV6_RXDSTOPTS		IPV6_DSTOPTS	/* obsolete name */
+/* Obsolete synonyms for the above.  */
+#define IPV6_RXHOPOPTS		IPV6_HOPOPTS
+#define IPV6_RXDSTOPTS		IPV6_DSTOPTS
+#define IPV6_ADD_MEMBERSHIP	IPV6_JOIN_GROUP
+#define IPV6_DROP_MEMBERSHIP	IPV6_LEAVE_GROUP
+
 
 /* IPV6_MTU_DISCOVER values.  */
 #define IPV6_PMTUDISC_DONT	0	/* Never send DF frames.  */
@@ -126,3 +133,9 @@ struct in_pktinfo
 /* Socket level values for IPv6.  */
 #define SOL_IPV6        41
 #define SOL_ICMPV6      58
+
+/* Routing header options for IPv6.  */
+#define IPV6_RTHDR_LOOSE	0	/* Hop doesn't need to be neighbour. */
+#define IPV6_RTHDR_STRICT	1	/* Hop must be a neighbour.  */
+
+#define IPV6_RTHDR_TYPE_0	0	/* IPv6 Routing header type 0.  */
diff --git a/libc/sysdeps/linux/arm/bits/ioctl-types.h b/libc/sysdeps/linux/arm/bits/ioctl-types.h
index 59c79df81..e856a04b4 100644
--- a/libc/sysdeps/linux/arm/bits/ioctl-types.h
+++ b/libc/sysdeps/linux/arm/bits/ioctl-types.h
@@ -1,21 +1,21 @@
 /* Structure types for pre-termios terminal ioctls.  Linux version.
-   Copyright (C) 1996, 1997, 1999 Free Software Foundation, Inc.
+   Copyright (C) 1996, 1997, 1999, 2001 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.
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
 
    The GNU C Library is distributed in the hope