Subject: [patch] add intptr uintptr to (system foreign)
From: Matt Wette <[email-masked]>
To: [email-masked]
Date: Tue, 4 Jul 2017 16:38:37 -0700
List-Id: <debbugs-submit.debbugs.gnu.org>

I submit this patch for adding intptr and uintptr to (system foreign).
This is with reference to guile-2.2.2 and changes libguile/foreign.c and module/system/foreign.scm.
After application, I was albe to get guile-2.2.2 to complete “make” and “make check”. 
No specific tests for this patch have been performed.

Rationale: I am working on a FFI helper which uses scheme-bytestructure (see GitHub.com) and that package includes these types.

Matt

--- libguile/foreign.c-orig	2017-07-04 15:57:55.000000000 -0700
+++ libguile/foreign.c	2017-07-04 16:02:45.000000000 -0700
@@ -56,6 +56,8 @@
 SCM_SYMBOL (sym_size_t, "size_t");
 SCM_SYMBOL (sym_ssize_t, "ssize_t");
 SCM_SYMBOL (sym_ptrdiff_t, "ptrdiff_t");
+SCM_SYMBOL (sym_intptr_t, "intptr_t");
+SCM_SYMBOL (sym_uintptr_t, "uintptr_t");
 
 /* that's for pointers, you know. */
 SCM_SYMBOL (sym_asterisk, "*");
@@ -1248,6 +1250,26 @@
 #endif
 	      );
 
+  scm_define (sym_intptr_t,
+#if SCM_SIZEOF_INTPTR_T == 8
+	      scm_from_uint8 (SCM_FOREIGN_TYPE_INT64)
+#elif SCM_SIZEOF_INTPTR_T == 4
+	      scm_from_uint8 (SCM_FOREIGN_TYPE_INT32)
+#else
+# error unsupported sizeof (scm_t_intptr)
+#endif
+	      );
+
+  scm_define (sym_uintptr_t,
+#if SCM_SIZEOF_UINTPTR_T == 8
+	      scm_from_uint8 (SCM_FOREIGN_TYPE_UINT64)
+#elif SCM_SIZEOF_UINTPTR_T == 4
+	      scm_from_uint8 (SCM_FOREIGN_TYPE_UINT32)
+#else
+# error unsupported sizeof (scm_t_uintptr)
+#endif
+	      );
+
   null_pointer = scm_cell (scm_tc7_pointer, 0);
   scm_define (sym_null, null_pointer);
 }
--- module/system/foreign.scm-orig	2017-07-04 16:06:15.000000000 -0700
+++ module/system/foreign.scm	2017-07-04 16:06:51.000000000 -0700
@@ -30,6 +30,7 @@
             uint16 int16
             uint32 int32
             uint64 int64
+            intptr uintptr
 
             sizeof alignof