Index: uspace/lib/bithenge/src/helenos/common.h
===================================================================
--- uspace/lib/bithenge/src/helenos/common.h	(revision bfe90b6b7580ea944610d1ef63bd58ffa1dba441)
+++ uspace/lib/bithenge/src/helenos/common.h	(revision 2498b9515ac2e60a64adc171d59e3a1f3aaef339)
@@ -73,12 +73,4 @@
 }
 
-static inline void *memchr(const void *s, int c, size_t n)
-{
-	for (size_t i = 0; i < n; i++)
-		if (((char *)s)[i] == c)
-			return (void *)(s + i);
-	return NULL;
-}
-
 static inline errno_t bithenge_parse_int(const char *start, bithenge_int_t *result)
 {
Index: uspace/lib/c/Makefile
===================================================================
--- uspace/lib/c/Makefile	(revision bfe90b6b7580ea944610d1ef63bd58ffa1dba441)
+++ uspace/lib/c/Makefile	(revision 2498b9515ac2e60a64adc171d59e3a1f3aaef339)
@@ -193,4 +193,5 @@
 	test/fibril/timer.c \
 	test/main.c \
+	test/mem.c \
 	test/io/table.c \
 	test/stdio/scanf.c \
Index: uspace/lib/c/generic/mem.c
===================================================================
--- uspace/lib/c/generic/mem.c	(revision bfe90b6b7580ea944610d1ef63bd58ffa1dba441)
+++ uspace/lib/c/generic/mem.c	(revision 2498b9515ac2e60a64adc171d59e3a1f3aaef339)
@@ -1,5 +1,5 @@
 /*
  * Copyright (c) 2005 Martin Decky
- * Copyright (c) 2008 Jiri Svoboda
+ * Copyright (c) 2018 Jiri Svoboda
  * All rights reserved.
  *
@@ -252,4 +252,27 @@
 }
 
+/** Search memory area.
+ *
+ * @param s Memory area
+ * @param c Character (byte) to search for
+ * @param n Size of memory area in bytes
+ *
+ * @return Pointer to the first occurrence of @a c in the first @a n
+ *         bytes of @a s or @c NULL if not found.
+ */
+void *memchr(const void *s, int c, size_t n)
+{
+	uint8_t *u = (uint8_t *) s;
+	unsigned char uc = (unsigned char) c;
+	size_t i;
+
+	for (i = 0; i < n; i++) {
+		if (u[i] == uc)
+			return (void *) &u[i];
+	}
+
+	return NULL;
+}
+
 /** @}
  */
Index: uspace/lib/c/include/mem.h
===================================================================
--- uspace/lib/c/include/mem.h	(revision bfe90b6b7580ea944610d1ef63bd58ffa1dba441)
+++ uspace/lib/c/include/mem.h	(revision 2498b9515ac2e60a64adc171d59e3a1f3aaef339)
@@ -1,4 +1,5 @@
 /*
  * Copyright (c) 2005 Martin Decky
+ * Copyright (c) 2018 Jiri Svoboda
  * All rights reserved.
  *
@@ -49,4 +50,6 @@
 extern int memcmp(const void *, const void *, size_t)
     __attribute__((nonnull(1, 2)));
+extern void *memchr(const void *, int, size_t)
+    __attribute__((nonnull(1)));
 
 #endif
Index: uspace/lib/c/test/main.c
===================================================================
--- uspace/lib/c/test/main.c	(revision bfe90b6b7580ea944610d1ef63bd58ffa1dba441)
+++ uspace/lib/c/test/main.c	(revision 2498b9515ac2e60a64adc171d59e3a1f3aaef339)
@@ -34,4 +34,5 @@
 PCUT_IMPORT(circ_buf);
 PCUT_IMPORT(fibril_timer);
+PCUT_IMPORT(mem);
 PCUT_IMPORT(odict);
 PCUT_IMPORT(qsort);
Index: uspace/lib/c/test/mem.c
===================================================================
--- uspace/lib/c/test/mem.c	(revision 2498b9515ac2e60a64adc171d59e3a1f3aaef339)
+++ uspace/lib/c/test/mem.c	(revision 2498b9515ac2e60a64adc171d59e3a1f3aaef339)
@@ -0,0 +1,118 @@
+/*
+ * Copyright (c) 2018 Jiri Svoboda
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <mem.h>
+#include <pcut/pcut.h>
+
+PCUT_INIT;
+
+PCUT_TEST_SUITE(mem);
+
+/** memcpy function */
+PCUT_TEST(memcpy)
+{
+	char buf[5];
+	void *p;
+
+	p = memcpy(buf, "abc\0d", 5);
+	PCUT_ASSERT_TRUE(p == buf);
+
+	PCUT_ASSERT_INT_EQUALS('a', buf[0]);
+	PCUT_ASSERT_INT_EQUALS('b', buf[1]);
+	PCUT_ASSERT_INT_EQUALS('c', buf[2]);
+	PCUT_ASSERT_INT_EQUALS('\0', buf[3]);
+	PCUT_ASSERT_INT_EQUALS('d', buf[4]);
+}
+
+/** memmove function */
+PCUT_TEST(memmove)
+{
+	char buf[] = "abc\0d";
+	void *p;
+
+	p = memmove(buf, buf + 1, 4);
+	PCUT_ASSERT_TRUE(p == buf);
+
+	PCUT_ASSERT_INT_EQUALS('b', buf[0]);
+	PCUT_ASSERT_INT_EQUALS('c', buf[1]);
+	PCUT_ASSERT_INT_EQUALS('\0', buf[2]);
+	PCUT_ASSERT_INT_EQUALS('d', buf[3]);
+	PCUT_ASSERT_INT_EQUALS('d', buf[4]);
+}
+
+/** memcmp function */
+PCUT_TEST(memcmp)
+{
+	const char *s1 = "ab" "\0" "1d";
+	const char *s2 = "ab" "\0" "2d";
+	int c;
+
+	c = memcmp(s1, s2, 3);
+	PCUT_ASSERT_INT_EQUALS(0, c);
+
+	c = memcmp(s1, s2, 4);
+	PCUT_ASSERT_TRUE(c < 0);
+
+	c = memcmp(s2, s1, 4);
+	PCUT_ASSERT_TRUE(c > 0);
+}
+
+/** memchr function */
+PCUT_TEST(memchr)
+{
+	const char *s = "abc\0d";
+	void *p;
+
+	p = memchr(s, 'd', 5);
+	PCUT_ASSERT_TRUE(p == s + 4);
+
+	p = memchr(s, '\0', 5);
+	PCUT_ASSERT_TRUE(p == s + 3);
+
+	p = memchr(s, 'd', 4);
+	PCUT_ASSERT_TRUE(p == NULL);
+}
+
+/** memset function */
+PCUT_TEST(memset)
+{
+	char buf[5];
+	void *p;
+
+	buf[0] = buf[1] = buf[2] = buf[3] = buf[4] = 'a';
+	p = memset(buf, 'x', 5);
+	PCUT_ASSERT_TRUE(p == buf);
+
+	PCUT_ASSERT_INT_EQUALS('x', buf[0]);
+	PCUT_ASSERT_INT_EQUALS('x', buf[1]);
+	PCUT_ASSERT_INT_EQUALS('x', buf[2]);
+	PCUT_ASSERT_INT_EQUALS('x', buf[3]);
+	PCUT_ASSERT_INT_EQUALS('x', buf[4]);
+}
+
+PCUT_EXPORT(mem);
Index: uspace/lib/posix/include/posix/string.h
===================================================================
--- uspace/lib/posix/include/posix/string.h	(revision bfe90b6b7580ea944610d1ef63bd58ffa1dba441)
+++ uspace/lib/posix/include/posix/string.h	(revision 2498b9515ac2e60a64adc171d59e3a1f3aaef339)
@@ -36,7 +36,4 @@
 #ifndef POSIX_STRING_H_
 #define POSIX_STRING_H_
-
-#include "sys/types.h"
-
 /*
  * TODO: not implemented due to missing locale support
@@ -48,24 +45,7 @@
 
 #include <_bits/NULL.h>
+#include <_bits/size_t.h>
 
-/*
- * These are the same as in HelenOS libc.
- * It would be possible to directly include <str.h> and <mem.h> but
- * it is better not to pollute POSIX namespace with other functions
- * defined in that header.
- *
- * Because libposix is always linked with libc, providing only these
- * forward declarations ought to be enough.
- */
-
-/* From mem.h */
-// #define bzero(ptr, len)  memset((ptr), 0, (len))
-extern void *memset(void *, int, size_t)
-    __attribute__((nonnull(1)));
-extern void *memcpy(void *, const void *, size_t)
-    __attribute__((nonnull(1, 2)));
-extern void *memmove(void *, const void *, size_t)
-    __attribute__((nonnull(1, 2)));
-
+#include "libc/mem.h"
 
 /* Copying and Concatenation */
@@ -80,11 +60,9 @@
 extern char *strndup(const char *s, size_t n);
 
-/* String/Array Comparison */
-extern int memcmp(const void *mem1, const void *mem2, size_t n);
+/* String Comparison */
 extern int strcmp(const char *s1, const char *s2);
 extern int strncmp(const char *s1, const char *s2, size_t n);
 
 /* Search Functions */
-extern void *memchr(const void *mem, int c, size_t n);
 extern char *strchr(const char *s, int c);
 extern char *strrchr(const char *s, int c);
@@ -122,5 +100,4 @@
 #endif
 
-
 #endif  // POSIX_STRING_H_
 
Index: uspace/lib/posix/src/string.c
===================================================================
--- uspace/lib/posix/src/string.c	(revision bfe90b6b7580ea944610d1ef63bd58ffa1dba441)
+++ uspace/lib/posix/src/string.c	(revision 2498b9515ac2e60a64adc171d59e3a1f3aaef339)
@@ -288,27 +288,4 @@
 
 	return 0;
-}
-
-/**
- * Find byte in memory.
- *
- * @param mem Memory area in which to look for the byte.
- * @param c Byte to look for.
- * @param n Maximum number of bytes to be inspected.
- * @return Pointer to the specified byte on success,
- *     NULL pointer otherwise.
- */
-void *memchr(const void *mem, int c, size_t n)
-{
-	assert(mem != NULL);
-
-	const unsigned char *s = mem;
-
-	for (size_t i = 0; i < n; ++i) {
-		if (s[i] == (unsigned char) c) {
-			return (void *) &s[i];
-		}
-	}
-	return NULL;
 }
 
