This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
RE: bzero/bcopy/bcmp/mempcpy (was: Improve strncpy performance further)
- From: Joseph Myers <joseph at codesourcery dot com>
- To: Wilco Dijkstra <wdijkstr at arm dot com>
- Cc: 'Ondřej Bílka' <neleai at seznam dot cz>, 'Roland McGrath' <roland at hack dot frob dot com>, <libc-alpha at sourceware dot org>
- Date: Wed, 4 Feb 2015 18:56:21 +0000
- Subject: RE: bzero/bcopy/bcmp/mempcpy (was: Improve strncpy performance further)
- Authentication-results: sourceware.org; auth=none
- References: <001801d02b72$6ce0c3c0$46a24b40$ at com> <20150108185812 dot 285782C3BF6 at topped-with-meat dot com> <001901d02c0d$43cf9920$cb6ecb60$ at com> <20150109191632 dot 694692C3C1F at topped-with-meat dot com> <001a01d02dc9$bd6f0370$384d0a50$ at com> <20150113191449 dot AD91B2C39DC at topped-with-meat dot com> <001e01d03003$f67b8670$e3729350$ at com> <20150114193244 dot 44C022C39DB at topped-with-meat dot com> <002101d030da$c05f76f0$411e64d0$ at com> <20150131203619 dot GA13121 at domone dot leoexpresswifi dot com> <002b01d04097$ec2c9b10$c485d130$ at com> <alpine dot DEB dot 2 dot 10 dot 1502041726450 dot 4240 at digraph dot polyomino dot org dot uk> <002c01d040aa$60fa51a0$22eef4e0$ at com>
On Wed, 4 Feb 2015, Wilco Dijkstra wrote:
> Indeed it's unfortunate that these as well as the generic __bzero are
> inefficient. Would it be possible for GCC to detect a modern GLIBC from the
> headers and only emit calls to __bzero (or say a new __memclr symbol) if a
> target provides an optimized version? Not sure whether there is already a way
> to do this, or whether such trickery is discouraged...
There's existing support for checking the glibc version at GCC configure
time and acting in GCC based on that (of course, that's just the minimum
glibc version that GCC knows will be used at runtime - it doesn't take
account of glibc upgrades). That's sufficient if using new glibc features
would require a GCC upgrade anyway. If an older GCC could meaningfully
use a newer glibc feature when glibc is upgraded - if, for example, GCC
knows about using efficient __bzero but the set of relevant architectures
varies with glibc version, so you want glibc headers to tell GCC whether
__bzero is efficient for that glibc version and architecture - then you
get into stdc-predef.h (or an architecture-specific bits/ file included
therefrom) doing "#pragma GCC library_feature efficient___bzero" or
similar - a new pragma to inform GCC of library features it can presume on
the target. (There might be other possible approaches to implementing
this.)
--
Joseph S. Myers
joseph@codesourcery.com