[PATCH 7/7] Cygwin: remove miscellaneous 32-bit code

Ken Brown kbrown@cornell.edu
Thu May 26 19:17:40 GMT 2022


Patch attached.
-------------- next part --------------
From d78b3f13a5eca554d50a7c40532f84cafdd1435a Mon Sep 17 00:00:00 2001
From: Ken Brown <kbrown@cornell.edu>
Date: Tue, 24 May 2022 14:26:33 -0400
Subject: [PATCH 7/7] Cygwin: remove miscellaneous 32-bit code

---
 winsup/cygwin/autoload.cc                | 136 -----------------------
 winsup/cygwin/child_info.h               |   4 -
 winsup/cygwin/cpuid.h                    |  23 ----
 winsup/cygwin/cygheap.cc                 |   4 -
 winsup/cygwin/cygmalloc.h                |   2 -
 winsup/cygwin/cygtls.cc                  |   2 -
 winsup/cygwin/cygtls.h                   |   4 -
 winsup/cygwin/dcrt0.cc                   |  19 ----
 winsup/cygwin/dlfcn.cc                   |  23 ----
 winsup/cygwin/dll_init.cc                |  11 --
 winsup/cygwin/external.cc                |   7 --
 winsup/cygwin/fhandler_proc.cc           |   2 -
 winsup/cygwin/fhandler_procnet.cc        |   2 -
 winsup/cygwin/fhandler_socket_inet.cc    |  49 --------
 winsup/cygwin/fhandler_socket_local.cc   |  10 --
 winsup/cygwin/fhandler_socket_unix.cc    |   4 -
 winsup/cygwin/fork.cc                    |   4 -
 winsup/cygwin/gcc_seh.h                  |   2 -
 winsup/cygwin/heap.cc                    |  50 +--------
 winsup/cygwin/hookapi.cc                 |  25 +----
 winsup/cygwin/include/a.out.h            |   7 --
 winsup/cygwin/include/asm/bitsperlong.h  |   4 -
 winsup/cygwin/include/bits/wordsize.h    |   6 +-
 winsup/cygwin/include/cygwin/config.h    |  11 +-
 winsup/cygwin/include/cygwin/signal.h    |  59 ----------
 winsup/cygwin/include/sys/cygwin.h       |   4 -
 winsup/cygwin/include/sys/dirent.h       |  16 ---
 winsup/cygwin/init.cc                    |   3 -
 winsup/cygwin/lib/_cygwin_crt0_common.cc |  11 --
 winsup/cygwin/libstdcxx_wrapper.cc       |   7 --
 winsup/cygwin/miscfuncs.cc               |  96 ----------------
 winsup/cygwin/miscfuncs.h                |   2 -
 winsup/cygwin/mmap.cc                    |  36 ------
 winsup/cygwin/mmap_alloc.cc              |   4 -
 winsup/cygwin/mmap_alloc.h               |   4 -
 winsup/cygwin/net.cc                     |   8 --
 winsup/cygwin/ntdll.h                    |   2 -
 winsup/cygwin/path.cc                    | 102 -----------------
 winsup/cygwin/perprocess.h               |   4 -
 winsup/cygwin/shm.cc                     |   4 -
 winsup/cygwin/sigproc.cc                 |   5 -
 winsup/cygwin/smallprint.cc              |  32 ------
 winsup/cygwin/strsig.cc                  |  14 +--
 winsup/cygwin/sysconf.cc                 |  16 ---
 winsup/cygwin/thread.cc                  |   4 -
 winsup/cygwin/wincap.h                   |   2 -
 winsup/cygwin/winsup.h                   |  10 --
 47 files changed, 12 insertions(+), 844 deletions(-)

diff --git a/winsup/cygwin/autoload.cc b/winsup/cygwin/autoload.cc
index 1f52411d8..18366c600 100644
--- a/winsup/cygwin/autoload.cc
+++ b/winsup/cygwin/autoload.cc
@@ -66,7 +66,6 @@ bool NO_COPY wsock_started;
 /* LoadDLLprime is used to prime the DLL info information, providing an
    additional initialization routine to call prior to calling the first
    function.  */
-#ifdef __x86_64__
 #define LoadDLLprime(dllname, init_also, no_resolve_on_fork) __asm__ ("	\n\
 .ifndef " #dllname "_primed				\n\
   .section	.data_cygwin_nocopy,\"w\"		\n\
@@ -82,22 +81,6 @@ bool NO_COPY wsock_started;
   .set		" #dllname "_primed, 1			\n\
 .endif							\n\
 ");
-#else
-#define LoadDLLprime(dllname, init_also, no_resolve_on_fork) __asm__ ("	\n\
-.ifndef " #dllname "_primed				\n\
-  .section	.data_cygwin_nocopy,\"w\"		\n\
-  .align	4					\n\
-."#dllname "_info:					\n\
-  .long		_std_dll_init				\n\
-  .long		" #no_resolve_on_fork "			\n\
-  .long		-1					\n\
-  .long		" #init_also "				\n\
-  .string16	\"" #dllname ".dll\"			\n\
-  .text							\n\
-  .set		" #dllname "_primed, 1			\n\
-.endif							\n\
-");
-#endif
 
 /* Create a "decorated" name */
 #define mangle(name, n) #name "@" #n
@@ -112,7 +95,6 @@ bool NO_COPY wsock_started;
   LoadDLLfuncEx3(name, n, dllname, notimp, err, 0)
 
 /* Main DLL setup stuff. */
-#ifdef __x86_64__
 #define LoadDLLfuncEx3(name, n, dllname, notimp, err, no_resolve_on_fork) \
   LoadDLLprime (dllname, dll_func_load, no_resolve_on_fork) \
   __asm__ ("						\n\
@@ -137,26 +119,6 @@ _win32_" #name ":					\n\
   .asciz	\"" #name "\"				\n\
   .text							\n\
 ");
-#else
-#define LoadDLLfuncEx3(name, n, dllname, notimp, err, no_resolve_on_fork) \
-  LoadDLLprime (dllname, dll_func_load, no_resolve_on_fork) \
-  __asm__ ("						\n\
-  .section	." #dllname "_autoload_text,\"wx\"	\n\
-  .global	_" mangle (name, n) "			\n\
-  .global	_win32_" mangle (name, n) "		\n\
-  .align	8					\n\
-_" mangle (name, n) ":					\n\
-_win32_" mangle (name, n) ":				\n\
-  .byte		0xe9					\n\
-  .long		-4 + 1f - .				\n\
-1:movl		(2f),%eax				\n\
-   call		*(%eax)					\n\
-2:.long		." #dllname "_info			\n\
-  .long		(" #n "+" #notimp ") | (((" #err ") & 0xff) <<16) \n\
-  .asciz	\"" #name "\"				\n\
-  .text							\n\
-");
-#endif
 
 /* DLL loader helper functions used during initialization. */
 
@@ -172,7 +134,6 @@ extern "C" void dll_chain () __asm__ ("dll_chain");
 
 extern "C" {
 
-#ifdef __x86_64__
 __asm__ ("								\n\
 	 .section .rdata,\"r\"							\n\
 msg1:									\n\
@@ -234,66 +195,6 @@ dll_chain:								\n\
 	push	%rax		# Restore 'return address'		\n\
 	jmp	*%rdx		# Jump to next init function		\n\
 ");
-#else
-__asm__ ("								\n\
-	 .text								\n\
-msg1:									\n\
-	.ascii	\"couldn't dynamically determine load address for '%s' (handle %p), %E\\0\"\n\
-									\n\
-	.align	32							\n\
-noload:									\n\
-	popl	%edx		# Get the address of the information block\n\
-	movl	4(%edx),%eax	# Should we 'ignore' the lack		\n\
-	test	$1,%eax		#  of this function?			\n\
-	jz	1f		# Nope.					\n\
-	decl	%eax		# Yes.  This is the # of bytes + 1	\n\
-	popl	%edx		# Caller's caller			\n\
-	addl	%eax,%esp	# Pop off bytes				\n\
-	andl	$0xffff0000,%eax# upper word				\n\
-	subl	%eax,%esp	# adjust for possible return value	\n\
-	pushl	%eax		# Save return value for later		\n\
-	pushl	%edx		# Save return address for later		\n\
-	movl	$127,%eax	# ERROR_PROC_NOT_FOUND			\n\
-	pushl	%eax		# First argument			\n\
-	call	_SetLastError@4	# Set it				\n\
-	popl	%edx		# Get back return address		\n\
-	popl	%eax		# Get back return value			\n\
-	sarl	$16,%eax	# return value in high order word	\n\
-	jmp	*%edx		# Return				\n\
-1:									\n\
-	movl	(%edx),%eax	# Handle value				\n\
-	pushl	4(%eax)							\n\
-	leal	8(%edx),%eax	# Location of name of function		\n\
-	pushl	%eax							\n\
-	pushl	$msg1		# The message				\n\
-	call	_api_fatal	# Print message. Never returns		\n\
-									\n\
-	.globl	dll_func_load						\n\
-dll_func_load:								\n\
-	movl	(%esp),%eax	# 'Return address' contains load info	\n\
-	addl	$8,%eax		# Address of name of function to load	\n\
-	pushl	%eax		# Second argument			\n\
-	movl	-8(%eax),%eax	# Where handle lives			\n\
-	movl	4(%eax),%eax	# Address of Handle to DLL		\n\
-	pushl	%eax		# Handle to DLL				\n\
-	call	_GetProcAddress@8# Load it				\n\
-	test	%eax,%eax	# Success?				\n\
-	jne	gotit		# Yes					\n\
-	jmp	noload		# Issue an error or return		\n\
-gotit:									\n\
-	popl	%edx		# Pointer to 'return address'		\n\
-	subl	%edx,%eax	# Make it relative			\n\
-	addl	$7,%eax		# Tweak					\n\
-	subl	$12,%edx	# Point to jmp				\n\
-	movl	%eax,1(%edx)	# Move relative address after jump	\n\
-	jmp	*%edx		# Jump to actual function		\n\
-									\n\
-	.global	dll_chain						\n\
-dll_chain:								\n\
-	pushl	%eax		# Restore 'return address'		\n\
-	jmp	*%edx		# Jump to next init function		\n\
-");
-#endif
 
 /* C representations of the two info blocks described above.
    FIXME: These structures confuse gdb for some reason.  GDB can print
@@ -311,18 +212,12 @@ struct func_info
 {
   struct dll_info *dll;
   LONG decoration;
-#ifdef __x86_64__
   UINT_PTR func_addr;
-#endif
   char name[];
 };
 
 /* Mechanism for setting up info for passing to dll_chain routines. */
-#ifdef __x86_64__
 typedef __uint128_t two_addr_t;
-#else
-typedef __uint64_t two_addr_t;
-#endif
 union retchain
 {
   struct {uintptr_t high; uintptr_t low;};
@@ -354,7 +249,6 @@ dll_load (HANDLE& handle, PWCHAR name)
 #define RETRY_COUNT 10
 
 /* The standard DLL initialization routine. */
-#ifdef __x86_64__
 
 /* On x86_64, we need assembler wrappers for std_dll_init and wsock_init.
    In the x86_64 ABI it's no safe bet that frame[1] (aka 8(%rbp)) contains
@@ -396,14 +290,7 @@ INIT_WRAPPER (std_dll_init)
 
 __attribute__ ((used, noinline)) static two_addr_t
 std_dll_init (struct func_info *func)
-#else
-__attribute__ ((used, noinline)) static two_addr_t
-std_dll_init ()
-#endif
 {
-#ifdef __i386__
-  struct func_info *func = (struct func_info *) __builtin_return_address (0);
-#endif
   struct dll_info *dll = func->dll;
   retchain ret;
 
@@ -452,37 +339,22 @@ std_dll_init ()
   ret.high = (uintptr_t) func;
 
   InterlockedDecrement (&dll->here);
-
-#ifdef __i386__
-  /* Kludge alert.  Redirects the return address to dll_chain. */
-  uintptr_t *volatile frame = (uintptr_t *) __builtin_frame_address (0);
-  frame[1] = (uintptr_t) dll_chain;
-#endif
-
   return ret.ll;
 }
 
 /* Initialization function for winsock stuff. */
 
-#ifdef __x86_64__
 /* See above comment preceeding std_dll_init. */
 INIT_WRAPPER (wsock_init)
 
 __attribute__ ((used, noinline)) static two_addr_t
 wsock_init (struct func_info *func)
-#else
-__attribute__ ((used, noinline)) static two_addr_t
-wsock_init ()
-#endif
 {
   /* CV 2016-03-09: Moved wsadata into wsock_init to workaround a problem
      with the NO_COPY definition of wsadata and here starting with gcc-5.3.0.
      See the git log for a description. */
   static WSADATA NO_COPY wsadata;
   static LONG NO_COPY here = -1L;
-#ifdef __i386__
-  struct func_info *func = (struct func_info *) __builtin_return_address (0);
-#endif
   struct dll_info *dll = func->dll;
 
   while (InterlockedIncrement (&here))
@@ -513,15 +385,7 @@ wsock_init ()
 	  wsock_started = 1;
 	}
     }
-
-#ifdef __i386__
-  /* Kludge alert.  Redirects the return address to dll_chain. */
-  uintptr_t *volatile frame = (uintptr_t *) __builtin_frame_address (0);
-  frame[1] = (uintptr_t) dll_chain;
-#endif
-
   InterlockedDecrement (&here);
-
   volatile retchain ret;
   /* Set "arguments for dll_chain. */
   ret.low = (uintptr_t) dll_func_load;
diff --git a/winsup/cygwin/child_info.h b/winsup/cygwin/child_info.h
index 8a8ca2563..453339317 100644
--- a/winsup/cygwin/child_info.h
+++ b/winsup/cygwin/child_info.h
@@ -28,11 +28,7 @@ enum child_status
 #define OPROC_MAGIC_MASK 0xff00ff00
 #define OPROC_MAGIC_GENERIC 0xaf00f000
 
-#ifdef __x86_64__
 #define PROC_MAGIC_GENERIC 0xaf00fa64
-#else /*!x86_64*/
-#define PROC_MAGIC_GENERIC 0xaf00fa32
-#endif
 
 #define EXEC_MAGIC_SIZE sizeof(child_info)
 
diff --git a/winsup/cygwin/cpuid.h b/winsup/cygwin/cpuid.h
index 18d920955..bd903733d 100644
--- a/winsup/cygwin/cpuid.h
+++ b/winsup/cygwin/cpuid.h
@@ -18,7 +18,6 @@ cpuid (uint32_t *a, uint32_t *b, uint32_t *c, uint32_t *d, uint32_t ain,
 		: "a" (ain), "c" (cin));
 }
 
-#ifdef __x86_64__
 static inline bool __attribute ((always_inline))
 can_set_flag (uint32_t long flag)
 {
@@ -39,27 +38,5 @@ can_set_flag (uint32_t long flag)
   );
   return ((r1 ^ r2) & flag) != 0;
 }
-#else
-static inline bool __attribute ((always_inline))
-can_set_flag (uint32_t flag)
-{
-  uint32_t r1, r2;
-
-  asm volatile ("pushfl\n"
-		"popl %0\n"
-		"movl %0, %1\n"
-		"xorl %2, %0\n"
-		"pushl %0\n"
-		"popfl\n"
-		"pushfl\n"
-		"popl %0\n"
-		"pushl %1\n"
-		"popfl\n"
-		: "=&r" (r1), "=&r" (r2)
-		: "ir" (flag)
-  );
-  return ((r1 ^ r2) & flag) != 0;
-}
-#endif
 
 #endif // !CPUID_H
diff --git a/winsup/cygwin/cygheap.cc b/winsup/cygwin/cygheap.cc
index 465a9bcdd..6e9b393f9 100644
--- a/winsup/cygwin/cygheap.cc
+++ b/winsup/cygwin/cygheap.cc
@@ -252,11 +252,7 @@ cygheap_init ()
 	 The idea is to have better matching bucket sizes (not wasting
 	 space) without trading in performance compared to the old powers
 	 of 2 method. */
-#ifdef __x86_64__
       unsigned sz[2] = { 16, 24 };	/* sizeof cygheap_entry == 16 */
-#else
-      unsigned sz[2] = { 8, 12 };	/* sizeof cygheap_entry == 8 */
-#endif
       for (unsigned b = 1; b < NBUCKETS; b++, sz[b & 1] <<= 1)
 	cygheap->bucket_val[b] = sz[b & 1];
       /* Default locale settings. */
diff --git a/winsup/cygwin/cygmalloc.h b/winsup/cygwin/cygmalloc.h
index 9095f9b4a..73a2f060b 100644
--- a/winsup/cygwin/cygmalloc.h
+++ b/winsup/cygwin/cygmalloc.h
@@ -21,9 +21,7 @@ int dlmalloc_trim (size_t);
 int dlmallopt (int p, int v);
 void dlmalloc_stats ();
 
-#ifdef __x86_64__
 #define MALLOC_ALIGNMENT ((size_t)16U)
-#endif
 
 #if defined (DLMALLOC_VERSION)	/* Building malloc.cc */
 
diff --git a/winsup/cygwin/cygtls.cc b/winsup/cygwin/cygtls.cc
index c0ee645e0..866342613 100644
--- a/winsup/cygwin/cygtls.cc
+++ b/winsup/cygwin/cygtls.cc
@@ -147,11 +147,9 @@ _cygtls::cleanup_early (struct _reent *)
   /* Do nothing */
 }
 
-#ifdef __x86_64__
 void san::leave ()
 {
   /* Restore tls_pathbuf counters in case of error. */
   _my_tls.locals.pathbufs._counters = _cnt;
   _my_tls.andreas = _clemente;
 }
-#endif
diff --git a/winsup/cygwin/cygtls.h b/winsup/cygwin/cygtls.h
index d2230a493..b265978f0 100644
--- a/winsup/cygwin/cygtls.h
+++ b/winsup/cygwin/cygtls.h
@@ -37,11 +37,7 @@ details. */
 #include "thread.h"
 #endif
 
-#ifdef __x86_64__
 #pragma pack(push,8)
-#else
-#pragma pack(push,4)
-#endif
 
 /* Defined here to support auto rebuild of tlsoffsets.h. */
 class tls_pathbuf
diff --git a/winsup/cygwin/dcrt0.cc b/winsup/cygwin/dcrt0.cc
index b846cc5bb..9cc436cda 100644
--- a/winsup/cygwin/dcrt0.cc
+++ b/winsup/cygwin/dcrt0.cc
@@ -390,14 +390,6 @@ check_sanity_and_sync (per_process *p)
   if (p->api_major > cygwin_version.api_major)
     api_fatal ("cygwin DLL and APP are out of sync -- API version mismatch %u > %u",
 	       p->api_major, cygwin_version.api_major);
-
-#ifdef __i386__
-  /* This is a kludge to work around a version of _cygwin_common_crt0
-     which overwrote the cxx_malloc field with the local DLL copy.
-     Hilarity ensues if the DLL is not loaded while the process
-     is forking. */
-  __cygwin_user_data.cxx_malloc = &default_cygwin_cxx_malloc;
-#endif
 }
 
 child_info NO_COPY *child_proc_info;
@@ -581,17 +573,10 @@ get_cygwin_startup_info ()
   return res;
 }
 
-#ifdef __x86_64__
 #define dll_data_start &__data_start__
 #define dll_data_end &__data_end__
 #define dll_bss_start &__bss_start__
 #define dll_bss_end &__bss_end__
-#else
-#define dll_data_start &_data_start__
-#define dll_data_end &_data_end__
-#define dll_bss_start &_bss_start__
-#define dll_bss_end &_bss_end__
-#endif
 
 void
 child_info_fork::handle_fork ()
@@ -791,10 +776,8 @@ dll_crt0_0 ()
   if (!dynamically_loaded)
     sigproc_init ();
 
-#ifdef __x86_64__
   /* See comment preceeding myfault_altstack_handler in exception.cc. */
   AddVectoredContinueHandler (0, myfault_altstack_handler);
-#endif
 
   debug_printf ("finished dll_crt0_0 initialization");
 }
@@ -1221,7 +1204,6 @@ cygwin_atexit (void (*fn) (void))
   int res;
 
   dll *d = dlls.find ((void *) _my_tls.retaddr ());
-#ifdef __x86_64__
   /* x86_64 DLLs created with GCC 4.8.3-3 register __gcc_deregister_frame
      as atexit function using a call to atexit, rather than __cxa_atexit.
      Due to GCC's tail call optimizing, cygwin_atexit doesn't get the correct
@@ -1243,7 +1225,6 @@ cygwin_atexit (void (*fn) (void))
      use the statically linked atexit function though, as outlined above. */
   if (!d)
     d = dlls.find ((void *) fn);
-#endif
   res = d ? __cxa_atexit ((void (*) (void *)) fn, NULL, d->handle) : atexit (fn);
   return res;
 }
diff --git a/winsup/cygwin/dlfcn.cc b/winsup/cygwin/dlfcn.cc
index 9a7472850..fb7052473 100644
--- a/winsup/cygwin/dlfcn.cc
+++ b/winsup/cygwin/dlfcn.cc
@@ -272,24 +272,6 @@ dlopen (const char *name, int flags)
 	    break;
 	}
 
-#ifdef __i386__
-      /* Workaround for broken DLLs built against Cygwin versions 1.7.0-49
-	 up to 1.7.0-57.  They override the cxx_malloc pointer in their
-	 DLL initialization code even if loaded dynamically.  This is a
-	 no-no since a later dlclose lets cxx_malloc point into nirvana.
-	 The below kludge "fixes" that by reverting the original cxx_malloc
-	 pointer after LoadLibrary.  This implies that their overrides
-	 won't be applied; that's OK.  All overrides should be present at
-	 final link time, as Windows doesn't allow undefined references;
-	 it would actually be wrong for a dlopen'd DLL to opportunistically
-	 override functions in a way that wasn't known then.  We're not
-	 going to try and reproduce the full ELF dynamic loader here!  */
-
-      /* Store original cxx_malloc pointer. */
-      struct per_process_cxx_malloc *tmp_malloc;
-      tmp_malloc = __cygwin_user_data.cxx_malloc;
-#endif
-
       ret = (void *) LoadLibraryW (wpath);
       /* reference counting */
       if (ret)
@@ -299,11 +281,6 @@ dlopen (const char *name, int flags)
 	    ++d->count;
 	}
 
-#ifdef __i386__
-      /* Restore original cxx_malloc pointer. */
-      __cygwin_user_data.cxx_malloc = tmp_malloc;
-#endif
-
       if (ret && gmheflags)
 	GetModuleHandleExW (gmheflags, wpath, (HMODULE *) &ret);
 
diff --git a/winsup/cygwin/dll_init.cc b/winsup/cygwin/dll_init.cc
index 24e3b8764..649af1153 100644
--- a/winsup/cygwin/dll_init.cc
+++ b/winsup/cygwin/dll_init.cc
@@ -873,17 +873,6 @@ dll_dllcrt0_1 (VOID *x)
     res = (PVOID) d;
 }
 
-#ifdef __i386__
-/* OBSOLETE: This function is obsolete and will go away in the
-   future.  Cygwin can now handle being loaded from a noncygwin app
-   using the same entry point. */
-extern "C" int
-dll_noncygwin_dllcrt0 (HMODULE h, per_process *p)
-{
-  return (int) dll_dllcrt0 (h, p);
-}
-#endif /* __i386__ */
-
 extern "C" void
 cygwin_detach_dll (dll *)
 {
diff --git a/winsup/cygwin/external.cc b/winsup/cygwin/external.cc
index f65ac2650..a9a5b6432 100644
--- a/winsup/cygwin/external.cc
+++ b/winsup/cygwin/external.cc
@@ -246,13 +246,6 @@ cygwin_internal (cygwin_getinfo_types t, ...)
 	break;
 
       case CW_USER_DATA:
-#ifdef __i386__
-	/* This is a kludge to work around a version of _cygwin_common_crt0
-	   which overwrote the cxx_malloc field with the local DLL copy.
-	   Hilarity ensues if the DLL is not loaded like while the process
-	   is forking. */
-	__cygwin_user_data.cxx_malloc = &default_cygwin_cxx_malloc;
-#endif
 	res = (uintptr_t) &__cygwin_user_data;
 	break;
 
diff --git a/winsup/cygwin/fhandler_proc.cc b/winsup/cygwin/fhandler_proc.cc
index b79f31922..24067f687 100644
--- a/winsup/cygwin/fhandler_proc.cc
+++ b/winsup/cygwin/fhandler_proc.cc
@@ -1104,9 +1104,7 @@ format_proc_cpuinfo (void *, char *&destbuf)
 	  ftcprint (features2, 12, "acc_power"); /* accum power */
 	}
 
-#if __x86_64__
       ftuprint ("nopl");	/* NOPL (0F 1F) instructions */
-#endif
 
 /* cpuid 0x0000000b ecx[8:15] type */
 #define BAD_TYPE    0
diff --git a/winsup/cygwin/fhandler_procnet.cc b/winsup/cygwin/fhandler_procnet.cc
index 937353bde..d512887d5 100644
--- a/winsup/cygwin/fhandler_procnet.cc
+++ b/winsup/cygwin/fhandler_procnet.cc
@@ -9,13 +9,11 @@ details. */
 #define  __INSIDE_CYGWIN_NET__
 #define USE_SYS_TYPES_FD_SET
 #include "winsup.h"
-#ifdef __x86_64__
 /* 2014-04-24: Current Mingw headers define sockaddr_in6 using u_long (8 byte)
    because a redefinition for LP64 systems is missing.  This leads to a wrong
    definition and size of sockaddr_in6 when building with winsock headers. */
 #undef u_long
 #define u_long __ms_u_long
-#endif
 #include <w32api/ws2tcpip.h>
 #include <w32api/iphlpapi.h>
 #include <asm/byteorder.h>
diff --git a/winsup/cygwin/fhandler_socket_inet.cc b/winsup/cygwin/fhandler_socket_inet.cc
index 6339052fb..2ffe4917f 100644
--- a/winsup/cygwin/fhandler_socket_inet.cc
+++ b/winsup/cygwin/fhandler_socket_inet.cc
@@ -12,7 +12,6 @@
 #define USE_SYS_TYPES_FD_SET
 
 #include "winsup.h"
-#ifdef __x86_64__
 /* 2014-04-24: Current Mingw headers define sockaddr_in6 using u_long (8 byte)
    because a redefinition for LP64 systems is missing.  This leads to a wrong
    definition and size of sockaddr_in6 when building with winsock headers.
@@ -20,7 +19,6 @@
    function calls. */
 #undef u_long
 #define u_long __ms_u_long
-#endif
 #include <w32api/ws2tcpip.h>
 #include <w32api/mswsock.h>
 #include <w32api/mstcpip.h>
@@ -696,13 +694,8 @@ fhandler_socket_wsock::set_socket_handle (SOCKET sock, int af, int type,
 	debug_printf ("Reset SIO_UDP_CONNRESET: WinSock error %u",
 		      WSAGetLastError ());
     }
-#ifdef __x86_64__
   rmem () = 212992;
   wmem () = 212992;
-#else
-  rmem () = 64512;
-  wmem () = 64512;
-#endif
   return 0;
 }
 
@@ -1147,12 +1140,8 @@ fhandler_socket_inet::recv_internal (LPWSAMSG wsamsg, bool use_recvmsg)
     if ((wsamsg->dwFlags & MSG_OOB) || oobinline)
       {
 	u_long atmark = 0;
-#ifdef __x86_64__
 	/* SIOCATMARK = _IOR('s',7,u_long) */
 	int err = ::ioctlsocket (get_socket (), _IOR('s',7,u_long), &atmark);
-#else
-	int err = ::ioctlsocket (get_socket (), SIOCATMARK, &atmark);
-#endif
 	if (err)
 	  {
 	    set_winsock_errno ();
@@ -1276,7 +1265,6 @@ fhandler_socket_wsock::recvfrom (void *in_ptr, size_t len, int flags,
 {
   char *ptr = (char *) in_ptr;
 
-#ifdef __x86_64__
   /* size_t is 64 bit, but the len member in WSABUF is 32 bit.
      Split buffer if necessary. */
   DWORD bufcnt = len / UINT32_MAX + ((!len || (len % UINT32_MAX)) ? 1 : 0);
@@ -1293,13 +1281,6 @@ fhandler_socket_wsock::recvfrom (void *in_ptr, size_t len, int flags,
       len -= wsaptr->len;
       ptr += wsaptr->len;
     }
-#else
-  WSABUF wsabuf = { len, ptr };
-  WSAMSG wsamsg = { from, from && fromlen ? *fromlen : 0,
-		    &wsabuf, 1,
-		    { 0, NULL},
-		    (DWORD) flags };
-#endif
   ssize_t ret = recv_internal (&wsamsg, false);
   if (fromlen)
     *fromlen = wsamsg.namelen;
@@ -1371,7 +1352,6 @@ fhandler_socket_wsock::read (void *in_ptr, size_t& len)
 {
   char *ptr = (char *) in_ptr;
 
-#ifdef __x86_64__
   /* size_t is 64 bit, but the len member in WSABUF is 32 bit.
      Split buffer if necessary. */
   DWORD bufcnt = len / UINT32_MAX + ((!len || (len % UINT32_MAX)) ? 1 : 0);
@@ -1385,11 +1365,6 @@ fhandler_socket_wsock::read (void *in_ptr, size_t& len)
       len -= wsaptr->len;
       ptr += wsaptr->len;
     }
-#else
-  WSABUF wsabuf = { len, ptr };
-  WSAMSG wsamsg = { NULL, 0, &wsabuf, 1, { 0,  NULL }, 0 };
-#endif
-
   len = recv_internal (&wsamsg, false);
 }
 
@@ -1539,7 +1514,6 @@ fhandler_socket_inet::sendto (const void *in_ptr, size_t len, int flags,
   if (to && get_inet_addr_inet (to, tolen, &sst, &tolen) == SOCKET_ERROR)
     return SOCKET_ERROR;
 
-#ifdef __x86_64__
   /* size_t is 64 bit, but the len member in WSABUF is 32 bit.
      Split buffer if necessary. */
   DWORD bufcnt = len / UINT32_MAX + ((!len || (len % UINT32_MAX)) ? 1 : 0);
@@ -1556,13 +1530,6 @@ fhandler_socket_inet::sendto (const void *in_ptr, size_t len, int flags,
       len -= wsaptr->len;
       ptr += wsaptr->len;
     }
-#else
-  WSABUF wsabuf = { len, ptr };
-  WSAMSG wsamsg = { to ? (struct sockaddr *) &sst : NULL, tolen,
-		    &wsabuf, 1,
-		    { 0, NULL},
-		    0 };
-#endif
   return send_internal (&wsamsg, flags);
 }
 
@@ -1690,7 +1657,6 @@ fhandler_socket_wsock::write (const void *in_ptr, size_t len)
 {
   char *ptr = (char *) in_ptr;
 
-#ifdef __x86_64__
   /* size_t is 64 bit, but the len member in WSABUF is 32 bit.
      Split buffer if necessary. */
   DWORD bufcnt = len / UINT32_MAX + ((!len || (len % UINT32_MAX)) ? 1 : 0);
@@ -1704,10 +1670,6 @@ fhandler_socket_wsock::write (const void *in_ptr, size_t len)
       len -= wsaptr->len;
       ptr += wsaptr->len;
     }
-#else
-  WSABUF wsabuf = { len, ptr };
-  WSAMSG wsamsg = { NULL, 0, &wsabuf, 1, { 0, NULL }, 0 };
-#endif
   return send_internal (&wsamsg, 0);
 }
 
@@ -2395,9 +2357,7 @@ fhandler_socket_wsock::ioctl (unsigned int cmd, void *p)
        and BSD systems defined as int pointer, so the applications will
        use a type of the expected size.  Hopefully. */
     case FIOASYNC:
-#ifdef __x86_64__
     case _IOW('f', 125, u_long):
-#endif
       res = WSAAsyncSelect (get_socket (), winmsg, WM_ASYNCIO,
 	      *(int *) p ? ASYNC_MASK : 0);
       syscall_printf ("Async I/O on socket %s",
@@ -2408,9 +2368,7 @@ fhandler_socket_wsock::ioctl (unsigned int cmd, void *p)
 	WSAEventSelect (get_socket (), wsock_evt, EVENT_MASK);
       break;
     case FIONREAD:
-#ifdef __x86_64__
     case _IOR('f', 127, u_long):
-#endif
       /* Make sure to use the Winsock definition of FIONREAD. */
       res = ::ioctlsocket (get_socket (), _IOR('f', 127, u_long), (u_long *) p);
       if (res == SOCKET_ERROR)
@@ -2420,11 +2378,9 @@ fhandler_socket_wsock::ioctl (unsigned int cmd, void *p)
     case SIOCATMARK:
       /* Sockets are always non-blocking internally.  So we just note the
 	 state here. */
-#ifdef __x86_64__
       /* Convert the different idea of u_long in the definition of cmd. */
       if (((cmd >> 16) & IOCPARM_MASK) == sizeof (unsigned long))
 	cmd = (cmd & ~(IOCPARM_MASK << 16)) | (sizeof (u_long) << 16);
-#endif
       if (cmd == FIONBIO)
 	{
 	  syscall_printf ("socket is now %sblocking",
@@ -2437,14 +2393,9 @@ fhandler_socket_wsock::ioctl (unsigned int cmd, void *p)
       /* In winsock, the return value of SIOCATMARK is FALSE if
 	 OOB data exists, TRUE otherwise. This is almost opposite
 	 to expectation. */
-#ifdef __x86_64__
       /* SIOCATMARK = _IOR('s',7,u_long) */
       if (cmd == _IOR('s',7,u_long) && !res)
 	*(u_long *)p = !*(u_long *)p;
-#else
-      if (cmd == SIOCATMARK && !res)
-	*(u_long *)p = !*(u_long *)p;
-#endif
       break;
     default:
       res = fhandler_socket::ioctl (cmd, p);
diff --git a/winsup/cygwin/fhandler_socket_local.cc b/winsup/cygwin/fhandler_socket_local.cc
index 249ad0e4b..e4a88169b 100644
--- a/winsup/cygwin/fhandler_socket_local.cc
+++ b/winsup/cygwin/fhandler_socket_local.cc
@@ -12,7 +12,6 @@
 #define USE_SYS_TYPES_FD_SET
 
 #include "winsup.h"
-#ifdef __x86_64__
 /* 2014-04-24: Current Mingw headers define sockaddr_in6 using u_long (8 byte)
    because a redefinition for LP64 systems is missing.  This leads to a wrong
    definition and size of sockaddr_in6 when building with winsock headers.
@@ -20,7 +19,6 @@
    function calls. */
 #undef u_long
 #define u_long __ms_u_long
-#endif
 #include "ntsecapi.h"
 #include <w32api/ws2tcpip.h>
 #include <w32api/mswsock.h>
@@ -1341,7 +1339,6 @@ fhandler_socket_local::sendto (const void *in_ptr, size_t len, int flags,
   if (to && get_inet_addr_local (to, tolen, &sst, &tolen) == SOCKET_ERROR)
     return SOCKET_ERROR;
 
-#ifdef __x86_64__
   /* size_t is 64 bit, but the len member in WSABUF is 32 bit.
      Split buffer if necessary. */
   DWORD bufcnt = len / UINT32_MAX + ((!len || (len % UINT32_MAX)) ? 1 : 0);
@@ -1358,13 +1355,6 @@ fhandler_socket_local::sendto (const void *in_ptr, size_t len, int flags,
       len -= wsaptr->len;
       ptr += wsaptr->len;
     }
-#else
-  WSABUF wsabuf = { len, ptr };
-  WSAMSG wsamsg = { to ? (struct sockaddr *) &sst : NULL, tolen,
-		    &wsabuf, 1,
-		    { 0, NULL},
-		    0 };
-#endif
   return send_internal (&wsamsg, flags);
 }
 
diff --git a/winsup/cygwin/fhandler_socket_unix.cc b/winsup/cygwin/fhandler_socket_unix.cc
index 10b1339c6..55e0432b6 100644
--- a/winsup/cygwin/fhandler_socket_unix.cc
+++ b/winsup/cygwin/fhandler_socket_unix.cc
@@ -2247,14 +2247,10 @@ fhandler_socket_unix::ioctl (unsigned int cmd, void *p)
   switch (cmd)
     {
     case FIOASYNC:
-#ifdef __x86_64__
     case _IOW('f', 125, int):
-#endif
       break;
     case FIONREAD:
-#ifdef __x86_64__
     case _IOR('f', 127, int):
-#endif
     case FIONBIO:
       {
 	const bool was_nonblocking = is_nonblocking ();
diff --git a/winsup/cygwin/fork.cc b/winsup/cygwin/fork.cc
index 912f17274..65f3e051b 100644
--- a/winsup/cygwin/fork.cc
+++ b/winsup/cygwin/fork.cc
@@ -626,11 +626,7 @@ dofork (void **proc, bool *with_forkables)
     ischild = !!setjmp (grouped.ch.jmp);
 
     volatile char * volatile stackp;
-#ifdef __x86_64__
     __asm__ volatile ("movq %%rsp,%0": "=r" (stackp));
-#else
-    __asm__ volatile ("movl %%esp,%0": "=r" (stackp));
-#endif
 
     if (!ischild)
       res = grouped.parent (stackp);
diff --git a/winsup/cygwin/gcc_seh.h b/winsup/cygwin/gcc_seh.h
index fb779ef73..d93c5a239 100644
--- a/winsup/cygwin/gcc_seh.h
+++ b/winsup/cygwin/gcc_seh.h
@@ -8,7 +8,6 @@ details. */
 
 /* From the GCC source file libgcc/unwind-seh.c. */
 
-#ifdef __x86_64__
 #define STATUS_USER_DEFINED		(1U << 29)
 #define GCC_MAGIC			(('G' << 16) | ('C' << 8) | 'C')
 #define GCC_EXCEPTION(TYPE)		\
@@ -16,4 +15,3 @@ details. */
 #define STATUS_GCC_THROW		GCC_EXCEPTION (0)
 #define STATUS_GCC_UNWIND		GCC_EXCEPTION (1)
 #define STATUS_GCC_FORCED		GCC_EXCEPTION (2)
-#endif
diff --git a/winsup/cygwin/heap.cc b/winsup/cygwin/heap.cc
index 0fbda30f2..fbec7d499 100644
--- a/winsup/cygwin/heap.cc
+++ b/winsup/cygwin/heap.cc
@@ -29,7 +29,6 @@ static ptrdiff_t page_const;
 static uintptr_t
 eval_start_address ()
 {
-#ifdef __x86_64__
   /* On 64 bit, we choose a fixed address outside the 32 bit area.  The
      executable starts at 0x1:00400000L, the Cygwin DLL starts at
      0x1:80040000L, other rebased DLLs are located in the region from
@@ -38,38 +37,6 @@ eval_start_address ()
      are located in the region from 0x6:00000000L up to 0x8:00000000L.
      So the heap starts at 0x8:00000000L. */
   uintptr_t start_address = 0x800000000L;
-#else
-  /* Windows performs heap ASLR.  This spoils the entire region below
-     0x20000000 for us, because that region is used by Windows to randomize
-     heap and stack addresses.  Therefore we put our heap into a safe region
-     starting at 0x20000000.  This should work right from the start in 99%
-     of the cases. */
-  uintptr_t start_address = 0x20000000L;
-  MEMORY_BASIC_INFORMATION mbi;
-
-  if (VirtualQuery ((void *) 0xbf000000L, &mbi, sizeof mbi))
-    {
-      /* However, if we're running on a /3GB enabled 32 bit system or on
-	 a 64 bit system, and the executable is large address aware, then
-	 we know that we have spare 1 Gig (32 bit) or even 2 Gigs (64 bit)
-	 virtual address space.  This memory region is practically unused
-	 by Windows, only PEB and TEBs are allocated top-down here.
-
-	 We used to use the current TEB address as very simple test that
-	 this is a large address aware executable, but that fails on W10
-	 WOW64 because the main TEB is apparently commited in the lower
-	 2 Gigs these days.
-
-	 The above test for address 0xbf000000 is supposed to make sure
-	 that we really have 3GB on a 32 bit system.  Windows supports
-	 smaller large address regions, but then it's not that interesting
-	 for us to use it for the heap.  If the region is big enough, the
-	 heap gets allocated at its start.  What we get are 0.999 or 1.999
-	 Gigs of free contiguous memory for heap, thread stacks, and shared
-	 memory regions. */
-      start_address = 0x80000000L;
-    }
-#endif
   return start_address;
 }
 
@@ -83,27 +50,18 @@ eval_initial_heap_size ()
   dosheader = (PIMAGE_DOS_HEADER) GetModuleHandle (NULL);
   ntheader = (PIMAGE_NT_HEADERS) ((PBYTE) dosheader + dosheader->e_lfanew);
   /* LoaderFlags is an obsolete DWORD member of the PE/COFF file header.
-     It's value is ignored by the loader, so we're free to use it for
-     Cygwin.  If it's 0, we default to the usual 384 Megs on 32 bit and
-     512 on 64 bit.  Otherwise, we use it as the default initial heap size
-     in megabyte.  Valid values are between 4 and 2048/8388608 Megs. */
+     Its value is ignored by the loader, so we're free to use it for
+     Cygwin.  If it's 0, we default to 512.  Otherwise, we use it as
+     the default initial heap size in megabyte.  Valid values are
+     between 4 and 8388608 Megs. */
 
   size = ntheader->OptionalHeader.LoaderFlags;
-#ifdef __x86_64__
   if (size == 0)
     size = 512;
   else if (size < 4)
     size = 4;
   else if (size > 8388608)
     size = 8388608;
-#else
-  if (size == 0)
-    size = 384;
-  else if (size < 4)
-    size = 4;
-  else if (size > 2048)
-    size = 2048;
-#endif
   return size << 20;
 }
 
diff --git a/winsup/cygwin/hookapi.cc b/winsup/cygwin/hookapi.cc
index 1eb5fdea2..fbf13ce90 100644
--- a/winsup/cygwin/hookapi.cc
+++ b/winsup/cygwin/hookapi.cc
@@ -72,11 +72,7 @@ rvadelta (PIMAGE_NT_HEADERS pnt, DWORD import_rva, DWORD &max_size)
 static void *
 putmem (PIMAGE_THUNK_DATA pi, const void *hookfn)
 {
-#ifdef __x86_64__
 #define THUNK_FUNC_TYPE ULONGLONG
-#else
-#define THUNK_FUNC_TYPE DWORD
-#endif
 
   DWORD ofl;
   if (!VirtualProtect (pi, sizeof (THUNK_FUNC_TYPE), PAGE_READWRITE, &ofl) )
@@ -282,14 +278,7 @@ find_first_notloaded_dll (path_conv& pc)
   bool is_64bit;
   pExeNTHdr = PEHeaderFromHModule (hm, is_64bit);
 
-  if (!pExeNTHdr)
-    goto out;
-
-#ifdef __x86_64__
-  if (!is_64bit)
-#else
-  if (is_64bit)
-#endif
+  if (!pExeNTHdr || !is_64bit)
     goto out;
 
   importRVA = pExeNTHdr->OptionalHeader.DataDirectory
@@ -349,17 +338,9 @@ hook_or_detect_cygwin (const char *name, const void *fn, WORD& subsys, HANDLE h)
   bool is_64bit;
   PIMAGE_NT_HEADERS pExeNTHdr = PEHeaderFromHModule (hm, is_64bit);
 
-  if (!pExeNTHdr)
-    return NULL;
-
   /* Shortcut.  We don't have to do anything further from here, if the
-     executable's architecture doesn't match, unless we want to support
-     a mix of 32 and 64 bit Cygwin at one point. */
-#ifdef __x86_64__
-  if (!is_64bit)
-#else
-  if (is_64bit)
-#endif
+     executable's architecture doesn't match. */
+  if (!pExeNTHdr || !is_64bit)
     return NULL;
 
   DWORD importRVA, importRVASize;
diff --git a/winsup/cygwin/include/a.out.h b/winsup/cygwin/include/a.out.h
index 87053668c..8f006b328 100644
--- a/winsup/cygwin/include/a.out.h
+++ b/winsup/cygwin/include/a.out.h
@@ -391,9 +391,6 @@ typedef struct
   uint32_t bsize;		/* uninitialized data "   "		*/
   uint32_t entry;		/* entry pt.				*/
   uint32_t text_start;	/* base of text used for this file */
-#ifdef __i386__
-  uint32_t data_start;	/* base of all data used for this file */
-#endif
 
   /* NT extra fields; see internal.h for descriptions */
   uintptr_t ImageBase;
@@ -424,11 +421,7 @@ typedef struct
 
 
 #undef AOUTSZ
-#ifdef __x86_64__
 #define AOUTSZ (AOUTHDRSZ + 212)
-#else
-#define AOUTSZ (AOUTHDRSZ + 196)
-#endif
 
 #undef  E_FILNMLEN
 #define E_FILNMLEN	18	/* # characters in a file name		*/
diff --git a/winsup/cygwin/include/asm/bitsperlong.h b/winsup/cygwin/include/asm/bitsperlong.h
index 48037b645..4f2768056 100644
--- a/winsup/cygwin/include/asm/bitsperlong.h
+++ b/winsup/cygwin/include/asm/bitsperlong.h
@@ -9,10 +9,6 @@ details. */
 #ifndef __ASM_BITSPERLONG_H
 #define __ASM_BITSPERLONG_H
 
-#ifdef __x86_64__
 #define __BITS_PER_LONG 64
-#else
-#define __BITS_PER_LONG 32
-#endif
 
 #endif /* __ASM_BITSPERLONG_H */
diff --git a/winsup/cygwin/include/bits/wordsize.h b/winsup/cygwin/include/bits/wordsize.h
index b0ee337f8..6630631e6 100644
--- a/winsup/cygwin/include/bits/wordsize.h
+++ b/winsup/cygwin/include/bits/wordsize.h
@@ -2,10 +2,8 @@
 
 #ifndef _WORDSIZE_H
 #define _WORDSIZE_H 1
-#ifdef __x86_64__
+
 # define __WORDSIZE     64
 # define __WORDSIZE_COMPAT32    1
-#else
-# define __WORDSIZE     32
-#endif
+
 #endif /*_WORDSIZE_H*/
diff --git a/winsup/cygwin/include/cygwin/config.h b/winsup/cygwin/include/cygwin/config.h
index 2373c1b3f..fd3093755 100644
--- a/winsup/cygwin/include/cygwin/config.h
+++ b/winsup/cygwin/include/cygwin/config.h
@@ -36,21 +36,12 @@ __attribute__((__gnu_inline__))
 extern inline struct _reent *__getreent (void)
 {
   register char *ret;
-#ifdef __x86_64__
   __asm __volatile__ ("movq %%gs:8,%0" : "=r" (ret));
-#else
-  __asm __volatile__ ("movl %%fs:4,%0" : "=r" (ret));
-#endif
   return (struct _reent *) (ret - __CYGTLS_PADSIZE__);
 }
 #endif /* _LIBC || __INSIDE_CYGWIN__ */
 
-#ifdef __x86_64__
-# define __SYMBOL_PREFIX
-#else
-# define __SYMBOL_PREFIX "_"
-#endif
-#define _SYMSTR(x)	__SYMBOL_PREFIX #x
+#define _SYMSTR(x)	#x
 
 #define __FILENAME_MAX__ 4096	/* Keep in sync with PATH_MAX in limits.h. */
 
diff --git a/winsup/cygwin/include/cygwin/signal.h b/winsup/cygwin/include/cygwin/signal.h
index 7b17134f5..221a53721 100644
--- a/winsup/cygwin/include/cygwin/signal.h
+++ b/winsup/cygwin/include/cygwin/signal.h
@@ -19,7 +19,6 @@ extern "C" {
   Define a struct __mcontext, which should be identical in layout to the Win32
   API type CONTEXT with the addition of oldmask and cr2 fields at the end.
 */
-#ifdef __x86_64__
 
 struct _uc_fpxreg {
   __uint16_t significand[4];
@@ -98,67 +97,9 @@ struct __attribute__ ((__aligned__ (16))) __mcontext
   __uint64_t cr2;
 };
 
-#else /* !x86_64 */
-
-struct _uc_fpreg
-{
-  __uint16_t significand[4];
-  __uint16_t exponent;
-};
-
-struct _fpstate
-{
-  __uint32_t cw;
-  __uint32_t sw;
-  __uint32_t tag;
-  __uint32_t ipoff;
-  __uint32_t cssel;
-  __uint32_t dataoff;
-  __uint32_t datasel;
-  struct _uc_fpreg _st[8];
-  __uint32_t nxst;
-};
-
-struct __mcontext
-{
-  __uint32_t ctxflags;
-  __uint32_t dr0;
-  __uint32_t dr1;
-  __uint32_t dr2;
-  __uint32_t dr3;
-  __uint32_t dr6;
-  __uint32_t dr7;
-  struct _fpstate fpstate;
-  __uint32_t gs;
-  __uint32_t fs;
-  __uint32_t es;
-  __uint32_t ds;
-  __uint32_t edi;
-  __uint32_t esi;
-  __uint32_t ebx;
-  __uint32_t edx;
-  __uint32_t ecx;
-  __uint32_t eax;
-  __uint32_t ebp;
-  __uint32_t eip;
-  __uint32_t cs;
-  __uint32_t eflags;
-  __uint32_t esp;
-  __uint32_t ss;
-  __uint32_t reserved[128];
-  __uint32_t oldmask;
-  __uint32_t cr2;
-};
-
-#endif /* !x86_64 */
-
 /* Needed for GDB.  It only compiles in the context copy code if this macro is
    defined.  This is not sizeof(CONTEXT) due to historical accidents. */
-#ifdef __x86_64__
 #define __COPY_CONTEXT_SIZE 816
-#else
-#define __COPY_CONTEXT_SIZE 204
-#endif
 
 typedef union sigval
 {
diff --git a/winsup/cygwin/include/sys/cygwin.h b/winsup/cygwin/include/sys/cygwin.h
index 5532cb683..2c5997b5e 100644
--- a/winsup/cygwin/include/sys/cygwin.h
+++ b/winsup/cygwin/include/sys/cygwin.h
@@ -330,11 +330,7 @@ struct per_process
   DWORD api_minor;		/*  linked with */
   /* For future expansion, so apps won't have to be relinked if we
      add an item. */
-#ifdef __x86_64__
   DWORD_PTR unused2[4];
-#else
-  DWORD_PTR unused2[2];
-#endif
 
   int (*posix_memalign)(void **, size_t, size_t);
 
diff --git a/winsup/cygwin/include/sys/dirent.h b/winsup/cygwin/include/sys/dirent.h
index 0e7a78cc0..40e5e7729 100644
--- a/winsup/cygwin/include/sys/dirent.h
+++ b/winsup/cygwin/include/sys/dirent.h
@@ -15,9 +15,6 @@
 
 #define __DIRENT_VERSION	2
 
-#ifdef __i386__
-#pragma pack(push,4)
-#endif
 #define _DIRENT_HAVE_D_TYPE
 struct dirent
 {
@@ -28,21 +25,11 @@ struct dirent
   __uint32_t __d_internal1;
   char d_name[NAME_MAX + 1];
 };
-#ifdef __i386__
-#pragma pack(pop)
-#endif
 
 #define d_fileno d_ino			/* BSD compatible definition */
 
-#ifdef __x86_64__
 #define __DIRENT_COOKIE 0xcdcd8484
-#else
-#define __DIRENT_COOKIE 0xdede4242
-#endif
 
-#ifdef __i386__
-#pragma pack(push,4)
-#endif
 typedef struct __DIR
 {
   /* This is first to set alignment in non _LIBC case.  */
@@ -56,9 +43,6 @@ typedef struct __DIR
   void *__fh;
   unsigned __flags;
 } DIR;
-#ifdef __i386__
-#pragma pack(pop)
-#endif
 
 #if __BSD_VISIBLE
 #ifdef _DIRENT_HAVE_D_TYPE
diff --git a/winsup/cygwin/init.cc b/winsup/cygwin/init.cc
index ab20ce577..d822a3851 100644
--- a/winsup/cygwin/init.cc
+++ b/winsup/cygwin/init.cc
@@ -19,9 +19,6 @@ unsigned threadfunc_ix[8];
 static bool dll_finished_loading;
 #define OLDFUNC_OFFSET -1
 
-#ifdef __i386__
-__attribute__ ((force_align_arg_pointer))
-#endif
 static void WINAPI
 threadfunc_fe (VOID *arg)
 {
diff --git a/winsup/cygwin/lib/_cygwin_crt0_common.cc b/winsup/cygwin/lib/_cygwin_crt0_common.cc
index 6c51422b8..365015011 100644
--- a/winsup/cygwin/lib/_cygwin_crt0_common.cc
+++ b/winsup/cygwin/lib/_cygwin_crt0_common.cc
@@ -14,17 +14,10 @@ details. */
    unnecessarily.  */
 #define WEAK __attribute__ ((weak))
 
-#ifdef __x86_64__
 #define REAL_ZNWX		"__real__Znwm"
 #define REAL_ZNAX		"__real__Znam"
 #define REAL_ZNWX_NOTHROW_T	"__real__ZnwmRKSt9nothrow_t"
 #define REAL_ZNAX_NOTHROW_T	"__real__ZnamRKSt9nothrow_t"
-#else
-#define REAL_ZNWX		"___real__Znwj"
-#define REAL_ZNAX		"___real__Znaj"
-#define REAL_ZNWX_NOTHROW_T	"___real__ZnwjRKSt9nothrow_t"
-#define REAL_ZNAX_NOTHROW_T	"___real__ZnajRKSt9nothrow_t"
-#endif
 #define REAL_ZDLPV		_SYMSTR (__real__ZdlPv)
 #define REAL_ZDAPV		_SYMSTR (__real__ZdaPv)
 #define REAL_ZDLPV_NOTHROW_T	_SYMSTR (__real__ZdlPvRKSt9nothrow_t)
@@ -65,12 +58,8 @@ int _fmode;
 
 extern char __RUNTIME_PSEUDO_RELOC_LIST__;
 extern char __RUNTIME_PSEUDO_RELOC_LIST_END__;
-#ifdef __x86_64__
 extern char __image_base__;
 #define _image_base__ __image_base__
-#else
-extern char _image_base__;
-#endif
 
 struct per_process_cxx_malloc __cygwin_cxx_malloc =
 {
diff --git a/winsup/cygwin/libstdcxx_wrapper.cc b/winsup/cygwin/libstdcxx_wrapper.cc
index 2c41b3759..34911d0e1 100644
--- a/winsup/cygwin/libstdcxx_wrapper.cc
+++ b/winsup/cygwin/libstdcxx_wrapper.cc
@@ -20,17 +20,10 @@ details.  */
    around the standard C++ memory management operators; these are the wrappers,
    but we want the compiler to know they are the malloc operators and not have
    it think they're just any old function matching 'extern "C" _wrap_*'.  */
-#ifdef __x86_64__
 #define MANGLED_ZNWX			"__wrap__Znwm"
 #define MANGLED_ZNAX			"__wrap__Znam"
 #define MANGLED_ZNWX_NOTHROW_T		"__wrap__ZnwmRKSt9nothrow_t"
 #define MANGLED_ZNAX_NOTHROW_T		"__wrap__ZnamRKSt9nothrow_t"
-#else
-#define MANGLED_ZNWX			"___wrap__Znwj"
-#define MANGLED_ZNAX			"___wrap__Znaj"
-#define MANGLED_ZNWX_NOTHROW_T		"___wrap__ZnwjRKSt9nothrow_t"
-#define MANGLED_ZNAX_NOTHROW_T		"___wrap__ZnajRKSt9nothrow_t"
-#endif
 
 extern void *operator new(std::size_t sz) noexcept (false)
 			__asm__ (MANGLED_ZNWX);
diff --git a/winsup/cygwin/miscfuncs.cc b/winsup/cygwin/miscfuncs.cc
index c3e63f433..d9caf9b73 100644
--- a/winsup/cygwin/miscfuncs.cc
+++ b/winsup/cygwin/miscfuncs.cc
@@ -334,12 +334,8 @@ __import_address (void *imp)
       if (*((uint16_t *) imp) == 0x25ff)
 	{
 	  const char *ptr = (const char *) imp;
-#ifdef __x86_64__
 	  const uintptr_t *jmpto = (uintptr_t *)
 				   (ptr + 6 + *(int32_t *)(ptr + 2));
-#else
-	  const uintptr_t *jmpto = (uintptr_t *) *((uintptr_t *) (ptr + 2));
-#endif
 	  return (void *) *jmpto;
 	}
     }
@@ -417,41 +413,6 @@ pthread_wrapper (PVOID arg)
   /* Initialize new _cygtls. */
   _my_tls.init_thread (wrapper_arg.stackbase - __CYGTLS_PADSIZE__,
 		       (DWORD (*)(void*, void*)) wrapper_arg.func);
-#ifdef __i386__
-  /* Copy exception list over to new stack.  I'm not quite sure how the
-     exception list is extended by Windows itself.  What's clear is that it
-     always grows downwards and that it starts right at the stackbase.
-     Therefore we first count the number of exception records and place
-     the copy at the stackbase, too, so there's still a lot of room to
-     extend the list up to where our _cygtls region starts. */
-  _exception_list *old_start = (_exception_list *) teb->Tib.ExceptionList;
-  unsigned count = 0;
-  teb->Tib.ExceptionList = NULL;
-  for (_exception_list *e_ptr = old_start;
-       e_ptr && e_ptr != (_exception_list *) -1;
-       e_ptr = e_ptr->prev)
-    ++count;
-  if (count)
-    {
-      _exception_list *new_start = (_exception_list *) wrapper_arg.stackbase
-						       - count;
-      teb->Tib.ExceptionList = (struct _EXCEPTION_REGISTRATION_RECORD *)
-			       new_start;
-      while (true)
-	{
-	  new_start->handler = old_start->handler;
-	  if (old_start->prev == (_exception_list *) -1)
-	    {
-	      new_start->prev = (_exception_list *) -1;
-	      break;
-	    }
-	  new_start->prev = new_start + 1;
-	  new_start = new_start->prev;
-	  old_start = old_start->prev;
-	}
-    }
-#endif
-#ifdef __x86_64__
   __asm__ ("\n\
 	   leaq  %[WRAPPER_ARG], %%rbx	# Load &wrapper_arg into rbx	\n\
 	   movq  (%%rbx), %%r12		# Load thread func into r12	\n\
@@ -475,44 +436,11 @@ pthread_wrapper (PVOID arg)
 	   call  *%%r12			# Call thread func		\n"
 	   : : [WRAPPER_ARG] "o" (wrapper_arg),
 	       [CYGTLS] "i" (__CYGTLS_PADSIZE__));
-#else
-  __asm__ ("\n\
-	   leal  %[WRAPPER_ARG], %%ebx	# Load &wrapper_arg into ebx	\n\
-	   movl  (%%ebx), %%eax		# Load thread func into eax	\n\
-	   movl  4(%%ebx), %%ecx	# Load thread arg into ecx	\n\
-	   movl  8(%%ebx), %%edx	# Load stackaddr into edx	\n\
-	   movl  12(%%ebx), %%ebx	# Load stackbase into ebx	\n\
-	   subl  %[CYGTLS], %%ebx	# Subtract __CYGTLS_PADSIZE__	\n\
-	   subl  $4, %%ebx		# Subtract another 4 bytes	\n\
-	   movl  %%ebx, %%esp		# Set esp			\n\
-	   xorl  %%ebp, %%ebp		# Set ebp to 0			\n\
-	   # Make gcc 3.x happy and align the stack so that it is	\n\
-	   # 16 byte aligned right before the final call opcode.	\n\
-	   andl  $-16, %%esp		# 16 byte align			\n\
-	   addl  $-12, %%esp		# 12 bytes + 4 byte arg = 16	\n\
-	   # Now we moved to the new stack.  Save thread func address	\n\
-	   # and thread arg on new stack				\n\
-	   pushl %%ecx			# Push thread arg onto stack	\n\
-	   pushl %%eax			# Push thread func onto stack	\n\
-	   # Now it's safe to release the OS stack.			\n\
-	   pushl $0x8000		# dwFreeType: MEM_RELEASE	\n\
-	   pushl $0x0			# dwSize:     0			\n\
-	   pushl %%edx			# lpAddress:  stackaddr		\n\
-	   call _VirtualFree@12		# Shoot				\n\
-	   # All set.  We can pop the thread function address from	\n\
-	   # the stack and call it.  The thread arg is still on the	\n\
-	   # stack in the expected spot.				\n\
-	   popl  %%eax			# Pop thread_func address	\n\
-	   call  *%%eax			# Call thread func		\n"
-	   : : [WRAPPER_ARG] "o" (wrapper_arg),
-	       [CYGTLS] "i" (__CYGTLS_PADSIZE__));
-#endif
   /* pthread::thread_init_wrapper calls pthread::exit, which
      in turn calls ExitThread, so we should never arrive here. */
   api_fatal ("Dumb thinko in pthread handling.  Whip the developer.");
 }
 
-#ifdef __x86_64__
 /* The memory region used for thread stacks. The memory layout is outlined
    in heap.cc, function eval_start_address(). */
 #define THREAD_STORAGE_LOW	0x600000000L
@@ -665,7 +593,6 @@ create_new_main_thread_stack (PVOID &allocationbase)
   NtCurrentTeb()->Tib.StackLimit = stacklimit;
   return ((PBYTE) allocationbase + stacksize - 16);
 }
-#endif
 
 HANDLE WINAPI
 CygwinCreateThread (LPTHREAD_START_ROUTINE thread_func, PVOID thread_arg,
@@ -710,17 +637,7 @@ CygwinCreateThread (LPTHREAD_START_ROUTINE thread_func, PVOID thread_arg,
       real_stacksize = roundup2 (real_stacksize,
 				 wincap.allocation_granularity ());
       /* Reserve stack. */
-#ifdef __x86_64__
       real_stackaddr = thr_alloc.alloc (real_stacksize);
-#else
-      /* FIXME? If the TOP_DOWN method tends to collide too much with
-	 other stuff, we should provide our own mechanism to find a
-	 suitable place for the stack.  Top down from the start of
-	 the Cygwin DLL comes to mind. */
-      real_stackaddr = VirtualAlloc (NULL, real_stacksize,
-				     MEM_RESERVE | MEM_TOP_DOWN,
-				     PAGE_READWRITE);
-#endif
       if (!real_stackaddr)
 	return NULL;
       /* Set up committed region.  We set up the stack like the OS does,
@@ -781,7 +698,6 @@ err:
   return thread;
 }
 
-#ifdef __x86_64__
 /* These functions are almost verbatim FreeBSD code (even if the header of
    one file mentiones NetBSD), just wrapped in the minimum required code to
    make them work with the MS AMD64 ABI.
@@ -984,8 +900,6 @@ wmempcpy:								\n\
 	.seh_endproc							\n\
 ");
 
-#endif
-
 /* Signal the thread name to any attached debugger
 
    (See "How to: Set a Thread Name in Native Code"
@@ -1004,18 +918,8 @@ SetThreadName(DWORD dwThreadID, const char* threadName)
       0x1000,                 /* type, must be 0x1000 */
       (ULONG_PTR) threadName, /* pointer to threadname */
       dwThreadID,             /* thread ID (+ flags on x86_64) */
-#ifdef _X86_
-      0,                      /* flags, must be zero */
-#endif
     };
 
-#ifdef _X86_
-  /* On x86, for __try/__except to work, we must ensure our exception handler is
-     installed, which may not be the case if this is being called during early
-     initialization. */
-  exception protect;
-#endif
-
   __try
     {
       RaiseException (MS_VC_EXCEPTION, 0, sizeof (info) / sizeof (ULONG_PTR),
diff --git a/winsup/cygwin/miscfuncs.h b/winsup/cygwin/miscfuncs.h
index b0f8c242c..565029561 100644
--- a/winsup/cygwin/miscfuncs.h
+++ b/winsup/cygwin/miscfuncs.h
@@ -108,9 +108,7 @@ ssize_t check_iovec (const struct iovec *, int, bool);
 #define check_iovec_for_read(a, b) check_iovec ((a), (b), false)
 #define check_iovec_for_write(a, b) check_iovec ((a), (b), true)
 
-#ifdef __x86_64__
 extern PVOID create_new_main_thread_stack (PVOID &allocationbase);
-#endif
 
 extern "C" DWORD WINAPI pthread_wrapper (PVOID arg);
 extern "C" HANDLE WINAPI CygwinCreateThread (LPTHREAD_START_ROUTINE thread_func,
diff --git a/winsup/cygwin/mmap.cc b/winsup/cygwin/mmap.cc
index 5aa6d0c09..948eeec1f 100644
--- a/winsup/cygwin/mmap.cc
+++ b/winsup/cygwin/mmap.cc
@@ -196,7 +196,6 @@ MapView (HANDLE h, void *addr, size_t len, DWORD openflags,
   SIZE_T viewsize = len;
   ULONG alloc_type = MEM_TOP_DOWN;
 
-#ifdef __x86_64__
   /* Don't call NtMapViewOfSectionEx during fork.  It requires autoloading
      a function under loader lock (STATUS_DLL_INIT_FAILED). */
   if (!from_fixup_after_fork && wincap.has_extended_mem_api ())
@@ -232,7 +231,6 @@ MapView (HANDLE h, void *addr, size_t len, DWORD openflags,
 		    base, status, h, addr, off, viewsize, alloc_type, protect);
       return base;
     }
-#endif
 
   /* Try mapping using the given address first, even if it's NULL.
      If it failed, and addr was not NULL and flags is not MAP_FIXED,
@@ -1063,40 +1061,8 @@ go_ahead:
     }
 
   orig_len = roundup2 (orig_len, pagesize);
-#ifdef __x86_64__
   if (!wincap.has_extended_mem_api ())
     addr = mmap_alloc.alloc (addr, orig_len ?: len, fixed (flags));
-#else
-  if (orig_len)
-    {
-      /* If the requested length is bigger than the file size, we try to
-	 allocate an area of the full size first.  This area is immediately
-	 deallocated and the address we got is used as base address for the
-	 subsequent real mappings.  This ensures that we have enough space
-	 for the whole thing. */
-      PVOID newaddr = VirtualAlloc (addr, orig_len, MEM_TOP_DOWN | MEM_RESERVE,
-				    PAGE_READWRITE);
-      if (!newaddr)
-	{
-	  /* If addr is not NULL, but MAP_FIXED isn't given, allow the OS
-	     to choose. */
-	  if (addr && !fixed (flags))
-	    newaddr = VirtualAlloc (NULL, orig_len, MEM_TOP_DOWN | MEM_RESERVE,
-				    PAGE_READWRITE);
-	  if (!newaddr)
-	    {
-	      __seterrno ();
-	      goto out_with_unlock;
-	    }
-	}
-      if (!VirtualFree (newaddr, 0, MEM_RELEASE))
-	{
-	  __seterrno ();
-	  goto out_with_unlock;
-	}
-      addr = newaddr;
-    }
-#endif
 
   base = mmap_worker (map_list, fh, (caddr_t) addr, len, prot, flags, fd, off,
 		      &st);
@@ -1600,7 +1566,6 @@ fhandler_dev_zero::mmap (caddr_t *addr, size_t len, int prot,
       DWORD protect = gen_protect (prot, flags);
       DWORD alloc_type = MEM_TOP_DOWN | MEM_RESERVE
 			 | (noreserve (flags) ? 0 : MEM_COMMIT);
-#ifdef __x86_64__
       if (wincap.has_extended_mem_api ())
 	{
 	  static const MEM_ADDRESS_REQUIREMENTS mmap_req = {
@@ -1621,7 +1586,6 @@ fhandler_dev_zero::mmap (caddr_t *addr, size_t len, int prot,
 				  protect, &mmap_ext, 1);
 	}
       else
-#endif
 	{
 	  base = VirtualAlloc (*addr, len, alloc_type, protect);
 	  if (!base && addr && !fixed (flags))
diff --git a/winsup/cygwin/mmap_alloc.cc b/winsup/cygwin/mmap_alloc.cc
index cd4d49bc9..7cbe42553 100644
--- a/winsup/cygwin/mmap_alloc.cc
+++ b/winsup/cygwin/mmap_alloc.cc
@@ -1,5 +1,3 @@
-#ifdef __x86_64__
-
 #include "winsup.h"
 #include "mmap_alloc.h"
 #include <sys/param.h>
@@ -78,5 +76,3 @@ mmap_allocator::alloc (PVOID in_addr, SIZE_T in_size, bool fixed)
 }
 
 mmap_allocator mmap_alloc;	/* Inherited by forked child. */
-
-#endif
diff --git a/winsup/cygwin/mmap_alloc.h b/winsup/cygwin/mmap_alloc.h
index 01c195d52..8d6aebcaf 100644
--- a/winsup/cygwin/mmap_alloc.h
+++ b/winsup/cygwin/mmap_alloc.h
@@ -1,5 +1,3 @@
-#ifdef __x86_64__
-
 /* The memory region used for memory maps */
 #define MMAP_STORAGE_LOW	0x001000000000L	/* Leave 32 Gigs for heap. */
 /* Up to Win 8 only supporting 44 bit address space, starting with Win 8.1
@@ -17,5 +15,3 @@ public:
 };
 
 extern mmap_allocator mmap_alloc;
-
-#endif
diff --git a/winsup/cygwin/net.cc b/winsup/cygwin/net.cc
index 36e2923b4..e6c5eadf2 100644
--- a/winsup/cygwin/net.cc
+++ b/winsup/cygwin/net.cc
@@ -12,13 +12,11 @@ details. */
 #define USE_SYS_TYPES_FD_SET
 #define __WSA_ERR_MACROS_DEFINED
 #include "winsup.h"
-#ifdef __x86_64__
 /* 2014-04-24: Current Mingw headers define sockaddr_in6 using u_long (8 byte)
    because a redefinition for LP64 systems is missing.  This leads to a wrong
    definition and size of sockaddr_in6 when building with winsock headers. */
 #undef u_long
 #define u_long __ms_u_long
-#endif
 #include <w32api/ws2tcpip.h>
 #include <w32api/mswsock.h>
 #include <w32api/iphlpapi.h>
@@ -290,7 +288,6 @@ realloc_ent (int sz, hostent *)
    The 'unionent' struct is a union of all of the currently used
    *ent structure.  */
 
-#ifdef __x86_64__
 /* For some baffling reason, somebody at Microsoft decided that it would be
    a good idea to exchange the s_port and s_proto members in the servent
    structure. */
@@ -302,9 +299,6 @@ struct win64_servent
   short  s_port;
 };
 #define WIN_SERVENT(x)	((win64_servent *)(x))
-#else
-#define WIN_SERVENT(x)	((servent *)(x))
-#endif
 
 #ifdef DEBUGGING
 static void *
@@ -3078,11 +3072,9 @@ cygwin_getaddrinfo (const char *hostname, const char *servname,
 	  /* sizeof addrinfo == sizeof addrinfoW */
 	  memcpy (&whints, hints, sizeof whints);
 	  whints.ai_flags &= ~AI_IDN_MASK;
-#ifdef __x86_64__
 	  /* ai_addrlen is socklen_t (4 bytes) in POSIX but size_t (8 bytes) in
 	     Winsock.  Sert upper 4 bytes explicitely to 0 to avoid EAI_FAIL. */
 	  whints.ai_addrlen &= UINT32_MAX;
-#endif
 	  /* On Windows, the default behaviour is as if AI_ADDRCONFIG is set,
 	     apparently for performance reasons.  To get the POSIX default
 	     behaviour, the AI_ALL flag has to be set. */
diff --git a/winsup/cygwin/ntdll.h b/winsup/cygwin/ntdll.h
index cd455ebfc..5cb7cc636 100644
--- a/winsup/cygwin/ntdll.h
+++ b/winsup/cygwin/ntdll.h
@@ -1377,7 +1377,6 @@ typedef enum _SECTION_INHERIT
 
 typedef VOID (APIENTRY *PTIMER_APC_ROUTINE)(PVOID, ULONG, ULONG);
 
-#ifdef __x86_64__
 typedef struct _SCOPE_TABLE
 {
   ULONG Count;
@@ -1389,7 +1388,6 @@ typedef struct _SCOPE_TABLE
     ULONG JumpTarget;
   } ScopeRecord[1];
 } SCOPE_TABLE, *PSCOPE_TABLE;
-#endif
 
 #ifdef __cplusplus
 /* This is the mapping of the KUSER_SHARED_DATA structure into the user
diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc
index bd3ffdce6..ea695ed99 100644
--- a/winsup/cygwin/path.cc
+++ b/winsup/cygwin/path.cc
@@ -4489,8 +4489,6 @@ fcwd_access_t::SetVersionFromPointer (PBYTE buf_p, bool is_buffer)
    it's not exported from the DLL, unfortunately.  Therefore we have to
    use some knowledge to figure out the address. */
 
-#ifdef __x86_64__
-
 #define peek32(x)	(*(int32_t *)(x))
 
 static fcwd_access_t **
@@ -4588,106 +4586,6 @@ find_fast_cwd_pointer ()
   /* Compute address of the fcwd_access_t ** pointer. */
   return (fcwd_access_t **) (testrbx + peek32 (movrbx + 3));
 }
-#else
-
-#define peek32(x)	(*(uint32_t *)(x))
-
-static fcwd_access_t **
-find_fast_cwd_pointer ()
-{
-  /* Fetch entry points of relevant functions in ntdll.dll. */
-  HMODULE ntdll = GetModuleHandle ("ntdll.dll");
-  if (!ntdll)
-    return NULL;
-  const uint8_t *get_dir = (const uint8_t *)
-			   GetProcAddress (ntdll, "RtlGetCurrentDirectory_U");
-  const uint8_t *ent_crit = (const uint8_t *)
-			    GetProcAddress (ntdll, "RtlEnterCriticalSection");
-  if (!get_dir || !ent_crit)
-    return NULL;
-  /* Search first relative call instruction in RtlGetCurrentDirectory_U. */
-  const uint8_t *rcall = (const uint8_t *) memchr (get_dir, 0xe8, 64);
-  if (!rcall)
-    return NULL;
-  /* Fetch offset from instruction and compute address of called function.
-     This function actually fetches the current FAST_CWD instance and
-     performs some other actions, not important to us. */
-  ptrdiff_t offset = (ptrdiff_t) peek32 (rcall + 1);
-  const uint8_t *use_cwd = rcall + 5 + offset;
-  /* Find first `push %edi' instruction. */
-  const uint8_t *pushedi = (const uint8_t *) memchr (use_cwd, 0x57, 32);
-  if (!pushedi)
-    return NULL;
-  /* ...which should be followed by `mov crit-sect-addr,%edi' then
-     `push %edi', or by just a single `push crit-sect-addr'. */
-  const uint8_t *movedi = pushedi + 1;
-  const uint8_t *mov_pfast_cwd;
-  if (movedi[0] == 0x8b && movedi[1] == 0xff)	/* mov %edi,%edi -> W8 */
-    {
-      /* Windows 8 does not call RtlEnterCriticalSection.  The code manipulates
-	 the FastPebLock manually, probably because RtlEnterCriticalSection has
-	 been converted to an inline function.
-
-	 Next we search for a `mov some address,%eax'.  This address points
-	 to the LockCount member of the FastPebLock structure, so the address
-	 is equal to FastPebLock + 4. */
-      const uint8_t *moveax = (const uint8_t *) memchr (movedi, 0xb8, 16);
-      if (!moveax)
-	return NULL;
-      offset = (ptrdiff_t) peek32 (moveax + 1) - 4;
-      /* Compare the address with the known PEB lock as stored in the PEB. */
-      if ((PRTL_CRITICAL_SECTION) offset != NtCurrentTeb ()->Peb->FastPebLock)
-	return NULL;
-      /* Now search for the mov instruction fetching the address of the global
-	 PFAST_CWD *. */
-      mov_pfast_cwd = moveax;
-      do
-	{
-	  mov_pfast_cwd = (const uint8_t *) memchr (++mov_pfast_cwd, 0x8b, 48);
-	}
-      while (mov_pfast_cwd && mov_pfast_cwd[1] != 0x1d
-	     && (mov_pfast_cwd - moveax) < 48);
-      if (!mov_pfast_cwd || mov_pfast_cwd[1] != 0x1d)
-	return NULL;
-    }
-  else
-    {
-      if (movedi[0] == 0xbf && movedi[5] == 0x57)
-	rcall = movedi + 6;
-      else if (movedi[0] == 0x68)
-	rcall = movedi + 5;
-      else if (movedi[0] == 0x88 && movedi[4] == 0x83 && movedi[7] == 0x68)
-	{
-	  /* Windows 8.1 Preview: The `mov lock_addr,%edi' is actually a
-	     `mov %cl,15(%esp), followed by an `or #-1,%ebx, followed by a
-	     `push lock_addr'. */
-	  movedi += 7;
-	  rcall = movedi + 5;
-	}
-      else
-	return NULL;
-      /* Compare the address used for the critical section with the known
-	 PEB lock as stored in the PEB. */
-      if ((PRTL_CRITICAL_SECTION) peek32 (movedi + 1)
-	  != NtCurrentTeb ()->Peb->FastPebLock)
-	return NULL;
-      /* To check we are seeing the right code, we check our expectation that
-	 the next instruction is a relative call into RtlEnterCriticalSection. */
-      if (rcall[0] != 0xe8)
-	return NULL;
-      /* Check that this is a relative call to RtlEnterCriticalSection. */
-      offset = (ptrdiff_t) peek32 (rcall + 1);
-      if (rcall + 5 + offset != ent_crit)
-	return NULL;
-      mov_pfast_cwd = rcall + 5;
-    }
-  /* After locking the critical section, the code should read the global
-     PFAST_CWD * pointer that is guarded by that critical section. */
-  if (mov_pfast_cwd[0] != 0x8b)
-    return NULL;
-  return (fcwd_access_t **) peek32 (mov_pfast_cwd + 2);
-}
-#endif
 
 static fcwd_access_t **
 find_fast_cwd ()
diff --git a/winsup/cygwin/perprocess.h b/winsup/cygwin/perprocess.h
index b524ab9db..78530894f 100644
--- a/winsup/cygwin/perprocess.h
+++ b/winsup/cygwin/perprocess.h
@@ -19,11 +19,7 @@ extern struct per_process __cygwin_user_data;
 /* We use the following to test that sizeof hasn't changed.  When adding
    or deleting members, insert fillers or use the reserved entries.
    Do not change this value. */
-#ifdef __x86_64__
 #define SIZEOF_PER_PROCESS (41 * 8)
-#else
-#define SIZEOF_PER_PROCESS (42 * 4)
-#endif
 
 #ifdef __cplusplus
 }
diff --git a/winsup/cygwin/shm.cc b/winsup/cygwin/shm.cc
index 40d8dcb10..af079ad86 100644
--- a/winsup/cygwin/shm.cc
+++ b/winsup/cygwin/shm.cc
@@ -222,11 +222,7 @@ shmat (int shmid, const void *shmaddr, int shmflg)
     }
   NTSTATUS status;
   SIZE_T viewsize = ssh_entry->size;
-#ifdef __x86_64__
   vm_object_t ptr = mmap_alloc.alloc (NULL, viewsize, false);
-#else
-  vm_object_t ptr = NULL;
-#endif
 
   ULONG access = (shmflg & SHM_RDONLY) ? PAGE_READONLY : PAGE_READWRITE;
   status = NtMapViewOfSection (ssh_entry->hdl, NtCurrentProcess (), &ptr, 0,
diff --git a/winsup/cygwin/sigproc.cc b/winsup/cygwin/sigproc.cc
index 0d9da237c..0ccbc5046 100644
--- a/winsup/cygwin/sigproc.cc
+++ b/winsup/cygwin/sigproc.cc
@@ -50,13 +50,8 @@ char NO_COPY myself_nowait_dummy[1] = {'0'};
    This class can allocate memory.  But there's no need to free it
    because only one instance of the class is created per process. */
 class child_procs {
-#ifdef __i386__
-    static const int _NPROCS = 256;
-    static const int _NPROCS_2 = 1023;
-#else
     static const int _NPROCS = 1024;
     static const int _NPROCS_2 = 4095;
-#endif
     int _count;
     uint8_t _procs[_NPROCS * sizeof (pinfo)] __attribute__ ((__aligned__));
     pinfo *_procs_2;
diff --git a/winsup/cygwin/smallprint.cc b/winsup/cygwin/smallprint.cc
index 4a14ee3cf..4ec4b279c 100644
--- a/winsup/cygwin/smallprint.cc
+++ b/winsup/cygwin/smallprint.cc
@@ -219,37 +219,29 @@ __small_vsprintf (char *dst, const char *fmt, va_list ap)
 		  break;
 		case 'R':
 		  {
-#ifdef __x86_64__
 		    if (l_opt)
 		      Rval = va_arg (ap, int64_t);
 		    else
-#endif
 		      Rval = va_arg (ap, int32_t);
 		    dst = __rn (dst, 10, addsign, Rval, len, pad, LMASK);
 		  }
 		  break;
 		case 'd':
 		  base = 10;
-#ifdef __x86_64__
 		  if (l_opt)
 		    goto gen_decimalLL;
-#endif
 		  goto gen_decimal;
 		case 'u':
 		  base = 10;
 		  addsign = 0;
-#ifdef __x86_64__
 		  if (l_opt)
 		    goto gen_decimalLL;
-#endif
 		  goto gen_decimal;
 		case 'o':
 		  base = 8;
 		  addsign = 0;
-#ifdef __x86_64__
 		  if (l_opt)
 		    goto gen_decimalLL;
-#endif
 		  goto gen_decimal;
 		case 'y':
 		  *dst++ = '0';
@@ -258,10 +250,8 @@ __small_vsprintf (char *dst, const char *fmt, va_list ap)
 		case 'x':
 		  base = 16;
 		  addsign = 0;
-#ifdef __x86_64__
 		  if (l_opt)
 		    goto gen_decimalLL;
-#endif
 gen_decimal:
 		  dst = rnarg (dst, h_opt * base, addsign, len, pad);
 		  break;
@@ -289,11 +279,7 @@ gen_decimalLL:
 		case 'p':
 		  *dst++ = '0';
 		  *dst++ = 'x';
-#ifdef __x86_64__
 		  dst = rnargLL (dst, h_opt * 16, 0, len, pad);
-#else
-		  dst = rnarg (dst, h_opt * 16, 0, len, pad);
-#endif
 		  break;
 		case '.':
 		  n = strtol (fmt, (char **) &fmt, 10);
@@ -503,9 +489,7 @@ __small_vswprintf (PWCHAR dst, const WCHAR *fmt, va_list ap)
   while (*fmt)
     {
       unsigned int n = 0x7fff;
-#ifdef __x86_64__
       bool l_opt = false;
-#endif
       /* set to -1 on '_', indicates upper (1)/lower(-1) case */
       int h_opt = 1;
       if (*fmt != L'%')
@@ -543,9 +527,7 @@ __small_vswprintf (PWCHAR dst, const WCHAR *fmt, va_list ap)
 		  len = len * 10 + (c - L'0');
 		  continue;
 		case L'l':
-#ifdef __x86_64__
 		  l_opt = true;
-#endif
 		  continue;
 		case '_':
 		  h_opt = -1;
@@ -560,37 +542,29 @@ __small_vswprintf (PWCHAR dst, const WCHAR *fmt, va_list ap)
 		  break;
 		case 'R':
 		  {
-#ifdef __x86_64__
 		    if (l_opt)
 		      Rval = va_arg (ap, int64_t);
 		    else
-#endif
 		      Rval = va_arg (ap, int32_t);
 		    dst = __wrn (dst, 10, addsign, Rval, len, pad, LMASK);
 		  }
 		  break;
 		case L'd':
 		  base = 10;
-#ifdef __x86_64__
 		  if (l_opt)
 		    goto gen_decimalLL;
-#endif
 		  goto gen_decimal;
 		case 'u':
 		  base = 10;
 		  addsign = 0;
-#ifdef __x86_64__
 		  if (l_opt)
 		    goto gen_decimalLL;
-#endif
 		  goto gen_decimal;
 		case 'o':
 		  base = 8;
 		  addsign = 0;
-#ifdef __x86_64__
 		  if (l_opt)
 		    goto gen_decimalLL;
-#endif
 		  goto gen_decimal;
 		case 'y':
 		  *dst++ = '0';
@@ -599,10 +573,8 @@ __small_vswprintf (PWCHAR dst, const WCHAR *fmt, va_list ap)
 		case 'x':
 		  base = 16;
 		  addsign = 0;
-#ifdef __x86_64__
 		  if (l_opt)
 		    goto gen_decimalLL;
-#endif
 gen_decimal:
 		  dst = wrnarg (dst, h_opt * base, addsign, len, pad);
 		  break;
@@ -630,11 +602,7 @@ gen_decimalLL:
 		case L'p':
 		  *dst++ = L'0';
 		  *dst++ = L'x';
-#ifdef __x86_64__
 		  dst = wrnargLL (dst, h_opt * 16, 0, len, pad);
-#else
-		  dst = wrnarg (dst, h_opt * 16, 0, len, pad);
-#endif
 		  break;
 		case L'P':
 		  RtlInitUnicodeString (us = &uw, global_progname);
diff --git a/winsup/cygwin/strsig.cc b/winsup/cygwin/strsig.cc
index 03f959f88..65f8cedff 100644
--- a/winsup/cygwin/strsig.cc
+++ b/winsup/cygwin/strsig.cc
@@ -19,7 +19,7 @@ struct sigdesc
   const char *str;
 };
 
-#define __signals_common \
+#define __signals \
   _s(SIGHUP, "Hangup"),				/*  1 */ \
   _s(SIGINT, "Interrupt"),			/*  2 */ \
   _s(SIGQUIT, "Quit"),				/*  3 */ \
@@ -54,11 +54,7 @@ struct sigdesc
   _s2(SIGPWR, "Power failure",			/* 29 */ \
       SIGLOST, "Resource lost"),			 \
   _s(SIGUSR1, "User defined signal 1"),		/* 30 */ \
-  _s(SIGUSR2, "User defined signal 2"),		/* 31 */
-
-#ifdef __x86_64__
-# define __signals \
-  __signals_common \
+  _s(SIGUSR2, "User defined signal 2"),		/* 31 */ \
   _s(SIGRTMIN, "Real-time signal 0"),		/* 32 */ \
   _s(SIGRTMIN + 1, "Real-time signal 1"),	/* 33 */ \
   _s(SIGRTMIN + 2, "Real-time signal 2"),	/* 34 */ \
@@ -92,12 +88,6 @@ struct sigdesc
   _s(SIGRTMIN + 30, "Real-time signal 30"),	/* 62 */ \
   _s(SIGRTMIN + 31, "Real-time signal 31"),	/* 63 */ \
   _s(SIGRTMAX, "Real-time signal 32")		/* 64 */
-#else
-# define __signals \
-  __signals_common \
-  _s2(SIGRTMIN, "Real-time signal 0",		/* 32 */ \
-      SIGRTMAX, "Real-time signal 0")
-#endif
 
 #define _s(n, s) #n
 #define _s2(n, s, n1, s1) #n
diff --git a/winsup/cygwin/sysconf.cc b/winsup/cygwin/sysconf.cc
index 3d0bb9c4f..2db92e4de 100644
--- a/winsup/cygwin/sysconf.cc
+++ b/winsup/cygwin/sysconf.cc
@@ -664,7 +664,6 @@ static struct
   {0, NULL},				/* _CS_POSIX_V6_ILP32_OFF32_LDFLAGS */
   {0, NULL},				/* _CS_POSIX_V6_ILP32_OFF32_LIBS */
   {0, NULL},				/* _CS_XBS5_ILP32_OFF32_LINTFLAGS */
-#ifdef __x86_64__
   {0, NULL},				/* _CS_POSIX_V6_ILP32_OFFBIG_CFLAGS */
   {0, NULL},				/* _CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS */
   {0, NULL},				/* _CS_POSIX_V6_ILP32_OFFBIG_LIBS */
@@ -678,21 +677,6 @@ static struct
   {ls ("")},				/* _CS_POSIX_V6_LPBIG_OFFBIG_LIBS */
   {ls ("")},				/* _CS_XBS5_LPBIG_OFFBIG_LINTFLAGS */
   {ls ("POSIX_V6_LP64_OFF64")},		/* _CS_POSIX_V6_WIDTH_RESTRICTED_ENVS */
-#else
-  {ls ("")},				/* _CS_POSIX_V6_ILP32_OFFBIG_CFLAGS */
-  {ls ("")},				/* _CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS */
-  {ls ("")},				/* _CS_POSIX_V6_ILP32_OFFBIG_LIBS */
-  {ls ("")},				/* _CS_XBS5_ILP32_OFFBIG_LINTFLAGS */
-  {0, NULL},				/* _CS_POSIX_V6_LP64_OFF64_CFLAGS */
-  {0, NULL},				/* _CS_POSIX_V6_LP64_OFF64_LDFLAGS */
-  {0, NULL},				/* _CS_POSIX_V6_LP64_OFF64_LIBS */
-  {0, NULL},				/* _CS_XBS5_LP64_OFF64_LINTFLAGS */
-  {0, NULL},				/* _CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS */
-  {0, NULL},				/* _CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS */
-  {0, NULL},				/* _CS_POSIX_V6_LPBIG_OFFBIG_LIBS */
-  {0, NULL},				/* _CS_XBS5_LPBIG_OFFBIG_LINTFLAGS */
-  {ls ("POSIX_V6_ILP32_OFFBIG")},	/* _CS_POSIX_V6_WIDTH_RESTRICTED_ENVS */
-#endif
   {ls ("")},				/* _CS_POSIX_V7_THREADS_CFLAGS */
   {ls ("")},				/* _CS_POSIX_V7_THREADS_LDFLAGS */
   {ls ("POSIXLY_CORRECT=1")},		/* _CS_V7_ENV */
diff --git a/winsup/cygwin/thread.cc b/winsup/cygwin/thread.cc
index b7da4d0c7..72c04dbda 100644
--- a/winsup/cygwin/thread.cc
+++ b/winsup/cygwin/thread.cc
@@ -630,11 +630,7 @@ pthread::cancel ()
       threadlist_t *tl_entry = cygheap->find_tls (cygtls);
       if (!cygtls->inside_kernel (&context))
 	{
-#ifdef __x86_64__
 	  context.Rip = (ULONG_PTR) pthread::static_cancel_self;
-#else
-	  context.Eip = (DWORD) pthread::static_cancel_self;
-#endif
 	  SetThreadContext (win32_obj_id, &context);
 	}
       cygheap->unlock_tls (tl_entry);
diff --git a/winsup/cygwin/wincap.h b/winsup/cygwin/wincap.h
index 818359f94..e06b82f1f 100644
--- a/winsup/cygwin/wincap.h
+++ b/winsup/cygwin/wincap.h
@@ -73,9 +73,7 @@ public:
   {
     return ((wincaps *) this->caps)->def_guard_pages * page_size ();
   }
-#ifdef __x86_64__
   intptr_t IMPLEMENT (mmap_storage_high)
-#endif
   bool  IMPLEMENT (is_server)
   bool	IMPLEMENT (needs_query_information)
   bool	IMPLEMENT (has_precise_system_time)
diff --git a/winsup/cygwin/winsup.h b/winsup/cygwin/winsup.h
index 87aa5ef8d..4147dcebf 100644
--- a/winsup/cygwin/winsup.h
+++ b/winsup/cygwin/winsup.h
@@ -156,11 +156,6 @@ extern "C" PVOID dll_dllcrt0 (HMODULE, per_process *);
 
 extern "C" void _pei386_runtime_relocator (per_process *);
 
-#ifdef __i386__
-/* dynamically loaded dll initialization for non-cygwin apps */
-extern "C" int dll_noncygwin_dllcrt0 (HMODULE, per_process *);
-#endif /* __i386__ */
-
 void do_exit (int) __attribute__ ((noreturn));
 
 /* libstdc++ malloc operator wrapper support.  */
@@ -259,12 +254,7 @@ extern inline bool flush_file_buffers (HANDLE h)
 #define NO_R ~(S_IRUSR | S_IRGRP | S_IROTH)
 #define NO_X ~(S_IXUSR | S_IXGRP | S_IXOTH)
 
-
-#ifdef __x86_64__
 extern "C" char __data_start__, __data_end__, __bss_start__, __bss_end__;
-#else
-extern "C" char _data_start__, _data_end__, _bss_start__, _bss_end__;
-#endif
 extern "C" void (*__CTOR_LIST__) (void);
 extern "C" void (*__DTOR_LIST__) (void);
 
-- 
2.36.1



More information about the Cygwin-patches mailing list