diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/backend/nodes/list.c | 12 | ||||
| -rw-r--r-- | src/backend/utils/mmgr/mcxt.c | 11 | ||||
| -rw-r--r-- | src/include/nodes/pg_list.h | 16 | ||||
| -rw-r--r-- | src/include/pg_config.h.in | 4 | ||||
| -rw-r--r-- | src/include/pg_config.h.win32 | 16 | ||||
| -rw-r--r-- | src/include/port/win32.h | 11 | ||||
| -rw-r--r-- | src/include/portability/instr_time.h | 4 | ||||
| -rw-r--r-- | src/include/utils/palloc.h | 10 |
8 files changed, 41 insertions, 43 deletions
diff --git a/src/backend/nodes/list.c b/src/backend/nodes/list.c index 9968b1ef15..24fcffd22f 100644 --- a/src/backend/nodes/list.c +++ b/src/backend/nodes/list.c @@ -9,7 +9,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/nodes/list.c,v 1.73 2010/01/02 16:57:46 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/nodes/list.c,v 1.74 2010/02/13 02:34:11 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -1224,12 +1224,10 @@ list_copy_tail(List *oldlist, int nskip) } /* - * When using non-GCC compilers, we can't define these as inline - * functions in pg_list.h, so they are defined here. - * - * TODO: investigate supporting inlining for some non-GCC compilers. + * pg_list.h defines inline versions of these functions if allowed by the + * compiler; in which case the definitions below are skipped. */ -#ifndef __GNUC__ +#ifndef USE_INLINE ListCell * list_head(List *l) @@ -1248,7 +1246,7 @@ list_length(List *l) { return l ? l->length : 0; } -#endif /* ! __GNUC__ */ +#endif /* ! USE_INLINE */ /* * Temporary compatibility functions diff --git a/src/backend/utils/mmgr/mcxt.c b/src/backend/utils/mmgr/mcxt.c index bb4c0e69e5..6d31e4e075 100644 --- a/src/backend/utils/mmgr/mcxt.c +++ b/src/backend/utils/mmgr/mcxt.c @@ -14,7 +14,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/mmgr/mcxt.c,v 1.68 2010/01/02 16:57:58 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/utils/mmgr/mcxt.c,v 1.69 2010/02/13 02:34:12 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -628,11 +628,10 @@ repalloc(void *pointer, Size size) * MemoryContextSwitchTo * Returns the current context; installs the given context. * - * This is inlined when using GCC. - * - * TODO: investigate supporting inlining for some non-GCC compilers. + * palloc.h defines an inline version of this function if allowed by the + * compiler; in which case the definition below is skipped. */ -#ifndef __GNUC__ +#ifndef USE_INLINE MemoryContext MemoryContextSwitchTo(MemoryContext context) @@ -645,7 +644,7 @@ MemoryContextSwitchTo(MemoryContext context) CurrentMemoryContext = context; return old; } -#endif /* ! __GNUC__ */ +#endif /* ! USE_INLINE */ /* * MemoryContextStrdup 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 |
