From: | Kurt Harriman <harriman(at)acm(dot)org> |
---|---|
To: | pgsql-hackers(at)postgresql(dot)org, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Peter Eisentraut <peter_e(at)gmx(dot)net> |
Subject: | Re: Patch: Remove gcc dependency in definition of inline functions |
Date: | 2010-02-10 22:53:49 |
Message-ID: | 4B7338FD.9010802@acm.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Revised patch is attached (4th edition).
It's also available in my git repository in the "submitted" branch:
http://git.postgresql.org/gitweb?p=users/harriman/share.git;a=shortlog;h=refs/heads/submitted
With this patch, the "configure" script tests whether a static
inline function can be defined without incurring a warning when
not referenced. If successful, the preprocessor symbol USE_INLINE
is defined to 1 in pg_config.h. Otherwise USE_INLINE remains
undefined.
palloc.h and pg_list.h condition their inline function
definitions on USE_INLINE instead of the gcc-specific __GNUC__.
Thus the functions can be inlined on more platforms, not only gcc.
Ordinary out-of-line calls are still used if the compiler doesn't
recognize inline functions, or spews warnings when static inline
functions are defined but not referenced.
From now on in cross-platform code, plain "inline" should be used
instead of compiler-specific alternate spellings such as __inline__,
because the configure script redefines "inline" to the appropriate
alternate spelling if necessary. (This patch doesn't affect the
redefinition of "inline": that was already in place.)
Changes since the second and third editions of this patch:
- Renamed the new preprocessor symbol to USE_INLINE, following the
advice of Tom Lane, instead of my earlier attempts PG_INLINE or
inline_quietly. It is used like this:
/* include/utils/palloc.h */
#ifdef USE_INLINE
static inline MemoryContext
MemoryContextSwitchTo(MemoryContext context)
{
MemoryContext old = CurrentMemoryContext;
CurrentMemoryContext = context;
return old;
}
#else
extern MemoryContext MemoryContextSwitchTo(MemoryContext context);
#endif /* USE_INLINE */
/* backend/utils/mmgr/mcxt.c */
#ifndef USE_INLINE
MemoryContext
MemoryContextSwitchTo(MemoryContext context)
{
MemoryContext old;
AssertArg(MemoryContextIsValid(context));
old = CurrentMemoryContext;
CurrentMemoryContext = context;
return old;
}
#endif /* ! USE_INLINE */
- Simplified the autoconf logic added to config/c-compiler.m4.
- Removed MSVC-related changes (__forceinline) from the autoconf
stuff. Instead, updated the manually-edited pg_config.h.win32
file to define "inline" as __inline, and USE_INLINE as 1.
- Removed Windows-only misspelling of __inline__ in instr_time.h.
This was the only occurrence of __inline__; therefore, deleted
the no-longer-needed definition of __inline__ from port/win32.h.
Also deleted the definition of inline from port/win32.h, since
it is now defined in pg_config.h.win32, consistent with the
other platforms.
Thanks again to all who have commented.
Regards,
... kurt
Attachment | Content-Type | Size |
---|---|---|
inline-across-platforms.zip | application/octet-stream | 3.6 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Kurt Harriman | 2010-02-10 23:04:06 | Re: Patch: Remove gcc dependency in definition of inline functions |
Previous Message | Marko Tiikkaja | 2010-02-10 22:50:48 | Re: Writeable CTEs and empty relations |