]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[libc] Convert memcpy() from a macro to an inline function
authorMichael Brown <mcb30@ipxe.org>
Sun, 4 Nov 2012 22:50:27 +0000 (22:50 +0000)
committerMichael Brown <mcb30@ipxe.org>
Mon, 12 Nov 2012 16:58:49 +0000 (16:58 +0000)
Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/arch/x86/include/bits/string.h
src/include/string.h

index e5850ed9323f3df864ee00468f5381c94e7a7e1c..f0d3c965970cd7bea779eaea88b44454af856c28 100644 (file)
@@ -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
 
index 2fd6acf1636e58f3bf54a70857e56c0155c9492c..3482e1b2248c97fbcabe5431edeb9967d600289d 100644 (file)
@@ -37,6 +37,7 @@ char * __pure strpbrk(const char * cs,const char * ct) __nonnull;
 char * strtok(char * s,const char * ct) __nonnull;
 char * strsep(char **s, const char *ct) __nonnull;
 void * memset(void * s,int c,size_t count) __nonnull;
+void * memcpy ( void *dest, const void *src, size_t len ) __nonnull;
 void * memmove(void * dest,const void *src,size_t count) __nonnull;
 int __pure memcmp(const void * cs,const void * ct,
                                    size_t count) __nonnull;