This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [LIBIBERTY]: Expose tail calls in xmemdup and xstrdup
- From: Ian Lance Taylor <ian at airs dot com>
- To: "Kaveh R. Ghazi" <ghazi at caip dot rutgers dot edu>
- Cc: gcc-patches at gcc dot gnu dot org, dj at redhat dot com
- Date: 24 Mar 2005 12:48:16 -0500
- Subject: Re: [LIBIBERTY]: Expose tail calls in xmemdup and xstrdup
- References: <200503241526.j2OFQ4pM012387@caip.rutgers.edu>
"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