A number of cleanups.  Now compiles with libc5, glibc, and uClibc.  Fix a few
shadowed variables.  Move (almost) all syscalls to libbb/syscalls.c, so I can
handle them sanely and all at once.
 -Erik
diff --git a/adjtimex.c b/adjtimex.c
index 02b6e89..e3c160d 100644
--- a/adjtimex.c
+++ b/adjtimex.c
@@ -44,7 +44,14 @@
 #include <sys/types.h>
 #include <stdlib.h>
 #include <unistd.h>
+
+#if __GNU_LIBRARY__ < 5
 #include <sys/timex.h>
+extern int adjtimex(struct timex *buf);
+#else
+#include <sys/timex.h>
+#endif
+
 #ifdef BB_VER
 #include "busybox.h"
 #endif
@@ -163,7 +170,7 @@
 			"    return value: %d (%s)\n",
 		txc.constant,
 		txc.precision, txc.tolerance, txc.tick,
-		txc.time.tv_sec, txc.time.tv_usec, ret, descript);
+		(long)txc.time.tv_sec, (long)txc.time.tv_usec, ret, descript);
 	}
 	return (ret<0);
 }
diff --git a/archival/dpkg.c b/archival/dpkg.c
index d650817..dc0b23e 100644
--- a/archival/dpkg.c
+++ b/archival/dpkg.c
@@ -12,14 +12,6 @@
 #include "busybox.h"
 
 
-/* Stupid libc doesn't have a reliable way for use to know 
- * that libc5 is being used.   Assume this is good enough */ 
-#if !defined __GLIBC__ && !defined __UCLIBC__
-#error It looks like you are using libc5, which does not support
-#error tfind().  tfind() is used by busybox dpkg.
-#error Please disable BB_DPKG.  Sorry.
-#endif	
-
 #define DEPENDSMAX	64	/* maximum number of depends we can handle */
 
 /* Should we do full dependency checking? */
@@ -591,6 +583,7 @@
 	char *adminscripts[] = { "/prerm", "/postrm", "/preinst", "/postinst",
 			"/conffiles", "/md5sums", "/shlibs", "/templates" };
 	char buf[1024], buf2[1024];
+	FILE *myfile = stdout;
 
 	DPRINTF("Unpacking %s\n", pkg->package);
 
@@ -622,9 +615,9 @@
 		strcpy(lst_file, infodir);
 		strcat(lst_file, pkg->package);
 		strcat(lst_file, ".list");
-		outfp = freopen(lst_file, "w", stdout);
+		outfp = freopen(lst_file, "w", myfile);
 		deb_extract(dpkg_deb_list, NULL, pkg->file);
-		stdout = freopen(NULL, "w", outfp);
+		myfile = freopen(NULL, "w", outfp);
 
 		printf("done\n");
 		getchar();
diff --git a/coreutils/dd.c b/coreutils/dd.c
index 3f58929..297d0ab 100644
--- a/coreutils/dd.c
+++ b/coreutils/dd.c
@@ -151,8 +151,8 @@
 			out_part++;
 	}
 
-	fprintf(statusfp, "%d+%d records in\n", in_full, in_part);
-	fprintf(statusfp, "%d+%d records out\n", out_full, out_part);
+	fprintf(statusfp, "%ld+%ld records in\n", (long)in_full, (long)in_part);
+	fprintf(statusfp, "%ld+%ld records out\n", (long)out_full, (long)out_part);
 
 	return EXIT_SUCCESS;
 }
diff --git a/coreutils/ls.c b/coreutils/ls.c
index 49470e9..0b89ecc 100644
--- a/coreutils/ls.c
+++ b/coreutils/ls.c
@@ -626,7 +626,7 @@
 				column += 10;
 				break;
 			case LIST_NLINKS:
-				printf("%4d ", dn->dstat.st_nlink);
+				printf("%4ld ", (long)dn->dstat.st_nlink);
 				column += 10;
 				break;
 			case LIST_ID_NAME:
diff --git a/dd.c b/dd.c
index 3f58929..297d0ab 100644
--- a/dd.c
+++ b/dd.c
@@ -151,8 +151,8 @@
 			out_part++;
 	}
 
-	fprintf(statusfp, "%d+%d records in\n", in_full, in_part);
-	fprintf(statusfp, "%d+%d records out\n", out_full, out_part);
+	fprintf(statusfp, "%ld+%ld records in\n", (long)in_full, (long)in_part);
+	fprintf(statusfp, "%ld+%ld records out\n", (long)out_full, (long)out_part);
 
 	return EXIT_SUCCESS;
 }
diff --git a/dmesg.c b/dmesg.c
index 2c85ed3..73de6d1 100644
--- a/dmesg.c
+++ b/dmesg.c
@@ -20,18 +20,13 @@
 #include <getopt.h>
 
 #if __GNU_LIBRARY__ < 5
-#include <sys/syscall.h>
-#include <linux/unistd.h>
-#ifndef __alpha__
-# define __NR_klogctl __NR_syslog
-static inline _syscall3(int, klogctl, int, type, char *, b, int, len);
-#else							/* __alpha__ */
-#define klogctl syslog
-#endif
-
+# ifdef __alpha__
+#   define klogctl syslog
+# endif
 #else
 # include <sys/klog.h>
 #endif
+
 #include "busybox.h"
 
 int dmesg_main(int argc, char **argv)
diff --git a/dpkg.c b/dpkg.c
index d650817..dc0b23e 100644
--- a/dpkg.c
+++ b/dpkg.c
@@ -12,14 +12,6 @@
 #include "busybox.h"
 
 
-/* Stupid libc doesn't have a reliable way for use to know 
- * that libc5 is being used.   Assume this is good enough */ 
-#if !defined __GLIBC__ && !defined __UCLIBC__
-#error It looks like you are using libc5, which does not support
-#error tfind().  tfind() is used by busybox dpkg.
-#error Please disable BB_DPKG.  Sorry.
-#endif	
-
 #define DEPENDSMAX	64	/* maximum number of depends we can handle */
 
 /* Should we do full dependency checking? */
@@ -591,6 +583,7 @@
 	char *adminscripts[] = { "/prerm", "/postrm", "/preinst", "/postinst",
 			"/conffiles", "/md5sums", "/shlibs", "/templates" };
 	char buf[1024], buf2[1024];
+	FILE *myfile = stdout;
 
 	DPRINTF("Unpacking %s\n", pkg->package);
 
@@ -622,9 +615,9 @@
 		strcpy(lst_file, infodir);
 		strcat(lst_file, pkg->package);
 		strcat(lst_file, ".list");
-		outfp = freopen(lst_file, "w", stdout);
+		outfp = freopen(lst_file, "w", myfile);
 		deb_extract(dpkg_deb_list, NULL, pkg->file);
-		stdout = freopen(NULL, "w", outfp);
+		myfile = freopen(NULL, "w", outfp);
 
 		printf("done\n");
 		getchar();
diff --git a/include/libbb.h b/include/libbb.h
index d850bef..d0896ab 100644
--- a/include/libbb.h
+++ b/include/libbb.h
@@ -211,5 +211,6 @@
 };
 
 int ask_confirmation(void);
+int klogctl(int type, char * b, int len);
 
 #endif /* __LIBBB_H__ */
diff --git a/init.c b/init.c
index 570b8a6..bf992b5 100644
--- a/init.c
+++ b/init.c
@@ -115,9 +115,7 @@
 #if defined(__GLIBC__)
 #include <sys/kdaemon.h>
 #else
-#include <sys/syscall.h>
-#include <linux/unistd.h>
-static _syscall2(int, bdflush, int, func, int, data);
+extern int bdflush (int func, long int data);
 #endif							/* __GLIBC__ */
 
 
diff --git a/init/init.c b/init/init.c
index 570b8a6..bf992b5 100644
--- a/init/init.c
+++ b/init/init.c
@@ -115,9 +115,7 @@
 #if defined(__GLIBC__)
 #include <sys/kdaemon.h>
 #else
-#include <sys/syscall.h>
-#include <linux/unistd.h>
-static _syscall2(int, bdflush, int, func, int, data);
+extern int bdflush (int func, long int data);
 #endif							/* __GLIBC__ */
 
 
diff --git a/insmod.c b/insmod.c
index 0a7cb1e..ad1486b 100644
--- a/insmod.c
+++ b/insmod.c
@@ -119,7 +119,7 @@
 #ifndef MODUTILS_MODULE_H
 static const int MODUTILS_MODULE_H = 1;
 
-#ident "$Id: insmod.c,v 1.53 2001/03/22 19:01:16 andersen Exp $"
+#ident "$Id: insmod.c,v 1.54 2001/04/05 03:14:39 andersen Exp $"
 
 /* This file contains the structures used by the 2.0 and 2.1 kernels.
    We do not use the kernel headers directly because we do not wish
@@ -325,7 +325,7 @@
 #ifndef MODUTILS_OBJ_H
 static const int MODUTILS_OBJ_H = 1;
 
-#ident "$Id: insmod.c,v 1.53 2001/03/22 19:01:16 andersen Exp $"
+#ident "$Id: insmod.c,v 1.54 2001/04/05 03:14:39 andersen Exp $"
 
 /* The relocatable object is manipulated using elfin types.  */
 
@@ -1210,18 +1210,18 @@
 
 #if defined(BB_USE_GOT_ENTRIES)
 	if (got_offset) {
-		struct obj_section* relsec = obj_find_section(f, ".got");
+		struct obj_section* myrelsec = obj_find_section(f, ".got");
 
-		if (relsec) {
-			obj_extend_section(relsec, got_offset);
+		if (myrelsec) {
+			obj_extend_section(myrelsec, got_offset);
 		} else {
-			relsec = obj_create_alloced_section(f, ".got", 
+			myrelsec = obj_create_alloced_section(f, ".got", 
 							    BB_GOT_ENTRY_SIZE,
 							    got_offset);
-			assert(relsec);
+			assert(myrelsec);
 		}
 
-		ifile->got = relsec;
+		ifile->got = myrelsec;
 	}
 #endif
 
@@ -1748,19 +1748,19 @@
 			while (*q++ == ',');
 		} else {
 			char *contents = f->sections[sym->secidx]->contents;
-			char *loc = contents + sym->value;
+			char *myloc = contents + sym->value;
 			char *r;			/* To search for commas */
 
 			/* Break the string with comas */
 			while ((r = strchr(q, ',')) != (char *) NULL) {
 				*r++ = '\0';
-				obj_string_patch(f, sym->secidx, loc - contents, q);
-				loc += sizeof(char *);
+				obj_string_patch(f, sym->secidx, myloc - contents, q);
+				myloc += sizeof(char *);
 				q = r;
 			}
 
 			/* last part */
-			obj_string_patch(f, sym->secidx, loc - contents, q);
+			obj_string_patch(f, sym->secidx, myloc - contents, q);
 		}
 
 		argc--, argv++;
diff --git a/klogd.c b/klogd.c
index 95d4eea..241a991 100644
--- a/klogd.c
+++ b/klogd.c
@@ -40,20 +40,14 @@
 #include <ctype.h>
 #include <sys/syslog.h>
 
-#if ! defined __GLIBC__ && ! defined __UCLIBC__
-#include <sys/syscall.h>
-#include <linux/unistd.h>
-
-#ifndef __alpha__
-# define __NR_klogctl __NR_syslog
-static inline _syscall3(int, klogctl, int, type, char *, b, int, len);
-#else							/* __alpha__ */
-#define klogctl syslog
-#endif
-
+#if __GNU_LIBRARY__ < 5
+# ifdef __alpha__
+#   define klogctl syslog
+# endif
 #else
 # include <sys/klog.h>
 #endif
+
 #include "busybox.h"
 
 static void klogd_signal(int sig)
diff --git a/libbb/libbb.h b/libbb/libbb.h
index d850bef..d0896ab 100644
--- a/libbb/libbb.h
+++ b/libbb/libbb.h
@@ -211,5 +211,6 @@
 };
 
 int ask_confirmation(void);
+int klogctl(int type, char * b, int len);
 
 #endif /* __LIBBB_H__ */
diff --git a/libbb/syscalls.c b/libbb/syscalls.c
index 0211546..efca399 100644
--- a/libbb/syscalls.c
+++ b/libbb/syscalls.c
@@ -32,18 +32,63 @@
 
 #include "libbb.h"
 
+_syscall3(int, sysfs, int, option, unsigned int, fs_index, char *, buf);
 
-_syscall1(int, sysinfo, struct sysinfo *, info);
+#ifndef __NR_pivot_root
+#warning This kernel does not support the pivot_root syscall
+#warning -> The pivot_root system call is being stubbed out...
+int pivot_root(const char * new_root,const char * put_old)
+{
+	/* BusyBox was compiled against a kernel that did not support
+	 *  the pivot_root system call.  To make this application work,
+	 *  you will need to recompile with a kernel supporting the
+	 *  pivot_root system call.
+	 */
+	fprintf(stderr, "\n\nTo make this application work, you will need to recompile\n");
+	fprintf(stderr, "with a kernel supporting the pivot_root system call. -Erik\n\n");
+	errno=ENOSYS;
+	return -1;
+}
+#else
+_syscall2(int,pivot_root,const char *,new_root,const char *,put_old)
+#endif
 
-/* Include our own version of <sys/mount.h>, since libc5 doesn't
- * know about umount2 */
-extern _syscall1(int, umount, const char *, special_file);
-extern _syscall5(int, mount, const char *, special_file, const char *, dir,
-		const char *, fstype, unsigned long int, rwflag, const void *, data);
+
+
+
+#if __GNU_LIBRARY__ < 5
+/* These syscalls are not included as part of libc5 */
+_syscall2(int, bdflush, int, func, int, data);
+_syscall1(int, delete_module, const char *, name)
+
+#ifndef __NR_query_module
+#warning This kernel does not support the query_module syscall
+#warning -> The query_module system call is being stubbed out...
+int query_module(const char *name, int which, void *buf, size_t bufsize, size_t *ret)
+{
+	/* BusyBox was compiled against a kernel that did not support
+	 *  the query_module system call.  To make this application work,
+	 *  you will need to recompile with a kernel supporting the
+	 *  query_module system call.
+	 */
+	fprintf(stderr, "\n\nTo make this application work, you will need to recompile\n");
+	fprintf(stderr, "with a kernel supporting the query_module system call. -Erik\n\n");
+	errno=ENOSYS;
+	return -1;
+}
+#else
+_syscall5(int, query_module, const char *, name, int, which,
+		void *, buf, size_t, bufsize, size_t*, ret);
+#endif
+
+#ifndef __alpha__
+# define __NR_klogctl __NR_syslog
+  _syscall3(int, klogctl, int, type, char *, b, int, len);
+#endif
 
 #ifndef __NR_umount2
 # warning This kernel does not support the umount2 syscall
-# warning The umount2 system call is being stubbed out...
+# warning -> The umount2 system call is being stubbed out...
 int umount2(const char * special_file, int flags)
 {
 	/* BusyBox was compiled against a kernel that did not support
@@ -57,14 +102,17 @@
 	return -1;
 }
 # else
-extern _syscall2(int, umount2, const char *, special_file, int, flags);
+_syscall2(int, umount2, const char *, special_file, int, flags);
 #endif
 
-#ifndef __NR_query_module
-static const int __NR_query_module = 167;
+
+#endif /* __GNU_LIBRARY__ < 5 */
+
+
+#if 0
+_syscall1(int, sysinfo, struct sysinfo *, info);
 #endif
-_syscall5(int, query_module, const char *, name, int, which,
-		void *, buf, size_t, bufsize, size_t*, ret);
+
 
 /* END CODE */
 /*
diff --git a/ls.c b/ls.c
index 49470e9..0b89ecc 100644
--- a/ls.c
+++ b/ls.c
@@ -626,7 +626,7 @@
 				column += 10;
 				break;
 			case LIST_NLINKS:
-				printf("%4d ", dn->dstat.st_nlink);
+				printf("%4ld ", (long)dn->dstat.st_nlink);
 				column += 10;
 				break;
 			case LIST_ID_NAME:
diff --git a/lsmod.c b/lsmod.c
index 8251705..0f1b09b 100644
--- a/lsmod.c
+++ b/lsmod.c
@@ -52,8 +52,7 @@
 };
 
 
-int query_module(const char *name, int which, void *buf, size_t bufsize,
-		 size_t *ret);
+int query_module(const char *name, int which, void *buf, size_t bufsize, size_t *ret);
 
 /* Values for query_module's which.  */
 static const int QM_MODULES = 1;
diff --git a/miscutils/adjtimex.c b/miscutils/adjtimex.c
index 02b6e89..e3c160d 100644
--- a/miscutils/adjtimex.c
+++ b/miscutils/adjtimex.c
@@ -44,7 +44,14 @@
 #include <sys/types.h>
 #include <stdlib.h>
 #include <unistd.h>
+
+#if __GNU_LIBRARY__ < 5
 #include <sys/timex.h>
+extern int adjtimex(struct timex *buf);
+#else
+#include <sys/timex.h>
+#endif
+
 #ifdef BB_VER
 #include "busybox.h"
 #endif
@@ -163,7 +170,7 @@
 			"    return value: %d (%s)\n",
 		txc.constant,
 		txc.precision, txc.tolerance, txc.tick,
-		txc.time.tv_sec, txc.time.tv_usec, ret, descript);
+		(long)txc.time.tv_sec, (long)txc.time.tv_usec, ret, descript);
 	}
 	return (ret<0);
 }
diff --git a/miscutils/update.c b/miscutils/update.c
index b282b9e..ce2b6cf 100644
--- a/miscutils/update.c
+++ b/miscutils/update.c
@@ -33,14 +33,12 @@
 #include <unistd.h> /* for getopt() */
 #include <stdlib.h>
 
-
 #if defined(__GLIBC__)
 #include <sys/kdaemon.h>
 #else
-#include <sys/syscall.h>
-#include <linux/unistd.h>
-static _syscall2(int, bdflush, int, func, int, data);
-#endif /* __GLIBC__ */
+extern int bdflush (int func, long int data);
+#endif							/* __GLIBC__ */
+
 #include "busybox.h"
 
 static unsigned int sync_duration = 30;
diff --git a/modutils/insmod.c b/modutils/insmod.c
index 0a7cb1e..ad1486b 100644
--- a/modutils/insmod.c
+++ b/modutils/insmod.c
@@ -119,7 +119,7 @@
 #ifndef MODUTILS_MODULE_H
 static const int MODUTILS_MODULE_H = 1;
 
-#ident "$Id: insmod.c,v 1.53 2001/03/22 19:01:16 andersen Exp $"
+#ident "$Id: insmod.c,v 1.54 2001/04/05 03:14:39 andersen Exp $"
 
 /* This file contains the structures used by the 2.0 and 2.1 kernels.
    We do not use the kernel headers directly because we do not wish
@@ -325,7 +325,7 @@
 #ifndef MODUTILS_OBJ_H
 static const int MODUTILS_OBJ_H = 1;
 
-#ident "$Id: insmod.c,v 1.53 2001/03/22 19:01:16 andersen Exp $"
+#ident "$Id: insmod.c,v 1.54 2001/04/05 03:14:39 andersen Exp $"
 
 /* The relocatable object is manipulated using elfin types.  */
 
@@ -1210,18 +1210,18 @@
 
 #if defined(BB_USE_GOT_ENTRIES)
 	if (got_offset) {
-		struct obj_section* relsec = obj_find_section(f, ".got");
+		struct obj_section* myrelsec = obj_find_section(f, ".got");
 
-		if (relsec) {
-			obj_extend_section(relsec, got_offset);
+		if (myrelsec) {
+			obj_extend_section(myrelsec, got_offset);
 		} else {
-			relsec = obj_create_alloced_section(f, ".got", 
+			myrelsec = obj_create_alloced_section(f, ".got", 
 							    BB_GOT_ENTRY_SIZE,
 							    got_offset);
-			assert(relsec);
+			assert(myrelsec);
 		}
 
-		ifile->got = relsec;
+		ifile->got = myrelsec;
 	}
 #endif
 
@@ -1748,19 +1748,19 @@
 			while (*q++ == ',');
 		} else {
 			char *contents = f->sections[sym->secidx]->contents;
-			char *loc = contents + sym->value;
+			char *myloc = contents + sym->value;
 			char *r;			/* To search for commas */
 
 			/* Break the string with comas */
 			while ((r = strchr(q, ',')) != (char *) NULL) {
 				*r++ = '\0';
-				obj_string_patch(f, sym->secidx, loc - contents, q);
-				loc += sizeof(char *);
+				obj_string_patch(f, sym->secidx, myloc - contents, q);
+				myloc += sizeof(char *);
 				q = r;
 			}
 
 			/* last part */
-			obj_string_patch(f, sym->secidx, loc - contents, q);
+			obj_string_patch(f, sym->secidx, myloc - contents, q);
 		}
 
 		argc--, argv++;
diff --git a/modutils/lsmod.c b/modutils/lsmod.c
index 8251705..0f1b09b 100644
--- a/modutils/lsmod.c
+++ b/modutils/lsmod.c
@@ -52,8 +52,7 @@
 };
 
 
-int query_module(const char *name, int which, void *buf, size_t bufsize,
-		 size_t *ret);
+int query_module(const char *name, int which, void *buf, size_t bufsize, size_t *ret);
 
 /* Values for query_module's which.  */
 static const int QM_MODULES = 1;
diff --git a/modutils/rmmod.c b/modutils/rmmod.c
index 36857e0..7596d02 100644
--- a/modutils/rmmod.c
+++ b/modutils/rmmod.c
@@ -26,16 +26,11 @@
 #include <unistd.h>
 #include <stdlib.h>
 #include <getopt.h>
-#include <sys/syscall.h>
-#include <linux/unistd.h>
 #include "busybox.h"
-#define __LIBRARY__
 
+extern int delete_module(const char * name);
 
 
-/* And the system call of the day is...  */
-_syscall1(int, delete_module, const char *, name)
-
 extern int rmmod_main(int argc, char **argv)
 {
 	int n, ret = EXIT_SUCCESS;
diff --git a/mount.c b/mount.c
index 57dc73e..5b6ec1e 100644
--- a/mount.c
+++ b/mount.c
@@ -84,11 +84,7 @@
 extern int umount (__const char *__special_file);
 extern int umount2 (__const char *__special_file, int __flags);
 
-#include <sys/syscall.h>
-#include <linux/unistd.h>
-static int sysfs( int option, unsigned int fs_index, char * buf);
-_syscall3(int, sysfs, int, option, unsigned int, fs_index, char *, buf);
-
+extern int sysfs( int option, unsigned int fs_index, char * buf);
 
 extern const char mtab_file[];	/* Defined in utility.c */
 
diff --git a/networking/tftp.c b/networking/tftp.c
index 309df36..466851c 100644
--- a/networking/tftp.c
+++ b/networking/tftp.c
@@ -116,7 +116,7 @@
 	len = sizeof(sa);
 
 	memset(&sa, 0, len);
-	bind(socketfd, &sa, len);
+	bind(socketfd, (struct sockaddr *)&sa, len);
 
 	sa.sin_family = host->h_addrtype;
 	sa.sin_port = htons(port);
diff --git a/pivot_root.c b/pivot_root.c
index 4d7f8a3..ba26b9c 100644
--- a/pivot_root.c
+++ b/pivot_root.c
@@ -9,30 +9,9 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <errno.h>
-#include <sys/syscall.h>
-#include <linux/unistd.h>
 #include "busybox.h"
 
-#ifndef __NR_pivot_root
-#warning This kernel does not support the pivot_root syscall
-#warning The pivot_root system call is being stubbed out...
-int pivot_root(const char * new_root,const char * put_old)
-{
-	/* BusyBox was compiled against a kernel that did not support
-	 *  the pivot_root system call.  To make this application work,
-	 *  you will need to recompile with a kernel supporting the
-	 *  pivot_root system call.
-	 */
-	fprintf(stderr, "\n\nTo make this application work, you will need to recompile\n");
-	fprintf(stderr, "with a kernel supporting the pivot_root system call. -Erik\n\n");
-	errno=ENOSYS;
-	return -1;
-}
-#else
-static _syscall2(int,pivot_root,const char *,new_root,const char *,put_old)
-#endif
-
-
+extern int pivot_root(const char * new_root,const char * put_old);
 
 int pivot_root_main(int argc, char **argv)
 {
diff --git a/rmmod.c b/rmmod.c
index 36857e0..7596d02 100644
--- a/rmmod.c
+++ b/rmmod.c
@@ -26,16 +26,11 @@
 #include <unistd.h>
 #include <stdlib.h>
 #include <getopt.h>
-#include <sys/syscall.h>
-#include <linux/unistd.h>
 #include "busybox.h"
-#define __LIBRARY__
 
+extern int delete_module(const char * name);
 
 
-/* And the system call of the day is...  */
-_syscall1(int, delete_module, const char *, name)
-
 extern int rmmod_main(int argc, char **argv)
 {
 	int n, ret = EXIT_SUCCESS;
diff --git a/swaponoff.c b/swaponoff.c
index 55022ae..ce0e2c6 100644
--- a/swaponoff.c
+++ b/swaponoff.c
@@ -29,14 +29,17 @@
 #include <string.h>
 #include <stdlib.h>
 #include <sys/mount.h>
-#include <sys/syscall.h>
-#include <linux/unistd.h>
+
+#if __GNU_LIBRARY__ < 5
+/* libc5 doesn't have sys/swap.h, define these here. */ 
+extern int swapon (__const char *__path, int __flags);
+extern int swapoff (__const char *__path);
+#else
+#include <sys/swap.h>
+#endif
+
 #include "busybox.h"
 
-static _syscall2(int, swapon, const char *, path, int, flags);
-static _syscall1(int, swapoff, const char *, path);
-
-
 static int whichApp;
 
 static const int SWAPON_APP = 1;
diff --git a/sysklogd/klogd.c b/sysklogd/klogd.c
index 95d4eea..241a991 100644
--- a/sysklogd/klogd.c
+++ b/sysklogd/klogd.c
@@ -40,20 +40,14 @@
 #include <ctype.h>
 #include <sys/syslog.h>
 
-#if ! defined __GLIBC__ && ! defined __UCLIBC__
-#include <sys/syscall.h>
-#include <linux/unistd.h>
-
-#ifndef __alpha__
-# define __NR_klogctl __NR_syslog
-static inline _syscall3(int, klogctl, int, type, char *, b, int, len);
-#else							/* __alpha__ */
-#define klogctl syslog
-#endif
-
+#if __GNU_LIBRARY__ < 5
+# ifdef __alpha__
+#   define klogctl syslog
+# endif
 #else
 # include <sys/klog.h>
 #endif
+
 #include "busybox.h"
 
 static void klogd_signal(int sig)
diff --git a/tftp.c b/tftp.c
index 309df36..466851c 100644
--- a/tftp.c
+++ b/tftp.c
@@ -116,7 +116,7 @@
 	len = sizeof(sa);
 
 	memset(&sa, 0, len);
-	bind(socketfd, &sa, len);
+	bind(socketfd, (struct sockaddr *)&sa, len);
 
 	sa.sin_family = host->h_addrtype;
 	sa.sin_port = htons(port);
diff --git a/update.c b/update.c
index b282b9e..ce2b6cf 100644
--- a/update.c
+++ b/update.c
@@ -33,14 +33,12 @@
 #include <unistd.h> /* for getopt() */
 #include <stdlib.h>
 
-
 #if defined(__GLIBC__)
 #include <sys/kdaemon.h>
 #else
-#include <sys/syscall.h>
-#include <linux/unistd.h>
-static _syscall2(int, bdflush, int, func, int, data);
-#endif /* __GLIBC__ */
+extern int bdflush (int func, long int data);
+#endif							/* __GLIBC__ */
+
 #include "busybox.h"
 
 static unsigned int sync_duration = 30;
diff --git a/util-linux/dmesg.c b/util-linux/dmesg.c
index 2c85ed3..73de6d1 100644
--- a/util-linux/dmesg.c
+++ b/util-linux/dmesg.c
@@ -20,18 +20,13 @@
 #include <getopt.h>
 
 #if __GNU_LIBRARY__ < 5
-#include <sys/syscall.h>
-#include <linux/unistd.h>
-#ifndef __alpha__
-# define __NR_klogctl __NR_syslog
-static inline _syscall3(int, klogctl, int, type, char *, b, int, len);
-#else							/* __alpha__ */
-#define klogctl syslog
-#endif
-
+# ifdef __alpha__
+#   define klogctl syslog
+# endif
 #else
 # include <sys/klog.h>
 #endif
+
 #include "busybox.h"
 
 int dmesg_main(int argc, char **argv)
diff --git a/util-linux/mount.c b/util-linux/mount.c
index 57dc73e..5b6ec1e 100644
--- a/util-linux/mount.c
+++ b/util-linux/mount.c
@@ -84,11 +84,7 @@
 extern int umount (__const char *__special_file);
 extern int umount2 (__const char *__special_file, int __flags);
 
-#include <sys/syscall.h>
-#include <linux/unistd.h>
-static int sysfs( int option, unsigned int fs_index, char * buf);
-_syscall3(int, sysfs, int, option, unsigned int, fs_index, char *, buf);
-
+extern int sysfs( int option, unsigned int fs_index, char * buf);
 
 extern const char mtab_file[];	/* Defined in utility.c */
 
diff --git a/util-linux/pivot_root.c b/util-linux/pivot_root.c
index 4d7f8a3..ba26b9c 100644
--- a/util-linux/pivot_root.c
+++ b/util-linux/pivot_root.c
@@ -9,30 +9,9 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <errno.h>
-#include <sys/syscall.h>
-#include <linux/unistd.h>
 #include "busybox.h"
 
-#ifndef __NR_pivot_root
-#warning This kernel does not support the pivot_root syscall
-#warning The pivot_root system call is being stubbed out...
-int pivot_root(const char * new_root,const char * put_old)
-{
-	/* BusyBox was compiled against a kernel that did not support
-	 *  the pivot_root system call.  To make this application work,
-	 *  you will need to recompile with a kernel supporting the
-	 *  pivot_root system call.
-	 */
-	fprintf(stderr, "\n\nTo make this application work, you will need to recompile\n");
-	fprintf(stderr, "with a kernel supporting the pivot_root system call. -Erik\n\n");
-	errno=ENOSYS;
-	return -1;
-}
-#else
-static _syscall2(int,pivot_root,const char *,new_root,const char *,put_old)
-#endif
-
-
+extern int pivot_root(const char * new_root,const char * put_old);
 
 int pivot_root_main(int argc, char **argv)
 {
diff --git a/util-linux/swaponoff.c b/util-linux/swaponoff.c
index 55022ae..ce0e2c6 100644
--- a/util-linux/swaponoff.c
+++ b/util-linux/swaponoff.c
@@ -29,14 +29,17 @@
 #include <string.h>
 #include <stdlib.h>
 #include <sys/mount.h>
-#include <sys/syscall.h>
-#include <linux/unistd.h>
+
+#if __GNU_LIBRARY__ < 5
+/* libc5 doesn't have sys/swap.h, define these here. */ 
+extern int swapon (__const char *__path, int __flags);
+extern int swapoff (__const char *__path);
+#else
+#include <sys/swap.h>
+#endif
+
 #include "busybox.h"
 
-static _syscall2(int, swapon, const char *, path, int, flags);
-static _syscall1(int, swapoff, const char *, path);
-
-
 static int whichApp;
 
 static const int SWAPON_APP = 1;