Commit c43eae24de28d9d1255f0c7645ecb2276e624062

Thomas de Grivel 2023-03-06T16:08:49

fix compatibility with C99

diff --git a/.gitignore b/.gitignore
index dea0b1b..2e7cc7c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -44,3 +44,4 @@ __pycache__
 .docker_home
 emsdk
 test-results
+x86_64-*/
diff --git a/include/ffi.h.in b/include/ffi.h.in
index e7fe963..98d5d56 100644
--- a/include/ffi.h.in
+++ b/include/ffi.h.in
@@ -338,7 +338,7 @@ typedef struct {
   union {
     char tramp[FFI_TRAMPOLINE_SIZE];
     void *ftramp;
-  };
+  } tramp;
 #endif
   ffi_cif   *cif;
   void     (*fun)(ffi_cif*,void*,void**,void*);
diff --git a/src/closures.c b/src/closures.c
index 0f2d619..a126d0e 100644
--- a/src/closures.c
+++ b/src/closures.c
@@ -1012,7 +1012,7 @@ ffi_closure_alloc (size_t size, void **code)
         return NULL;
       }
       *code = FFI_FN (ffi_tramp_get_addr (ftramp));
-      ((ffi_closure *) ptr)->ftramp = ftramp;
+      ((ffi_closure *) ptr)->tramp.ftramp = ftramp;
     }
 
   return ptr;
@@ -1030,7 +1030,7 @@ ffi_data_to_code_pointer (void *data)
     {
       if (!ffi_tramp_is_supported ())
         return add_segment_exec_offset (data, seg);
-      return ffi_tramp_get_addr (((ffi_closure *) data)->ftramp);
+      return ffi_tramp_get_addr (((ffi_closure *) data)->tramp.ftramp);
     }
   else
     return data;
@@ -1050,7 +1050,7 @@ ffi_closure_free (void *ptr)
     ptr = sub_segment_exec_offset (ptr, seg);
 #endif
   if (ffi_tramp_is_supported ())
-    ffi_tramp_free (((ffi_closure *) ptr)->ftramp);
+    ffi_tramp_free (((ffi_closure *) ptr)->tramp.ftramp);
 
   dlfree (ptr);
 }
diff --git a/src/x86/ffi64.c b/src/x86/ffi64.c
index 6a8e37f..996b3b8 100644
--- a/src/x86/ffi64.c
+++ b/src/x86/ffi64.c
@@ -768,7 +768,7 @@ ffi_prep_closure_loc (ffi_closure* closure,
     0x0f, 0x1f, 0x80, 0x00, 0x00, 0x00, 0x00
   };
   void (*dest)(void);
-  char *tramp = closure->tramp;
+  char *tramp = closure->tramp.tramp;
 
 #ifndef __ILP32__
   if (cif->abi == FFI_EFI64 || cif->abi == FFI_GNUW64)
@@ -925,8 +925,8 @@ ffi_prep_go_closure (ffi_go_closure* closure, ffi_cif* cif,
     return FFI_BAD_ABI;
 
   closure->tramp = (cif->flags & UNIX64_FLAG_XMM_ARGS
-		    ? ffi_go_closure_unix64_sse
-		    : ffi_go_closure_unix64);
+                    ? ffi_go_closure_unix64_sse
+                    : ffi_go_closure_unix64);
   closure->cif = cif;
   closure->fun = fun;
 
diff --git a/src/x86/ffiw64.c b/src/x86/ffiw64.c
index 8271658..46c0dde 100644
--- a/src/x86/ffiw64.c
+++ b/src/x86/ffiw64.c
@@ -239,7 +239,7 @@ EFI64(ffi_prep_closure_loc)(ffi_closure* closure,
     /* nopl  0(%rax) */
     0x0f, 0x1f, 0x80, 0x00, 0x00, 0x00, 0x00
   };
-  char *tramp = closure->tramp;
+  char *tramp = closure->tramp.tramp;
 
   switch (cif->abi)
     {