Patchwork [08/15] nios2: Use Linux kABI for syscall return

login
register
mail settings
Submitter Adhemerval Zanella Netto
Date Feb. 10, 2020, 7:20 p.m.
Message ID <20200210192038.23588-8-adhemerval.zanella@linaro.org>
Download mbox | patch
Permalink /patch/37873/
State New
Headers show

Comments

Adhemerval Zanella Netto - Feb. 10, 2020, 7:20 p.m.
It changes the nios INTERNAL_SYSCALL_RAW macro to return a negative
value instead of 'r2' register value on 'err' macro argument.

The macro INTERNAL_SYSCALL_DECL is no longer required, and the
INTERNAL_SYSCALL_ERROR_P follows the other Linux kABIS.

Checked with a build against nios2-linux-gnu.
---
 sysdeps/unix/sysv/linux/nios2/sysdep.h | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
Florian Weimer - Feb. 11, 2020, 11:20 a.m.
* Adhemerval Zanella:

> +#define INTERNAL_SYSCALL_ERROR_P(val, err) \
> +  ((unsigned long) (val) >= (unsigned long) -4095)

This should use unsigned long int.  Rest looks okay.

Thanks,
Florian
Andreas Schwab - Feb. 11, 2020, 11:50 a.m.
On Feb 10 2020, Adhemerval Zanella wrote:

> diff --git a/sysdeps/unix/sysv/linux/nios2/sysdep.h b/sysdeps/unix/sysv/linux/nios2/sysdep.h
> index b02730bd23..eab888df32 100644
> --- a/sysdeps/unix/sysv/linux/nios2/sysdep.h
> +++ b/sysdeps/unix/sysv/linux/nios2/sysdep.h
> @@ -157,13 +157,14 @@
>       (int) result_var; })
>  
>  #undef INTERNAL_SYSCALL_DECL
> -#define INTERNAL_SYSCALL_DECL(err) unsigned int err __attribute__((unused))
> +#define INTERNAL_SYSCALL_DECL(err) do { } while (0)
>  
>  #undef INTERNAL_SYSCALL_ERROR_P
> -#define INTERNAL_SYSCALL_ERROR_P(val, err) ((void) (val), (unsigned int) (err))
> +#define INTERNAL_SYSCALL_ERROR_P(val, err) \
> +  ((unsigned long) (val) >= (unsigned long) -4095)

Perhaps -4095UL instead?

Andreas.
Adhemerval Zanella Netto - Feb. 11, 2020, 7:09 p.m.
On 11/02/2020 08:20, Florian Weimer wrote:
> * Adhemerval Zanella:
> 
>> +#define INTERNAL_SYSCALL_ERROR_P(val, err) \
>> +  ((unsigned long) (val) >= (unsigned long) -4095)
> 
> This should use unsigned long int.  Rest looks okay.
> 
> Thanks,
> Florian
> 

I didn't bother because this snippet will be removed by the
'linux: Consolidate INLINE_SYSCALL' patch in this set, but you
are correct.

I have changed to:
 
#define INTERNAL_SYSCALL_ERROR_P(val, err) \
  ((unsigned long) (val) > -4096UL)

(which is the one I used on consolidation).

Patch

diff --git a/sysdeps/unix/sysv/linux/nios2/sysdep.h b/sysdeps/unix/sysv/linux/nios2/sysdep.h
index b02730bd23..eab888df32 100644
--- a/sysdeps/unix/sysv/linux/nios2/sysdep.h
+++ b/sysdeps/unix/sysv/linux/nios2/sysdep.h
@@ -157,13 +157,14 @@ 
      (int) result_var; })
 
 #undef INTERNAL_SYSCALL_DECL
-#define INTERNAL_SYSCALL_DECL(err) unsigned int err __attribute__((unused))
+#define INTERNAL_SYSCALL_DECL(err) do { } while (0)
 
 #undef INTERNAL_SYSCALL_ERROR_P
-#define INTERNAL_SYSCALL_ERROR_P(val, err) ((void) (val), (unsigned int) (err))
+#define INTERNAL_SYSCALL_ERROR_P(val, err) \
+  ((unsigned long) (val) >= (unsigned long) -4095)
 
 #undef INTERNAL_SYSCALL_ERRNO
-#define INTERNAL_SYSCALL_ERRNO(val, err)   ((void) (err), val)
+#define INTERNAL_SYSCALL_ERRNO(val, err)     (-(val))
 
 #undef INTERNAL_SYSCALL_RAW
 #define INTERNAL_SYSCALL_RAW(name, err, nr, args...)            \
@@ -180,8 +181,7 @@ 
                      : "+r" (_r2), "=r" (_err)                  \
                      : ASM_ARGS_##nr				\
                      : __SYSCALL_CLOBBERS);                     \
-       _sys_result = _r2;                                       \
-       err = _err;                                              \
+       _sys_result = _err != 0 ? -_r2 : -_r2;                   \
      }                                                          \
      (int) _sys_result; })