--- ./testsuite/libffi.call/ffitest.h	Sun Jul 14 03:03:59 2019
+++ ./testsuite/libffi.call/ffitest.h	Sun Jul 14 23:01:21 2019
@@ -6,7 +6,9 @@
 #include "fficonfig.h"
 
 #if defined HAVE_STDINT_H
-#include <stdint.h>
+# if !(defined(__cplusplus) && defined(__sgi) && !defined(__GNUC__) )
+#  include <stdint.h>
+# endif
 #endif
 
 #if defined HAVE_INTTYPES_H
@@ -109,6 +111,7 @@
 #endif
 /* This doesn't match <inttypes.h>, which has "u" here, but the arguments
    are uintptr_t, which is always unsigned long.  */
+#undef PRIuPTR
 #define PRIuPTR "lu"
 #endif
 
--- ./testsuite/libffi.call/cls_ulong_va.c	Thu Jul 18 01:54:09 2019
+++ ./testsuite/libffi.call/cls_ulong_va.c	Thu Jul 18 01:56:15 2019
@@ -13,9 +13,9 @@
 static void cls_ret_T_fn(ffi_cif* cif __UNUSED__, void* resp, void** args,
 			 void* userdata __UNUSED__)
  {
-   *(T *)resp = *(T *)args[0];
+   *(ffi_arg *)resp = *(T *)args[0];
 
-   printf("%ld: %ld %ld\n", *(T *)resp, *(T *)args[0], *(T *)args[1]);
+   printf("%ld: %ld %ld\n", (long)*(ffi_arg *)resp, *(T *)args[0], *(T *)args[1]);
  }
 
 typedef T (*cls_ret_T)(T, ...);
--- include/ffi.h.in.orig	Sat Nov  8 13:47:24 2014
+++ include/ffi.h.in	Sat Jul 20 23:18:59 2019
@@ -103,6 +103,11 @@
 #   undef  FFI_64_BIT_MAX
 #   define FFI_64_BIT_MAX 9223372036854775807LL
 #  endif
+#  ifdef  __sgi /* IRIX has LONGLONG_MAX */
+#   define FFI_LONG_LONG_MAX LONGLONG_MAX
+#   undef  FFI_64_BIT_MAX
+#   define FFI_64_BIT_MAX 9223372036854775807LL
+#  endif
 # endif
 #endif
 
@@ -311,6 +316,9 @@
 #ifdef _MSC_VER
 __declspec(align(8))
 #endif
+# ifdef __sgi
+#  pragma pack (8)
+# endif
 typedef struct {
 #if @FFI_EXEC_TRAMPOLINE_TABLE@
   void *trampoline_table;
@@ -326,7 +334,7 @@
 #else
 } ffi_closure;
 # ifdef __sgi
-#  pragma pack 0
+#  pragma pack (0)
 # endif
 #endif
 
@@ -347,7 +355,7 @@
 		      void*codeloc);
 
 #ifdef __sgi
-# pragma pack 8
+# pragma pack (8)
 #endif
 typedef struct {
 #if @FFI_EXEC_TRAMPOLINE_TABLE@
@@ -373,6 +381,9 @@
   void      *user_data;
 
 } ffi_raw_closure;
+# ifdef __sgi
+#  pragma pack (0)
+# endif
 
 typedef struct {
 #if @FFI_EXEC_TRAMPOLINE_TABLE@
--- include/Makefile.in	Mon Aug 12 00:31:17 2019
+++ include/Makefile.in	Mon Aug 12 00:33:46 2019
@@ -149,7 +149,7 @@
     || { echo " ( cd '$$dir' && rm -f" $$files ")"; \
          $(am__cd) "$$dir" && rm -f $$files; }; \
   }
-am__installdirs = "$(DESTDIR)$(includesdir)"
+am__installdirs = "$(DESTDIR)$(includedir)"
 HEADERS = $(nodist_includes_HEADERS)
 am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
 # Read a list of newline-separated strings from the standard input,
@@ -359,10 +359,10 @@
 	-rm -rf .libs _libs
 install-nodist_includesHEADERS: $(nodist_includes_HEADERS)
 	@$(NORMAL_INSTALL)
-	@list='$(nodist_includes_HEADERS)'; test -n "$(includesdir)" || list=; \
+	@list='$(nodist_includes_HEADERS)'; test -n "$(includedir)" || list=; \
 	if test -n "$$list"; then \
-	  echo " $(MKDIR_P) '$(DESTDIR)$(includesdir)'"; \
-	  $(MKDIR_P) "$(DESTDIR)$(includesdir)" || exit 1; \
+	  echo " $(MKDIR_P) '$(DESTDIR)$(includedir)'"; \
+	  $(MKDIR_P) "$(DESTDIR)$(includedir)" || exit 1; \
 	fi; \
 	for p in $$list; do \
 	  if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
@@ -369,15 +369,15 @@
 	  echo "$$d$$p"; \
 	done | $(am__base_list) | \
 	while read files; do \
-	  echo " $(INSTALL_HEADER) $$files '$(DESTDIR)$(includesdir)'"; \
-	  $(INSTALL_HEADER) $$files "$(DESTDIR)$(includesdir)" || exit $$?; \
+	  echo " $(INSTALL_HEADER) $$files '$(DESTDIR)$(includedir)'"; \
+	  $(INSTALL_HEADER) $$files "$(DESTDIR)$(includedir)" || exit $$?; \
 	done
 
 uninstall-nodist_includesHEADERS:
 	@$(NORMAL_UNINSTALL)
-	@list='$(nodist_includes_HEADERS)'; test -n "$(includesdir)" || list=; \
+	@list='$(nodist_includes_HEADERS)'; test -n "$(includedir)" || list=; \
 	files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
-	dir='$(DESTDIR)$(includesdir)'; $(am__uninstall_files_from_dir)
+	dir='$(DESTDIR)$(includedir)'; $(am__uninstall_files_from_dir)
 
 ID: $(am__tagged_files)
 	$(am__define_uniq_tagged_files); mkid -fID $$unique
@@ -465,7 +465,7 @@
 check: check-am
 all-am: Makefile $(HEADERS)
 installdirs:
-	for dir in "$(DESTDIR)$(includesdir)"; do \
+	for dir in "$(DESTDIR)$(includedir)"; do \
 	  test -z "$$dir" || $(MKDIR_P) "$$dir"; \
 	done
 install: install-am
