Skip to content

Commit

Permalink
Adding ARM Windows support, WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
ktakashi committed Nov 27, 2023
1 parent a86690e commit 7d204f7
Show file tree
Hide file tree
Showing 6 changed files with 83 additions and 67 deletions.
3 changes: 1 addition & 2 deletions ext/ffi/libffi/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ set(PACKAGE "libffi")
set(PACKAGE_BUGREPORT "http://sourceware.org/libffi.html")
set(PACKAGE_NAME ${PACKAGE})
set(PACKAGE_TARNAME ${PACKAGE})
set(PACKAGE_VERSION "3.0.13")
set(PACKAGE_VERSION "3.4.4")
set(PACKAGE_STRING "${PACKAGE} ${PACKAGE_VERSION}")
set(VERSION "${PACKAGE_VERSION}")

Expand Down Expand Up @@ -196,7 +196,6 @@ else ()
DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/include)
elseif (${TARGET} STREQUAL "ARM64_WIN64")
set(libffi_platform_source src/aarch64/ffi.c)
set(libffi_platform_asm src/aarch64/sysv.S)
set(libffi_platform_asm src/aarch64/win64_armasm.S)
file(COPY src/aarch64/ffitarget.h
DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/include)
Expand Down
124 changes: 62 additions & 62 deletions ext/ffi/libffi/cmake/fficonfig.h.in
Original file line number Diff line number Diff line change
@@ -1,194 +1,194 @@
/* fficonfig.h.in. Generated from configure.ac by autoheader. */

/* Define if building universal (internal helper macro) */
#undef AC_APPLE_UNIVERSAL_BUILD
#cmakedefine AC_APPLE_UNIVERSAL_BUILD

/* Define to 1 if using 'alloca.c'. */
#undef C_ALLOCA
#cmakedefine C_ALLOCA @C_ALLOCA@

/* Define to the flags needed for the .section .eh_frame directive. */
#undef EH_FRAME_FLAGS
#cmakedefine EH_FRAME_FLAGS "@EH_FRAME_FLAGS@"

/* Define this if you want extra debugging. */
#undef FFI_DEBUG
#cmakedefine FFI_DEBUG

/* Define this if you want statically defined trampolines */
#undef FFI_EXEC_STATIC_TRAMP
#cmakedefine FFI_EXEC_STATIC_TRAMP @FFI_EXEC_STATIC_TRAMP@

/* Cannot use PROT_EXEC on this target, so, we revert to alternative means */
#undef FFI_EXEC_TRAMPOLINE_TABLE
#cmakedefine FFI_EXEC_TRAMPOLINE_TABLE @FFI_EXEC_TRAMPOLINE_TABLE@

/* Define this if you want to enable pax emulated trampolines (experimental)
*/
#undef FFI_MMAP_EXEC_EMUTRAMP_PAX
#cmakedefine FFI_MMAP_EXEC_EMUTRAMP_PAX @FFI_MMAP_EXEC_EMUTRAMP_PAX@

/* Cannot use malloc on this target, so, we revert to alternative means */
#undef FFI_MMAP_EXEC_WRIT
#cmakedefine FFI_MMAP_EXEC_WRIT @FFI_MMAP_EXEC_WRIT@

/* Define this if you do not want support for the raw API. */
#undef FFI_NO_RAW_API
#cmakedefine FFI_NO_RAW_API

/* Define this if you do not want support for aggregate types. */
#undef FFI_NO_STRUCTS
#cmakedefine FFI_NO_STRUCTS

/* Define to 1 if you have 'alloca', as a function or macro. */
#undef HAVE_ALLOCA
#cmakedefine HAVE_ALLOCA @HAVE_ALLOCA@

/* Define to 1 if <alloca.h> works. */
#undef HAVE_ALLOCA_H
#cmakedefine HAVE_ALLOCA_H @HAVE_ALLOCA_H@

/* Define if your assembler supports .cfi_* directives. */
#undef HAVE_AS_CFI_PSEUDO_OP
#cmakedefine HAVE_AS_CFI_PSEUDO_OP @HAVE_AS_CFI_PSEUDO_OP@

/* Define if your assembler supports .register. */
#undef HAVE_AS_REGISTER_PSEUDO_OP
#cmakedefine HAVE_AS_REGISTER_PSEUDO_OP @HAVE_AS_REGISTER_PSEUDO_OP@

/* Define if the compiler uses zarch features. */
#undef HAVE_AS_S390_ZARCH
#cmakedefine HAVE_AS_S390_ZARCH @HAVE_AS_S390_ZARCH@

/* Define if your assembler and linker support unaligned PC relative relocs.
*/
#undef HAVE_AS_SPARC_UA_PCREL
#cmakedefine HAVE_AS_SPARC_UA_PCREL @HAVE_AS_SPARC_UA_PCREL@

/* Define if your assembler supports unwind section type. */
#undef HAVE_AS_X86_64_UNWIND_SECTION_TYPE
#cmakedefine HAVE_AS_X86_64_UNWIND_SECTION_TYPE @HAVE_AS_X86_64_UNWIND_SECTION_TYPE@

/* Define if your assembler supports PC relative relocs. */
#undef HAVE_AS_X86_PCREL
#cmakedefine HAVE_AS_X86_PCREL @HAVE_AS_X86_PCREL@

/* Define to 1 if you have the <dlfcn.h> header file. */
#undef HAVE_DLFCN_H
#cmakedefine HAVE_DLFCN_H @HAVE_DLFCN_H@

/* Define if __attribute__((visibility("hidden"))) is supported. */
#undef HAVE_HIDDEN_VISIBILITY_ATTRIBUTE
#cmakedefine HAVE_HIDDEN_VISIBILITY_ATTRIBUTE @HAVE_HIDDEN_VISIBILITY_ATTRIBUTE@

/* Define to 1 if you have the <inttypes.h> header file. */
#undef HAVE_INTTYPES_H
#cmakedefine HAVE_INTTYPES_H @HAVE_INTTYPES_H@

/* Define if you have the long double type and it is bigger than a double */
#undef HAVE_LONG_DOUBLE
#cmakedefine HAVE_LONG_DOUBLE @HAVE_LONG_DOUBLE@

/* Define if you support more than one size of the long double type */
#undef HAVE_LONG_DOUBLE_VARIANT
#cmakedefine HAVE_LONG_DOUBLE_VARIANT @HAVE_LONG_DOUBLE_VARIANT@

/* Define to 1 if you have the `memcpy' function. */
#undef HAVE_MEMCPY
#cmakedefine HAVE_MEMCPY @HAVE_MEMCPY@

/* Define to 1 if you have the `memfd_create' function. */
#undef HAVE_MEMFD_CREATE
#cmakedefine HAVE_MEMFD_CREATE @HAVE_MEMFD_CREATE@

/* Define to 1 if you have the `mkostemp' function. */
#undef HAVE_MKOSTEMP
#cmakedefine HAVE_MKOSTEMP @HAVE_MKOSTEMP@

/* Define to 1 if you have the `mkstemp' function. */
#undef HAVE_MKSTEMP
#cmakedefine HAVE_MKSTEMP @HAVE_MKSTEMP@

/* Define to 1 if you have the `mmap' function. */
#undef HAVE_MMAP
#cmakedefine HAVE_MMAP @HAVE_MMAP@

/* Define if mmap with MAP_ANON(YMOUS) works. */
#undef HAVE_MMAP_ANON
#cmakedefine HAVE_MMAP_ANON @HAVE_MMAP_ANON@

/* Define if mmap of /dev/zero works. */
#undef HAVE_MMAP_DEV_ZERO
#cmakedefine HAVE_MMAP_DEV_ZERO @HAVE_MMAP_DEV_ZERO@

/* Define if read-only mmap of a plain file works. */
#undef HAVE_MMAP_FILE
#cmakedefine HAVE_MMAP_FILE @HAVE_MMAP_FILE@

/* Define if your compiler supports pointer authentication. */
#undef HAVE_PTRAUTH
#cmakedefine HAVE_PTRAUTH @HAVE_PTRAUTH@

/* Define if .eh_frame sections should be read-only. */
#undef HAVE_RO_EH_FRAME
#cmakedefine HAVE_RO_EH_FRAME @HAVE_RO_EH_FRAME@

/* Define to 1 if you have the <stdint.h> header file. */
#undef HAVE_STDINT_H
#cmakedefine HAVE_STDINT_H @HAVE_STDINT_H@

/* Define to 1 if you have the <stdio.h> header file. */
#undef HAVE_STDIO_H
#cmakedefine HAVE_STDIO_H @HAVE_STDIO_H@

/* Define to 1 if you have the <stdlib.h> header file. */
#undef HAVE_STDLIB_H
#cmakedefine HAVE_STDLIB_H @HAVE_STDLIB_H@

/* Define to 1 if you have the <strings.h> header file. */
#undef HAVE_STRINGS_H
#cmakedefine HAVE_STRINGS_H @HAVE_STRINGS_H@

/* Define to 1 if you have the <string.h> header file. */
#undef HAVE_STRING_H
#cmakedefine HAVE_STRING_H @HAVE_STRING_H@

/* Define to 1 if you have the <sys/memfd.h> header file. */
#undef HAVE_SYS_MEMFD_H
#cmakedefine HAVE_SYS_MEMFD_H @HAVE_SYS_MMAN_H@

/* Define to 1 if you have the <sys/mman.h> header file. */
#undef HAVE_SYS_MMAN_H
#cmakedefine HAVE_SYS_MMAN_H

/* Define to 1 if you have the <sys/stat.h> header file. */
#undef HAVE_SYS_STAT_H
#cmakedefine HAVE_SYS_STAT_H @HAVE_SYS_STAT_H@

/* Define to 1 if you have the <sys/types.h> header file. */
#undef HAVE_SYS_TYPES_H
#cmakedefine HAVE_SYS_TYPES_H @HAVE_SYS_TYPES_H@

/* Define to 1 if you have the <unistd.h> header file. */
#undef HAVE_UNISTD_H
#cmakedefine HAVE_UNISTD_H @HAVE_UNISTD_H@

/* Define to 1 if GNU symbol versioning is used for libatomic. */
#undef LIBFFI_GNU_SYMBOL_VERSIONING
#cmakedefine LIBFFI_GNU_SYMBOL_VERSIONING

/* Define to the sub-directory where libtool stores uninstalled libraries. */
#undef LT_OBJDIR
#cmakedefine LT_OBJDIR

/* Name of package */
#undef PACKAGE
#cmakedefine PACKAGE "@PACKAGE@"

/* Define to the address where bug reports for this package should be sent. */
#undef PACKAGE_BUGREPORT
#cmakedefine PACKAGE_BUGREPORT "@PACKAGE_BUGREPORT@"

/* Define to the full name of this package. */
#undef PACKAGE_NAME
#cmakedefine PACKAGE_NAME "@PACKAGE_NAME@"

/* Define to the full name and version of this package. */
#undef PACKAGE_STRING
#cmakedefine PACKAGE_STRING "@PACKAGE_STRING@"

/* Define to the one symbol short name of this package. */
#undef PACKAGE_TARNAME
#cmakedefine PACKAGE_TARNAME "@PACKAGE_TARNAME@"

/* Define to the home page for this package. */
#undef PACKAGE_URL
#cmakedefine PACKAGE_URL "@PACKAGE_URL@"

/* Define to the version of this package. */
#undef PACKAGE_VERSION
#cmakedefine PACKAGE_VERSION "@PACKAGE_VERSION@"

/* The size of `double', as computed by sizeof. */
#undef SIZEOF_DOUBLE
#cmakedefine SIZEOF_DOUBLE @SIZEOF_DOUBLE@

/* The size of `long double', as computed by sizeof. */
#undef SIZEOF_LONG_DOUBLE
#cmakedefine SIZEOF_LONG_DOUBLE @SIZEOF_LONG_DOUBLE@

/* The size of `size_t', as computed by sizeof. */
#undef SIZEOF_SIZE_T
#cmakedefine SIZEOF_SIZE_T @SIZEOF_SIZE_T@

/* If using the C implementation of alloca, define if you know the
direction of stack growth for your system; otherwise it will be
automatically deduced at runtime.
STACK_DIRECTION > 0 => grows toward higher addresses
STACK_DIRECTION < 0 => grows toward lower addresses
STACK_DIRECTION = 0 => direction of growth unknown */
#undef STACK_DIRECTION
#cmakedefine STACK_DIRECTION

/* Define to 1 if all of the C90 standard headers exist (not just the ones
required in a freestanding environment). This macro is provided for
backward compatibility; new code need not use it. */
#undef STDC_HEADERS
#cmakedefine STDC_HEADERS @STDC_HEADERS@

/* Define if symbols are underscored. */
#undef SYMBOL_UNDERSCORE
#cmakedefine SYMBOL_UNDERSCORE

/* Define this if you are using Purify and want to suppress spurious messages.
*/
#undef USING_PURIFY
#cmakedefine USING_PURIFY

/* Version number of package */
#undef VERSION
#cmakedefine VERSION @VERSION@

/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
significant byte first (like Motorola and SPARC, unlike Intel). */
Expand All @@ -198,12 +198,12 @@
# endif
#else
# ifndef WORDS_BIGENDIAN
# undef WORDS_BIGENDIAN
# cmakedefine WORDS_BIGENDIAN @WORDS_BIGENDIAN@
# endif
#endif

/* Define to `unsigned int' if <sys/types.h> does not define. */
#undef size_t
#cmakedefine size_t


#ifdef HAVE_HIDDEN_VISIBILITY_ATTRIBUTE
Expand Down
6 changes: 6 additions & 0 deletions ext/socket/sagittarius-socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ typedef long suseconds_t;
# ifdef EPIPE
# undef EPIPE
# endif
# ifdef EINPROGRESS
# undef EINPROGRESS
# endif
# ifdef ETIMEDOUT
# undef ETIMEDOUT
# endif
# define EINTR WSAEINTR
# define EAGAIN WSATRY_AGAIN
# define EWOULDBLOCK WSAEWOULDBLOCK
Expand Down
8 changes: 8 additions & 0 deletions src/os/win/system.c
Original file line number Diff line number Diff line change
Expand Up @@ -938,11 +938,19 @@ static int fill_trace(EXCEPTION_POINTERS *ep, void **trace)
ct = GetCurrentThread();

#if defined(_WIN64)
# if defined(_M_ARM64)
machine_type = IMAGE_FILE_MACHINE_ARM64; /* found in winnt.h */
memset(&stack_frame, 0, sizeof(stack_frame));
stack_frame.AddrPC.Offset = cr.Pc;
stack_frame.AddrFrame.Offset = cr.Fp;
stack_frame.AddrStack.Offset = cr.Sp;
# else
machine_type = IMAGE_FILE_MACHINE_AMD64;
memset(&stack_frame, 0, sizeof(stack_frame));
stack_frame.AddrPC.Offset = cr.Rip;
stack_frame.AddrFrame.Offset = cr.Rbp;
stack_frame.AddrStack.Offset = cr.Rsp;
# endif
#else
machine_type = IMAGE_FILE_MACHINE_I386;
memset(&stack_frame, 0, sizeof(stack_frame));
Expand Down
5 changes: 5 additions & 0 deletions src/os/win/thread.c
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,11 @@ void Sg_ExitThread(SgInternalThread *thread, void *ret)
#define WIN_STCKPTR(ctx) ((ctx).Rsp)
#endif

#if defined(_M_ARM64) || defined(_M_ARM)
#define WIN_PROGCTR(ctx) ((ctx).Pc)
#define WIN_STCKPTR(ctx) ((ctx).Sp)
#endif

#if !defined(WIN_PROGCTR)
#error Module contains CPU-specific code; modify and recompile.
#endif
Expand Down
4 changes: 1 addition & 3 deletions src/os/win/win_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,12 @@
#define W_OK 2
#define R_OK 4

#include "../../shortnames.incl"

/* from mosh */
static const wchar_t* utf32ToUtf16(SgString *path)
{
int size = SG_STRING_SIZE(path);
SgCodec *codec = Sg_MakeUtf16Codec(UTF_16LE);
SgTranscoder *tcoder = Sg_MakeTranscoder(codec, LF, SG_REPLACE_ERROR);
SgTranscoder *tcoder = Sg_MakeTranscoder(codec, SG_EOL_STYLE_LF, SG_REPLACE_ERROR);
SgPort *out, *tout;
SgBytePort bp;
SgTranscodedPort tp;
Expand Down

0 comments on commit 7d204f7

Please sign in to comment.