Skip to content

Commit eaca085

Browse files
Merge remote-tracking branch 'libffi/master'
1 parent 704a82d commit eaca085

32 files changed

Lines changed: 890 additions & 593 deletions

configure.ac

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,10 @@ fi
119119
AC_SUBST(HAVE_LONG_DOUBLE)
120120
AC_SUBST(HAVE_LONG_DOUBLE_VARIANT)
121121

122+
AC_CHECK_TYPE(__int128_t,
123+
AC_DEFINE(HAVE_INT128, 1,
124+
[Define if __int128_t and __uint128_t are supported.]))
125+
122126
AC_C_BIGENDIAN
123127

124128
GCC_AS_CFI_PSEUDO_OP

include/ffi.h.in

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,11 @@ extern "C" {
7777
#define FFI_TYPE_STRUCT 13
7878
#define FFI_TYPE_POINTER 14
7979
#define FFI_TYPE_COMPLEX 15
80+
#define FFI_TYPE_UINT128 16
81+
#define FFI_TYPE_SINT128 17
8082

8183
/* This should always refer to the last type code (for sanity checks). */
82-
#define FFI_TYPE_LAST FFI_TYPE_COMPLEX
84+
#define FFI_TYPE_LAST FFI_TYPE_SINT128
8385

8486
#include <ffitarget.h>
8587

@@ -227,6 +229,11 @@ FFI_EXTERN ffi_type ffi_type_complex_float;
227229
FFI_EXTERN ffi_type ffi_type_complex_double;
228230
FFI_EXTERN ffi_type ffi_type_complex_longdouble;
229231
#endif
232+
233+
#ifdef FFI_TARGET_HAS_INT128
234+
FFI_EXTERN ffi_type ffi_type_uint128;
235+
FFI_EXTERN ffi_type ffi_type_sint128;
236+
#endif
230237
#endif /* LIBFFI_HIDE_BASIC_TYPES */
231238

232239
typedef enum {

libffi.map.in

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,3 +91,11 @@ LIBFFI_GO_CLOSURE_8.0 {
9191
ffi_prep_go_closure;
9292
} LIBFFI_CLOSURE_8.0;
9393
#endif
94+
95+
#ifdef FFI_TARGET_HAS_INT128
96+
LIBFFI_INT128_8.3 {
97+
global:
98+
ffi_type_sint128;
99+
ffi_type_uint128;
100+
} LIBFFI_BASE_8.1;
101+
#endif

libtool-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,4 @@
2626
# release, then set age to 0.
2727
#
2828
# CURRENT:REVISION:AGE
29-
10:0:2
29+
11:0:3

src/aarch64/ffi.c

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
2828
#include <ffi_common.h>
2929
#include "internal.h"
3030
#ifdef _WIN32
31+
#define WIN32_LEAN_AND_MEAN
3132
#include <windows.h> /* FlushInstructionCache */
3233
#endif
3334
#include <tramp.h>
@@ -537,6 +538,32 @@ allocate_int_to_reg_or_stack (struct call_context *context,
537538
return allocate_to_stack (state, stack, size, size);
538539
}
539540

541+
static void *
542+
allocate_int128_to_reg_or_stack (struct call_context *context,
543+
struct arg_state *state, void *stack)
544+
{
545+
unsigned ngrn = state->ngrn;
546+
void *ret;
547+
548+
/* The normal AArch64 ABI requires even Xreg; Darwin does not. */
549+
#ifndef __APPLE__
550+
ngrn += ngrn & 1;
551+
#endif
552+
553+
if (ngrn < N_X_ARG_REG)
554+
{
555+
ret = &context->x[ngrn];
556+
ngrn += 2;
557+
}
558+
else
559+
{
560+
ret = allocate_to_stack (state, stack, 16, 16);
561+
ngrn = N_X_ARG_REG;
562+
}
563+
state->ngrn = ngrn;
564+
return ret;
565+
}
566+
540567
ffi_status FFI_HIDDEN
541568
ffi_prep_cif_machdep (ffi_cif *cif)
542569
{
@@ -576,6 +603,11 @@ ffi_prep_cif_machdep (ffi_cif *cif)
576603
flags = (sizeof(void *) == 4 ? AARCH64_RET_UINT32 : AARCH64_RET_INT64);
577604
break;
578605

606+
case FFI_TYPE_UINT128:
607+
case FFI_TYPE_SINT128:
608+
flags = AARCH64_RET_INT128;
609+
break;
610+
579611
case FFI_TYPE_FLOAT:
580612
case FFI_TYPE_DOUBLE:
581613
case FFI_TYPE_LONGDOUBLE:
@@ -741,6 +773,12 @@ ffi_call_int (ffi_cif *cif, void (*fn)(void), void *orig_rvalue,
741773
}
742774
break;
743775

776+
case FFI_TYPE_UINT128:
777+
case FFI_TYPE_SINT128:
778+
dest = allocate_int128_to_reg_or_stack (context, &state, stack);
779+
memcpy (dest, a, 16);
780+
break;
781+
744782
case FFI_TYPE_FLOAT:
745783
case FFI_TYPE_DOUBLE:
746784
case FFI_TYPE_LONGDOUBLE:
@@ -1023,6 +1061,11 @@ ffi_closure_SYSV_inner (ffi_cif *cif,
10231061
avalue[i] = allocate_int_to_reg_or_stack (context, &state, stack, s);
10241062
break;
10251063

1064+
case FFI_TYPE_UINT128:
1065+
case FFI_TYPE_SINT128:
1066+
avalue[i] = allocate_int128_to_reg_or_stack (context, &state, stack);
1067+
break;
1068+
10261069
case FFI_TYPE_FLOAT:
10271070
case FFI_TYPE_DOUBLE:
10281071
case FFI_TYPE_LONGDOUBLE:

src/aarch64/ffitarget.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,4 +94,6 @@ typedef enum ffi_abi
9494
#define FFI_TARGET_HAS_COMPLEX_TYPE
9595
#endif
9696

97+
#define FFI_TARGET_HAS_INT128 1
98+
9799
#endif

src/alpha/ffi.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,8 @@ ffi_prep_cif_machdep(ffi_cif *cif)
9595
bytes += 8;
9696
break;
9797

98+
case FFI_TYPE_SINT128:
99+
case FFI_TYPE_UINT128:
98100
case FFI_TYPE_VOID:
99101
case FFI_TYPE_STRUCT:
100102
/* Passed by value in N slots. */
@@ -149,6 +151,8 @@ ffi_prep_cif_machdep(ffi_cif *cif)
149151
case FFI_TYPE_POINTER:
150152
flags = ALPHA_FLAGS(ALPHA_ST_INT, ALPHA_LD_INT64);
151153
break;
154+
case FFI_TYPE_SINT128:
155+
case FFI_TYPE_UINT128:
152156
case FFI_TYPE_LONGDOUBLE:
153157
case FFI_TYPE_STRUCT:
154158
/* Passed in memory, with a hidden pointer. */
@@ -281,6 +285,8 @@ ffi_call_int (ffi_cif *cif, void (*fn)(void), void *rvalue,
281285
argp[argn++] = (unsigned long)valp;
282286
break;
283287

288+
case FFI_TYPE_SINT128:
289+
case FFI_TYPE_UINT128:
284290
case FFI_TYPE_VOID:
285291
case FFI_TYPE_STRUCT:
286292
size = ty->size;
@@ -418,6 +424,8 @@ ffi_closure_osf_inner (ffi_cif *cif,
418424
argn += 1;
419425
break;
420426

427+
case FFI_TYPE_SINT128:
428+
case FFI_TYPE_UINT128:
421429
case FFI_TYPE_VOID:
422430
case FFI_TYPE_STRUCT:
423431
size = ty->size;

src/alpha/ffitarget.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ typedef enum ffi_abi {
4646

4747
#define FFI_TARGET_SPECIFIC_STACK_SPACE_ALLOCATION
4848
#define FFI_TARGET_HAS_COMPLEX_TYPE
49+
#define FFI_TARGET_HAS_INT128
4950

5051
/* ---- Definitions for closures ----------------------------------------- */
5152

src/loongarch64/ffitarget.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ typedef enum ffi_abi
6969

7070
#endif /* LIBFFI_ASM */
7171

72+
#define FFI_TARGET_HAS_INT128
73+
7274
/* ---- Definitions for closures ----------------------------------------- */
7375

7476
#define FFI_CLOSURES 1

src/loongarch64/sysv.S

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,17 +89,17 @@ ffi_call_asm:
8989
we preserve the call_context so that it can be read back in the
9090
caller. */
9191

92-
.cfi_def_cfa 5, FRAME_LEN # Interim CFA based on a1.
92+
.cfi_def_cfa 5, FRAME_LEN /* Interim CFA based on a1. */
9393
SARG $fp, $a1, FRAME_LEN - 2*PTRS
9494
.cfi_offset 22, -2*PTRS
9595
SARG $ra, $a1, FRAME_LEN - 1*PTRS
9696
.cfi_offset 1, -1*PTRS
9797

9898
addi.d $fp, $a1, FRAME_LEN
9999
move $sp, $a0
100-
.cfi_def_cfa 22, 0 # Our frame is fully set up.
100+
.cfi_def_cfa 22, 0 /* Our frame is fully set up. */
101101

102-
# Load arguments.
102+
/* Load arguments. */
103103
move $t1, $a2
104104
move $t2, $a3
105105

0 commit comments

Comments
 (0)