mirror of
				https://github.com/postgres/postgres.git
				synced 2025-11-03 09:13:20 +03:00 
			
		
		
		
	Rely on inline functions even if that causes warnings in older compilers.
So far we have worked around the fact that some very old compilers do
not support 'inline' functions by only using inline functions
conditionally (or not at all). Since such compilers are very rare by
now, we have decided to rely on inline functions from 9.6 onwards.
To avoid breaking these old compilers inline is defined away when not
supported. That'll cause "function x defined but not used" type of
warnings, but since nobody develops on such compilers anymore that's
ok.
This change in policy will allow us to more easily employ inline
functions.
I chose to remove code previously conditional on PG_USE_INLINE as it
seemed confusing to have code dependent on a define that's always
defined.
Blacklisting of compilers, like in c53f73879f, now has to be done
differently. A platform template can define PG_FORCE_DISABLE_INLINE to
force inline to be defined empty.
Discussion: 20150701161447.GB30708@awork2.anarazel.de
			
			
This commit is contained in:
		@@ -71,34 +71,25 @@ 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 static inline functions
 | 
			
		||||
 * if supported by the compiler, or as regular functions otherwise.
 | 
			
		||||
 * See STATIC_IF_INLINE in c.h.
 | 
			
		||||
 * arguments.
 | 
			
		||||
 */
 | 
			
		||||
#ifndef PG_USE_INLINE
 | 
			
		||||
extern ListCell *list_head(const List *l);
 | 
			
		||||
extern ListCell *list_tail(List *l);
 | 
			
		||||
extern int	list_length(const List *l);
 | 
			
		||||
#endif   /* PG_USE_INLINE */
 | 
			
		||||
#if defined(PG_USE_INLINE) || defined(PG_LIST_INCLUDE_DEFINITIONS)
 | 
			
		||||
STATIC_IF_INLINE ListCell *
 | 
			
		||||
static inline ListCell *
 | 
			
		||||
list_head(const List *l)
 | 
			
		||||
{
 | 
			
		||||
	return l ? l->head : NULL;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
STATIC_IF_INLINE ListCell *
 | 
			
		||||
static inline ListCell *
 | 
			
		||||
list_tail(List *l)
 | 
			
		||||
{
 | 
			
		||||
	return l ? l->tail : NULL;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
STATIC_IF_INLINE int
 | 
			
		||||
static inline int
 | 
			
		||||
list_length(const List *l)
 | 
			
		||||
{
 | 
			
		||||
	return l ? l->length : 0;
 | 
			
		||||
}
 | 
			
		||||
#endif   /*-- PG_USE_INLINE || PG_LIST_INCLUDE_DEFINITIONS */
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * NB: There is an unfortunate legacy from a previous incarnation of
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user