emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Emacs-diffs] /srv/bzr/emacs/trunk r112828: Merge the specpdl and ba


From: Paul Eggert
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
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130514 Thunderbird/17.0.6

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  <address@hidden>
+
+       * conf_post.h: Add comments for INLINE, EXTERN_INLINE, etc.
+
 2013-06-18  Kenichi Handa  <address@hidden>
 
        * 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 via email to

[Prev in Thread] Current Thread [Next in Thread]