From 3ee6d822b3e7b602bf8dbe2b21f95e566602183c Mon Sep 17 00:00:00 2001
From: Wenlong Zhang <zhangwenlong@loongson.cn>
Date: Fri, 19 May 2023 02:56:26 +0000
Subject: [PATCH] add loongarch64 support for ffi

---
 ext/ffi_c/libffi/Makefile.am                  |   2 +
 ext/ffi_c/libffi/config.guess                 |   3 +
 ext/ffi_c/libffi/config.sub                   |   1 +
 ext/ffi_c/libffi/configure.host               |   4 +
 ext/ffi_c/libffi/src/loongarch64/ffi.c        | 621 ++++++++++++++++++
 ext/ffi_c/libffi/src/loongarch64/ffitarget.h  |  82 +++
 ext/ffi_c/libffi/src/loongarch64/sysv.S       | 327 +++++++++
 ffi.gemspec                                   |  66 +-
 lib/ffi/platform/loongarch64-linux/types.conf | 141 ++++
 9 files changed, 1217 insertions(+), 30 deletions(-)
 create mode 100644 ext/ffi_c/libffi/src/loongarch64/ffi.c
 create mode 100644 ext/ffi_c/libffi/src/loongarch64/ffitarget.h
 create mode 100644 ext/ffi_c/libffi/src/loongarch64/sysv.S
 create mode 100644 lib/ffi/platform/loongarch64-linux/types.conf

diff --git a/ext/ffi_c/libffi/Makefile.am b/ext/ffi_c/libffi/Makefile.am
index 27a11b2..d598e8c 100644
--- a/ext/ffi_c/libffi/Makefile.am
+++ b/ext/ffi_c/libffi/Makefile.am
@@ -76,6 +76,7 @@ noinst_HEADERS = \
 	src/x86/ffitarget.h src/x86/internal.h src/x86/internal64.h src/x86/asmnames.h \
 	src/xtensa/ffitarget.h						\
 	src/dlmalloc.c
+	src/loongarch64/ffitarget.h
 
 EXTRA_libffi_la_SOURCES = \
 	src/aarch64/ffi.c src/aarch64/sysv.S				\
@@ -113,6 +114,7 @@ EXTRA_libffi_la_SOURCES = \
 	 src/x86/ffiw64.c src/x86/win64.S 				\
 	 src/x86/ffi64.c src/x86/unix64.S				\
 	src/xtensa/ffi.c src/xtensa/sysv.S
+	src/loongarch64/ffi.c src/loongarch64/sysv.S
 
 TARGET_OBJ = @TARGET_OBJ@
 libffi_la_LIBADD = $(TARGET_OBJ)
diff --git a/ext/ffi_c/libffi/config.guess b/ext/ffi_c/libffi/config.guess
index faa63aa..db4f48f 100644
--- a/ext/ffi_c/libffi/config.guess
+++ b/ext/ffi_c/libffi/config.guess
@@ -976,6 +976,9 @@ EOF
     k1om:Linux:*:*)
 	echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
 	exit ;;
+	loongarch32:Linux:*:* | loongarch64:Linux:*:* | loongarchx32:Linux:*:*)
+	echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+	exit ;;
     m32r*:Linux:*:*)
 	echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
 	exit ;;
diff --git a/ext/ffi_c/libffi/config.sub b/ext/ffi_c/libffi/config.sub
index 40ea5df..f469dea 100644
--- a/ext/ffi_c/libffi/config.sub
+++ b/ext/ffi_c/libffi/config.sub
@@ -268,6 +268,7 @@ case $basic_machine in
 	| k1om \
 	| le32 | le64 \
 	| lm32 \
+	| loongarch32 | loongarch64 | loongarchx32 \
 	| m32c | m32r | m32rle | m68000 | m68k | m88k \
 	| maxq | mb | microblaze | microblazeel | mcore | mep | metag \
 	| mips | mipsbe | mipseb | mipsel | mipsle \
diff --git a/ext/ffi_c/libffi/configure.host b/ext/ffi_c/libffi/configure.host
index 7634c3a..1e0c74d 100644
--- a/ext/ffi_c/libffi/configure.host
+++ b/ext/ffi_c/libffi/configure.host
@@ -129,6 +129,10 @@ case "${host}" in
 	TARGET=IA64; TARGETDIR=ia64
 	SOURCES="ffi.c unix.S"
 	;;
+  loongarch64-*-*)
+	TARGET=LOONGARCH64; TARGETDIR=loongarch64
+	SOURCES="ffi.c sysv.S"
+	;;
 
   m32r*-*-*)
 	TARGET=M32R; TARGETDIR=m32r
diff --git a/ext/ffi_c/libffi/src/loongarch64/ffi.c b/ext/ffi_c/libffi/src/loongarch64/ffi.c
new file mode 100644
index 0000000..140be3b
--- /dev/null
+++ b/ext/ffi_c/libffi/src/loongarch64/ffi.c
@@ -0,0 +1,621 @@
+/* -----------------------------------------------------------------------
+   ffi.c - Copyright (c) 2022 Xu Chenghua <xuchenghua@loongson.cn>
+                         2022 Cheng Lulu <chenglulu@loongson.cn>
+   Based on RISC-V port
+
+   LoongArch Foreign Function Interface
+
+   Permission is hereby granted, free of charge, to any person obtaining
+   a copy of this software and associated documentation files (the
+   ``Software''), to deal in the Software without restriction, including
+   without limitation the rights to use, copy, modify, merge, publish,
+   distribute, sublicense, and/or sell copies of the Software, and to
+   permit persons to whom the Software is furnished to do so, subject to
+   the following conditions:
+
+   The above copyright notice and this permission notice shall be included
+   in all copies or substantial portions of the Software.
+
+   THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
+   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+   NONINFRINGEMENT.  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+   HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+   WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+   OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+   DEALINGS IN THE SOFTWARE.
+   ----------------------------------------------------------------------- */
+
+#include <ffi.h>
+#include <ffi_common.h>
+
+#include <stdlib.h>
+#include <stdint.h>
+
+#if defined(__loongarch_soft_float)
+# define ABI_FRLEN 0
+#elif defined(__loongarch_single_float)
+# define ABI_FRLEN 32
+# define ABI_FLOAT float
+#elif defined(__loongarch_double_float)
+# define ABI_FRLEN 64
+# define ABI_FLOAT double
+#else
+#error unsupported LoongArch floating-point ABI
+#endif
+
+#define NARGREG 8
+#define STKALIGN 16
+#define MAXCOPYARG (2 * sizeof (double))
+
+/* call_context registers
+   - 8 floating point parameter/result registers.
+   - 8 integer parameter/result registers.
+   - 2 registers used by the assembly code to in-place construct its own
+     stack frame
+     - frame register
+     - return register
+*/
+typedef struct call_context
+{
+  ABI_FLOAT fa[8];
+  size_t a[10];
+} call_context;
+
+typedef struct call_builder
+{
+  call_context *aregs;
+  int used_integer;
+  int used_float;
+  size_t *used_stack;
+  size_t *stack;
+  size_t next_struct_area;
+} call_builder;
+
+/* Integer (not pointer) less than ABI GRLEN.  */
+/* FFI_TYPE_INT does not appear to be used.  */
+#if __SIZEOF_POINTER__ == 8
+# define IS_INT(type) ((type) >= FFI_TYPE_UINT8 && (type) <= FFI_TYPE_SINT64)
+#else
+# define IS_INT(type) ((type) >= FFI_TYPE_UINT8 && (type) <= FFI_TYPE_SINT32)
+#endif
+
+#if ABI_FRLEN
+typedef struct float_struct_info
+{
+  char as_elements;
+  char type1;
+  char offset2;
+  char type2;
+} float_struct_info;
+
+#if ABI_FRLEN >= 64
+# define IS_FLOAT(type) ((type) >= FFI_TYPE_FLOAT && (type) <= FFI_TYPE_DOUBLE)
+#else
+# define IS_FLOAT(type) ((type) == FFI_TYPE_FLOAT)
+#endif
+
+static ffi_type **
+flatten_struct (ffi_type *in, ffi_type **out, ffi_type **out_end)
+{
+  int i;
+
+  if (out == out_end)
+    return out;
+  if (in->type != FFI_TYPE_STRUCT)
+    *(out++) = in;
+  else
+    for (i = 0; in->elements[i]; i++)
+      out = flatten_struct (in->elements[i], out, out_end);
+  return out;
+}
+
+/* Structs with at most two fields after flattening, one of which is of
+   floating point type, are passed in multiple registers if sufficient
+   registers are available.  */
+static float_struct_info
+struct_passed_as_elements (call_builder *cb, ffi_type *top)
+{
+  float_struct_info ret = {0, 0, 0, 0};
+  ffi_type *fields[3];
+  int num_floats, num_ints;
+  int num_fields = flatten_struct (top, fields, fields + 3) - fields;
+
+  if (num_fields == 1)
+    {
+      if (IS_FLOAT (fields[0]->type))
+	{
+	  ret.as_elements = 1;
+	  ret.type1 = fields[0]->type;
+	}
+    }
+  else if (num_fields == 2)
+    {
+      num_floats = IS_FLOAT (fields[0]->type) + IS_FLOAT (fields[1]->type);
+      num_ints = IS_INT (fields[0]->type) + IS_INT (fields[1]->type);
+      if (num_floats == 0 || num_floats + num_ints != 2)
+	return ret;
+      if (cb->used_float + num_floats > NARGREG
+	  || cb->used_integer + (2 - num_floats) > NARGREG)
+	return ret;
+      if (!IS_FLOAT (fields[0]->type) && !IS_FLOAT (fields[1]->type))
+	return ret;
+
+      ret.type1 = fields[0]->type;
+      ret.type2 = fields[1]->type;
+      ret.offset2 = FFI_ALIGN (fields[0]->size, fields[1]->alignment);
+      ret.as_elements = 1;
+    }
+  return ret;
+}
+#endif
+
+/* Allocates a single register, float register, or GRLEN-sized stack slot to a
+   datum.  */
+static void
+marshal_atom (call_builder *cb, int type, void *data)
+{
+  size_t value = 0;
+  switch (type)
+    {
+    case FFI_TYPE_UINT8:
+      value = *(uint8_t *) data;
+      break;
+    case FFI_TYPE_SINT8:
+      value = *(int8_t *) data;
+      break;
+    case FFI_TYPE_UINT16:
+      value = *(uint16_t *) data;
+      break;
+    case FFI_TYPE_SINT16:
+      value = *(int16_t *) data;
+      break;
+    /* 32-bit quantities are always sign-extended in the ABI.  */
+    case FFI_TYPE_UINT32:
+      value = *(int32_t *) data;
+      break;
+    case FFI_TYPE_SINT32:
+      value = *(int32_t *) data;
+      break;
+#if __SIZEOF_POINTER__ == 8
+    case FFI_TYPE_UINT64:
+      value = *(uint64_t *) data;
+      break;
+    case FFI_TYPE_SINT64:
+      value = *(int64_t *) data;
+      break;
+#endif
+    case FFI_TYPE_POINTER:
+      value = *(size_t *) data;
+      break;
+
+#if ABI_FRLEN >= 32
+    case FFI_TYPE_FLOAT:
+      *(float *)(cb->aregs->fa + cb->used_float++) = *(float *) data;
+      return;
+#endif
+#if ABI_FRLEN >= 64
+    case FFI_TYPE_DOUBLE:
+      (cb->aregs->fa[cb->used_float++]) = *(double *) data;
+      return;
+#endif
+    default:
+      FFI_ASSERT (0);
+      break;
+    }
+
+  if (cb->used_integer == NARGREG)
+    *cb->used_stack++ = value;
+  else
+    cb->aregs->a[cb->used_integer++] = value;
+}
+
+static void
+unmarshal_atom (call_builder *cb, int type, void *data)
+{
+  size_t value;
+  switch (type)
+    {
+#if ABI_FRLEN >= 32
+    case FFI_TYPE_FLOAT:
+      *(float *) data = *(float *)(cb->aregs->fa + cb->used_float++);
+      return;
+#endif
+#if ABI_FRLEN >= 64
+    case FFI_TYPE_DOUBLE:
+      *(double *) data = cb->aregs->fa[cb->used_float++];
+      return;
+#endif
+    }
+
+  if (cb->used_integer == NARGREG)
+    value = *cb->used_stack++;
+  else
+    value = cb->aregs->a[cb->used_integer++];
+
+  switch (type)
+    {
+    case FFI_TYPE_UINT8:
+    case FFI_TYPE_SINT8:
+    case FFI_TYPE_UINT16:
+    case FFI_TYPE_SINT16:
+    case FFI_TYPE_UINT32:
+    case FFI_TYPE_SINT32:
+#if __SIZEOF_POINTER__ == 8
+    case FFI_TYPE_UINT64:
+    case FFI_TYPE_SINT64:
+#endif
+    case FFI_TYPE_POINTER:
+      *(ffi_arg *)data = value;
+      break;
+    default:
+      FFI_ASSERT (0);
+      break;
+    }
+}
+
+/* Allocate and copy a structure that is passed by value on the stack and
+   return a pointer to it.  */
+static void *
+allocate_and_copy_struct_to_stack (call_builder *cb, void *data,
+				   ffi_type *type)
+{
+  size_t dest = cb->next_struct_area - type->size;
+
+  dest = FFI_ALIGN_DOWN (dest, type->alignment);
+  cb->next_struct_area = dest;
+
+  return memcpy ((char *)cb->stack + dest, data, type->size);
+}
+
+/* Adds an argument to a call, or a not by reference return value.  */
+static void
+marshal (call_builder *cb, ffi_type *type, int var, void *data)
+{
+  size_t realign[2];
+
+#if ABI_FRLEN
+  if (!var && type->type == FFI_TYPE_STRUCT)
+    {
+      float_struct_info fsi = struct_passed_as_elements (cb, type);
+      if (fsi.as_elements)
+	{
+	  marshal_atom (cb, fsi.type1, data);
+	  if (fsi.offset2)
+	    marshal_atom (cb, fsi.type2, ((char *) data) + fsi.offset2);
+	  return;
+	}
+    }
+
+  if (!var && cb->used_float < NARGREG
+      && IS_FLOAT (type->type))
+    {
+      marshal_atom (cb, type->type, data);
+      return;
+    }
+
+  double promoted;
+  if (var && type->type == FFI_TYPE_FLOAT)
+    {
+      /* C standard requires promoting float -> double for variable arg.  */
+      promoted = *(float *) data;
+      type = &ffi_type_double;
+      data = &promoted;
+    }
+#endif
+
+  if (type->size > 2 * __SIZEOF_POINTER__)
+    /* Pass by reference.  */
+    {
+      allocate_and_copy_struct_to_stack (cb, data, type);
+      data = (char *)cb->stack + cb->next_struct_area;
+      marshal_atom (cb, FFI_TYPE_POINTER, &data);
+    }
+  else if (IS_INT (type->type) || type->type == FFI_TYPE_POINTER)
+    marshal_atom (cb, type->type, data);
+  else
+    {
+      /* Overlong integers, soft-float floats, and structs without special
+	 float handling are treated identically from this point on.  */
+
+      /* Variadics are aligned even in registers.  */
+      if (type->alignment > __SIZEOF_POINTER__)
+	{
+	  if (var)
+	    cb->used_integer = FFI_ALIGN (cb->used_integer, 2);
+	  cb->used_stack
+	    = (size_t *) FFI_ALIGN (cb->used_stack, 2 * __SIZEOF_POINTER__);
+	}
+
+      memcpy (realign, data, type->size);
+      if (type->size > 0)
+	marshal_atom (cb, FFI_TYPE_POINTER, realign);
+      if (type->size > __SIZEOF_POINTER__)
+	marshal_atom (cb, FFI_TYPE_POINTER, realign + 1);
+    }
+}
+
+/* For arguments passed by reference returns the pointer, otherwise the arg
+   is copied (up to MAXCOPYARG bytes).  */
+static void *
+unmarshal (call_builder *cb, ffi_type *type, int var, void *data)
+{
+  size_t realign[2];
+  void *pointer;
+
+#if ABI_FRLEN
+  if (!var && type->type == FFI_TYPE_STRUCT)
+    {
+      float_struct_info fsi = struct_passed_as_elements (cb, type);
+      if (fsi.as_elements)
+	{
+	  unmarshal_atom (cb, fsi.type1, data);
+	  if (fsi.offset2)
+	    unmarshal_atom (cb, fsi.type2, ((char *) data) + fsi.offset2);
+	  return data;
+	}
+    }
+
+  if (!var && cb->used_float < NARGREG
+      && IS_FLOAT (type->type))
+    {
+      unmarshal_atom (cb, type->type, data);
+      return data;
+    }
+
+  if (var && type->type == FFI_TYPE_FLOAT)
+    {
+      int m = cb->used_integer;
+      void *promoted
+	= m < NARGREG ? cb->aregs->a + m : cb->used_stack + m - NARGREG + 1;
+      *(float *) promoted = *(double *) promoted;
+    }
+#endif
+
+  if (type->size > 2 * __SIZEOF_POINTER__)
+    {
+      /* Pass by reference.  */
+      unmarshal_atom (cb, FFI_TYPE_POINTER, (char *) &pointer);
+      return pointer;
+    }
+  else if (IS_INT (type->type) || type->type == FFI_TYPE_POINTER)
+    {
+      unmarshal_atom (cb, type->type, data);
+      return data;
+    }
+  else
+    {
+      /* Overlong integers, soft-float floats, and structs without special
+	 float handling are treated identically from this point on.  */
+
+      /* Variadics are aligned even in registers.  */
+      if (type->alignment > __SIZEOF_POINTER__)
+	{
+	  if (var)
+	    cb->used_integer = FFI_ALIGN (cb->used_integer, 2);
+	  cb->used_stack
+	    = (size_t *) FFI_ALIGN (cb->used_stack, 2 * __SIZEOF_POINTER__);
+	}
+
+      if (type->size > 0)
+	unmarshal_atom (cb, FFI_TYPE_POINTER, realign);
+      if (type->size > __SIZEOF_POINTER__)
+	unmarshal_atom (cb, FFI_TYPE_POINTER, realign + 1);
+      memcpy (data, realign, type->size);
+      return data;
+    }
+}
+
+static int
+passed_by_ref (call_builder *cb, ffi_type *type, int var)
+{
+#if ABI_FRLEN
+  if (!var && type->type == FFI_TYPE_STRUCT)
+    {
+      float_struct_info fsi = struct_passed_as_elements (cb, type);
+      if (fsi.as_elements)
+	return 0;
+    }
+#endif
+
+  return type->size > 2 * __SIZEOF_POINTER__;
+}
+
+/* Perform machine dependent cif processing.  */
+ffi_status
+ffi_prep_cif_machdep (ffi_cif *cif)
+{
+  cif->loongarch_nfixedargs = cif->nargs;
+  return FFI_OK;
+}
+
+/* Perform machine dependent cif processing when we have a variadic
+   function.  */
+ffi_status
+ffi_prep_cif_machdep_var (ffi_cif *cif, unsigned int nfixedargs,
+			  unsigned int ntotalargs)
+{
+  cif->loongarch_nfixedargs = nfixedargs;
+  return FFI_OK;
+}
+
+/* Low level routine for calling functions.  */
+extern void ffi_call_asm (void *stack, struct call_context *regs,
+			  void (*fn) (void), void *closure) FFI_HIDDEN;
+
+static void
+ffi_call_int (ffi_cif *cif, void (*fn) (void), void *rvalue, void **avalue,
+	      void *closure)
+{
+  /* This is a conservative estimate, assuming a complex return value and
+     that all remaining arguments are long long / __int128 */
+  size_t arg_bytes = cif->bytes;
+  size_t rval_bytes = 0;
+  if (rvalue == NULL && cif->rtype->size > 2 * __SIZEOF_POINTER__)
+    rval_bytes = FFI_ALIGN (cif->rtype->size, STKALIGN);
+  size_t alloc_size = arg_bytes + rval_bytes + sizeof (call_context);
+
+  /* The assembly code will deallocate all stack data at lower addresses
+     than the argument region, so we need to allocate the frame and the
+     return value after the arguments in a single allocation.  */
+  size_t alloc_base;
+  /* Argument region must be 16-byte aligned in LP64 ABIs.  */
+  if (_Alignof(max_align_t) >= STKALIGN)
+    /* Since sizeof long double is normally 16, the compiler will
+       guarantee alloca alignment to at least that much.  */
+    alloc_base = (size_t) alloca (alloc_size);
+  else
+    alloc_base = FFI_ALIGN (alloca (alloc_size + STKALIGN - 1), STKALIGN);
+
+  if (rval_bytes)
+    rvalue = (void *) (alloc_base + arg_bytes);
+
+  call_builder cb;
+  cb.used_float = cb.used_integer = 0;
+  cb.aregs = (call_context *) (alloc_base + arg_bytes + rval_bytes);
+  cb.used_stack = (void *) alloc_base;
+  cb.stack = (void *) alloc_base;
+  cb.next_struct_area = arg_bytes;
+
+  int return_by_ref = passed_by_ref (&cb, cif->rtype, 0);
+  if (return_by_ref)
+    cb.aregs->a[cb.used_integer++] = (size_t)rvalue;
+
+  int i;
+  for (i = 0; i < cif->nargs; i++)
+    marshal (&cb, cif->arg_types[i], i >= cif->loongarch_nfixedargs,
+	     avalue[i]);
+
+  ffi_call_asm ((void *) alloc_base, cb.aregs, fn, closure);
+
+  cb.used_float = cb.used_integer = 0;
+  if (!return_by_ref && rvalue)
+    unmarshal (&cb, cif->rtype, 0, rvalue);
+}
+
+void
+ffi_call (ffi_cif *cif, void (*fn) (void), void *rvalue, void **avalue)
+{
+  ffi_call_int (cif, fn, rvalue, avalue, NULL);
+}
+
+void
+ffi_call_go (ffi_cif *cif, void (*fn) (void), void *rvalue, void **avalue,
+	     void *closure)
+{
+  ffi_call_int (cif, fn, rvalue, avalue, closure);
+}
+
+extern void ffi_closure_asm (void) FFI_HIDDEN;
+
+ffi_status
+ffi_prep_closure_loc (ffi_closure *closure, ffi_cif *cif,
+		      void (*fun) (ffi_cif *, void *, void **, void *),
+		      void *user_data, void *codeloc)
+{
+  uint32_t *tramp = (uint32_t *) &closure->tramp[0];
+  uint64_t fn = (uint64_t) (uintptr_t) ffi_closure_asm;
+
+  if (cif->abi <= FFI_FIRST_ABI || cif->abi >= FFI_LAST_ABI)
+    return FFI_BAD_ABI;
+
+#if defined(FFI_EXEC_STATIC_TRAMP)
+  if (ffi_tramp_is_present(closure))
+    {
+      ffi_tramp_set_parms (closure->ftramp, ffi_closure_asm, closure);
+      goto out;
+    }
+#endif
+
+  /* Fill the dynamic trampoline.  We will call ffi_closure_inner with codeloc,
+     not closure, but as long as the memory is readable it should work.  */
+  tramp[0] = 0x1800000c; /* pcaddi $t0, 0 (i.e. $t0 <- tramp) */
+  tramp[1] = 0x28c0418d; /* ld.d   $t1, $t0, 16 */
+  tramp[2] = 0x4c0001a0; /* jirl   $zero, $t1, 0 */
+  tramp[3] = 0x03400000; /* nop */
+  tramp[4] = fn;
+  tramp[5] = fn >> 32;
+
+  __builtin___clear_cache (codeloc, codeloc + FFI_TRAMPOLINE_SIZE);
+
+#if defined(FFI_EXEC_STATIC_TRAMP)
+out:
+#endif
+  closure->cif = cif;
+  closure->fun = fun;
+  closure->user_data = user_data;
+
+  return FFI_OK;
+}
+
+extern void ffi_go_closure_asm (void) FFI_HIDDEN;
+
+ffi_status
+ffi_prep_go_closure (ffi_go_closure *closure, ffi_cif *cif,
+		     void (*fun) (ffi_cif *, void *, void **, void *))
+{
+  if (cif->abi <= FFI_FIRST_ABI || cif->abi >= FFI_LAST_ABI)
+    return FFI_BAD_ABI;
+
+  closure->tramp = (void *) ffi_go_closure_asm;
+  closure->cif = cif;
+  closure->fun = fun;
+  return FFI_OK;
+}
+
+/* Called by the assembly code with aregs pointing to saved argument registers
+   and stack pointing to the stacked arguments.  Return values passed in
+   registers will be reloaded from aregs.  */
+void FFI_HIDDEN
+ffi_closure_inner (ffi_cif *cif,
+		   void (*fun) (ffi_cif *, void *, void **, void *),
+		   void *user_data, size_t *stack, call_context *aregs)
+{
+  void **avalue = alloca (cif->nargs * sizeof (void *));
+  /* Storage for arguments which will be copied by unmarshal().  We could
+     theoretically avoid the copies in many cases and use at most 128 bytes
+     of memory, but allocating disjoint storage for each argument is
+     simpler.  */
+  char *astorage = alloca (cif->nargs * MAXCOPYARG);
+  void *rvalue;
+  call_builder cb;
+  int return_by_ref;
+  int i;
+
+  cb.aregs = aregs;
+  cb.used_integer = cb.used_float = 0;
+  cb.used_stack = stack;
+
+  return_by_ref = passed_by_ref (&cb, cif->rtype, 0);
+  if (return_by_ref)
+    unmarshal (&cb, &ffi_type_pointer, 0, &rvalue);
+  else
+    rvalue = alloca (cif->rtype->size);
+
+  for (i = 0; i < cif->nargs; i++)
+    avalue[i]
+      = unmarshal (&cb, cif->arg_types[i], i >= cif->loongarch_nfixedargs,
+		   astorage + i * MAXCOPYARG);
+
+  fun (cif, rvalue, avalue, user_data);
+
+  if (!return_by_ref && cif->rtype->type != FFI_TYPE_VOID)
+    {
+      cb.used_integer = cb.used_float = 0;
+      marshal (&cb, cif->rtype, 0, rvalue);
+    }
+}
+
+#if defined(FFI_EXEC_STATIC_TRAMP)
+void *
+ffi_tramp_arch (size_t *tramp_size, size_t *map_size)
+{
+  extern void *trampoline_code_table;
+
+  *tramp_size = 16;
+  /* A mapping size of 64K is chosen to cover the page sizes of 4K, 16K, and
+     64K.  */
+  *map_size = 1 << 16;
+  return &trampoline_code_table;
+}
+#endif
diff --git a/ext/ffi_c/libffi/src/loongarch64/ffitarget.h b/ext/ffi_c/libffi/src/loongarch64/ffitarget.h
new file mode 100644
index 0000000..5a4698a
--- /dev/null
+++ b/ext/ffi_c/libffi/src/loongarch64/ffitarget.h
@@ -0,0 +1,82 @@
+/* -----------------------------------------------------------------*-C-*-
+   ffitarget.h - Copyright (c) 2022 Xu Chenghua <xuchenghua@loongson.cn>
+                               2022 Cheng Lulu <chenglulu@loongson.cn>
+
+   Target configuration macros for LoongArch.
+
+   Permission is hereby granted, free of charge, to any person obtaining
+   a copy of this software and associated documentation files (the
+   ``Software''), to deal in the Software without restriction, including
+   without limitation the rights to use, copy, modify, merge, publish,
+   distribute, sublicense, and/or sell copies of the Software, and to
+   permit persons to whom the Software is furnished to do so, subject to
+   the following conditions:
+
+   The above copyright notice and this permission notice shall be included
+   in all copies or substantial portions of the Software.
+
+   THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
+   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+   NONINFRINGEMENT.  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+   HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+   WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+   OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+   DEALINGS IN THE SOFTWARE.
+
+   ----------------------------------------------------------------------- */
+
+#ifndef LIBFFI_TARGET_H
+#define LIBFFI_TARGET_H
+
+#ifndef LIBFFI_H
+#error \
+  "Please do not include ffitarget.h directly into your source.  Use ffi.h instead."
+#endif
+
+#ifndef __loongarch__
+#error \
+  "libffi was configured for a LoongArch target but this does not appear to be a LoongArch compiler."
+#endif
+
+#ifndef LIBFFI_ASM
+
+typedef unsigned long ffi_arg;
+typedef signed long ffi_sarg;
+
+typedef enum ffi_abi
+{
+  FFI_FIRST_ABI = 0,
+  FFI_LP64S,
+  FFI_LP64F,
+  FFI_LP64D,
+  FFI_LAST_ABI,
+
+#if defined(__loongarch64)
+#if defined(__loongarch_soft_float)
+  FFI_DEFAULT_ABI = FFI_LP64S
+#elif defined(__loongarch_single_float)
+  FFI_DEFAULT_ABI = FFI_LP64F
+#elif defined(__loongarch_double_float)
+  FFI_DEFAULT_ABI = FFI_LP64D
+#else
+#error unsupported LoongArch floating-point ABI
+#endif
+#else
+#error unsupported LoongArch base architecture
+#endif
+} ffi_abi;
+
+#endif /* LIBFFI_ASM */
+
+/* ---- Definitions for closures ----------------------------------------- */
+
+#define FFI_CLOSURES 1
+#define FFI_GO_CLOSURES 1
+#define FFI_TRAMPOLINE_SIZE 24
+#define FFI_NATIVE_RAW_API 0
+#define FFI_EXTRA_CIF_FIELDS \
+  unsigned loongarch_nfixedargs; \
+  unsigned loongarch_unused;
+#define FFI_TARGET_SPECIFIC_VARIADIC
+#endif
diff --git a/ext/ffi_c/libffi/src/loongarch64/sysv.S b/ext/ffi_c/libffi/src/loongarch64/sysv.S
new file mode 100644
index 0000000..aa7bde2
--- /dev/null
+++ b/ext/ffi_c/libffi/src/loongarch64/sysv.S
@@ -0,0 +1,327 @@
+/* -----------------------------------------------------------------------
+  sysv.S  - Copyright (c) 2022 Xu Chenghua <xuchenghua@loongson.cn>
+                          2022 Cheng Lulu <chenglulu@loongson.cn>
+
+   LoongArch Foreign Function Interface
+
+   Permission is hereby granted, free of charge, to any person obtaining
+   a copy of this software and associated documentation files (the
+   ``Software''), to deal in the Software without restriction, including
+   without limitation the rights to use, copy, modify, merge, publish,
+   distribute, sublicense, and/or sell copies of the Software, and to
+   permit persons to whom the Software is furnished to do so, subject to
+   the following conditions:
+
+   The above copyright notice and this permission notice shall be included
+   in all copies or substantial portions of the Software.
+
+   THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
+   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+   NONINFRINGEMENT.  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+   HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+   WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+   OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+   DEALINGS IN THE SOFTWARE.
+   ----------------------------------------------------------------------- */
+
+#define LIBFFI_ASM
+#include <fficonfig.h>
+#include <ffi.h>
+
+/* Define aliases so that we can handle all ABIs uniformly.  */
+
+#if __SIZEOF_POINTER__ == 8
+# define PTRS 8
+# define LARG ld.d
+# define SARG st.d
+#else
+# define PTRS 4
+# define LARG ld.w
+# define SARG st.w
+#endif
+
+#if defined(__loongarch_single_float)
+# define FLTS 4
+# define FLD fld.w
+# define FST fst.w
+#elif defined(__loongarch_double_float)
+# define FLTS 8
+# define FLARG fld.d
+# define FSARG fst.d
+#elif defined(__loongarch_soft_float)
+# define FLTS 0
+#else
+#error unsupported LoongArch floating-point ABI
+#endif
+
+    .text
+    .globl  ffi_call_asm
+    .type   ffi_call_asm, @function
+    .hidden ffi_call_asm
+/* struct call_context
+   {
+     ABI_FLOAT fa[8];
+     size_t a[10];
+   }
+
+   - 8 floating point parameter/result registers (fa[0] - fa[7])
+   - 8 integer parameter/result registers (a[0] - a[7])
+   - 2 registers used by the assembly code to in-place construct its own stack
+     frame.
+    - frame pointer (a[8])
+    - return address (a[9])
+
+   void ffi_call_asm (size_t *stackargs, struct call_context *regargs,
+		      void (*fn)(void), void *closure); */
+
+#define FRAME_LEN (8 * FLTS + 10 * PTRS)
+
+ffi_call_asm:
+	.cfi_startproc
+
+	/* We are NOT going to set up an ordinary stack frame.  In order to pass
+	   the stacked args to the called function, we adjust our stack pointer
+	   to a0, which is in the _caller's_ alloca area.  We establish our own
+	   stack frame at the end of the call_context.
+
+	   Anything below the arguments will be freed at this point, although
+	   we preserve the call_context so that it can be read back in the
+	   caller.  */
+
+	.cfi_def_cfa	5, FRAME_LEN # Interim CFA based on a1.
+	SARG	$fp, $a1, FRAME_LEN - 2*PTRS
+	.cfi_offset	22, -2*PTRS
+	SARG	$ra, $a1, FRAME_LEN - 1*PTRS
+	.cfi_offset	1, -1*PTRS
+
+	addi.d	$fp, $a1, FRAME_LEN
+	move	$sp, $a0
+	.cfi_def_cfa	22, 0 # Our frame is fully set up.
+
+	# Load arguments.
+	move	$t1, $a2
+	move	$t2, $a3
+
+#if FLTS
+	FLARG	$fa0, $fp, -FRAME_LEN+0*FLTS
+	FLARG	$fa1, $fp, -FRAME_LEN+1*FLTS
+	FLARG	$fa2, $fp, -FRAME_LEN+2*FLTS
+	FLARG	$fa3, $fp, -FRAME_LEN+3*FLTS
+	FLARG	$fa4, $fp, -FRAME_LEN+4*FLTS
+	FLARG	$fa5, $fp, -FRAME_LEN+5*FLTS
+	FLARG	$fa6, $fp, -FRAME_LEN+6*FLTS
+	FLARG	$fa7, $fp, -FRAME_LEN+7*FLTS
+#endif
+
+	LARG	$a0, $fp, -FRAME_LEN+8*FLTS+0*PTRS
+	LARG	$a1, $fp, -FRAME_LEN+8*FLTS+1*PTRS
+	LARG	$a2, $fp, -FRAME_LEN+8*FLTS+2*PTRS
+	LARG	$a3, $fp, -FRAME_LEN+8*FLTS+3*PTRS
+	LARG	$a4, $fp, -FRAME_LEN+8*FLTS+4*PTRS
+	LARG	$a5, $fp, -FRAME_LEN+8*FLTS+5*PTRS
+	LARG	$a6, $fp, -FRAME_LEN+8*FLTS+6*PTRS
+	LARG	$a7, $fp, -FRAME_LEN+8*FLTS+7*PTRS
+
+	/* Call */
+	jirl	$ra, $t1, 0
+
+#if FLTS
+	/* Save return values - only a0/a1 (fa0/fa1) are used.  */
+	FSARG	$fa0, $fp, -FRAME_LEN+0*FLTS
+	FSARG	$fa1, $fp, -FRAME_LEN+1*FLTS
+#endif
+
+	SARG	$a0, $fp, -FRAME_LEN+8*FLTS+0*PTRS
+	SARG	$a1, $fp, -FRAME_LEN+8*FLTS+1*PTRS
+
+	/* Restore and return.  */
+	addi.d	$sp, $fp, -FRAME_LEN
+	.cfi_def_cfa	3, FRAME_LEN
+	LARG	$ra, $fp, -1*PTRS
+	.cfi_restore	1
+	LARG	$fp, $fp, -2*PTRS
+	.cfi_restore	22
+	jr	$ra
+	.cfi_endproc
+	.size	ffi_call_asm, .-ffi_call_asm
+
+
+/* ffi_closure_asm. Expects address of the passed-in ffi_closure in t0.
+   void ffi_closure_inner (ffi_cif *cif,
+			   void (*fun)(ffi_cif *, void *, void **, void *),
+			   void *user_data,
+			   size_t *stackargs, struct call_context *regargs) */
+
+	.globl	ffi_closure_asm
+	.hidden	ffi_closure_asm
+	.type	ffi_closure_asm, @function
+
+ffi_closure_asm:
+	.cfi_startproc
+	addi.d	$sp, $sp, -FRAME_LEN
+	.cfi_def_cfa_offset FRAME_LEN
+
+	/* Make a frame.  */
+	SARG	$fp, $sp, FRAME_LEN - 2*PTRS
+	.cfi_offset	22, -2*PTRS
+	SARG	$ra, $sp, FRAME_LEN - 1*PTRS
+	.cfi_offset	1, -1*PTRS
+	addi.d	$fp, $sp, FRAME_LEN
+
+	/* Save arguments.  */
+#if FLTS
+	FSARG	$fa0, $sp, 0*FLTS
+	FSARG	$fa1, $sp, 1*FLTS
+	FSARG	$fa2, $sp, 2*FLTS
+	FSARG	$fa3, $sp, 3*FLTS
+	FSARG	$fa4, $sp, 4*FLTS
+	FSARG	$fa5, $sp, 5*FLTS
+	FSARG	$fa6, $sp, 6*FLTS
+	FSARG	$fa7, $sp, 7*FLTS
+#endif
+
+	SARG	$a0, $sp, 8*FLTS+0*PTRS
+	SARG	$a1, $sp, 8*FLTS+1*PTRS
+	SARG	$a2, $sp, 8*FLTS+2*PTRS
+	SARG	$a3, $sp, 8*FLTS+3*PTRS
+	SARG	$a4, $sp, 8*FLTS+4*PTRS
+	SARG	$a5, $sp, 8*FLTS+5*PTRS
+	SARG	$a6, $sp, 8*FLTS+6*PTRS
+	SARG	$a7, $sp, 8*FLTS+7*PTRS
+
+	/* Enter C */
+	LARG	$a0, $t0, FFI_TRAMPOLINE_SIZE+0*PTRS
+	LARG	$a1, $t0, FFI_TRAMPOLINE_SIZE+1*PTRS
+	LARG	$a2, $t0, FFI_TRAMPOLINE_SIZE+2*PTRS
+	addi.d	$a3, $sp, FRAME_LEN
+	move	$a4, $sp
+
+	bl	ffi_closure_inner
+
+	/* Return values.  */
+#if FLTS
+	FLARG	$fa0, $sp, 0*FLTS
+	FLARG	$fa1, $sp, 1*FLTS
+#endif
+
+	LARG	$a0, $sp, 8*FLTS+0*PTRS
+	LARG	$a1, $sp, 8*FLTS+1*PTRS
+
+	/* Restore and return.  */
+	LARG	$ra, $sp, FRAME_LEN-1*PTRS
+	.cfi_restore	1
+	LARG	$fp, $sp, FRAME_LEN-2*PTRS
+	.cfi_restore	22
+	addi.d	$sp, $sp, FRAME_LEN
+	.cfi_def_cfa_offset 0
+	jr	$ra
+	.cfi_endproc
+	.size	ffi_closure_asm, .-ffi_closure_asm
+
+/* Static trampoline code table, in which each element is a trampoline.
+
+   The trampoline clobbers t0 and t1, but we don't save them on the stack
+   because our psABI explicitly says they are scratch registers, at least for
+   ELF.  Our dynamic trampoline is already clobbering them anyway.
+
+   The trampoline has two parameters - target code to jump to and data for
+   the target code. The trampoline extracts the parameters from its parameter
+   block (see tramp_table_map()).  The trampoline saves the data address in
+   t0 and jumps to the target code.  As ffi_closure_asm() already expects the
+   data address to be in t0, we don't need a "ffi_closure_asm_alt".  */
+
+#if defined(FFI_EXEC_STATIC_TRAMP)
+	.align	16
+	.globl	trampoline_code_table
+	.hidden	trampoline_code_table
+	.type	trampoline_code_table, @function
+
+trampoline_code_table:
+
+	.rept	65536 / 16
+	pcaddu12i	$t1, 16 # 65536 >> 12
+	ld.d	$t0, $t1, 0
+	ld.d	$t1, $t1, 8
+	jirl	$zero, $t1, 0
+	.endr
+	.size	trampoline_code_table, .-trampoline_code_table
+
+	.align	2
+#endif
+
+/* ffi_go_closure_asm.  Expects address of the passed-in ffi_go_closure in t2.
+   void ffi_closure_inner (ffi_cif *cif,
+			   void (*fun)(ffi_cif *, void *, void **, void *),
+			   void *user_data,
+			   size_t *stackargs, struct call_context *regargs) */
+
+	.globl	ffi_go_closure_asm
+	.hidden	ffi_go_closure_asm
+	.type	ffi_go_closure_asm, @function
+
+ffi_go_closure_asm:
+	.cfi_startproc
+	addi.d	$sp, $sp, -FRAME_LEN
+	.cfi_def_cfa_offset FRAME_LEN
+
+	/* Make a frame.  */
+	SARG	$fp, $sp, FRAME_LEN - 2*PTRS
+	.cfi_offset	22, -2*PTRS
+	SARG	$ra, $sp, FRAME_LEN - 1*PTRS
+	.cfi_offset	1, -1*PTRS
+	addi.d	$fp, $sp, FRAME_LEN
+
+	/* Save arguments.  */
+#if FLTS
+	FSARG	$fa0, $sp, 0*FLTS
+	FSARG	$fa1, $sp, 1*FLTS
+	FSARG	$fa2, $sp, 2*FLTS
+	FSARG	$fa3, $sp, 3*FLTS
+	FSARG	$fa4, $sp, 4*FLTS
+	FSARG	$fa5, $sp, 5*FLTS
+	FSARG	$fa6, $sp, 6*FLTS
+	FSARG	$fa7, $sp, 7*FLTS
+#endif
+
+	SARG	$a0, $sp, 8*FLTS+0*PTRS
+	SARG	$a1, $sp, 8*FLTS+1*PTRS
+	SARG	$a2, $sp, 8*FLTS+2*PTRS
+	SARG	$a3, $sp, 8*FLTS+3*PTRS
+	SARG	$a4, $sp, 8*FLTS+4*PTRS
+	SARG	$a5, $sp, 8*FLTS+5*PTRS
+	SARG	$a6, $sp, 8*FLTS+6*PTRS
+	SARG	$a7, $sp, 8*FLTS+7*PTRS
+
+	/* Enter C */
+	LARG	$a0, $t2, 1*PTRS
+	LARG	$a1, $t2, 2*PTRS
+	move	$a2, $t2
+	addi.d	$a3, $sp, FRAME_LEN
+	move	$a4, $sp
+
+	bl	ffi_closure_inner
+
+	/* Return values.  */
+#if FLTS
+	FLARG	$fa0, $sp, 0*FLTS
+	FLARG	$fa1, $sp, 1*FLTS
+#endif
+
+	LARG	$a0, $sp, 8*FLTS+0*PTRS
+	LARG	$a1, $sp, 8*FLTS+1*PTRS
+
+	/* Restore and return.  */
+	LARG	$ra, $sp, FRAME_LEN-1*PTRS
+	.cfi_restore	1
+	LARG	$fp, $sp, FRAME_LEN-2*PTRS
+	.cfi_restore	22
+	addi.d	$sp, $sp, FRAME_LEN
+	.cfi_def_cfa_offset 0
+	jr	$ra
+	.cfi_endproc
+	.size	ffi_go_closure_asm, .-ffi_go_closure_asm
+
+#if defined __ELF__ && defined __linux__
+	.section .note.GNU-stack,"",%progbits
+#endif
diff --git a/ffi.gemspec b/ffi.gemspec
index cefb297..3578b03 100644
--- a/ffi.gemspec
+++ b/ffi.gemspec
@@ -1,36 +1,42 @@
-require File.expand_path("../lib/#{File.basename(__FILE__, '.gemspec')}/version", __FILE__)
+# -*- encoding: utf-8 -*-
+# stub: ffi 1.10.0 ruby lib
+# stub: ext/ffi_c/extconf.rb
 
 Gem::Specification.new do |s|
-  s.name = 'ffi'
-  s.version = FFI::VERSION
-  s.author = 'Wayne Meissner'
-  s.email = 'wmeissner@gmail.com'
-  s.homepage = 'http://wiki.github.com/ffi/ffi'
-  s.summary = 'Ruby FFI'
-  s.description = 'Ruby FFI library'
-  s.files = `git ls-files -z`.split("\x0").reject do |f|
-    f =~ /^(bench|gen|libtest|nbproject|spec)/
-  end
+  s.name = "ffi".freeze
+  s.version = "1.10.0"
+
+  s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
+  s.require_paths = ["lib".freeze]
+  s.authors = ["Wayne Meissner".freeze]
+  s.date = "2019-01-06"
+  s.description = "Ruby FFI library".freeze
+  s.email = "wmeissner@gmail.com".freeze
+  s.extensions = ["ext/ffi_c/extconf.rb".freeze]
+  s.files = [".gitignore".freeze, ".gitmodules".freeze, ".travis.yml".freeze, ".yardopts".freeze, "CHANGELOG.md".freeze, "COPYING".freeze, "Gemfile".freeze, "LICENSE".freeze, "LICENSE.SPECS".freeze, "README.md".freeze, "Rakefile".freeze, "appveyor.yml".freeze, "ext/ffi_c/AbstractMemory.c".freeze, "ext/ffi_c/AbstractMemory.h".freeze, "ext/ffi_c/ArrayType.c".freeze, "ext/ffi_c/ArrayType.h".freeze, "ext/ffi_c/Buffer.c".freeze, "ext/ffi_c/Call.c".freeze, "ext/ffi_c/Call.h".freeze, "ext/ffi_c/ClosurePool.c".freeze, "ext/ffi_c/ClosurePool.h".freeze, "ext/ffi_c/DataConverter.c".freeze, "ext/ffi_c/DynamicLibrary.c".freeze, "ext/ffi_c/DynamicLibrary.h".freeze, "ext/ffi_c/Function.c".freeze, "ext/ffi_c/Function.h".freeze, "ext/ffi_c/FunctionInfo.c".freeze, "ext/ffi_c/LastError.c".freeze, "ext/ffi_c/LastError.h".freeze, "ext/ffi_c/LongDouble.c".freeze, "ext/ffi_c/LongDouble.h".freeze, "ext/ffi_c/MappedType.c".freeze, "ext/ffi_c/MappedType.h".freeze, "ext/ffi_c/MemoryPointer.c".freeze, "ext/ffi_c/MemoryPointer.h".freeze, "ext/ffi_c/MethodHandle.c".freeze, "ext/ffi_c/MethodHandle.h".freeze, "ext/ffi_c/Platform.c".freeze, "ext/ffi_c/Platform.h".freeze, "ext/ffi_c/Pointer.c".freeze, "ext/ffi_c/Pointer.h".freeze, "ext/ffi_c/Struct.c".freeze, "ext/ffi_c/Struct.h".freeze, "ext/ffi_c/StructByReference.c".freeze, "ext/ffi_c/StructByReference.h".freeze, "ext/ffi_c/StructByValue.c".freeze, "ext/ffi_c/StructByValue.h".freeze, "ext/ffi_c/StructLayout.c".freeze, "ext/ffi_c/Thread.c".freeze, "ext/ffi_c/Thread.h".freeze, "ext/ffi_c/Type.c".freeze, "ext/ffi_c/Type.h".freeze, "ext/ffi_c/Types.c".freeze, "ext/ffi_c/Types.h".freeze, "ext/ffi_c/Variadic.c".freeze, "ext/ffi_c/compat.h".freeze, "ext/ffi_c/extconf.rb".freeze, "ext/ffi_c/ffi.c".freeze, "ext/ffi_c/libffi.bsd.mk".freeze, "ext/ffi_c/libffi.darwin.mk".freeze, "ext/ffi_c/libffi.gnu.mk".freeze, "ext/ffi_c/libffi.mk".freeze, "ext/ffi_c/libffi.vc.mk".freeze, "ext/ffi_c/libffi.vc64.mk".freeze, "ext/ffi_c/libffi/.appveyor.yml".freeze, "ext/ffi_c/libffi/.github/issue_template.md".freeze, "ext/ffi_c/libffi/.gitignore".freeze, "ext/ffi_c/libffi/.travis.yml".freeze, "ext/ffi_c/libffi/.travis/ar-lib".freeze, "ext/ffi_c/libffi/.travis/build.sh".freeze, "ext/ffi_c/libffi/.travis/compile".freeze, "ext/ffi_c/libffi/.travis/install.sh".freeze, "ext/ffi_c/libffi/.travis/moxie-sim.exp".freeze, "ext/ffi_c/libffi/.travis/site.exp".freeze, "ext/ffi_c/libffi/ChangeLog.libffi".freeze, "ext/ffi_c/libffi/ChangeLog.libffi-3.1".freeze, "ext/ffi_c/libffi/ChangeLog.libgcj".freeze, "ext/ffi_c/libffi/ChangeLog.v1".freeze, "ext/ffi_c/libffi/LICENSE".freeze, "ext/ffi_c/libffi/LICENSE-BUILDTOOLS".freeze, "ext/ffi_c/libffi/Makefile.am".freeze, "ext/ffi_c/libffi/Makefile.in".freeze, "ext/ffi_c/libffi/README.md".freeze, "ext/ffi_c/libffi/acinclude.m4".freeze, "ext/ffi_c/libffi/autogen.sh".freeze, "ext/ffi_c/libffi/config.guess".freeze, "ext/ffi_c/libffi/config.sub".freeze, "ext/ffi_c/libffi/configure".freeze, "ext/ffi_c/libffi/configure.ac".freeze, "ext/ffi_c/libffi/configure.host".freeze, "ext/ffi_c/libffi/doc/Makefile.am".freeze, "ext/ffi_c/libffi/doc/Makefile.in".freeze, "ext/ffi_c/libffi/doc/libffi.texi".freeze, "ext/ffi_c/libffi/doc/version.texi".freeze, "ext/ffi_c/libffi/fficonfig.h.in".freeze, "ext/ffi_c/libffi/generate-darwin-source-and-headers.py".freeze, "ext/ffi_c/libffi/include/Makefile.am".freeze, "ext/ffi_c/libffi/include/Makefile.in".freeze, "ext/ffi_c/libffi/include/ffi.h.in".freeze, "ext/ffi_c/libffi/include/ffi_cfi.h".freeze, "ext/ffi_c/libffi/include/ffi_common.h".freeze, "ext/ffi_c/libffi/install-sh".freeze, "ext/ffi_c/libffi/libffi.map.in".freeze, "ext/ffi_c/libffi/libffi.pc.in".freeze, "ext/ffi_c/libffi/libffi.xcodeproj/project.pbxproj".freeze, "ext/ffi_c/libffi/libtool-ldflags".freeze, "ext/ffi_c/libffi/libtool-version".freeze, "ext/ffi_c/libffi/ltmain.sh".freeze, "ext/ffi_c/libffi/m4/asmcfi.m4".freeze, "ext/ffi_c/libffi/m4/ax_append_flag.m4".freeze, "ext/ffi_c/libffi/m4/ax_cc_maxopt.m4".freeze, "ext/ffi_c/libffi/m4/ax_cflags_warn_all.m4".freeze, "ext/ffi_c/libffi/m4/ax_check_compile_flag.m4".freeze, "ext/ffi_c/libffi/m4/ax_compiler_vendor.m4".freeze, "ext/ffi_c/libffi/m4/ax_configure_args.m4".freeze, "ext/ffi_c/libffi/m4/ax_enable_builddir.m4".freeze, "ext/ffi_c/libffi/m4/ax_gcc_archflag.m4".freeze, "ext/ffi_c/libffi/m4/ax_gcc_x86_cpuid.m4".freeze, "ext/ffi_c/libffi/m4/ax_require_defined.m4".freeze, "ext/ffi_c/libffi/man/Makefile.am".freeze, "ext/ffi_c/libffi/man/Makefile.in".freeze, "ext/ffi_c/libffi/man/ffi.3".freeze, "ext/ffi_c/libffi/man/ffi_call.3".freeze, "ext/ffi_c/libffi/man/ffi_prep_cif.3".freeze, "ext/ffi_c/libffi/man/ffi_prep_cif_var.3".freeze, "ext/ffi_c/libffi/missing".freeze, "ext/ffi_c/libffi/msvcc.sh".freeze, "ext/ffi_c/libffi/src/aarch64/ffi.c".freeze, "ext/ffi_c/libffi/src/aarch64/ffitarget.h".freeze, "ext/ffi_c/libffi/src/aarch64/internal.h".freeze, "ext/ffi_c/libffi/src/aarch64/sysv.S".freeze, "ext/ffi_c/libffi/src/loongarch64/sysv.S".freeze, "ext/ffi_c/libffi/src/loongarch64/ffi.c".freeze, "ext/ffi_c/libffi/src/loongarch64/ffitarget.h".freeze, "ext/ffi_c/libffi/src/alpha/ffi.c".freeze, "ext/ffi_c/libffi/src/alpha/ffitarget.h".freeze, "ext/ffi_c/libffi/src/alpha/internal.h".freeze, "ext/ffi_c/libffi/src/alpha/osf.S".freeze, "ext/ffi_c/libffi/src/arc/arcompact.S".freeze, "ext/ffi_c/libffi/src/arc/ffi.c".freeze, "ext/ffi_c/libffi/src/arc/ffitarget.h".freeze, "ext/ffi_c/libffi/src/arm/ffi.c".freeze, "ext/ffi_c/libffi/src/arm/ffitarget.h".freeze, "ext/ffi_c/libffi/src/arm/internal.h".freeze, "ext/ffi_c/libffi/src/arm/sysv.S".freeze, "ext/ffi_c/libffi/src/avr32/ffi.c".freeze, "ext/ffi_c/libffi/src/avr32/ffitarget.h".freeze, "ext/ffi_c/libffi/src/avr32/sysv.S".freeze, "ext/ffi_c/libffi/src/bfin/ffi.c".freeze, "ext/ffi_c/libffi/src/bfin/ffitarget.h".freeze, "ext/ffi_c/libffi/src/bfin/sysv.S".freeze, "ext/ffi_c/libffi/src/closures.c".freeze, "ext/ffi_c/libffi/src/cris/ffi.c".freeze, "ext/ffi_c/libffi/src/cris/ffitarget.h".freeze, "ext/ffi_c/libffi/src/cris/sysv.S".freeze, "ext/ffi_c/libffi/src/debug.c".freeze, "ext/ffi_c/libffi/src/dlmalloc.c".freeze, "ext/ffi_c/libffi/src/frv/eabi.S".freeze, "ext/ffi_c/libffi/src/frv/ffi.c".freeze, "ext/ffi_c/libffi/src/frv/ffitarget.h".freeze, "ext/ffi_c/libffi/src/ia64/ffi.c".freeze, "ext/ffi_c/libffi/src/ia64/ffitarget.h".freeze, "ext/ffi_c/libffi/src/ia64/ia64_flags.h".freeze, "ext/ffi_c/libffi/src/ia64/unix.S".freeze, "ext/ffi_c/libffi/src/java_raw_api.c".freeze, "ext/ffi_c/libffi/src/m32r/ffi.c".freeze, "ext/ffi_c/libffi/src/m32r/ffitarget.h".freeze, "ext/ffi_c/libffi/src/m32r/sysv.S".freeze, "ext/ffi_c/libffi/src/m68k/ffi.c".freeze, "ext/ffi_c/libffi/src/m68k/ffitarget.h".freeze, "ext/ffi_c/libffi/src/m68k/sysv.S".freeze, "ext/ffi_c/libffi/src/m88k/ffi.c".freeze, "ext/ffi_c/libffi/src/m88k/ffitarget.h".freeze, "ext/ffi_c/libffi/src/m88k/obsd.S".freeze, "ext/ffi_c/libffi/src/metag/ffi.c".freeze, "ext/ffi_c/libffi/src/metag/ffitarget.h".freeze, "ext/ffi_c/libffi/src/metag/sysv.S".freeze, "ext/ffi_c/libffi/src/microblaze/ffi.c".freeze, "ext/ffi_c/libffi/src/microblaze/ffitarget.h".freeze, "ext/ffi_c/libffi/src/microblaze/sysv.S".freeze, "ext/ffi_c/libffi/src/mips/ffi.c".freeze, "ext/ffi_c/libffi/src/mips/ffitarget.h".freeze, "ext/ffi_c/libffi/src/mips/n32.S".freeze, "ext/ffi_c/libffi/src/mips/o32.S".freeze, "ext/ffi_c/libffi/src/moxie/eabi.S".freeze, "ext/ffi_c/libffi/src/moxie/ffi.c".freeze, "ext/ffi_c/libffi/src/moxie/ffitarget.h".freeze, "ext/ffi_c/libffi/src/nios2/ffi.c".freeze, "ext/ffi_c/libffi/src/nios2/ffitarget.h".freeze, "ext/ffi_c/libffi/src/nios2/sysv.S".freeze, "ext/ffi_c/libffi/src/or1k/ffi.c".freeze, "ext/ffi_c/libffi/src/or1k/ffitarget.h".freeze, "ext/ffi_c/libffi/src/or1k/sysv.S".freeze, "ext/ffi_c/libffi/src/pa/ffi.c".freeze, "ext/ffi_c/libffi/src/pa/ffitarget.h".freeze, "ext/ffi_c/libffi/src/pa/hpux32.S".freeze, "ext/ffi_c/libffi/src/pa/linux.S".freeze, "ext/ffi_c/libffi/src/powerpc/aix.S".freeze, "ext/ffi_c/libffi/src/powerpc/aix_closure.S".freeze, "ext/ffi_c/libffi/src/powerpc/asm.h".freeze, "ext/ffi_c/libffi/src/powerpc/darwin.S".freeze, "ext/ffi_c/libffi/src/powerpc/darwin_closure.S".freeze, "ext/ffi_c/libffi/src/powerpc/ffi.c".freeze, "ext/ffi_c/libffi/src/powerpc/ffi_darwin.c".freeze, "ext/ffi_c/libffi/src/powerpc/ffi_linux64.c".freeze, "ext/ffi_c/libffi/src/powerpc/ffi_powerpc.h".freeze, "ext/ffi_c/libffi/src/powerpc/ffi_sysv.c".freeze, "ext/ffi_c/libffi/src/powerpc/ffitarget.h".freeze, "ext/ffi_c/libffi/src/powerpc/linux64.S".freeze, "ext/ffi_c/libffi/src/powerpc/linux64_closure.S".freeze, "ext/ffi_c/libffi/src/powerpc/ppc_closure.S".freeze, "ext/ffi_c/libffi/src/powerpc/sysv.S".freeze, "ext/ffi_c/libffi/src/prep_cif.c".freeze, "ext/ffi_c/libffi/src/raw_api.c".freeze, "ext/ffi_c/libffi/src/riscv/ffi.c".freeze, "ext/ffi_c/libffi/src/riscv/ffitarget.h".freeze, "ext/ffi_c/libffi/src/riscv/sysv.S".freeze, "ext/ffi_c/libffi/src/s390/ffi.c".freeze, "ext/ffi_c/libffi/src/s390/ffitarget.h".freeze, "ext/ffi_c/libffi/src/s390/internal.h".freeze, "ext/ffi_c/libffi/src/s390/sysv.S".freeze, "ext/ffi_c/libffi/src/sh/ffi.c".freeze, "ext/ffi_c/libffi/src/sh/ffitarget.h".freeze, "ext/ffi_c/libffi/src/sh/sysv.S".freeze, "ext/ffi_c/libffi/src/sh64/ffi.c".freeze, "ext/ffi_c/libffi/src/sh64/ffitarget.h".freeze, "ext/ffi_c/libffi/src/sh64/sysv.S".freeze, "ext/ffi_c/libffi/src/sparc/ffi.c".freeze, "ext/ffi_c/libffi/src/sparc/ffi64.c".freeze, "ext/ffi_c/libffi/src/sparc/ffitarget.h".freeze, "ext/ffi_c/libffi/src/sparc/internal.h".freeze, "ext/ffi_c/libffi/src/sparc/v8.S".freeze, "ext/ffi_c/libffi/src/sparc/v9.S".freeze, "ext/ffi_c/libffi/src/tile/ffi.c".freeze, "ext/ffi_c/libffi/src/tile/ffitarget.h".freeze, "ext/ffi_c/libffi/src/tile/tile.S".freeze, "ext/ffi_c/libffi/src/types.c".freeze, "ext/ffi_c/libffi/src/vax/elfbsd.S".freeze, "ext/ffi_c/libffi/src/vax/ffi.c".freeze, "ext/ffi_c/libffi/src/vax/ffitarget.h".freeze, "ext/ffi_c/libffi/src/x86/asmnames.h".freeze, "ext/ffi_c/libffi/src/x86/ffi.c".freeze, "ext/ffi_c/libffi/src/x86/ffi64.c".freeze, "ext/ffi_c/libffi/src/x86/ffitarget.h".freeze, "ext/ffi_c/libffi/src/x86/ffiw64.c".freeze, "ext/ffi_c/libffi/src/x86/internal.h".freeze, "ext/ffi_c/libffi/src/x86/internal64.h".freeze, "ext/ffi_c/libffi/src/x86/sysv.S".freeze, "ext/ffi_c/libffi/src/x86/unix64.S".freeze, "ext/ffi_c/libffi/src/x86/win64.S".freeze, "ext/ffi_c/libffi/src/x86/win64_intel.S".freeze, "ext/ffi_c/libffi/src/xtensa/ffi.c".freeze, "ext/ffi_c/libffi/src/xtensa/ffitarget.h".freeze, "ext/ffi_c/libffi/src/xtensa/sysv.S".freeze, "ext/ffi_c/libffi/stamp-h.in".freeze, "ext/ffi_c/libffi/testsuite/Makefile.am".freeze, "ext/ffi_c/libffi/testsuite/Makefile.in".freeze, "ext/ffi_c/libffi/testsuite/config/default.exp".freeze, "ext/ffi_c/libffi/testsuite/lib/libffi.exp".freeze, "ext/ffi_c/libffi/testsuite/lib/target-libpath.exp".freeze, "ext/ffi_c/libffi/testsuite/lib/wrapper.exp".freeze, "ext/ffi_c/libffi/testsuite/libffi.bhaible/Makefile".freeze, "ext/ffi_c/libffi/testsuite/libffi.bhaible/README".freeze, "ext/ffi_c/libffi/testsuite/libffi.bhaible/alignof.h".freeze, "ext/ffi_c/libffi/testsuite/libffi.bhaible/bhaible.exp".freeze, "ext/ffi_c/libffi/testsuite/libffi.bhaible/test-call.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.bhaible/test-callback.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.bhaible/testcases.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.call/align_mixed.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.call/align_stdcall.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.call/call.exp".freeze, "ext/ffi_c/libffi/testsuite/libffi.call/closure_fn0.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.call/closure_fn1.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.call/closure_fn2.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.call/closure_fn3.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.call/closure_fn4.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.call/closure_fn5.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.call/closure_fn6.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.call/closure_loc_fn0.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.call/closure_simple.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.call/cls_12byte.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.call/cls_16byte.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.call/cls_18byte.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.call/cls_19byte.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.call/cls_1_1byte.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.call/cls_20byte.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.call/cls_20byte1.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.call/cls_24byte.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.call/cls_2byte.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.call/cls_3_1byte.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.call/cls_3byte1.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.call/cls_3byte2.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.call/cls_3float.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.call/cls_4_1byte.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.call/cls_4byte.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.call/cls_5_1_byte.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.call/cls_5byte.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.call/cls_64byte.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.call/cls_6_1_byte.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.call/cls_6byte.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.call/cls_7_1_byte.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.call/cls_7byte.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.call/cls_8byte.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.call/cls_9byte1.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.call/cls_9byte2.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.call/cls_align_double.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.call/cls_align_float.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.call/cls_align_longdouble.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.call/cls_align_longdouble_split.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.call/cls_align_longdouble_split2.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.call/cls_align_pointer.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.call/cls_align_sint16.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.call/cls_align_sint32.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.call/cls_align_sint64.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.call/cls_align_uint16.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.call/cls_align_uint32.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.call/cls_align_uint64.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.call/cls_dbls_struct.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.call/cls_double.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.call/cls_double_va.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.call/cls_float.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.call/cls_longdouble.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.call/cls_longdouble_va.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.call/cls_many_mixed_args.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.call/cls_many_mixed_float_double.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.call/cls_multi_schar.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.call/cls_multi_sshort.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.call/cls_multi_sshortchar.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.call/cls_multi_uchar.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.call/cls_multi_ushort.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.call/cls_multi_ushortchar.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.call/cls_pointer.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.call/cls_pointer_stack.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.call/cls_schar.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.call/cls_sint.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.call/cls_sshort.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.call/cls_struct_va1.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.call/cls_uchar.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.call/cls_uchar_va.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.call/cls_uint.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.call/cls_uint_va.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.call/cls_ulong_va.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.call/cls_ulonglong.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.call/cls_ushort.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.call/cls_ushort_va.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.call/err_bad_abi.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.call/err_bad_typedef.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.call/ffitest.h".freeze, "ext/ffi_c/libffi/testsuite/libffi.call/float.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.call/float1.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.call/float2.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.call/float3.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.call/float4.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.call/float_va.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.call/huge_struct.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.call/many.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.call/many2.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.call/many_double.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.call/many_mixed.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.call/negint.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.call/nested_struct.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.call/nested_struct1.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.call/nested_struct10.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.call/nested_struct11.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.call/nested_struct2.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.call/nested_struct3.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.call/nested_struct4.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.call/nested_struct5.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.call/nested_struct6.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.call/nested_struct7.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.call/nested_struct8.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.call/nested_struct9.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.call/offsets.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.call/pr1172638.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.call/problem1.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.call/promotion.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.call/pyobjc-tc.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.call/return_dbl.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.call/return_dbl1.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.call/return_dbl2.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.call/return_fl.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.call/return_fl1.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.call/return_fl2.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.call/return_fl3.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.call/return_ldl.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.call/return_ll.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.call/return_ll1.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.call/return_sc.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.call/return_sl.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.call/return_uc.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.call/return_ul.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.call/stret_large.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.call/stret_large2.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.call/stret_medium.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.call/stret_medium2.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.call/strlen.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.call/strlen2.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.call/strlen3.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.call/strlen4.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.call/struct1.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.call/struct10.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.call/struct2.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.call/struct3.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.call/struct4.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.call/struct5.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.call/struct6.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.call/struct7.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.call/struct8.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.call/struct9.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.call/testclosure.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.call/uninitialized.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.call/unwindtest.cc".freeze, "ext/ffi_c/libffi/testsuite/libffi.call/unwindtest_ffi_call.cc".freeze, "ext/ffi_c/libffi/testsuite/libffi.call/va_1.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.call/va_struct1.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.call/va_struct2.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.call/va_struct3.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.complex/cls_align_complex.inc".freeze, "ext/ffi_c/libffi/testsuite/libffi.complex/cls_align_complex_double.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.complex/cls_align_complex_float.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.complex/cls_align_complex_longdouble.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.complex/cls_complex.inc".freeze, "ext/ffi_c/libffi/testsuite/libffi.complex/cls_complex_double.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.complex/cls_complex_float.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.complex/cls_complex_longdouble.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.complex/cls_complex_struct.inc".freeze, "ext/ffi_c/libffi/testsuite/libffi.complex/cls_complex_struct_double.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.complex/cls_complex_struct_float.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.complex/cls_complex_struct_longdouble.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.complex/cls_complex_va.inc".freeze, "ext/ffi_c/libffi/testsuite/libffi.complex/cls_complex_va_double.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.complex/cls_complex_va_float.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.complex/cls_complex_va_longdouble.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.complex/complex.exp".freeze, "ext/ffi_c/libffi/testsuite/libffi.complex/complex.inc".freeze, "ext/ffi_c/libffi/testsuite/libffi.complex/complex_defs_double.inc".freeze, "ext/ffi_c/libffi/testsuite/libffi.complex/complex_defs_float.inc".freeze, "ext/ffi_c/libffi/testsuite/libffi.complex/complex_defs_longdouble.inc".freeze, "ext/ffi_c/libffi/testsuite/libffi.complex/complex_double.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.complex/complex_float.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.complex/complex_int.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.complex/complex_longdouble.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.complex/ffitest.h".freeze, "ext/ffi_c/libffi/testsuite/libffi.complex/many_complex.inc".freeze, "ext/ffi_c/libffi/testsuite/libffi.complex/many_complex_double.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.complex/many_complex_float.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.complex/many_complex_longdouble.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.complex/return_complex.inc".freeze, "ext/ffi_c/libffi/testsuite/libffi.complex/return_complex1.inc".freeze, "ext/ffi_c/libffi/testsuite/libffi.complex/return_complex1_double.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.complex/return_complex1_float.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.complex/return_complex1_longdouble.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.complex/return_complex2.inc".freeze, "ext/ffi_c/libffi/testsuite/libffi.complex/return_complex2_double.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.complex/return_complex2_float.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.complex/return_complex2_longdouble.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.complex/return_complex_double.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.complex/return_complex_float.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.complex/return_complex_longdouble.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.go/aa-direct.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.go/closure1.c".freeze, "ext/ffi_c/libffi/testsuite/libffi.go/ffitest.h".freeze, "ext/ffi_c/libffi/testsuite/libffi.go/go.exp".freeze, "ext/ffi_c/libffi/testsuite/libffi.go/static-chain.h".freeze, "ext/ffi_c/rbffi.h".freeze, "ext/ffi_c/rbffi_endian.h".freeze, "ext/ffi_c/win32/stdbool.h".freeze, "ext/ffi_c/win32/stdint.h".freeze, "ffi.gemspec".freeze, "lib/ffi.rb".freeze, "lib/ffi/autopointer.rb".freeze, "lib/ffi/buffer.rb".freeze, "lib/ffi/callback.rb".freeze, "lib/ffi/enum.rb".freeze, "lib/ffi/errno.rb".freeze, "lib/ffi/ffi.rb".freeze, "lib/ffi/io.rb".freeze, "lib/ffi/library.rb".freeze, "lib/ffi/managedstruct.rb".freeze, "lib/ffi/memorypointer.rb".freeze, "lib/ffi/platform.rb".freeze, "lib/ffi/platform/aarch64-freebsd/types.conf".freeze, "lib/ffi/platform/aarch64-freebsd12/types.conf".freeze, "lib/ffi/platform/aarch64-linux/types.conf".freeze, "lib/ffi/platform/loongarch64-linux/types.conf".freeze, "lib/ffi/platform/arm-freebsd/types.conf".freeze, "lib/ffi/platform/arm-freebsd12/types.conf".freeze, "lib/ffi/platform/arm-linux/types.conf".freeze, "lib/ffi/platform/i386-cygwin/types.conf".freeze, "lib/ffi/platform/i386-darwin/types.conf".freeze, "lib/ffi/platform/i386-freebsd/types.conf".freeze, "lib/ffi/platform/i386-freebsd12/types.conf".freeze, "lib/ffi/platform/i386-gnu/types.conf".freeze, "lib/ffi/platform/i386-linux/types.conf".freeze, "lib/ffi/platform/i386-netbsd/types.conf".freeze, "lib/ffi/platform/i386-openbsd/types.conf".freeze, "lib/ffi/platform/i386-solaris/types.conf".freeze, "lib/ffi/platform/i386-windows/types.conf".freeze, "lib/ffi/platform/ia64-linux/types.conf".freeze, "lib/ffi/platform/mips-linux/types.conf".freeze, "lib/ffi/platform/mips64-linux/types.conf".freeze, "lib/ffi/platform/mips64el-linux/types.conf".freeze, "lib/ffi/platform/mipsel-linux/types.conf".freeze, "lib/ffi/platform/mipsisa32r6-linux/types.conf".freeze, "lib/ffi/platform/mipsisa32r6el-linux/types.conf".freeze, "lib/ffi/platform/mipsisa64r6-linux/types.conf".freeze, "lib/ffi/platform/mipsisa64r6el-linux/types.conf".freeze, "lib/ffi/platform/powerpc-aix/types.conf".freeze, "lib/ffi/platform/powerpc-darwin/types.conf".freeze, "lib/ffi/platform/powerpc-linux/types.conf".freeze, "lib/ffi/platform/powerpc64-linux/types.conf".freeze, "lib/ffi/platform/s390-linux/types.conf".freeze, "lib/ffi/platform/s390x-linux/types.conf".freeze, "lib/ffi/platform/sparc-linux/types.conf".freeze, "lib/ffi/platform/sparc-solaris/types.conf".freeze, "lib/ffi/platform/sparc64-linux/types.conf".freeze, "lib/ffi/platform/sparcv9-solaris/types.conf".freeze, "lib/ffi/platform/x86_64-cygwin/types.conf".freeze, "lib/ffi/platform/x86_64-darwin/types.conf".freeze, "lib/ffi/platform/x86_64-freebsd/types.conf".freeze, "lib/ffi/platform/x86_64-freebsd12/types.conf".freeze, "lib/ffi/platform/x86_64-linux/types.conf".freeze, "lib/ffi/platform/x86_64-netbsd/types.conf".freeze, "lib/ffi/platform/x86_64-openbsd/types.conf".freeze, "lib/ffi/platform/x86_64-solaris/types.conf".freeze, "lib/ffi/platform/x86_64-windows/types.conf".freeze, "lib/ffi/pointer.rb".freeze, "lib/ffi/struct.rb".freeze, "lib/ffi/struct_layout_builder.rb".freeze, "lib/ffi/tools/const_generator.rb".freeze, "lib/ffi/tools/generator.rb".freeze, "lib/ffi/tools/generator_task.rb".freeze, "lib/ffi/tools/struct_generator.rb".freeze, "lib/ffi/tools/types_generator.rb".freeze, "lib/ffi/types.rb".freeze, "lib/ffi/union.rb".freeze, "lib/ffi/variadic.rb".freeze, "lib/ffi/version.rb".freeze, "samples/getlogin.rb".freeze, "samples/getpid.rb".freeze, "samples/gettimeofday.rb".freeze, "samples/hello.rb".freeze, "samples/inotify.rb".freeze, "samples/pty.rb".freeze, "samples/qsort.rb".freeze, "samples/sample_helper.rb".freeze]
+  s.homepage = "http://wiki.github.com/ffi/ffi".freeze
+  s.licenses = ["BSD-3-Clause".freeze]
+  s.rdoc_options = ["--exclude=ext/ffi_c/.*\\.o$".freeze, "--exclude=ffi_c\\.(bundle|so)$".freeze]
+  s.required_ruby_version = Gem::Requirement.new(">= 1.9".freeze)
+  s.rubygems_version = "3.1.6".freeze
+  s.summary = "Ruby FFI".freeze
 
-  # Add libffi git files
-  lfs = `git --git-dir ext/ffi_c/libffi/.git ls-files -z`.split("\x0")
-  # Add autoconf generated files of libffi
-  lfs += %w[ configure config.guess config.sub install-sh ltmain.sh missing fficonfig.h.in ]
-  # Add automake generated files of libffi
-  lfs += `git --git-dir ext/ffi_c/libffi/.git ls-files -z *.am */*.am`.gsub(".am\0", ".in\0").split("\x0")
-  s.files += lfs.map do |f|
-    File.join("ext/ffi_c/libffi", f)
+  if s.respond_to? :specification_version then
+    s.specification_version = 4
   end
 
-  s.extensions << 'ext/ffi_c/extconf.rb'
-  s.has_rdoc = false
-  s.rdoc_options = %w[--exclude=ext/ffi_c/.*\.o$ --exclude=ffi_c\.(bundle|so)$]
-  s.license = 'BSD-3-Clause'
-  s.require_paths << 'ext/ffi_c'
-  s.required_ruby_version = '>= 1.9'
-  s.add_development_dependency 'rake', '~> 10.1'
-  s.add_development_dependency 'rake-compiler', '~> 1.0'
-  s.add_development_dependency 'rake-compiler-dock', '~> 0.6.2'
-  s.add_development_dependency 'rspec', '~> 2.14.1'
-  s.add_development_dependency 'rubygems-tasks', "~> 0.2.4"
+  if s.respond_to? :add_runtime_dependency then
+    s.add_development_dependency(%q<rake>.freeze, ["~> 10.1"])
+    s.add_development_dependency(%q<rake-compiler>.freeze, ["~> 1.0"])
+    s.add_development_dependency(%q<rake-compiler-dock>.freeze, ["~> 0.6.2"])
+    s.add_development_dependency(%q<rspec>.freeze, ["~> 2.14.1"])
+    s.add_development_dependency(%q<rubygems-tasks>.freeze, ["~> 0.2.4"])
+  else
+    s.add_dependency(%q<rake>.freeze, ["~> 10.1"])
+    s.add_dependency(%q<rake-compiler>.freeze, ["~> 1.0"])
+    s.add_dependency(%q<rake-compiler-dock>.freeze, ["~> 0.6.2"])
+    s.add_dependency(%q<rspec>.freeze, ["~> 2.14.1"])
+    s.add_dependency(%q<rubygems-tasks>.freeze, ["~> 0.2.4"])
+  end
 end
+
diff --git a/lib/ffi/platform/loongarch64-linux/types.conf b/lib/ffi/platform/loongarch64-linux/types.conf
new file mode 100644
index 0000000..aa8716d
--- /dev/null
+++ b/lib/ffi/platform/loongarch64-linux/types.conf
@@ -0,0 +1,141 @@
+rbx.platform.typedef.*__caddr_t = char
+rbx.platform.typedef.__blkcnt64_t = long
+rbx.platform.typedef.__blkcnt_t = long
+rbx.platform.typedef.__blksize_t = int
+rbx.platform.typedef.__clock_t = long
+rbx.platform.typedef.__clockid_t = int
+rbx.platform.typedef.__daddr_t = int
+rbx.platform.typedef.__dev_t = ulong
+rbx.platform.typedef.__fd_mask = long
+rbx.platform.typedef.__fsblkcnt64_t = ulong
+rbx.platform.typedef.__fsblkcnt_t = ulong
+rbx.platform.typedef.__fsfilcnt64_t = ulong
+rbx.platform.typedef.__fsfilcnt_t = ulong
+rbx.platform.typedef.__fsword_t = long
+rbx.platform.typedef.__gid_t = uint
+rbx.platform.typedef.__id_t = uint
+rbx.platform.typedef.__ino64_t = ulong
+rbx.platform.typedef.__ino_t = ulong
+rbx.platform.typedef.__int16_t = short
+rbx.platform.typedef.__int32_t = int
+rbx.platform.typedef.__int64_t = long
+rbx.platform.typedef.__int8_t = char
+rbx.platform.typedef.__int_least16_t = short
+rbx.platform.typedef.__int_least32_t = int
+rbx.platform.typedef.__int_least64_t = long
+rbx.platform.typedef.__int_least8_t = char
+rbx.platform.typedef.__intmax_t = long
+rbx.platform.typedef.__intptr_t = long
+rbx.platform.typedef.__key_t = int
+rbx.platform.typedef.__loff_t = long
+rbx.platform.typedef.__mode_t = uint
+rbx.platform.typedef.__nlink_t = uint
+rbx.platform.typedef.__off64_t = long
+rbx.platform.typedef.__off_t = long
+rbx.platform.typedef.__pid_t = int
+rbx.platform.typedef.__priority_which_t = int
+rbx.platform.typedef.__quad_t = long
+rbx.platform.typedef.__rlim64_t = ulong
+rbx.platform.typedef.__rlim_t = ulong
+rbx.platform.typedef.__rlimit_resource_t = int
+rbx.platform.typedef.__rusage_who_t = int
+rbx.platform.typedef.__sig_atomic_t = int
+rbx.platform.typedef.__socklen_t = uint
+rbx.platform.typedef.__ssize_t = long
+rbx.platform.typedef.__suseconds_t = long
+rbx.platform.typedef.__syscall_slong_t = long
+rbx.platform.typedef.__syscall_ulong_t = ulong
+rbx.platform.typedef.__time_t = long
+rbx.platform.typedef.__timer_t = pointer
+rbx.platform.typedef.__u_char = uchar
+rbx.platform.typedef.__u_int = uint
+rbx.platform.typedef.__u_long = ulong
+rbx.platform.typedef.__u_quad_t = ulong
+rbx.platform.typedef.__u_short = ushort
+rbx.platform.typedef.__uid_t = uint
+rbx.platform.typedef.__uint16_t = ushort
+rbx.platform.typedef.__uint32_t = uint
+rbx.platform.typedef.__uint64_t = ulong
+rbx.platform.typedef.__uint8_t = uchar
+rbx.platform.typedef.__uint_least16_t = ushort
+rbx.platform.typedef.__uint_least32_t = uint
+rbx.platform.typedef.__uint_least64_t = ulong
+rbx.platform.typedef.__uint_least8_t = uchar
+rbx.platform.typedef.__uintmax_t = ulong
+rbx.platform.typedef.__useconds_t = uint
+rbx.platform.typedef.blkcnt_t = long
+rbx.platform.typedef.blksize_t = int
+rbx.platform.typedef.clock_t = long
+rbx.platform.typedef.clockid_t = int
+rbx.platform.typedef.daddr_t = int
+rbx.platform.typedef.dev_t = ulong
+rbx.platform.typedef.fd_mask = long
+rbx.platform.typedef.fsblkcnt_t = ulong
+rbx.platform.typedef.fsfilcnt_t = ulong
+rbx.platform.typedef.gid_t = uint
+rbx.platform.typedef.id_t = uint
+rbx.platform.typedef.in_addr_t = uint
+rbx.platform.typedef.in_port_t = ushort
+rbx.platform.typedef.ino_t = ulong
+rbx.platform.typedef.int16_t = short
+rbx.platform.typedef.int32_t = int
+rbx.platform.typedef.int64_t = long
+rbx.platform.typedef.int8_t = char
+rbx.platform.typedef.int_fast16_t = long
+rbx.platform.typedef.int_fast32_t = long
+rbx.platform.typedef.int_fast64_t = long
+rbx.platform.typedef.int_fast8_t = char
+rbx.platform.typedef.int_least16_t = short
+rbx.platform.typedef.int_least32_t = int
+rbx.platform.typedef.int_least64_t = long
+rbx.platform.typedef.int_least8_t = char
+rbx.platform.typedef.intmax_t = long
+rbx.platform.typedef.intptr_t = long
+rbx.platform.typedef.key_t = int
+rbx.platform.typedef.loff_t = long
+rbx.platform.typedef.mode_t = uint
+rbx.platform.typedef.nlink_t = uint
+rbx.platform.typedef.off_t = long
+rbx.platform.typedef.pid_t = int
+rbx.platform.typedef.pthread_key_t = uint
+rbx.platform.typedef.pthread_once_t = int
+rbx.platform.typedef.pthread_t = ulong
+rbx.platform.typedef.ptrdiff_t = long
+rbx.platform.typedef.quad_t = long
+rbx.platform.typedef.register_t = long
+rbx.platform.typedef.rlim_t = ulong
+rbx.platform.typedef.sa_family_t = ushort
+rbx.platform.typedef.size_t = ulong
+rbx.platform.typedef.socklen_t = uint
+rbx.platform.typedef.ssize_t = long
+rbx.platform.typedef.suseconds_t = long
+rbx.platform.typedef.time_t = long
+rbx.platform.typedef.timer_t = pointer
+rbx.platform.typedef.u_char = uchar
+rbx.platform.typedef.u_int = uint
+rbx.platform.typedef.u_int16_t = ushort
+rbx.platform.typedef.u_int32_t = uint
+rbx.platform.typedef.u_int64_t = ulong_long
+rbx.platform.typedef.u_int8_t = uchar
+rbx.platform.typedef.u_long = ulong
+rbx.platform.typedef.u_quad_t = ulong
+rbx.platform.typedef.u_short = ushort
+rbx.platform.typedef.uid_t = uint
+rbx.platform.typedef.uint = uint
+rbx.platform.typedef.uint16_t = ushort
+rbx.platform.typedef.uint32_t = uint
+rbx.platform.typedef.uint64_t = ulong
+rbx.platform.typedef.uint8_t = uchar
+rbx.platform.typedef.uint_fast16_t = ulong
+rbx.platform.typedef.uint_fast32_t = ulong
+rbx.platform.typedef.uint_fast64_t = ulong
+rbx.platform.typedef.uint_fast8_t = uchar
+rbx.platform.typedef.uint_least16_t = ushort
+rbx.platform.typedef.uint_least32_t = uint
+rbx.platform.typedef.uint_least64_t = ulong
+rbx.platform.typedef.uint_least8_t = uchar
+rbx.platform.typedef.uintmax_t = ulong
+rbx.platform.typedef.uintptr_t = ulong
+rbx.platform.typedef.ulong = ulong
+rbx.platform.typedef.ushort = ushort
+rbx.platform.typedef.wchar_t = int
-- 
2.33.0

