* expanding builtins
@ 2005-06-27 14:12 James Lemke
2005-06-27 14:26 ` Jakub Jelinek
0 siblings, 1 reply; 4+ messages in thread
From: James Lemke @ 2005-06-27 14:12 UTC (permalink / raw)
To: gcc
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?
--
James Lemke jim@TheLemkes.ca Orillia, Ontario
1992 ST1100, STOC #3750; FWD# M:245401 H:246889
Life is what happens while you're busy making other plans. --John Lennon
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: expanding builtins
2005-06-27 14:12 expanding builtins James Lemke
@ 2005-06-27 14:26 ` Jakub Jelinek
2005-06-27 15:24 ` Andreas Schwab
2005-06-27 15:30 ` James Lemke
0 siblings, 2 replies; 4+ messages in thread
From: Jakub Jelinek @ 2005-06-27 14:26 UTC (permalink / raw)
To: James Lemke; +Cc: gcc
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
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: expanding builtins
2005-06-27 14:26 ` Jakub Jelinek
@ 2005-06-27 15:24 ` Andreas Schwab
2005-06-27 15:30 ` James Lemke
1 sibling, 0 replies; 4+ messages in thread
From: Andreas Schwab @ 2005-06-27 15:24 UTC (permalink / raw)
To: Jakub Jelinek; +Cc: James Lemke, gcc
Jakub Jelinek <jakub@redhat.com> writes:
> 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.
Except that sometimes the function is actually called _memcpy at the
assembler level.
Andreas.
--
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux Products GmbH, MaxfeldstraÃe 5, 90409 Nürnberg, Germany
Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: expanding builtins
2005-06-27 14:26 ` Jakub Jelinek
2005-06-27 15:24 ` Andreas Schwab
@ 2005-06-27 15:30 ` James Lemke
1 sibling, 0 replies; 4+ messages in thread
From: James Lemke @ 2005-06-27 15:30 UTC (permalink / raw)
To: Jakub Jelinek; +Cc: gcc
> 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.
Thanks Jakub! That worked very well.
Jim.
> 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);
--
James Lemke jim@TheLemkes.ca Orillia, Ontario
1992 ST1100, STOC #3750; FWD# M:245401 H:246889
Life is what happens while you're busy making other plans. --John Lennon
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2005-06-27 15:30 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-06-27 14:12 expanding builtins James Lemke
2005-06-27 14:26 ` Jakub Jelinek
2005-06-27 15:24 ` Andreas Schwab
2005-06-27 15:30 ` James Lemke
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).