guile-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] add ssize_t


From: Daniel Hartwig
Subject: [PATCH] add ssize_t
Date: Sat, 2 Feb 2013 15:37:30 +0800

* libguile/gen-scmconfig.c: Determine the size of ssize_t (POSIX).

* libguile/foreign.c: New symbol is an alias for a signed integer type.

* module/system/foreign.scm: Export the new symbol.

* doc/ref/api-foreign.texi (Foreign Types): Document.
---
 doc/ref/api-foreign.texi  |    1 +
 libguile/foreign.c        |   11 +++++++++++
 libguile/gen-scmconfig.c  |    1 +
 module/system/foreign.scm |    2 +-
 4 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/doc/ref/api-foreign.texi b/doc/ref/api-foreign.texi
index f8ed4cc..f99e1cd 100644
--- a/doc/ref/api-foreign.texi
+++ b/doc/ref/api-foreign.texi
@@ -489,6 +489,7 @@ platform-dependent size:
 @defvrx {Scheme Variable} long
 @defvrx {Scheme Variable} unsigned-long
 @defvrx {Scheme Variable} size_t
address@hidden {Scheme Variable} ssize_t
 Values exported by the @code{(system foreign)} module, representing C
 numeric types. For example, @code{long} may be @code{equal?} to
 @code{int64} on a 64-bit platform.
diff --git a/libguile/foreign.c b/libguile/foreign.c
index 320e20d..dea3bc4 100644
--- a/libguile/foreign.c
+++ b/libguile/foreign.c
@@ -53,6 +53,7 @@ SCM_SYMBOL (sym_unsigned_short, "unsigned-short");
 SCM_SYMBOL (sym_unsigned_int, "unsigned-int");
 SCM_SYMBOL (sym_unsigned_long, "unsigned-long");
 SCM_SYMBOL (sym_size_t, "size_t");
+SCM_SYMBOL (sym_ssize_t, "ssize_t");
 
 /* that's for pointers, you know. */
 SCM_SYMBOL (sym_asterisk, "*");
@@ -1284,6 +1285,16 @@ scm_init_foreign (void)
 #endif
              );
 
+  scm_define (sym_ssize_t,
+#if SIZEOF_SSIZE_T == 8
+             scm_from_uint8 (SCM_FOREIGN_TYPE_INT64)
+#elif SIZEOF_SSIZE_T == 4
+             scm_from_uint8 (SCM_FOREIGN_TYPE_INT32)
+#else
+# error unsupported sizeof (ssize_t)
+#endif
+             );
+
   null_pointer = scm_cell (scm_tc7_pointer, 0);
   scm_define (sym_null, null_pointer);
 }
diff --git a/libguile/gen-scmconfig.c b/libguile/gen-scmconfig.c
index 77ab94f..5d11944 100644
--- a/libguile/gen-scmconfig.c
+++ b/libguile/gen-scmconfig.c
@@ -232,6 +232,7 @@ main (int argc, char *argv[])
   pf ("#define SCM_SIZEOF_INT %d\n", SIZEOF_INT);
   pf ("#define SCM_SIZEOF_UNSIGNED_INT %d\n", SIZEOF_UNSIGNED_INT);
   pf ("#define SCM_SIZEOF_SIZE_T %d\n", SIZEOF_SIZE_T);
+  pf ("#define SCM_SIZEOF_SSIZE_T %d\n", SIZEOF_SSIZE_T);
 
   pf ("\n");
   pf ("/* Size of (unsigned) long long or 0 if not available (scm_t_*64 may\n"
diff --git a/module/system/foreign.scm b/module/system/foreign.scm
index 37f9b41..a6cbaab 100644
--- a/module/system/foreign.scm
+++ b/module/system/foreign.scm
@@ -25,7 +25,7 @@
             float double
             short
             unsigned-short
-            int unsigned-int long unsigned-long size_t
+            int unsigned-int long unsigned-long size_t ssize_t
             int8 uint8
             uint16 int16
             uint32 int32
-- 
1.7.10.4




reply via email to

[Prev in Thread] Current Thread [Next in Thread]