summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2010-03-17 00:45:57 +0100
committerLudovic Courtès <ludo@gnu.org>2010-03-17 00:54:01 +0100
commitdd1464bf38c5e2dc71652b62f63e4bcf93179a14 (patch)
tree34622829defb07702cfc99836707b86065e94f43
parent3023e7b0c90081f0060cb78a4a534ed7cd77c9bf (diff)
downloadguile-dd1464bf38c5e2dc71652b62f63e4bcf93179a14.tar.gz
Provide `int', `long', `size_t', etc. in `(system foreign)'.
* libguile/foreign.c (sym_int, sym_long, sym_unsigned_int, sym_unsigned_long, sym_size_t): New variables. (scm_init_foreign): Define them at the Scheme level. * module/system/foreign.scm (int, unsigned-int, long, unsigned-long, size_t): New exported bindings.
-rw-r--r--libguile/foreign.c55
-rw-r--r--module/system/foreign.scm1
2 files changed, 56 insertions, 0 deletions
diff --git a/libguile/foreign.c b/libguile/foreign.c
index c87c378a7..b462ee982 100644
--- a/libguile/foreign.c
+++ b/libguile/foreign.c
@@ -42,6 +42,11 @@ SCM_SYMBOL (sym_uint32, "uint32");
SCM_SYMBOL (sym_int32, "int32");
SCM_SYMBOL (sym_uint64, "uint64");
SCM_SYMBOL (sym_int64, "int64");
+SCM_SYMBOL (sym_int, "int");
+SCM_SYMBOL (sym_long, "long");
+SCM_SYMBOL (sym_unsigned_int, "unsigned-int");
+SCM_SYMBOL (sym_unsigned_long, "unsigned-long");
+SCM_SYMBOL (sym_size_t, "size_t");
/* that's for pointers, you know. */
SCM_SYMBOL (sym_asterisk, "*");
@@ -984,6 +989,56 @@ scm_init_foreign (void)
scm_define (sym_int32, scm_from_uint8 (SCM_FOREIGN_TYPE_INT32));
scm_define (sym_uint64, scm_from_uint8 (SCM_FOREIGN_TYPE_UINT64));
scm_define (sym_int64, scm_from_uint8 (SCM_FOREIGN_TYPE_INT64));
+
+ scm_define (sym_int,
+#if SIZEOF_INT == 8
+ scm_from_uint8 (SCM_FOREIGN_TYPE_INT64)
+#elif SIZEOF_INT == 4
+ scm_from_uint8 (SCM_FOREIGN_TYPE_INT32)
+#else
+# error unsupported sizeof (int)
+#endif
+ );
+
+ scm_define (sym_unsigned_int,
+#if SIZEOF_UNSIGNED_INT == 8
+ scm_from_uint8 (SCM_FOREIGN_TYPE_UINT64)
+#elif SIZEOF_UNSIGNED_INT == 4
+ scm_from_uint8 (SCM_FOREIGN_TYPE_UINT32)
+#else
+# error unsupported sizeof (unsigned int)
+#endif
+ );
+
+ scm_define (sym_long,
+#if SIZEOF_LONG == 8
+ scm_from_uint8 (SCM_FOREIGN_TYPE_INT64)
+#elif SIZEOF_LONG == 4
+ scm_from_uint8 (SCM_FOREIGN_TYPE_INT32)
+#else
+# error unsupported sizeof (long)
+#endif
+ );
+
+ scm_define (sym_unsigned_long,
+#if SIZEOF_UNSIGNED_LONG == 8
+ scm_from_uint8 (SCM_FOREIGN_TYPE_UINT64)
+#elif SIZEOF_UNSIGNED_LONG == 4
+ scm_from_uint8 (SCM_FOREIGN_TYPE_UINT32)
+#else
+# error unsupported sizeof (unsigned long)
+#endif
+ );
+
+ scm_define (sym_size_t,
+#if SIZEOF_SIZE_T == 8
+ scm_from_uint8 (SCM_FOREIGN_TYPE_UINT64)
+#elif SIZEOF_SIZE_T == 4
+ scm_from_uint8 (SCM_FOREIGN_TYPE_UINT32)
+#else
+# error unsupported sizeof (size_t)
+#endif
+ );
}
void
diff --git a/module/system/foreign.scm b/module/system/foreign.scm
index 73c11feaa..7966dd977 100644
--- a/module/system/foreign.scm
+++ b/module/system/foreign.scm
@@ -20,6 +20,7 @@
#:use-module (rnrs bytevector)
#:export (void
float double
+ int unsigned-int long unsigned-long size_t
int8 uint8
uint16 int16
uint32 int32