public inbox for cygwin-cvs@sourceware.org
help / color / mirror / Atom feed
From: Ken Brown <kbrown@sourceware.org>
To: cygwin-cvs@sourceware.org
Subject: [newlib-cygwin] Cygwin: restore '#ifdef __x86_64__' for CPU-specific code
Date: Sat, 11 Jun 2022 02:01:50 +0000 (GMT)	[thread overview]
Message-ID: <20220611020150.191713858284@sourceware.org> (raw)

https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=bbfe79fb725a1f8833143416f10db822e04f902b

commit bbfe79fb725a1f8833143416f10db822e04f902b
Author: Ken Brown <kbrown@cornell.edu>
Date:   Thu Jun 9 18:42:03 2022 -0400

    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).

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
 
 /* 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 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));
 }
 
+#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 012819b61..e4931a286 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 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" : "=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 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 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 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;
 }
 
+#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"


                 reply	other threads:[~2022-06-11  2:01 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220611020150.191713858284@sourceware.org \
    --to=kbrown@sourceware.org \
    --cc=cygwin-cvs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).