Merge branch 'idle-release' of git://git.kernel.org/pub/scm/linux/kernel/git/lenb...
[safe/jmp/linux-2.6] / arch / x86 / include / asm / string_32.h
index 487843e..3d3e835 100644 (file)
@@ -1,5 +1,5 @@
-#ifndef ASM_X86__STRING_32_H
-#define ASM_X86__STRING_32_H
+#ifndef _ASM_X86_STRING_32_H
+#define _ASM_X86_STRING_32_H
 
 #ifdef __KERNEL__
 
@@ -65,7 +65,6 @@ static __always_inline void *__constant_memcpy(void *to, const void *from,
        case 4:
                *(int *)to = *(int *)from;
                return to;
-
        case 3:
                *(short *)to = *(short *)from;
                *((char *)to + 2) = *((char *)from + 2);
@@ -177,10 +176,23 @@ static inline void *__memcpy3d(void *to, const void *from, size_t len)
  *     No 3D Now!
  */
 
+#ifndef CONFIG_KMEMCHECK
+
+#if (__GNUC__ >= 4)
+#define memcpy(t, f, n) __builtin_memcpy(t, f, n)
+#else
 #define memcpy(t, f, n)                                \
        (__builtin_constant_p((n))              \
         ? __constant_memcpy((t), (f), (n))     \
         : __memcpy((t), (f), (n)))
+#endif
+#else
+/*
+ * kmemcheck becomes very happy if we use the REP instructions unconditionally,
+ * because it means that we know both memory operands in advance.
+ */
+#define memcpy(t, f, n) __memcpy((t), (f), (n))
+#endif
 
 #endif
 
@@ -309,11 +321,15 @@ void *__constant_c_and_count_memset(void *s, unsigned long pattern,
         : __memset_generic((s), (c), (count)))
 
 #define __HAVE_ARCH_MEMSET
+#if (__GNUC__ >= 4)
+#define memset(s, c, count) __builtin_memset(s, c, count)
+#else
 #define memset(s, c, count)                                            \
        (__builtin_constant_p(c)                                        \
         ? __constant_c_x_memset((s), (0x01010101UL * (unsigned char)(c)), \
                                 (count))                               \
         : __memset((s), (c), (count)))
+#endif
 
 /*
  * find the first occurrence of byte 'c', or 1 past the area if none
@@ -323,4 +339,4 @@ extern void *memscan(void *addr, int c, size_t size);
 
 #endif /* __KERNEL__ */
 
-#endif /* ASM_X86__STRING_32_H */
+#endif /* _ASM_X86_STRING_32_H */