Index: uspace/lib/c/Makefile
===================================================================
--- uspace/lib/c/Makefile	(revision aec41c815c786936ee5edb382011403392833e23)
+++ uspace/lib/c/Makefile	(revision d39c46e03cdf4c2a6b309cc0244b5bf42b3b6000)
@@ -85,4 +85,5 @@
 	generic/str.c \
 	generic/str_error.c \
+	generic/strtol.c \
 	generic/l18n/langs.c \
 	generic/fibril.c \
Index: uspace/lib/c/generic/str.c
===================================================================
--- uspace/lib/c/generic/str.c	(revision aec41c815c786936ee5edb382011403392833e23)
+++ uspace/lib/c/generic/str.c	(revision d39c46e03cdf4c2a6b309cc0244b5bf42b3b6000)
@@ -1273,128 +1273,4 @@
 }
 
-/** Convert string to a number.
- * Core of strtol and strtoul functions.
- *
- * @param nptr		Pointer to string.
- * @param endptr	If not NULL, function stores here pointer to the first
- * 			invalid character.
- * @param base		Zero or number between 2 and 36 inclusive.
- * @param sgn		It's set to 1 if minus found.
- * @return		Result of conversion.
- */
-static unsigned long
-_strtoul(const char *nptr, char **endptr, int base, char *sgn)
-{
-	unsigned char c;
-	unsigned long result = 0;
-	unsigned long a, b;
-	const char *str = nptr;
-	const char *tmpptr;
-	
-	while (isspace(*str))
-		str++;
-	
-	if (*str == '-') {
-		*sgn = 1;
-		++str;
-	} else if (*str == '+')
-		++str;
-	
-	if (base) {
-		if ((base == 1) || (base > 36)) {
-			/* FIXME: set errno to EINVAL */
-			return 0;
-		}
-		if ((base == 16) && (*str == '0') && ((str[1] == 'x') ||
-		    (str[1] == 'X'))) {
-			str += 2;
-		}
-	} else {
-		base = 10;
-		
-		if (*str == '0') {
-			base = 8;
-			if ((str[1] == 'X') || (str[1] == 'x'))  {
-				base = 16;
-				str += 2;
-			}
-		}
-	}
-	
-	tmpptr = str;
-
-	while (*str) {
-		c = *str;
-		c = (c >= 'a' ? c - 'a' + 10 : (c >= 'A' ? c - 'A' + 10 :
-		    (c <= '9' ? c - '0' : 0xff)));
-		if (c >= base) {
-			break;
-		}
-		
-		a = (result & 0xff) * base + c;
-		b = (result >> 8) * base + (a >> 8);
-		
-		if (b > (ULONG_MAX >> 8)) {
-			/* overflow */
-			/* FIXME: errno = ERANGE*/
-			return ULONG_MAX;
-		}
-	
-		result = (b << 8) + (a & 0xff);
-		++str;
-	}
-	
-	if (str == tmpptr) {
-		/*
-		 * No number was found => first invalid character is the first
-		 * character of the string.
-		 */
-		/* FIXME: set errno to EINVAL */
-		str = nptr;
-		result = 0;
-	}
-	
-	if (endptr)
-		*endptr = (char *) str;
-
-	if (nptr == str) {
-		/*FIXME: errno = EINVAL*/
-		return 0;
-	}
-
-	return result;
-}
-
-/** Convert initial part of string to long int according to given base.
- * The number may begin with an arbitrary number of whitespaces followed by
- * optional sign (`+' or `-'). If the base is 0 or 16, the prefix `0x' may be
- * inserted and the number will be taken as hexadecimal one. If the base is 0
- * and the number begin with a zero, number will be taken as octal one (as with
- * base 8). Otherwise the base 0 is taken as decimal.
- *
- * @param nptr		Pointer to string.
- * @param endptr	If not NULL, function stores here pointer to the first
- * 			invalid character.
- * @param base		Zero or number between 2 and 36 inclusive.
- * @return		Result of conversion.
- */
-long int strtol(const char *nptr, char **endptr, int base)
-{
-	char sgn = 0;
-	unsigned long number = 0;
-	
-	number = _strtoul(nptr, endptr, base, &sgn);
-
-	if (number > LONG_MAX) {
-		if ((sgn) && (number == (unsigned long) (LONG_MAX) + 1)) {
-			/* FIXME: set 0 to errno */
-			return number;
-		}
-		/* FIXME: set ERANGE to errno */
-		return (sgn ? LONG_MIN : LONG_MAX);
-	}
-	
-	return (sgn ? -number : number);
-}
 
 /** Duplicate string.
@@ -1457,27 +1333,4 @@
 	str_ncpy(dest, size + 1, src, size);
 	return dest;
-}
-
-/** Convert initial part of string to unsigned long according to given base.
- * The number may begin with an arbitrary number of whitespaces followed by
- * optional sign (`+' or `-'). If the base is 0 or 16, the prefix `0x' may be
- * inserted and the number will be taken as hexadecimal one. If the base is 0
- * and the number begin with a zero, number will be taken as octal one (as with
- * base 8). Otherwise the base 0 is taken as decimal.
- *
- * @param nptr		Pointer to string.
- * @param endptr	If not NULL, function stores here pointer to the first
- * 			invalid character
- * @param base		Zero or number between 2 and 36 inclusive.
- * @return		Result of conversion.
- */
-unsigned long strtoul(const char *nptr, char **endptr, int base)
-{
-	char sgn = 0;
-	unsigned long number = 0;
-	
-	number = _strtoul(nptr, endptr, base, &sgn);
-
-	return (sgn ? -number : number);
 }
 
Index: uspace/lib/c/generic/strtol.c
===================================================================
--- uspace/lib/c/generic/strtol.c	(revision d39c46e03cdf4c2a6b309cc0244b5bf42b3b6000)
+++ uspace/lib/c/generic/strtol.c	(revision d39c46e03cdf4c2a6b309cc0244b5bf42b3b6000)
@@ -0,0 +1,257 @@
+/*
+ * Copyright (c) 2005 Martin Decky
+ * Copyright (c) 2008 Jiri Svoboda
+ * Copyright (c) 2011 Martin Sucha
+ * Copyright (c) 2011 Oleg Romanenko
+ * Copyright (c) 2011 Jiri Zarevucky
+ * 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
+ */
+
+#include <inttypes.h>
+#include <stdlib.h>
+#include <limits.h>
+#include <ctype.h>
+#include <assert.h>
+
+// TODO: unit tests
+
+static inline int _digit_value(int c)
+{
+	if (isdigit(c)) {
+		return c - '0';
+	} else if (islower(c)) {
+		return c - 'a' + 10;
+	} else if (isupper(c)) {
+		return c - 'A' + 10;
+	}
+	return INT_MAX;
+}
+
+static inline uintmax_t _strtoumax(
+    const char *restrict nptr, char **restrict endptr, int base,
+    bool *restrict sgn)
+{
+	assert(nptr != NULL);
+	assert(sgn != NULL);
+
+	/* Skip leading whitespace. */
+
+	while (isspace(*nptr)) {
+		nptr++;
+	}
+
+	/* Parse sign, if any. */
+
+	switch (*nptr) {
+	case '-':
+		*sgn = true;
+		nptr++;
+		break;
+	case '+':
+		nptr++;
+		break;
+	}
+
+	/* Figure out the base. */
+
+	if (base == 0) {
+		if (*nptr == '0') {
+			if (tolower(nptr[1]) == 'x') {
+				/* 0x... is hex. */
+				base = 16;
+				nptr += 2;
+			} else {
+				/* 0... is octal. */
+				base = 8;
+			}
+		} else {
+			/* Anything else is decimal by default. */
+			base = 10;
+		}
+	} else if (base == 16) {
+		/* Allow hex number to be prefixed with "0x". */
+		if (nptr[0] == '0' && tolower(nptr[1]) == 'x') {
+			nptr += 2;
+		}
+	} else if (base < 0 || base == 1 || base > 36) {
+		errno = EINVAL;
+		return 0;
+	}
+
+	/* Read the value. */
+
+	uintmax_t result = 0;
+	int digit;
+
+	while (digit = _digit_value(*nptr), digit < base) {
+
+		if (__builtin_mul_overflow(result, base, &result) ||
+		    __builtin_add_overflow(result, digit, &result)) {
+
+			errno = ERANGE;
+			result = UINTMAX_MAX;
+			break;
+		}
+
+		nptr++;
+	}
+
+	/* Set endptr. */
+
+	if (endptr != NULL) {
+		/* Move the pointer to the end of the number,
+		 * in case it isn't there already.
+		 */
+		while (_digit_value(*nptr) < base) {
+			nptr++;
+		}
+
+		*endptr = (char *) nptr;
+	}
+
+	return result;
+}
+
+static inline intmax_t _strtosigned(const char *nptr, char **endptr, int base,
+    intmax_t min, intmax_t max)
+{
+	bool sgn = false;
+	uintmax_t number = _strtoumax(nptr, endptr, base, &sgn);
+
+	if (number > (uintmax_t) max) {
+		if (sgn && (number - 1 == (uintmax_t) max)) {
+			return min;
+		}
+
+		errno = ERANGE;
+		return (sgn ? min : max);
+	}
+
+	return (sgn ? -number : number);
+}
+
+static inline uintmax_t _strtounsigned(const char *nptr, char **endptr, int base,
+    uintmax_t max)
+{
+	bool sgn = false;
+	uintmax_t number = _strtoumax(nptr, endptr, base, &sgn);
+
+	if (sgn) {
+		if (number == 0) {
+			return 0;
+		} else {
+			errno = ERANGE;
+			return max;
+		}
+	}
+
+	if (number > max) {
+		errno = ERANGE;
+		return max;
+	}
+
+	return number;
+}
+
+/** Convert initial part of string to long int according to given base.
+ * The number may begin with an arbitrary number of whitespaces followed by
+ * optional sign (`+' or `-'). If the base is 0 or 16, the prefix `0x' may be
+ * inserted and the number will be taken as hexadecimal one. If the base is 0
+ * and the number begin with a zero, number will be taken as octal one (as with
+ * base 8). Otherwise the base 0 is taken as decimal.
+ *
+ * @param nptr		Pointer to string.
+ * @param[out] endptr	If not NULL, function stores here pointer to the first
+ * 			invalid character.
+ * @param base		Zero or number between 2 and 36 inclusive.
+ * @return		Result of conversion.
+ */
+long strtol(const char *nptr, char **endptr, int base)
+{
+	return _strtosigned(nptr, endptr, base, LONG_MIN, LONG_MAX);
+}
+
+/** Convert initial part of string to unsigned long according to given base.
+ * The number may begin with an arbitrary number of whitespaces followed by
+ * optional sign (`+' or `-'). If the base is 0 or 16, the prefix `0x' may be
+ * inserted and the number will be taken as hexadecimal one. If the base is 0
+ * and the number begin with a zero, number will be taken as octal one (as with
+ * base 8). Otherwise the base 0 is taken as decimal.
+ *
+ * @param nptr		Pointer to string.
+ * @param[out] endptr	If not NULL, function stores here pointer to the first
+ * 			invalid character
+ * @param base		Zero or number between 2 and 36 inclusive.
+ * @return		Result of conversion.
+ */
+unsigned long strtoul(const char *nptr, char **endptr, int base)
+{
+	return _strtounsigned(nptr, endptr, base, ULONG_MAX);
+}
+
+long long strtoll(const char *nptr, char **endptr, int base)
+{
+	return _strtosigned(nptr, endptr, base, LLONG_MIN, LLONG_MAX);
+}
+
+unsigned long long strtoull(const char *nptr, char **endptr, int base)
+{
+	return _strtounsigned(nptr, endptr, base, ULLONG_MAX);
+}
+
+intmax_t strtoimax(const char *nptr, char **endptr, int base)
+{
+	return _strtosigned(nptr, endptr, base, INTMAX_MIN, INTMAX_MAX);
+}
+
+uintmax_t strtoumax(const char *nptr, char **endptr, int base)
+{
+	return _strtounsigned(nptr, endptr, base, UINTMAX_MAX);
+}
+
+int atoi(const char *nptr)
+{
+	return (int)strtol(nptr, NULL, 10);
+}
+
+long atol(const char *nptr)
+{
+	return strtol(nptr, NULL, 10);
+}
+
+long long atoll(const char *nptr)
+{
+	return strtoll(nptr, NULL, 10);
+}
+
+/** @}
+ */
Index: uspace/lib/c/include/inttypes.h
===================================================================
--- uspace/lib/c/include/inttypes.h	(revision aec41c815c786936ee5edb382011403392833e23)
+++ uspace/lib/c/include/inttypes.h	(revision d39c46e03cdf4c2a6b309cc0244b5bf42b3b6000)
@@ -38,4 +38,11 @@
 #include <_bits/inttypes.h>
 
+#ifndef __HELENOS_DISABLE_INTMAX__
+intmax_t strtoimax(const char *__restrict__ nptr,
+    char **__restrict__ endptr, int base);
+uintmax_t strtoumax(const char *__restrict__ nptr,
+    char **__restrict__ endptr, int base);
+#endif
+
 #endif
 
Index: uspace/lib/c/include/stdlib.h
===================================================================
--- uspace/lib/c/include/stdlib.h	(revision aec41c815c786936ee5edb382011403392833e23)
+++ uspace/lib/c/include/stdlib.h	(revision d39c46e03cdf4c2a6b309cc0244b5bf42b3b6000)
@@ -48,4 +48,13 @@
 extern void exit(int) __attribute__((noreturn));
 
+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);
+
 #endif
 
Index: uspace/lib/posix/Makefile
===================================================================
--- uspace/lib/posix/Makefile	(revision aec41c815c786936ee5edb382011403392833e23)
+++ uspace/lib/posix/Makefile	(revision d39c46e03cdf4c2a6b309cc0244b5bf42b3b6000)
@@ -76,5 +76,4 @@
 	source/stdio/scanf.c \
 	source/stdlib.c \
-	source/stdlib/strtol.c \
 	source/stdlib/strtold.c \
 	source/string.c \
Index: uspace/lib/posix/include/posix/inttypes.h
===================================================================
--- uspace/lib/posix/include/posix/inttypes.h	(revision aec41c815c786936ee5edb382011403392833e23)
+++ uspace/lib/posix/include/posix/inttypes.h	(revision d39c46e03cdf4c2a6b309cc0244b5bf42b3b6000)
@@ -43,10 +43,4 @@
 #include "libc/inttypes.h"
 
-extern intmax_t __POSIX_DEF__(strtoimax)(const char *__restrict__ nptr,
-    char **__restrict__ endptr, int base);
-extern uintmax_t __POSIX_DEF__(strtoumax)(const char *__restrict__ nptr,
-    char **__restrict__ endptr, int base);
-
-
 #endif /* POSIX_INTTYPES_H_ */
 
Index: uspace/lib/posix/include/posix/stdlib.h
===================================================================
--- uspace/lib/posix/include/posix/stdlib.h	(revision aec41c815c786936ee5edb382011403392833e23)
+++ uspace/lib/posix/include/posix/stdlib.h	(revision d39c46e03cdf4c2a6b309cc0244b5bf42b3b6000)
@@ -101,14 +101,14 @@
 
 /* Integer Conversion */
-extern int __POSIX_DEF__(atoi)(const char *nptr);
-extern long int __POSIX_DEF__(atol)(const char *nptr);
-extern long long int __POSIX_DEF__(atoll)(const char *nptr);
-extern long int __POSIX_DEF__(strtol)(const char *__restrict__ nptr,
+extern int atoi(const char *nptr);
+extern long int atol(const char *nptr);
+extern long long int atoll(const char *nptr);
+extern long int strtol(const char *__restrict__ nptr,
     char **__restrict__ endptr, int base);
-extern long long int __POSIX_DEF__(strtoll)(const char *__restrict__ nptr,
+extern long long int strtoll(const char *__restrict__ nptr,
     char **__restrict__ endptr, int base);
-extern unsigned long int __POSIX_DEF__(strtoul)(const char *__restrict__ nptr,
+extern unsigned long int strtoul(const char *__restrict__ nptr,
     char **__restrict__ endptr, int base);
-extern unsigned long long int __POSIX_DEF__(strtoull)(
+extern unsigned long long int strtoull(
     const char *__restrict__ nptr, char **__restrict__ endptr, int base);
 
Index: uspace/lib/posix/source/stdio/scanf.c
===================================================================
--- uspace/lib/posix/source/stdio/scanf.c	(revision aec41c815c786936ee5edb382011403392833e23)
+++ uspace/lib/posix/source/stdio/scanf.c	(revision d39c46e03cdf4c2a6b309cc0244b5bf42b3b6000)
@@ -563,5 +563,5 @@
 				}
 				char *fmt_new = NULL;
-				width = posix_strtol(fmt, &fmt_new, 10);
+				width = strtol(fmt, &fmt_new, 10);
 				if (width != 0) {
 					fmt = fmt_new;
@@ -648,7 +648,7 @@
 				/* Try to convert the integer. */
 				if (int_conv_unsigned) {
-					ures = posix_strtoull(cur_limited, &cur_updated, int_conv_base);
+					ures = strtoull(cur_limited, &cur_updated, int_conv_base);
 				} else {
-					sres = posix_strtoll(cur_limited, &cur_updated, int_conv_base);
+					sres = strtoll(cur_limited, &cur_updated, int_conv_base);
 				}
 
Index: uspace/lib/posix/source/stdlib/strtol.c
===================================================================
--- uspace/lib/posix/source/stdlib/strtol.c	(revision aec41c815c786936ee5edb382011403392833e23)
+++ 	(revision )
@@ -1,399 +1,0 @@
-/*
- * Copyright (c) 2011 Jiri Zarevucky
- * 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 libposix
- * @{
- */
-/** @file Backend for integer conversions.
- */
-
-#define LIBPOSIX_INTERNAL
-#define __POSIX_DEF__(x) posix_##x
-
-#include "../internal/common.h"
-#include "posix/stdlib.h"
-
-#include "posix/ctype.h"
-
-#include <errno.h>
-
-#include "posix/inttypes.h"
-#include "posix/limits.h"
-
-/**
- * Decides whether a digit belongs to a particular base.
- *
- * @param c Character representation of the digit.
- * @param base Base against which the digit shall be tested.
- * @return True if the digit belongs to the base, false otherwise.
- */
-static inline bool is_digit_in_base(int c, int base)
-{
-	if (base <= 10) {
-		return c >= '0' && c < '0' + base;
-	} else {
-		return isdigit(c) ||
-		    (tolower(c) >= 'a' && tolower(c) < ('a' + base - 10));
-	}
-}
-
-/**
- * Derive a digit from its character representation.
- *
- * @param c Character representation of the digit.
- * @return Digit value represented by an integer.
- */
-static inline int digit_value(int c)
-{
-	if (c <= '9') {
-		return c - '0';
-	} else {
-		return 10 + tolower(c) - 'a';
-	}
-}
-
-/**
- * Generic function for parsing an integer from it's string representation.
- * Different variants differ in lower and upper bounds.
- * The parsed string returned by this function is always positive, sign
- * information is provided via a dedicated parameter.
- *
- * @param nptr Input string.
- * @param endptr If non-NULL, *endptr is set to the position of the first
- *     unrecognized character. If no digit has been parsed, value of
- *     nptr is stored there (regardless of any skipped characters at the
- *     beginning).
- * @param base Expected base of the string representation. If 0, base is
- *    determined to be decimal, octal or hexadecimal using the same rules
- *    as C syntax. Otherwise, value must be between 2 and 36, inclusive.
- * @param min_value Lower bound for the resulting conversion.
- * @param max_value Upper bound for the resulting conversion.
- * @param out_negative Either NULL for unsigned conversion or a pointer to the
- *     bool variable into which shall be placed the negativity of the resulting
- *     converted value.
- * @return The absolute value of the parsed value, or the closest in-range value
- *     if the parsed value is out of range. If the input is invalid, zero is
- *     returned and errno is set to EINVAL.
- */
-static inline uintmax_t internal_strtol(
-    const char *restrict nptr, char **restrict endptr, int base,
-    const intmax_t min_value, const uintmax_t max_value,
-    bool *restrict out_negative)
-{
-	if (nptr == NULL) {
-		errno = EINVAL;
-		return 0;
-	}
-	
-	if (base < 0 || base == 1 || base > 36) {
-		errno = EINVAL;
-		return 0;
-	}
-	
-	/* The maximal absolute value that can be returned in this run.
-	 * Depends on sign.
-	 */
-	uintmax_t real_max_value = max_value;
-	
-	/* Current index in the input string. */
-	size_t i = 0;
-	bool negative = false;
-	
-	/* Skip whitespace. */
-	while (isspace(nptr[i])) {
-		i++;
-	}
-	
-	/* Parse sign. */
-	switch (nptr[i]) {
-	case '-':
-		negative = true;
-		
-		/* The strange computation is are there to avoid a corner case
-		 * where -min_value can't be represented in intmax_t.
-		 * (I'm not exactly sure what the semantics are in such a
-		 *  case, but this should be safe for any case.)
-		 */
-		real_max_value = (min_value == 0)
-		    ? 0
-		    :(((uintmax_t) -(min_value + 1)) + 1);
-		
-		/* Fallthrough */
-	case '+':
-		i++;
-	}
-	
-	/* Figure out the base. */
-	switch (base) {
-	case 0:
-		if (nptr[i] == '0') {
-			if (tolower(nptr[i + 1]) == 'x') {
-				/* 0x... is hex. */
-				base = 16;
-				i += 2;
-			} else {
-				/* 0... is octal. */
-				base = 8;
-			}
-		} else {
-			/* Anything else is decimal by default. */
-			base = 10;
-		}
-		break;
-	case 16:
-		/* Allow hex number to be prefixed with "0x". */
-		if (nptr[i] == '0' && tolower(nptr[i + 1]) == 'x') {
-			i += 2;
-		}
-		break;
-	}
-	
-	if (!is_digit_in_base(nptr[i], base)) {
-		/* No digits to parse, invalid input. */
-		
-		errno = EINVAL;
-		if (endptr != NULL) {
-			*endptr = (char *) nptr;
-		}
-		return 0;
-	}
-	
-	/* Maximal value to which a digit can be added without a risk
-	 * of overflow.
-	 */
-	uintmax_t max_safe_value = (real_max_value - base + 1) / base;
-	
-	uintmax_t result = 0;
-	
-	if (real_max_value == 0) {
-		/* Special case when a negative number is parsed as
-		 * unsigned integer. Only -0 is accepted.
-		 */
-		
-		while (is_digit_in_base(nptr[i], base)) {
-			if (nptr[i] != '0') {
-				errno = ERANGE;
-				result = 0;
-			}
-			i++;
-		}
-	}
-	
-	while (is_digit_in_base(nptr[i], base)) {
-		int digit = digit_value(nptr[i]);
-		
-		if (result > max_safe_value) {
-			/* corner case, check for overflow */
-			
-			uintmax_t boundary = (real_max_value - digit) / base;
-			
-			if (result > boundary) {
-				/* overflow */
-				errno = ERANGE;
-				result = real_max_value;
-				break;
-			}
-		}
-		
-		result = result * base + digit;
-		i++;
-	}
-	
-	if (endptr != NULL) {
-		/* Move the pointer to the end of the number,
-		 * in case it isn't there already.
-		 */
-		while (is_digit_in_base(nptr[i], base)) {
-			i++;
-		}
-		
-		*endptr = (char *) &nptr[i];
-	}
-	if (out_negative != NULL) {
-		*out_negative = negative;
-	}
-	return result;
-}
-
-/**
- * Convert a string to an integer.
- *
- * @param nptr Input string.
- * @return Result of the conversion.
- */
-int posix_atoi(const char *nptr)
-{
-	bool neg = false;
-	uintmax_t result =
-	    internal_strtol(nptr, NULL, 10, INT_MIN, INT_MAX, &neg);
-
-	return (neg ? ((int) -result) : (int) result);
-}
-
-/**
- * Convert a string to a long integer.
- *
- * @param nptr Input string.
- * @return Result of the conversion.
- */
-long posix_atol(const char *nptr)
-{
-	bool neg = false;
-	uintmax_t result =
-	    internal_strtol(nptr, NULL, 10, LONG_MIN, LONG_MAX, &neg);
-
-	return (neg ? ((long) -result) : (long) result);
-}
-
-/**
- * Convert a string to a long long integer.
- *
- * @param nptr Input string.
- * @return Result of the conversion.
- */
-long long posix_atoll(const char *nptr)
-{
-	bool neg = false;
-	uintmax_t result =
-	    internal_strtol(nptr, NULL, 10, LLONG_MIN, LLONG_MAX, &neg);
-
-	return (neg ? ((long long) -result) : (long long) result);
-}
-
-/**
- * Convert a string to a long integer.
- *
- * @param nptr Input string.
- * @param endptr Pointer to the final part of the string which
- *     was not used for conversion.
- * @param base Expected base of the string representation.
- * @return Result of the conversion.
- */
-long posix_strtol(const char *restrict nptr, char **restrict endptr, int base)
-{
-	bool neg = false;
-	uintmax_t result =
-	    internal_strtol(nptr, endptr, base, LONG_MIN, LONG_MAX, &neg);
-
-	return (neg ? ((long) -result) : ((long) result));
-}
-
-/**
- * Convert a string to a long long integer.
- *
- * @param nptr Input string.
- * @param endptr Pointer to the final part of the string which
- *     was not used for conversion.
- * @param base Expected base of the string representation.
- * @return Result of the conversion.
- */
-long long posix_strtoll(
-    const char *restrict nptr, char **restrict endptr, int base)
-{
-	bool neg = false;
-	uintmax_t result =
-	    internal_strtol(nptr, endptr, base, LLONG_MIN, LLONG_MAX, &neg);
-
-	return (neg ? ((long long) -result) : (long long) result);
-}
-
-/**
- * Convert a string to a largest signed integer type.
- *
- * @param nptr Input string.
- * @param endptr Pointer to the final part of the string which
- *     was not used for conversion.
- * @param base Expected base of the string representation.
- * @return Result of the conversion.
- */
-intmax_t posix_strtoimax(
-    const char *restrict nptr, char **restrict endptr, int base)
-{
-	bool neg = false;
-	uintmax_t result =
-	    internal_strtol(nptr, endptr, base, INTMAX_MIN, INTMAX_MAX, &neg);
-
-	return (neg ? ((intmax_t) -result) : (intmax_t) result);
-}
-
-/**
- * Convert a string to an unsigned long integer.
- *
- * @param nptr Input string.
- * @param endptr Pointer to the final part of the string which
- *     was not used for conversion.
- * @param base Expected base of the string representation.
- * @return Result of the conversion.
- */
-unsigned long posix_strtoul(
-    const char *restrict nptr, char **restrict endptr, int base)
-{
-	uintmax_t result =
-	    internal_strtol(nptr, endptr, base, 0, ULONG_MAX, NULL);
-
-	return (unsigned long) result;
-}
-
-/**
- * Convert a string to an unsigned long long integer.
- *
- * @param nptr Input string.
- * @param endptr Pointer to the final part of the string which
- *     was not used for conversion.
- * @param base Expected base of the string representation.
- * @return Result of the conversion.
- */
-unsigned long long posix_strtoull(
-    const char *restrict nptr, char **restrict endptr, int base)
-{
-	uintmax_t result =
-	    internal_strtol(nptr, endptr, base, 0, ULLONG_MAX, NULL);
-
-	return (unsigned long long) result;
-}
-
-/**
- * Convert a string to a largest unsigned integer type.
- *
- * @param nptr Input string.
- * @param endptr Pointer to the final part of the string which
- *     was not used for conversion.
- * @param base Expected base of the string representation.
- * @return Result of the conversion.
- */
-uintmax_t posix_strtoumax(
-    const char *restrict nptr, char **restrict endptr, int base)
-{
-	uintmax_t result =
-	    internal_strtol(nptr, endptr, base, 0, UINTMAX_MAX, NULL);
-
-	return result;
-}
-
-/** @}
- */
