Marking select(2) as restrict

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


On 2018-Feb-25, at 5:51 AM, Konstantin Belousov <kib at freebsd.org> 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:
>> https://github.com/udp/freebsd-libc/blob/master/sys/select.c#L48
>> Which in turn appears to call __sys_select:
>> https://github.com/udp/freebsd-libc/blob/master/include/libc_private.h#L346
>> See also:
>> https://lists.freebsd.org/pipermail/freebsd-questions/2007-August/154906.html
>> 
>> If I understand correctly, the *only* place that defines the
>> optimizations actually being done is the static functions itself:
>> https://github.com/freebsd/freebsd/blob/master/lib/libthr/thread/thr_syscalls.c#L487
> 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 https://en.wikipedia.org/wiki/OpenMandriva_Lx :

"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."

https://wiki.openmandriva.org/en/3.03/Release_Notes#LLVM.2Fclang
reports:

"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."

https://www.openmandriva.org/en/news/article/openmandriva-lx-3-03-get-it-while-it-s-hot
reports:

"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:

https://github.com/OpenMandrivaAssociation/glibc/tree/master

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

For reference for V3.03:
( https://www.openmandriva.org/en/news/article/openmandriva-lx-3-03-get-it-while-it-s-hot )

"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 yahoo.com
( markmi at dsl-only.net is
going away in 2018-Feb, late)



More information about the freebsd-standards mailing list