From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Noah Lavine Newsgroups: gmane.lisp.guile.devel Subject: Re: [PATCH] Verify Size of Objcode Headers Date: Sun, 20 Jun 2010 19:59:59 -0400 Message-ID: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 (Apple Message framework v1078) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable X-Trace: dough.gmane.org 1277078422 4804 80.91.229.12 (21 Jun 2010 00:00:22 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Mon, 21 Jun 2010 00:00:22 +0000 (UTC) Cc: guile-devel@gnu.org To: ludo@gnu.org Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Mon Jun 21 02:00:20 2010 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1OQUR2-0006zv-9m for guile-devel@m.gmane.org; Mon, 21 Jun 2010 02:00:20 +0200 Original-Received: from localhost ([127.0.0.1]:59316 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OQUR1-0001fA-9V for guile-devel@m.gmane.org; Sun, 20 Jun 2010 20:00:19 -0400 Original-Received: from [140.186.70.92] (port=57895 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OQUQs-0001es-RM for guile-devel@gnu.org; Sun, 20 Jun 2010 20:00:12 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OQUQq-00084o-4A for guile-devel@gnu.org; Sun, 20 Jun 2010 20:00:09 -0400 Original-Received: from mail-iw0-f169.google.com ([209.85.214.169]:45176) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OQUQn-00083o-KA; Sun, 20 Jun 2010 20:00:05 -0400 Original-Received: by iwn39 with SMTP id 39so1112142iwn.0 for ; Sun, 20 Jun 2010 17:00:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:content-type :content-transfer-encoding:subject:date:message-id:cc:to :mime-version:x-mailer; bh=YNyEJKBd6DegIyWfRnFbt71a1M2NaujzWmJBWWj5R8s=; b=Y1d6MbekNHsQ+TXT+O10msU350j1iDIrJSDSJ0k1GIwLSf7CdPLO/sDc/mSBCZuRfy Sm3b7+pruwpNIRo1/GZzNKX7cajVfrV4xpF87YzLdQC6FjBRgvpJ3o4/Fu1IG1x4DJpO ISQDiWw0wg1NxX8hG1Q19Y6FJ/j/Ql03f5r58= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:content-type:content-transfer-encoding:subject:date:message-id :cc:to:mime-version:x-mailer; b=frI2lOlsaJH/BYGQUPyBAOwzyhcneoTnIzOovikMlm1rMwfiyoGXaPWfximgnzbO16 NPkibbc4AnHFsVzx+zptC6EAq8mUpvsxDNn9zkmV5GyRu/IqUalzfYLfjy+YIW6GqRsH sJc9le9FlNsw0M2WUgYrhrK3zfbsxdgwap5gw= Original-Received: by 10.231.14.201 with SMTP id h9mr4248006iba.129.1277078404583; Sun, 20 Jun 2010 17:00:04 -0700 (PDT) Original-Received: from dhcp-137-112-114-94.wlan.rose-hulman.edu (dhcp-137-112-114-94.wlan.rose-hulman.edu [137.112.114.94]) by mx.google.com with ESMTPS id f1sm54081705ibg.3.2010.06.20.17.00.03 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sun, 20 Jun 2010 17:00:04 -0700 (PDT) X-Mailer: Apple Mail (2.1078) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.devel:10530 Archived-At: 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" =20 #include "libguile/validate.h" #include "libguile/continuations.h" =20 +#include "verify.h" /* from Gnulib, in guile/lib */ =20 =20 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[] =3D { OBJCODE_HEADER(5,5) } SCM_UNUSED; + verify (sizeof (dummy) =3D=3D sizeof (struct scm_objcode)); + tc16_continuation =3D 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" =20 +#include "verify.h" /* from Gnulib, in guile/lib */ =20 =20 =20 @@ -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[] =3D { OBJCODE_HEADER(5,5) } SCM_UNUSED; + verify (sizeof (dummy) =3D=3D sizeof (struct scm_objcode)); + #include "libguile/control.x" } =20 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" =20 +#include "verify.h" /* from Gnulib, in guile/lib */ =20 =20 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[] =3D { OBJCODE_HEADER } SCM_UNUSED; + verify (sizeof (dummy) =3D=3D 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" =20 #include "libguile/private-options.h" + +#include "verify.h" /* from Gnulib, in guile/lib */ =20 /* * gsubr.c @@ -878,6 +880,9 @@ gsubr_21l(SCM req1, SCM req2, SCM opt, SCM rst) void scm_init_gsubr() { + scm_t_uint8 dummy[] =3D { OBJCODE_HEADER } SCM_UNUSED; + verify (sizeof (dummy) =3D=3D 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 =20 - +#include "verify.h" /* from Gnulib, in guile/lib */ =20 =20 /* scm_smobs scm_numsmob @@ -598,6 +598,9 @@ void scm_smob_prehistory () { long i; + scm_t_uint8 dummy[] =3D { OBJCODE_HEADER } SCM_UNUSED; + + verify (sizeof (dummy) =3D=3D sizeof (struct scm_objcode)); =20 smob_gc_kind =3D GC_new_kind (GC_new_free_list (), GC_MAKE_PROC (GC_new_proc (smob_mark), 0), --=20 1.7.1