]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
Use C11 alignas in typedef definitions
authorPeter Eisentraut <peter@eisentraut.org>
Mon, 16 Mar 2026 09:41:38 +0000 (10:41 +0100)
committerPeter Eisentraut <peter@eisentraut.org>
Mon, 16 Mar 2026 10:35:51 +0000 (11:35 +0100)
They were already using pg_attribute_aligned.  This replaces that with
alignas and moves that into the required syntactic position.

Suggested-by: Peter Eisentraut <peter@eisentraut.org>
Author: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
Discussion: https://postgr.es/m/d7a788fa-e609-4894-a8be-2f70e135424f%40eisentraut.org

src/backend/storage/aio/method_io_uring.c
src/include/storage/proc.h

index ed6e71bcd4631a1807eda1c29eb0a9877cf8cdca..4867ded35ea4f0c87a179d5db8042247bbb5781f 100644 (file)
@@ -79,13 +79,15 @@ const IoMethodOps pgaio_uring_ops = {
 
 /*
  * Per-backend state when using io_method=io_uring
- *
- * Align the whole struct to a cacheline boundary, to prevent false sharing
- * between completion_lock and prior backend's io_uring_ring.
  */
-typedef struct pg_attribute_aligned (PG_CACHE_LINE_SIZE)
-PgAioUringContext
+typedef struct PgAioUringContext
 {
+       /*
+        * Align the whole struct to a cacheline boundary, to prevent false
+        * sharing between completion_lock and prior backend's io_uring_ring.
+        */
+       alignas(PG_CACHE_LINE_SIZE)
+
        /*
         * Multiple backends can process completions for this backend's io_uring
         * instance (e.g. when the backend issuing IO is busy doing something
index 3f89450c21635cdb16eb225eafa71a00fb37f6b5..bf3094f0f7d95d79378080d7f7b8e407d047e617 100644 (file)
@@ -180,6 +180,11 @@ typedef enum
  */
 typedef struct PGPROC
 {
+       /*
+        * Align the struct at cache line boundaries.  This is just for
+        * performance, to avoid false sharing.
+        */
+       alignas(PG_CACHE_LINE_SIZE)
        dlist_head *procgloballist; /* procglobal list that owns this PGPROC */
        dlist_node      freeProcsLink;  /* link in procgloballist, when in recycled
                                                                 * state */
@@ -375,14 +380,6 @@ typedef struct PGPROC
 
        uint32          wait_event_info;        /* proc's wait information */
 }
-
-/*
- * If compiler understands aligned pragma, use it to align the struct at cache
- * line boundaries.  This is just for performance, to avoid false sharing.
- */
-#if defined(pg_attribute_aligned)
-                       pg_attribute_aligned(PG_CACHE_LINE_SIZE)
-#endif
 PGPROC;
 
 extern PGDLLIMPORT PGPROC *MyProc;