diff mbox

multipath-tools: replace 64bit archs macros by __LP64__

Message ID 20170519013818.15130-1-xose.vazquez@gmail.com (mailing list archive)
State Not Applicable, archived
Delegated to: christophe varoqui
Headers show

Commit Message

Xose Vazquez Perez May 19, 2017, 1:38 a.m. UTC
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 <christophe.varoqui@opensvc.com>
Cc: device-mapper development <dm-devel@redhat.com>
Signed-off-by: Xose Vazquez Perez <xose.vazquez@gmail.com>
---
 kpartx/lopart.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

Comments

Bart Van Assche May 19, 2017, 3:31 a.m. UTC | #1
On Fri, 2017-05-19 at 03:38 +0200, Xose Vazquez Perez wrote:
> 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 <christophe.varoqui@opensvc.com>
> Cc: device-mapper development <dm-devel@redhat.com>
> Signed-off-by: Xose Vazquez Perez <xose.vazquez@gmail.com>
> ---
>  kpartx/lopart.c | 7 +++----
>  1 file changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/kpartx/lopart.c b/kpartx/lopart.c
> index 4e6dab4..3c16eb0 100644
> --- a/kpartx/lopart.c
> +++ b/kpartx/lopart.c
> @@ -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 *

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.

--
dm-devel mailing list
dm-devel@redhat.com
https://www.redhat.com/mailman/listinfo/dm-devel
Xose Vazquez Perez June 11, 2017, 7:14 p.m. UTC | #2
On 05/19/2017 05:31 AM, Bart Van Assche wrote:

> On Fri, 2017-05-19 at 03:38 +0200, Xose Vazquez Perez wrote:
>> 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 <christophe.varoqui@opensvc.com>
>> Cc: device-mapper development <dm-devel@redhat.com>
>> Signed-off-by: Xose Vazquez Perez <xose.vazquez@gmail.com>
>> ---
>>  kpartx/lopart.c | 7 +++----
>>  1 file changed, 3 insertions(+), 4 deletions(-)
>>
>> diff --git a/kpartx/lopart.c b/kpartx/lopart.c
>> index 4e6dab4..3c16eb0 100644
>> --- a/kpartx/lopart.c
>> +++ b/kpartx/lopart.c
>> @@ -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 *
> 
> 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.

--
dm-devel mailing list
dm-devel@redhat.com
https://www.redhat.com/mailman/listinfo/dm-devel
Bart Van Assche June 13, 2017, 3:38 p.m. UTC | #3
On Sun, 2017-06-11 at 21:14 +0200, Xose Vazquez Perez wrote:
> On 05/19/2017 05:31 AM, Bart Van Assche wrote:
> > 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.

--
dm-devel mailing list
dm-devel@redhat.com
https://www.redhat.com/mailman/listinfo/dm-devel
diff mbox

Patch

diff --git a/kpartx/lopart.c b/kpartx/lopart.c
index 4e6dab4..3c16eb0 100644
--- a/kpartx/lopart.c
+++ b/kpartx/lopart.c
@@ -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 *