[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Guile-commits] 06/07: foreign: Add 'uintptr_t' and 'intptr_t'.
From: |
Ludovic Courtès |
Subject: |
[Guile-commits] 06/07: foreign: Add 'uintptr_t' and 'intptr_t'. |
Date: |
Wed, 22 Nov 2017 10:47:18 -0500 (EST) |
civodul pushed a commit to branch stable-2.2
in repository guile.
commit bb5d316b161add31612e6afe41e5a6ea5851c277
Author: Matt Wette <address@hidden>
Date: Wed Nov 22 16:32:39 2017 +0100
foreign: Add 'uintptr_t' and 'intptr_t'.
* libguile/foreign.c (scm_uintptr_t, scm_intptr_t): New variables.
(scm_init_foreign): Define them.
* module/system/foreign.scm: Export 'intptr_t' and 'uintptr_t'.
* doc/ref/api-foreign.texi (Foreign Types): Document them.
Co-authored-by: Ludovic Courtès <address@hidden>
---
doc/ref/api-foreign.texi | 2 ++
libguile/foreign.c | 22 ++++++++++++++++++++++
module/system/foreign.scm | 1 +
3 files changed, 25 insertions(+)
diff --git a/doc/ref/api-foreign.texi b/doc/ref/api-foreign.texi
index bb93d6d..d99a333 100644
--- a/doc/ref/api-foreign.texi
+++ b/doc/ref/api-foreign.texi
@@ -498,6 +498,8 @@ platform-dependent size:
@defvrx {Scheme Variable} size_t
@defvrx {Scheme Variable} ssize_t
@defvrx {Scheme Variable} ptrdiff_t
address@hidden {Scheme Variable} intptr_t
address@hidden {Scheme Variable} uintptr_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 17af101..927c46f 100644
--- a/libguile/foreign.c
+++ b/libguile/foreign.c
@@ -56,6 +56,8 @@ 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");
+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 @@ scm_init_foreign (void)
#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);
}
diff --git a/module/system/foreign.scm b/module/system/foreign.scm
index 3304eb0..d1c2ceb 100644
--- a/module/system/foreign.scm
+++ b/module/system/foreign.scm
@@ -30,6 +30,7 @@
uint16 int16
uint32 int32
uint64 int64
+ intptr_t uintptr_t
sizeof alignof
- [Guile-commits] branch stable-2.2 updated (2fe9a85 -> 48d4255), Ludovic Courtès, 2017/11/22
- [Guile-commits] 02/07: Convert `close' ref to xref., Ludovic Courtès, 2017/11/22
- [Guile-commits] 01/07: Honor '%fresh-auto-compile'., Ludovic Courtès, 2017/11/22
- [Guile-commits] 04/07: ia64: Fix crash in thread context switch., Ludovic Courtès, 2017/11/22
- [Guile-commits] 06/07: foreign: Add 'uintptr_t' and 'intptr_t'.,
Ludovic Courtès <=
- [Guile-commits] 05/07: scripts: help: Fix reference to the "Using Guile Tools" node., Ludovic Courtès, 2017/11/22
- [Guile-commits] 03/07: Mention (ice-9 peg) module path., Ludovic Courtès, 2017/11/22
- [Guile-commits] 07/07: ltdl wrappers now use a recursive mutex., Ludovic Courtès, 2017/11/22