abi: support for most basic calling conventions
authorMichael Wallner <mike@php.net>
Wed, 8 Feb 2017 18:26:54 +0000 (19:26 +0100)
committerMichael Wallner <mike@php.net>
Wed, 8 Feb 2017 18:26:54 +0000 (19:26 +0100)
README.md
m4/psi/psi.m4
src/libffi.c
src/libjit.c
src/types/decl_abi.c

index 5d20134bc0f8a6ca5bb239a957feb5a9a0aca445..3b4c47898df844e508874e69471d15406b5b2979 100644 (file)
--- a/README.md
+++ b/README.md
@@ -225,7 +225,7 @@ extern char *strerror(int errnum);
 
 You may specify a non-standard calling convention in place of `extern`, where `default` and `cdecl` have the same meaning as `extern`.
 
-Additionally recognized calling conventions include: `mscdecl`, `stdcall` and `fastcall`.
+Additionally recognized calling conventions include: `stdcall` and `fastcall`.
 
 ### Constants
 
index 67878346db61e5765024af4e225c09502888b94d..9bb1a4bb57408f7b573420199c3d9fb4575bd705 100644 (file)
@@ -470,6 +470,13 @@ AC_DEFUN(PSI_CHECK_LIBFFI, [
                        AC_MSG_WARN([Could not find libffi, please provide the base install path])
                fi
        fi
+       
+       save_CFLAGS=$CFLAGS
+       CFLAGS="$CFLAGS $INCLUDES"
+       AC_CHECK_DECL(FFI_STDCALL,[AC_DEFINE([HAVE_FFI_STDCALL],[1],[ ])],,[#include "ffi.h"])
+       AC_CHECK_DECL(FFI_FASTCALL,[AC_DEFINE([HAVE_FFI_FASTCALL],[1],[ ])],,[#include "ffi.h"])
+       CFLAGS=$save_CFLAGS
+       
        PHP_CHECK_LIBRARY(ffi, ffi_closure_alloc, [
                PHP_CHECK_LIBRARY(ffi, ffi_prep_closure_loc, [
                        AC_DEFINE(PSI_HAVE_FFI_PREP_CLOSURE_LOC, 1, [ ])
index e859dbd1bad9b687c40a14ef46d78bf96819aa10..644b0fed5d8b6d70f64dd34205d62081653b34cd 100644 (file)
@@ -156,6 +156,18 @@ static void psi_ffi_callback(ffi_cif *sig, void *result, void **args, void *data
 }
 
 static inline ffi_abi psi_ffi_abi(const char *convention) {
+       if (FFI_LAST_ABI - 2 != FFI_FIRST_ABI) {
+#ifdef HAVE_FFI_STDCALL
+               if (!strcasecmp(convention, "stdcall")) {
+                       return FFI_STDCALL;
+               }
+#endif
+#ifdef HAVE_FFI_FASTCALL
+               if (!strcasecmp(convention, "fastcall")) {
+                       return FFI_FASTCALL;
+               }
+#endif
+       }
        return FFI_DEFAULT_ABI;
 }
 
index 338e8a73de2b830457b67228204eae3433ae8cfb..a32742a1f709e05649ceee603a0f2fc8a8960522 100644 (file)
@@ -36,6 +36,12 @@ static inline jit_type_t psi_jit_decl_arg_type(struct psi_decl_arg *darg);
 
 static inline jit_abi_t psi_jit_abi(const char *convention)
 {
+       if (!strcasecmp(convention, "stdcall")) {
+               return jit_abi_stdcall;
+       }
+       if (!strcasecmp(convention, "fastcall")) {
+               return jit_abi_fastcall;
+       }
        return jit_abi_cdecl;
 }
 static inline jit_type_t psi_jit_token_type(token_t t)
index 3db51e6c8be2108853dbff41cd78406bd8b40977..60ad161915914e829bcf77a92215b0cbcad33bc6 100644 (file)
@@ -56,7 +56,6 @@ static const char * const abi_ccs[] = {
                "default", /* \                 */
                "extern",  /*  > - all the same */
                "cdecl",   /* /                 */
-               "mscdecl",
                "stdcall",
                "fastcall",
 };