From 27b9483ea910efa12ddb57110855219140d1d51b Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Sat, 10 Oct 2015 19:19:27 +0200 Subject: add atoi, atol, atoll, and atoq MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- include/stdlib.h | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) (limited to 'include') diff --git a/include/stdlib.h b/include/stdlib.h index eca92b2..4aa95f2 100644 --- a/include/stdlib.h +++ b/include/stdlib.h @@ -133,6 +133,63 @@ char* relpath(const char*, const char*) #endif +/** + * Convert a string to an integer, + * without checking for errors. + * + * Note that, the behaviour is unspecified + * if the string contains anything else than + * digits and either a leading '-' (hyphen) + * or a leading plus. + * + * @param string The string to convert. + * @return The integer encoded by the string. + */ +int atoi(const char*) + __GCC_ONLY(__attribute__((warn_unused_result, nonnull, pure))); + +/** + * Convert a string to an integer, + * without checking for errors. + * + * Note that, the behaviour is unspecified + * if the string contains anything else than + * digits and either a leading '-' (hyphen) + * or a leading plus. + * + * @param string The string to convert. + * @return The integer encoded by the string. + */ +long int atol(const char*) + __GCC_ONLY(__attribute__((warn_unused_result, nonnull, pure))); + +/** + * Convert a string to an integer, + * without checking for errors. + * + * Note that, the behaviour is unspecified + * if the string contains anything else than + * digits and either a leading '-' (hyphen) + * or a leading plus. + * + * @param string The string to convert. + * @return The integer encoded by the string. + */ +long long int atoll(const char*) + __GCC_ONLY(__attribute__((warn_unused_result, nonnull, pure))); + +#if !defined(__PORTABLE) +/** + * This function is identical to `atoll`. + * + * This is a Linux libc extension. + */ +long long int atoq(const char*) + __deprecated("'atoq' is obsolete and not portable, use 'atoll' instead.") + __GCC_ONLY(__attribute__((warn_unused_result, nonnull, pure))); +#endif + + /* TODO implement rand-functions */ #define RAND_MAX 1 -- cgit v1.2.3-70-g09d2