unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: ludo@gnu.org (Ludovic Courtès)
To: guile-devel@gnu.org
Subject: Re: Merging ‘bdw-gc-static-alloc’
Date: Mon, 02 Nov 2009 22:44:19 +0100	[thread overview]
Message-ID: <87hbtciouk.fsf@gnu.org> (raw)
In-Reply-To: m3bpjynu8a.fsf@pobox.com

[-- Attachment #1: Type: text/plain, Size: 592 bytes --]

Hello!

I merged that branch in ‘master’.

... and soon after I noticed this glitch with ‘SCM_DEFINE’: when
‘SCM_SUPPORT_STATIC_ALLOCATION’ is defined, it requires a previous C
declaration of the subr being defined.  For instance:

  SCM_DEFINE (foo, "foo", 1, 0, 0, (SCM x), "") { ... }

must now be preceded by:

  extern SCM foo (SCM);

This is not a problem in Guile core where we compile with
‘-Wmissing-prototypes’ and provide public declarations for all
‘SCM_DEFINE’d functions, but it may be a problem in projects that don’t.

This is easily remedied this way:


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Type: text/x-patch, Size: 624 bytes --]

--- a/libguile/snarf.h
+++ b/libguile/snarf.h
@@ -101,14 +101,15 @@ SCM_SNARF_DOCS(primitive, FNAME, PRIMNAME, ARGLIST, REQ, OPT, VAR, DOCSTRING)
 /* Static subr allocation.  */
 #define SCM_DEFINE(FNAME, PRIMNAME, REQ, OPT, VAR, ARGLIST, DOCSTRING)	\
 SCM_SYMBOL (scm_i_paste (FNAME, __name), PRIMNAME);			\
-SCM_SNARF_HERE(								\
+SCM_SNARF_HERE(							\
   static const char scm_i_paste (s_, FNAME) [] = PRIMNAME;		\
+  extern SCM FNAME ARGLIST;						\
   SCM_IMMUTABLE_SUBR (scm_i_paste (FNAME, __subr),			\
 		      scm_i_paste (FNAME, __name),			\
 		      REQ, OPT, VAR, &FNAME);				\
   SCM FNAME ARGLIST							\

[-- Attachment #3: Type: text/plain, Size: 679 bytes --]


However, there are potentially 2 problems with this:

  1. The declaration could conflict with a previous, slightly different
     one.

     Apparently, a given function declaration and the same one decorated
     with GCC function attributes are considered the same, so this
     should be OK.  However, I’m slightly concerned about MSVC’s
     __declspec: does it work if it sees:

       __declspec(dllexport) extern SCM foo (SCM);
       extern SCM foo (SCM);

     If it works, that probably means this point is moot.

  2. The automatically added ‘extern’ declaration makes
     ‘-Wmissing-prototypes’ useless, which is annoying.

Thoughts?

Thanks,
Ludo’.

  reply	other threads:[~2009-11-02 21:44 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-10-02  9:15 Merging ‘bdw-gc-static-alloc’ Ludovic Courtès
2009-10-02 16:26 ` Andy Wingo
2009-10-23  9:16   ` Ludovic Courtès
2009-10-23 12:57     ` Andy Wingo
2009-11-02 21:44       ` Ludovic Courtès [this message]
2009-11-03 20:57         ` (no subject) Neil Jerram
2009-11-05 22:30           ` Merging ‘bdw-gc-static-alloc’ Ludovic Courtès
2009-11-08 22:21             ` (no subject) Neil Jerram

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=87hbtciouk.fsf@gnu.org \
    --to=ludo@gnu.org \
    --cc=guile-devel@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).