Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit de6fd1c

Browse files
committed
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 c53f738, now has to be done differently. A platform template can define PG_FORCE_DISABLE_INLINE to force inline to be defined empty. Discussion: [email protected]
1 parent a855118 commit de6fd1c

29 files changed

+92
-415
lines changed

config/c-compiler.m4

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -17,40 +17,6 @@ fi])# PGAC_C_SIGNED
1717

1818

1919

20-
# PGAC_C_INLINE
21-
# -------------
22-
# Check if the C compiler understands inline functions without being
23-
# noisy about unused static inline functions. Some older compilers
24-
# understand inline functions (as tested by AC_C_INLINE) but warn about
25-
# them if they aren't used in a translation unit.
26-
#
27-
# This test used to just define an inline function, but some compilers
28-
# (notably clang) got too smart and now warn about unused static
29-
# inline functions when defined inside a .c file, but not when defined
30-
# in an included header. Since the latter is what we want to use, test
31-
# to see if the warning appears when the function is in a header file.
32-
# Not pretty, but it works.
33-
#
34-
# Defines: inline, PG_USE_INLINE
35-
AC_DEFUN([PGAC_C_INLINE],
36-
[AC_C_INLINE
37-
AC_CACHE_CHECK([for quiet inline (no complaint if unreferenced)], pgac_cv_c_inline_quietly,
38-
[pgac_cv_c_inline_quietly=no
39-
if test "$ac_cv_c_inline" != no; then
40-
pgac_c_inline_save_werror=$ac_c_werror_flag
41-
ac_c_werror_flag=yes
42-
AC_LINK_IFELSE([AC_LANG_PROGRAM([#include "$srcdir/config/test_quiet_include.h"],[])],
43-
[pgac_cv_c_inline_quietly=yes])
44-
ac_c_werror_flag=$pgac_c_inline_save_werror
45-
fi])
46-
if test "$pgac_cv_c_inline_quietly" != no; then
47-
AC_DEFINE_UNQUOTED([PG_USE_INLINE], 1,
48-
[Define to 1 if "static inline" works without unwanted warnings from ]
49-
[compilations where static inline functions are defined but not called.])
50-
fi
51-
])# PGAC_C_INLINE
52-
53-
5420
# PGAC_C_PRINTF_ARCHETYPE
5521
# -----------------------
5622
# Set the format archetype used by gcc to check printf type functions. We

config/test_quiet_include.h

Lines changed: 0 additions & 18 deletions
This file was deleted.

configure

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -11006,44 +11006,6 @@ _ACEOF
1100611006
;;
1100711007
esac
1100811008

11009-
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for quiet inline (no complaint if unreferenced)" >&5
11010-
$as_echo_n "checking for quiet inline (no complaint if unreferenced)... " >&6; }
11011-
if ${pgac_cv_c_inline_quietly+:} false; then :
11012-
$as_echo_n "(cached) " >&6
11013-
else
11014-
pgac_cv_c_inline_quietly=no
11015-
if test "$ac_cv_c_inline" != no; then
11016-
pgac_c_inline_save_werror=$ac_c_werror_flag
11017-
ac_c_werror_flag=yes
11018-
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
11019-
/* end confdefs.h. */
11020-
#include "$srcdir/config/test_quiet_include.h"
11021-
int
11022-
main ()
11023-
{
11024-
11025-
;
11026-
return 0;
11027-
}
11028-
_ACEOF
11029-
if ac_fn_c_try_link "$LINENO"; then :
11030-
pgac_cv_c_inline_quietly=yes
11031-
fi
11032-
rm -f core conftest.err conftest.$ac_objext \
11033-
conftest$ac_exeext conftest.$ac_ext
11034-
ac_c_werror_flag=$pgac_c_inline_save_werror
11035-
fi
11036-
fi
11037-
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $pgac_cv_c_inline_quietly" >&5
11038-
$as_echo "$pgac_cv_c_inline_quietly" >&6; }
11039-
if test "$pgac_cv_c_inline_quietly" != no; then
11040-
11041-
cat >>confdefs.h <<_ACEOF
11042-
#define PG_USE_INLINE 1
11043-
_ACEOF
11044-
11045-
fi
11046-
1104711009
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for printf format archetype" >&5
1104811010
$as_echo_n "checking for printf format archetype... " >&6; }
1104911011
if ${pgac_cv_printf_archetype+:} false; then :

configure.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1309,7 +1309,7 @@ fi
13091309

13101310
m4_defun([AC_PROG_CC_STDC], []) dnl We don't want that.
13111311
AC_C_BIGENDIAN
1312-
PGAC_C_INLINE
1312+
AC_C_INLINE
13131313
PGAC_PRINTF_ARCHETYPE
13141314
AC_C_FLEXIBLE_ARRAY_MEMBER
13151315
PGAC_C_SIGNED

src/backend/lib/ilist.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,6 @@
1818
*/
1919
#include "postgres.h"
2020

21-
/* See ilist.h */
22-
#define ILIST_INCLUDE_DEFINITIONS
23-
2421
#include "lib/ilist.h"
2522

2623
/*

src/backend/nodes/list.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,6 @@
1515
*/
1616
#include "postgres.h"
1717

18-
/* see pg_list.h */
19-
#define PG_LIST_INCLUDE_DEFINITIONS
20-
2118
#include "nodes/pg_list.h"
2219

2320

src/backend/port/atomics.c

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,6 @@
1313
*/
1414
#include "postgres.h"
1515

16-
/*
17-
* We want the functions below to be inline; but if the compiler doesn't
18-
* support that, fall back on providing them as regular functions. See
19-
* STATIC_IF_INLINE in c.h.
20-
*/
21-
#define ATOMICS_INCLUDE_DEFINITIONS
22-
2316
#include "miscadmin.h"
2417
#include "port/atomics.h"
2518
#include "storage/spin.h"

src/backend/utils/adt/arrayfuncs.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,6 @@
2020
#endif
2121
#include <math.h>
2222

23-
/* See arrayaccess.h */
24-
#define ARRAYACCESS_INCLUDE_DEFINITIONS
25-
2623
#include "access/htup_details.h"
2724
#include "catalog/pg_type.h"
2825
#include "funcapi.h"

src/backend/utils/mmgr/mcxt.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,6 @@
1919
*-------------------------------------------------------------------------
2020
*/
2121

22-
/* see palloc.h. Must be before postgres.h */
23-
#define MCXT_INCLUDE_DEFINITIONS
24-
2522
#include "postgres.h"
2623

2724
#include "miscadmin.h"

src/backend/utils/sort/sortsupport.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,6 @@
1515

1616
#include "postgres.h"
1717

18-
/* See sortsupport.h */
19-
#define SORTSUPPORT_INCLUDE_DEFINITIONS
20-
2118
#include "access/nbtree.h"
2219
#include "fmgr.h"
2320
#include "utils/lsyscache.h"

0 commit comments

Comments
 (0)