Index: uspace/lib/c/generic/mem.c
===================================================================
--- uspace/lib/c/generic/mem.c	(revision 8fdb18e1b43cce69fbf3e0ce3a63e333e77c79db)
+++ uspace/lib/c/generic/mem.c	(revision 44ecf894e75e499c21daf2e1b5fbc588301e35e5)
@@ -224,19 +224,25 @@
  * @param s1  Pointer to the first area to compare.
  * @param s2  Pointer to the second area to compare.
- * @param len Size of the first area in bytes. Both areas must have
- *            the same length.
- *
- * @return If len is 0, return zero. If the areas match, return
- *         zero. Otherwise return non-zero.
- *
- */
-int bcmp(const void *s1, const void *s2, size_t len)
+ * @param len Size of the areas in bytes.
+ *
+ * @return Zero if areas have the same contents. If they differ,
+ *	   the sign of the result is the same as the sign of the
+ *	   difference of the first pair of different bytes.
+ *
+ */
+int memcmp(const void *s1, const void *s2, size_t len)
 {
 	uint8_t *u1 = (uint8_t *) s1;
 	uint8_t *u2 = (uint8_t *) s2;
-	
-	for (; (len != 0) && (*u1++ == *u2++); len--);
-	
-	return len;
+	size_t i;
+
+	for (i = 0; i < len; i++) {
+		if (*u1 != *u2)
+			return (int)(*u1) - (int)(*u2);
+		++u1;
+		++u2;
+	}
+
+	return 0;
 }
 
