public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Alejandro Colomar <alx.manpages@gmail.com>
To: Wilco Dijkstra <Wilco.Dijkstra@arm.com>,
	Paul Eggert <eggert@cs.ucla.edu>,
	Adhemerval Zanella Netto <adhemerval.zanella@linaro.org>,
	"linux-man@vger.kernel.org" <linux-man@vger.kernel.org>
Cc: Alejandro Colomar <alx@kernel.org>,
	"libc-alpha@sourceware.org" <libc-alpha@sourceware.org>,
	"G. Branden Robinson" <g.branden.robinson@gmail.com>
Subject: Re: [PATCH] bind.2, mount_setattr.2, openat2.2, perf_event_open.2, pidfd_send_signal.2, recvmmsg.2, seccomp_unotify.2, select_tut.2, sendmmsg.2, set_thread_area.2, sysctl.2, bzero.3, getaddrinfo.3, getaddrinfo_a.3, getutent.3, mbrtowc.3, mbsinit.3, rti...
Date: Fri, 6 Jan 2023 01:22:38 +0100	[thread overview]
Message-ID: <68e4db4a-dba1-dcf3-c332-8b462193a097@gmail.com> (raw)
In-Reply-To: <PAWPR08MB89827AFF364FB662C3FC5F9A83FA9@PAWPR08MB8982.eurprd08.prod.outlook.com>


[-- Attachment #1.1: Type: text/plain, Size: 2629 bytes --]

Hi Wilco,

On 1/6/23 01:02, Wilco Dijkstra wrote:
> Hi Alex,
> 
>> There are many users of bzero(3) in the wild, and it is a fine API from a
>> usability point of view.
> 
> Since you repeatedly claim lots of use of these functions, I did a quick search
> on https://codesearch.debian.net/
> 
> bzero: 21440
> memset: 563054
> 
> mempcpy: 4489
> memcpy: 692873
> 
> I used "memcpy(" and "memcpy (" and added the results. These overestimate
> usage due to prototypes and comments, and don't include memcpy and memset
> calls emitted by compilers so in reality the results are even more skewed.

Many projects redefine those functions themselves, with alternative names, so 
it's hard to really count how much is the intention of projects to use it, 
rather than actual use.  Since the standards don't guarantee such functions, 
projects that care a lot, use a portable name (one that isn't reserved; 
sometimes they don't even know that there's a GNU extension with that name and 
use a weird one, such as cpymem() by nginx).

Projects that prefer portability and don't care about using good APIs so much 
will fall back to the standard APIs, which is most projects, so of course the 
numbers are not comparable in the wild.

The thing is that those APIs are better (imagine that they were all standard, 
and were all equally known by programmers; which ones would you use?).  Some 
programmers will want to use the better APIs, independently of libc providing it 
or not.  In some cases, for high performance programs, good APIs are even more 
relevant.  Not implementing them in libc, will only mean that projects will roll 
their own.

I'm not saying that's bad either.  If we want to simplify libc, and add some 
extension libraries that are independent of libc, that would provide such 
functions, that's fine by me.  And maybe it's the better thing to do.

So, whether you like it or not, a relevant number of programs (although, as you 
proved, a small one compared to the entire universe of programs) will keep using 
an API that asks for a pointer and a size and zeroes it.  We can call it 
bzero(3), or memzero(3), or ext_memzero(3) (ext_ being a prefix for a library 
providing useful extensions to libc), but the function will be there.

Where do you suggest that we put such function?  In or out of libc?

> 
> There may be other repositories which can be easily searched, but these results
> are clear enough to conclude these functions are dead.
I'd say dead is too much.

Cheers,

Alex

> 
> Cheers,
> Wilco

-- 
<http://www.alejandro-colomar.es/>

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2023-01-06  0:22 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-06  0:02 Wilco Dijkstra
2023-01-06  0:22 ` Alejandro Colomar [this message]
2023-01-06  0:57   ` Alejandro Colomar
  -- strict thread matches above, loose matches on Subject: below --
2023-01-06 15:53 Wilco Dijkstra
2023-01-06 16:20 ` Alejandro Colomar
2023-01-06 17:01   ` Joseph Myers
2023-01-06  2:26 Wilco Dijkstra
2023-01-06 13:49 ` Alejandro Colomar
2023-01-05 19:37 [PATCH] bind.2, mount_setattr.2, openat2.2, perf_event_open.2, pidfd_send_signal.2, recvmmsg.2, seccomp_unotify.2, select_tut.2, sendmmsg.2, set_thread_area.2, sysctl.2, bzero.3, getaddrinfo.3, getaddrinfo_a.3, getutent.3, mbrtowc.3, mbsinit.3, rtime.3, rtnetlink.3, strptime.3, NULL.3const, size_t.3type, void.3type, aio.7, netlink.7, unix.7: Prefer bzero(3) over memset(3) Alejandro Colomar
2023-01-05 20:48 ` Adhemerval Zanella Netto
2023-01-05 20:55   ` Paul Eggert
2023-01-05 21:12     ` [PATCH] bind.2, mount_setattr.2, openat2.2, perf_event_open.2, pidfd_send_signal.2, recvmmsg.2, seccomp_unotify.2, select_tut.2, sendmmsg.2, set_thread_area.2, sysctl.2, bzero.3, getaddrinfo.3, getaddrinfo_a.3, getutent.3, mbrtowc.3, mbsinit.3, rti Wilco Dijkstra
2023-01-05 21:33       ` Alejandro Colomar
2023-01-05 23:30       ` Wilco Dijkstra

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=68e4db4a-dba1-dcf3-c332-8b462193a097@gmail.com \
    --to=alx.manpages@gmail.com \
    --cc=Wilco.Dijkstra@arm.com \
    --cc=adhemerval.zanella@linaro.org \
    --cc=alx@kernel.org \
    --cc=eggert@cs.ucla.edu \
    --cc=g.branden.robinson@gmail.com \
    --cc=libc-alpha@sourceware.org \
    --cc=linux-man@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).