* RE: [PATCH] MIPS64 atomic_arch.h Clang complains about input type
@ 2016-03-08 10:09 Jaydeep Patil
2016-03-08 11:26 ` Szabolcs Nagy
0 siblings, 1 reply; 5+ messages in thread
From: Jaydeep Patil @ 2016-03-08 10:09 UTC (permalink / raw)
To: Rich Felker (dalias@libc.org); +Cc: musl
[-- Attachment #1: Type: text/plain, Size: 1361 bytes --]
Added musl@lists.openwall.com<mailto:musl@lists.openwall.com> in Cc
From: Jaydeep Patil
Sent: 08 March 2016 PM 03:38
To: Rich Felker (dalias@libc.org)
Subject: [PATCH] MIPS64 atomic_arch.h Clang complains about input type
Hi Rich,
Clang (3.9.0) generates following error for a_sc_p function in atomic_arch.h:
./arch/mips64/atomic_arch.h:37:29: error: unsupported inline asm: input with type 'long *' matching output with type 'int'
Could you please consider this patch to fix it?
-----
From 3e64da8f5db923a919cd5600e8031c158a0368a2 Mon Sep 17 00:00:00 2001
From: Jaydeep Patil <jaydeep.patil@imgtec.com>
Date: Tue, 8 Mar 2016 10:06:38 +0000
Subject: [PATCH] [MIPS64] Fix Clang error
---
arch/mips64/atomic_arch.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/mips64/atomic_arch.h b/arch/mips64/atomic_arch.h
index 49d9884..8af6500 100644
--- a/arch/mips64/atomic_arch.h
+++ b/arch/mips64/atomic_arch.h
@@ -29,9 +29,9 @@ static inline void *a_ll_p(volatile long *p)
}
#define a_sc_p a_sc_p
-static inline int a_sc_p(volatile long *p, void *v)
+static inline void *a_sc_p(volatile long *p, void *v)
{
- int r;
+ void *r;
__asm__ __volatile__ (
"scd %0, %1"
: "=r"(r), "=m"(*p) : "0"(v) : "memory");
--
2.1.4
Thanks,
Jaydeep
[-- Attachment #2: Type: text/html, Size: 6088 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: RE: [PATCH] MIPS64 atomic_arch.h Clang complains about input type
2016-03-08 10:09 [PATCH] MIPS64 atomic_arch.h Clang complains about input type Jaydeep Patil
@ 2016-03-08 11:26 ` Szabolcs Nagy
2016-03-08 17:26 ` Rich Felker (dalias@libc.org)
0 siblings, 1 reply; 5+ messages in thread
From: Szabolcs Nagy @ 2016-03-08 11:26 UTC (permalink / raw)
To: musl; +Cc: Rich Felker (dalias@libc.org)
* Jaydeep Patil <Jaydeep.Patil@imgtec.com> [2016-03-08 10:09:43 +0000]:
>
> ./arch/mips64/atomic_arch.h:37:29: error: unsupported inline asm: input with type 'long *' matching output with type 'int'
>
clang probably should not complain about this
(it's possible to have the output in the low 32bit of a 64bit input reg
and then you do want mismatching input/output types for the same reg)
> #define a_sc_p a_sc_p
> -static inline int a_sc_p(volatile long *p, void *v)
> +static inline void *a_sc_p(volatile long *p, void *v)
> {
> - int r;
> + void *r;
> __asm__ __volatile__ (
> "scd %0, %1"
> : "=r"(r), "=m"(*p) : "0"(v) : "memory");
the return type should be int (1 on success, 0 on failure)
e.g. you can use 'long r' instead of 'int r'
if clang still complains then maybe
union {void *v; long r;} u = {v};
__asm__ __volatile__ (
"scd %0, %1" : "+r"(u.v), "=m"(*p) :: "memory");
return u.r;
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: RE: [PATCH] MIPS64 atomic_arch.h Clang complains about input type
2016-03-08 11:26 ` Szabolcs Nagy
@ 2016-03-08 17:26 ` Rich Felker (dalias@libc.org)
2016-03-08 18:11 ` Szabolcs Nagy
0 siblings, 1 reply; 5+ messages in thread
From: Rich Felker (dalias@libc.org) @ 2016-03-08 17:26 UTC (permalink / raw)
To: musl
On Tue, Mar 08, 2016 at 12:26:13PM +0100, Szabolcs Nagy wrote:
> * Jaydeep Patil <Jaydeep.Patil@imgtec.com> [2016-03-08 10:09:43 +0000]:
> >
> > ./arch/mips64/atomic_arch.h:37:29: error: unsupported inline asm: input with type 'long *' matching output with type 'int'
> >
>
> clang probably should not complain about this
>
> (it's possible to have the output in the low 32bit of a 64bit input reg
> and then you do want mismatching input/output types for the same reg)
I can imagine it being problematic on other archs where the register
names are different for 32-bit and 64-bit versions -- %0 couldn't
expand to both. Isn't there a similar ugly issue on aarch64's
atomic_arch.h?
> > #define a_sc_p a_sc_p
> > -static inline int a_sc_p(volatile long *p, void *v)
> > +static inline void *a_sc_p(volatile long *p, void *v)
> > {
> > - int r;
> > + void *r;
> > __asm__ __volatile__ (
> > "scd %0, %1"
> > : "=r"(r), "=m"(*p) : "0"(v) : "memory");
>
> the return type should be int (1 on success, 0 on failure)
>
> e.g. you can use 'long r' instead of 'int r'
>
> if clang still complains then maybe
>
> union {void *v; long r;} u = {v};
> __asm__ __volatile__ (
> "scd %0, %1" : "+r"(u.v), "=m"(*p) :: "memory");
> return u.r;
If simply using 'long' works, I think that's the cleanest/simplest
solution. The union is uglier and less obvious what it's doing so I'd
rather avoid it if we can.
Rich
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: RE: [PATCH] MIPS64 atomic_arch.h Clang complains about input type
2016-03-08 17:26 ` Rich Felker (dalias@libc.org)
@ 2016-03-08 18:11 ` Szabolcs Nagy
0 siblings, 0 replies; 5+ messages in thread
From: Szabolcs Nagy @ 2016-03-08 18:11 UTC (permalink / raw)
To: musl
* Rich Felker (dalias@libc.org) <dalias@libc.org> [2016-03-08 12:26:50 -0500]:
> On Tue, Mar 08, 2016 at 12:26:13PM +0100, Szabolcs Nagy wrote:
> > * Jaydeep Patil <Jaydeep.Patil@imgtec.com> [2016-03-08 10:09:43 +0000]:
> > >
> > > ./arch/mips64/atomic_arch.h:37:29: error: unsupported inline asm: input with type 'long *' matching output with type 'int'
> > >
> >
> > clang probably should not complain about this
> >
> > (it's possible to have the output in the low 32bit of a 64bit input reg
> > and then you do want mismatching input/output types for the same reg)
>
> I can imagine it being problematic on other archs where the register
> names are different for 32-bit and 64-bit versions -- %0 couldn't
> expand to both. Isn't there a similar ugly issue on aarch64's
> atomic_arch.h?
>
in aarch64 asm wN is the 32bit part of gpr N and xN is the whole 64bit.
(width is not part of the mnemonics, but the operands in most cases).
in gcc inline asm %w0 prints wN and %x0 prints xN for gpr operands,
plain %0 is the same as %x0 for gprs but works for other operands too.
aarch64 gcc does not complain if you pass int for a 64bit operand or long
for 32bit one (that's why we had a bug in atomic_arch.h, i forgot the 'w'),
but this sdc input-output operand would work.
> > > #define a_sc_p a_sc_p
> > > -static inline int a_sc_p(volatile long *p, void *v)
> > > +static inline void *a_sc_p(volatile long *p, void *v)
> > > {
> > > - int r;
> > > + void *r;
> > > __asm__ __volatile__ (
> > > "scd %0, %1"
> > > : "=r"(r), "=m"(*p) : "0"(v) : "memory");
> >
> > the return type should be int (1 on success, 0 on failure)
> >
> > e.g. you can use 'long r' instead of 'int r'
> >
> > if clang still complains then maybe
> >
> > union {void *v; long r;} u = {v};
> > __asm__ __volatile__ (
> > "scd %0, %1" : "+r"(u.v), "=m"(*p) :: "memory");
> > return u.r;
>
> If simply using 'long' works, I think that's the cleanest/simplest
> solution. The union is uglier and less obvious what it's doing so I'd
> rather avoid it if we can.
>
> Rich
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: RE: [PATCH] MIPS64 atomic_arch.h Clang complains about input type
2016-03-09 5:00 Jaydeep Patil
@ 2016-03-11 5:19 ` Rich Felker (dalias@libc.org)
0 siblings, 0 replies; 5+ messages in thread
From: Rich Felker (dalias@libc.org) @ 2016-03-11 5:19 UTC (permalink / raw)
To: musl
On Wed, Mar 09, 2016 at 05:00:42AM +0000, Jaydeep Patil wrote:
> Hi Rich,
>
> > If simply using 'long' works, I think that's the cleanest/simplest
> > solution. The union is uglier and less obvious what it's doing so I'd
> > rather avoid it if we can.
>
> >From e91d41f84822377ef14c675094ad904d89dbd927 Mon Sep 17 00:00:00 2001
> From: Jaydeep Patil <jaydeep.patil@imgtec.com>
> Date: Wed, 9 Mar 2016 04:56:50 +0000
> Subject: [PATCH 2/2] [MIPS64] Change a_sc_p for clang
>
> ---
> arch/mips64/atomic_arch.h | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/arch/mips64/atomic_arch.h b/arch/mips64/atomic_arch.h
> index 8af6500..df35cf6 100644
> --- a/arch/mips64/atomic_arch.h
> +++ b/arch/mips64/atomic_arch.h
> @@ -29,9 +29,9 @@ static inline void *a_ll_p(volatile long *p)
> }
>
> #define a_sc_p a_sc_p
> -static inline void *a_sc_p(volatile long *p, void *v)
> +static inline long a_sc_p(volatile long *p, void *v)
> {
> - void *r;
> + long r;
> __asm__ __volatile__ (
> "scd %0, %1"
> : "=r"(r), "=m"(*p) : "0"(v) : "memory");
I've committed this fix and also fixed the pointer types to match the
actual types they operate on.
Rich
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2016-03-11 5:19 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-03-08 10:09 [PATCH] MIPS64 atomic_arch.h Clang complains about input type Jaydeep Patil
2016-03-08 11:26 ` Szabolcs Nagy
2016-03-08 17:26 ` Rich Felker (dalias@libc.org)
2016-03-08 18:11 ` Szabolcs Nagy
2016-03-09 5:00 Jaydeep Patil
2016-03-11 5:19 ` Rich Felker (dalias@libc.org)
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/musl/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).