remove pg_restrict workaround - Mailing list pgsql-hackers

From Peter Eisentraut
Subject remove pg_restrict workaround
Date
Msg-id 0e3d8644-c01d-4374-86ea-9f0a987981f0@eisentraut.org
Whole thread Raw
Responses Re: remove pg_restrict workaround
List 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

pgsql-hackers by date:

Previous
From: Shinya Kato
Date:
Subject: Re: Add log_autovacuum_{vacuum|analyze}_min_duration
Next
From: Akshay Joshi
Date:
Subject: [PATCH] Add pg_get_policy_ddl() function to reconstruct CREATE POLICY statement