Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

Houston, Tranquillity Base here. The Eagle has landed. -- Neil Armstrong


devel / comp.lang.c / Re: Word For Today: “Uglification”

SubjectAuthor
* Word For Today: “Uglification”Lawrence D'Oliveiro
+* Re: Word For Today: “Uglification”Keith Thompson
|`* Re: Word For Today: “Uglification”Lawrence D'Oliveiro
| `- Re: Word For Today: “Uglification”Keith Thompson
+* Re: Word For Today: “Uglification”Kaz Kylheku
|`* Re: Word For Today: “Uglification”Tim Rentsch
| `* Re: Word For Today: “Uglification”Keith Thompson
|  +* Re: Word For Today: “Uglification”Scott Lurndal
|  |+- Re: Word For Today: “Uglification”Scott Lurndal
|  |`* Re: Word For Today: “Uglification”Keith Thompson
|  | +- Re: Word For Today: “Uglification”Scott Lurndal
|  | `- Re: Word For Today: “Uglification”David Brown
|  +* Re: Word For Today: “Uglification”Keith Thompson
|  |`* Re: Word For Today: “Uglification”Scott Lurndal
|  | `* Re: Word For Today: “Uglification”Keith Thompson
|  |  `* Re: Word For Today: “Uglification”Kaz Kylheku
|  |   `* Re: Word For Today: “Uglification”Keith Thompson
|  |    `- Re: Word For Today: “Uglification”David Brown
|  `- Re: Word For Today: “Uglification”Tim Rentsch
+* Re: Word For Today: “Uglification”James Kuyper
|`* Re: Word For Today: “Uglification”Lawrence D'Oliveiro
| +- Re: Word For Today: “Uglification”Lawrence D'Oliveiro
| +* Re: Word For Today: “Uglification”Kaz Kylheku
| |`* Re: Word For Today: “Uglification”Richard Kettlewell
| | +* Re: Word For Today: “Uglification”David Brown
| | |+* Re: Word For Today: “Uglification”Anton Shepelev
| | ||`* Re: Word For Today: “Uglification”bart
| | || +* Re: Word For Today: “Uglification”Anton Shepelev
| | || |`* Re: Word For Today: “Uglification”bart
| | || | `* Re: Word For Today: “Uglification”Kaz Kylheku
| | || |  `* Re: Word For Today: “Uglification”bart
| | || |   +* Re: Word For Today: “Uglification”Keith Thompson
| | || |   |+* Re: Word For Today: “Uglification”bart
| | || |   ||+* Re: Word For Today: “Uglification”Michael S
| | || |   |||+* Re: Word For Today: “Uglification”Keith Thompson
| | || |   ||||`* Re: Word For Today: “Uglification”David Brown
| | || |   |||| `* Re: Word For Today: “Uglification”Keith Thompson
| | || |   ||||  `- Re: Word For Today: “Uglification”David Brown
| | || |   |||+- Re: Word For Today: “Uglification”David Brown
| | || |   |||`- Re: Word For Today: “Uglification”Kaz Kylheku
| | || |   ||`* Re: Word For Today: “Uglification”Keith Thompson
| | || |   || `- Re: Word For Today: “Uglification”bart
| | || |   |`- Re: Word For Today: “Uglification”Nick Bowler
| | || |   `- Re: Word For Today: “Uglification”Kaz Kylheku
| | || `- Re: Word For Today: “Uglification”Kaz Kylheku
| | |`- Re: Word For Today: “Uglification”Blue-Maned_Hawk
| | `* Re: Word For Today: “Uglification”Lawrence D'Oliveiro
| |  +* Re: Word For Today: “Uglification”Keith Thompson
| |  |`* Re: Word For Today: “Uglification”Richard Kettlewell
| |  | `* Re: Word For Today: “Uglification”Keith Thompson
| |  |  `* Re: Word For Today: “Uglification”Lawrence D'Oliveiro
| |  |   +- Re: Word For Today: “Uglification”Kaz Kylheku
| |  |   +- Re: Word For Today: “Uglification”Keith Thompson
| |  |   `* Re: Word For Today: “Uglification”Scott Lurndal
| |  |    `* Re: Word For Today: “Uglification”Lawrence D'Oliveiro
| |  |     +* Re: Word For Today: “Uglification”Keith Thompson
| |  |     |+- Re: Word For Today: “Uglification”Richard Kettlewell
| |  |     |`- Re: Word For Today: “Uglification”Kaz Kylheku
| |  |     `- Re: Word For Today: “Uglification”Scott Lurndal
| |  `- Re: Word For Today: “Uglification”Kaz Kylheku
| `* Re: Word For Today: “Uglification”James Kuyper
|  `* Re: Word For Today: “Uglification”Lawrence D'Oliveiro
|   +- Re: Word For Today: “Uglification”Keith Thompson
|   `* Re: Word For Today: “Uglification”James Kuyper
|    `* Re: Word For Today: “Uglification”Lawrence D'Oliveiro
|     +- Re: Word For Today: “Uglification”Kaz Kylheku
|     `- Re: Word For Today: “Uglification”James Kuyper
`- Re: Word For Today: “Uglification”Kaz Kylheku

Pages:123
Re: Word For Today: “Uglification”

<VrqIN.117152$GX69.42500@fx46.iad>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=34361&group=comp.lang.c#34361

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!newsfeed.endofthelinebbs.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx46.iad.POSTED!not-for-mail
X-newsreader: xrn 9.03-beta-14-64bit
Sender: scott@dragon.sl.home (Scott Lurndal)
From: sco...@slp53.sl.home (Scott Lurndal)
Reply-To: slp53@pacbell.net
Subject: Re: Word For Today: “Uglification”
Newsgroups: comp.lang.c
References: <uso6or$3t3jn$3@dont-email.me> <usopec$4eob$1@dont-email.me> <usort1$4t2r$1@dont-email.me> <20240312003531.349@kylheku.com> <wwvwmq7x4ex.fsf@LkoBDZeT.terraraq.uk> <usqnji$i40m$2@dont-email.me> <871q8f81wo.fsf@nosuchdomain.example.com> <wwvcyrysdyl.fsf@LkoBDZeT.terraraq.uk> <87jzm66uiz.fsf@nosuchdomain.example.com> <ust74s$15mv5$3@dont-email.me> <yQpIN.107778$SyNd.20359@fx33.iad> <ustaiu$16ghu$2@dont-email.me>
Lines: 27
Message-ID: <VrqIN.117152$GX69.42500@fx46.iad>
X-Complaints-To: abuse@usenetserver.com
NNTP-Posting-Date: Wed, 13 Mar 2024 23:15:01 UTC
Organization: UsenetServer - www.usenetserver.com
Date: Wed, 13 Mar 2024 23:15:01 GMT
X-Received-Bytes: 1987
 by: Scott Lurndal - Wed, 13 Mar 2024 23:15 UTC

Lawrence D'Oliveiro <ldo@nz.invalid> writes:
>On Wed, 13 Mar 2024 22:33:02 GMT, Scott Lurndal wrote:
>
>> Third party libraries are allowed to use any mechanism they like to
>> minimize name conflicts other than prefixing with two underscores.
>
>But there is no other such mechanism available.

Of course there is. The most simple is to prefix
any external symbols with a library specific
prefix.

Or to suffix any symbol with two underscore characters
and a library-specific string.

Or obfuscate the extern symbols in the library and use #define
macros to map a readable name to the obfuscated symbol
in the corresponding header file(s).

As has been pointed out, extending the double-leading
underscore mechanism outside the implementation requires
some central authority to manage names across all
third-party libraries. (which is generally true for any prefix
mechanism, whether it is __ or fubar_).

We seem to have survived just fine without any such
disambiguation mechanism to date.

Re: Word For Today: “Uglification”

<wwvcyrxiu7v.fsf@LkoBDZeT.terraraq.uk>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=34362&group=comp.lang.c#34362

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!news.nntp4.net!nntp.terraraq.uk!.POSTED.tunnel.sfere.anjou.terraraq.org.uk!not-for-mail
From: inva...@invalid.invalid (Richard Kettlewell)
Newsgroups: comp.lang.c
Subject: Re: Word For Today: “Uglification”
Date: Wed, 13 Mar 2024 23:32:20 +0000
Organization: terraraq NNTP server
Message-ID: <wwvcyrxiu7v.fsf@LkoBDZeT.terraraq.uk>
References: <uso6or$3t3jn$3@dont-email.me> <usopec$4eob$1@dont-email.me>
<usort1$4t2r$1@dont-email.me> <20240312003531.349@kylheku.com>
<wwvwmq7x4ex.fsf@LkoBDZeT.terraraq.uk> <usqnji$i40m$2@dont-email.me>
<871q8f81wo.fsf@nosuchdomain.example.com>
<wwvcyrysdyl.fsf@LkoBDZeT.terraraq.uk>
<87jzm66uiz.fsf@nosuchdomain.example.com>
<ust74s$15mv5$3@dont-email.me> <yQpIN.107778$SyNd.20359@fx33.iad>
<ustaiu$16ghu$2@dont-email.me>
<878r2l68bo.fsf@nosuchdomain.example.com>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: innmantic.terraraq.uk; posting-host="tunnel.sfere.anjou.terraraq.org.uk:172.17.207.6";
logging-data="70233"; mail-complaints-to="usenet@innmantic.terraraq.uk"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux)
Cancel-Lock: sha1:Lxf6l7jQ83f96lk450V/n0HtyPE=
X-Face: h[Hh-7npe<<b4/eW[]sat,I3O`t8A`(ej.H!F4\8|;ih)`7{@:A~/j1}gTt4e7-n*F?.Rl^
F<\{jehn7.KrO{!7=:(@J~]<.[{>v9!1<qZY,{EJxg6?Er4Y7Ng2\Ft>Z&W?r\c.!4DXH5PWpga"ha
+r0NzP?vnz:e/knOY)PI-
X-Boydie: NO
 by: Richard Kettlewell - Wed, 13 Mar 2024 23:32 UTC

Keith Thompson <Keith.S.Thompson+u@gmail.com> writes:
> Lawrence D'Oliveiro <ldo@nz.invalid> writes:
>> On Wed, 13 Mar 2024 22:33:02 GMT, Scott Lurndal wrote:
>>> Third party libraries are allowed to use any mechanism they like to
>>> minimize name conflicts other than prefixing with two underscores.
>>
>> But there is no other such mechanism available.
>
> Are you aware that working third party libraries exist, and name
> collisions are fairly rare? How do you think that's possible?
>
> There are no 100% reliable mechanisms. There are mechanisms that work
> well enough in practice, including using library-specific prefixes.

The collisions I recall running into are library headers defining things
like MIN, MAX, TRUE, FALSE - useful in isolation, but a nuisance when
more than one library does it.

Actually the offending headers that spring are mind are supplied by the
implementor of the platform they support, albeit that the headers
involved are not ones specified in standard C.

--
https://www.greenend.org.uk/rjk/

Re: Word For Today: “Uglification”

<20240313172324.87@kylheku.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=34363&group=comp.lang.c#34363

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: 433-929-...@kylheku.com (Kaz Kylheku)
Newsgroups: comp.lang.c
Subject: Re: Word For Today: “Uglification”
Date: Thu, 14 Mar 2024 00:40:31 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 42
Message-ID: <20240313172324.87@kylheku.com>
References: <uso6or$3t3jn$3@dont-email.me> <usopec$4eob$1@dont-email.me>
<usort1$4t2r$1@dont-email.me> <20240312003531.349@kylheku.com>
<wwvwmq7x4ex.fsf@LkoBDZeT.terraraq.uk> <usqnji$i40m$2@dont-email.me>
<871q8f81wo.fsf@nosuchdomain.example.com>
<wwvcyrysdyl.fsf@LkoBDZeT.terraraq.uk>
<87jzm66uiz.fsf@nosuchdomain.example.com> <ust74s$15mv5$3@dont-email.me>
<yQpIN.107778$SyNd.20359@fx33.iad> <ustaiu$16ghu$2@dont-email.me>
<878r2l68bo.fsf@nosuchdomain.example.com>
Injection-Date: Thu, 14 Mar 2024 00:40:31 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="5144a5b70d2242e56a2fa01db8244180";
logging-data="1308624"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+/VU4Wft0H9dC6rcW6MvqgJoeaxXoz6p4="
User-Agent: slrn/pre1.0.4-9 (Linux)
Cancel-Lock: sha1:bX3FD2/Dq88wa38gAuKWc22mtOk=
 by: Kaz Kylheku - Thu, 14 Mar 2024 00:40 UTC

On 2024-03-13, Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote:
> Lawrence D'Oliveiro <ldo@nz.invalid> writes:
>> On Wed, 13 Mar 2024 22:33:02 GMT, Scott Lurndal wrote:
>>> Third party libraries are allowed to use any mechanism they like to
>>> minimize name conflicts other than prefixing with two underscores.
>>
>> But there is no other such mechanism available.
>
> Are you aware that working third party libraries exist, and name
> collisions are fairly rare? How do you think that's possible?

It's possible because firstly, even if there are collisions latent
in the library mixture, not all libraries are used together in one
application. E.g. in an OS distro installation there might be a thousand
libraries, but no application uses all thousand.

Secondly, even if two libraries are used in the same application, where
those libraries have a header-file-level clash, the clash only occurs if
their headers are included in the same translation unit in that program.

Thirdly, mere linkage of two libraries into the same program can only
cause a clash if it involves an external name.

Fourth, even if two libraries have a clashing external name, I think
that under certain dynamic linking paradigms, this is only a problem if
that name is used. If the same name refers to multiple entities, there
is an ambiguity, but if the program doesn't use that name, then the
ambiguity doesn't matter.

Fifth, if we are talking specifically about names used by macros for
naming local symbols inserted into the program, libraries not in the C
implementation in fact can get away with using the __ space. If these
identifiers don't land on a compiler keyword, there is no actual
problem. Now a third party library could choose such a name inside its
macro such that the C library has also used the same name inside its
macro. But for that to cause a clash, the macros have to be nested
together.

--
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
Mastodon: @Kazinator@mstdn.ca

Re: Word For Today: “Uglification”

<usthef$17uno$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=34364&group=comp.lang.c#34364

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: jameskuy...@alumni.caltech.edu (James Kuyper)
Newsgroups: comp.lang.c
Subject: Re: Word For Today: “Uglification”
Date: Wed, 13 Mar 2024 20:47:11 -0400
Organization: A noiseless patient Spider
Lines: 11
Message-ID: <usthef$17uno$1@dont-email.me>
References: <uso6or$3t3jn$3@dont-email.me> <usopec$4eob$1@dont-email.me>
<usort1$4t2r$1@dont-email.me> <usptlp$c79g$1@dont-email.me>
<usqhjg$gpvk$2@dont-email.me> <usrl1b$r66p$1@dont-email.me>
<ust76r$15mv5$4@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 14 Mar 2024 00:47:11 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="671a4c3da01f59f5ddbd946adf4aea6e";
logging-data="1309432"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/IJKnminP67WgT0lGyGHw0rFab9J7AHEA="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:oYflL4H3knyKU8mq6pxdYcoAnmQ=
In-Reply-To: <ust76r$15mv5$4@dont-email.me>
Content-Language: en-US
 by: James Kuyper - Thu, 14 Mar 2024 00:47 UTC

On 3/13/24 17:52, Lawrence D'Oliveiro wrote:
> On Wed, 13 Mar 2024 03:36:11 -0400, James Kuyper wrote:
>
>> Yes, I do, and so do implementors. Avoiding those clashes is their
>> responsibility.
>
> Implementors of the C standard? What about providers of other libraries?

Avoiding conflicts is their responsibility, obviously. As a general
rule, they do so by choosing a library-specific prefix to use on all
identifiers that might otherwise cause problems.

Re: Word For Today: “Uglification”

<86v85opw22.fsf@linuxsc.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=34367&group=comp.lang.c#34367

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: tr.17...@z991.linuxsc.com (Tim Rentsch)
Newsgroups: comp.lang.c
Subject: Re: Word For Today: “Uglification”
Date: Thu, 14 Mar 2024 10:23:01 -0700
Organization: A noiseless patient Spider
Lines: 41
Message-ID: <86v85opw22.fsf@linuxsc.com>
References: <uso6or$3t3jn$3@dont-email.me> <20240311202758.193@kylheku.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: dont-email.me; posting-host="c73a7ccbfb7c95d529f92c065d1adb1d";
logging-data="1848520"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+eoFjP5Vud+pw6wi4bhOooTyESzXJeZBg="
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:bUYoQLcnkX2HROUkHuoBfFj6uJQ=
sha1:teNrWkPsjkal8+GMgKX+uRnxifM=
 by: Tim Rentsch - Thu, 14 Mar 2024 17:23 UTC

Kaz Kylheku <433-929-6894@kylheku.com> writes:

[some editing of white space done]

> On 2024-03-12, Lawrence D'Oliveiro <ldo@nz.invalid> wrote:
>
>> From /usr/include/<<arch>>/bits/select.h on my Debian system:
>>
>> #define __FD_ZERO(s) \
>> do { \
>> unsigned int __i; \
>> fd_set *__arr = (s); \
>
> This assignment has value; it checks that, loosely speaking,
> s is an "assignment compatible" pointer with a fd_set *,
> so that there is a diagnostic if the macro is applied to
> an object of the wrong type.

More to the point, if the macro is applied to a value of the wrong
type.

>> for (__i = 0; __i < sizeof (fd_set) / sizeof (__fd_mask); ++__i) \
>> __FDS_BITS (__arr)[__i] = 0; \
>
> Here, I would have done memset(__arr, 0, sizeof *__arr).

That assumes that it is the entire fd_set that needs to be zeroed,
which may not be right. Note the call to the __FDS_BITS() macro.

Better:

#define __FD_ZERO(s) ( \
(void) memset( \
__FDS_BITS( (fd_set*){(s)} ), 0, sizeof __FDS_BITS( (fd_set*){0} ) \
) \
)

This definition: avoids introducing any new identifiers; checks
that the argument s yields an assignment compatible pointer; and
provides a macro that can be used as a void expression (unlike the
original macro definition, which can be used only as a statement).

Re: Word For Today: “Uglification”

<87v85o4i1v.fsf@nosuchdomain.example.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=34371&group=comp.lang.c#34371

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Keith.S....@gmail.com (Keith Thompson)
Newsgroups: comp.lang.c
Subject: Re: Word For Today: “Uglification”
Date: Thu, 14 Mar 2024 14:31:08 -0700
Organization: None to speak of
Lines: 97
Message-ID: <87v85o4i1v.fsf@nosuchdomain.example.com>
References: <uso6or$3t3jn$3@dont-email.me> <20240311202758.193@kylheku.com>
<86v85opw22.fsf@linuxsc.com>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="c21b1ebd01dd0ccb23ead5461c6d1b5d";
logging-data="1963357"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/RKkxCMNi7SRqus7nInI/T"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:ZBAvnyKA4ggq6KMJAMT5aFmvYUE=
sha1:PrQkLf/vHY/7ZvCKTEzS9adR3JY=
 by: Keith Thompson - Thu, 14 Mar 2024 21:31 UTC

Tim Rentsch <tr.17687@z991.linuxsc.com> writes:
> Kaz Kylheku <433-929-6894@kylheku.com> writes:
>
> [some editing of white space done]
>
>> On 2024-03-12, Lawrence D'Oliveiro <ldo@nz.invalid> wrote:
>>
>>> From /usr/include/<<arch>>/bits/select.h on my Debian system:
>>>
>>> #define __FD_ZERO(s) \
>>> do { \
>>> unsigned int __i; \
>>> fd_set *__arr = (s); \
>>
>> This assignment has value; it checks that, loosely speaking,
>> s is an "assignment compatible" pointer with a fd_set *,
>> so that there is a diagnostic if the macro is applied to
>> an object of the wrong type.
>
> More to the point, if the macro is applied to a value of the wrong
> type.
>
>>> for (__i = 0; __i < sizeof (fd_set) / sizeof (__fd_mask); ++__i) \
>>> __FDS_BITS (__arr)[__i] = 0; \
>>
>> Here, I would have done memset(__arr, 0, sizeof *__arr).
>
> That assumes that it is the entire fd_set that needs to be zeroed,
> which may not be right. Note the call to the __FDS_BITS() macro.
>
> Better:
>
> #define __FD_ZERO(s) ( \
> (void) memset( \
> __FDS_BITS( (fd_set*){(s)} ), 0, sizeof __FDS_BITS( (fd_set*){0} ) \
> ) \
> )
>
> This definition: avoids introducing any new identifiers; checks
> that the argument s yields an assignment compatible pointer; and
> provides a macro that can be used as a void expression (unlike the
> original macro definition, which can be used only as a statement).

For context, here's the entire file from my system (Ubuntu 24.0.4,
package libc6-dev:amd64 2.35-0ubuntu3.6). I get the impression that the
author(s) decided not to use memset to avoid the required #include,
which might increase compilation times for code that indirectly includes
this header. (I offer no opinion on whether that's a good tradeoff.)

Note that __FD_ZERO is very clearly *not* intended to be invoked by
arbitrary code.

```
/* Copyright (C) 1997-2022 Free Software Foundation, Inc.
This file is part of the GNU C Library.

The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<https://www.gnu.org/licenses/>. */

#ifndef _SYS_SELECT_H
# error "Never use <bits/select.h> directly; include <sys/select.h> instead."
#endif

/* We don't use `memset' because this would require a prototype and
the array isn't too big. */
#define __FD_ZERO(s) \
do { \
unsigned int __i; \
fd_set *__arr = (s); \
for (__i = 0; __i < sizeof (fd_set) / sizeof (__fd_mask); ++__i) \
__FDS_BITS (__arr)[__i] = 0; \
} while (0)
#define __FD_SET(d, s) \
((void) (__FDS_BITS (s)[__FD_ELT(d)] |= __FD_MASK(d)))
#define __FD_CLR(d, s) \
((void) (__FDS_BITS (s)[__FD_ELT(d)] &= ~__FD_MASK(d)))
#define __FD_ISSET(d, s) \
((__FDS_BITS (s)[__FD_ELT (d)] & __FD_MASK (d)) != 0)

```

--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Working, but not speaking, for Medtronic
void Void(void) { Void(); } /* The recursive call of the void */

Re: Word For Today: “Uglification”

<bbMIN.411923$vFZa.142318@fx13.iad>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=34378&group=comp.lang.c#34378

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx13.iad.POSTED!not-for-mail
X-newsreader: xrn 9.03-beta-14-64bit
Sender: scott@dragon.sl.home (Scott Lurndal)
From: sco...@slp53.sl.home (Scott Lurndal)
Reply-To: slp53@pacbell.net
Subject: Re: Word For Today: “Uglification”
Newsgroups: comp.lang.c
References: <uso6or$3t3jn$3@dont-email.me> <20240311202758.193@kylheku.com> <86v85opw22.fsf@linuxsc.com> <87v85o4i1v.fsf@nosuchdomain.example.com>
Lines: 110
Message-ID: <bbMIN.411923$vFZa.142318@fx13.iad>
X-Complaints-To: abuse@usenetserver.com
NNTP-Posting-Date: Thu, 14 Mar 2024 23:59:03 UTC
Organization: UsenetServer - www.usenetserver.com
Date: Thu, 14 Mar 2024 23:59:03 GMT
X-Received-Bytes: 5549
 by: Scott Lurndal - Thu, 14 Mar 2024 23:59 UTC

Keith Thompson <Keith.S.Thompson+u@gmail.com> writes:
>Tim Rentsch <tr.17687@z991.linuxsc.com> writes:
>> Kaz Kylheku <433-929-6894@kylheku.com> writes:
>>
>> [some editing of white space done]
>>
>>> On 2024-03-12, Lawrence D'Oliveiro <ldo@nz.invalid> wrote:
>>>
>>>> From /usr/include/<<arch>>/bits/select.h on my Debian system:
>>>>
>>>> #define __FD_ZERO(s) \
>>>> do { \
>>>> unsigned int __i; \
>>>> fd_set *__arr = (s); \
>>>
>>> This assignment has value; it checks that, loosely speaking,
>>> s is an "assignment compatible" pointer with a fd_set *,
>>> so that there is a diagnostic if the macro is applied to
>>> an object of the wrong type.
>>
>> More to the point, if the macro is applied to a value of the wrong
>> type.
>>
>>>> for (__i = 0; __i < sizeof (fd_set) / sizeof (__fd_mask); ++__i) \
>>>> __FDS_BITS (__arr)[__i] = 0; \
>>>
>>> Here, I would have done memset(__arr, 0, sizeof *__arr).
>>
>> That assumes that it is the entire fd_set that needs to be zeroed,
>> which may not be right. Note the call to the __FDS_BITS() macro.
>>
>> Better:
>>
>> #define __FD_ZERO(s) ( \
>> (void) memset( \
>> __FDS_BITS( (fd_set*){(s)} ), 0, sizeof __FDS_BITS( (fd_set*){0} ) \
>> ) \
>> )
>>
>> This definition: avoids introducing any new identifiers; checks
>> that the argument s yields an assignment compatible pointer; and
>> provides a macro that can be used as a void expression (unlike the
>> original macro definition, which can be used only as a statement).
>
>For context, here's the entire file from my system (Ubuntu 24.0.4,
>package libc6-dev:amd64 2.35-0ubuntu3.6). I get the impression that the
>author(s) decided not to use memset to avoid the required #include,
>which might increase compilation times for code that indirectly includes
>this header. (I offer no opinion on whether that's a good tradeoff.)
>
>Note that __FD_ZERO is very clearly *not* intended to be invoked by
>arbitrary code.
>
>```
>/* Copyright (C) 1997-2022 Free Software Foundation, Inc.
> This file is part of the GNU C Library.
>
> The GNU C Library is free software; you can redistribute it and/or
> modify it under the terms of the GNU Lesser General Public
> License as published by the Free Software Foundation; either
> version 2.1 of the License, or (at your option) any later version.
>
> The GNU C Library is distributed in the hope that it will be useful,
> but WITHOUT ANY WARRANTY; without even the implied warranty of
> MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> Lesser General Public License for more details.
>
> You should have received a copy of the GNU Lesser General Public
> License along with the GNU C Library; if not, see
> <https://www.gnu.org/licenses/>. */
>
>#ifndef _SYS_SELECT_H
># error "Never use <bits/select.h> directly; include <sys/select.h> instead."
>#endif
>
>
>/* We don't use `memset' because this would require a prototype and
> the array isn't too big. */
>#define __FD_ZERO(s) \
> do { \
> unsigned int __i; \
> fd_set *__arr = (s); \
> for (__i = 0; __i < sizeof (fd_set) / sizeof (__fd_mask); ++__i) \
> __FDS_BITS (__arr)[__i] = 0; \
> } while (0)
>#define __FD_SET(d, s) \
> ((void) (__FDS_BITS (s)[__FD_ELT(d)] |= __FD_MASK(d)))
>#define __FD_CLR(d, s) \
> ((void) (__FDS_BITS (s)[__FD_ELT(d)] &= ~__FD_MASK(d)))
>#define __FD_ISSET(d, s) \
> ((__FDS_BITS (s)[__FD_ELT (d)] & __FD_MASK (d)) != 0)
>
>```
>

That code is only selected if it is not compiled with
gcc. If it is gcc 2 or later, the header file uses

# define __FD_ZERO(fdsp) \
do { \
int __d0, __d1; \
__asm__ __volatile__ ("cld; rep; " __FD_ZERO_STOS \
: "=c" (__d0), "=D" (__d1) \
: "a" (0), "0" (sizeof (fd_set) \
/ sizeof (__fd_mask)), \
"1" (&__FDS_BITS (fdsp)[0]) \
: "memory"); \
} while (0)

Re: Word For Today: “Uglification”

<LdMIN.411924$vFZa.113768@fx13.iad>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=34379&group=comp.lang.c#34379

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!nntp.comgw.net!peer02.ams4!peer.am4.highwinds-media.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx13.iad.POSTED!not-for-mail
X-newsreader: xrn 9.03-beta-14-64bit
Sender: scott@dragon.sl.home (Scott Lurndal)
From: sco...@slp53.sl.home (Scott Lurndal)
Reply-To: slp53@pacbell.net
Subject: Re: Word For Today: “Uglification”
Newsgroups: comp.lang.c
References: <uso6or$3t3jn$3@dont-email.me> <20240311202758.193@kylheku.com> <86v85opw22.fsf@linuxsc.com> <87v85o4i1v.fsf@nosuchdomain.example.com> <bbMIN.411923$vFZa.142318@fx13.iad>
Lines: 112
Message-ID: <LdMIN.411924$vFZa.113768@fx13.iad>
X-Complaints-To: abuse@usenetserver.com
NNTP-Posting-Date: Fri, 15 Mar 2024 00:01:47 UTC
Organization: UsenetServer - www.usenetserver.com
Date: Fri, 15 Mar 2024 00:01:47 GMT
X-Received-Bytes: 5847
 by: Scott Lurndal - Fri, 15 Mar 2024 00:01 UTC

scott@slp53.sl.home (Scott Lurndal) writes:
>Keith Thompson <Keith.S.Thompson+u@gmail.com> writes:
>>Tim Rentsch <tr.17687@z991.linuxsc.com> writes:
>>> Kaz Kylheku <433-929-6894@kylheku.com> writes:
>>>
>>> [some editing of white space done]
>>>
>>>> On 2024-03-12, Lawrence D'Oliveiro <ldo@nz.invalid> wrote:
>>>>
>>>>> From /usr/include/<<arch>>/bits/select.h on my Debian system:
>>>>>
>>>>> #define __FD_ZERO(s) \
>>>>> do { \
>>>>> unsigned int __i; \
>>>>> fd_set *__arr = (s); \
>>>>
>>>> This assignment has value; it checks that, loosely speaking,
>>>> s is an "assignment compatible" pointer with a fd_set *,
>>>> so that there is a diagnostic if the macro is applied to
>>>> an object of the wrong type.
>>>
>>> More to the point, if the macro is applied to a value of the wrong
>>> type.
>>>
>>>>> for (__i = 0; __i < sizeof (fd_set) / sizeof (__fd_mask); ++__i) \
>>>>> __FDS_BITS (__arr)[__i] = 0; \
>>>>
>>>> Here, I would have done memset(__arr, 0, sizeof *__arr).
>>>
>>> That assumes that it is the entire fd_set that needs to be zeroed,
>>> which may not be right. Note the call to the __FDS_BITS() macro.
>>>
>>> Better:
>>>
>>> #define __FD_ZERO(s) ( \
>>> (void) memset( \
>>> __FDS_BITS( (fd_set*){(s)} ), 0, sizeof __FDS_BITS( (fd_set*){0} ) \
>>> ) \
>>> )
>>>
>>> This definition: avoids introducing any new identifiers; checks
>>> that the argument s yields an assignment compatible pointer; and
>>> provides a macro that can be used as a void expression (unlike the
>>> original macro definition, which can be used only as a statement).
>>
>>For context, here's the entire file from my system (Ubuntu 24.0.4,
>>package libc6-dev:amd64 2.35-0ubuntu3.6). I get the impression that the
>>author(s) decided not to use memset to avoid the required #include,
>>which might increase compilation times for code that indirectly includes
>>this header. (I offer no opinion on whether that's a good tradeoff.)
>>
>>Note that __FD_ZERO is very clearly *not* intended to be invoked by
>>arbitrary code.
>>
>>```
>>/* Copyright (C) 1997-2022 Free Software Foundation, Inc.
>> This file is part of the GNU C Library.
>>
>> The GNU C Library is free software; you can redistribute it and/or
>> modify it under the terms of the GNU Lesser General Public
>> License as published by the Free Software Foundation; either
>> version 2.1 of the License, or (at your option) any later version.
>>
>> The GNU C Library is distributed in the hope that it will be useful,
>> but WITHOUT ANY WARRANTY; without even the implied warranty of
>> MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
>> Lesser General Public License for more details.
>>
>> You should have received a copy of the GNU Lesser General Public
>> License along with the GNU C Library; if not, see
>> <https://www.gnu.org/licenses/>. */
>>
>>#ifndef _SYS_SELECT_H
>># error "Never use <bits/select.h> directly; include <sys/select.h> instead."
>>#endif
>>
>>
>>/* We don't use `memset' because this would require a prototype and
>> the array isn't too big. */
>>#define __FD_ZERO(s) \
>> do { \
>> unsigned int __i; \
>> fd_set *__arr = (s); \
>> for (__i = 0; __i < sizeof (fd_set) / sizeof (__fd_mask); ++__i) \
>> __FDS_BITS (__arr)[__i] = 0; \
>> } while (0)
>>#define __FD_SET(d, s) \
>> ((void) (__FDS_BITS (s)[__FD_ELT(d)] |= __FD_MASK(d)))
>>#define __FD_CLR(d, s) \
>> ((void) (__FDS_BITS (s)[__FD_ELT(d)] &= ~__FD_MASK(d)))
>>#define __FD_ISSET(d, s) \
>> ((__FDS_BITS (s)[__FD_ELT (d)] & __FD_MASK (d)) != 0)
>>
>>```
>>
>
>That code is only selected if it is not compiled with
>gcc. If it is gcc 2 or later, the header file uses
>
># define __FD_ZERO(fdsp) \
> do { \
> int __d0, __d1; \
> __asm__ __volatile__ ("cld; rep; " __FD_ZERO_STOS \
> : "=c" (__d0), "=D" (__d1) \
> : "a" (0), "0" (sizeof (fd_set) \
> / sizeof (__fd_mask)), \
> "1" (&__FDS_BITS (fdsp)[0]) \
> : "memory"); \
> } while (0)
>

(Fedora Core 20).

Re: Word For Today: “Uglification”

<87r0gc4am0.fsf@nosuchdomain.example.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=34380&group=comp.lang.c#34380

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Keith.S....@gmail.com (Keith Thompson)
Newsgroups: comp.lang.c
Subject: Re: Word For Today: “Uglification”
Date: Thu, 14 Mar 2024 17:11:51 -0700
Organization: None to speak of
Lines: 38
Message-ID: <87r0gc4am0.fsf@nosuchdomain.example.com>
References: <uso6or$3t3jn$3@dont-email.me> <20240311202758.193@kylheku.com>
<86v85opw22.fsf@linuxsc.com> <87v85o4i1v.fsf@nosuchdomain.example.com>
<bbMIN.411923$vFZa.142318@fx13.iad>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="1424ef631298fc5a748d3d307144615d";
logging-data="2016875"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/o2N71G+NMuPvP3PBr0PHu"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:xkOmZm45LQaRfiFWvlN6wPZsEas=
sha1:QkML5dfZqchmFa8b4zDlcX4/QYc=
 by: Keith Thompson - Fri, 15 Mar 2024 00:11 UTC

scott@slp53.sl.home (Scott Lurndal) writes:
> Keith Thompson <Keith.S.Thompson+u@gmail.com> writes:
>>For context, here's the entire file from my system (Ubuntu 24.0.4,
>>package libc6-dev:amd64 2.35-0ubuntu3.6). I get the impression that the
>>author(s) decided not to use memset to avoid the required #include,
>>which might increase compilation times for code that indirectly includes
>>this header. (I offer no opinion on whether that's a good tradeoff.)
>>
>>Note that __FD_ZERO is very clearly *not* intended to be invoked by
>>arbitrary code.
>>
>>```
[code snipped]
>>```
>>
>
> That code is only selected if it is not compiled with
> gcc. If it is gcc 2 or later, the header file uses
>
> # define __FD_ZERO(fdsp) \
> do { \
> int __d0, __d1; \
> __asm__ __volatile__ ("cld; rep; " __FD_ZERO_STOS \
> : "=c" (__d0), "=D" (__d1) \
> : "a" (0), "0" (sizeof (fd_set) \
> / sizeof (__fd_mask)), \
> "1" (&__FDS_BITS (fdsp)[0]) \
> : "memory"); \
> } while (0)

Oh? I don't see that code anywhere in the current glibc sources, in any
older version of bits/select.h, or anywhere under /usr/include on my
system.

--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Working, but not speaking, for Medtronic
void Void(void) { Void(); } /* The recursive call of the void */

Re: Word For Today: “Uglification”

<87msr04afd.fsf@nosuchdomain.example.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=34381&group=comp.lang.c#34381

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Keith.S....@gmail.com (Keith Thompson)
Newsgroups: comp.lang.c
Subject: Re: Word For Today: “Uglification”
Date: Thu, 14 Mar 2024 17:15:50 -0700
Organization: None to speak of
Lines: 19
Message-ID: <87msr04afd.fsf@nosuchdomain.example.com>
References: <uso6or$3t3jn$3@dont-email.me> <20240311202758.193@kylheku.com>
<86v85opw22.fsf@linuxsc.com> <87v85o4i1v.fsf@nosuchdomain.example.com>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="1424ef631298fc5a748d3d307144615d";
logging-data="2016875"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18gtWBdVBOa3bqG5W6omHA2"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:yeb0OWiyolGfX8648g9tt+WpG3Y=
sha1:xqMEUpQj6vUhb1quAuMiQIHIpFc=
 by: Keith Thompson - Fri, 15 Mar 2024 00:15 UTC

Keith Thompson <Keith.S.Thompson+u@gmail.com> writes:
[...]
> For context, here's the entire file from my system (Ubuntu 24.0.4,
> package libc6-dev:amd64 2.35-0ubuntu3.6). I get the impression that the
> author(s) decided not to use memset to avoid the required #include,
> which might increase compilation times for code that indirectly includes
> this header. (I offer no opinion on whether that's a good tradeoff.)
[...]

An older version did use memset(). It was changed to use a loop in
1997, with a commit message that included:
"Don't use memset to prevent prototype trouble, use simple loop."
It may have been to avoid problems with pre-ANSI C compilers that didn't
support prototypes. That's still speculation on my part.

--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Working, but not speaking, for Medtronic
void Void(void) { Void(); } /* The recursive call of the void */

Re: Word For Today: “Uglification”

<0HMIN.574791$xHn7.519575@fx14.iad>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=34382&group=comp.lang.c#34382

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx14.iad.POSTED!not-for-mail
X-newsreader: xrn 9.03-beta-14-64bit
Sender: scott@dragon.sl.home (Scott Lurndal)
From: sco...@slp53.sl.home (Scott Lurndal)
Reply-To: slp53@pacbell.net
Subject: Re: Word For Today: “Uglification”
Newsgroups: comp.lang.c
References: <uso6or$3t3jn$3@dont-email.me> <20240311202758.193@kylheku.com> <86v85opw22.fsf@linuxsc.com> <87v85o4i1v.fsf@nosuchdomain.example.com> <bbMIN.411923$vFZa.142318@fx13.iad> <87r0gc4am0.fsf@nosuchdomain.example.com>
Lines: 50
Message-ID: <0HMIN.574791$xHn7.519575@fx14.iad>
X-Complaints-To: abuse@usenetserver.com
NNTP-Posting-Date: Fri, 15 Mar 2024 00:33:00 UTC
Organization: UsenetServer - www.usenetserver.com
Date: Fri, 15 Mar 2024 00:33:00 GMT
X-Received-Bytes: 3098
 by: Scott Lurndal - Fri, 15 Mar 2024 00:33 UTC

Keith Thompson <Keith.S.Thompson+u@gmail.com> writes:
>scott@slp53.sl.home (Scott Lurndal) writes:
>> Keith Thompson <Keith.S.Thompson+u@gmail.com> writes:
>>>For context, here's the entire file from my system (Ubuntu 24.0.4,
>>>package libc6-dev:amd64 2.35-0ubuntu3.6). I get the impression that the
>>>author(s) decided not to use memset to avoid the required #include,
>>>which might increase compilation times for code that indirectly includes
>>>this header. (I offer no opinion on whether that's a good tradeoff.)
>>>
>>>Note that __FD_ZERO is very clearly *not* intended to be invoked by
>>>arbitrary code.
>>>
>>>```
>[code snipped]
>>>```
>>>
>>
>> That code is only selected if it is not compiled with
>> gcc. If it is gcc 2 or later, the header file uses
>>
>> # define __FD_ZERO(fdsp) \
>> do { \
>> int __d0, __d1; \
>> __asm__ __volatile__ ("cld; rep; " __FD_ZERO_STOS \
>> : "=c" (__d0), "=D" (__d1) \
>> : "a" (0), "0" (sizeof (fd_set) \
>> / sizeof (__fd_mask)), \
>> "1" (&__FDS_BITS (fdsp)[0]) \
>> : "memory"); \
>> } while (0)
>
>Oh? I don't see that code anywhere in the current glibc sources, in any
>older version of bits/select.h, or anywhere under /usr/include on my
>system.

I'm using Fedora Core 20. Should have noted that directly in the reply,
sorry about that. It had surprised me when I looked at the generated
code, thinking that perhaps the optimizer generated the rep stos
when optimizing the loop.

$ rpm -q -f /usr/include/bits/select.h
glibc-headers-2.18-19.fc20.x86_64
$ gcc --version
gcc (GCC) 4.8.3 20140911 (Red Hat 4.8.3-7)

Yes, I should probably update to a newer Fedora release, but this
has been rock solid for almost a decade (until last week when
an automatic firefox update started requiring wayland libraries).

We do use gcc11+ and recent Ubuntu/Fedora/Redhat release at the office.

Re: Word For Today: “Uglification”

<lIMIN.574792$xHn7.491768@fx14.iad>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=34383&group=comp.lang.c#34383

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!border-1.nntp.ord.giganews.com!nntp.giganews.com!npeer.as286.net!npeer-ng0.as286.net!peer01.ams1!peer.ams1.xlned.com!news.xlned.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx14.iad.POSTED!not-for-mail
X-newsreader: xrn 9.03-beta-14-64bit
Sender: scott@dragon.sl.home (Scott Lurndal)
From: sco...@slp53.sl.home (Scott Lurndal)
Reply-To: slp53@pacbell.net
Subject: Re: Word For Today: “Uglification”
Newsgroups: comp.lang.c
References: <uso6or$3t3jn$3@dont-email.me> <20240311202758.193@kylheku.com> <86v85opw22.fsf@linuxsc.com> <87v85o4i1v.fsf@nosuchdomain.example.com> <87msr04afd.fsf@nosuchdomain.example.com>
Lines: 84
Message-ID: <lIMIN.574792$xHn7.491768@fx14.iad>
X-Complaints-To: abuse@usenetserver.com
NNTP-Posting-Date: Fri, 15 Mar 2024 00:34:25 UTC
Organization: UsenetServer - www.usenetserver.com
Date: Fri, 15 Mar 2024 00:34:25 GMT
X-Received-Bytes: 4426
X-Original-Bytes: 4287
 by: Scott Lurndal - Fri, 15 Mar 2024 00:34 UTC

Keith Thompson <Keith.S.Thompson+u@gmail.com> writes:
>Keith Thompson <Keith.S.Thompson+u@gmail.com> writes:
>[...]
>> For context, here's the entire file from my system (Ubuntu 24.0.4,
>> package libc6-dev:amd64 2.35-0ubuntu3.6). I get the impression that the
>> author(s) decided not to use memset to avoid the required #include,
>> which might increase compilation times for code that indirectly includes
>> this header. (I offer no opinion on whether that's a good tradeoff.)
>[...]
>
>An older version did use memset(). It was changed to use a loop in
>1997, with a commit message that included:
> "Don't use memset to prevent prototype trouble, use simple loop."
>It may have been to avoid problems with pre-ANSI C compilers that didn't
>support prototypes. That's still speculation on my part.

Here's the full fc20 version:
$ rpm -q -f /usr/include/bits/select.h
glibc-headers-2.18-19.fc20.x86_64

/* Copyright (C) 1997-2013 Free Software Foundation, Inc.
This file is part of the GNU C Library.

The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */

#ifndef _SYS_SELECT_H
# error "Never use <bits/select.h> directly; include <sys/select.h> instead."
#endif

#include <bits/wordsize.h>

#if defined __GNUC__ && __GNUC__ >= 2

# if __WORDSIZE == 64
# define __FD_ZERO_STOS "stosq"
# else
# define __FD_ZERO_STOS "stosl"
# endif

# define __FD_ZERO(fdsp) \
do { \
int __d0, __d1; \
__asm__ __volatile__ ("cld; rep; " __FD_ZERO_STOS \
: "=c" (__d0), "=D" (__d1) \
: "a" (0), "0" (sizeof (fd_set) \
/ sizeof (__fd_mask)), \
"1" (&__FDS_BITS (fdsp)[0]) \
: "memory"); \
} while (0)

#else /* ! GNU CC */

/* We don't use `memset' because this would require a prototype and
the array isn't too big. */
# define __FD_ZERO(set) \
do { \
unsigned int __i; \
fd_set *__arr = (set); \
for (__i = 0; __i < sizeof (fd_set) / sizeof (__fd_mask); ++__i) \
__FDS_BITS (__arr)[__i] = 0; \
} while (0)

#endif /* GNU CC */

#define __FD_SET(d, set) \
((void) (__FDS_BITS (set)[__FD_ELT (d)] |= __FD_MASK (d)))
#define __FD_CLR(d, set) \
((void) (__FDS_BITS (set)[__FD_ELT (d)] &= ~__FD_MASK (d)))
#define __FD_ISSET(d, set) \
((__FDS_BITS (set)[__FD_ELT (d)] & __FD_MASK (d)) != 0)

Re: Word For Today: “Uglification”

<87il1o44oi.fsf@nosuchdomain.example.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=34384&group=comp.lang.c#34384

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Keith.S....@gmail.com (Keith Thompson)
Newsgroups: comp.lang.c
Subject: Re: Word For Today: “Uglification”
Date: Thu, 14 Mar 2024 19:19:57 -0700
Organization: None to speak of
Lines: 39
Message-ID: <87il1o44oi.fsf@nosuchdomain.example.com>
References: <uso6or$3t3jn$3@dont-email.me> <20240311202758.193@kylheku.com>
<86v85opw22.fsf@linuxsc.com> <87v85o4i1v.fsf@nosuchdomain.example.com>
<87msr04afd.fsf@nosuchdomain.example.com>
<lIMIN.574792$xHn7.491768@fx14.iad>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="1424ef631298fc5a748d3d307144615d";
logging-data="2064836"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19Xsd5nheE7O4ZU2MFQyQkt"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:UfLOVf626kORHBiPetUo7dOZ43k=
sha1:njf/Xa9G8OW6vpCeAjq9dyjtsxU=
 by: Keith Thompson - Fri, 15 Mar 2024 02:19 UTC

scott@slp53.sl.home (Scott Lurndal) writes:
> Keith Thompson <Keith.S.Thompson+u@gmail.com> writes:
>>Keith Thompson <Keith.S.Thompson+u@gmail.com> writes:
>>[...]
>>> For context, here's the entire file from my system (Ubuntu 24.0.4,
>>> package libc6-dev:amd64 2.35-0ubuntu3.6). I get the impression that the
>>> author(s) decided not to use memset to avoid the required #include,
>>> which might increase compilation times for code that indirectly includes
>>> this header. (I offer no opinion on whether that's a good tradeoff.)
>>[...]
>>
>>An older version did use memset(). It was changed to use a loop in
>>1997, with a commit message that included:
>> "Don't use memset to prevent prototype trouble, use simple loop."
>>It may have been to avoid problems with pre-ANSI C compilers that didn't
>>support prototypes. That's still speculation on my part.
>
> Here's the full fc20 version:
> $ rpm -q -f /usr/include/bits/select.h
> glibc-headers-2.18-19.fc20.x86_64
>
>
[...]
> #if defined __GNUC__ && __GNUC__ >= 2
[...]
> #else /* ! GNU CC */
[...]
> #endif /* GNU CC */
[...]

I don't see that in the GNU glibc git repo, even on branches with
"fedora" in their names. Perhaps it's a change applied by Red Hat and
not propagated upstream. (Though I'm not sure why Red Hat would need to
allow for glibc not being compiled by gcc.)

--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Working, but not speaking, for Medtronic
void Void(void) { Void(); } /* The recursive call of the void */

Re: Word For Today: “Uglification”

<86il1op5uk.fsf@linuxsc.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=34385&group=comp.lang.c#34385

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: tr.17...@z991.linuxsc.com (Tim Rentsch)
Newsgroups: comp.lang.c
Subject: Re: Word For Today: “Uglification”
Date: Thu, 14 Mar 2024 19:49:07 -0700
Organization: A noiseless patient Spider
Lines: 62
Message-ID: <86il1op5uk.fsf@linuxsc.com>
References: <uso6or$3t3jn$3@dont-email.me> <20240311202758.193@kylheku.com> <86v85opw22.fsf@linuxsc.com> <87v85o4i1v.fsf@nosuchdomain.example.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: dont-email.me; posting-host="ebc16c50d4d7433bc8cd997a3211d402";
logging-data="2194720"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX181xKP+RL6IUv/swoLc3oacJVYV5E78Q5k="
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:7PgPLu0FgbTTCQMBadoKP3Y8xHM=
sha1:BXvFUeWaw4gmr5V4MpnbEiX4dMs=
 by: Tim Rentsch - Fri, 15 Mar 2024 02:49 UTC

Keith Thompson <Keith.S.Thompson+u@gmail.com> writes:

> Tim Rentsch <tr.17687@z991.linuxsc.com> writes:
>
>> Kaz Kylheku <433-929-6894@kylheku.com> writes:
>>
>> [some editing of white space done]
>>
>>> On 2024-03-12, Lawrence D'Oliveiro <ldo@nz.invalid> wrote:
>>>
>>>> From /usr/include/<<arch>>/bits/select.h on my Debian system:
>>>>
>>>> #define __FD_ZERO(s) \
>>>> do { \
>>>> unsigned int __i; \
>>>> fd_set *__arr = (s); \
>>>
>>> This assignment has value; it checks that, loosely speaking,
>>> s is an "assignment compatible" pointer with a fd_set *,
>>> so that there is a diagnostic if the macro is applied to
>>> an object of the wrong type.
>>
>> More to the point, if the macro is applied to a value of the wrong
>> type.
>>
>>>> for (__i = 0; __i < sizeof (fd_set) / sizeof (__fd_mask); ++__i) \
>>>> __FDS_BITS (__arr)[__i] = 0; \
>>>
>>> Here, I would have done memset(__arr, 0, sizeof *__arr).
>>
>> That assumes that it is the entire fd_set that needs to be zeroed,
>> which may not be right. Note the call to the __FDS_BITS() macro.
>>
>> Better:
>>
>> #define __FD_ZERO(s) ( \
>> (void) memset( \
>> __FDS_BITS( (fd_set*){(s)} ), 0, sizeof __FDS_BITS( (fd_set*){0} ) \
>> ) \
>> )
>>
>> This definition: avoids introducing any new identifiers; checks
>> that the argument s yields an assignment compatible pointer; and
>> provides a macro that can be used as a void expression (unlike the
>> original macro definition, which can be used only as a statement).
>
> For context, here's the entire file from my system (Ubuntu 24.0.4,
> package libc6-dev:amd64 2.35-0ubuntu3.6). I get the impression that the
> author(s) decided not to use memset to avoid the required #include,
> which might increase compilation times for code that indirectly includes
> this header. [...]

Yes, it seems clear from the (snipped) source that the authors
deliberately avoided using memset(), perhaps so as not to have
an unwanted dependency.

My comments were meant in the sense of comparing one revision to
another, and about macro definitions generally. They were not
meant to say anything specific about the context in which the
original macro was defined, both because it is not one I have
easy access to and because it doesn't affect the general nature
of my comments.

Re: Word For Today: “Uglification”

<20240314195148.755@kylheku.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=34387&group=comp.lang.c#34387

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: 433-929-...@kylheku.com (Kaz Kylheku)
Newsgroups: comp.lang.c
Subject: Re: Word For Today: “Uglification”
Date: Fri, 15 Mar 2024 03:17:51 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 65
Message-ID: <20240314195148.755@kylheku.com>
References: <uso6or$3t3jn$3@dont-email.me> <20240311202758.193@kylheku.com>
<86v85opw22.fsf@linuxsc.com> <87v85o4i1v.fsf@nosuchdomain.example.com>
<87msr04afd.fsf@nosuchdomain.example.com>
<lIMIN.574792$xHn7.491768@fx14.iad>
<87il1o44oi.fsf@nosuchdomain.example.com>
Injection-Date: Fri, 15 Mar 2024 03:17:51 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="8c47a74d86a279d136db227d771d8013";
logging-data="2205442"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19rXLv2fSY3xtLr1pWyNNW9pkaudMoYOY8="
User-Agent: slrn/pre1.0.4-9 (Linux)
Cancel-Lock: sha1:lxtWg6PG0bQhoDGs48UkahUh2kI=
 by: Kaz Kylheku - Fri, 15 Mar 2024 03:17 UTC

On 2024-03-15, Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote:
> scott@slp53.sl.home (Scott Lurndal) writes:
>> Keith Thompson <Keith.S.Thompson+u@gmail.com> writes:
>>>Keith Thompson <Keith.S.Thompson+u@gmail.com> writes:
>>>[...]
>>>> For context, here's the entire file from my system (Ubuntu 24.0.4,
>>>> package libc6-dev:amd64 2.35-0ubuntu3.6). I get the impression that the
>>>> author(s) decided not to use memset to avoid the required #include,
>>>> which might increase compilation times for code that indirectly includes
>>>> this header. (I offer no opinion on whether that's a good tradeoff.)
>>>[...]
>>>
>>>An older version did use memset(). It was changed to use a loop in
>>>1997, with a commit message that included:
>>> "Don't use memset to prevent prototype trouble, use simple loop."
>>>It may have been to avoid problems with pre-ANSI C compilers that didn't
>>>support prototypes. That's still speculation on my part.
>>
>> Here's the full fc20 version:
>> $ rpm -q -f /usr/include/bits/select.h
>> glibc-headers-2.18-19.fc20.x86_64
>>
>>
> [...]
>> #if defined __GNUC__ && __GNUC__ >= 2

Whoever wrote this didn't know that if __GNUC__ doesn't exist, it will
expand as 0, which is false, so this is equivalent to just

#if __GNUC__ >= 2

> [...]
>> #else /* ! GNU CC */
> [...]
>> #endif /* GNU CC */
> [...]
>
> I don't see that in the GNU glibc git repo, even on branches with
> "fedora" in their names. Perhaps it's a change applied by Red Hat and
> not propagated upstream. (Though I'm not sure why Red Hat would need to
> allow for glibc not being compiled by gcc.)

That it's checking for GNU C at least 2 suggests it is an old
patch.

If you look at the source directory for Fedora's package, you see
there are a bunch of patches that get applied:

https://src.fedoraproject.org/rpms/glibc/tree/rawhide

Now if we go to "f20", a heck of lot more patches were applied:

https://src.fedoraproject.org/rpms/glibc/tree/f20

Now, don't waste your time; it's not in any of those patches (I looked).

f20 references glibc-2.18.tar.gz, and that's where that code is found,
in this file:

./glibc-2.18/sysdeps/x86/bits/select.h

--
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
Mastodon: @Kazinator@mstdn.ca

Re: Word For Today: “Uglification”

<878r2k40qv.fsf@nosuchdomain.example.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=34388&group=comp.lang.c#34388

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Keith.S....@gmail.com (Keith Thompson)
Newsgroups: comp.lang.c
Subject: Re: Word For Today: “Uglification”
Date: Thu, 14 Mar 2024 20:44:56 -0700
Organization: None to speak of
Lines: 17
Message-ID: <878r2k40qv.fsf@nosuchdomain.example.com>
References: <uso6or$3t3jn$3@dont-email.me> <20240311202758.193@kylheku.com>
<86v85opw22.fsf@linuxsc.com> <87v85o4i1v.fsf@nosuchdomain.example.com>
<87msr04afd.fsf@nosuchdomain.example.com>
<lIMIN.574792$xHn7.491768@fx14.iad>
<87il1o44oi.fsf@nosuchdomain.example.com>
<20240314195148.755@kylheku.com>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="1424ef631298fc5a748d3d307144615d";
logging-data="2214723"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18hMx6zyKwcaUMDLs25uvQx"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:A6WFj0ny7Au9OxCLS2qZGMqkClM=
sha1:SJYalQSJesGdfe4a1eJgTUQNvSw=
 by: Keith Thompson - Fri, 15 Mar 2024 03:44 UTC

Kaz Kylheku <433-929-6894@kylheku.com> writes:
[...]
>>> #if defined __GNUC__ && __GNUC__ >= 2
>
> Whoever wrote this didn't know that if __GNUC__ doesn't exist, it will
> expand as 0, which is false, so this is equivalent to just
>
> #if __GNUC__ >= 2

Or they did know that and decided that the longer version would be clearer.

[...]

--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Working, but not speaking, for Medtronic
void Void(void) { Void(); } /* The recursive call of the void */

Re: Word For Today: “Uglification”

<ut103p$2695n$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=34392&group=comp.lang.c#34392

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: david.br...@hesbynett.no (David Brown)
Newsgroups: comp.lang.c
Subject: Re: Word For Today: “Uglification”
Date: Fri, 15 Mar 2024 09:15:53 +0100
Organization: A noiseless patient Spider
Lines: 47
Message-ID: <ut103p$2695n$1@dont-email.me>
References: <uso6or$3t3jn$3@dont-email.me> <20240311202758.193@kylheku.com>
<86v85opw22.fsf@linuxsc.com> <87v85o4i1v.fsf@nosuchdomain.example.com>
<bbMIN.411923$vFZa.142318@fx13.iad> <87r0gc4am0.fsf@nosuchdomain.example.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 15 Mar 2024 08:15:53 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="7521a6ab962105e84f4e48866803f6e1";
logging-data="2303159"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19ShO08e9YtiNkBMytoKoEcgCJ8YuVJ41o="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
Thunderbird/102.11.0
Cancel-Lock: sha1:fUs9l21WmOE5iavM4XJbawIYNhk=
Content-Language: en-GB
In-Reply-To: <87r0gc4am0.fsf@nosuchdomain.example.com>
 by: David Brown - Fri, 15 Mar 2024 08:15 UTC

On 15/03/2024 01:11, Keith Thompson wrote:
> scott@slp53.sl.home (Scott Lurndal) writes:
>> Keith Thompson <Keith.S.Thompson+u@gmail.com> writes:
>>> For context, here's the entire file from my system (Ubuntu 24.0.4,
>>> package libc6-dev:amd64 2.35-0ubuntu3.6). I get the impression that the
>>> author(s) decided not to use memset to avoid the required #include,
>>> which might increase compilation times for code that indirectly includes
>>> this header. (I offer no opinion on whether that's a good tradeoff.)
>>>
>>> Note that __FD_ZERO is very clearly *not* intended to be invoked by
>>> arbitrary code.
>>>
>>> ```
> [code snipped]
>>> ```
>>>
>>
>> That code is only selected if it is not compiled with
>> gcc. If it is gcc 2 or later, the header file uses
>>
>> # define __FD_ZERO(fdsp) \
>> do { \
>> int __d0, __d1; \
>> __asm__ __volatile__ ("cld; rep; " __FD_ZERO_STOS \
>> : "=c" (__d0), "=D" (__d1) \
>> : "a" (0), "0" (sizeof (fd_set) \
>> / sizeof (__fd_mask)), \
>> "1" (&__FDS_BITS (fdsp)[0]) \
>> : "memory"); \
>> } while (0)
>
> Oh? I don't see that code anywhere in the current glibc sources, in any
> older version of bits/select.h, or anywhere under /usr/include on my
> system.
>

I see it in my older Mint system (based on Ubuntu bionic 18.04 LTS), but
not my newer one (based on Ubuntu jammy 22.04 LTS). So it looks like
was an optimisation that was useful in the past, but newer gcc gives the
same or better code from the pure C code. Keeping it in C rather than
inline assembly gives the compiler more information, even if the
generated object code is still the same, so that's always a good thing.

(And full memory clobbers are undesirable in performance code because it
can mean the compiler loses useful knowledge or has to re-load other
data from memory.)

Re: Word For Today: “Uglification”

<ut10gu$2695n$2@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=34393&group=comp.lang.c#34393

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: david.br...@hesbynett.no (David Brown)
Newsgroups: comp.lang.c
Subject: Re: Word For Today: “Uglification”
Date: Fri, 15 Mar 2024 09:22:54 +0100
Organization: A noiseless patient Spider
Lines: 22
Message-ID: <ut10gu$2695n$2@dont-email.me>
References: <uso6or$3t3jn$3@dont-email.me> <20240311202758.193@kylheku.com>
<86v85opw22.fsf@linuxsc.com> <87v85o4i1v.fsf@nosuchdomain.example.com>
<87msr04afd.fsf@nosuchdomain.example.com> <lIMIN.574792$xHn7.491768@fx14.iad>
<87il1o44oi.fsf@nosuchdomain.example.com> <20240314195148.755@kylheku.com>
<878r2k40qv.fsf@nosuchdomain.example.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 15 Mar 2024 08:22:54 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="7521a6ab962105e84f4e48866803f6e1";
logging-data="2303159"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18V6OTS2UxSU2tQP4OUkQpF9gin2h3ZOqY="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
Thunderbird/102.11.0
Cancel-Lock: sha1:mk/CSy7GZArd3tW7azWe/rcS3Nk=
In-Reply-To: <878r2k40qv.fsf@nosuchdomain.example.com>
Content-Language: en-GB
 by: David Brown - Fri, 15 Mar 2024 08:22 UTC

On 15/03/2024 04:44, Keith Thompson wrote:
> Kaz Kylheku <433-929-6894@kylheku.com> writes:
> [...]
>>>> #if defined __GNUC__ && __GNUC__ >= 2
>>
>> Whoever wrote this didn't know that if __GNUC__ doesn't exist, it will
>> expand as 0, which is false, so this is equivalent to just
>>
>> #if __GNUC__ >= 2
>
> Or they did know that and decided that the longer version would be clearer.
>

Or they did know, and decided they did not want a spurious warning when
compiling with "-Wundef" that generates a warning before replacing
undefined identifiers with 0 in #if directives. Personally, I always
use -Wundef in my own code, because I think the "default to 0" treatment
makes it far too easy for typos to go unnoticed. I have no idea if the
glibc folk agree with that and like to use -Wundef themselves, or if
they just like to make their code as "warning-proof" as possible.

Pages:123
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor