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 5d20134..3b4c478 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 6787834..9bb1a4b 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 e859dbd..644b0fe 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 338e8a7..a32742a 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 3db51e6..60ad161 100644 (file)
@@ -56,7 +56,6 @@ static const char * const abi_ccs[] = {
                "default", /* \                 */
                "extern",  /*  > - all the same */
                "cdecl",   /* /                 */
-               "mscdecl",
                "stdcall",
                "fastcall",
 };