aboutsummaryrefslogtreecommitdiffstats
path: root/src/arch/x86/include/bits/string.h
diff options
context:
space:
mode:
authorMichael Brown <mcb30@ipxe.org>2012-11-04 22:50:27 +0000
committerMichael Brown <mcb30@ipxe.org>2012-11-12 16:58:49 +0000
commit61c6af3f0b64b711f4a104aedad036a3d12093eb (patch)
tree9884fe6b50f35aba338108d3ee097ad26bbdcfc5 /src/arch/x86/include/bits/string.h
parentfc30b13b25d66c711778fee50ce2d5609ad361ee (diff)
downloadipxe-61c6af3f0b64b711f4a104aedad036a3d12093eb.tar.gz
[libc] Convert memcpy() from a macro to an inline function
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/arch/x86/include/bits/string.h')
-rw-r--r--src/arch/x86/include/bits/string.h28
1 files changed, 24 insertions, 4 deletions
diff --git a/src/arch/x86/include/bits/string.h b/src/arch/x86/include/bits/string.h
index e5850ed93..f0d3c9659 100644
--- a/src/arch/x86/include/bits/string.h
+++ b/src/arch/x86/include/bits/string.h
@@ -28,6 +28,14 @@ FILE_LICENCE ( PUBLIC_DOMAIN );
extern void * __memcpy ( void *dest, const void *src, size_t len );
extern void * __memcpy_reverse ( void *dest, const void *src, size_t len );
+/**
+ * Copy memory area (where length is a compile-time constant)
+ *
+ * @v dest Destination address
+ * @v src Source address
+ * @v len Length
+ * @ret dest Destination address
+ */
static inline __attribute__ (( always_inline )) void *
__constant_memcpy ( void *dest, const void *src, size_t len ) {
union {
@@ -139,10 +147,22 @@ __constant_memcpy ( void *dest, const void *src, size_t len ) {
return dest;
}
-#define memcpy( dest, src, len ) \
- ( __builtin_constant_p ( (len) ) ? \
- __constant_memcpy ( (dest), (src), (len) ) : \
- __memcpy ( (dest), (src), (len) ) )
+/**
+ * Copy memory area
+ *
+ * @v dest Destination address
+ * @v src Source address
+ * @v len Length
+ * @ret dest Destination address
+ */
+static inline __attribute__ (( always_inline )) void *
+memcpy ( void *dest, const void *src, size_t len ) {
+ if ( __builtin_constant_p ( len ) ) {
+ return __constant_memcpy ( dest, src, len );
+ } else {
+ return __memcpy ( dest, src, len );
+ }
+}
#define __HAVE_ARCH_MEMMOVE