all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Ken Raeburn <raeburn@gnu.org>
To: emacs-devel@gnu.org
Subject: Re: Redundant type checking in window.c and w32menu.c
Date: Thu, 21 Jun 2007 13:38:17 -0400	[thread overview]
Message-ID: <C56C42DB-C73F-42DE-A0DD-5ECCA9725F60@gnu.org> (raw)
In-Reply-To: <46799227.3070905@gnu.org>

On Jun 20, 2007, at 16:46, Jason Rumney wrote:
> Is this optimisation really worth the confusion of having two versions
> of these functions in the code?

We could use a new macro DEFUN_INLINE, like so:

#if CAN_DO_INLINE || defined PROVIDE_ADDRESSABLE_IMPLEMENTATION
DEFUN_INLINE ("car", Fcar, Scar, ....)
   (list)
   Lisp_Object list;
{
   ...;
}
#else
EXFUN(Fcar, 1);
#endif

where:

PROVIDE_ADDRESSABLE_IMPLEMENTATION: Is defined in exactly one Emacs  
source file, say, data.c, before lisp.h is included.

CAN_DO_INLINE: Is true if the compiler, with the current options,  
supports inline functions in some useful form.  (E.g., it could  
expand to test __GNUC__, __OPTIMIZE__, __STDC_VERSION__, etc.)  For  
brevity, we could also define a macro that tests both this property  
and PROVIDE_ADDRESSABLE_IMPLEMENTATION.

DEFUN_INLINE: If inline functions are not supported, expands to the  
same as DEFUN.  Otherwise, tests PROVIDE_ADDRESSABLE_IMPLEMENTATION  
and makes an addressable version if it's defined, and an inline  
version if not.  Depending on the compiler, "inline", "static  
inline", "extern inline", or other keywords may be used.

In older GCC compilers, "extern inline" means "expand inline or  
generate a reference to an external copy defined elsewhere, but don't  
provide an external definition or static copy", while "inline" would  
produce an external definition.  ISO C 99 has a different meaning for  
"extern inline", in fact I think the handling of "extern inline" and  
"inline" may be almost exactly reversed from the old GCC handling,  
and GCC is adapting to the spec but providing some attributes for  
finer control I think.  Using "static inline" sidesteps the issue but  
risks producing multiple static copies of the function if it's not  
expanded inline.  But there are also GCC version number macro tests  
and autoconf feature test cases possible.  This could make defining  
DEFUN_INLINE a little bit complicated, but the use of it should be  
pretty straightforward.

Then, data.o gets an addressable copy of the function for use in  
defining the Lisp symbol, and it can be expanded inline in other  
source files when the compiler supports it.  Debuggers on some older  
platforms may not handle functions defined in header files very well,  
but with inline expansion happening, you're not likely to be able to  
set breakpoints in these functions usefully anyways.

(On a vaguely related note, is it time to start assuming at least  
ANSI C '89 support, like prototypes, in the Emacs sources yet?)

Ken

  parent reply	other threads:[~2007-06-21 17:38 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-06-19 14:44 Redundant type checking in window.c and w32menu.c Dmitry Antipov
2007-06-19 14:55 ` Stefan Monnier
2007-06-19 18:46 ` Ken Raeburn
2007-06-20 14:12   ` Dmitry Antipov
2007-06-20 15:20     ` Jason Rumney
2007-06-20 17:55       ` dmantipov
2007-06-20 20:46         ` Jason Rumney
2007-06-21 15:46           ` Dmitry Antipov
2007-06-21 17:38           ` Ken Raeburn [this message]
2007-06-20 20:12     ` Tom Tromey

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

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

  git send-email \
    --in-reply-to=C56C42DB-C73F-42DE-A0DD-5ECCA9725F60@gnu.org \
    --to=raeburn@gnu.org \
    --cc=emacs-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.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.