diff options
author | Mark H Weaver <mhw@netris.org> | 2013-02-02 04:04:49 -0500 |
---|---|---|
committer | Mark H Weaver <mhw@netris.org> | 2013-02-02 04:13:44 -0500 |
commit | 3a3bea729fa25d1351d070160a65db5e9445ebc1 (patch) | |
tree | 80ef2dd591713a94cd5f594323087e2ab75d75c5 | |
parent | 7facc08a80149bae4f973c07b30b56e3ae945be7 (diff) |
Add foreign types: ssize_t and ptrdiff_t.
* libguile/foreign.c (sym_ssize_t, sym_ptrdiff_t): New symbols.
(scm_init_foreign): Add bindings for ssize_t and ptrdiff_t.
* module/system/foreign.scm: Export ssize_t and ptrdiff_t.
* doc/ref/api-foreign.texi (Foreign Types): Add docs.
-rw-r--r-- | doc/ref/api-foreign.texi | 2 | ||||
-rw-r--r-- | libguile/foreign.c | 24 | ||||
-rw-r--r-- | module/system/foreign.scm | 4 |
3 files changed, 27 insertions, 3 deletions
diff --git a/doc/ref/api-foreign.texi b/doc/ref/api-foreign.texi index f8ed4ccd7..2473870d3 100644 --- a/doc/ref/api-foreign.texi +++ b/doc/ref/api-foreign.texi @@ -489,6 +489,8 @@ platform-dependent size: @defvrx {Scheme Variable} long @defvrx {Scheme Variable} unsigned-long @defvrx {Scheme Variable} size_t +@defvrx {Scheme Variable} ssize_t +@defvrx {Scheme Variable} ptrdiff_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 320e20d8b..f5819c455 100644 --- a/libguile/foreign.c +++ b/libguile/foreign.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2010, 2011, 2012 Free Software Foundation, Inc. +/* Copyright (C) 2010, 2011, 2012, 2013 Free Software Foundation, Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License @@ -53,6 +53,8 @@ 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"); +SCM_SYMBOL (sym_ptrdiff_t, "ptrdiff_t"); /* that's for pointers, you know. */ SCM_SYMBOL (sym_asterisk, "*"); @@ -1284,6 +1286,26 @@ scm_init_foreign (void) #endif ); + scm_define (sym_ssize_t, +#if SIZEOF_SIZE_T == 8 + scm_from_uint8 (SCM_FOREIGN_TYPE_INT64) +#elif SIZEOF_SIZE_T == 4 + scm_from_uint8 (SCM_FOREIGN_TYPE_INT32) +#else +# error unsupported sizeof (ssize_t) +#endif + ); + + scm_define (sym_ptrdiff_t, +#if SCM_SIZEOF_SCM_T_PTRDIFF == 8 + scm_from_uint8 (SCM_FOREIGN_TYPE_INT64) +#elif SCM_SIZEOF_SCM_T_PTRDIFF == 4 + scm_from_uint8 (SCM_FOREIGN_TYPE_INT32) +#else +# error unsupported sizeof (scm_t_ptrdiff) +#endif + ); + null_pointer = scm_cell (scm_tc7_pointer, 0); scm_define (sym_null, null_pointer); } diff --git a/module/system/foreign.scm b/module/system/foreign.scm index 37f9b41ac..e4db6ffb3 100644 --- a/module/system/foreign.scm +++ b/module/system/foreign.scm @@ -1,4 +1,4 @@ -;;;; Copyright (C) 2010, 2011 Free Software Foundation, Inc. +;;;; Copyright (C) 2010, 2011, 2013 Free Software Foundation, Inc. ;;;; ;;;; This library is free software; you can redistribute it and/or ;;;; modify it under the terms of the GNU Lesser General Public @@ -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 ptrdiff_t int8 uint8 uint16 int16 uint32 int32 |