diff options
author | Mattias Andrée <maandree@operamail.com> | 2014-08-25 19:14:03 +0200 |
---|---|---|
committer | Mattias Andrée <maandree@operamail.com> | 2014-08-25 19:14:03 +0200 |
commit | 1414c2217f7fa44c7e82927c5747a6080b9ab647 (patch) | |
tree | 89db4e97743671fb906b9b875fdd467d4dafbb12 /src/libmdsserver | |
parent | info: most of macros.h (diff) | |
download | mds-1414c2217f7fa44c7e82927c5747a6080b9ab647.tar.gz mds-1414c2217f7fa44c7e82927c5747a6080b9ab647.tar.bz2 mds-1414c2217f7fa44c7e82927c5747a6080b9ab647.tar.xz |
m
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to 'src/libmdsserver')
-rw-r--r-- | src/libmdsserver/macro-bits.h | 48 |
1 files changed, 48 insertions, 0 deletions
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 |