From: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
To: Christopher Li <sparse@chrisli.org>
Cc: Linux-Sparse <linux-sparse@vger.kernel.org>
Subject: Re: [PATCH 2/2] add support for __int128
Date: Tue, 7 Feb 2017 15:40:30 +0100 [thread overview]
Message-ID: <20170207144027.jkhkaxlphbybcsrn@macbook.local> (raw)
In-Reply-To: <CANeU7QnmjMr30T7SgRMTi9v_+XhKkexhm0=nbHvnyr7q_cbdiQ@mail.gmail.com>
On Tue, Feb 07, 2017 at 11:05:19AM +0800, Christopher Li wrote:
> On Tue, Feb 7, 2017 at 10:49 AM, Luc Van Oostenryck
> <luc.vanoostenryck@gmail.com> wrote:
> >>> @@ -1496,6 +1504,8 @@ static struct token *declaration_specifiers(struct token *token, struct decl_sta
> >>> }
> >>> seen |= s->op->set;
> >>> class += s->op->class;
> >>> + if (s->op->set & Set_Int128)
> >>> + size = 2;
> >>> if (s->op->type & KW_SHORT) {
> >>> size = -1;
> >>> } else if (s->op->type & KW_LONG && size++) {
> >>
> >> This patch is already applied in sparse-next.
> >> But I have a question regarding the "size = 2;" Is the number 2 a magic
> >> number?
> >
> > Not really magic but certainly not obvious:
> > * 'size' acts here as a sort of modifiers for interger
> > * plain integer, 'int' thus, are set to 'size = 0'
> > * then if 'short' is encountered, it's set to 'size = -1'
> > * each 'long' increment size by 1
> > * so int = 0, long = 1, long long = 2 & long long long = 3
> > * here __int128 is in fact 'long long long' so should ends to 3
> > but the code contained a 'size++' which explain the 'size = 2'
> > I had to had to support this type.
> >
> > To be honest I don't like much what is done with this 'size' but
> > it works and I always try to make the smallest change in the
> > pre-existing code.
> >
>
> Adding the sparse mailing list.
>
> Thanks for the explain regarding the size. So the size is actually the
> how many extra int in terms of size.
>
> In that case, maybe we can add define/enum SIZE_128_BIT as 2,
> SIZE_SHORT as -1 etc together with your comment.
I think it would be misleading because:
* here 'size' is not directly related to the size of the integer
(in the sizeof() sense) but is very close to the notion of 'rank'
as used in the C standard
* __int128 is essentially 'long long long int' and as such we should
set SIZE_128_BIT as 3 and not as 2 but here we have to *initialize*
it to the preceding rank, 2, as the next run of the loop will
increment it to the right value, 3.
I tried to do it in a more clear/direct way but as I had then to
duplicate some code I choose to do it with the existing code & logic.
If you wish, I'll look if I can make things a bit clearer or maybe
just adding an appropriate comment.
Luc
prev parent reply other threads:[~2017-02-07 14:40 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-12-09 23:03 [PATCH 0/2] add support for __int128 Luc Van Oostenryck
2016-12-09 23:03 ` [PATCH 1/2] fix missing element in types declaration Luc Van Oostenryck
2016-12-09 23:03 ` [PATCH 2/2] add support for __int128 Luc Van Oostenryck
2017-02-07 2:34 ` Christopher Li
[not found] ` <CAMHZB6Hc9qwOve85K7Ji27eEL-dK90fDGebv_U3MgGmF58WFgQ@mail.gmail.com>
2017-02-07 3:05 ` Christopher Li
2017-02-07 14:40 ` Luc Van Oostenryck [this message]
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=20170207144027.jkhkaxlphbybcsrn@macbook.local \
--to=luc.vanoostenryck@gmail.com \
--cc=linux-sparse@vger.kernel.org \
--cc=sparse@chrisli.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 NNTP newsgroup(s).