Index: uspace/lib/c/Makefile
===================================================================
--- uspace/lib/c/Makefile	(revision 6c44036225de80ff6c2c43f95480748e8b3892bd)
+++ uspace/lib/c/Makefile	(revision 75c430e3f06e21429663d9c36e1d4a0a6f8c5660)
@@ -163,4 +163,5 @@
 	generic/stats.c \
 	generic/assert.c \
+	generic/bsearch.c \
 	generic/pio_trace.c \
 	generic/qsort.c \
Index: uspace/lib/c/generic/bsearch.c
===================================================================
--- uspace/lib/c/generic/bsearch.c	(revision 75c430e3f06e21429663d9c36e1d4a0a6f8c5660)
+++ uspace/lib/c/generic/bsearch.c	(revision 75c430e3f06e21429663d9c36e1d4a0a6f8c5660)
@@ -0,0 +1,78 @@
+/*
+ * 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.
+ */
+
+/** @addtogroup libc
+ * @{
+ */
+
+/**
+ * @file
+ * @brief Binary search.
+ */
+
+#include <bsearch.h>
+#include <stddef.h>
+
+/** Binary search.
+ *
+ * @param key Key to search for
+ * @param base Array of objects
+ * @param nmemb Number of objects in array
+ * @param size Size of each object
+ * @param compar Comparison function
+ */
+void *bsearch(const void *key, const void *base, size_t nmemb, size_t size,
+    int (*compar)(const void *, const void *))
+{
+	size_t pividx;
+	const void *pivot;
+	int r;
+
+	while (nmemb != 0) {
+		pividx = nmemb / 2;
+		pivot = base + size * pividx;
+
+		r = compar(key, pivot);
+		if (r == 0)
+			return (void *)pivot;
+
+		if (r < 0) {
+			/* Now only look at members preceding pivot */
+			nmemb = pividx;
+		} else {
+			/* Now only look at members following pivot */
+			nmemb = nmemb - pividx - 1;
+			base += size * (pividx + 1);
+		}
+	}
+
+	return NULL;
+}
+
+/** @}
+ */
Index: uspace/lib/c/generic/stdlib.c
===================================================================
--- uspace/lib/c/generic/stdlib.c	(revision 6c44036225de80ff6c2c43f95480748e8b3892bd)
+++ uspace/lib/c/generic/stdlib.c	(revision 75c430e3f06e21429663d9c36e1d4a0a6f8c5660)
@@ -166,4 +166,32 @@
 }
 
+/** Get environment list entry.
+ *
+ * Note that this function is not reentrant. The returned string is only
+ * guaranteed to be valid until the next call to @c getenv.
+ *
+ * @param name Entry name
+ * @return Pointer to string or @c NULL if not found
+ */
+char *getenv(const char *name)
+{
+	(void) name;
+	return NULL;
+}
+
+/** Execute command.
+ *
+ * @param string Command to execute or @c NULL
+ *
+ * @return If @a string is @c NULL, return zero (no command processor
+ *         available). If @a string is not @c NULL, return 1 (failure).
+ */
+int system(const char *string)
+{
+	if (string == NULL)
+		return 0;
+
+	return 1;
+}
 
 /** Compute quotient and remainder of int division.
Index: uspace/lib/c/include/bsearch.h
===================================================================
--- uspace/lib/c/include/bsearch.h	(revision 75c430e3f06e21429663d9c36e1d4a0a6f8c5660)
+++ uspace/lib/c/include/bsearch.h	(revision 75c430e3f06e21429663d9c36e1d4a0a6f8c5660)
@@ -0,0 +1,46 @@
+/*
+ * 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.
+ */
+
+/** @addtogroup libc
+ * @{
+ */
+/** @file
+ */
+
+#ifndef LIBC_BSEARCH_H_
+#define LIBC_BSEARCH_H_
+
+#include <stddef.h>
+
+extern void *bsearch(const void *, const void *, size_t, size_t,
+    int (*)(const void *, const void *));
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/c/include/stdlib.h
===================================================================
--- uspace/lib/c/include/stdlib.h	(revision 6c44036225de80ff6c2c43f95480748e8b3892bd)
+++ uspace/lib/c/include/stdlib.h	(revision 75c430e3f06e21429663d9c36e1d4a0a6f8c5660)
@@ -38,4 +38,5 @@
 #include <_bits/size_t.h>
 #include <_bits/wchar_t.h>
+#include <bsearch.h>
 #include <malloc.h>
 #include <qsort.h>
@@ -74,5 +75,5 @@
 
 extern int rand(void);
-extern void srand(unsigned int seed);
+extern void srand(unsigned int);
 
 extern void abort(void) __attribute__((noreturn));
@@ -82,4 +83,7 @@
 extern int at_quick_exit(void (*)(void));
 extern void quick_exit(int);
+
+extern char *getenv(const char *);
+extern int system(const char *);
 
 extern int atoi(const char *);
Index: uspace/lib/c/test/stdlib.c
===================================================================
--- uspace/lib/c/test/stdlib.c	(revision 6c44036225de80ff6c2c43f95480748e8b3892bd)
+++ uspace/lib/c/test/stdlib.c	(revision 75c430e3f06e21429663d9c36e1d4a0a6f8c5660)
@@ -282,4 +282,83 @@
 }
 
+/** getenv function */
+PCUT_TEST(getenv)
+{
+	char *s;
+
+	s = getenv("FOO");
+	PCUT_ASSERT_NULL(s);
+}
+
+/** Test availability of command processor */
+PCUT_TEST(system_null)
+{
+	int rc;
+
+	rc = system(NULL);
+	PCUT_ASSERT_INT_EQUALS(0, rc);
+}
+
+/** Test running a command */
+PCUT_TEST(system_cmd)
+{
+	int rc;
+
+	/* This should fail as system is just a stub */
+	rc = system("/app/bdsh");
+	PCUT_ASSERT_INT_EQUALS(1, rc);
+}
+
+/** Comparison function for bsearch test */
+static int test_compar(const void *a, const void *b)
+{
+	const int *ia, *ib;
+
+	ia = (const int *)a;
+	ib = (const int *)b;
+
+	return *ia - *ib;
+}
+
+PCUT_TEST(bsearch)
+{
+	int numbers[] = { 1, 2, 6, 7, 7, 10, 100, 120 };
+	int k;
+	void *r;
+
+	k = 0;
+	r = bsearch(&k, numbers, sizeof(numbers) / sizeof(int), sizeof(int),
+	    test_compar);
+	PCUT_ASSERT_NULL(r);
+
+	k = 1;
+	r = bsearch(&k, numbers, sizeof(numbers) / sizeof(int), sizeof(int),
+	    test_compar);
+	PCUT_ASSERT_NOT_NULL(r);
+	PCUT_ASSERT_INT_EQUALS(1, *(int *)r);
+
+	k = 3;
+	r = bsearch(&k, numbers, sizeof(numbers) / sizeof(int), sizeof(int),
+	    test_compar);
+	PCUT_ASSERT_NULL(r);
+
+	k = 6;
+	r = bsearch(&k, numbers, sizeof(numbers) / sizeof(int), sizeof(int),
+	    test_compar);
+	PCUT_ASSERT_NOT_NULL(r);
+	PCUT_ASSERT_INT_EQUALS(6, *(int *)r);
+
+	k = 7;
+	r = bsearch(&k, numbers, sizeof(numbers) / sizeof(int), sizeof(int),
+	    test_compar);
+	PCUT_ASSERT_NOT_NULL(r);
+	PCUT_ASSERT_INT_EQUALS(7, *(int *)r);
+
+	k = 200;
+	r = bsearch(&k, numbers, sizeof(numbers) / sizeof(int), sizeof(int),
+	    test_compar);
+	PCUT_ASSERT_NULL(r);
+}
+
 /** Integer division */
 PCUT_TEST(div_func)
Index: uspace/lib/posix/include/posix/stdlib.h
===================================================================
--- uspace/lib/posix/include/posix/stdlib.h	(revision 6c44036225de80ff6c2c43f95480748e8b3892bd)
+++ uspace/lib/posix/include/posix/stdlib.h	(revision 75c430e3f06e21429663d9c36e1d4a0a6f8c5660)
@@ -47,12 +47,6 @@
 extern long long llabs(long long i);
 
-/* Array Functions */
-extern void *bsearch(const void *key, const void *base,
-    size_t nmemb, size_t size, int (*compar)(const void *, const void *));
-
 /* Environment Access */
-extern char *getenv(const char *name);
 extern int putenv(char *string);
-extern int system(const char *string);
 
 /* Symbolic Links */
Index: uspace/lib/posix/src/stdlib.c
===================================================================
--- uspace/lib/posix/src/stdlib.c	(revision 6c44036225de80ff6c2c43f95480748e8b3892bd)
+++ uspace/lib/posix/src/stdlib.c	(revision 75c430e3f06e21429663d9c36e1d4a0a6f8c5660)
@@ -84,55 +84,4 @@
 
 /**
- * Binary search in a sorted array.
- *
- * @param key Object to search for.
- * @param base Pointer to the first element of the array.
- * @param nmemb Number of elements in the array.
- * @param size Size of each array element.
- * @param compar Comparison function.
- * @return Pointer to a matching element, or NULL if none can be found.
- */
-void *bsearch(const void *key, const void *base,
-    size_t nmemb, size_t size, int (*compar)(const void *, const void *))
-{
-	while (nmemb > 0) {
-		const void *middle = base + (nmemb / 2) * size;
-		int cmp = compar(key, middle);
-		if (cmp == 0) {
-			return (void *) middle;
-		}
-		if (middle == base) {
-			/*
-			 * There is just one member left to check and it
-			 * didn't match the key. Avoid infinite loop.
-			 */
-			break;
-		}
-		if (cmp < 0) {
-			nmemb = nmemb / 2;
-		} else if (cmp > 0) {
-			nmemb = nmemb - (nmemb / 2);
-			base = middle;
-		}
-	}
-
-	return NULL;
-}
-
-/**
- * Retrieve a value of the given environment variable.
- *
- * Since HelenOS doesn't support env variables at the moment,
- * this function always returns NULL.
- *
- * @param name Name of the variable.
- * @return Value of the variable or NULL if such variable does not exist.
- */
-char *getenv(const char *name)
-{
-	return NULL;
-}
-
-/**
  *
  * @param name
@@ -143,19 +92,4 @@
 {
 	// TODO: low priority, just a compile-time dependency of binutils
-	not_implemented();
-	return 0;
-}
-
-/**
- * Issue a command.
- *
- * @param string String to be passed to a command interpreter or NULL.
- * @return Termination status of the command if the command is not NULL,
- *     otherwise indicate whether there is a command interpreter (non-zero)
- *     or not (zero).
- */
-int system(const char *string)
-{
-	// TODO: does nothing at the moment
 	not_implemented();
 	return 0;
