From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2210) id 191713858284; Sat, 11 Jun 2022 02:01:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 191713858284 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Ken Brown To: cygwin-cvs@sourceware.org Subject: [newlib-cygwin] Cygwin: restore '#ifdef __x86_64__' for CPU-specific code X-Act-Checkin: newlib-cygwin X-Git-Author: Ken Brown X-Git-Refname: refs/heads/master X-Git-Oldrev: b0cb9f85ca3626e0e68fd451c3090d253ceb4300 X-Git-Newrev: bbfe79fb725a1f8833143416f10db822e04f902b Message-Id: <20220611020150.191713858284@sourceware.org> Date: Sat, 11 Jun 2022 02:01:50 +0000 (GMT) X-BeenThere: cygwin-cvs@cygwin.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Cygwin core component git logs List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 11 Jun 2022 02:01:50 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dnewlib-cygwin.git;h=3Dbbfe79fb725= a1f8833143416f10db822e04f902b commit bbfe79fb725a1f8833143416f10db822e04f902b Author: Ken Brown Date: Thu Jun 9 18:42:03 2022 -0400 Cygwin: restore '#ifdef __x86_64__' for CPU-specific code =20 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). Diff: --- winsup/cygwin/autoload.cc | 21 +++++++++++++++++++++ winsup/cygwin/cpuid.h | 4 ++++ winsup/cygwin/fork.cc | 4 ++++ winsup/cygwin/include/cygwin/config.h | 4 ++++ winsup/cygwin/include/cygwin/signal.h | 5 +++++ winsup/cygwin/miscfuncs.cc | 9 +++++++++ 6 files changed, 47 insertions(+) diff --git a/winsup/cygwin/autoload.cc b/winsup/cygwin/autoload.cc index 668e64650..8ab42d3e5 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 =20 /* 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) =20 /* 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 =20 /* DLL loader helper functions used during initialization. */ =20 @@ -131,6 +139,7 @@ extern "C" void dll_chain () __asm__ ("dll_chain"); =20 extern "C" { =20 +#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 =20 /* 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 =20 /* The standard DLL initialization routine. */ +#ifdef __x86_64__ =20 /* 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\ =20 INIT_WRAPPER (std_dll_init) =20 +#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) =20 /* Initialization function for winsock stuff. */ =20 +#ifdef __x86_64__ /* See above comment preceeding std_dll_init. */ INIT_WRAPPER (wsock_init) +#else +#error unimplemented for this target +#endif =20 __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 bd903733d..6dbb1bddf 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)); } =20 +#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) !=3D 0; } +#else +#error unimplemented for this target +#endif =20 #endif // !CPUID_H diff --git a/winsup/cygwin/fork.cc b/winsup/cygwin/fork.cc index 012819b61..e4931a286 100644 --- a/winsup/cygwin/fork.cc +++ b/winsup/cygwin/fork.cc @@ -626,7 +626,11 @@ dofork (void **proc, bool *with_forkables) ischild =3D !!setjmp (grouped.ch.jmp); =20 volatile char * volatile stackp; +#ifdef __x86_64__ __asm__ volatile ("movq %%rsp,%0": "=3Dr" (stackp)); +#else +#error unimplemented for this target +#endif =20 if (!ischild) res =3D grouped.parent (stackp); diff --git a/winsup/cygwin/include/cygwin/config.h b/winsup/cygwin/include/= cygwin/config.h index f6d1b68f0..1d515a6f5 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" : "=3Dr" (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 221a53721..3c4108ac9 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 W= in32 API type CONTEXT with the addition of oldmask and cr2 fields at the end. */ +#ifdef __x86_64__ =20 struct _uc_fpxreg { __uint16_t significand[4]; @@ -97,6 +98,10 @@ struct __attribute__ ((__aligned__ (16))) __mcontext __uint64_t cr2; }; =20 +#else +#error unimplemented for this target +#endif + /* Needed for GDB. It only compiles in the context copy code if this macr= o 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 d9caf9b73..c6d564af3 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; } =20 +#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\ "); =20 +#else +#error unimplemented for this target +#endif + /* Signal the thread name to any attached debugger =20 (See "How to: Set a Thread Name in Native Code"