Martin Storsjo : arm64: Use __builtin_ms_va_list and __attribute__((ms_abi )) on arm64.

Alexandre Julliard julliard at winehq.org
Thu Sep 13 03:49:14 CDT 2018


Module: wine
Branch: stable
Commit: 295359a17447d6ad487b6c652c3a98bbe17cee6e
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=295359a17447d6ad487b6c652c3a98bbe17cee6e

Author: Martin Storsjo <martin at martin.st>
Date:   Wed May  9 23:34:57 2018 +0300

arm64: Use __builtin_ms_va_list and __attribute__((ms_abi)) on arm64.

Windows uses a different ABI for va_list on arm64 just like on x86_64.

On x86_64, the calling convention for windows functions is completely
different from the one on other platforms. On arm64, they're mostly the
same, with the only exception being variadic functions (where all float
arguments are passed in integer registers, since the va_list is a single
pointer).

Any functions using __builtin_ms_va_start need to be decorated with
__attribute__((ms_abi)).

Signed-off-by: Martin Storsjo <martin at martin.st>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
(cherry picked from commit 8fb8cc03c3edb599dd98f369e14a08f899cbff95)
Signed-off-by: Michael Stefaniuc <mstefani at winehq.org>

---

 configure                | 24 ++++++++++++++++++++++++
 configure.ac             |  7 +++++++
 include/msvcrt/crtdefs.h |  6 +++++-
 include/windef.h         |  6 +++++-
 include/wine/test.h      |  4 ++--
 5 files changed, 43 insertions(+), 4 deletions(-)

diff --git a/configure b/configure
index 9f17560..8a7ea65 100755
--- a/configure
+++ b/configure
@@ -5314,6 +5314,30 @@ rm -f core conftest.err conftest.$ac_objext \
     TARGETFLAGS="-marm -mfloat-abi=$float_abi"
 
     ;;
+  aarch64*)
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC supports __builtin_ms_va_list" >&5
+$as_echo_n "checking whether $CC supports __builtin_ms_va_list... " >&6; }
+    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <stdarg.h>
+int
+main ()
+{
+void func(__builtin_ms_va_list *args);
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+                       as_fn_error $? "You need clang >= 5.0 to build Wine for arm64." "$LINENO" 5
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+    ;;
   i[3456789]86*)
     enable_win16=${enable_win16:-yes}
     ;;
diff --git a/configure.ac b/configure.ac
index ec2e16f..201ef0c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -202,6 +202,13 @@ case $host in
     CFLAGS="$CFLAGS -marm -mfloat-abi=$float_abi"
     AC_SUBST(TARGETFLAGS,"-marm -mfloat-abi=$float_abi")
     ;;
+  aarch64*)
+    AC_MSG_CHECKING([whether $CC supports __builtin_ms_va_list])
+    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdarg.h>]], [[void func(__builtin_ms_va_list *args);]])],
+                      [AC_MSG_RESULT([yes])],
+                      [AC_MSG_RESULT([no])
+                       AC_MSG_ERROR([You need clang >= 5.0 to build Wine for arm64.])])
+    ;;
   i[[3456789]]86*)
     enable_win16=${enable_win16:-yes}
     ;;
diff --git a/include/msvcrt/crtdefs.h b/include/msvcrt/crtdefs.h
index a9edef5..0c0b087 100644
--- a/include/msvcrt/crtdefs.h
+++ b/include/msvcrt/crtdefs.h
@@ -62,6 +62,8 @@
 #  endif
 # elif defined(__arm__) && defined (__GNUC__) && !defined(__SOFTFP__)
 #   define __stdcall __attribute__((pcs("aapcs-vfp")))
+# elif defined(__aarch64__) && defined (__GNUC__)
+#  define __stdcall __attribute__((ms_abi))
 # else  /* __i386__ */
 #  define __stdcall
 # endif  /* __i386__ */
@@ -82,13 +84,15 @@
 #  endif
 # elif defined(__arm__) && defined (__GNUC__) && !defined(__SOFTFP__)
 #   define __cdecl __attribute__((pcs("aapcs-vfp")))
+# elif defined(__aarch64__) && defined (__GNUC__)
+#  define __cdecl __attribute__((ms_abi))
 # elif !defined(_MSC_VER)
 #  define __cdecl
 # endif
 #endif /* __cdecl */
 
 #ifndef __ms_va_list
-# if defined(__x86_64__) && defined (__GNUC__)
+# if (defined(__x86_64__) || defined(__aarch64__)) && defined (__GNUC__)
 #  define __ms_va_list __builtin_ms_va_list
 #  define __ms_va_start(list,arg) __builtin_ms_va_start(list,arg)
 #  define __ms_va_end(list) __builtin_ms_va_end(list)
diff --git a/include/windef.h b/include/windef.h
index 8a9f944..d12b14f 100644
--- a/include/windef.h
+++ b/include/windef.h
@@ -71,6 +71,8 @@ extern "C" {
 #  endif
 # elif defined(__arm__) && defined (__GNUC__) && !defined(__SOFTFP__)
 #   define __stdcall __attribute__((pcs("aapcs-vfp")))
+# elif defined(__aarch64__) && defined (__GNUC__)
+#  define __stdcall __attribute__((ms_abi))
 # else  /* __i386__ */
 #  define __stdcall
 # endif  /* __i386__ */
@@ -91,13 +93,15 @@ extern "C" {
 #  endif
 # elif defined(__arm__) && defined (__GNUC__) && !defined(__SOFTFP__)
 #   define __cdecl __attribute__((pcs("aapcs-vfp")))
+# elif defined(__aarch64__) && defined (__GNUC__)
+#  define __cdecl __attribute__((ms_abi))
 # elif !defined(_MSC_VER)
 #  define __cdecl
 # endif
 #endif /* __cdecl */
 
 #ifndef __ms_va_list
-# if defined(__x86_64__) && defined (__GNUC__)
+# if (defined(__x86_64__) || defined(__aarch64__)) && defined (__GNUC__)
 #  define __ms_va_list __builtin_ms_va_list
 #  define __ms_va_start(list,arg) __builtin_ms_va_start(list,arg)
 #  define __ms_va_end(list) __builtin_ms_va_end(list)
diff --git a/include/wine/test.h b/include/wine/test.h
index 4ec66d5..3caff6c 100644
--- a/include/wine/test.h
+++ b/include/wine/test.h
@@ -87,7 +87,7 @@ static inline int winetest_strcmpW( const WCHAR *str1, const WCHAR *str2 )
 #define START_TEST(name) void func_##name(void)
 #endif
 
-#if defined(__x86_64__) && defined(__GNUC__) && defined(__WINE_USE_MSVCRT)
+#if (defined(__x86_64__) || defined(__aarch64__)) && defined(__GNUC__) && defined(__WINE_USE_MSVCRT)
 #define __winetest_cdecl __cdecl
 #define __winetest_va_list __builtin_ms_va_list
 #else
@@ -178,7 +178,7 @@ extern void __winetest_cdecl winetest_trace( const char *msg, ... ) WINETEST_PRI
 #include <stdio.h>
 #include <excpt.h>
 
-#if defined(__x86_64__) && defined(__GNUC__) && defined(__WINE_USE_MSVCRT)
+#if (defined(__x86_64__) || defined(__aarch64__)) && defined(__GNUC__) && defined(__WINE_USE_MSVCRT)
 # define __winetest_va_start(list,arg) __builtin_ms_va_start(list,arg)
 # define __winetest_va_end(list) __builtin_ms_va_end(list)
 #else




More information about the wine-cvs mailing list