diff options
author | Ken Brown <kbrown@cornell.edu> | 2022-06-09 18:42:03 -0400 |
---|---|---|
committer | Ken Brown <kbrown@cornell.edu> | 2022-06-10 16:38:34 -0400 |
commit | bbfe79fb725a1f8833143416f10db822e04f902b (patch) | |
tree | d3a8baa648fd836298525f5203dccb820b9ab468 | |
parent | b0cb9f85ca3626e0e68fd451c3090d253ceb4300 (diff) | |
download | newlib-bbfe79fb725a1f8833143416f10db822e04f902b.zip newlib-bbfe79fb725a1f8833143416f10db822e04f902b.tar.gz newlib-bbfe79fb725a1f8833143416f10db822e04f902b.tar.bz2 |
Cygwin: restore '#ifdef __x86_64__' for CPU-specific code
Commit e1ce752a1d, "Cygwin: remove miscellaneous 32-bit code", removed
most occurrences of '#ifdef __x86_64__'. Restore those occurrences
that guarded code specific to the AMD64 processor, and #error out if
the processor is different. This will make it easier to find
AMD64-specific code if we ever want to add support for a different
64-bit processor (e.g., ARM64).
-rw-r--r-- | winsup/cygwin/autoload.cc | 21 | ||||
-rw-r--r-- | winsup/cygwin/cpuid.h | 4 | ||||
-rw-r--r-- | winsup/cygwin/fork.cc | 4 | ||||
-rw-r--r-- | winsup/cygwin/include/cygwin/config.h | 4 | ||||
-rw-r--r-- | winsup/cygwin/include/cygwin/signal.h | 5 | ||||
-rw-r--r-- | winsup/cygwin/miscfuncs.cc | 9 |
6 files changed, 47 insertions, 0 deletions
diff --git a/winsup/cygwin/autoload.cc b/winsup/cygwin/autoload.cc index 668e646..8ab42d3 100644 --- a/winsup/cygwin/autoload.cc +++ b/winsup/cygwin/autoload.cc @@ -66,6 +66,7 @@ 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\ @@ -81,6 +82,9 @@ bool NO_COPY wsock_started; .set " #dllname "_primed, 1 \n\ .endif \n\ "); +#else +#error unimplemented for this target +#endif /* Standard DLL load macro. May invoke a fatal error if the function isn't found. */ @@ -92,6 +96,7 @@ 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\ @@ -116,6 +121,9 @@ _win32_" #name ": \n\ .asciz \"" #name "\" \n\ .text \n\ "); +#else +#error unimplemented for this target +#endif /* DLL loader helper functions used during initialization. */ @@ -131,6 +139,7 @@ extern "C" void dll_chain () __asm__ ("dll_chain"); extern "C" { +#ifdef __x86_64__ __asm__ (" \n\ .section .rdata,\"r\" \n\ msg1: \n\ @@ -192,6 +201,9 @@ dll_chain: \n\ push %rax # Restore 'return address' \n\ jmp *%rdx # Jump to next init function \n\ "); +#else +#error unimplemented for this target +#endif /* C representations of the two info blocks described above. FIXME: These structures confuse gdb for some reason. GDB can print @@ -246,6 +258,7 @@ 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 @@ -285,6 +298,10 @@ _" #func ": \n\ INIT_WRAPPER (std_dll_init) +#else +#error unimplemented for this target +#endif + __attribute__ ((used, noinline)) static two_addr_t std_dll_init (struct func_info *func) { @@ -341,8 +358,12 @@ std_dll_init (struct func_info *func) /* Initialization function for winsock stuff. */ +#ifdef __x86_64__ /* See above comment preceeding std_dll_init. */ INIT_WRAPPER (wsock_init) +#else +#error unimplemented for this target +#endif __attribute__ ((used, noinline)) static two_addr_t wsock_init (struct func_info *func) diff --git a/winsup/cygwin/cpuid.h b/winsup/cygwin/cpuid.h index bd90373..6dbb1bd 100644 --- a/winsup/cygwin/cpuid.h +++ b/winsup/cygwin/cpuid.h @@ -18,6 +18,7 @@ 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) { @@ -38,5 +39,8 @@ can_set_flag (uint32_t long flag) ); return ((r1 ^ r2) & flag) != 0; } +#else +#error unimplemented for this target +#endif #endif // !CPUID_H diff --git a/winsup/cygwin/fork.cc b/winsup/cygwin/fork.cc index 012819b..e4931a2 100644 --- a/winsup/cygwin/fork.cc +++ b/winsup/cygwin/fork.cc @@ -626,7 +626,11 @@ 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 +#error unimplemented for this target +#endif if (!ischild) res = grouped.parent (stackp); diff --git a/winsup/cygwin/include/cygwin/config.h b/winsup/cygwin/include/cygwin/config.h index f6d1b68..1d515a6 100644 --- a/winsup/cygwin/include/cygwin/config.h +++ b/winsup/cygwin/include/cygwin/config.h @@ -36,7 +36,11 @@ __attribute__((__gnu_inline__)) extern inline struct _reent *__getreent (void) { register char *ret; +#ifdef __x86_64__ __asm __volatile__ ("movq %%gs:8,%0" : "=r" (ret)); +#else +#error unimplemented for this target +#endif return (struct _reent *) (ret - __CYGTLS_PADSIZE__); } #endif /* _LIBC || __INSIDE_CYGWIN__ */ diff --git a/winsup/cygwin/include/cygwin/signal.h b/winsup/cygwin/include/cygwin/signal.h index 221a537..3c4108a 100644 --- a/winsup/cygwin/include/cygwin/signal.h +++ b/winsup/cygwin/include/cygwin/signal.h @@ -19,6 +19,7 @@ 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]; @@ -97,6 +98,10 @@ struct __attribute__ ((__aligned__ (16))) __mcontext __uint64_t cr2; }; +#else +#error unimplemented for this target +#endif + /* 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. */ #define __COPY_CONTEXT_SIZE 816 diff --git a/winsup/cygwin/miscfuncs.cc b/winsup/cygwin/miscfuncs.cc index d9caf9b..c6d564a 100644 --- a/winsup/cygwin/miscfuncs.cc +++ b/winsup/cygwin/miscfuncs.cc @@ -413,6 +413,7 @@ pthread_wrapper (PVOID arg) /* Initialize new _cygtls. */ _my_tls.init_thread (wrapper_arg.stackbase - __CYGTLS_PADSIZE__, (DWORD (*)(void*, void*)) wrapper_arg.func); +#ifdef __x86_64__ __asm__ ("\n\ leaq %[WRAPPER_ARG], %%rbx # Load &wrapper_arg into rbx \n\ movq (%%rbx), %%r12 # Load thread func into r12 \n\ @@ -436,6 +437,9 @@ pthread_wrapper (PVOID arg) call *%%r12 # Call thread func \n" : : [WRAPPER_ARG] "o" (wrapper_arg), [CYGTLS] "i" (__CYGTLS_PADSIZE__)); +#else +#error unimplemented for this target +#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."); @@ -698,6 +702,7 @@ 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. @@ -900,6 +905,10 @@ wmempcpy: \n\ .seh_endproc \n\ "); +#else +#error unimplemented for this target +#endif + /* Signal the thread name to any attached debugger (See "How to: Set a Thread Name in Native Code" |