remove pg_restrict workaround

From: Peter Eisentraut <peter(at)eisentraut(dot)org>
To: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: remove pg_restrict workaround
Date: 2025-10-15 13:06:18
Message-ID: 0e3d8644-c01d-4374-86ea-9f0a987981f0@eisentraut.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

When in C11 mode, MSVC supports the standard "restrict" keyword, so we
don't need the workaround with using "pg_restrict" instead anymore.
(Just for clarification, restrict is a C99 feature, but MSVC only
accepts it properly in C11 mode.) So I'm proposing to remove that
workaround here, so that code can use the standard restrict keyword
without having to worry about the alternative spelling.

However, "restrict" does not exist in C++, but all supported compilers
support the spelling "__restrict" in C++. Therefore, I'm leaving in
place the Autoconf test and the equivalent Meson business, to maintain
the status quo with respect to C++. I'm updating the comments about
that a bit. (In a C++-free world, we could have plausibly removed the
Autoconf test altogether.)

While making the required adjustments, I found a few pieces of code that
use restrict (previously pg_restrict) in what appears to me to be
nonsensical ways, like

memcpy((char *pg_restrict) (buf->data + buf->len), &ni, sizeof(uint16));

The restrict qualifier is not meaningful in casts, so I'm confused about
why it is used here. I did not find any indications either in the old
discussions leading up to this change or on the wider web that there are
any other interpretations or compiler extensions or perhaps a C++ angle
that would make this meaningful. Also, the generated code appears to be
the same if I remove this. So I'm proposing to remove redundant casts
like this.

Attachment Content-Type Size
0001-Remove-meaninglist-restrict-qualifiers.patch text/plain 2.1 KB
0002-Replace-pg_restrict-by-standard-restrict.patch text/plain 10.9 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Akshay Joshi 2025-10-15 13:37:12 [PATCH] Add pg_get_policy_ddl() function to reconstruct CREATE POLICY statement
Previous Message Shinya Kato 2025-10-15 12:55:57 Re: Add log_autovacuum_{vacuum|analyze}_min_duration