public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Florian Weimer <fw@deneb.enyo.de>
To: "H.J. Lu" <hjl.tools@gmail.com>
Cc: "H.J. Lu via Libc-alpha" <libc-alpha@sourceware.org>
Subject: Re: [PATCH] Add SYSCALL_LONG/SYSCALL_ULONG to pass long to syscall [BZ #25810]
Date: Mon, 13 Apr 2020 10:23:44 +0200	[thread overview]
Message-ID: <87eesr4wvj.fsf@mid.deneb.enyo.de> (raw)
In-Reply-To: <CAMe9rOrLq4Rm_aq08yj2cohLafehHvgAxW=hyQEaLWr2SZRADg@mail.gmail.com> (H. J. Lu's message of "Sun, 12 Apr 2020 15:42:34 -0700")

* H. J. Lu:

> 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.

Why does it fail?  Are there any arguments besides pointers which must
not be sign-extended to 64 bits?  According to syscall(2), I don't
think, so I still think we can make this work if we just avoid
sign-extending pointers.

  reply	other threads:[~2020-04-13  8:23 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-10 21:22 H.J. Lu
2020-04-11 10:01 ` Florian Weimer
2020-04-11 13:26   ` H.J. Lu
2020-04-11 14:45     ` Florian Weimer
2020-04-11 15:04       ` H.J. Lu
2020-04-11 15:10         ` Florian Weimer
2020-04-11 15:23           ` H.J. Lu
2020-04-11 15:31             ` Florian Weimer
2020-04-11 20:25               ` H.J. Lu
2020-04-11 20:47                 ` Florian Weimer
2020-04-11 21:58                   ` H.J. Lu
2020-04-12 20:44                     ` Florian Weimer
2020-04-12 22:42                       ` H.J. Lu
2020-04-13  8:23                         ` Florian Weimer [this message]
2020-04-13 11:44                           ` H.J. Lu
2020-04-13 11:54                             ` H.J. Lu
2020-04-13 14:26                               ` H.J. Lu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87eesr4wvj.fsf@mid.deneb.enyo.de \
    --to=fw@deneb.enyo.de \
    --cc=hjl.tools@gmail.com \
    --cc=libc-alpha@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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 read-only IMAP folder(s) and NNTP newsgroup(s).