svn commit: r348007 - projects/fuse2/lib/libc/gen
Conrad Meyer
cem at freebsd.org
Mon May 20 22:23:51 UTC 2019
On Mon, May 20, 2019 at 1:51 PM Konstantin Belousov <kostikbel at gmail.com> wrote:
>
> On Mon, May 20, 2019 at 02:43:36PM -0600, Alan Somers wrote:
> > True, but I though that strlen would be more readable. Clang is smart
> > enough to realize that strlen's argument is a constant and omit the
> > call to strlen, so that's what I went with. Is there any other reason
> > to prefer sizeof() - 1 ?
>
> The reason is that it would also work for not so smart compiler, or with
> a smart compiler after we finally turn on -ffreestanding for libc, as it
> ought to be.
If we did that, it might make sense to implement strlen() as a macro
that did essentially the same thing using __builtin_strlen() (and
__builtin_constant_p, if necessary) extensions.
Best,
Conrad
More information about the svn-src-projects
mailing list