Add x86_64 to the bionic headers.

Manual changes:

  cpp.py: cope with macros that refer to other macros.

  defaults.py: x86 no longer always implies __i386__; use __i386__ to replace
  the kernel CONFIG_X86_32 flag.

  asm/page.h: the upstream page.h isn't a uapi header and no longer includes
  the stuff we were using it for. Let's just have our own static file, since
  it's the same for all our architectures (both 32- and 64-bit).

  sys/select.h: we used to use the various FD_SET-related macros from the
  kernel header files, but they've gone. Adjust by adding trivial equivalent
  definitions.

Automated changes:

  libc/kernel/arch-x86, libc/kernel/common: regenerated from
  external/kernel-headers.

Change-Id: I84fc0ed52dc742e043b4ae300fd3b58ee99b7fcd
diff --git a/libc/kernel/tools/cpp.py b/libc/kernel/tools/cpp.py
index b8aa775..e3a9038 100644
--- a/libc/kernel/tools/cpp.py
+++ b/libc/kernel/tools/cpp.py
@@ -1345,7 +1345,11 @@
                 if macros[name] == kCppUndefinedMacro:
                     return ("int", 0)
                 else:
-                    return ("int", 1)
+                    try:
+                        value = int(macros[name])
+                        return ("int", value)
+                    except:
+                        return ("defined", macros[name])
 
             if kernel_remove_config_macros and name.startswith("CONFIG_"):
                 return ("int", 0)
diff --git a/libc/kernel/tools/defaults.py b/libc/kernel/tools/defaults.py
index da02481..77bfc47 100644
--- a/libc/kernel/tools/defaults.py
+++ b/libc/kernel/tools/defaults.py
@@ -7,7 +7,7 @@
 
 # the list of supported architectures
 #
-kernel_archs = [ 'arm', 'x86', 'mips' ]
+kernel_archs = [ 'arm', 'mips', 'x86' ]
 
 # the list of include directories that belong to the kernel
 # tree. used when looking for sources...
@@ -33,6 +33,7 @@
     "__KERNEL_STRICT_NAMES":"1",
     "__CHECKER__": kCppUndefinedMacro,
     "__CHECK_ENDIAN__": kCppUndefinedMacro,
+    "CONFIG_X86_32": "__i386__",
     }
 
 # define to true if you want to remove all defined(CONFIG_FOO) tests
@@ -44,14 +45,14 @@
 # toolchain preprocessor
 kernel_default_arch_macros = {
     "arm": {},
-    "x86": {"__i386__": "1", "CONFIG_X86_32": "1"},
     "mips": {"CONFIG_32BIT":"1"},
+    "x86": {},
     }
 
 kernel_arch_token_replacements = {
     "arm": {},
-    "x86": {},
     "mips": {"off_t":"__kernel_off_t"},
+    "x86": {},
     }
 # Replace tokens in the output according to this mapping
 kernel_token_replacements = {
@@ -63,13 +64,7 @@
 # in the final ARM headers. this is only used to keep optimized byteswapping
 # static functions and stuff like that.
 kernel_known_arm_statics = set(
-       [ "___arch__swab32",    # asm-arm/byteorder.h
-       ]
-    )
-
-kernel_known_x86_statics = set(
-        [ "___arch__swab32",  # asm-x86/byteorder.h
-          "___arch__swab64",  # asm-x86/byteorder.h
+        [ "___arch__swab32",    # asm-arm/byteorder.h
         ]
     )
 
@@ -78,6 +73,12 @@
         ]
     )
 
+kernel_known_x86_statics = set(
+        [ "___arch__swab32",  # asm-x86/byteorder.h
+          "___arch__swab64",  # asm-x86/byteorder.h
+        ]
+    )
+
 kernel_known_generic_statics = set(
         [ "__invalid_size_argument_for_IOC",  # asm-generic/ioctl.h
           "__cmsg_nxthdr",                    # linux/socket.h
@@ -92,8 +93,8 @@
 #
 kernel_known_statics = {
         "arm" : kernel_known_arm_statics,
+        "mips" : kernel_known_mips_statics,
         "x86" : kernel_known_x86_statics,
-        "mips" : kernel_known_mips_statics
     }
 
 # this is a list of macros which we want to specifically exclude from