@@ -790,7 +790,7 @@ ffi_prep_closure_loc (ffi_closure *closure,
790790 void * user_data ,
791791 void * codeloc )
792792{
793- if (cif -> abi != FFI_SYSV )
793+ if (cif -> abi != FFI_SYSV && cif -> abi != FFI_WIN64 )
794794 return FFI_BAD_ABI ;
795795
796796 void (* start )(void );
@@ -851,7 +851,7 @@ ffi_prep_go_closure (ffi_go_closure *closure, ffi_cif* cif,
851851{
852852 void (* start )(void );
853853
854- if (cif -> abi != FFI_SYSV )
854+ if (cif -> abi != FFI_SYSV && cif -> abi != FFI_WIN64 )
855855 return FFI_BAD_ABI ;
856856
857857 if (cif -> flags & AARCH64_FLAG_ARG_V )
@@ -891,11 +891,18 @@ ffi_closure_SYSV_inner (ffi_cif *cif,
891891 void * stack , void * rvalue , void * struct_rvalue )
892892{
893893 void * * avalue = (void * * ) alloca (cif -> nargs * sizeof (void * ));
894- int i , h , nargs , flags ;
894+ int i , h , nargs , flags , isvariadic = 0 ;
895895 struct arg_state state ;
896896
897897 arg_init (& state );
898898
899+ flags = cif -> flags ;
900+ if (flags & AARCH64_FLAG_VARARG )
901+ {
902+ isvariadic = 1 ;
903+ flags &= ~AARCH64_FLAG_VARARG ;
904+ }
905+
899906 for (i = 0 , nargs = cif -> nargs ; i < nargs ; i ++ )
900907 {
901908 ffi_type * ty = cif -> arg_types [i ];
@@ -930,8 +937,7 @@ ffi_closure_SYSV_inner (ffi_cif *cif,
930937 if (h )
931938 {
932939 n = 4 - (h & 3 );
933- #ifdef _WIN32 /* for handling armasm calling convention */
934- if (cif -> is_variadic )
940+ if (cif -> abi == FFI_WIN64 && isvariadic )
935941 {
936942 if (state .ngrn + n <= N_X_ARG_REG )
937943 {
@@ -957,7 +963,6 @@ ffi_closure_SYSV_inner (ffi_cif *cif,
957963 }
958964 else
959965 {
960- #endif /* for handling armasm calling convention */
961966 if (state .nsrn + n <= N_V_ARG_REG )
962967 {
963968 void * reg = & context -> v [state .nsrn ];
@@ -970,9 +975,7 @@ ffi_closure_SYSV_inner (ffi_cif *cif,
970975 avalue [i ] = allocate_to_stack (& state , stack ,
971976 ty -> alignment , s );
972977 }
973- #ifdef _WIN32 /* for handling armasm calling convention */
974978 }
975- #endif /* for handling armasm calling convention */
976979 }
977980 else if (s > 16 )
978981 {
@@ -1013,7 +1016,6 @@ ffi_closure_SYSV_inner (ffi_cif *cif,
10131016#endif
10141017 }
10151018
1016- flags = cif -> flags ;
10171019 if (flags & AARCH64_RET_IN_MEM )
10181020 rvalue = struct_rvalue ;
10191021
0 commit comments