From 1414c2217f7fa44c7e82927c5747a6080b9ab647 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Mon, 25 Aug 2014 19:14:03 +0200 Subject: m MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/libmdsserver/macro-bits.h | 48 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) (limited to 'src/libmdsserver') diff --git a/src/libmdsserver/macro-bits.h b/src/libmdsserver/macro-bits.h index f1feddd..06207a3 100644 --- a/src/libmdsserver/macro-bits.h +++ b/src/libmdsserver/macro-bits.h @@ -88,6 +88,38 @@ */ #define atoull(str) ((unsigned long long)atoll(str)) +/** + * Convert the beginning of a `const char*` to an `int8_t` + * + * @param str:const char* The string that begins with an integer + * @return The integer at the beginning of the string + */ +# define ato8(str) ((int8_t)atoi(str)) + +/** + * Convert the beginning of a `const char*` to an `uint8_t` + * + * @param str:const char* The string that begins with an integer + * @return The integer at the beginning of the string + */ +# define atou8(str) ((uint8_t)atou(str)) + +/** + * Convert the beginning of a `const char*` to an `int16_t` + * + * @param str:const char* The string that begins with an integer + * @return The integer at the beginning of the string + */ +# define ato16(str) ((int16_t)atoi(str)) + +/** + * Convert the beginning of a `const char*` to an `uint16_t` + * + * @param str:const char* The string that begins with an integer + * @return The integer at the beginning of the string + */ +# define atou16(str) ((uint16_t)atou(str)) + #if __WORDSIZE == 64 /** * Convert the beginning of a `const char*` to an `int32_t` @@ -154,6 +186,22 @@ # define atou64(str) ((uint64_t)atoull(str)) #endif +/** + * Convert the beginning of a `const char*` to an `intmax_t` + * + * @param str:const char* The string that begins with an integer + * @return The integer at the beginning of the string + */ +# define atoj(str) ((intmax_t)atou64(str)) + +/** + * Convert the beginning of a `const char*` to an `uintmax_t` + * + * @param str:const char* The string that begins with an integer + * @return The integer at the beginning of the string + */ +# define atouj(str) ((uintmax_t)atou64(str)) + #endif -- cgit v1.2.3-70-g09d2