This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
RE: mempcpy performance.
- From: "Wilco Dijkstra" <wdijkstr at arm dot com>
- To: 'OndÅej BÃlka' <neleai at seznam dot cz>
- Cc: <eggert at cs dot ucla dot edu>, <libc-alpha at sourceware dot org>
- Date: Mon, 22 Dec 2014 19:38:14 -0000
- Subject: RE: mempcpy performance.
- Authentication-results: sourceware.org; auth=none
- References: <000f01d01ad0$17e381d0$47aa8570$ at com> <20141219220614 dot GA29640 at domone>
> OndÅej BÃlka wrote:
> Bit off topic,
>
> I have on my todo list fix that, by on architectures without assembly
> change definition to
>
> #define mempcpy(dest, src, n) (memcpy (dest, src, n) + n)
>
> which would remove extra call and possibly allow extra compiler
> optimizations.
This would need to use an extern inline function, but yes that is the right way to do it if there is no assembler implementation.
A similar thing needs to be done with bcopy and bzero - they currently don't get expanded inline at all due to missing the __asm__ "__bzero" redirection. Interestingly GCC expands __builtin_bzero into memset when inlining is not possible (although it returns the address of bzero if you use it as function symbol).
Wilco