]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
Shorten pg_attribute_always_inline to pg_always_inline
authorTomas Vondra <tomas.vondra@postgresql.org>
Sat, 11 Jul 2026 13:14:50 +0000 (15:14 +0200)
committerTomas Vondra <tomas.vondra@postgresql.org>
Sat, 11 Jul 2026 13:16:02 +0000 (15:16 +0200)
The pg_attribute_always_inline macro name is so long it forces pgindent
to format the code in strange ways. Which may incentivize patch authors
to either structure the code in strange ways (e.g. reorder prototypes),
use shorter names, etc. Neither is very desirable for code readability.

This shortens the name by removing the _attribute_ part. It also makes
it more consistent with pg_noinline, which does not have the _attribute_
part either.

Backpatched to all supported branches, to prevent conflicts when
backpatching other fixes. The backbranches however keep both the old and
new macro name, so that existing code keeps working.

Author: Andres Freund <andres@anarazel.de>
Reviewed-by: Peter Geoghegan <pg@bowt.ie>
Reviewed-by: Tomas Vondra <tomas@vondra.me>
Discussion: https://postgr.es/m/bqqdehahpoa36igpictuqyn2s2mexk3t3ehidh2ffd2slb35e5@rzgksuiszgbg
Backpatch-through: 14

src/backend/executor/execExprInterp.c
src/backend/executor/execTuples.c
src/backend/executor/nodeHashjoin.c
src/backend/utils/cache/catcache.c
src/include/c.h

index 231a73ec60999c4dd4fedee083f5d097fb56f1b4..a7e7de0d3c0b705d48cf3a96f0d0b8f97b4ea384 100644 (file)
@@ -167,24 +167,24 @@ static Datum ExecJustAssignOuterVarVirt(ExprState *state, ExprContext *econtext,
 static Datum ExecJustAssignScanVarVirt(ExprState *state, ExprContext *econtext, bool *isnull);
 
 /* execution helper functions */
-static pg_attribute_always_inline void ExecEvalArrayCompareInternal(FunctionCallInfo fcinfo,
-                                                                                                                                       ArrayType *arr,
-                                                                                                                                       int16 typlen,
-                                                                                                                                       bool typbyval,
-                                                                                                                                       char typalign,
-                                                                                                                                       bool useOr,
-                                                                                                                                       Datum *result,
-                                                                                                                                       bool *resultnull);
-static pg_attribute_always_inline void ExecAggPlainTransByVal(AggState *aggstate,
-                                                                                                                         AggStatePerTrans pertrans,
-                                                                                                                         AggStatePerGroup pergroup,
-                                                                                                                         ExprContext *aggcontext,
-                                                                                                                         int setno);
-static pg_attribute_always_inline void ExecAggPlainTransByRef(AggState *aggstate,
-                                                                                                                         AggStatePerTrans pertrans,
-                                                                                                                         AggStatePerGroup pergroup,
-                                                                                                                         ExprContext *aggcontext,
-                                                                                                                         int setno);
+static pg_always_inline void ExecEvalArrayCompareInternal(FunctionCallInfo fcinfo,
+                                                                                                                 ArrayType *arr,
+                                                                                                                 int16 typlen,
+                                                                                                                 bool typbyval,
+                                                                                                                 char typalign,
+                                                                                                                 bool useOr,
+                                                                                                                 Datum *result,
+                                                                                                                 bool *resultnull);
+static pg_always_inline void ExecAggPlainTransByVal(AggState *aggstate,
+                                                                                                       AggStatePerTrans pertrans,
+                                                                                                       AggStatePerGroup pergroup,
+                                                                                                       ExprContext *aggcontext,
+                                                                                                       int setno);
+static pg_always_inline void ExecAggPlainTransByRef(AggState *aggstate,
+                                                                                                       AggStatePerTrans pertrans,
+                                                                                                       AggStatePerGroup pergroup,
+                                                                                                       ExprContext *aggcontext,
+                                                                                                       int setno);
 
 /*
  * ScalarArrayOpExprHashEntry
@@ -2065,7 +2065,7 @@ get_cached_rowtype(Oid type_id, int32 typmod,
  */
 
 /* implementation of ExecJust(Inner|Outer|Scan)Var */
-static pg_attribute_always_inline Datum
+static pg_always_inline Datum
 ExecJustVarImpl(ExprState *state, TupleTableSlot *slot, bool *isnull)
 {
        ExprEvalStep *op = &state->steps[1];
@@ -2103,7 +2103,7 @@ ExecJustScanVar(ExprState *state, ExprContext *econtext, bool *isnull)
 }
 
 /* implementation of ExecJustAssign(Inner|Outer|Scan)Var */
-static pg_attribute_always_inline Datum
+static pg_always_inline Datum
 ExecJustAssignVarImpl(ExprState *state, TupleTableSlot *inslot, bool *isnull)
 {
        ExprEvalStep *op = &state->steps[1];
@@ -2198,7 +2198,7 @@ ExecJustConst(ExprState *state, ExprContext *econtext, bool *isnull)
 }
 
 /* implementation of ExecJust(Inner|Outer|Scan)VarVirt */
-static pg_attribute_always_inline Datum
+static pg_always_inline Datum
 ExecJustVarVirtImpl(ExprState *state, TupleTableSlot *slot, bool *isnull)
 {
        ExprEvalStep *op = &state->steps[0];
@@ -2241,7 +2241,7 @@ ExecJustScanVarVirt(ExprState *state, ExprContext *econtext, bool *isnull)
 }
 
 /* implementation of ExecJustAssign(Inner|Outer|Scan)VarVirt */
-static pg_attribute_always_inline Datum
+static pg_always_inline Datum
 ExecJustAssignVarVirtImpl(ExprState *state, TupleTableSlot *inslot, bool *isnull)
 {
        ExprEvalStep *op = &state->steps[0];
@@ -3395,7 +3395,7 @@ ExecEvalScalarArrayOp(ExprState *state, ExprEvalStep *op)
  * Callers must handle the strict LHS-is-NULL; return NULL fast path prior to
  * calling this.
  */
-static pg_attribute_always_inline void
+static pg_always_inline void
 ExecEvalArrayCompareInternal(FunctionCallInfo fcinfo, ArrayType *arr,
                                                         int16 typlen, bool typbyval, char typalign,
                                                         bool useOr, Datum *result, bool *resultnull)
@@ -4409,7 +4409,7 @@ ExecEvalAggOrderedTransTuple(ExprState *state, ExprEvalStep *op,
 }
 
 /* implementation of transition function invocation for byval types */
-static pg_attribute_always_inline void
+static pg_always_inline void
 ExecAggPlainTransByVal(AggState *aggstate, AggStatePerTrans pertrans,
                                           AggStatePerGroup pergroup,
                                           ExprContext *aggcontext, int setno)
@@ -4441,7 +4441,7 @@ ExecAggPlainTransByVal(AggState *aggstate, AggStatePerTrans pertrans,
 }
 
 /* implementation of transition function invocation for byref types */
-static pg_attribute_always_inline void
+static pg_always_inline void
 ExecAggPlainTransByRef(AggState *aggstate, AggStatePerTrans pertrans,
                                           AggStatePerGroup pergroup,
                                           ExprContext *aggcontext, int setno)
index 06ac253ea0c7045026fd6e998baf330bc72db2d5..e563a6d453025f27944a20b20b111c1dbee439ab 100644 (file)
@@ -71,8 +71,8 @@
 
 static TupleDesc ExecTypeFromTLInternal(List *targetList,
                                                                                bool skipjunk);
-static pg_attribute_always_inline void slot_deform_heap_tuple(TupleTableSlot *slot, HeapTuple tuple, uint32 *offp,
-                                                                                                                         int natts);
+static pg_always_inline void slot_deform_heap_tuple(TupleTableSlot *slot, HeapTuple tuple, uint32 *offp,
+                                                                                                       int natts);
 static inline void tts_buffer_heap_store_tuple(TupleTableSlot *slot,
                                                                                           HeapTuple tuple,
                                                                                           Buffer buffer,
@@ -921,7 +921,7 @@ tts_buffer_heap_store_tuple(TupleTableSlot *slot, HeapTuple tuple,
  * This is marked as always inline, so the different offp for different types
  * of slots gets optimized away.
  */
-static pg_attribute_always_inline void
+static pg_always_inline void
 slot_deform_heap_tuple(TupleTableSlot *slot, HeapTuple tuple, uint32 *offp,
                                           int natts)
 {
index f29b5d539d5d7de9bc3b646bacc927966cef0ed1..9486cb08ae2a088d79c119ed2bee01f718f7a5f5 100644 (file)
@@ -167,7 +167,7 @@ static void ExecParallelHashJoinPartitionOuter(HashJoinState *node);
  *                       the other one is "outer".
  * ----------------------------------------------------------------
  */
-static pg_attribute_always_inline TupleTableSlot *
+static pg_always_inline TupleTableSlot *
 ExecHashJoinImpl(PlanState *pstate, bool parallel)
 {
        HashJoinState *node = castNode(HashJoinState, pstate);
index a70a8f7b3292cf0ac44b20e343bcc0cf0358e8f0..322bfd5415ef9a3d980f55856c9d150e8a56c7b2 100644 (file)
@@ -942,7 +942,7 @@ RehashCatCache(CatCache *cp)
  *
  * Call CatalogCacheInitializeCache() if not yet done.
  */
-pg_attribute_always_inline
+pg_always_inline
 static void
 ConditionalCatalogCacheInitializeCache(CatCache *cache)
 {
index 4d0c81583f282bbaf2daf77da89082b852730cc9..ebe694bff9036be942f47e43c8cacfb2d978d00c 100644 (file)
 #endif
 
 /*
- * Use "pg_attribute_always_inline" in place of "inline" for functions that
+ * Use "pg_always_inline" in place of "inline" for functions that
  * we wish to force inlining of, even when the compiler's heuristics would
  * choose not to.  But, if possible, don't force inlining in unoptimized
  * debug builds.
+ *
+ * XXX The "pg_attribute_always_inline" variant is kept for backwards
+ * compatibility with existing code. All new code should use the shorter
+ * variant "pg_always_inline."
  */
 #if (defined(__GNUC__) && __GNUC__ > 3 && defined(__OPTIMIZE__)) || defined(__SUNPRO_C) || defined(__IBMC__)
 /* GCC > 3, Sunpro and XLC support always_inline via __attribute__ */
+#define pg_always_inline __attribute__((always_inline)) inline
 #define pg_attribute_always_inline __attribute__((always_inline)) inline
 #elif defined(_MSC_VER)
 /* MSVC has a special keyword for this */
+#define pg_always_inline __forceinline
 #define pg_attribute_always_inline __forceinline
 #else
 /* Otherwise, the best we can do is to say "inline" */
+#define pg_always_inline inline
 #define pg_attribute_always_inline inline
 #endif