Re: Optimize cerror on arm64

2017-03-18 Thread Mark Kettenis
> Date: Sat, 18 Mar 2017 14:58:36 -0700
> From: Philip Guenther 
> 
> > Hmm, the arm version still has the equivalent movn r1.  I'll let
> > guenther@ deal with that.
> 
> Ah, but it's necessary there...for correct error return from lseek(). 
> 64bit archs never need the second return register...and I've already 
> removed it from the equivalent of cerror on all the other 64bit archs.

Right.  Works fine here, so please commit that bit as well then.



Re: Optimize cerror on arm64

2017-03-18 Thread Philip Guenther
On Sat, 18 Mar 2017, Mark Kettenis wrote:
> > Date: Sat, 18 Mar 2017 17:20:21 +0100
> > From: Patrick Wildt 
> > 
> > On Sat, Mar 18, 2017 at 03:47:18PM +0100, Mark Kettenis wrote:
> > > Just like we did on other architectures.
> > > 
> > > ok?
> > 
> > guenther@ had the same diff (but he also removed the movn x1), which
> > looked good to me as well.  Basically still ok patrick@. ;)

iirc you hadn't had a chance to actually run it and I was waiting for 
someone who actually has the hardware to confirm I didn't miss something 
dumb...

So obviously ok guenther@


> Hmm, the arm version still has the equivalent movn r1.  I'll let
> guenther@ deal with that.

Ah, but it's necessary there...for correct error return from lseek(). 
64bit archs never need the second return register...and I've already 
removed it from the equivalent of cerror on all the other 64bit archs.


Philip



Re: Optimize cerror on arm64

2017-03-18 Thread Mark Kettenis
> Date: Sat, 18 Mar 2017 17:20:21 +0100
> From: Patrick Wildt 
> 
> On Sat, Mar 18, 2017 at 03:47:18PM +0100, Mark Kettenis wrote:
> > Just like we did on other architectures.
> > 
> > ok?
> 
> guenther@ had the same diff (but he also removed the movn x1), which
> looked good to me as well.  Basically still ok patrick@. ;)

Hmm, the arm version still has the equivalent movn r1.  I'll let
guenther@ deal with that.

> > Index: lib/libc/arch/aarch64/sys/cerror.S
> > ===
> > RCS file: /cvs/src/lib/libc/arch/aarch64/sys/cerror.S,v
> > retrieving revision 1.2
> > diff -u -p -r1.2 cerror.S
> > --- lib/libc/arch/aarch64/sys/cerror.S  25 Jan 2017 10:43:37 -  
> > 1.2
> > +++ lib/libc/arch/aarch64/sys/cerror.S  18 Mar 2017 14:45:58 -
> > @@ -28,17 +28,13 @@
> >  
> >  #include "SYS.h"
> >  
> > +/* offsetof(struct tib, tib_errno) - offsetof(struct tib, __tib_tcb) */
> > +#define TCB_OFFSET_ERRNO   (-12)
> > +
> >  _ENTRY(CERROR)
> > -   stp x0, x30, [sp,#-16]!
> > -   bl  _C_LABEL(__errno)
> > -   ldp x1, x30, [sp],#16
> > -   str w1, [x0]
> > +   mrs x1, tpidr_el0
> > +   str w0, [x1, #TCB_OFFSET_ERRNO]
> > movnx0, #0
> > movnx1, #0
> > ret
> >  END(CERROR)
> > -
> > -#if !defined(__PIC__)
> > -.Lerrno:
> > -   .word   errno
> > -#endif
> > 
> 



Re: Optimize cerror on arm64

2017-03-18 Thread Patrick Wildt
On Sat, Mar 18, 2017 at 03:47:18PM +0100, Mark Kettenis wrote:
> Just like we did on other architectures.
> 
> ok?

guenther@ had the same diff (but he also removed the movn x1), which
looked good to me as well.  Basically still ok patrick@. ;)

> 
> 
> Index: lib/libc/arch/aarch64/sys/cerror.S
> ===
> RCS file: /cvs/src/lib/libc/arch/aarch64/sys/cerror.S,v
> retrieving revision 1.2
> diff -u -p -r1.2 cerror.S
> --- lib/libc/arch/aarch64/sys/cerror.S25 Jan 2017 10:43:37 -  
> 1.2
> +++ lib/libc/arch/aarch64/sys/cerror.S18 Mar 2017 14:45:58 -
> @@ -28,17 +28,13 @@
>  
>  #include "SYS.h"
>  
> +/* offsetof(struct tib, tib_errno) - offsetof(struct tib, __tib_tcb) */
> +#define TCB_OFFSET_ERRNO (-12)
> +
>  _ENTRY(CERROR)
> - stp x0, x30, [sp,#-16]!
> - bl  _C_LABEL(__errno)
> - ldp x1, x30, [sp],#16
> - str w1, [x0]
> + mrs x1, tpidr_el0
> + str w0, [x1, #TCB_OFFSET_ERRNO]
>   movnx0, #0
>   movnx1, #0
>   ret
>  END(CERROR)
> -
> -#if !defined(__PIC__)
> -.Lerrno:
> - .word   errno
> -#endif
> 



Optimize cerror on arm64

2017-03-18 Thread Mark Kettenis
Just like we did on other architectures.

ok?


Index: lib/libc/arch/aarch64/sys/cerror.S
===
RCS file: /cvs/src/lib/libc/arch/aarch64/sys/cerror.S,v
retrieving revision 1.2
diff -u -p -r1.2 cerror.S
--- lib/libc/arch/aarch64/sys/cerror.S  25 Jan 2017 10:43:37 -  1.2
+++ lib/libc/arch/aarch64/sys/cerror.S  18 Mar 2017 14:45:58 -
@@ -28,17 +28,13 @@
 
 #include "SYS.h"
 
+/* offsetof(struct tib, tib_errno) - offsetof(struct tib, __tib_tcb) */
+#define TCB_OFFSET_ERRNO   (-12)
+
 _ENTRY(CERROR)
-   stp x0, x30, [sp,#-16]!
-   bl  _C_LABEL(__errno)
-   ldp x1, x30, [sp],#16
-   str w1, [x0]
+   mrs x1, tpidr_el0
+   str w0, [x1, #TCB_OFFSET_ERRNO]
movnx0, #0
movnx1, #0
ret
 END(CERROR)
-
-#if !defined(__PIC__)
-.Lerrno:
-   .word   errno
-#endif