aboutsummaryrefslogtreecommitdiffstats
path: root/src/libmdsserver/macro-bits.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/libmdsserver/macro-bits.h')
-rw-r--r--src/libmdsserver/macro-bits.h35
1 files changed, 15 insertions, 20 deletions
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 <limits.h>
#include <stdint.h>
#include <stddef.h>
-#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`
*