Skip to contentSkip to conversation

Fix the 64-bit macro definition of mips architecture

PATCH New sujiaxun 3 participants 12 messages Apr 22, 2021 – Apr 26, 2021

lore
Share & tools
lore

sujiaxun

author
#0 lore raw

PATCH 1/1 Fix the 64-bit macro definition of mips architecture

https://github.com/torvalds/linux/blob/master/arch/mips/include/uapi/asm/shmbuf.h
The mips 64-bit macro definition in the kernel is "__mips64",
and the mips 64-bit macro definition in the ltp is "__arch64__".

---
 include/lapi/msgbuf.h | 2 +-
 include/lapi/sembuf.h | 2 +-
 include/lapi/shmbuf.h | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
include/lapi/msgbuf.h +1 -1
index f3277270d..f010695f1 100644
@@ -17,7 +17,7 @@
 #if defined(__mips__)
 #define HAVE_MSQID64_DS
 
-#if defined(__arch64__)
+#if defined(__mips64)
 /*
  * The msqid64_ds structure for the MIPS architecture.
  * Note extra padding because this structure is passed back and forth
include/lapi/sembuf.h +1 -1
index 4ef0483a0..58ad9dff5 100644
@@ -24,7 +24,7 @@
  * Pad space is left for 2 miscellaneous 64-bit values on mips64,
  * but used for the upper 32 bit of the time values on mips32.
  */
-#if defined(__arch64__)
+#if defined(__mips64)
 struct semid64_ds {
 	struct ipc64_perm sem_perm;		/* permissions .. see ipc.h */
 	long		 sem_otime;		/* last semop time */
include/lapi/shmbuf.h +1 -1
index 28ee33620..fe405ffe8 100644
@@ -27,7 +27,7 @@
  * data structure when moving to 64-bit time_t.
  */
 
-#if defined(__arch64__)
+#if defined(__mips64)
 struct shmid64_ds {
 	struct ipc64_perm	shm_perm;	/* operation perms */
 	size_t			shm_segsz;	/* size of segment (bytes) */

--
2.20.1

#1 lore raw

PATCH 1/1 Fix the 64-bit macro definition of mips architecture

Hi sujiaxun,

[ Cc: Viresh, the original author ]

Quoted 16 lines

https://github.com/torvalds/linux/blob/master/arch/mips/include/uapi/asm/shmbuf.h
The mips 64-bit macro definition in the kernel is "__mips64",
and the mips 64-bit macro definition in the ltp is "__arch64__".

---
 include/lapi/msgbuf.h | 2 +-
 include/lapi/sembuf.h | 2 +-
 include/lapi/shmbuf.h | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
include/lapi/msgbuf.h +0 -0
index f3277270d..f010695f1 100644

include/lapi/msgbuf.h line 20

Quoted 5 lines
include/lapi/msgbuf.h +1 -1
@@ -17,7 +17,7 @@
 #if defined(__mips__)
 #define HAVE_MSQID64_DS
 
-#if defined(__arch64__)
+#if defined(__mips64)

So __arch64__ is not defined for mips 64 bit? (as it's defined for sparc 64bit?) __mips64 is obviously correct and better readable, but is it really required? (you can check it with: echo | gcc -dM -E -).

Kind regards,
Petr

#2 lore raw

PATCH 1/1 Fix the 64-bit macro definition of mips architecture

Quoted 23 lines · Petr Vorel

Hi sujiaxun,

[ Cc: Viresh, the original author ]

Quoted 18 lines

https://github.com/torvalds/linux/blob/master/arch/mips/include/uapi/asm/shmbuf.h
The mips 64-bit macro definition in the kernel is "__mips64",
and the mips 64-bit macro definition in the ltp is "__arch64__".

---
 include/lapi/msgbuf.h | 2 +-
 include/lapi/sembuf.h | 2 +-
 include/lapi/shmbuf.h | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
include/lapi/msgbuf.h +0 -0
index f3277270d..f010695f1 100644
@@ -17,7 +17,7 @@
 #if defined(__mips__)
 #define HAVE_MSQID64_DS
Quoted 4 lines

include/lapi/msgbuf.h line 19

Quoted 2 lines
include/lapi/msgbuf.h +1 -1
-#if defined(__arch64__)
+#if defined(__mips64)

So __arch64__ is not defined for mips 64 bit? (as it's defined for sparc 64bit?) __mips64 is obviously correct and better readable, but is it really required?

I am not sure what you meant by "is it really required?" The #ifdef hackery here ? It is as can be seen in include/uapi/asm-generic/shmbuf.h in Linux source.

Quoted 1 line

(you can check it with: echo | gcc -dM -E -).

Signature · 1 line
viresh
#3 lore raw

PATCH 1/1 Fix the 64-bit macro definition of mips architecture

Hi Viresh,

...

Quoted 7 lines
Quoted 4 lines

Review

Quoted 2 lines
(quoted diff) +1 -1
-#if defined(__arch64__)
+#if defined(__mips64)

So __arch64__ is not defined for mips 64 bit? (as it's defined for sparc 64bit?) __mips64 is obviously correct and better readable, but is it really required?

I am not sure what you meant by "is it really required?" The #ifdef hackery here ? It is as can be seen in include/uapi/asm-generic/shmbuf.h in Linux source.

I mean if #if defined(__mips__) && defined(__arch64__) detect 64bit mips the patch would not be needed (although IMHO __mips64 is more descriptive than __arch64__, for which you need to search for which architecture it was defined).

But I'm not sure myself if __arch64__ is defined for mips 64bit.

Kind regards,
Petr

#4 lore raw

PATCH 1/1 Fix the 64-bit macro definition of mips architecture

Quoted 8 lines · Petr Vorel

Hi Viresh,

...

Quoted 4 lines
Quoted 4 lines

Review

Quoted 2 lines
(quoted diff) +1 -1
-#if defined(__arch64__)
+#if defined(__mips64)

So __arch64__ is not defined for mips 64 bit? (as it's defined for sparc 64bit?) __mips64 is obviously correct and better readable, but is it really required?

Quoted 5 lines
Quoted 2 lines

I am not sure what you meant by "is it really required?" The #ifdef hackery here ? It is as can be seen in include/uapi/asm-generic/shmbuf.h in Linux source.

I mean if #if defined(__mips__) && defined(__arch64__) detect 64bit mips the patch would not be needed (although IMHO __mips64 is more descriptive than __arch64__, for which you need to search for which architecture it was defined).

Ahh, right.

Actually the kernel has this instead:

#if __BITS_PER_LONG == 64

Quoted 1 line

But I'm not sure myself if __arch64__ is defined for mips 64bit.

Neither do I.

Signature · 1 line
viresh
author
#5 lore raw

PATCH 1/1 Fix the 64-bit macro definition of mips architecture

Quoted 17 lines · Viresh Kumar
Quoted 8 lines · Petr Vorel

Hi Viresh,

...

Quoted 4 lines
Quoted 4 lines

Review

Quoted 2 lines
(quoted diff) +1 -1
-#if defined(__arch64__)
+#if defined(__mips64)

So __arch64__ is not defined for mips 64 bit? (as it's defined for sparc 64bit?) __mips64 is obviously correct and better readable, but is it really required?

Quoted 5 lines
Quoted 2 lines

I am not sure what you meant by "is it really required?" The #ifdef hackery here ? It is as can be seen in include/uapi/asm-generic/shmbuf.h in Linux source.

I mean if #if defined(__mips__) && defined(__arch64__) detect 64bit mips the patch would not be needed (although IMHO __mips64 is more descriptive than __arch64__, for which you need to search for which architecture it was defined).

Ahh, right.

Quoted 8 lines

Actually the kernel has this instead:

#if __BITS_PER_LONG == 64

Quoted 1 line

But I'm not sure myself if __arch64__ is defined for mips 64bit.

Neither do I.

uos@uos-PC:~$ echo |gcc -dM -E - | grep -i arch
#define _MIPS_ARCH "mips64r2"
#define _MIPS_ARCH_MIPS64R2 1
uos@uos-PC:~$ echo |gcc -dM -E - | grep -i mips64
#define _MIPS_ISA _MIPS_ISA_MIPS64
#define _MIPS_TUNE "mips64r2"
#define _MIPS_TUNE_MIPS64R2 1
#define _MIPS_ARCH "mips64r2"
#define _MIPS_ARCH_MIPS64R2 1
#define __mips64 1
uos@uos-PC:~$ uname  -m
mips64

The mips architecture gcc has no built-in __arch64__, only __mips64 definitions. Of course, "__BITS_PER_LONG == 64" can also be used, but I think it is better to use __mips64 in the mips architecture.

#6 lore raw

PATCH 1/1 Fix the 64-bit macro definition of mips architecture

Quoted 13 lines · sujiaxun
uos@uos-PC:~$ echo |gcc -dM -E - | grep -i arch
#define _MIPS_ARCH "mips64r2"
#define _MIPS_ARCH_MIPS64R2 1
uos@uos-PC:~$ echo |gcc -dM -E - | grep -i mips64
#define _MIPS_ISA _MIPS_ISA_MIPS64
#define _MIPS_TUNE "mips64r2"
#define _MIPS_TUNE_MIPS64R2 1
#define _MIPS_ARCH "mips64r2"
#define _MIPS_ARCH_MIPS64R2 1
#define __mips64 1
uos@uos-PC:~$ uname  -m
mips64
Quoted 3 lines

The mips architecture gcc has no built-in __arch64__, only __mips64 definitions. Of course, "__BITS_PER_LONG == 64" can also be used, but I think it is better to use __mips64 in the mips architecture.

Hmm, I will rather try to do what the kernel source code does, i.e. use __BITS_PER_LONG here instead.

Signature · 1 line
viresh
author
#7 lore raw

PATCH 1/1 Fix the 64-bit macro definition of mips architecture

Quoted 14 lines · Viresh Kumar
Quoted 13 lines · sujiaxun
uos@uos-PC:~$ echo |gcc -dM -E - | grep -i arch
#define _MIPS_ARCH "mips64r2"
#define _MIPS_ARCH_MIPS64R2 1
uos@uos-PC:~$ echo |gcc -dM -E - | grep -i mips64
#define _MIPS_ISA _MIPS_ISA_MIPS64
#define _MIPS_TUNE "mips64r2"
#define _MIPS_TUNE_MIPS64R2 1
#define _MIPS_ARCH "mips64r2"
#define _MIPS_ARCH_MIPS64R2 1
#define __mips64 1
uos@uos-PC:~$ uname  -m
mips64
Quoted 7 lines
Quoted 3 lines

The mips architecture gcc has no built-in __arch64__, only __mips64 definitions. Of course, "__BITS_PER_LONG == 64" can also be used, but I think it is better to use __mips64 in the mips architecture.

Hmm, I will rather try to do what the kernel source code does, i.e. use __BITS_PER_LONG here instead.

I resubmitted a patch and changed "__arch64__" to "#if __BITS_PER_LONG == 64", the link is:
https://patchwork.ozlabs.org/project/ltp/patch/[email protected]
/

#8 lore raw

PATCH 1/1 Fix the 64-bit macro definition of mips architecture

Quoted 21 lines · sujiaxun
Quoted 18 lines · Viresh Kumar
Quoted 16 lines · sujiaxun
uos@uos-PC:~$ echo |gcc -dM -E - | grep -i arch
#define _MIPS_ARCH "mips64r2"
#define _MIPS_ARCH_MIPS64R2 1
uos@uos-PC:~$ echo |gcc -dM -E - | grep -i mips64
#define _MIPS_ISA _MIPS_ISA_MIPS64
#define _MIPS_TUNE "mips64r2"
#define _MIPS_TUNE_MIPS64R2 1
#define _MIPS_ARCH "mips64r2"
#define _MIPS_ARCH_MIPS64R2 1
#define __mips64 1
uos@uos-PC:~$ uname  -m
mips64

The mips architecture gcc has no built-in __arch64__, only __mips64 definitions. Of course, "__BITS_PER_LONG == 64" can also be used, but I think it is better to use __mips64 in the mips architecture.

Quoted 5 lines
Quoted 3 lines

Hmm, I will rather try to do what the kernel source code does, i.e. use __BITS_PER_LONG here instead.

I resubmitted a patch and changed "__arch64__" to "#if __BITS_PER_LONG ==
64", the link is: https://patchwork.ozlabs.org/project/ltp/patch/[email protected]

You should have cc'd me directly :(

I don't have that patch in my inbox..

Though the patch looks fine.

Signature · 1 line
viresh
author
#9 lore raw

PATCH 1/1 Fix the 64-bit macro definition of mips architecture

? 2021/4/26 ??4:12, Viresh Kumar ??:

Quoted 25 lines · sujiaxun
Quoted 24 lines · Viresh Kumar
Quoted 21 lines · sujiaxun
Quoted 13 lines
uos@uos-PC:~$ echo |gcc -dM -E - | grep -i arch
#define _MIPS_ARCH "mips64r2"
#define _MIPS_ARCH_MIPS64R2 1
uos@uos-PC:~$ echo |gcc -dM -E - | grep -i mips64
#define _MIPS_ISA _MIPS_ISA_MIPS64
#define _MIPS_TUNE "mips64r2"
#define _MIPS_TUNE_MIPS64R2 1
#define _MIPS_ARCH "mips64r2"
#define _MIPS_ARCH_MIPS64R2 1
#define __mips64 1
uos@uos-PC:~$ uname  -m
mips64
Quoted 3 lines

The mips architecture gcc has no built-in __arch64__, only __mips64 definitions. Of course, "__BITS_PER_LONG == 64" can also be used, but I think it is better to use __mips64 in the mips architecture.

Hmm, I will rather try to do what the kernel source code does, i.e. use __BITS_PER_LONG here instead.

Quoted 9 lines
Quoted 2 lines

I resubmitted a patch and changed "__arch64__" to "#if __BITS_PER_LONG ==
64", the link is: https://patchwork.ozlabs.org/project/ltp/patch/[email protected]

You should have cc'd me directly :(

I don't have that patch in my inbox..

Though the patch looks fine.

Sorry, what should I do now?

#10 lore raw

PATCH 1/1 Fix the 64-bit macro definition of mips architecture

Quoted 31 lines · sujiaxun

? 2021/4/26 ??4:12, Viresh Kumar ??:

Quoted 28 lines · sujiaxun
Quoted 26 lines · Viresh Kumar
Quoted 14 lines · sujiaxun
Quoted 13 lines
uos@uos-PC:~$ echo |gcc -dM -E - | grep -i arch
#define _MIPS_ARCH "mips64r2"
#define _MIPS_ARCH_MIPS64R2 1
uos@uos-PC:~$ echo |gcc -dM -E - | grep -i mips64
#define _MIPS_ISA _MIPS_ISA_MIPS64
#define _MIPS_TUNE "mips64r2"
#define _MIPS_TUNE_MIPS64R2 1
#define _MIPS_ARCH "mips64r2"
#define _MIPS_ARCH_MIPS64R2 1
#define __mips64 1
uos@uos-PC:~$ uname  -m
mips64
Quoted 7 lines
Quoted 3 lines

The mips architecture gcc has no built-in __arch64__, only __mips64 definitions. Of course, "__BITS_PER_LONG == 64" can also be used, but I think it is better to use __mips64 in the mips architecture.

Hmm, I will rather try to do what the kernel source code does, i.e. use __BITS_PER_LONG here instead.

I resubmitted a patch and changed "__arch64__" to "#if __BITS_PER_LONG ==
64", the link is: https://patchwork.ozlabs.org/project/ltp/patch/[email protected]

Quoted 7 lines
Quoted 6 lines

You should have cc'd me directly :(

I don't have that patch in my inbox..

Though the patch looks fine.

Sorry, what should I do now?

Just reply to the email (without deleting any stuff), and add me in cc and mention in the top of the email like.

+Viresh.

Signature · 1 line
viresh
#11 lore raw

PATCH 1/1 Fix the 64-bit macro definition of mips architecture

In reply to Viresh Kumar
Quoted 5 lines · sujiaxun
Quoted 4 lines
uos@uos-PC:~$ echo |gcc -dM -E - | grep -i arch
#define _MIPS_ARCH "mips64r2"
#define _MIPS_ARCH_MIPS64R2 1
uos@uos-PC:~$ echo |gcc -dM -E - | grep -i mips64
Quoted 8 lines
Quoted 8 lines

#define _MIPS_ISA _MIPS_ISA_MIPS64
#define _MIPS_TUNE "mips64r2"
#define _MIPS_TUNE_MIPS64R2 1
#define _MIPS_ARCH "mips64r2"
#define _MIPS_ARCH_MIPS64R2 1
#define __mips64 1

uos@uos-PC:~$ uname  -m
mips64

Thanks for verification!

Quoted 6 lines
Quoted 3 lines

The mips architecture gcc has no built-in __arch64__, only __mips64 definitions. Of course, "__BITS_PER_LONG == 64" can also be used, but I think it is better to use __mips64 in the mips architecture.

Hmm, I will rather try to do what the kernel source code does, i.e. use __BITS_PER_LONG here instead.

+1

Kind regards,
Petr