This is the mail archive of the libc-alpha@sources.redhat.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Should we optimize memset to bzero?


On Fri, Nov 02, 2001 at 05:38:00PM +0100, Jakub Jelinek wrote:
> On Fri, Nov 02, 2001 at 08:28:49AM -0800, H . J . Lu wrote:
> > Should we optimize memset to bzero? Like
> > 
> > #define memset(s, c, n) \
> > (__extension__ ((__builtin_constant_p (c) && (c) == 0) \
> > 		? __bzero ((s), (n)) : __memset ((s), (c), (n)))
> 
> And we don't? Look at bits/string2.h...

We do? Try this

--s.c--
#include <string.h>

void
foo (char *x, int l)
{
  memset (x, 0, l);
}
---

# gcc -O2 -S s.c

BTW, in many cases, gcc won't inline those string/memory functions.


H.J.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]