guile-commits
[Top][All Lists]
Advanced

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

[Guile-commits] GNU Guile branch, master, updated. release_1-9-8-114-g54


From: Ludovic Courtès
Subject: [Guile-commits] GNU Guile branch, master, updated. release_1-9-8-114-g54eb59c
Date: Wed, 17 Mar 2010 23:42:36 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU Guile".

http://git.savannah.gnu.org/cgit/guile.git/commit/?id=54eb59cf4948482461e41f73c0a5b1f9c7081326

The branch, master has been updated
       via  54eb59cf4948482461e41f73c0a5b1f9c7081326 (commit)
      from  5595bd76414e50834b293ead7fd67a54fe56c563 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 54eb59cf4948482461e41f73c0a5b1f9c7081326
Author: Ludovic Courtès <address@hidden>
Date:   Thu Mar 18 00:27:38 2010 +0100

    Add `%null-pointer' to `(system foreign)'.
    
    * libguile/foreign.c (sym_null, null_pointer): New variables.
      (scm_foreign_to_bytevector): Raise an error when PTR is NULL.
      (scm_init_foreign): Define SYM_NULL.
    
    * module/system/foreign.scm (%null-pointer): New exported binding.

-----------------------------------------------------------------------

Summary of changes:
 libguile/foreign.c        |   15 ++++++++++++++-
 module/system/foreign.scm |    1 +
 2 files changed, 15 insertions(+), 1 deletions(-)

diff --git a/libguile/foreign.c b/libguile/foreign.c
index b462ee9..52ed10c 100644
--- a/libguile/foreign.c
+++ b/libguile/foreign.c
@@ -51,6 +51,14 @@ SCM_SYMBOL (sym_size_t, "size_t");
 /* that's for pointers, you know. */
 SCM_SYMBOL (sym_asterisk, "*");
 
+SCM_SYMBOL (sym_null, "%null-pointer");
+
+/* The cell representing the null pointer.  */
+static const scm_t_bits null_pointer[2] =
+  {
+    scm_tc7_foreign | (SCM_FOREIGN_TYPE_VOID << 8UL),
+    0
+  };
 
 static SCM cif_to_procedure (SCM cif, SCM func_ptr);
 
@@ -231,7 +239,10 @@ SCM_DEFINE (scm_foreign_to_bytevector, 
"foreign->bytevector", 1, 3, 0,
 
   SCM_VALIDATE_FOREIGN_TYPED (1, foreign, VOID);
   ptr = SCM_FOREIGN_POINTER (foreign, scm_t_int8);
-  
+
+  if (SCM_UNLIKELY (ptr == NULL))
+    scm_misc_error (FUNC_NAME, "null pointer dereference", SCM_EOL);
+
   if (SCM_UNBNDP (uvec_type))
     btype = SCM_ARRAY_ELEMENT_TYPE_VU8;
   else
@@ -1039,6 +1050,8 @@ scm_init_foreign (void)
 # error unsupported sizeof (size_t)
 #endif
              );
+
+  scm_define (sym_null, PTR2SCM (&null_pointer));
 }
 
 void
diff --git a/module/system/foreign.scm b/module/system/foreign.scm
index 7966dd9..9f389f2 100644
--- a/module/system/foreign.scm
+++ b/module/system/foreign.scm
@@ -25,6 +25,7 @@
             uint16 int16
             uint32 int32
             uint64 int64
+            %null-pointer
 
             sizeof alignof
 


hooks/post-receive
-- 
GNU Guile




reply via email to

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