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).
This commit is contained in:
parent
b0cb9f85ca
commit
bbfe79fb72
|
@ -66,6 +66,7 @@ bool NO_COPY wsock_started;
|
||||||
/* LoadDLLprime is used to prime the DLL info information, providing an
|
/* LoadDLLprime is used to prime the DLL info information, providing an
|
||||||
additional initialization routine to call prior to calling the first
|
additional initialization routine to call prior to calling the first
|
||||||
function. */
|
function. */
|
||||||
|
#ifdef __x86_64__
|
||||||
#define LoadDLLprime(dllname, init_also, no_resolve_on_fork) __asm__ (" \n\
|
#define LoadDLLprime(dllname, init_also, no_resolve_on_fork) __asm__ (" \n\
|
||||||
.ifndef " #dllname "_primed \n\
|
.ifndef " #dllname "_primed \n\
|
||||||
.section .data_cygwin_nocopy,\"w\" \n\
|
.section .data_cygwin_nocopy,\"w\" \n\
|
||||||
|
@ -81,6 +82,9 @@ bool NO_COPY wsock_started;
|
||||||
.set " #dllname "_primed, 1 \n\
|
.set " #dllname "_primed, 1 \n\
|
||||||
.endif \n\
|
.endif \n\
|
||||||
");
|
");
|
||||||
|
#else
|
||||||
|
#error unimplemented for this target
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Standard DLL load macro. May invoke a fatal error if the function isn't
|
/* Standard DLL load macro. May invoke a fatal error if the function isn't
|
||||||
found. */
|
found. */
|
||||||
|
@ -92,6 +96,7 @@ bool NO_COPY wsock_started;
|
||||||
LoadDLLfuncEx3(name, n, dllname, notimp, err, 0)
|
LoadDLLfuncEx3(name, n, dllname, notimp, err, 0)
|
||||||
|
|
||||||
/* Main DLL setup stuff. */
|
/* Main DLL setup stuff. */
|
||||||
|
#ifdef __x86_64__
|
||||||
#define LoadDLLfuncEx3(name, n, dllname, notimp, err, no_resolve_on_fork) \
|
#define LoadDLLfuncEx3(name, n, dllname, notimp, err, no_resolve_on_fork) \
|
||||||
LoadDLLprime (dllname, dll_func_load, no_resolve_on_fork) \
|
LoadDLLprime (dllname, dll_func_load, no_resolve_on_fork) \
|
||||||
__asm__ (" \n\
|
__asm__ (" \n\
|
||||||
|
@ -116,6 +121,9 @@ _win32_" #name ": \n\
|
||||||
.asciz \"" #name "\" \n\
|
.asciz \"" #name "\" \n\
|
||||||
.text \n\
|
.text \n\
|
||||||
");
|
");
|
||||||
|
#else
|
||||||
|
#error unimplemented for this target
|
||||||
|
#endif
|
||||||
|
|
||||||
/* DLL loader helper functions used during initialization. */
|
/* DLL loader helper functions used during initialization. */
|
||||||
|
|
||||||
|
@ -131,6 +139,7 @@ extern "C" void dll_chain () __asm__ ("dll_chain");
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
|
||||||
|
#ifdef __x86_64__
|
||||||
__asm__ (" \n\
|
__asm__ (" \n\
|
||||||
.section .rdata,\"r\" \n\
|
.section .rdata,\"r\" \n\
|
||||||
msg1: \n\
|
msg1: \n\
|
||||||
|
@ -192,6 +201,9 @@ dll_chain: \n\
|
||||||
push %rax # Restore 'return address' \n\
|
push %rax # Restore 'return address' \n\
|
||||||
jmp *%rdx # Jump to next init function \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.
|
/* C representations of the two info blocks described above.
|
||||||
FIXME: These structures confuse gdb for some reason. GDB can print
|
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
|
#define RETRY_COUNT 10
|
||||||
|
|
||||||
/* The standard DLL initialization routine. */
|
/* The standard DLL initialization routine. */
|
||||||
|
#ifdef __x86_64__
|
||||||
|
|
||||||
/* On x86_64, we need assembler wrappers for std_dll_init and wsock_init.
|
/* 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
|
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)
|
INIT_WRAPPER (std_dll_init)
|
||||||
|
|
||||||
|
#else
|
||||||
|
#error unimplemented for this target
|
||||||
|
#endif
|
||||||
|
|
||||||
__attribute__ ((used, noinline)) static two_addr_t
|
__attribute__ ((used, noinline)) static two_addr_t
|
||||||
std_dll_init (struct func_info *func)
|
std_dll_init (struct func_info *func)
|
||||||
{
|
{
|
||||||
|
@ -341,8 +358,12 @@ std_dll_init (struct func_info *func)
|
||||||
|
|
||||||
/* Initialization function for winsock stuff. */
|
/* Initialization function for winsock stuff. */
|
||||||
|
|
||||||
|
#ifdef __x86_64__
|
||||||
/* See above comment preceeding std_dll_init. */
|
/* See above comment preceeding std_dll_init. */
|
||||||
INIT_WRAPPER (wsock_init)
|
INIT_WRAPPER (wsock_init)
|
||||||
|
#else
|
||||||
|
#error unimplemented for this target
|
||||||
|
#endif
|
||||||
|
|
||||||
__attribute__ ((used, noinline)) static two_addr_t
|
__attribute__ ((used, noinline)) static two_addr_t
|
||||||
wsock_init (struct func_info *func)
|
wsock_init (struct func_info *func)
|
||||||
|
|
|
@ -18,6 +18,7 @@ cpuid (uint32_t *a, uint32_t *b, uint32_t *c, uint32_t *d, uint32_t ain,
|
||||||
: "a" (ain), "c" (cin));
|
: "a" (ain), "c" (cin));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef __x86_64__
|
||||||
static inline bool __attribute ((always_inline))
|
static inline bool __attribute ((always_inline))
|
||||||
can_set_flag (uint32_t long flag)
|
can_set_flag (uint32_t long flag)
|
||||||
{
|
{
|
||||||
|
@ -38,5 +39,8 @@ can_set_flag (uint32_t long flag)
|
||||||
);
|
);
|
||||||
return ((r1 ^ r2) & flag) != 0;
|
return ((r1 ^ r2) & flag) != 0;
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
#error unimplemented for this target
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif // !CPUID_H
|
#endif // !CPUID_H
|
||||||
|
|
|
@ -626,7 +626,11 @@ dofork (void **proc, bool *with_forkables)
|
||||||
ischild = !!setjmp (grouped.ch.jmp);
|
ischild = !!setjmp (grouped.ch.jmp);
|
||||||
|
|
||||||
volatile char * volatile stackp;
|
volatile char * volatile stackp;
|
||||||
|
#ifdef __x86_64__
|
||||||
__asm__ volatile ("movq %%rsp,%0": "=r" (stackp));
|
__asm__ volatile ("movq %%rsp,%0": "=r" (stackp));
|
||||||
|
#else
|
||||||
|
#error unimplemented for this target
|
||||||
|
#endif
|
||||||
|
|
||||||
if (!ischild)
|
if (!ischild)
|
||||||
res = grouped.parent (stackp);
|
res = grouped.parent (stackp);
|
||||||
|
|
|
@ -36,7 +36,11 @@ __attribute__((__gnu_inline__))
|
||||||
extern inline struct _reent *__getreent (void)
|
extern inline struct _reent *__getreent (void)
|
||||||
{
|
{
|
||||||
register char *ret;
|
register char *ret;
|
||||||
|
#ifdef __x86_64__
|
||||||
__asm __volatile__ ("movq %%gs:8,%0" : "=r" (ret));
|
__asm __volatile__ ("movq %%gs:8,%0" : "=r" (ret));
|
||||||
|
#else
|
||||||
|
#error unimplemented for this target
|
||||||
|
#endif
|
||||||
return (struct _reent *) (ret - __CYGTLS_PADSIZE__);
|
return (struct _reent *) (ret - __CYGTLS_PADSIZE__);
|
||||||
}
|
}
|
||||||
#endif /* _LIBC || __INSIDE_CYGWIN__ */
|
#endif /* _LIBC || __INSIDE_CYGWIN__ */
|
||||||
|
|
|
@ -19,6 +19,7 @@ extern "C" {
|
||||||
Define a struct __mcontext, which should be identical in layout to the Win32
|
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.
|
API type CONTEXT with the addition of oldmask and cr2 fields at the end.
|
||||||
*/
|
*/
|
||||||
|
#ifdef __x86_64__
|
||||||
|
|
||||||
struct _uc_fpxreg {
|
struct _uc_fpxreg {
|
||||||
__uint16_t significand[4];
|
__uint16_t significand[4];
|
||||||
|
@ -97,6 +98,10 @@ struct __attribute__ ((__aligned__ (16))) __mcontext
|
||||||
__uint64_t cr2;
|
__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
|
/* 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. */
|
defined. This is not sizeof(CONTEXT) due to historical accidents. */
|
||||||
#define __COPY_CONTEXT_SIZE 816
|
#define __COPY_CONTEXT_SIZE 816
|
||||||
|
|
|
@ -413,6 +413,7 @@ pthread_wrapper (PVOID arg)
|
||||||
/* Initialize new _cygtls. */
|
/* Initialize new _cygtls. */
|
||||||
_my_tls.init_thread (wrapper_arg.stackbase - __CYGTLS_PADSIZE__,
|
_my_tls.init_thread (wrapper_arg.stackbase - __CYGTLS_PADSIZE__,
|
||||||
(DWORD (*)(void*, void*)) wrapper_arg.func);
|
(DWORD (*)(void*, void*)) wrapper_arg.func);
|
||||||
|
#ifdef __x86_64__
|
||||||
__asm__ ("\n\
|
__asm__ ("\n\
|
||||||
leaq %[WRAPPER_ARG], %%rbx # Load &wrapper_arg into rbx \n\
|
leaq %[WRAPPER_ARG], %%rbx # Load &wrapper_arg into rbx \n\
|
||||||
movq (%%rbx), %%r12 # Load thread func into r12 \n\
|
movq (%%rbx), %%r12 # Load thread func into r12 \n\
|
||||||
|
@ -436,6 +437,9 @@ pthread_wrapper (PVOID arg)
|
||||||
call *%%r12 # Call thread func \n"
|
call *%%r12 # Call thread func \n"
|
||||||
: : [WRAPPER_ARG] "o" (wrapper_arg),
|
: : [WRAPPER_ARG] "o" (wrapper_arg),
|
||||||
[CYGTLS] "i" (__CYGTLS_PADSIZE__));
|
[CYGTLS] "i" (__CYGTLS_PADSIZE__));
|
||||||
|
#else
|
||||||
|
#error unimplemented for this target
|
||||||
|
#endif
|
||||||
/* pthread::thread_init_wrapper calls pthread::exit, which
|
/* pthread::thread_init_wrapper calls pthread::exit, which
|
||||||
in turn calls ExitThread, so we should never arrive here. */
|
in turn calls ExitThread, so we should never arrive here. */
|
||||||
api_fatal ("Dumb thinko in pthread handling. Whip the developer.");
|
api_fatal ("Dumb thinko in pthread handling. Whip the developer.");
|
||||||
|
@ -698,6 +702,7 @@ err:
|
||||||
return thread;
|
return thread;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef __x86_64__
|
||||||
/* These functions are almost verbatim FreeBSD code (even if the header of
|
/* These functions are almost verbatim FreeBSD code (even if the header of
|
||||||
one file mentiones NetBSD), just wrapped in the minimum required code to
|
one file mentiones NetBSD), just wrapped in the minimum required code to
|
||||||
make them work with the MS AMD64 ABI.
|
make them work with the MS AMD64 ABI.
|
||||||
|
@ -900,6 +905,10 @@ wmempcpy: \n\
|
||||||
.seh_endproc \n\
|
.seh_endproc \n\
|
||||||
");
|
");
|
||||||
|
|
||||||
|
#else
|
||||||
|
#error unimplemented for this target
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Signal the thread name to any attached debugger
|
/* Signal the thread name to any attached debugger
|
||||||
|
|
||||||
(See "How to: Set a Thread Name in Native Code"
|
(See "How to: Set a Thread Name in Native Code"
|
||||||
|
|
Loading…
Reference in New Issue