summaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2010-02-13 02:34:16 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2010-02-13 02:34:16 +0000
commite08ab7c3127c10d419e91072c68e1bfeaab025b8 (patch)
tree8e46dc2510ed865e15b6a56fbf93bdbb10deb07e /src/include
parentb95a720a487b5027af1b9e4a12542800598ff5de (diff)
downloadpostgresql-e08ab7c3127c10d419e91072c68e1bfeaab025b8.tar.gz
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
Diffstat (limited to 'src/include')
-rw-r--r--src/include/nodes/pg_list.h16
-rw-r--r--src/include/pg_config.h.in4
-rw-r--r--src/include/pg_config.h.win3216
-rw-r--r--src/include/port/win32.h11
-rw-r--r--src/include/portability/instr_time.h4
-rw-r--r--src/include/utils/palloc.h10
6 files changed, 31 insertions, 30 deletions
diff --git a/src/include/nodes/pg_list.h b/src/include/nodes/pg_list.h
index c9340c9af9..fae567969a 100644
--- a/src/include/nodes/pg_list.h
+++ b/src/include/nodes/pg_list.h
@@ -30,7 +30,7 @@
* Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/nodes/pg_list.h,v 1.62 2010/01/02 16:58:04 momjian Exp $
+ * $PostgreSQL: pgsql/src/include/nodes/pg_list.h,v 1.63 2010/02/13 02:34:13 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -71,24 +71,24 @@ struct ListCell
/*
* These routines are used frequently. However, we can't implement
* them as macros, since we want to avoid double-evaluation of macro
- * arguments. Therefore, we implement them using GCC inline functions,
- * and as regular functions with non-GCC compilers.
+ * arguments. Therefore, we implement them using static inline functions
+ * if supported by the compiler, or as regular functions otherwise.
*/
-#ifdef __GNUC__
+#ifdef USE_INLINE
-static __inline__ ListCell *
+static inline ListCell *
list_head(List *l)
{
return l ? l->head : NULL;
}
-static __inline__ ListCell *
+static inline ListCell *
list_tail(List *l)
{
return l ? l->tail : NULL;
}
-static __inline__ int
+static inline int
list_length(List *l)
{
return l ? l->length : 0;
@@ -98,7 +98,7 @@ list_length(List *l)
extern ListCell *list_head(List *l);
extern ListCell *list_tail(List *l);
extern int list_length(List *l);
-#endif /* __GNUC__ */
+#endif /* USE_INLINE */
/*
* NB: There is an unfortunate legacy from a previous incarnation of
diff --git a/src/include/pg_config.h.in b/src/include/pg_config.h.in
index 69799a5042..684aed4a9f 100644
--- a/src/include/pg_config.h.in
+++ b/src/include/pg_config.h.in
@@ -749,6 +749,10 @@
(--enable-float8-byval) */
#undef USE_FLOAT8_BYVAL
+/* Define to 1 if "static inline" works without unwanted warnings from
+ compilations where static inline functions are defined but not called. */
+#undef USE_INLINE
+
/* Define to 1 if you want 64-bit integer timestamp and interval support.
(--enable-integer-datetimes) */
#undef USE_INTEGER_DATETIMES
diff --git a/src/include/pg_config.h.win32 b/src/include/pg_config.h.win32
index 76f3731020..de97bcfab1 100644
--- a/src/include/pg_config.h.win32
+++ b/src/include/pg_config.h.win32
@@ -6,8 +6,8 @@
*
* HAVE_CBRT, HAVE_FUNCNAME_FUNC, HAVE_GETOPT, HAVE_GETOPT_H,
* HAVE_GETOPT_LONG, HAVE_RINT, HAVE_STRINGS_H, HAVE_STRTOLL,
- * HAVE_STRTOULL, HAVE_STRUCT_OPTION, ENABLE_THREAD_SAFETY
- *
+ * HAVE_STRTOULL, HAVE_STRUCT_OPTION, ENABLE_THREAD_SAFETY,
+ * USE_INLINE, inline
*/
/* Define to the type of arg 1 of 'accept' */
@@ -621,6 +621,10 @@
/* Define to 1 to build with Bonjour support. (--with-bonjour) */
/* #undef USE_BONJOUR */
+/* Define to 1 if "static inline" works without unwanted warnings from
+ compilations where static inline functions are defined but not called. */
+#define USE_INLINE 1
+
/* Define to 1 if you want 64-bit integer timestamp and interval support.
(--enable-integer-datetimes) */
/* #undef USE_INTEGER_DATETIMES */
@@ -664,9 +668,11 @@
/* Define to empty if `const' does not conform to ANSI C. */
/* #undef const */
-/* Define as `__inline' if that's what the C compiler calls it, or to nothing
- if it is not supported. */
-/* #undef inline */
+/* Define to `__inline__' or `__inline' if that's what the C compiler
+ calls it, or to nothing if 'inline' is not supported under any name. */
+#ifndef __cplusplus
+#define inline __inline
+#endif
/* Define to empty if the C compiler does not understand signed types. */
/* #undef signed */
diff --git a/src/include/port/win32.h b/src/include/port/win32.h
index ae784c2dcb..3ec81c4f7e 100644
--- a/src/include/port/win32.h
+++ b/src/include/port/win32.h
@@ -1,4 +1,4 @@
-/* $PostgreSQL: pgsql/src/include/port/win32.h,v 1.91 2010/01/02 22:47:37 mha Exp $ */
+/* $PostgreSQL: pgsql/src/include/port/win32.h,v 1.92 2010/02/13 02:34:14 tgl Exp $ */
#if defined(_MSC_VER) || defined(__BORLANDC__)
#define WIN32_ONLY_COMPILER
@@ -313,15 +313,6 @@ typedef __int64 ssize_t;
typedef unsigned short mode_t;
#endif
-/*
- * Certain "standard edition" versions of MSVC throw a warning
- * that later generates an error for "inline" statements, but
- * __inline seems to work. e.g. Microsoft Visual C++ .NET
- * Version 7.1.3088
- */
-#define inline __inline
-#define __inline__ __inline
-
#ifndef __BORLANDC__
#define _S_IRWXU (_S_IREAD | _S_IWRITE | _S_IEXEC)
#define _S_IXUSR _S_IEXEC
diff --git a/src/include/portability/instr_time.h b/src/include/portability/instr_time.h
index 6ba50bdf05..8515189bca 100644
--- a/src/include/portability/instr_time.h
+++ b/src/include/portability/instr_time.h
@@ -45,7 +45,7 @@
*
* Copyright (c) 2001-2010, PostgreSQL Global Development Group
*
- * $PostgreSQL: pgsql/src/include/portability/instr_time.h,v 1.5 2010/01/02 16:58:08 momjian Exp $
+ * $PostgreSQL: pgsql/src/include/portability/instr_time.h,v 1.6 2010/02/13 02:34:15 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -141,7 +141,7 @@ typedef LARGE_INTEGER instr_time;
#define INSTR_TIME_GET_MICROSEC(t) \
((uint64) (((double) (t).QuadPart * 1000000.0) / GetTimerFrequency()))
-static __inline__ double
+static inline double
GetTimerFrequency(void)
{
LARGE_INTEGER f;
diff --git a/src/include/utils/palloc.h b/src/include/utils/palloc.h
index a885e263d1..af59c3ce54 100644
--- a/src/include/utils/palloc.h
+++ b/src/include/utils/palloc.h
@@ -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