unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: Noah Lavine <noah549@gmail.com>
To: ludo@gnu.org
Cc: guile-devel@gnu.org
Subject: Re: [PATCH] Verify Size of Objcode Headers
Date: Sun, 20 Jun 2010 19:59:59 -0400	[thread overview]
Message-ID: <C2F5CF6E-2013-4A9C-9BFC-0523D4CB4CD3@gmail.com> (raw)

Thanks for the corrections. I think this patch addresses them.

Noah

Add static checks to make sure that the statically-generated object code
headers in continuations.c, control.c, foreign.c, gsubr.c and smob.c are the
same length as the struct scm_objcode data type in objcodes.h.
---
 libguile/continuations.c |    5 +++++
 libguile/control.c       |    4 ++++
 libguile/foreign.c       |    4 ++++
 libguile/gsubr.c         |    5 +++++
 libguile/smob.c          |    5 ++++-
 5 files changed, 22 insertions(+), 1 deletions(-)

diff --git a/libguile/continuations.c b/libguile/continuations.c
index dc504f0..0ded7e7 100644
--- a/libguile/continuations.c
+++ b/libguile/continuations.c
@@ -37,10 +37,12 @@
 #include "libguile/eval.h"
 #include "libguile/vm.h"
 #include "libguile/instructions.h"
+#include "libguile/objcodes.h"
 
 #include "libguile/validate.h"
 #include "libguile/continuations.h"
 
+#include "verify.h" /* from Gnulib, in guile/lib */
 

 
 static scm_t_bits tc16_continuation;
@@ -537,6 +539,9 @@ SCM_DEFINE (scm_with_continuation_barrier, "with-continuation-barrier", 1,0,0,
 void
 scm_init_continuations ()
 {
+  scm_t_uint8 dummy[] = { OBJCODE_HEADER(5,5) } SCM_UNUSED;
+  verify (sizeof (dummy) == sizeof (struct scm_objcode));
+
   tc16_continuation = scm_make_smob_type ("continuation", 0);
   scm_set_smob_print (tc16_continuation, continuation_print);
 #include "libguile/continuations.x"
diff --git a/libguile/control.c b/libguile/control.c
index 6c20675..605b2f9 100644
--- a/libguile/control.c
+++ b/libguile/control.c
@@ -26,6 +26,7 @@
 #include "libguile/instructions.h"
 #include "libguile/vm.h"
 
+#include "verify.h" /* from Gnulib, in guile/lib */
 

 
 
@@ -271,6 +272,9 @@ scm_i_prompt_print (SCM exp, SCM port, scm_print_state *pstate SCM_UNUSED)
 void
 scm_init_control (void)
 {
+  scm_t_uint8 dummy[] = { OBJCODE_HEADER(5,5) } SCM_UNUSED;
+  verify (sizeof (dummy) == sizeof (struct scm_objcode));
+
 #include "libguile/control.x"
 }
 
diff --git a/libguile/foreign.c b/libguile/foreign.c
index aae4c67..30dcf60 100644
--- a/libguile/foreign.c
+++ b/libguile/foreign.c
@@ -31,6 +31,7 @@
 #include "libguile/instructions.h"
 #include "libguile/foreign.h"
 
+#include "verify.h" /* from Gnulib, in guile/lib */
 

 
 SCM_SYMBOL (sym_void, "void");
@@ -1028,6 +1029,9 @@ scm_i_foreign_call (SCM foreign, const SCM *argv)
 static void
 scm_init_foreign (void)
 {
+  scm_t_uint8 dummy[] = { OBJCODE_HEADER } SCM_UNUSED;
+  verify (sizeof (dummy) == sizeof (struct scm_objcode));
+
 #ifndef SCM_MAGIC_SNARFER
 #include "libguile/foreign.x"
 #endif
diff --git a/libguile/gsubr.c b/libguile/gsubr.c
index de4bff6..21580b7 100644
--- a/libguile/gsubr.c
+++ b/libguile/gsubr.c
@@ -33,6 +33,8 @@
 #include "libguile/programs.h"
 
 #include "libguile/private-options.h"
+
+#include "verify.h" /* from Gnulib, in guile/lib */
 

 /*
  * gsubr.c
@@ -878,6 +880,9 @@ gsubr_21l(SCM req1, SCM req2, SCM opt, SCM rst)
 void
 scm_init_gsubr()
 {
+  scm_t_uint8 dummy[] = { OBJCODE_HEADER } SCM_UNUSED;
+  verify (sizeof (dummy) == sizeof (struct scm_objcode));
+
 #ifdef GSUBR_TEST
   scm_c_define_gsubr ("gsubr-2-1-l", 2, 1, 1, gsubr_21l); /* example */
 #endif
diff --git a/libguile/smob.c b/libguile/smob.c
index 171db8d..676c83b 100644
--- a/libguile/smob.c
+++ b/libguile/smob.c
@@ -42,7 +42,7 @@
 #include "libguile/bdw-gc.h"
 #include <gc/gc_mark.h>
 
-
+#include "verify.h" /* from Gnulib, in guile/lib */
 

 
 /* scm_smobs scm_numsmob
@@ -598,6 +598,9 @@ void
 scm_smob_prehistory ()
 {
   long i;
+  scm_t_uint8 dummy[] = { OBJCODE_HEADER } SCM_UNUSED;
+
+  verify (sizeof (dummy) == sizeof (struct scm_objcode));
 
   smob_gc_kind = GC_new_kind (GC_new_free_list (),
 			      GC_MAKE_PROC (GC_new_proc (smob_mark), 0),
-- 
1.7.1




             reply	other threads:[~2010-06-20 23:59 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-06-20 23:59 Noah Lavine [this message]
  -- strict thread matches above, loose matches on Subject: below --
2010-06-20 19:44 [PATCH] Verify Size of Objcode Headers Noah Lavine
2010-06-20 20:30 ` Andy Wingo
2010-06-20 21:22 ` Ludovic Courtès

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=C2F5CF6E-2013-4A9C-9BFC-0523D4CB4CD3@gmail.com \
    --to=noah549@gmail.com \
    --cc=guile-devel@gnu.org \
    --cc=ludo@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).