From ce216e062c95dafe87df1edc638f45b61ebe3a03 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Mon, 11 Jul 2016 20:00:22 +0200 Subject: Use *_MAX instead of __WORDSIZE 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 | 35 +++++++++++++++-------------------- 1 file changed, 15 insertions(+), 20 deletions(-) (limited to 'src/libmdsserver/macro-bits.h') diff --git a/src/libmdsserver/macro-bits.h b/src/libmdsserver/macro-bits.h index 07ed8c0..abfb34a 100644 --- a/src/libmdsserver/macro-bits.h +++ b/src/libmdsserver/macro-bits.h @@ -19,18 +19,11 @@ #define MDS_LIBMDSSERVER_MACRO_BITS_H +#include #include #include -#ifndef __WORDSIZE -# if defined(__x86_64__) && !defined(__ILP32__) -# define __WORDSIZE 64 -# else -# define __WORDSIZE 32 -# endif -#endif - /** * Convert the beginning of a `const char*` to a `size_t` @@ -120,7 +113,7 @@ */ # define atou16(str) ((uint16_t)atou(str)) -#if __WORDSIZE == 64 +#if UINT_MAX == UINT32_MAX /** * Convert the beginning of a `const char*` to an `int32_t` * @@ -136,39 +129,41 @@ * @return The integer at the beginning of the string */ # define atou32(str) ((uint32_t)atou(str)) - +#else /** - * Convert the beginning of a `const char*` to an `int64_t` + * Convert the beginning of a `const char*` to an `int32_t` * * @param str:const char* The string that begins with an integer * @return The integer at the beginning of the string */ -# define ato64(str) ((int64_t)atol(str)) +# define ato32(str) ((int32_t)atol(str)) /** - * Convert the beginning of a `const char*` to an `uint64_t` + * Convert the beginning of a `const char*` to an `uint32_t` * * @param str:const char* The string that begins with an integer * @return The integer at the beginning of the string */ -# define atou64(str) ((uint64_t)atoul(str)) -#else +# define atou32(str) ((uint32_t)atoul(str)) +#endif + +#if ULONG_MAX == UINT64_MAX /** - * Convert the beginning of a `const char*` to an `int32_t` + * Convert the beginning of a `const char*` to an `int64_t` * * @param str:const char* The string that begins with an integer * @return The integer at the beginning of the string */ -# define ato32(str) ((int32_t)atol(str)) +# define ato64(str) ((int64_t)atol(str)) /** - * Convert the beginning of a `const char*` to an `uint32_t` + * Convert the beginning of a `const char*` to an `uint64_t` * * @param str:const char* The string that begins with an integer * @return The integer at the beginning of the string */ -# define atou32(str) ((uint32_t)atoul(str)) - +# define atou64(str) ((uint64_t)atoul(str)) +#else /** * Convert the beginning of a `const char*` to an `int64_t` * -- cgit v1.2.3-70-g09d2