diff -urNp x-ref/include/asm-x86_64/asm-macros.i x/include/asm-x86_64/asm-macros.i
--- x-ref/include/asm-x86_64/asm-macros.i	2002-11-29 02:23:18.000000000 +0100
+++ x/include/asm-x86_64/asm-macros.i	1970-01-01 01:00:00.000000000 +0100
@@ -1,12 +0,0 @@
-
-	.macro SAVE_CALLEE_CLOBBERED
-	cld
-	pushq %rdi
-	pushq %rsi
-	pushq %rdx
-	pushq %rcx
-	pushq %rbx
-	pushq %rax
-	pushq %r8
-	pushq %r9" 
-	.endm
diff -urNp x-ref/include/asm-x86_64/bitops.h x/include/asm-x86_64/bitops.h
--- x-ref/include/asm-x86_64/bitops.h	2003-01-30 20:13:21.000000000 +0100
+++ x/include/asm-x86_64/bitops.h	2003-01-30 22:11:12.000000000 +0100
@@ -58,6 +58,14 @@ static __inline__ void __set_bit(long nr
 		:"dIr" (nr));
 }
 
+static __inline__ void __clear_bit(int nr, volatile void * addr)
+{
+	__asm__ __volatile__(
+		"btrl %1,%0"
+		:"=m" (ADDR)
+		:"Ir" (nr));
+}
+
 /**
  * clear_bit - Clears a bit in memory
  * @nr: Bit to clear
@@ -78,15 +86,6 @@ static __inline__ void clear_bit(long nr
 #define smp_mb__before_clear_bit()	barrier()
 #define smp_mb__after_clear_bit()	barrier()
 
-static __inline__ void __clear_bit(long nr, volatile void * addr)
-{
-	__asm__ __volatile__(
-		"btrq %1,%0"
-		:"=m" (ADDR)
-		:"dIr" (nr));
-}
-
-
 /**
  * __change_bit - Toggle a bit in memory
  * @nr: the bit to set
@@ -324,7 +323,7 @@ static __inline__ int find_next_zero_bit
 	return (offset + set + res);
 }
 
-#include <linux/compiler.h>
+
 /**
  * find_first_bit - find the first set bit in a memory region
  * @addr: The address to start the search at
@@ -345,9 +344,9 @@ static __inline__ int find_first_bit(voi
 		"jz 1f\n\t"
 		"leaq -4(%%rdi),%%rdi\n\t"
 		"bsfl (%%rdi),%%eax\n"
-		"1:\tsubq %%rbx,%%rdi\n\t"
-		"shlq $3,%%rdi\n\t"
-		"addq %%rdi,%%rax"
+		"1:\tsubl %%ebx,%%edi\n\t"
+		"shll $3,%%edi\n\t"
+		"addl %%edi,%%eax"
 		:"=a" (res), "=&c" (d0), "=&D" (d1)
 		:"1" ((size + 31) >> 5), "2" (addr), "b" (addr));
 	return res;
@@ -421,6 +420,21 @@ static __inline__ unsigned long ffz(unsi
 	return word;
 }
 
+
+/**
+ * __ffs - find first bit in word.
+ * @word: The word to search
+ *
+ * Undefined if no bit exists, so code should check against 0 first.
+ */
+static __inline__ unsigned long __ffs(unsigned long word)
+{
+	__asm__("bsfq %1,%0"
+		:"=r" (word)
+		:"rm" (word));
+	return word;
+}
+
 #ifdef __KERNEL__
 
 /**
@@ -442,35 +456,6 @@ static __inline__ int ffs(int x)
 	return r+1;
 }
 
-static __inline__ unsigned long __ffs(unsigned long word)
-{
-	__asm__("bsfq %1,%0"
-		:"=r" (word)
-		:"rm" (word));
-	return word;
-}
-
-
-/*
- * Every architecture must define this function. It's the fastest
- * way of searching a 140-bit bitmap where the first 100 bits are
- * unlikely to be set. It's guaranteed that at least one of the 140
- * bits is cleared.
- */
-static inline int _sched_find_first_bit(unsigned long *b)
-{
-	if (unlikely(b[0]))
-		return __ffs(b[0]);
-	if (unlikely(b[1]))
-		return __ffs(b[1]) + 32;
-	if (unlikely(b[2]))
-		return __ffs(b[2]) + 64;
-	if (b[3])
-		return __ffs(b[3]) + 96;
-	return __ffs(b[4]) + 128;
-}
-
-
 /**
  * hweightN - returns the hamming weight of a N-bit word
  * @x: the word to weigh
diff -urNp x-ref/include/asm-x86_64/ia32_unistd.h x/include/asm-x86_64/ia32_unistd.h
--- x-ref/include/asm-x86_64/ia32_unistd.h	2003-01-29 06:14:23.000000000 +0100
+++ x/include/asm-x86_64/ia32_unistd.h	2003-01-30 22:17:21.000000000 +0100
@@ -249,7 +249,14 @@
 #define __NR_ia32_futex		240
 #define __NR_ia32_sched_setaffinity	241
 #define __NR_ia32_sched_getaffinity	242
+#define __NR_ia32_set_thread_area	243
+#define __NR_ia32_get_thread_area	244
+#define __NR_ia32_io_setup		245
+#define __NR_ia32_io_destroy		246
+#define __NR_ia32_io_getevents		247
+#define __NR_ia32_io_submit		248
+#define __NR_ia32_io_cancel		249
 
-#define IA32_NR_syscalls 245
+#define IA32_NR_syscalls 260
 
 #endif /* _ASM_X86_64_IA32_UNISTD_H_ */
diff -urNp x-ref/include/asm-x86_64/ioctls.h x/include/asm-x86_64/ioctls.h
--- x-ref/include/asm-x86_64/ioctls.h	2003-01-30 20:13:21.000000000 +0100
+++ x/include/asm-x86_64/ioctls.h	2003-01-30 20:13:23.000000000 +0100
@@ -49,6 +49,7 @@
 #define TIOCGSID	0x5429  /* Return the session ID of FD */
 #define TIOCGPTN	_IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */
 #define TIOCSPTLCK	_IOW('T',0x31, int)  /* Lock/unlock Pty */
+#define TIOCGDEV        _IOR('T',0x32, unsigned int)
 
 #define FIONCLEX	0x5450  /* these numbers need to be adjusted. */
 #define FIOCLEX		0x5451
diff -urNp x-ref/include/asm-x86_64/max_numnodes.h x/include/asm-x86_64/max_numnodes.h
--- x-ref/include/asm-x86_64/max_numnodes.h	1970-01-01 01:00:00.000000000 +0100
+++ x/include/asm-x86_64/max_numnodes.h	2003-01-30 20:13:23.000000000 +0100
@@ -0,0 +1,14 @@
+#ifndef _ASM_MAX_NUMNODES_H
+#define _ASM_MAX_NUMNODES_H
+
+#include <linux/config.h>
+
+
+
+#ifdef CONFIG_K8_NUMA
+#define MAX_NUMNODES 8 
+#else
+#define MAX_NUMNODES 1
+#endif
+
+#endif
diff -urNp x-ref/include/asm-x86_64/mman.h x/include/asm-x86_64/mman.h
--- x-ref/include/asm-x86_64/mman.h	2003-01-30 20:13:21.000000000 +0100
+++ x/include/asm-x86_64/mman.h	2003-01-30 20:13:23.000000000 +0100
@@ -4,7 +4,7 @@
 #define PROT_READ	0x1		/* page can be read */
 #define PROT_WRITE	0x2		/* page can be written */
 #define PROT_EXEC	0x4		/* page can be executed */
-#define PROT_SEM	0x8
+#define PROT_SEM	0x8		/* page may be used for atomic ops */
 #define PROT_NONE	0x0		/* page can not be accessed */
 
 #define MAP_SHARED	0x01		/* Share changes */
diff -urNp x-ref/include/asm-x86_64/mmzone.h x/include/asm-x86_64/mmzone.h
--- x-ref/include/asm-x86_64/mmzone.h	2002-11-29 02:23:18.000000000 +0100
+++ x/include/asm-x86_64/mmzone.h	2003-01-30 20:13:23.000000000 +0100
@@ -22,8 +22,8 @@ struct bootmem_data_t;
 
 extern plat_pg_data_t *plat_node_data[];
 
+#include <asm/max_numnodes.h>
 #define MAXNODE 8 
-#define MAX_NUMNODES MAXNODE
 #define NODEMAPSIZE 0xff
 
 /* Simple perfect hash to map physical addresses to node numbers */
diff -urNp x-ref/include/asm-x86_64/system.h x/include/asm-x86_64/system.h
--- x-ref/include/asm-x86_64/system.h	2003-01-30 20:13:21.000000000 +0100
+++ x/include/asm-x86_64/system.h	2003-01-30 20:13:23.000000000 +0100
@@ -239,7 +239,7 @@ static inline unsigned long __cmpxchg(vo
 #define warn_if_not_ulong(x) do { unsigned long foo; (void) (&(x) == &foo); } while (0)
 
 /* interrupt control.. */
-#define __save_flags(x)		do { warn_if_not_ulong(x); __asm__ __volatile__("# save_flags \n\t pushfq ; popq %0":"=g" (x): /* no input */ :"memory"); } while (0)
+#define __save_flags(x)		do { warn_if_not_ulong(x); __asm__ __volatile__("# save_flags \n\t pushfq ; popq %q0":"=g" (x): /* no input */ :"memory"); } while (0)
 #define __restore_flags(x) 	__asm__ __volatile__("# restore_flags \n\t pushq %0 ; popfq": /* no output */ :"g" (x):"memory", "cc")
 #define __cli() 		__asm__ __volatile__("cli": : :"memory")
 #define __sti()			__asm__ __volatile__("sti": : :"memory")
diff -urNp x-ref/include/asm-x86_64/unistd.h x/include/asm-x86_64/unistd.h
--- x-ref/include/asm-x86_64/unistd.h	2003-01-30 20:13:21.000000000 +0100
+++ x/include/asm-x86_64/unistd.h	2003-01-30 22:20:16.000000000 +0100
@@ -436,51 +436,51 @@ __SYSCALL(__NR_gettid, sys_gettid)
 __SYSCALL(__NR_readahead, sys_readahead)
 
 #define __NR_setxattr		188
-__SYSCALL(__NR_setxattr, sys_ni_syscall)
+__SYSCALL(__NR_setxattr, sys_setxattr)
 #define __NR_lsetxattr		189
-__SYSCALL(__NR_lsetxattr, sys_ni_syscall)
+__SYSCALL(__NR_lsetxattr, sys_lsetxattr)
 #define __NR_fsetxattr		190
-__SYSCALL(__NR_fsetxattr, sys_ni_syscall)
+__SYSCALL(__NR_fsetxattr, sys_fsetxattr)
 #define __NR_getxattr		191
-__SYSCALL(__NR_getxattr, sys_ni_syscall)
+__SYSCALL(__NR_getxattr, sys_getxattr)
 #define __NR_lgetxattr		192
-__SYSCALL(__NR_lgetxattr, sys_ni_syscall)
+__SYSCALL(__NR_lgetxattr, sys_lgetxattr)
 #define __NR_fgetxattr		193
-__SYSCALL(__NR_fgetxattr, sys_ni_syscall) 
+__SYSCALL(__NR_fgetxattr, sys_fgetxattr) 
 #define __NR_listxattr		194
-__SYSCALL(__NR_listxattr, sys_ni_syscall) 
+__SYSCALL(__NR_listxattr, sys_listxattr) 
 #define __NR_llistxattr		195
-__SYSCALL(__NR_llistxattr, sys_ni_syscall) 
+__SYSCALL(__NR_llistxattr, sys_llistxattr) 
 #define __NR_flistxattr		196
-__SYSCALL(__NR_flistxattr, sys_ni_syscall) 
+__SYSCALL(__NR_flistxattr, sys_flistxattr) 
 #define __NR_removexattr	197
-__SYSCALL(__NR_removexattr, sys_ni_syscall) 
+__SYSCALL(__NR_removexattr, sys_removexattr) 
 #define __NR_lremovexattr	198
-__SYSCALL(__NR_lremovexattr, sys_ni_syscall) 
+__SYSCALL(__NR_lremovexattr, sys_lremovexattr) 
 #define __NR_fremovexattr	199
-__SYSCALL(__NR_fremovexattr, sys_ni_syscall) 
+__SYSCALL(__NR_fremovexattr, sys_fremovexattr) 
 #define __NR_tkill	200	/* 2.5 only */
 __SYSCALL(__NR_tkill, sys_ni_syscall) 
 #define __NR_time		201
 __SYSCALL(__NR_time, sys_time)
 #define __NR_futex		202 /* 2.5 only */
-__SYSCALL(__NR_futex, sys_ni_syscall)
+__SYSCALL(__NR_futex, sys_futex)
 #define __NR_sched_setaffinity    203
-__SYSCALL(__NR_sched_setaffinity, sys_ni_syscall)
+__SYSCALL(__NR_sched_setaffinity, sys_sched_setaffinity)
 #define __NR_sched_getaffinity     204
-__SYSCALL(__NR_sched_getaffinity, sys_ni_syscall)
+__SYSCALL(__NR_sched_getaffinity, sys_sched_getaffinity)
 #define __NR_set_thread_area	205
 __SYSCALL(__NR_set_thread_area, sys_ni_syscall)
 #define __NR_io_setup	206
-__SYSCALL(__NR_io_setup, sys_ni_syscall)
+__SYSCALL(__NR_io_setup, sys_io_setup)
 #define __NR_io_destroy	207
-__SYSCALL(__NR_io_destroy, sys_ni_syscall)
+__SYSCALL(__NR_io_destroy, sys_io_destroy)
 #define __NR_io_getevents	208
-__SYSCALL(__NR_io_getevents, sys_ni_syscall)
+__SYSCALL(__NR_io_getevents, sys_io_getevents)
 #define __NR_io_submit	209
-__SYSCALL(__NR_io_submit, sys_ni_syscall)
+__SYSCALL(__NR_io_submit, sys_io_submit)
 #define __NR_io_cancel	210
-__SYSCALL(__NR_io_cancel, sys_ni_syscall)
+__SYSCALL(__NR_io_cancel, sys_io_cancel)
 #define __NR_get_thread_area	211
 __SYSCALL(__NR_get_thread_area, sys_ni_syscall)
 #define __NR_lookup_dcookie     212