Fixed to #include correct 32-bit headers; Refreshed libc/kernel headers

This patch fixes an issue where 64-bit hreaders are incorrectly included
in kernel headers.  For example, file "libc/kernel/arch-x86/asm/io.h"
incorreclty includes "io_64.h" (missing, BTW) instead of "io_32.h".

The reason is because CONFIG_X86_32 isn't considered pre-defined in
"kernel_default_arch_macros" for x86, and clean_header.py doesn't
look at it at all anyway (ie. __i386__ is also ignored, but it's
okay since x86 cross compiler defines it back)

Fixed 2 tools/*py, README.TXT, and refreshed libc/kernel headers

Change-Id: Iac834cc8b3548f055d3f2a214af36072dd679fe8
diff --git a/libc/kernel/README.TXT b/libc/kernel/README.TXT
index 9ff97d6..1ca3350e 100644
--- a/libc/kernel/README.TXT
+++ b/libc/kernel/README.TXT
@@ -17,26 +17,27 @@
 
 the generation process works as follows:
 
-  * 'bionic/kernel/original/'
+  * 'external/kernel-headers/original/'
     contains a set of kernel headers as normally found in the 'include'
     directory of a normal Linux kernel source tree. note that this should
     only contain the files that are really needed by Android (use
     'find_headers.py' to find these automatically).
 
-  * 'bionic/kernel/common'
+  * 'bionic/libc/kernel/common'
     contains the non-arch-specific clean headers and directories
     (e.g. linux, asm-generic and mtd)
 
-  *'bionic/kernel/arch-arm/'
+  * 'bionic/libc/kernel/arch-arm/'
     contains the ARM-specific directory tree of clean headers.
 
-  * 'bionic/kernel/arch-arm/asm'
+  * 'bionic/libc/kernel/arch-arm/asm'
     contains the real ARM-specific headers
 
-  * 'bionic/kernel/arch-x86'
+  * 'bionic/libc/kernel/arch-x86'
+    'bionic/libc/kernel/arch-x86/asm'
     similarly contains all headers and symlinks to be used on x86
 
-  * 'bionic/kernel/tools' contains various Python and shell scripts used
+  * 'bionic/libc/kernel/tools' contains various Python and shell scripts used
     to manage and re-generate the headers
 
 the tools you can use are:
diff --git a/libc/kernel/arch-x86/asm/acpi.h b/libc/kernel/arch-x86/asm/acpi.h
index 255f7dc..92e6b7d 100644
--- a/libc/kernel/arch-x86/asm/acpi.h
+++ b/libc/kernel/arch-x86/asm/acpi.h
@@ -18,7 +18,7 @@
  ****************************************************************************/
 #ifndef _ASM_X86_ACPI_H
 #define _ASM_X86_ACPI_H
-#include "acpi_64.h"
+#include "acpi_32.h"
 #include <asm/processor.h>
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #endif
diff --git a/libc/kernel/arch-x86/asm/alternative.h b/libc/kernel/arch-x86/asm/alternative.h
index 52b937b..107f551 100644
--- a/libc/kernel/arch-x86/asm/alternative.h
+++ b/libc/kernel/arch-x86/asm/alternative.h
@@ -16,4 +16,4 @@
  ***
  ****************************************************************************
  ****************************************************************************/
-#include "alternative_64.h"
+#include "alternative_32.h"
diff --git a/libc/kernel/arch-x86/asm/apic.h b/libc/kernel/arch-x86/asm/apic.h
index d628eb3..bf6ac72 100644
--- a/libc/kernel/arch-x86/asm/apic.h
+++ b/libc/kernel/arch-x86/asm/apic.h
@@ -16,4 +16,4 @@
  ***
  ****************************************************************************
  ****************************************************************************/
-#include "apic_64.h"
+#include "apic_32.h"
diff --git a/libc/kernel/arch-x86/asm/apicdef.h b/libc/kernel/arch-x86/asm/apicdef.h
index 8890eb3..af5b074 100644
--- a/libc/kernel/arch-x86/asm/apicdef.h
+++ b/libc/kernel/arch-x86/asm/apicdef.h
@@ -16,4 +16,4 @@
  ***
  ****************************************************************************
  ****************************************************************************/
-#include "apicdef_64.h"
+#include "apicdef_32.h"
diff --git a/libc/kernel/arch-x86/asm/atomic.h b/libc/kernel/arch-x86/asm/atomic.h
index 0c0037c..9c65347 100644
--- a/libc/kernel/arch-x86/asm/atomic.h
+++ b/libc/kernel/arch-x86/asm/atomic.h
@@ -16,4 +16,4 @@
  ***
  ****************************************************************************
  ****************************************************************************/
-#include "atomic_64.h"
+#include "atomic_32.h"
diff --git a/libc/kernel/arch-x86/asm/auxvec.h b/libc/kernel/arch-x86/asm/auxvec.h
index 4fd3bc9..d3cffec 100644
--- a/libc/kernel/arch-x86/asm/auxvec.h
+++ b/libc/kernel/arch-x86/asm/auxvec.h
@@ -18,9 +18,7 @@
  ****************************************************************************/
 #ifndef _ASM_X86_AUXVEC_H
 #define _ASM_X86_AUXVEC_H
-#ifdef __i386__
 #define AT_SYSINFO 32
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#endif
 #define AT_SYSINFO_EHDR 33
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #endif
diff --git a/libc/kernel/arch-x86/asm/bitops.h b/libc/kernel/arch-x86/asm/bitops.h
index 657534d..491b611 100644
--- a/libc/kernel/arch-x86/asm/bitops.h
+++ b/libc/kernel/arch-x86/asm/bitops.h
@@ -16,4 +16,4 @@
  ***
  ****************************************************************************
  ****************************************************************************/
-#include "bitops_64.h"
+#include "bitops_32.h"
diff --git a/libc/kernel/arch-x86/asm/byteorder.h b/libc/kernel/arch-x86/asm/byteorder.h
index 98fc6b1..74dc9d6 100644
--- a/libc/kernel/arch-x86/asm/byteorder.h
+++ b/libc/kernel/arch-x86/asm/byteorder.h
@@ -22,53 +22,37 @@
 #include <linux/compiler.h>
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #ifdef __GNUC__
-#ifdef __i386__
 static __inline__ __attribute_const__ __u32 ___arch__swab32(__u32 x)
 {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  __asm__("xchgb %b0,%h0\n\t"
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  "rorl $16,%0\n\t"
  "xchgb %b0,%h0"
  :"=q" (x)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  : "0" (x));
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  return x;
 }
 static __inline__ __attribute_const__ __u64 ___arch__swab64(__u64 val)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  union {
  struct { __u32 a,b; } s;
  __u64 u;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  } v;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  v.u = val;
  v.s.a = ___arch__swab32(v.s.a);
  v.s.b = ___arch__swab32(v.s.b);
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  __asm__("xchgl %0,%1" : "=r" (v.s.a), "=r" (v.s.b) : "0" (v.s.a), "1" (v.s.b));
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  return v.u;
 }
-#else
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-static __inline__ __attribute_const__ __u64 ___arch__swab64(__u64 x)
-{
- __asm__("bswapq %0" : "=r" (x) : "0" (x));
- return x;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-}
-static __inline__ __attribute_const__ __u32 ___arch__swab32(__u32 x)
-{
- __asm__("bswapl %0" : "=r" (x) : "0" (x));
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
- return x;
-}
-#endif
 #define __arch__swab64(x) ___arch__swab64(x)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __arch__swab32(x) ___arch__swab32(x)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __BYTEORDER_HAS_U64__
 #endif
 #include <linux/byteorder/little_endian.h>
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #endif
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/arch-x86/asm/cmpxchg.h b/libc/kernel/arch-x86/asm/cmpxchg.h
index 0379a49..9447850 100644
--- a/libc/kernel/arch-x86/asm/cmpxchg.h
+++ b/libc/kernel/arch-x86/asm/cmpxchg.h
@@ -16,4 +16,4 @@
  ***
  ****************************************************************************
  ****************************************************************************/
-#include "cmpxchg_64.h"
+#include "cmpxchg_32.h"
diff --git a/libc/kernel/arch-x86/asm/cpufeature.h b/libc/kernel/arch-x86/asm/cpufeature.h
index 23637d1..7fcfacf 100644
--- a/libc/kernel/arch-x86/asm/cpufeature.h
+++ b/libc/kernel/arch-x86/asm/cpufeature.h
@@ -16,4 +16,4 @@
  ***
  ****************************************************************************
  ****************************************************************************/
-#include "cpufeature_64.h"
+#include "cpufeature_32.h"
diff --git a/libc/kernel/arch-x86/asm/current.h b/libc/kernel/arch-x86/asm/current.h
index c6b8b05..da85169 100644
--- a/libc/kernel/arch-x86/asm/current.h
+++ b/libc/kernel/arch-x86/asm/current.h
@@ -16,4 +16,4 @@
  ***
  ****************************************************************************
  ****************************************************************************/
-#include "current_64.h"
+#include "current_32.h"
diff --git a/libc/kernel/arch-x86/asm/desc.h b/libc/kernel/arch-x86/asm/desc.h
index 4566993..b60787e 100644
--- a/libc/kernel/arch-x86/asm/desc.h
+++ b/libc/kernel/arch-x86/asm/desc.h
@@ -16,4 +16,4 @@
  ***
  ****************************************************************************
  ****************************************************************************/
-#include "desc_64.h"
+#include "desc_32.h"
diff --git a/libc/kernel/arch-x86/asm/div64.h b/libc/kernel/arch-x86/asm/div64.h
index 8641ffa..420d9e3 100644
--- a/libc/kernel/arch-x86/asm/div64.h
+++ b/libc/kernel/arch-x86/asm/div64.h
@@ -18,6 +18,8 @@
  ****************************************************************************/
 #ifndef _ASM_X86_DIV64_H
 #define _ASM_X86_DIV64_H
-#include <asm-generic/div64.h>
-#endif
+#include <linux/types.h>
+#define do_div(n,base) ({   unsigned long __upper, __low, __high, __mod, __base;   __base = (base);   asm("":"=a" (__low), "=d" (__high):"A" (n));   __upper = __high;   if (__high) {   __upper = __high % (__base);   __high = __high / (__base);   }   asm("divl %2":"=a" (__low), "=d" (__mod):"rm" (__base), "0" (__low), "1" (__upper));   asm("":"=A" (n):"a" (__low),"d" (__high));   __mod;  })
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define div_long_long_rem(a,b,c) div_ll_X_l_rem(a,b,c)
+#endif
diff --git a/libc/kernel/arch-x86/asm/dma-mapping.h b/libc/kernel/arch-x86/asm/dma-mapping.h
index 5e4666c..0a9d23b 100644
--- a/libc/kernel/arch-x86/asm/dma-mapping.h
+++ b/libc/kernel/arch-x86/asm/dma-mapping.h
@@ -16,4 +16,4 @@
  ***
  ****************************************************************************
  ****************************************************************************/
-#include "dma-mapping_64.h"
+#include "dma-mapping_32.h"
diff --git a/libc/kernel/arch-x86/asm/dma.h b/libc/kernel/arch-x86/asm/dma.h
index 33baa8e..1e96d90 100644
--- a/libc/kernel/arch-x86/asm/dma.h
+++ b/libc/kernel/arch-x86/asm/dma.h
@@ -16,4 +16,4 @@
  ***
  ****************************************************************************
  ****************************************************************************/
-#include "dma_64.h"
+#include "dma_32.h"
diff --git a/libc/kernel/arch-x86/asm/dwarf2.h b/libc/kernel/arch-x86/asm/dwarf2.h
index 52c5bf7..916bcb8 100644
--- a/libc/kernel/arch-x86/asm/dwarf2.h
+++ b/libc/kernel/arch-x86/asm/dwarf2.h
@@ -16,4 +16,4 @@
  ***
  ****************************************************************************
  ****************************************************************************/
-#include "dwarf2_64.h"
+#include "dwarf2_32.h"
diff --git a/libc/kernel/arch-x86/asm/elf.h b/libc/kernel/arch-x86/asm/elf.h
index ac01942..2d1edfd 100644
--- a/libc/kernel/arch-x86/asm/elf.h
+++ b/libc/kernel/arch-x86/asm/elf.h
@@ -27,53 +27,24 @@
 typedef elf_greg_t elf_gregset_t[ELF_NGREG];
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 typedef struct user_i387_struct elf_fpregset_t;
-#ifdef __i386__
 typedef struct user_fxsr_struct elf_fpxregset_t;
 #define R_386_NONE 0
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define R_386_32 1
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define R_386_PC32 2
 #define R_386_GOT32 3
 #define R_386_PLT32 4
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define R_386_COPY 5
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define R_386_GLOB_DAT 6
 #define R_386_JMP_SLOT 7
 #define R_386_RELATIVE 8
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define R_386_GOTOFF 9
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define R_386_GOTPC 10
 #define R_386_NUM 11
 #define ELF_CLASS ELFCLASS32
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define ELF_DATA ELFDATA2LSB
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define ELF_ARCH EM_386
-#else
-#define R_X86_64_NONE 0  
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define R_X86_64_64 1  
-#define R_X86_64_PC32 2  
-#define R_X86_64_GOT32 3  
-#define R_X86_64_PLT32 4  
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define R_X86_64_COPY 5  
-#define R_X86_64_GLOB_DAT 6  
-#define R_X86_64_JUMP_SLOT 7  
-#define R_X86_64_RELATIVE 8  
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define R_X86_64_GOTPCREL 9  
-#define R_X86_64_32 10  
-#define R_X86_64_32S 11  
-#define R_X86_64_16 12  
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define R_X86_64_PC16 13  
-#define R_X86_64_8 14  
-#define R_X86_64_PC8 15  
-#define R_X86_64_NUM 16
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ELF_CLASS ELFCLASS64
-#define ELF_DATA ELFDATA2LSB
-#define ELF_ARCH EM_X86_64
-#endif
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #endif
diff --git a/libc/kernel/arch-x86/asm/fixmap.h b/libc/kernel/arch-x86/asm/fixmap.h
index 363f5a3..f8a1d18 100644
--- a/libc/kernel/arch-x86/asm/fixmap.h
+++ b/libc/kernel/arch-x86/asm/fixmap.h
@@ -16,4 +16,4 @@
  ***
  ****************************************************************************
  ****************************************************************************/
-#include "fixmap_64.h"
+#include "fixmap_32.h"
diff --git a/libc/kernel/arch-x86/asm/genapic.h b/libc/kernel/arch-x86/asm/genapic.h
index 9f9e505..3dc5e45 100644
--- a/libc/kernel/arch-x86/asm/genapic.h
+++ b/libc/kernel/arch-x86/asm/genapic.h
@@ -16,4 +16,4 @@
  ***
  ****************************************************************************
  ****************************************************************************/
-#include "genapic_64.h"
+#include "genapic_32.h"
diff --git a/libc/kernel/arch-x86/asm/hardirq.h b/libc/kernel/arch-x86/asm/hardirq.h
index c8c4e65..4e3b8c1 100644
--- a/libc/kernel/arch-x86/asm/hardirq.h
+++ b/libc/kernel/arch-x86/asm/hardirq.h
@@ -16,4 +16,4 @@
  ***
  ****************************************************************************
  ****************************************************************************/
-#include "hardirq_64.h"
+#include "hardirq_32.h"
diff --git a/libc/kernel/arch-x86/asm/hw_irq.h b/libc/kernel/arch-x86/asm/hw_irq.h
index eb2a64a..d69d8e9 100644
--- a/libc/kernel/arch-x86/asm/hw_irq.h
+++ b/libc/kernel/arch-x86/asm/hw_irq.h
@@ -16,4 +16,4 @@
  ***
  ****************************************************************************
  ****************************************************************************/
-#include "hw_irq_64.h"
+#include "hw_irq_32.h"
diff --git a/libc/kernel/arch-x86/asm/i387.h b/libc/kernel/arch-x86/asm/i387.h
index 07d579d..9333051 100644
--- a/libc/kernel/arch-x86/asm/i387.h
+++ b/libc/kernel/arch-x86/asm/i387.h
@@ -16,4 +16,4 @@
  ***
  ****************************************************************************
  ****************************************************************************/
-#include "i387_64.h"
+#include "i387_32.h"
diff --git a/libc/kernel/arch-x86/asm/io.h b/libc/kernel/arch-x86/asm/io.h
index 11f4db4..4e81b8c 100644
--- a/libc/kernel/arch-x86/asm/io.h
+++ b/libc/kernel/arch-x86/asm/io.h
@@ -16,4 +16,4 @@
  ***
  ****************************************************************************
  ****************************************************************************/
-#include "io_64.h"
+#include "io_32.h"
diff --git a/libc/kernel/arch-x86/asm/io_apic.h b/libc/kernel/arch-x86/asm/io_apic.h
index 03630cf..54bf23a 100644
--- a/libc/kernel/arch-x86/asm/io_apic.h
+++ b/libc/kernel/arch-x86/asm/io_apic.h
@@ -16,4 +16,4 @@
  ***
  ****************************************************************************
  ****************************************************************************/
-#include "io_apic_64.h"
+#include "io_apic_32.h"
diff --git a/libc/kernel/arch-x86/asm/irq.h b/libc/kernel/arch-x86/asm/irq.h
index d6e0493..eaa65db 100644
--- a/libc/kernel/arch-x86/asm/irq.h
+++ b/libc/kernel/arch-x86/asm/irq.h
@@ -16,4 +16,4 @@
  ***
  ****************************************************************************
  ****************************************************************************/
-#include "irq_64.h"
+#include "irq_32.h"
diff --git a/libc/kernel/arch-x86/asm/irqflags.h b/libc/kernel/arch-x86/asm/irqflags.h
index 872a942..4136598 100644
--- a/libc/kernel/arch-x86/asm/irqflags.h
+++ b/libc/kernel/arch-x86/asm/irqflags.h
@@ -16,4 +16,4 @@
  ***
  ****************************************************************************
  ****************************************************************************/
-#include "irqflags_64.h"
+#include "irqflags_32.h"
diff --git a/libc/kernel/arch-x86/asm/linkage.h b/libc/kernel/arch-x86/asm/linkage.h
index 3db2a07..3aae43d 100644
--- a/libc/kernel/arch-x86/asm/linkage.h
+++ b/libc/kernel/arch-x86/asm/linkage.h
@@ -16,4 +16,4 @@
  ***
  ****************************************************************************
  ****************************************************************************/
-#include "linkage_64.h"
+#include "linkage_32.h"
diff --git a/libc/kernel/arch-x86/asm/local.h b/libc/kernel/arch-x86/asm/local.h
index 34d9782..99acf6d 100644
--- a/libc/kernel/arch-x86/asm/local.h
+++ b/libc/kernel/arch-x86/asm/local.h
@@ -16,4 +16,4 @@
  ***
  ****************************************************************************
  ****************************************************************************/
-#include "local_64.h"
+#include "local_32.h"
diff --git a/libc/kernel/arch-x86/asm/mc146818rtc.h b/libc/kernel/arch-x86/asm/mc146818rtc.h
index 4c7f9cc..f7e8781 100644
--- a/libc/kernel/arch-x86/asm/mc146818rtc.h
+++ b/libc/kernel/arch-x86/asm/mc146818rtc.h
@@ -16,4 +16,4 @@
  ***
  ****************************************************************************
  ****************************************************************************/
-#include "mc146818rtc_64.h"
+#include "mc146818rtc_32.h"
diff --git a/libc/kernel/arch-x86/asm/module.h b/libc/kernel/arch-x86/asm/module.h
index 1627050..296ed2b 100644
--- a/libc/kernel/arch-x86/asm/module.h
+++ b/libc/kernel/arch-x86/asm/module.h
@@ -16,4 +16,4 @@
  ***
  ****************************************************************************
  ****************************************************************************/
-#include "module_64.h"
+#include "module_32.h"
diff --git a/libc/kernel/arch-x86/asm/mpspec.h b/libc/kernel/arch-x86/asm/mpspec.h
index f26ad2d..217a7d4 100644
--- a/libc/kernel/arch-x86/asm/mpspec.h
+++ b/libc/kernel/arch-x86/asm/mpspec.h
@@ -16,4 +16,4 @@
  ***
  ****************************************************************************
  ****************************************************************************/
-#include "mpspec_64.h"
+#include "mpspec_32.h"
diff --git a/libc/kernel/arch-x86/asm/msgbuf.h b/libc/kernel/arch-x86/asm/msgbuf.h
index 7580210..99caf76 100644
--- a/libc/kernel/arch-x86/asm/msgbuf.h
+++ b/libc/kernel/arch-x86/asm/msgbuf.h
@@ -22,28 +22,20 @@
  struct ipc64_perm msg_perm;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  __kernel_time_t msg_stime;
-#ifdef __i386__
  unsigned long __unused1;
-#endif
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  __kernel_time_t msg_rtime;
-#ifdef __i386__
  unsigned long __unused2;
-#endif
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  __kernel_time_t msg_ctime;
-#ifdef __i386__
  unsigned long __unused3;
-#endif
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  unsigned long msg_cbytes;
  unsigned long msg_qnum;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  unsigned long msg_qbytes;
  __kernel_pid_t msg_lspid;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  __kernel_pid_t msg_lrpid;
  unsigned long __unused4;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  unsigned long __unused5;
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #endif
diff --git a/libc/kernel/arch-x86/asm/msr.h b/libc/kernel/arch-x86/asm/msr.h
index 63da0cc..00fb800 100644
--- a/libc/kernel/arch-x86/asm/msr.h
+++ b/libc/kernel/arch-x86/asm/msr.h
@@ -23,27 +23,4 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #include <linux/types.h>
 #endif
-#ifdef __i386__
-#else
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#ifndef __ASSEMBLY__
-#include <linux/errno.h>
-#define rdmsr(msr,val1,val2)   __asm__ __volatile__("rdmsr"   : "=a" (val1), "=d" (val2)   : "c" (msr))
-#define rdmsrl(msr,val) do { unsigned long a__,b__;   __asm__ __volatile__("rdmsr"   : "=a" (a__), "=d" (b__)   : "c" (msr));   val = a__ | (b__<<32);  } while(0)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define wrmsr(msr,val1,val2)   __asm__ __volatile__("wrmsr"   :     : "c" (msr), "a" (val1), "d" (val2))
-#define wrmsrl(msr,val) wrmsr(msr,(__u32)((__u64)(val)),((__u64)(val))>>32)
-#define rdtsc(low,high)   __asm__ __volatile__("rdtsc" : "=a" (low), "=d" (high))
-#define rdtscl(low)   __asm__ __volatile__ ("rdtsc" : "=a" (low) : : "edx")
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define rdtscp(low,high,aux)   __asm__ __volatile__ (".byte 0x0f,0x01,0xf9" : "=a" (low), "=d" (high), "=c" (aux))
-#define rdtscll(val) do {   unsigned int __a,__d;   __asm__ __volatile__("rdtsc" : "=a" (__a), "=d" (__d));   (val) = ((unsigned long)__a) | (((unsigned long)__d)<<32);  } while(0)
-#define rdtscpll(val, aux) do {   unsigned long __a, __d;   __asm__ __volatile__ (".byte 0x0f,0x01,0xf9" : "=a" (__a), "=d" (__d), "=c" (aux));   (val) = (__d << 32) | __a;  } while (0)
-#define write_tsc(val1,val2) wrmsr(0x10, val1, val2)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define write_rdtscp_aux(val) wrmsr(0xc0000103, val, 0)
-#define rdpmc(counter,low,high)   __asm__ __volatile__("rdpmc"   : "=a" (low), "=d" (high)   : "c" (counter))
-#endif
-#endif
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #endif
diff --git a/libc/kernel/arch-x86/asm/page.h b/libc/kernel/arch-x86/asm/page.h
index 5ea7de5..3b45383 100644
--- a/libc/kernel/arch-x86/asm/page.h
+++ b/libc/kernel/arch-x86/asm/page.h
@@ -16,9 +16,4 @@
  ***
  ****************************************************************************
  ****************************************************************************/
-#ifdef __i386__
 #include "page_32.h"
-#else
-#include "page_64.h"
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#endif
diff --git a/libc/kernel/arch-x86/asm/percpu.h b/libc/kernel/arch-x86/asm/percpu.h
index a51075b..607b92e 100644
--- a/libc/kernel/arch-x86/asm/percpu.h
+++ b/libc/kernel/arch-x86/asm/percpu.h
@@ -16,4 +16,4 @@
  ***
  ****************************************************************************
  ****************************************************************************/
-#include "percpu_64.h"
+#include "percpu_32.h"
diff --git a/libc/kernel/arch-x86/asm/pgalloc.h b/libc/kernel/arch-x86/asm/pgalloc.h
index 37ce815..9175367 100644
--- a/libc/kernel/arch-x86/asm/pgalloc.h
+++ b/libc/kernel/arch-x86/asm/pgalloc.h
@@ -16,4 +16,4 @@
  ***
  ****************************************************************************
  ****************************************************************************/
-#include "pgalloc_64.h"
+#include "pgalloc_32.h"
diff --git a/libc/kernel/arch-x86/asm/pgtable.h b/libc/kernel/arch-x86/asm/pgtable.h
index 2367e0b..a9bed6b 100644
--- a/libc/kernel/arch-x86/asm/pgtable.h
+++ b/libc/kernel/arch-x86/asm/pgtable.h
@@ -16,4 +16,4 @@
  ***
  ****************************************************************************
  ****************************************************************************/
-#include "pgtable_64.h"
+#include "pgtable_32.h"
diff --git a/libc/kernel/arch-x86/asm/posix_types.h b/libc/kernel/arch-x86/asm/posix_types.h
index 21d4bf2..4e26788 100644
--- a/libc/kernel/arch-x86/asm/posix_types.h
+++ b/libc/kernel/arch-x86/asm/posix_types.h
@@ -16,9 +16,4 @@
  ***
  ****************************************************************************
  ****************************************************************************/
-#ifdef __i386__
 #include "posix_types_32.h"
-#else
-#include "posix_types_64.h"
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#endif
diff --git a/libc/kernel/arch-x86/asm/processor.h b/libc/kernel/arch-x86/asm/processor.h
index 38a66b1..e9eaec8 100644
--- a/libc/kernel/arch-x86/asm/processor.h
+++ b/libc/kernel/arch-x86/asm/processor.h
@@ -16,4 +16,4 @@
  ***
  ****************************************************************************
  ****************************************************************************/
-#include "processor_64.h"
+#include "processor_32.h"
diff --git a/libc/kernel/arch-x86/asm/ptrace-abi.h b/libc/kernel/arch-x86/asm/ptrace-abi.h
index 7cd9425..bbc7e86 100644
--- a/libc/kernel/arch-x86/asm/ptrace-abi.h
+++ b/libc/kernel/arch-x86/asm/ptrace-abi.h
@@ -18,63 +18,28 @@
  ****************************************************************************/
 #ifndef _ASM_X86_PTRACE_ABI_H
 #define _ASM_X86_PTRACE_ABI_H
-#ifdef __i386__
 #define EBX 0
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define ECX 1
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define EDX 2
 #define ESI 3
 #define EDI 4
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define EBP 5
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define EAX 6
 #define DS 7
 #define ES 8
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define FS 9
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define GS 10
 #define ORIG_EAX 11
 #define EIP 12
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define CS 13
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define EFL 14
 #define UESP 15
 #define SS 16
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define FRAME_SIZE 17
-#else
-#if defined(__ASSEMBLY__) || defined(__FRAME_OFFSETS)
-#define R15 0
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define R14 8
-#define R13 16
-#define R12 24
-#define RBP 32
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define RBX 40
-#define R11 48
-#define R10 56
-#define R9 64
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define R8 72
-#define RAX 80
-#define RCX 88
-#define RDX 96
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define RSI 104
-#define RDI 112
-#define ORIG_RAX 120  
-#define RIP 128
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define CS 136
-#define EFLAGS 144
-#define RSP 152
-#define SS 160
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define ARGOFFSET R11
-#endif
-#define FRAME_SIZE 168
-#endif
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define PTRACE_GETREGS 12
 #define PTRACE_SETREGS 13
diff --git a/libc/kernel/arch-x86/asm/ptrace.h b/libc/kernel/arch-x86/asm/ptrace.h
index 2560e5a..95d381e 100644
--- a/libc/kernel/arch-x86/asm/ptrace.h
+++ b/libc/kernel/arch-x86/asm/ptrace.h
@@ -22,60 +22,28 @@
 #include <asm/ptrace-abi.h>
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #ifndef __ASSEMBLY__
-#ifdef __i386__
 struct pt_regs {
  long ebx;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  long ecx;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  long edx;
  long esi;
  long edi;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  long ebp;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  long eax;
  int xds;
  int xes;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  int xfs;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  long orig_eax;
  long eip;
  int xcs;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  long eflags;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  long esp;
  int xss;
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#else
-struct pt_regs {
- unsigned long r15;
- unsigned long r14;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
- unsigned long r13;
- unsigned long r12;
- unsigned long rbp;
- unsigned long rbx;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
- unsigned long r11;
- unsigned long r10;
- unsigned long r9;
- unsigned long r8;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
- unsigned long rax;
- unsigned long rcx;
- unsigned long rdx;
- unsigned long rsi;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
- unsigned long rdi;
- unsigned long orig_rax;
- unsigned long rip;
- unsigned long cs;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
- unsigned long eflags;
- unsigned long rsp;
- unsigned long ss;
-};
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #endif
-#endif
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #endif
diff --git a/libc/kernel/arch-x86/asm/scatterlist.h b/libc/kernel/arch-x86/asm/scatterlist.h
index 376087f..b691d08 100644
--- a/libc/kernel/arch-x86/asm/scatterlist.h
+++ b/libc/kernel/arch-x86/asm/scatterlist.h
@@ -16,4 +16,4 @@
  ***
  ****************************************************************************
  ****************************************************************************/
-#include "scatterlist_64.h"
+#include "scatterlist_32.h"
diff --git a/libc/kernel/arch-x86/asm/segment.h b/libc/kernel/arch-x86/asm/segment.h
index eeb7a1c..145e21d 100644
--- a/libc/kernel/arch-x86/asm/segment.h
+++ b/libc/kernel/arch-x86/asm/segment.h
@@ -16,4 +16,4 @@
  ***
  ****************************************************************************
  ****************************************************************************/
-#include "segment_64.h"
+#include "segment_32.h"
diff --git a/libc/kernel/arch-x86/asm/semaphore.h b/libc/kernel/arch-x86/asm/semaphore.h
index 6ee8244..7a2223e 100644
--- a/libc/kernel/arch-x86/asm/semaphore.h
+++ b/libc/kernel/arch-x86/asm/semaphore.h
@@ -16,4 +16,4 @@
  ***
  ****************************************************************************
  ****************************************************************************/
-#include "semaphore_64.h"
+#include "semaphore_32.h"
diff --git a/libc/kernel/arch-x86/asm/shmbuf.h b/libc/kernel/arch-x86/asm/shmbuf.h
index 81cce3e..5ecfe08 100644
--- a/libc/kernel/arch-x86/asm/shmbuf.h
+++ b/libc/kernel/arch-x86/asm/shmbuf.h
@@ -23,39 +23,32 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  size_t shm_segsz;
  __kernel_time_t shm_atime;
-#ifdef __i386__
  unsigned long __unused1;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#endif
  __kernel_time_t shm_dtime;
-#ifdef __i386__
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  unsigned long __unused2;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#endif
  __kernel_time_t shm_ctime;
-#ifdef __i386__
  unsigned long __unused3;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#endif
  __kernel_pid_t shm_cpid;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  __kernel_pid_t shm_lpid;
  unsigned long shm_nattch;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  unsigned long __unused4;
  unsigned long __unused5;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 struct shminfo64 {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  unsigned long shmmax;
  unsigned long shmmin;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  unsigned long shmmni;
  unsigned long shmseg;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  unsigned long shmall;
  unsigned long __unused1;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  unsigned long __unused2;
  unsigned long __unused3;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  unsigned long __unused4;
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #endif
diff --git a/libc/kernel/arch-x86/asm/sigcontext.h b/libc/kernel/arch-x86/asm/sigcontext.h
index b0b5fd4..390189f 100644
--- a/libc/kernel/arch-x86/asm/sigcontext.h
+++ b/libc/kernel/arch-x86/asm/sigcontext.h
@@ -21,130 +21,73 @@
 #include <linux/compiler.h>
 #include <asm/types.h>
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#ifdef __i386__
 struct _fpreg {
  unsigned short significand[4];
  unsigned short exponent;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct _fpxreg {
  unsigned short significand[4];
  unsigned short exponent;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  unsigned short padding[3];
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 struct _xmmreg {
  unsigned long element[4];
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct _fpstate {
  unsigned long cw;
  unsigned long sw;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  unsigned long tag;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  unsigned long ipoff;
  unsigned long cssel;
  unsigned long dataoff;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  unsigned long datasel;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  struct _fpreg _st[8];
  unsigned short status;
  unsigned short magic;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  unsigned long _fxsr_env[6];
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  unsigned long mxcsr;
  unsigned long reserved;
  struct _fpxreg _fxsr_st[8];
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  struct _xmmreg _xmm[8];
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  unsigned long padding[56];
 };
 #define X86_FXSR_MAGIC 0x0000
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct sigcontext {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  unsigned short gs, __gsh;
  unsigned short fs, __fsh;
  unsigned short es, __esh;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  unsigned short ds, __dsh;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  unsigned long edi;
  unsigned long esi;
  unsigned long ebp;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  unsigned long esp;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  unsigned long ebx;
  unsigned long edx;
  unsigned long ecx;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  unsigned long eax;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  unsigned long trapno;
  unsigned long err;
  unsigned long eip;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  unsigned short cs, __csh;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  unsigned long eflags;
  unsigned long esp_at_signal;
  unsigned short ss, __ssh;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  struct _fpstate __user * fpstate;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  unsigned long oldmask;
  unsigned long cr2;
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#else
-struct _fpstate {
- __u16 cwd;
- __u16 swd;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
- __u16 twd;
- __u16 fop;
- __u64 rip;
- __u64 rdp;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
- __u32 mxcsr;
- __u32 mxcsr_mask;
- __u32 st_space[32];
- __u32 xmm_space[64];
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
- __u32 reserved2[24];
-};
-struct sigcontext {
- unsigned long r8;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
- unsigned long r9;
- unsigned long r10;
- unsigned long r11;
- unsigned long r12;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
- unsigned long r13;
- unsigned long r14;
- unsigned long r15;
- unsigned long rdi;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
- unsigned long rsi;
- unsigned long rbp;
- unsigned long rbx;
- unsigned long rdx;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
- unsigned long rax;
- unsigned long rcx;
- unsigned long rsp;
- unsigned long rip;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
- unsigned long eflags;
- unsigned short cs;
- unsigned short gs;
- unsigned short fs;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
- unsigned short __pad0;
- unsigned long err;
- unsigned long trapno;
- unsigned long oldmask;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
- unsigned long cr2;
- struct _fpstate __user *fpstate;
- unsigned long reserved1[8];
-};
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #endif
-#endif
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/arch-x86/asm/signal.h b/libc/kernel/arch-x86/asm/signal.h
index a15028c..1c8f2f6 100644
--- a/libc/kernel/arch-x86/asm/signal.h
+++ b/libc/kernel/arch-x86/asm/signal.h
@@ -93,35 +93,20 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #include <asm-generic/signal.h>
 #ifndef __ASSEMBLY__
-#ifdef __i386__
 struct sigaction {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  union {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  __sighandler_t _sa_handler;
  void (*_sa_sigaction)(int, struct siginfo *, void *);
  } _u;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  sigset_t sa_mask;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  unsigned long sa_flags;
  void (*sa_restorer)(void);
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define sa_handler _u._sa_handler
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define sa_sigaction _u._sa_sigaction
-#else
-struct sigaction {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
- __sighandler_t sa_handler;
- unsigned long sa_flags;
- __sigrestore_t sa_restorer;
- sigset_t sa_mask;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-};
-struct k_sigaction {
- struct sigaction sa;
-};
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#endif
 typedef struct sigaltstack {
  void __user *ss_sp;
  int ss_flags;
diff --git a/libc/kernel/arch-x86/asm/smp.h b/libc/kernel/arch-x86/asm/smp.h
index c69e3ef..4e439d5 100644
--- a/libc/kernel/arch-x86/asm/smp.h
+++ b/libc/kernel/arch-x86/asm/smp.h
@@ -16,4 +16,4 @@
  ***
  ****************************************************************************
  ****************************************************************************/
-#include "smp_64.h"
+#include "smp_32.h"
diff --git a/libc/kernel/arch-x86/asm/spinlock.h b/libc/kernel/arch-x86/asm/spinlock.h
index 4c0f30e..286bf86 100644
--- a/libc/kernel/arch-x86/asm/spinlock.h
+++ b/libc/kernel/arch-x86/asm/spinlock.h
@@ -16,4 +16,4 @@
  ***
  ****************************************************************************
  ****************************************************************************/
-#include "spinlock_64.h"
+#include "spinlock_32.h"
diff --git a/libc/kernel/arch-x86/asm/stat.h b/libc/kernel/arch-x86/asm/stat.h
index a4ccbe8..3878c88 100644
--- a/libc/kernel/arch-x86/asm/stat.h
+++ b/libc/kernel/arch-x86/asm/stat.h
@@ -19,111 +19,73 @@
 #ifndef _ASM_X86_STAT_H
 #define _ASM_X86_STAT_H
 #define STAT_HAVE_NSEC 1
-#ifdef __i386__
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct stat {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  unsigned long st_dev;
  unsigned long st_ino;
  unsigned short st_mode;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  unsigned short st_nlink;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  unsigned short st_uid;
  unsigned short st_gid;
  unsigned long st_rdev;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  unsigned long st_size;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  unsigned long st_blksize;
  unsigned long st_blocks;
  unsigned long st_atime;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  unsigned long st_atime_nsec;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  unsigned long st_mtime;
  unsigned long st_mtime_nsec;
  unsigned long st_ctime;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  unsigned long st_ctime_nsec;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  unsigned long __unused4;
  unsigned long __unused5;
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define STAT64_HAS_BROKEN_ST_INO 1
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct stat64 {
  unsigned long long st_dev;
  unsigned char __pad0[4];
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  unsigned long __st_ino;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  unsigned int st_mode;
  unsigned int st_nlink;
  unsigned long st_uid;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  unsigned long st_gid;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  unsigned long long st_rdev;
  unsigned char __pad3[4];
  long long st_size;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  unsigned long st_blksize;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  unsigned long long st_blocks;
  unsigned long st_atime;
  unsigned long st_atime_nsec;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  unsigned long st_mtime;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  unsigned int st_mtime_nsec;
  unsigned long st_ctime;
  unsigned long st_ctime_nsec;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  unsigned long long st_ino;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
-#else
-struct stat {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
- unsigned long st_dev;
- unsigned long st_ino;
- unsigned long st_nlink;
- unsigned int st_mode;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
- unsigned int st_uid;
- unsigned int st_gid;
- unsigned int __pad0;
- unsigned long st_rdev;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
- long st_size;
- long st_blksize;
- long st_blocks;
- unsigned long st_atime;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
- unsigned long st_atime_nsec;
- unsigned long st_mtime;
- unsigned long st_mtime_nsec;
- unsigned long st_ctime;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
- unsigned long st_ctime_nsec;
- long __unused[3];
-};
-#endif
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct __old_kernel_stat {
  unsigned short st_dev;
  unsigned short st_ino;
- unsigned short st_mode;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+ unsigned short st_mode;
  unsigned short st_nlink;
  unsigned short st_uid;
  unsigned short st_gid;
- unsigned short st_rdev;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#ifdef __i386__
+ unsigned short st_rdev;
  unsigned long st_size;
  unsigned long st_atime;
  unsigned long st_mtime;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  unsigned long st_ctime;
-#else
- unsigned int st_size;
- unsigned int st_atime;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
- unsigned int st_mtime;
- unsigned int st_ctime;
-#endif
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #endif
diff --git a/libc/kernel/arch-x86/asm/statfs.h b/libc/kernel/arch-x86/asm/statfs.h
index f137d17..7472605 100644
--- a/libc/kernel/arch-x86/asm/statfs.h
+++ b/libc/kernel/arch-x86/asm/statfs.h
@@ -18,58 +18,6 @@
  ****************************************************************************/
 #ifndef _ASM_X86_STATFS_H
 #define _ASM_X86_STATFS_H
-#ifdef __i386__
 #include <asm-generic/statfs.h>
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#else
-struct statfs {
- long f_type;
- long f_bsize;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
- long f_blocks;
- long f_bfree;
- long f_bavail;
- long f_files;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
- long f_ffree;
- __kernel_fsid_t f_fsid;
- long f_namelen;
- long f_frsize;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
- long f_spare[5];
-};
-struct statfs64 {
- long f_type;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
- long f_bsize;
- long f_blocks;
- long f_bfree;
- long f_bavail;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
- long f_files;
- long f_ffree;
- __kernel_fsid_t f_fsid;
- long f_namelen;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
- long f_frsize;
- long f_spare[5];
-};
-struct compat_statfs64 {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
- __u32 f_type;
- __u32 f_bsize;
- __u64 f_blocks;
- __u64 f_bfree;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
- __u64 f_bavail;
- __u64 f_files;
- __u64 f_ffree;
- __kernel_fsid_t f_fsid;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
- __u32 f_namelen;
- __u32 f_frsize;
- __u32 f_spare[5];
-} __attribute__((packed));
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #endif
-#endif
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/libc/kernel/arch-x86/asm/string.h b/libc/kernel/arch-x86/asm/string.h
index e6cda34..874b2f0 100644
--- a/libc/kernel/arch-x86/asm/string.h
+++ b/libc/kernel/arch-x86/asm/string.h
@@ -16,4 +16,4 @@
  ***
  ****************************************************************************
  ****************************************************************************/
-#include "string_64.h"
+#include "string_32.h"
diff --git a/libc/kernel/arch-x86/asm/system.h b/libc/kernel/arch-x86/asm/system.h
index e4faf67..12767cd 100644
--- a/libc/kernel/arch-x86/asm/system.h
+++ b/libc/kernel/arch-x86/asm/system.h
@@ -16,4 +16,4 @@
  ***
  ****************************************************************************
  ****************************************************************************/
-#include "system_64.h"
+#include "system_32.h"
diff --git a/libc/kernel/arch-x86/asm/thread_info.h b/libc/kernel/arch-x86/asm/thread_info.h
index 05d12e4..d15e362 100644
--- a/libc/kernel/arch-x86/asm/thread_info.h
+++ b/libc/kernel/arch-x86/asm/thread_info.h
@@ -16,4 +16,4 @@
  ***
  ****************************************************************************
  ****************************************************************************/
-#include "thread_info_64.h"
+#include "thread_info_32.h"
diff --git a/libc/kernel/arch-x86/asm/tlbflush.h b/libc/kernel/arch-x86/asm/tlbflush.h
index fa924b6..fd576df 100644
--- a/libc/kernel/arch-x86/asm/tlbflush.h
+++ b/libc/kernel/arch-x86/asm/tlbflush.h
@@ -16,4 +16,4 @@
  ***
  ****************************************************************************
  ****************************************************************************/
-#include "tlbflush_64.h"
+#include "tlbflush_32.h"
diff --git a/libc/kernel/arch-x86/asm/types.h b/libc/kernel/arch-x86/asm/types.h
index f5aa99e..b71d89b 100644
--- a/libc/kernel/arch-x86/asm/types.h
+++ b/libc/kernel/arch-x86/asm/types.h
@@ -28,17 +28,11 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 typedef __signed__ int __s32;
 typedef unsigned int __u32;
-#ifdef __i386__
 #ifdef __GNUC__
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 __extension__ typedef __signed__ long long __s64;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 __extension__ typedef unsigned long long __u64;
 #endif
-#else
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-typedef __signed__ long long __s64;
-typedef unsigned long long __u64;
 #endif
 #endif
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#endif
diff --git a/libc/kernel/arch-x86/asm/uaccess.h b/libc/kernel/arch-x86/asm/uaccess.h
index 124e7e1..b167f6d 100644
--- a/libc/kernel/arch-x86/asm/uaccess.h
+++ b/libc/kernel/arch-x86/asm/uaccess.h
@@ -16,4 +16,4 @@
  ***
  ****************************************************************************
  ****************************************************************************/
-#include "uaccess_64.h"
+#include "uaccess_32.h"
diff --git a/libc/kernel/arch-x86/asm/unistd.h b/libc/kernel/arch-x86/asm/unistd.h
index 3c55d9a..d109f5f 100644
--- a/libc/kernel/arch-x86/asm/unistd.h
+++ b/libc/kernel/arch-x86/asm/unistd.h
@@ -16,9 +16,4 @@
  ***
  ****************************************************************************
  ****************************************************************************/
-#ifdef __i386__
 #include "unistd_32.h"
-#else
-#include "unistd_64.h"
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#endif
diff --git a/libc/kernel/arch-x86/asm/user.h b/libc/kernel/arch-x86/asm/user.h
index 0d655d1..054182e 100644
--- a/libc/kernel/arch-x86/asm/user.h
+++ b/libc/kernel/arch-x86/asm/user.h
@@ -16,9 +16,4 @@
  ***
  ****************************************************************************
  ****************************************************************************/
-#ifdef __i386__
 #include "user_32.h"
-#else
-#include "user_64.h"
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#endif
diff --git a/libc/kernel/tools/clean_header.py b/libc/kernel/tools/clean_header.py
index 22e62aa..01569fc 100755
--- a/libc/kernel/tools/clean_header.py
+++ b/libc/kernel/tools/clean_header.py
@@ -62,8 +62,11 @@
         sys.stderr.write( "error: can't parse '%s'" % path )
         sys.exit(1)
 
+    macros = kernel_known_macros.copy()
+    if arch and arch in kernel_default_arch_macros:
+        macros.update(kernel_default_arch_macros[arch])
 
-    blocks.optimizeMacros( kernel_known_macros )
+    blocks.optimizeMacros( macros )
     blocks.optimizeIf01()
     blocks.removeVarsAndFuncs( statics )
     blocks.replaceTokens( kernel_token_replacements )
diff --git a/libc/kernel/tools/defaults.py b/libc/kernel/tools/defaults.py
index aa68e7c..7fbed46 100644
--- a/libc/kernel/tools/defaults.py
+++ b/libc/kernel/tools/defaults.py
@@ -44,7 +44,7 @@
 # toolchain preprocessor
 kernel_default_arch_macros = {
     "arm": {},
-    "x86": {"__i386__": "1"},
+    "x86": {"__i386__": "1", "CONFIG_X86_32": "1"},
     }
 
 # Replace tokens in the output according to this mapping