Marking select(2) as restrict

Mark Millard marklmi26-fbsd at
Sun Feb 25 17:42:18 UTC 2018

On 2018-Feb-25, at 5:51 AM, Konstantin Belousov <kib at> wrote:

> On Sun, Feb 25, 2018 at 06:52:55AM +0100, Stefan Blachmann wrote:
>> The Linux manual pages do not mention restrict for select().
>> glibc select() itself returns just ENOSYS(), if there is no alias for select().
>> So I guess what actually gets called is this:
>> Which in turn appears to call __sys_select:
>> See also:
>> If I understand correctly, the *only* place that defines the
>> optimizations actually being done is the static functions itself:
> No, you do not understand this correctly. Select(2) implementation is
> in kernel and cannot be affected by the userspace prototype change. It
> is the caller of select(2) which might be optimized unexpectedly when
> select claims that its arguments cannot be aliased.
> The use of restrict in the glibc prototype would be a good argument if
> clang on glibc were not a rare combination.

I'm only noting where some evidence might be available . . .

My understanding is that there is (at least) one desktop Linux
distribution that is clang based: OpenMadriva Lx. It may be a
source of information. Checking a little into its status . . .

From :

"A beta release of OpenMandriva Lx 3.0 was released in June 2016.[19]
This new release came with significant changes to the core system
- among other things, it was the first desktop Linux distribution
that was built completely with the Clang compiler instead of GCC."

"OpenMandriva provides LLVM/clang 5.0.0 as the default compiler,
GCC is also available. Over 90% of packages in our main repository
are now built with LLVM/clang."

"Everything with this release, including the new Firefox Quantum
57, is compiled with LLVM/clang 5.0.0"

Looking quickly, there is glibc source involved:

(There are other branches, such a 3.0 branch.) I have not
analyzed the patches that they use.

For reference for V3.03:
( )

"At the hardware level there is an up-to-date kernel at 4.13.12
release and systemd 234 and for your graphics stack mesa 17.2.3
with a S3TC support enabled and xorg 1.19.5."

"Our main desktop environment KDE Plasma is updated to 5.10.5
and Frameworks are at 5.39."

Mark Millard
marklmi at
( markmi at is
going away in 2018-Feb, late)

More information about the freebsd-standards mailing list