Use C11 alignas instead of palloc/malloc for alignment

From: Peter Eisentraut <peter(at)eisentraut(dot)org>
To: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Use C11 alignas instead of palloc/malloc for alignment
Date: 2026-09-08 10:08:52
Message-ID: 94a128da-bf3e-46bd-9e2d-609573c484da@eisentraut.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

There are a number of places where palloc()/malloc()/etc. was used
solely to obtain an aligned buffer. We can do these much simpler by
using alignas with a local variable instead. See attached patch.

One of these revealed a small problem with how pgindent handles alignas
(it doesn't know about it and it might or might not work well depending
on context), so I added a workaround into pgindent to fix that. (Or we
could try to reshuffle that code to avoid the problem.)

Attachment Content-Type Size
0001-Use-C11-alignas-instead-of-palloc-malloc-for-alignme.patch text/plain 11.4 KB
0002-pgindent-Fix-indentation-of-alignas-in-struct-member.patch text/plain 2.1 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Nazir Bilal Yavuz 2026-09-08 10:11:00 Re: Speed up COPY FROM text/CSV parsing using SIMD
Previous Message Andrei Lepikhov 2026-09-08 10:07:48 Re: [PATCH] Planner support function for generate_subscripts()