Re: [patch 2.6.17-rc5 1/2] i386 memcpy: use as few moves as possiblefor I/O

From: H. Peter Anvin
Date: Tue May 30 2006 - 21:37:29 EST


One concern: this is not the standard return value for memcpy(). It either needs a comment to that effect (stating it returns a pointer to the end of the area), or just make it return void.

Also, the formatting looks nonstandard.

/*
+ * Do memcpy with as few moves as possible (for transfers to/from IO space.)
+ */
+static inline void * __minimal_memcpy(void * to, const void * from, size_t n)
+{
+int d0, d1, d2;
+__asm__ __volatile__(
+ "rep ; movsl\n\t"
+ "testb $2,%b4\n\t"
+ "jz 1f\n\t"
+ "movsw\n"
+ "1:\n\t"
+ "testb $1,%b4\n\t"
+ "jz 2f\n\t"
+ "movsb\n"
+ "2:"
+ : "=&c" (d0), "=&D" (d1), "=&S" (d2)
+ :"0" (n/4), "q" (n), "1" ((long) to), "2" ((long) from)
+ : "memory");
+return to;
+}


-hpa
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/