all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Paul Eggert <eggert@cs.ucla.edu>
To: Eli Zaretskii <eliz@gnu.org>
Cc: emacs-devel@gnu.org
Subject: Re: [Emacs-diffs] /srv/bzr/emacs/trunk r112828: Merge the specpdl and	backtrace stacks. Make the structure of the
Date: Tue, 18 Jun 2013 11:50:54 -0700	[thread overview]
Message-ID: <51C0AC0E.2020907@cs.ucla.edu> (raw)
In-Reply-To: <83mwr5x62g.fsf@gnu.org>

On 06/04/13 08:13, Eli Zaretskii wrote:

> My guess would be in lisp.h

Since the pattern is used in many .h files, I put the
documentation in src/conf_post.h, before the definition
of INLINE, EXTERN_INLINE, etc., as trunk bzr 113054
(patch at end of this message).

> how to explain the
> fact that revision 112828 produced unresolved externals for such
> functions that were defined in the same file (eval.c)?

112828 declared LISP_INLINE functions in eval.c.
That wasn't right for C99 platforms, because
in eval.c LISP_INLINE expands to plain 'inline',
and C99 requires that if any module defines a plain
inline function FOO (perhaps via a .h file), then
FOO must be defined as 'extern inline' in exactly one
other module.

Eventually this problem got fixed by declaring
these as ordinary functions, not as inline functions.

I'll add some more documentation to Gnulib about this.
The short version is that C code should ordinarily
not use 'inline'.  The only exception is for functions
defined in a .h file, which should be defined using the
pattern documented below.

=== modified file 'src/ChangeLog'
--- src/ChangeLog	2013-06-18 14:54:48 +0000
+++ src/ChangeLog	2013-06-18 18:36:13 +0000
@@ -1,3 +1,7 @@
+2013-06-18  Paul Eggert  <eggert@cs.ucla.edu>
+
+	* conf_post.h: Add comments for INLINE, EXTERN_INLINE, etc.
+
 2013-06-18  Kenichi Handa  <handa@gnu.org>
 
 	* font.c (Ffont_spec): Signal an error for an invalid font name

=== modified file 'src/conf_post.h'
--- src/conf_post.h	2013-03-13 18:42:22 +0000
+++ src/conf_post.h	2013-06-18 18:36:13 +0000
@@ -207,6 +207,37 @@
 #undef noinline
 #endif
 
+/* Use Gnulib's extern-inline module for extern inline functions.
+   An include file foo.h should prepend FOO_INLINE to function
+   definitions, with the following overall pattern:
+
+      [#include any other .h files first.]
+      ...
+      INLINE_HEADER_BEGIN
+      #ifndef FOO_INLINE
+      # define FOO_INLINE INLINE
+      #endif
+      ...
+      FOO_INLINE int
+      incr (int i)
+      {
+        return i + 1;
+      }
+      ...
+      INLINE_HEADER_END
+
+   The corresponding foo.c file should do this:
+
+      #define FOO_INLINE EXTERN_INLINE
+
+   before including any .h file other than config.h.
+   Other .c files should not define FOO_INILNE.
+
+   C99 compilers compile functions like 'incr' as C99-style extern
+   inline functions.  Pre-C99 GCCs do something similar with
+   GNU-specific keywords.  Pre-C99 non-GCC compilers use static
+   functions, which bloats the code but is good enough.  */
+
 #define INLINE _GL_INLINE
 #define EXTERN_INLINE _GL_EXTERN_INLINE
 #define INLINE_HEADER_BEGIN _GL_INLINE_HEADER_BEGIN





  reply	other threads:[~2013-06-18 18:50 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <E1UjQtA-0006p7-My@vcs.savannah.gnu.org>
2013-06-03 13:59 ` [Emacs-diffs] /srv/bzr/emacs/trunk r112828: Merge the specpdl and backtrace stacks. Make the structure of the Juanma Barranquero
2013-06-03 14:01   ` Juanma Barranquero
2013-06-03 18:25   ` Stefan Monnier
2013-06-03 19:23     ` Eli Zaretskii
2013-06-04  5:55       ` Paul Eggert
2013-06-04 15:13         ` Eli Zaretskii
2013-06-18 18:50           ` Paul Eggert [this message]
2013-06-18 19:05             ` Eli Zaretskii
2013-06-18 20:56               ` Paul Eggert

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=51C0AC0E.2020907@cs.ucla.edu \
    --to=eggert@cs.ucla.edu \
    --cc=eliz@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.