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: [PATCH] Verify Size of Objcode Headers Date: Sun, 20 Jun 2010 15:44:58 -0400 Message-ID: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 X-Trace: dough.gmane.org 1277063112 31604 80.91.229.12 (20 Jun 2010 19:45:12 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sun, 20 Jun 2010 19:45:12 +0000 (UTC) To: guile-devel@gnu.org Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Sun Jun 20 21:45:11 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 1OQQS1-00037I-GZ for guile-devel@m.gmane.org; Sun, 20 Jun 2010 21:45:05 +0200 Original-Received: from localhost ([127.0.0.1]:45064 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OQQS0-00075D-LC for guile-devel@m.gmane.org; Sun, 20 Jun 2010 15:45:04 -0400 Original-Received: from [140.186.70.92] (port=41162 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OQQRx-00074D-DK for guile-devel@gnu.org; Sun, 20 Jun 2010 15:45:02 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OQQRw-0007iT-8V for guile-devel@gnu.org; Sun, 20 Jun 2010 15:45:01 -0400 Original-Received: from mail-iw0-f169.google.com ([209.85.214.169]:36263) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OQQRw-0007iM-5g for guile-devel@gnu.org; Sun, 20 Jun 2010 15:45:00 -0400 Original-Received: by iwn39 with SMTP id 39so968021iwn.0 for ; Sun, 20 Jun 2010 12:44:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:sender:received:date :x-google-sender-auth:message-id:subject:from:to:content-type; bh=KeSk7S/LAvIZKqh26eUejFBr8fBAaIPZmdTWwpQpn+M=; b=AVjWfg8nRAJhy28a0GOqTEkKsQKp2pTBGdy6n2roOYM3MMk/F5vEcUenq0H1Ql+C2S j9hAcKDvyMmL+nj+ylIwaUEpiPxYBrqCHMypoSXQ88FD6rnwGEArDsJbdZ1ee5Fd6Btz wZy8uWg8uFdhJVAIsQxhDmPujiFpmI72+80kk= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:date:x-google-sender-auth:message-id:subject :from:to:content-type; b=v48rQiP3r9H2RnP2tt8a2JcsXol1aWlQ28aqlmcrOWY8XJeeibFzSprgFREX1Psiwa n8TpfASHkGZ8mbK+K/d6yO+Bi+FPfNCAnGpafXqOXo5BahmbeIIspArApd+TtNG7VS81 xPxKL58RTPeofUZJfITvSTZIdXTqld9qGouaA= Original-Received: by 10.231.169.9 with SMTP id w9mr4667262iby.58.1277063098794; Sun, 20 Jun 2010 12:44:58 -0700 (PDT) Original-Received: by 10.231.12.67 with HTTP; Sun, 20 Jun 2010 12:44:58 -0700 (PDT) X-Google-Sender-Auth: 6Rq60GfAfw19SUjh_vBpPtCuJuw 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:10522 Archived-At: 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 | 4 ++++ libguile/control.c | 3 +++ libguile/foreign.c | 3 +++ libguile/gsubr.c | 3 +++ libguile/objcodes.h | 5 +++++ libguile/smob.c | 3 +++ 6 files changed, 21 insertions(+), 0 deletions(-) diff --git a/libguile/continuations.c b/libguile/continuations.c index dc504f0..e99043f 100644 --- a/libguile/continuations.c +++ b/libguile/continuations.c @@ -37,6 +37,7 @@ #include "libguile/eval.h" #include "libguile/vm.h" #include "libguile/instructions.h" +#include "libguile/objcodes.h" #include "libguile/validate.h" #include "libguile/continuations.h" @@ -537,6 +538,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) }; + VERIFY_OBJCODE_HEADER_SIZE(dummy); + 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..91fedf1 100644 --- a/libguile/control.c +++ b/libguile/control.c @@ -271,6 +271,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) }; + VERIFY_OBJCODE_HEADER_SIZE(dummy); + #include "libguile/control.x" } diff --git a/libguile/foreign.c b/libguile/foreign.c index aae4c67..60a01a1 100644 --- a/libguile/foreign.c +++ b/libguile/foreign.c @@ -1028,6 +1028,9 @@ scm_i_foreign_call (SCM foreign, const SCM *argv) static void scm_init_foreign (void) { + scm_t_uint8 dummy[] = { OBJCODE_HEADER }; + VERIFY_OBJCODE_HEADER_SIZE(dummy); + #ifndef SCM_MAGIC_SNARFER #include "libguile/foreign.x" #endif diff --git a/libguile/gsubr.c b/libguile/gsubr.c index de4bff6..c01471c 100644 --- a/libguile/gsubr.c +++ b/libguile/gsubr.c @@ -878,6 +878,9 @@ gsubr_21l(SCM req1, SCM req2, SCM opt, SCM rst) void scm_init_gsubr() { + scm_t_uint8 dummy[] = { OBJCODE_HEADER }; + VERIFY_OBJCODE_HEADER_SIZE(dummy); + #ifdef GSUBR_TEST scm_c_define_gsubr ("gsubr-2-1-l", 2, 1, 1, gsubr_21l); /* example */ #endif diff --git a/libguile/objcodes.h b/libguile/objcodes.h index 2bff9aa..cb86e63 100644 --- a/libguile/objcodes.h +++ b/libguile/objcodes.h @@ -21,6 +21,8 @@ #include +#include /* from Gnulib, in guile/lib */ + /* Objcode data should be directly mappable to this C structure. */ struct scm_objcode { @@ -54,6 +56,9 @@ struct scm_objcode #define SCM_OBJCODE_IS_BYTEVECTOR(x) (SCM_OBJCODE_FLAGS (x) & SCM_F_OBJCODE_IS_BYTEVECTOR) #define SCM_OBJCODE_IS_SLICE(x) (SCM_OBJCODE_FLAGS (x) & SCM_F_OBJCODE_IS_SLICE) +#define VERIFY_OBJCODE_HEADER_SIZE(header) verify(sizeof(header) \ + == sizeof(struct scm_objcode)) + SCM scm_c_make_objcode_slice (SCM parent, const scm_t_uint8 *ptr); SCM_API SCM scm_load_objcode (SCM file); SCM_API SCM scm_objcode_p (SCM obj); diff --git a/libguile/smob.c b/libguile/smob.c index 171db8d..3aba9de 100644 --- a/libguile/smob.c +++ b/libguile/smob.c @@ -598,6 +598,9 @@ void scm_smob_prehistory () { long i; + scm_t_uint8 dummy[] = { OBJCODE_HEADER }; + + VERIFY_OBJCODE_HEADER_SIZE(dummy); smob_gc_kind = GC_new_kind (GC_new_free_list (), GC_MAKE_PROC (GC_new_proc (smob_mark), 0), -- 1.7.1