This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [LIBIBERTY]: Expose tail calls in xmemdup and xstrdup


"Kaveh R. Ghazi" <ghazi@caip.rutgers.edu> writes:

> This patch exposes tail calls in xmemdup and xstrdup to the optimizer.
> It is similar to a patch to plain strdup way back here:
> http://gcc.gnu.org/ml/gcc-patches/2003-04/msg00903.html
> 
> In order to guarantee that memcpy is declared, I prototype it
> explicitly as is done in many other libiberty functions.  I also
> removed the "register" keyword since we're allowing the compiler to
> figure out the best allocation scheme now.

Note that this explicit declaration is only done in .c files that are
careful to *not* include libiberty.h nor any header file which declare
memcpy.  Since xmemdup.c includes libiberty.h--and should, because
that is where xmemdup and xcalloc are declared--you should not use
this technique.

Instead, just include <string.h> as is already done.  It will declare
memcpy on pretty much all systems, and I don't think we need to worry
about the ones on which it doesn't.  In fact, I don't see that you
should change the set of header files at all.

If you really want to make sure that memcpy is declared, then you
should try including both <string.h> and <strings.h> as in, e.g,
concat.c, and only declare memcpy in the case where neither
HAVE_STRING_H nor HAVE_STRINGS_H is defined.  In such a case, I think
it is best to declare it without a prototype for extra protection
against declaration conflicts.

Ian


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