aboutsummaryrefslogtreecommitdiffstats
path: root/include/stdlib.h
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2015-10-10 19:19:27 +0200
committerMattias Andrée <maandree@operamail.com>2015-10-10 19:19:27 +0200
commit27b9483ea910efa12ddb57110855219140d1d51b (patch)
treeee0c884eaad983d1465ff75035db4cd138be9e0e /include/stdlib.h
parentupdate todo (diff)
downloadslibc-27b9483ea910efa12ddb57110855219140d1d51b.tar.gz
slibc-27b9483ea910efa12ddb57110855219140d1d51b.tar.bz2
slibc-27b9483ea910efa12ddb57110855219140d1d51b.tar.xz
add atoi, atol, atoll, and atoq
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to 'include/stdlib.h')
-rw-r--r--include/stdlib.h57
1 files changed, 57 insertions, 0 deletions
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