Index: uspace/app/tester/mm/common.c
===================================================================
--- uspace/app/tester/mm/common.c	(revision b1696194837e19c7e4d446880d20ede25043bad4)
+++ uspace/app/tester/mm/common.c	(revision 44e85413b5db9e8d690890c835ecbdf8ec078d8e)
@@ -35,4 +35,5 @@
 #include <stdlib.h>
 #include <errno.h>
+#include <malloc.h>
 #include "../tester.h"
 #include "common.h"
Index: uspace/lib/c/generic/bsearch.c
===================================================================
--- uspace/lib/c/generic/bsearch.c	(revision b1696194837e19c7e4d446880d20ede25043bad4)
+++ 	(revision )
@@ -1,78 +1,0 @@
-/*
- * 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/malloc.c
===================================================================
--- uspace/lib/c/generic/malloc.c	(revision b1696194837e19c7e4d446880d20ede25043bad4)
+++ uspace/lib/c/generic/malloc.c	(revision 44e85413b5db9e8d690890c835ecbdf8ec078d8e)
@@ -34,5 +34,5 @@
  */
 
-#include <malloc.h>
+#include <stdlib.h>
 #include <stdalign.h>
 #include <stdbool.h>
@@ -47,4 +47,5 @@
 #include <stdlib.h>
 #include <adt/gcdlcm.h>
+#include <malloc.h>
 
 #include "private/malloc.h"
@@ -773,24 +774,4 @@
 }
 
-/** Allocate memory by number of elements
- *
- * @param nmemb Number of members to allocate.
- * @param size  Size of one member in bytes.
- *
- * @return Allocated memory or NULL.
- *
- */
-void *calloc(const size_t nmemb, const size_t size)
-{
-	// FIXME: Check for overflow
-
-	void *block = malloc(nmemb * size);
-	if (block == NULL)
-		return NULL;
-
-	memset(block, 0, nmemb * size);
-	return block;
-}
-
 /** Allocate memory
  *
Index: uspace/lib/c/generic/qsort.c
===================================================================
--- uspace/lib/c/generic/qsort.c	(revision b1696194837e19c7e4d446880d20ede25043bad4)
+++ 	(revision )
@@ -1,214 +1,0 @@
-/*
- * Copyright (c) 2017 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 Quicksort.
- */
-
-#include <qsort.h>
-#include <stdbool.h>
-#include <stddef.h>
-
-/** Quicksort spec */
-typedef struct {
-	void *base;
-	size_t nmemb;
-	size_t size;
-	int (*compar)(const void *, const void *, void *);
-	void *arg;
-} qs_spec_t;
-
-/** Comparison function wrapper.
- *
- * Performs qsort_r comparison using qsort comparison function
- *
- * @param a First element
- * @param b Second element
- * @param arg qsort comparison function
- */
-static int compar_wrap(const void *a, const void *b, void *arg)
-{
-	int (*compar)(const void *, const void *) =
-	    (int (*)(const void *, const void *))arg;
-
-	return compar(a, b);
-}
-
-/** Determine if one element is less-than another element.
- *
- * @param qs Quicksort spec
- * @param i First element index
- * @param j Second element index
- */
-static bool elem_lt(qs_spec_t *qs, size_t i, size_t j)
-{
-	const void *a;
-	const void *b;
-	int r;
-
-	a = qs->base + i * qs->size;
-	b = qs->base + j * qs->size;
-
-	r = qs->compar(a, b, qs->arg);
-
-	return r < 0;
-}
-
-/** Swap two elements.
- *
- * @param qs Quicksort spec
- * @param i First element index
- * @param j Second element index
- */
-static void elem_swap(qs_spec_t *qs, size_t i, size_t j)
-{
-	char *a;
-	char *b;
-	char t;
-	size_t k;
-
-	a = qs->base + i * qs->size;
-	b = qs->base + j * qs->size;
-
-	for (k = 0; k < qs->size; k++) {
-		t = a[k];
-		a[k] = b[k];
-		b[k] = t;
-	}
-}
-
-/** Partition a range of indices.
- *
- * @param qs Quicksort spec
- * @param lo Lower bound (inclusive)
- * @param hi Upper bound (inclusive)
- * @return Pivot index
- */
-static size_t partition(qs_spec_t *qs, size_t lo, size_t hi)
-{
-	size_t pivot;
-	size_t i, j;
-
-	pivot = lo + (hi - lo) / 2;
-	i = lo;
-	j = hi;
-	while (true) {
-		while (elem_lt(qs, i, pivot))
-			++i;
-		while (elem_lt(qs, pivot, j))
-			--j;
-
-		if (i >= j)
-			return j;
-
-		elem_swap(qs, i, j);
-
-		/* Need to follow pivot movement */
-		if (i == pivot)
-			pivot = j;
-		else if (j == pivot)
-			pivot = i;
-
-		i++;
-		j--;
-	}
-}
-
-/** Sort a range of indices.
- *
- * @param qs Quicksort spec
- * @param lo Lower bound (inclusive)
- * @param hi Upper bound (inclusive)
- */
-static void quicksort(qs_spec_t *qs, size_t lo, size_t hi)
-{
-	size_t p;
-
-	if (lo < hi) {
-		p = partition(qs, lo, hi);
-		quicksort(qs, lo, p);
-		quicksort(qs, p + 1, hi);
-	}
-}
-
-/** Quicksort.
- *
- * @param base Array to sort
- * @param nmemb Number of array members
- * @param size Size of member in bytes
- * @param compar Comparison function
- */
-void qsort(void *base, size_t nmemb, size_t size, int (*compar)(const void *,
-    const void *))
-{
-	qs_spec_t qs;
-
-	if (nmemb == 0)
-		return;
-
-	qs.base = base;
-	qs.nmemb = nmemb;
-	qs.size = size;
-	qs.compar = compar_wrap;
-	qs.arg = compar;
-
-	quicksort(&qs, 0, nmemb - 1);
-}
-
-/** Quicksort with extra argument to comparison function.
- *
- * @param base Array to sort
- * @param nmemb Number of array members
- * @param size Size of member in bytes
- * @param compar Comparison function
- * @param arg Argument to comparison function
- */
-void qsort_r(void *base, size_t nmemb, size_t size, int (*compar)(const void *,
-    const void *, void *), void *arg)
-{
-	qs_spec_t qs;
-
-	if (nmemb == 0)
-		return;
-
-	qs.base = base;
-	qs.nmemb = nmemb;
-	qs.size = size;
-	qs.compar = compar;
-	qs.arg = arg;
-
-	quicksort(&qs, 0, nmemb - 1);
-}
-
-/** @}
- */
Index: uspace/lib/c/include/bsearch.h
===================================================================
--- uspace/lib/c/include/bsearch.h	(revision b1696194837e19c7e4d446880d20ede25043bad4)
+++ 	(revision )
@@ -1,51 +1,0 @@
-/*
- * 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>
-#include <_bits/decls.h>
-
-__C_DECLS_BEGIN;
-
-extern void *bsearch(const void *, const void *, size_t, size_t,
-    int (*)(const void *, const void *));
-
-__C_DECLS_END;
-
-#endif
-
-/** @}
- */
Index: uspace/lib/c/include/malloc.h
===================================================================
--- uspace/lib/c/include/malloc.h	(revision b1696194837e19c7e4d446880d20ede25043bad4)
+++ uspace/lib/c/include/malloc.h	(revision 44e85413b5db9e8d690890c835ecbdf8ec078d8e)
@@ -39,21 +39,7 @@
 #include <_bits/decls.h>
 
-__C_DECLS_BEGIN;
-
-extern void *malloc(size_t size)
-    __attribute__((malloc));
-extern void *calloc(size_t nmemb, size_t size)
-    __attribute__((malloc));
-extern void *realloc(void *addr, size_t size)
-    __attribute__((warn_unused_result));
-extern void free(void *addr);
-
-__C_DECLS_END;
-
 #ifdef _HELENOS_SOURCE
 __HELENOS_DECLS_BEGIN;
 
-extern void *memalign(size_t align, size_t size)
-    __attribute__((malloc));
 extern void *heap_check(void);
 
Index: uspace/lib/c/include/qsort.h
===================================================================
--- uspace/lib/c/include/qsort.h	(revision b1696194837e19c7e4d446880d20ede25043bad4)
+++ 	(revision )
@@ -1,56 +1,0 @@
-/*
- * Copyright (c) 2017 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_QSORT_H_
-#define _LIBC_QSORT_H_
-
-#include <stddef.h>
-#include <_bits/decls.h>
-
-__C_DECLS_BEGIN;
-extern void qsort(void *, size_t, size_t, int (*)(const void *,
-    const void *));
-__C_DECLS_END;
-
-#ifdef _HELENOS_SOURCE
-__HELENOS_DECLS_BEGIN;
-extern void qsort_r(void *, size_t, size_t, int (*)(const void *,
-    const void *, void *), void *);
-__HELENOS_DECLS_END;
-#endif
-
-#endif
-
-/** @}
- */
Index: uspace/lib/c/include/stdlib.h
===================================================================
--- uspace/lib/c/include/stdlib.h	(revision b1696194837e19c7e4d446880d20ede25043bad4)
+++ 	(revision )
@@ -1,116 +1,0 @@
-/*
- * Copyright (c) 2005 Martin Decky
- * 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_STDLIB_H_
-#define _LIBC_STDLIB_H_
-
-#include <_bits/size_t.h>
-#include <_bits/wchar_t.h>
-#include <_bits/uchar.h>
-#include <_bits/decls.h>
-#include <bsearch.h>
-#include <malloc.h>
-#include <qsort.h>
-
-#define EXIT_SUCCESS 0
-#define EXIT_FAILURE 1
-
-#define RAND_MAX  714025
-
-#define MB_CUR_MAX 4
-
-__C_DECLS_BEGIN;
-
-/** Type returned by the div function */
-typedef struct {
-	/** Quotient */
-	int quot;
-	/** Remainder */
-	int rem;
-} div_t;
-
-/** Type returned by the ldiv function */
-typedef struct {
-	/** Quotient */
-	long quot;
-	/** Remainder */
-	long rem;
-} ldiv_t;
-
-/** Type returned by the lldiv function */
-typedef struct {
-	/** Quotient */
-	long long quot;
-	/** Remainder */
-	long long rem;
-} lldiv_t;
-
-extern long double strtold(const char *, char **);
-
-extern int rand(void);
-extern void srand(unsigned int);
-
-extern void abort(void) __attribute__((noreturn));
-extern int atexit(void (*)(void));
-extern void exit(int) __attribute__((noreturn));
-extern void _Exit(int) __attribute__((noreturn));
-extern int at_quick_exit(void (*)(void));
-extern void quick_exit(int);
-
-extern char *getenv(const char *);
-extern int system(const char *);
-
-extern int abs(int);
-extern long labs(long);
-extern long long llabs(long long);
-
-extern int atoi(const char *);
-extern long atol(const char *);
-extern long long atoll(const char *);
-
-extern long strtol(const char *__restrict__, char **__restrict__, int);
-extern long long strtoll(const char *__restrict__, char **__restrict__, int);
-extern unsigned long strtoul(const char *__restrict__, char **__restrict__, int);
-extern unsigned long long strtoull(const char *__restrict__, char **__restrict__, int);
-
-extern div_t div(int, int);
-extern ldiv_t ldiv(long, long);
-extern lldiv_t lldiv(long long, long long);
-
-__C_DECLS_END;
-
-#endif
-
-/** @}
- */
Index: uspace/lib/c/meson.build
===================================================================
--- uspace/lib/c/meson.build	(revision b1696194837e19c7e4d446880d20ede25043bad4)
+++ uspace/lib/c/meson.build	(revision 44e85413b5db9e8d690890c835ecbdf8ec078d8e)
@@ -62,4 +62,8 @@
 src += files(
 	'common/stdc/mem.c',
+	'common/stdc/bsearch.c',
+	'common/stdc/qsort.c',
+	'common/stdc/calloc.c',
+
 	'generic/libc.c',
 	'generic/as.c',
@@ -160,6 +164,4 @@
 	'generic/stats.c',
 	'generic/assert.c',
-	'generic/bsearch.c',
-	'generic/qsort.c',
 	'generic/ubsan.c',
 	'generic/uuid.c',
Index: uspace/lib/posix/include/posix/stdlib.h
===================================================================
--- uspace/lib/posix/include/posix/stdlib.h	(revision b1696194837e19c7e4d446880d20ede25043bad4)
+++ uspace/lib/posix/include/posix/stdlib.h	(revision 44e85413b5db9e8d690890c835ecbdf8ec078d8e)
@@ -37,5 +37,5 @@
 #define POSIX_STDLIB_H_
 
-#include <libc/stdlib.h>
+#include <common/stdlib.h>
 #include <sys/types.h>
 
Index: uspace/lib/posix/src/stdio.c
===================================================================
--- uspace/lib/posix/src/stdio.c	(revision b1696194837e19c7e4d446880d20ede25043bad4)
+++ uspace/lib/posix/src/stdio.c	(revision 44e85413b5db9e8d690890c835ecbdf8ec078d8e)
@@ -55,5 +55,5 @@
 #include <io/printf_core.h>
 #include <str.h>
-#include <malloc.h>
+#include <stdlib.h>
 #include <adt/list.h>
 
Index: uspace/lib/posix/src/time.c
===================================================================
--- uspace/lib/posix/src/time.c	(revision b1696194837e19c7e4d446880d20ede25043bad4)
+++ uspace/lib/posix/src/time.c	(revision 44e85413b5db9e8d690890c835ecbdf8ec078d8e)
@@ -47,5 +47,5 @@
 
 #include <fibril.h>
-#include <malloc.h>
+#include <stdlib.h>
 #include <task.h>
 #include <stddef.h>
Index: uspace/lib/posix/src/unistd.c
===================================================================
--- uspace/lib/posix/src/unistd.c	(revision b1696194837e19c7e4d446880d20ede25043bad4)
+++ uspace/lib/posix/src/unistd.c	(revision 44e85413b5db9e8d690890c835ecbdf8ec078d8e)
@@ -50,5 +50,5 @@
 #include <task.h>
 #include <stats.h>
-#include <malloc.h>
+#include <stdlib.h>
 #include <vfs/vfs.h>
 
