pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
assume availability of "inline" keyword
4+ messages / 2 participants
[nested] [flat]

Commits from this thread:
  2026-02-19 aa71a35a40  Assume "inline" keyword is available.
* assume availability of "inline" keyword
@ 2026-02-19 17:20  Nathan Bossart <nathandbossart@gmail.com>
  0 siblings, 1 reply; 4+ messages in thread

From: Nathan Bossart @ 2026-02-19 17:20 UTC (permalink / raw)
  To: pgsql-hackers

I noticed some code that uses __inline__ (which IIUC is a gcc extension) as
well as a related configure check.  "inline" was first added to C99, and we
now require C11, so we can just assume it's there, right?  FWIW it looks
like meson builds don't bother checking this.

-- 
nathan

Attachments:

v1-0001-Assume-availability-of-inline-keyword.patch (text/plain, 5.6K) download From daf8dd4a9364ea9c1d6c060c545f4f1cad682b7a Mon Sep 17 00:00:00 2001 From: Nathan Bossart <nathan@postgresql.org> Date: Thu, 19 Feb 2026 11:15:18 -0600 Subject: [PATCH v1 1/1] Assume availability of "inline" keyword. --- configure | 42 ----------------------------- configure.ac | 1 - src/include/pg_config.h.in | 6 ----- src/include/port/atomics/arch-x86.h | 2 +- src/include/storage/s_lock.h | 24 ++++++++--------- 5 files changed, 13 insertions(+), 62 deletions(-) diff --git a/configure b/configure index a6eab396299..e1a08129974 100755 --- a/configure +++ b/configure @@ -14741,48 +14741,6 @@ $as_echo "#define AC_APPLE_UNIVERSAL_BUILD 1" >>confdefs.h presetting ac_cv_c_bigendian=no (or yes) will help" "$LINENO" 5 ;; esac -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for inline" >&5 -$as_echo_n "checking for inline... " >&6; } -if ${ac_cv_c_inline+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_cv_c_inline=no -for ac_kw in inline __inline__ __inline; do - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#ifndef __cplusplus -typedef int foo_t; -static $ac_kw foo_t static_foo () {return 0; } -$ac_kw foo_t foo () {return 0; } -#endif - -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_c_inline=$ac_kw -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - test "$ac_cv_c_inline" != no && break -done - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_inline" >&5 -$as_echo "$ac_cv_c_inline" >&6; } - -case $ac_cv_c_inline in - inline | yes) ;; - *) - case $ac_cv_c_inline in - no) ac_val=;; - *) ac_val=$ac_cv_c_inline;; - esac - cat >>confdefs.h <<_ACEOF -#ifndef __cplusplus -#define inline $ac_val -#endif -_ACEOF - ;; -esac - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for C printf format archetype" >&5 $as_echo_n "checking for C printf format archetype... " >&6; } if ${pgac_cv_printf_archetype+:} false; then : diff --git a/configure.ac b/configure.ac index 455ba31f1d1..cc85c233c03 100644 --- a/configure.ac +++ b/configure.ac @@ -1712,7 +1712,6 @@ fi m4_defun([AC_PROG_CC_STDC], []) dnl We don't want that. AC_C_BIGENDIAN -AC_C_INLINE PGAC_PRINTF_ARCHETYPE PGAC_CXX_PRINTF_ARCHETYPE PGAC_C_STATEMENT_EXPRESSIONS diff --git a/src/include/pg_config.h.in b/src/include/pg_config.h.in index 339268dc8ef..3824a5571bb 100644 --- a/src/include/pg_config.h.in +++ b/src/include/pg_config.h.in @@ -780,12 +780,6 @@ /* Define for large files, on AIX-style hosts. */ #undef _LARGE_FILES -/* 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 -#undef inline -#endif - /* Define to keyword to use for C99 restrict support, or to nothing if not supported */ #undef pg_restrict diff --git a/src/include/port/atomics/arch-x86.h b/src/include/port/atomics/arch-x86.h index 43a8e90b2d2..bd6f4f56ca2 100644 --- a/src/include/port/atomics/arch-x86.h +++ b/src/include/port/atomics/arch-x86.h @@ -104,7 +104,7 @@ typedef struct pg_atomic_uint64 */ #if defined(__GNUC__) || defined(__INTEL_COMPILER) #define PG_HAVE_SPIN_DELAY -static __inline__ void +static inline void pg_spin_delay_impl(void) { __asm__ __volatile__(" rep; nop \n"); diff --git a/src/include/storage/s_lock.h b/src/include/storage/s_lock.h index 3d9070e79d4..62364586d60 100644 --- a/src/include/storage/s_lock.h +++ b/src/include/storage/s_lock.h @@ -134,7 +134,7 @@ typedef unsigned char slock_t; #define TAS(lock) tas(lock) -static __inline__ int +static inline int tas(volatile slock_t *lock) { slock_t _res = 1; @@ -164,7 +164,7 @@ tas(volatile slock_t *lock) #define SPIN_DELAY() spin_delay() -static __inline__ void +static inline void spin_delay(void) { /* @@ -215,7 +215,7 @@ typedef unsigned char slock_t; */ #define TAS_SPIN(lock) (*(lock) ? 1 : TAS(lock)) -static __inline__ int +static inline int tas(volatile slock_t *lock) { slock_t _res = 1; @@ -231,7 +231,7 @@ tas(volatile slock_t *lock) #define SPIN_DELAY() spin_delay() -static __inline__ void +static inline void spin_delay(void) { /* @@ -259,7 +259,7 @@ spin_delay(void) typedef int slock_t; -static __inline__ int +static inline int tas(volatile slock_t *lock) { return __sync_lock_test_and_set(lock, 1); @@ -277,7 +277,7 @@ tas(volatile slock_t *lock) #define SPIN_DELAY() spin_delay() -static __inline__ void +static inline void spin_delay(void) { /* @@ -302,7 +302,7 @@ typedef unsigned int slock_t; #define TAS(lock) tas(lock) -static __inline__ int +static inline int tas(volatile slock_t *lock) { int _res = 0; @@ -331,7 +331,7 @@ typedef unsigned char slock_t; #define TAS(lock) tas(lock) -static __inline__ int +static inline int tas(volatile slock_t *lock) { slock_t _res; @@ -416,7 +416,7 @@ typedef unsigned int slock_t; * But if the spinlock is in ordinary memory, we can use lwsync instead for * better performance. */ -static __inline__ int +static inline int tas(volatile slock_t *lock) { slock_t _t; @@ -482,7 +482,7 @@ typedef unsigned int slock_t; #define MIPS_SET_MIPS2 #endif -static __inline__ int +static inline int tas(volatile slock_t *lock) { volatile slock_t *_l = lock; @@ -544,7 +544,7 @@ do \ typedef int slock_t; -static __inline__ int +static inline int tas(volatile slock_t *lock) { return __sync_lock_test_and_set(lock, 1); @@ -559,7 +559,7 @@ tas(volatile slock_t *lock) typedef char slock_t; -static __inline__ int +static inline int tas(volatile slock_t *lock) { return __sync_lock_test_and_set(lock, 1); -- 2.50.1 (Apple Git-155)
^ permalink raw reply [nested|flat] 4+ messages in thread

* Re: assume availability of "inline" keyword
@ 2026-02-19 19:19  Tom Lane <tgl@sss.pgh.pa.us>
  parent: Nathan Bossart <nathandbossart@gmail.com>
  0 siblings, 1 reply; 4+ messages in thread

From: Tom Lane @ 2026-02-19 19:19 UTC (permalink / raw)
  To: Nathan Bossart <nathandbossart@gmail.com>; +Cc: pgsql-hackers

Nathan Bossart <nathandbossart@gmail.com> writes:
> I noticed some code that uses __inline__ (which IIUC is a gcc extension) as
> well as a related configure check.  "inline" was first added to C99, and we
> now require C11, so we can just assume it's there, right?  FWIW it looks
> like meson builds don't bother checking this.

All those usages are guarded by

#if defined(__GNUC__) || defined(__INTEL_COMPILER)

so we are only concerned with gcc-alikes, which reduces the risks
of trouble.  However, I have a vague recollection that it is/was
possible to put gcc in a mode where it only takes __inline__
not inline.  This is likely something you get from -std=c90 or
thereabouts, which would be irrelevant now.  But I'd suggest
checking it's okay under -std=c11 (not gnu11), just to be sure.

			regards, tom lane





^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: assume availability of "inline" keyword
@ 2026-02-19 19:54  Nathan Bossart <nathandbossart@gmail.com>
  parent: Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 4+ messages in thread

From: Nathan Bossart @ 2026-02-19 19:54 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: pgsql-hackers

On Thu, Feb 19, 2026 at 02:19:33PM -0500, Tom Lane wrote:
> All those usages are guarded by
> 
> #if defined(__GNUC__) || defined(__INTEL_COMPILER)
> 
> so we are only concerned with gcc-alikes, which reduces the risks
> of trouble.  However, I have a vague recollection that it is/was
> possible to put gcc in a mode where it only takes __inline__
> not inline.  This is likely something you get from -std=c90 or
> thereabouts, which would be irrelevant now.  But I'd suggest
> checking it's okay under -std=c11 (not gnu11), just to be sure.

Right.  I checked a couple of compilers and none seemed to mind this patch
with -std=c11.

-- 
nathan





^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: assume availability of "inline" keyword
@ 2026-02-19 20:40  Nathan Bossart <nathandbossart@gmail.com>
  parent: Nathan Bossart <nathandbossart@gmail.com>
  0 siblings, 0 replies; 4+ messages in thread

From: Nathan Bossart @ 2026-02-19 20:40 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: pgsql-hackers

Committed.

-- 
nathan





^ permalink  raw  reply  [nested|flat] 4+ messages in thread


end of thread, other threads:[~2026-02-19 20:40 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2026-02-19 17:20 assume availability of "inline" keyword Nathan Bossart <nathandbossart@gmail.com>
2026-02-19 19:19 ` Tom Lane <tgl@sss.pgh.pa.us>
2026-02-19 19:54   ` Nathan Bossart <nathandbossart@gmail.com>
2026-02-19 20:40     ` Nathan Bossart <nathandbossart@gmail.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox