summaryrefslogtreecommitdiff
blob: 41821e89140c7c2cc2dfed35c8c6267317cd4551 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
From f4d413725030b35ec2f01733b154489d0b4c6e1d Mon Sep 17 00:00:00 2001
From: matoro <matoro@users.noreply.github.com>
Date: Sun, 26 Jun 2022 23:19:00 -0400
Subject: [PATCH] Move FFI_TYPE definitions above <ffitarget.h> include

For powerpc at least, these definitions are referenced in the
target-specific ffitarget.h.  Discovered in the jffi project.  Should
close https://github.com/libffi/libffi/issues/637.  Downstream jffi bug
https://github.com/jnr/jffi/issues/107.  Downstream distro bug
https://bugs.gentoo.org/827215.

Testing - both libffi and jffi test suites pass with this patch applied,
at least on ppc64le linux.  I did not see any warnings about
redefinitions.

Tested versions - libffi 3.4.2, jffi 1.3.6 and 1.3.9.
---
 include/ffi.h.in | 50 ++++++++++++++++++++++++------------------------
 1 file changed, 25 insertions(+), 25 deletions(-)

diff --git a/include/ffi.h.in b/include/ffi.h.in
index d16f307e..6cd19baa 100644
--- a/include/ffi.h.in
+++ b/include/ffi.h.in
@@ -56,6 +56,31 @@ extern "C" {
 
 /* ---- System configuration information --------------------------------- */
 
+/* If these change, update src/mips/ffitarget.h. */
+#define FFI_TYPE_VOID       0
+#define FFI_TYPE_INT        1
+#define FFI_TYPE_FLOAT      2
+#define FFI_TYPE_DOUBLE     3
+#if @HAVE_LONG_DOUBLE@
+#define FFI_TYPE_LONGDOUBLE 4
+#else
+#define FFI_TYPE_LONGDOUBLE FFI_TYPE_DOUBLE
+#endif
+#define FFI_TYPE_UINT8      5
+#define FFI_TYPE_SINT8      6
+#define FFI_TYPE_UINT16     7
+#define FFI_TYPE_SINT16     8
+#define FFI_TYPE_UINT32     9
+#define FFI_TYPE_SINT32     10
+#define FFI_TYPE_UINT64     11
+#define FFI_TYPE_SINT64     12
+#define FFI_TYPE_STRUCT     13
+#define FFI_TYPE_POINTER    14
+#define FFI_TYPE_COMPLEX    15
+
+/* This should always refer to the last type code (for sanity checks).  */
+#define FFI_TYPE_LAST       FFI_TYPE_COMPLEX
+
 #include <ffitarget.h>
 
 #ifndef LIBFFI_ASM
@@ -496,31 +521,6 @@ ffi_status ffi_get_struct_offsets (ffi_abi abi, ffi_type *struct_type,
 
 #endif
 
-/* If these change, update src/mips/ffitarget.h. */
-#define FFI_TYPE_VOID       0
-#define FFI_TYPE_INT        1
-#define FFI_TYPE_FLOAT      2
-#define FFI_TYPE_DOUBLE     3
-#if @HAVE_LONG_DOUBLE@
-#define FFI_TYPE_LONGDOUBLE 4
-#else
-#define FFI_TYPE_LONGDOUBLE FFI_TYPE_DOUBLE
-#endif
-#define FFI_TYPE_UINT8      5
-#define FFI_TYPE_SINT8      6
-#define FFI_TYPE_UINT16     7
-#define FFI_TYPE_SINT16     8
-#define FFI_TYPE_UINT32     9
-#define FFI_TYPE_SINT32     10
-#define FFI_TYPE_UINT64     11
-#define FFI_TYPE_SINT64     12
-#define FFI_TYPE_STRUCT     13
-#define FFI_TYPE_POINTER    14
-#define FFI_TYPE_COMPLEX    15
-
-/* This should always refer to the last type code (for sanity checks).  */
-#define FFI_TYPE_LAST       FFI_TYPE_COMPLEX
-
 #ifdef __cplusplus
 }
 #endif