aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/libmdsserver/client-list.c2
-rw-r--r--src/libmdsserver/linked-list.c2
-rw-r--r--src/libmdsserver/macro-bits.h35
-rw-r--r--src/libmdsserver/mds-message.c2
4 files changed, 18 insertions, 23 deletions
diff --git a/src/libmdsserver/client-list.c b/src/libmdsserver/client-list.c
index 4a32b57..30e0832 100644
--- a/src/libmdsserver/client-list.c
+++ b/src/libmdsserver/client-list.c
@@ -47,7 +47,7 @@ static size_t to_power_of_two(size_t value)
value |= value >> 4;
value |= value >> 8;
value |= value >> 16;
-#if __WORDSIZE == 64
+#if SIZE_MAX == UINT64_MAX
value |= value >> 32;
#endif
return value + 1;
diff --git a/src/libmdsserver/linked-list.c b/src/libmdsserver/linked-list.c
index 3b60e83..6921951 100644
--- a/src/libmdsserver/linked-list.c
+++ b/src/libmdsserver/linked-list.c
@@ -47,7 +47,7 @@ static size_t to_power_of_two(size_t value)
value |= value >> 4;
value |= value >> 8;
value |= value >> 16;
-#if __WORDSIZE == 64
+#if SIZE_MAX == UINT64_MAX
value |= value >> 32;
#endif
return value + 1;
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`
*
diff --git a/src/libmdsserver/mds-message.c b/src/libmdsserver/mds-message.c
index e610bc0..5f2c536 100644
--- a/src/libmdsserver/mds-message.c
+++ b/src/libmdsserver/mds-message.c
@@ -516,7 +516,7 @@ int mds_message_unmarshal(mds_message_t* restrict this, char* restrict data)
this->buffer_size |= this->buffer_size >> 4;
this->buffer_size |= this->buffer_size >> 8;
this->buffer_size |= this->buffer_size >> 16;
-#if __WORDSIZE == 64
+#if SIZE_MAX == UINT64_MAX
this->buffer_size |= this->buffer_size >> 32;
#endif
this->buffer_size += 1;