Skip to contentSkip to conversation

multipath-tools: replace 64bit archs macros by __LP64__

PATCH In review Xose Vazquez Perez 2 participants 4 messages May 19, 2017 – Jun 13, 2017 Device mapper

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 multipath-tools: replace 64bit archs macros by __LP64__

Rationale: https://gcc.gnu.org/onlinedocs/cpp/Common-Predefined-Macros.html

__LP64__
_LP64
These macros are defined, with value 1, if (and only if) the compilation is for a target where long int and pointer both use 64-bits and int uses 32-bit.

Cc Christophe Varoqui <[email protected]>
Cc device-mapper development <[email protected]>
---
 kpartx/lopart.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
kpartx/lopart.c +3 -4
index 4e6dab4..3c16eb0 100644
@@ -38,11 +38,10 @@
 #define LOOP_CTL_GET_FREE       0x4C82
 #endif
 
-#if !defined (__alpha__) && !defined (__ia64__) && !defined (__x86_64__) \
-	&& !defined (__s390x__)
-#define int2ptr(x)	((void *) ((int) x))
-#else
+#if defined (__LP64__)
 #define int2ptr(x)	((void *) ((long) x))
+#else
+#define int2ptr(x)	((void *) ((int) x))
 #endif
 
 static char *
Signature · 1 line
2.13.0
#1 lore raw
Quoted 24 lines · Xose Vazquez Perez

Rationale: https://gcc.gnu.org/onlinedocs/cpp/Common-Predefined-Macros.html

__LP64__
_LP64
These macros are defined, with value 1, if (and only if) the compilation is for a target where long int and pointer both use 64-bits and int uses 32-bit.

Cc Christophe Varoqui <[email protected]>
Cc device-mapper development <[email protected]>
---
 kpartx/lopart.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
kpartx/lopart.c +0 -1
index 4e6dab4..3c16eb0 100644
@@ -38,11 +38,10 @@
 #define LOOP_CTL_GET_FREE       0x4C82
 #endif
 
-#if !defined (__alpha__) && !defined (__ia64__) && !defined (__x86_64__) \

kpartx/lopart.c line 47

Quoted 10 lines
kpartx/lopart.c +3 -3
-	&& !defined (__s390x__)
-#define int2ptr(x)	((void *) ((int) x))
-#else
+#if defined (__LP64__)
 #define int2ptr(x)	((void *) ((long) x))
+#else
+#define int2ptr(x)	((void *) ((int) x))
 #endif
 
 static char *

Hello Xose,

Since there is only one user of int2ptr(), please remove the macro definitions and use the following construct: (void *)(uintptr_t)(...).

Thanks,

Bart.

#2 lore raw
Quoted 34 lines · Bart Van Assche
Quoted 33 lines · Xose Vazquez Perez

Rationale: https://gcc.gnu.org/onlinedocs/cpp/Common-Predefined-Macros.html

__LP64__
_LP64
These macros are defined, with value 1, if (and only if) the compilation is for a target where long int and pointer both use 64-bits and int uses 32-bit.

Cc Christophe Varoqui <[email protected]>
Cc device-mapper development <[email protected]>
---
 kpartx/lopart.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
kpartx/lopart.c +3 -4
index 4e6dab4..3c16eb0 100644
@@ -38,11 +38,10 @@
 #define LOOP_CTL_GET_FREE       0x4C82
 #endif
 
-#if !defined (__alpha__) && !defined (__ia64__) && !defined (__x86_64__) \
-	&& !defined (__s390x__)
-#define int2ptr(x)	((void *) ((int) x))
-#else
+#if defined (__LP64__)
 #define int2ptr(x)	((void *) ((long) x))
+#else
+#define int2ptr(x)	((void *) ((int) x))
 #endif
 
Quoted 6 lines

kpartx/lopart.c line 47

Quoted 1 line
kpartx/lopart.c +0 -0
 static char *

Hello Xose,

Since there is only one user of int2ptr(), please remove the macro definitions and use the following construct: (void *)(uintptr_t)(...).

No time for a proper patch, use it as an interim fix.

#3 lore raw
Quoted 5 lines · Xose Vazquez Perez
Quoted 2 lines · Bart Van Assche

Since there is only one user of int2ptr(), please remove the macro definitions and use the following construct: (void *)(uintptr_t)(...).

No time for a proper patch, use it as an interim fix.

Hello Jose,

I will post a patch to remove int2ptr().

Bart.