[PATCH] Add SYSCALL_LONG/SYSCALL_ULONG to pass long to syscall [BZ #25810]

H.J. Lu hjl.tools@gmail.com
Sun Apr 12 22:42:34 GMT 2020


On Sun, Apr 12, 2020 at 1:44 PM Florian Weimer <fw@deneb.enyo.de> wrote:
>
> * H. J. Lu:
>
> > nohup: ignoring input and appending output to 'nohup.out'
> > gnu-tools-1:pts/5[130]> m nohup.out
> > In file included from ../sysdeps/x86_64/nptl/tls.h:28,
> >                  from ../include/errno.h:25,
> >                  from ../sysdeps/unix/sysv/linux/fexecve.c:18:
> > ../sysdeps/unix/sysv/linux/fexecve.c: In function ‘fexecve’:
> > ../sysdeps/unix/sysv/linux/x86_64/x32/sysdep.h:56:6: error: cast from pointer to
> >  integer of different size [-Werror=pointer-to-int-cast]
> >    56 |    : (long long int) (X))
> >       |      ^
>
> Please try something like this:
>
> #define ARGIFY(X)                                                       \
>   ({                                                                    \
>     _Pragma ("GCC diagnostic push");                                    \
>     _Pragma ("GCC diagnostic ignored \"-Wpointer-to-int-cast\"");       \
>     (sizeof (X) <= 4 && (__typeof__ (X)) 0 < (__typeof__ (X)) -1)       \
>       ? (long long int) (unsigned long int) (X)                         \
>       : (long int long) (X);                                            \
>     _Pragma ("GCC diagnostic pop");                                     \
>   })
>
> (__builtin_choose_expr does not work because it only suppresses
> errors, not warnings.)
>
> It may not work in some cases because (__typeof__ (X)) 0 is not valid
> if X is an array.

It compiles, but doesn't work.  We need to cast the input of

#define TYPEFY(X, name) __typeof__ ((X) - (X)) name
#define ARGIFY(X) ((__typeof__ ((X) - (X))) (X))

to unsigned long long.

-- 
H.J.


More information about the Libc-alpha mailing list