This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: expanding builtins
- From: Jakub Jelinek <jakub at redhat dot com>
- To: James Lemke <jim at TheLemkes dot ca>
- Cc: gcc at gcc dot gnu dot org
- Date: Mon, 27 Jun 2005 16:26:32 +0200
- Subject: Re: expanding builtins
- References: <1119881510.29036.29.camel@keel.thelemkes.ca>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
On Mon, Jun 27, 2005 at 10:11:50AM -0400, James Lemke wrote:
> I have a situation where a structure is not properly aligned and I want
> to copy it to fix this.
>
> I'm aware that -no-builtin-memcpy will suppress the expansion of
> memcpy() (force library calls) for a whole module. Is it possible to
> suppress the expansion for a single invocation?
You can:
#include <string.h>
...
extern __typeof(memcpy) my_memcpy __asm ("memcpy");
and use my_memcpy instead of memcpy in the place where you want to force
library call.
Or you can use memcpy builtin, just tell GCC it should forget everything
it knows about alignment of whatever you know is not aligned.
void *psrc = (void *) src;
__asm ("" : "+r" (psrc));
memcpy (dest, psrc, len);
Jakub