1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-08 11:42:09 +03:00

Support inlining various small performance-critical functions on non-GCC

compilers, by applying a configure check to see if the compiler will accept
an unreferenced "static inline foo ..." function without warnings.  It is
believed that such warnings are the only reason not to declare inlined
functions in headers, if the compiler understands "inline" at all.

Kurt Harriman
This commit is contained in:
Tom Lane
2010-02-13 02:34:16 +00:00
parent b95a720a48
commit e08ab7c312
11 changed files with 137 additions and 46 deletions

View File

@ -21,7 +21,7 @@
* Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $PostgreSQL: pgsql/src/include/utils/palloc.h,v 1.42 2010/01/02 16:58:10 momjian Exp $
* $PostgreSQL: pgsql/src/include/utils/palloc.h,v 1.43 2010/02/13 02:34:16 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@ -72,11 +72,11 @@ extern void *repalloc(void *pointer, Size size);
/*
* MemoryContextSwitchTo can't be a macro in standard C compilers.
* But we can make it an inline function when using GCC.
* But we can make it an inline function if the compiler supports it.
*/
#ifdef __GNUC__
#ifdef USE_INLINE
static __inline__ MemoryContext
static inline MemoryContext
MemoryContextSwitchTo(MemoryContext context)
{
MemoryContext old = CurrentMemoryContext;
@ -87,7 +87,7 @@ MemoryContextSwitchTo(MemoryContext context)
#else
extern MemoryContext MemoryContextSwitchTo(MemoryContext context);
#endif /* __GNUC__ */
#endif /* USE_INLINE */
/*
* These are like standard strdup() except the copied string is