[systemd-devel] [PATCH] shared/util.h: portable sizeof(long) == sizeof(int) test

Emil Renner Berthing systemd at esmil.dk
Fri Sep 19 11:26:53 PDT 2014


Don't rely on __WORDSIZE, but just standard LONG_MAX
and INT_MAX from limits.h.
---
 src/shared/util.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/shared/util.h b/src/shared/util.h
index 08d556f..00068c6 100644
--- a/src/shared/util.h
+++ b/src/shared/util.h
@@ -205,7 +205,7 @@ int safe_atod(const char *s, double *ret_d);
 
 int safe_atou8(const char *s, uint8_t *ret);
 
-#if __WORDSIZE == 32
+#if LONG_MAX == INT_MAX
 static inline int safe_atolu(const char *s, unsigned long *ret_u) {
         assert_cc(sizeof(unsigned long) == sizeof(unsigned));
         return safe_atou(s, (unsigned*) ret_u);
-- 
2.1.0



More information about the systemd-devel mailing list