File: libffi-m68k.diff

package info (click to toggle)
gcc-4.9 4.9.2-10%2Bdeb8u1
  • links: PTS, VCS
  • area: main
  • in suites: jessie
  • size: 78,296 kB
  • sloc: makefile: 1,979; python: 870; sh: 801; perl: 165; awk: 23; cpp: 14
file content (141 lines) | stat: -rw-r--r-- 3,240 bytes parent folder | download | duplicates (12)
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
# DP: Apply #660525 fix to in-tree libffi

--- a/src/libffi/src/m68k/sysv.S
+++ b/src/libffi/src/m68k/sysv.S
@@ -2,9 +2,10 @@
 	
    sysv.S - Copyright (c) 2012 Alan Hourihane
 	    Copyright (c) 1998, 2012 Andreas Schwab
-	    Copyright (c) 2008 Red Hat, Inc. 
-   
-   m68k Foreign Function Interface 
+	    Copyright (c) 2008 Red Hat, Inc.
+	    Copyright (c) 2012 Thorsten Glaser
+
+   m68k Foreign Function Interface
 
    Permission is hereby granted, free of charge, to any person obtaining
    a copy of this software and associated documentation files (the
@@ -168,8 +169,28 @@ retstruct1:
 
 retstruct2:
 	btst	#7,%d2
-	jbeq	noretval
+	jbeq	retsint8
 	move.w	%d0,(%a1)
+	jbra	epilogue
+
+retsint8:
+	btst	#8,%d2
+	jbeq	retsint16
+	| NOTE: On the mc68000, extb is not supported. 8->16, then 16->32.
+#if !defined(__mc68020__) && !defined(__mc68030__) && !defined(__mc68040__) && !defined(__mc68060__) && !defined(__mcoldfire__)
+	ext.w	%d0
+	ext.l	%d0
+#else
+	extb.l	%d0
+#endif
+	move.l	%d0,(%a1)
+	jbra	epilogue
+
+retsint16:
+	btst	#9,%d2
+	jbeq	noretval
+	ext.l	%d0
+	move.l	%d0,(%a1)
 
 noretval:
 epilogue:
@@ -201,8 +222,10 @@ CALLFUNC(ffi_closure_SYSV):
 	lsr.l	#1,%d0
 	jne	1f
 	jcc	.Lcls_epilogue
+	| CIF_FLAGS_INT
 	move.l	-12(%fp),%d0
 .Lcls_epilogue:
+	| no CIF_FLAGS_*
 	unlk	%fp
 	rts
 1:
@@ -210,6 +233,7 @@ CALLFUNC(ffi_closure_SYSV):
 	lsr.l	#2,%d0
 	jne	1f
 	jcs	.Lcls_ret_float
+	| CIF_FLAGS_DINT
 	move.l	(%a0)+,%d0
 	move.l	(%a0),%d1
 	jra	.Lcls_epilogue
@@ -224,6 +248,7 @@ CALLFUNC(ffi_closure_SYSV):
 	lsr.l	#2,%d0
 	jne	1f
 	jcs	.Lcls_ret_ldouble
+	| CIF_FLAGS_DOUBLE
 #if defined(__MC68881__) || defined(__HAVE_68881__)
 	fmove.d	(%a0),%fp0
 #else
@@ -242,17 +267,37 @@ CALLFUNC(ffi_closure_SYSV):
 	jra	.Lcls_epilogue
 1:
 	lsr.l	#2,%d0
-	jne	.Lcls_ret_struct2
+	jne	1f
 	jcs	.Lcls_ret_struct1
+	| CIF_FLAGS_POINTER
 	move.l	(%a0),%a0
 	move.l	%a0,%d0
 	jra	.Lcls_epilogue
 .Lcls_ret_struct1:
 	move.b	(%a0),%d0
 	jra	.Lcls_epilogue
-.Lcls_ret_struct2:
+1:
+	lsr.l	#2,%d0
+	jne	1f
+	jcs	.Lcls_ret_sint8
+	| CIF_FLAGS_STRUCT2
 	move.w	(%a0),%d0
 	jra	.Lcls_epilogue
+.Lcls_ret_sint8:
+	move.l	(%a0),%d0
+	| NOTE: On the mc68000, extb is not supported. 8->16, then 16->32.
+#if !defined(__mc68020__) && !defined(__mc68030__) && !defined(__mc68040__) && !defined(__mc68060__) && !defined(__mcoldfire__)
+	ext.w	%d0
+	ext.l	%d0
+#else
+	extb.l	%d0
+#endif
+	jra	.Lcls_epilogue
+1:
+	| CIF_FLAGS_SINT16
+	move.l	(%a0),%d0
+	ext.l	%d0
+	jra	.Lcls_epilogue
 	CFI_ENDPROC()
 
 	.size	CALLFUNC(ffi_closure_SYSV),.-CALLFUNC(ffi_closure_SYSV)
--- a/src/libffi/src/m68k/ffi.c
+++ b/src/libffi/src/m68k/ffi.c
@@ -123,6 +123,8 @@ ffi_prep_args (void *stack, extended_cif
 #define CIF_FLAGS_POINTER	32
 #define CIF_FLAGS_STRUCT1	64
 #define CIF_FLAGS_STRUCT2	128
+#define CIF_FLAGS_SINT8		256
+#define CIF_FLAGS_SINT16	512
 
 /* Perform machine dependent cif processing */
 ffi_status
@@ -200,6 +202,14 @@ ffi_prep_cif_machdep (ffi_cif *cif)
       cif->flags = CIF_FLAGS_DINT;
       break;
 
+    case FFI_TYPE_SINT16:
+      cif->flags = CIF_FLAGS_SINT16;
+      break;
+
+    case FFI_TYPE_SINT8:
+      cif->flags = CIF_FLAGS_SINT8;
+      break;
+
     default:
       cif->flags = CIF_FLAGS_INT;
       break;