All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] sh: fixes for various build warnings
@ 2021-06-02 23:14 Randy Dunlap
  2021-06-02 23:14 ` [PATCH 1/4] sh: convert xchg() to a statement expression Randy Dunlap
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Randy Dunlap @ 2021-06-02 23:14 UTC (permalink / raw)
  To: linux-kernel; +Cc: Randy Dunlap, Yoshinori Sato, Rich Felker, linux-sh

Fix a few build warnings on SUPERH.

Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
Cc: Rich Felker <dalias@libc.org>
Cc: linux-sh@vger.kernel.org

[PATCH 1/3] sh: convert xchg() to a statement expression
[RFC PATCH 2/3] sh: define __BIG_ENDIAN for math-emu
[PATCH 3/3] sh: fix READ/WRITE redefinition warnings

 arch/sh/include/asm/cmpxchg.h |    2 -
 arch/sh/math-emu/math.c       |   44 ++++++++++++++++----------------
 arch/sh/math-emu/sfp-util.h   |    2 -
 3 files changed, 24 insertions(+), 24 deletions(-)

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 1/4] sh: convert xchg() to a statement expression
  2021-06-02 23:14 [PATCH 0/3] sh: fixes for various build warnings Randy Dunlap
@ 2021-06-02 23:14 ` Randy Dunlap
  2021-06-02 23:14 ` [RFC PATCH 3/4] sh: define __BIG_ENDIAN for math-emu Randy Dunlap
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 8+ messages in thread
From: Randy Dunlap @ 2021-06-02 23:14 UTC (permalink / raw)
  To: linux-kernel
  Cc: Randy Dunlap, Yoshinori Sato, Rich Felker, linux-sh, David Howells

Use a GCC statement expression (extension) for xchg(), as is done
in other arches.

Fixes this build warning:

../fs/ocfs2/file.c: In function 'ocfs2_file_write_iter':
../arch/sh/include/asm/cmpxchg.h:49:3: warning: value computed is not used [-Wunused-value]
   49 |  ((__typeof__(*(ptr)))__xchg((ptr),(unsigned long)(x), sizeof(*(ptr))))

Fixes: e839ca528718 ("Disintegrate asm/system.h for SH")
Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
Cc: Rich Felker <dalias@libc.org>
Cc: linux-sh@vger.kernel.org
Cc: David Howells <dhowells@redhat.com>
---
This is similar to a patch from Arnd for m68k:
  https://lore.kernel.org/linux-m68k/20201008123429.1133896-1-arnd@arndb.de/

 arch/sh/include/asm/cmpxchg.h |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- linux-next-20210528.orig/arch/sh/include/asm/cmpxchg.h
+++ linux-next-20210528/arch/sh/include/asm/cmpxchg.h
@@ -46,7 +46,7 @@ extern void __xchg_called_with_bad_point
 })
 
 #define xchg(ptr,x)	\
-	((__typeof__(*(ptr)))__xchg((ptr),(unsigned long)(x), sizeof(*(ptr))))
+	({(__typeof__(*(ptr)))__xchg((ptr),(unsigned long)(x), sizeof(*(ptr)));})
 
 /* This function doesn't exist, so you'll get a linker error
  * if something tries to do an invalid cmpxchg(). */

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [RFC PATCH 3/4] sh: define __BIG_ENDIAN for math-emu
  2021-06-02 23:14 [PATCH 0/3] sh: fixes for various build warnings Randy Dunlap
  2021-06-02 23:14 ` [PATCH 1/4] sh: convert xchg() to a statement expression Randy Dunlap
@ 2021-06-02 23:14 ` Randy Dunlap
  2021-06-03  7:54   ` Geert Uytterhoeven
  2021-06-02 23:14 ` [PATCH 4/4] sh: fix READ/WRITE redefinition warnings Randy Dunlap
  2021-06-03  6:51 ` [PATCH 0/3] sh: fixes for various build warnings John Paul Adrian Glaubitz
  3 siblings, 1 reply; 8+ messages in thread
From: Randy Dunlap @ 2021-06-02 23:14 UTC (permalink / raw)
  To: linux-kernel; +Cc: Randy Dunlap, Yoshinori Sato, Rich Felker, linux-sh

The headers in include/math-emu/ test for __BYTE_ORDER == __BIG_ENDIAN
without checking to see if these macros are defined, so add
a define for __BIG_ENDIAN before pulling in these headers.

This placates these build warnings:

In file included from ../arch/sh/math-emu/math.c:23:
../include/math-emu/single.h:50:21: warning: "__BIG_ENDIAN" is not defined, evaluates to 0 [-Wundef]
   50 | #if __BYTE_ORDER == __BIG_ENDIAN
In file included from ../arch/sh/math-emu/math.c:24:
../include/math-emu/double.h:59:21: warning: "__BIG_ENDIAN" is not defined, evaluates to 0 [-Wundef]
   59 | #if __BYTE_ORDER == __BIG_ENDIAN

Fixes: 4b565680d163 ("sh: math-emu support")
Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
Cc: Rich Felker <dalias@libc.org>
Cc: linux-sh@vger.kernel.org
---
 arch/sh/math-emu/sfp-util.h |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- linux-next-20210528.orig/arch/sh/math-emu/sfp-util.h
+++ linux-next-20210528/arch/sh/math-emu/sfp-util.h
@@ -70,4 +70,4 @@
 
 #define __BYTE_ORDER __LITTLE_ENDIAN
 
-
+#define __BIG_ENDIAN 0

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 4/4] sh: fix READ/WRITE redefinition warnings
  2021-06-02 23:14 [PATCH 0/3] sh: fixes for various build warnings Randy Dunlap
  2021-06-02 23:14 ` [PATCH 1/4] sh: convert xchg() to a statement expression Randy Dunlap
  2021-06-02 23:14 ` [RFC PATCH 3/4] sh: define __BIG_ENDIAN for math-emu Randy Dunlap
@ 2021-06-02 23:14 ` Randy Dunlap
  2021-06-03  6:51 ` [PATCH 0/3] sh: fixes for various build warnings John Paul Adrian Glaubitz
  3 siblings, 0 replies; 8+ messages in thread
From: Randy Dunlap @ 2021-06-02 23:14 UTC (permalink / raw)
  To: linux-kernel
  Cc: Randy Dunlap, Yoshinori Sato, Rich Felker, linux-sh, Takashi YOSHII

kernel.h defines READ and WRITE, so rename the SH math-emu macros
to MREAD and MWRITE.

Fixes these warnings:

../arch/sh/math-emu/math.c:54: warning: "WRITE" redefined
   54 | #define WRITE(d,a) ({if(put_user(d, (typeof (d) __user *)a)) return -EFAULT;})
In file included from ../arch/sh/math-emu/math.c:10:
../include/linux/kernel.h:37: note: this is the location of the previous definition
   37 | #define WRITE   1
../arch/sh/math-emu/math.c:55: warning: "READ" redefined
   55 | #define READ(d,a) ({if(get_user(d, (typeof (d) __user *)a)) return -EFAULT;})
In file included from ../arch/sh/math-emu/math.c:10:
../include/linux/kernel.h:36: note: this is the location of the previous definition
   36 | #define READ   0

Fixes: 4b565680d163 ("sh: math-emu support")
Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
Cc: Rich Felker <dalias@libc.org>
Cc: linux-sh@vger.kernel.org
Cc: Takashi YOSHII <takasi-y@ops.dti.ne.jp>
---
 arch/sh/math-emu/math.c |   44 +++++++++++++++++++-------------------
 1 file changed, 22 insertions(+), 22 deletions(-)

--- linux-next-20210528.orig/arch/sh/math-emu/math.c
+++ linux-next-20210528/arch/sh/math-emu/math.c
@@ -51,8 +51,8 @@
 #define Rn	(regs->regs[n])
 #define Rm	(regs->regs[m])
 
-#define WRITE(d,a)	({if(put_user(d, (typeof (d) __user *)a)) return -EFAULT;})
-#define READ(d,a)	({if(get_user(d, (typeof (d) __user *)a)) return -EFAULT;})
+#define MWRITE(d,a)	({if(put_user(d, (typeof (d) __user *)a)) return -EFAULT;})
+#define MREAD(d,a)	({if(get_user(d, (typeof (d) __user *)a)) return -EFAULT;})
 
 #define PACK_S(r,f)	FP_PACK_SP(&r,f)
 #define UNPACK_S(f,r)	FP_UNPACK_SP(f,&r)
@@ -157,11 +157,11 @@ fmov_idx_reg(struct sh_fpu_soft_struct *
 {
 	if (FPSCR_SZ) {
 		FMOV_EXT(n);
-		READ(FRn, Rm + R0 + 4);
+		MREAD(FRn, Rm + R0 + 4);
 		n++;
-		READ(FRn, Rm + R0);
+		MREAD(FRn, Rm + R0);
 	} else {
-		READ(FRn, Rm + R0);
+		MREAD(FRn, Rm + R0);
 	}
 
 	return 0;
@@ -173,11 +173,11 @@ fmov_mem_reg(struct sh_fpu_soft_struct *
 {
 	if (FPSCR_SZ) {
 		FMOV_EXT(n);
-		READ(FRn, Rm + 4);
+		MREAD(FRn, Rm + 4);
 		n++;
-		READ(FRn, Rm);
+		MREAD(FRn, Rm);
 	} else {
-		READ(FRn, Rm);
+		MREAD(FRn, Rm);
 	}
 
 	return 0;
@@ -189,12 +189,12 @@ fmov_inc_reg(struct sh_fpu_soft_struct *
 {
 	if (FPSCR_SZ) {
 		FMOV_EXT(n);
-		READ(FRn, Rm + 4);
+		MREAD(FRn, Rm + 4);
 		n++;
-		READ(FRn, Rm);
+		MREAD(FRn, Rm);
 		Rm += 8;
 	} else {
-		READ(FRn, Rm);
+		MREAD(FRn, Rm);
 		Rm += 4;
 	}
 
@@ -207,11 +207,11 @@ fmov_reg_idx(struct sh_fpu_soft_struct *
 {
 	if (FPSCR_SZ) {
 		FMOV_EXT(m);
-		WRITE(FRm, Rn + R0 + 4);
+		MWRITE(FRm, Rn + R0 + 4);
 		m++;
-		WRITE(FRm, Rn + R0);
+		MWRITE(FRm, Rn + R0);
 	} else {
-		WRITE(FRm, Rn + R0);
+		MWRITE(FRm, Rn + R0);
 	}
 
 	return 0;
@@ -223,11 +223,11 @@ fmov_reg_mem(struct sh_fpu_soft_struct *
 {
 	if (FPSCR_SZ) {
 		FMOV_EXT(m);
-		WRITE(FRm, Rn + 4);
+		MWRITE(FRm, Rn + 4);
 		m++;
-		WRITE(FRm, Rn);
+		MWRITE(FRm, Rn);
 	} else {
-		WRITE(FRm, Rn);
+		MWRITE(FRm, Rn);
 	}
 
 	return 0;
@@ -240,12 +240,12 @@ fmov_reg_dec(struct sh_fpu_soft_struct *
 	if (FPSCR_SZ) {
 		FMOV_EXT(m);
 		Rn -= 8;
-		WRITE(FRm, Rn + 4);
+		MWRITE(FRm, Rn + 4);
 		m++;
-		WRITE(FRm, Rn);
+		MWRITE(FRm, Rn);
 	} else {
 		Rn -= 4;
-		WRITE(FRm, Rn);
+		MWRITE(FRm, Rn);
 	}
 
 	return 0;
@@ -445,11 +445,11 @@ id_sys(struct sh_fpu_soft_struct *fregs,
 	case 0x4052:
 	case 0x4062:
 		Rn -= 4;
-		WRITE(*reg, Rn);
+		MWRITE(*reg, Rn);
 		break;
 	case 0x4056:
 	case 0x4066:
-		READ(*reg, Rn);
+		MREAD(*reg, Rn);
 		Rn += 4;
 		break;
 	default:

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 0/3] sh: fixes for various build warnings
  2021-06-02 23:14 [PATCH 0/3] sh: fixes for various build warnings Randy Dunlap
                   ` (2 preceding siblings ...)
  2021-06-02 23:14 ` [PATCH 4/4] sh: fix READ/WRITE redefinition warnings Randy Dunlap
@ 2021-06-03  6:51 ` John Paul Adrian Glaubitz
  3 siblings, 0 replies; 8+ messages in thread
From: John Paul Adrian Glaubitz @ 2021-06-03  6:51 UTC (permalink / raw)
  To: Randy Dunlap, linux-kernel; +Cc: Yoshinori Sato, Rich Felker, linux-sh

Hi Randy!

On 6/3/21 1:14 AM, Randy Dunlap wrote:
> Fix a few build warnings on SUPERH.
> 
> Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
> Cc: Rich Felker <dalias@libc.org>
> Cc: linux-sh@vger.kernel.org
> 
> [PATCH 1/3] sh: convert xchg() to a statement expression
> [RFC PATCH 2/3] sh: define __BIG_ENDIAN for math-emu
> [PATCH 3/3] sh: fix READ/WRITE redefinition warnings
> 
>  arch/sh/include/asm/cmpxchg.h |    2 -
>  arch/sh/math-emu/math.c       |   44 ++++++++++++++++----------------
>  arch/sh/math-emu/sfp-util.h   |    2 -
>  3 files changed, 24 insertions(+), 24 deletions(-)

Thanks for your patches. I have been pondering to fix these warnings for a while
now glad someone else was quicker than me :-).

I will test your patches later today and see if there are any regressions.

Adrian

-- 
 .''`.  John Paul Adrian Glaubitz
: :' :  Debian Developer - glaubitz@debian.org
`. `'   Freie Universitaet Berlin - glaubitz@physik.fu-berlin.de
  `-    GPG: 62FF 8A75 84E0 2956 9546  0006 7426 3B37 F5B5 F913

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [RFC PATCH 3/4] sh: define __BIG_ENDIAN for math-emu
  2021-06-02 23:14 ` [RFC PATCH 3/4] sh: define __BIG_ENDIAN for math-emu Randy Dunlap
@ 2021-06-03  7:54   ` Geert Uytterhoeven
  2021-06-03 23:19     ` Randy Dunlap
  0 siblings, 1 reply; 8+ messages in thread
From: Geert Uytterhoeven @ 2021-06-03  7:54 UTC (permalink / raw)
  To: Randy Dunlap
  Cc: Linux Kernel Mailing List, Yoshinori Sato, Rich Felker, Linux-sh list

Hi Randy,

On Thu, Jun 3, 2021 at 1:17 AM Randy Dunlap <rdunlap@infradead.org> wrote:
> The headers in include/math-emu/ test for __BYTE_ORDER == __BIG_ENDIAN
> without checking to see if these macros are defined, so add
> a define for __BIG_ENDIAN before pulling in these headers.
>
> This placates these build warnings:
>
> In file included from ../arch/sh/math-emu/math.c:23:
> ../include/math-emu/single.h:50:21: warning: "__BIG_ENDIAN" is not defined, evaluates to 0 [-Wundef]
>    50 | #if __BYTE_ORDER == __BIG_ENDIAN
> In file included from ../arch/sh/math-emu/math.c:24:
> ../include/math-emu/double.h:59:21: warning: "__BIG_ENDIAN" is not defined, evaluates to 0 [-Wundef]
>    59 | #if __BYTE_ORDER == __BIG_ENDIAN
>
> Fixes: 4b565680d163 ("sh: math-emu support")
> Signed-off-by: Randy Dunlap <rdunlap@infradead.org>

Thanks for your patch!

> --- linux-next-20210528.orig/arch/sh/math-emu/sfp-util.h
> +++ linux-next-20210528/arch/sh/math-emu/sfp-util.h
> @@ -70,4 +70,4 @@
>
>  #define __BYTE_ORDER __LITTLE_ENDIAN
>
> -
> +#define __BIG_ENDIAN 0

I don't think this is the right fix.

I think the right values should be picked up from:

    include/uapi/linux/byteorder/big_endian.h:#define __BIG_ENDIAN 4321
    include/uapi/linux/byteorder/little_endian.h:#define __LITTLE_ENDIAN 1234

How is this picked up on other architectures using <math-emu/single.h>?

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [RFC PATCH 3/4] sh: define __BIG_ENDIAN for math-emu
  2021-06-03  7:54   ` Geert Uytterhoeven
@ 2021-06-03 23:19     ` Randy Dunlap
  2021-06-04  7:24       ` Geert Uytterhoeven
  0 siblings, 1 reply; 8+ messages in thread
From: Randy Dunlap @ 2021-06-03 23:19 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Linux Kernel Mailing List, Yoshinori Sato, Rich Felker, Linux-sh list

On 6/3/21 12:54 AM, Geert Uytterhoeven wrote:
> Hi Randy,
> 
> On Thu, Jun 3, 2021 at 1:17 AM Randy Dunlap <rdunlap@infradead.org> wrote:
>> The headers in include/math-emu/ test for __BYTE_ORDER == __BIG_ENDIAN
>> without checking to see if these macros are defined, so add
>> a define for __BIG_ENDIAN before pulling in these headers.
>>
>> This placates these build warnings:
>>
>> In file included from ../arch/sh/math-emu/math.c:23:
>> ../include/math-emu/single.h:50:21: warning: "__BIG_ENDIAN" is not defined, evaluates to 0 [-Wundef]
>>    50 | #if __BYTE_ORDER == __BIG_ENDIAN
>> In file included from ../arch/sh/math-emu/math.c:24:
>> ../include/math-emu/double.h:59:21: warning: "__BIG_ENDIAN" is not defined, evaluates to 0 [-Wundef]
>>    59 | #if __BYTE_ORDER == __BIG_ENDIAN
>>
>> Fixes: 4b565680d163 ("sh: math-emu support")
>> Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
> 
> Thanks for your patch!
> 
>> --- linux-next-20210528.orig/arch/sh/math-emu/sfp-util.h
>> +++ linux-next-20210528/arch/sh/math-emu/sfp-util.h
>> @@ -70,4 +70,4 @@
>>
>>  #define __BYTE_ORDER __LITTLE_ENDIAN
>>
>> -
>> +#define __BIG_ENDIAN 0
> 
> I don't think this is the right fix.
> 
> I think the right values should be picked up from:
> 
>     include/uapi/linux/byteorder/big_endian.h:#define __BIG_ENDIAN 4321
>     include/uapi/linux/byteorder/little_endian.h:#define __LITTLE_ENDIAN 1234
> 
> How is this picked up on other architectures using <math-emu/single.h>?

Hi Geert,

There isn't very much to compare to in other arch/.
I've made a v2 patch that is done like arch/nds32/ does.
What do you think about this one?

thanks.
---
From: Randy Dunlap <rdunlap@infradead.org>
Subject: [RFC PATCH 2/3 v2] sh: define __BIG_ENDIAN for math-emu

Fix this by defining both ENDIAN macros in
<asm/sfp-machine.h> so that they can be utilized in
<math-emu/soft-fp.h> according to the latter's comment:
/* Allow sfp-machine to have its own byte order definitions. */

(This is what is done in arch/nds32/include/asm/sfp-machine.h.)

This placates these build warnings:

In file included from ../arch/sh/math-emu/math.c:23:
../include/math-emu/single.h:50:21: warning: "__BIG_ENDIAN" is not defined, evaluates to 0 [-Wundef]
   50 | #if __BYTE_ORDER == __BIG_ENDIAN
In file included from ../arch/sh/math-emu/math.c:24:
../include/math-emu/double.h:59:21: warning: "__BIG_ENDIAN" is not defined, evaluates to 0 [-Wundef]
   59 | #if __BYTE_ORDER == __BIG_ENDIAN

Fixes: 4b565680d163 ("sh: math-emu support")
Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
Cc: Rich Felker <dalias@libc.org>
Cc: linux-sh@vger.kernel.org
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
---
 arch/sh/include/asm/sfp-machine.h |    8 ++++++++
 1 file changed, 8 insertions(+)

--- linux-next-20210528.orig/arch/sh/include/asm/sfp-machine.h
+++ linux-next-20210528/arch/sh/include/asm/sfp-machine.h
@@ -13,6 +13,14 @@
 #ifndef _SFP_MACHINE_H
 #define _SFP_MACHINE_H
 
+#ifdef __BIG_ENDIAN__
+#define __BYTE_ORDER __BIG_ENDIAN
+#define __LITTLE_ENDIAN 0
+#else
+#define __BYTE_ORDER __LITTLE_ENDIAN
+#define __BIG_ENDIAN 0
+#endif
+
 #define _FP_W_TYPE_SIZE		32
 #define _FP_W_TYPE		unsigned long
 #define _FP_WS_TYPE		signed long



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [RFC PATCH 3/4] sh: define __BIG_ENDIAN for math-emu
  2021-06-03 23:19     ` Randy Dunlap
@ 2021-06-04  7:24       ` Geert Uytterhoeven
  0 siblings, 0 replies; 8+ messages in thread
From: Geert Uytterhoeven @ 2021-06-04  7:24 UTC (permalink / raw)
  To: Randy Dunlap
  Cc: Linux Kernel Mailing List, Yoshinori Sato, Rich Felker, Linux-sh list

Hi Randy,

On Fri, Jun 4, 2021 at 1:19 AM Randy Dunlap <rdunlap@infradead.org> wrote:
> On 6/3/21 12:54 AM, Geert Uytterhoeven wrote:
> > On Thu, Jun 3, 2021 at 1:17 AM Randy Dunlap <rdunlap@infradead.org> wrote:
> >> The headers in include/math-emu/ test for __BYTE_ORDER == __BIG_ENDIAN
> >> without checking to see if these macros are defined, so add
> >> a define for __BIG_ENDIAN before pulling in these headers.
> >>
> >> This placates these build warnings:
> >>
> >> In file included from ../arch/sh/math-emu/math.c:23:
> >> ../include/math-emu/single.h:50:21: warning: "__BIG_ENDIAN" is not defined, evaluates to 0 [-Wundef]
> >>    50 | #if __BYTE_ORDER == __BIG_ENDIAN
> >> In file included from ../arch/sh/math-emu/math.c:24:
> >> ../include/math-emu/double.h:59:21: warning: "__BIG_ENDIAN" is not defined, evaluates to 0 [-Wundef]
> >>    59 | #if __BYTE_ORDER == __BIG_ENDIAN
> >>
> >> Fixes: 4b565680d163 ("sh: math-emu support")
> >> Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
> >
> > Thanks for your patch!
> >
> >> --- linux-next-20210528.orig/arch/sh/math-emu/sfp-util.h
> >> +++ linux-next-20210528/arch/sh/math-emu/sfp-util.h
> >> @@ -70,4 +70,4 @@
> >>
> >>  #define __BYTE_ORDER __LITTLE_ENDIAN
> >>
> >> -
> >> +#define __BIG_ENDIAN 0
> >
> > I don't think this is the right fix.
> >
> > I think the right values should be picked up from:
> >
> >     include/uapi/linux/byteorder/big_endian.h:#define __BIG_ENDIAN 4321
> >     include/uapi/linux/byteorder/little_endian.h:#define __LITTLE_ENDIAN 1234
> >
> > How is this picked up on other architectures using <math-emu/single.h>?
>
> There isn't very much to compare to in other arch/.
> I've made a v2 patch that is done like arch/nds32/ does.
> What do you think about this one?
>
> thanks.
> ---
> From: Randy Dunlap <rdunlap@infradead.org>
> Subject: [RFC PATCH 2/3 v2] sh: define __BIG_ENDIAN for math-emu
>
> Fix this by defining both ENDIAN macros in
> <asm/sfp-machine.h> so that they can be utilized in
> <math-emu/soft-fp.h> according to the latter's comment:
> /* Allow sfp-machine to have its own byte order definitions. */
>
> (This is what is done in arch/nds32/include/asm/sfp-machine.h.)
>
> This placates these build warnings:
>
> In file included from ../arch/sh/math-emu/math.c:23:
> ../include/math-emu/single.h:50:21: warning: "__BIG_ENDIAN" is not defined, evaluates to 0 [-Wundef]
>    50 | #if __BYTE_ORDER == __BIG_ENDIAN
> In file included from ../arch/sh/math-emu/math.c:24:
> ../include/math-emu/double.h:59:21: warning: "__BIG_ENDIAN" is not defined, evaluates to 0 [-Wundef]
>    59 | #if __BYTE_ORDER == __BIG_ENDIAN
>
> Fixes: 4b565680d163 ("sh: math-emu support")
> Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
> Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
> Cc: Rich Felker <dalias@libc.org>
> Cc: linux-sh@vger.kernel.org
> Cc: Geert Uytterhoeven <geert@linux-m68k.org>
> Cc: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
> ---
>  arch/sh/include/asm/sfp-machine.h |    8 ++++++++
>  1 file changed, 8 insertions(+)
>
> --- linux-next-20210528.orig/arch/sh/include/asm/sfp-machine.h
> +++ linux-next-20210528/arch/sh/include/asm/sfp-machine.h
> @@ -13,6 +13,14 @@
>  #ifndef _SFP_MACHINE_H
>  #define _SFP_MACHINE_H
>
> +#ifdef __BIG_ENDIAN__
> +#define __BYTE_ORDER __BIG_ENDIAN
> +#define __LITTLE_ENDIAN 0
> +#else
> +#define __BYTE_ORDER __LITTLE_ENDIAN
> +#define __BIG_ENDIAN 0
> +#endif
> +
>  #define _FP_W_TYPE_SIZE                32
>  #define _FP_W_TYPE             unsigned long
>  #define _FP_WS_TYPE            signed long

These checks match with what is set by my sh cross-compiler (gcc
8.1.0):

diff <(sh4-linux-gcc-8.1.0 -ml -dM -E - < /dev/null | grep -E
"(BYTE_ORDER|ENDIAN)") <(sh4-linux-gcc-8.1.0 -mb -dM -E - < /dev/null
| grep -E "(BYTE_ORDER|ENDIAN)")
--- /dev/fd/63 2021-06-04 09:15:50.689928352 +0200
+++ /dev/fd/62 2021-06-04 09:15:50.689928352 +0200
@@ -1,6 +1,6 @@
 #define __ORDER_LITTLE_ENDIAN__ 1234
-#define __FLOAT_WORD_ORDER__ __ORDER_LITTLE_ENDIAN__
+#define __BIG_ENDIAN__ 1
+#define __FLOAT_WORD_ORDER__ __ORDER_BIG_ENDIAN__
 #define __ORDER_PDP_ENDIAN__ 3412
-#define __LITTLE_ENDIAN__ 1
 #define __ORDER_BIG_ENDIAN__ 4321
-#define __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__
+#define __BYTE_ORDER__ __ORDER_BIG_ENDIAN__

So
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>

Note that powerpc checks on _BIG_ENDIAN, which works as my powerpc
cross-compiler (gcc 9.3.0) defines both _BIG_ENDIAN and _BIG_ENDIAN__.

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2021-06-04  7:24 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-02 23:14 [PATCH 0/3] sh: fixes for various build warnings Randy Dunlap
2021-06-02 23:14 ` [PATCH 1/4] sh: convert xchg() to a statement expression Randy Dunlap
2021-06-02 23:14 ` [RFC PATCH 3/4] sh: define __BIG_ENDIAN for math-emu Randy Dunlap
2021-06-03  7:54   ` Geert Uytterhoeven
2021-06-03 23:19     ` Randy Dunlap
2021-06-04  7:24       ` Geert Uytterhoeven
2021-06-02 23:14 ` [PATCH 4/4] sh: fix READ/WRITE redefinition warnings Randy Dunlap
2021-06-03  6:51 ` [PATCH 0/3] sh: fixes for various build warnings John Paul Adrian Glaubitz

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.