From: bjorn@mork.no (Bjørn Mork)
To: kernelnewbies@lists.kernelnewbies.org
Subject: confusing code....whats the point of this construct ?
Date: Wed, 11 Mar 2015 20:41:55 +0100 [thread overview]
Message-ID: <87a8zj48zg.fsf@nemi.mork.no> (raw)
In-Reply-To: <10256.1426100251@turing-police.cc.vt.edu> (Valdis Kletnieks's message of "Wed, 11 Mar 2015 14:57:31 -0400")
Valdis.Kletnieks at vt.edu writes:
> On Wed, 11 Mar 2015 18:37:32 -0000, Jeff Haran said:
>
>> I don't understand the problem here. The caller passes in a condition to be
>> evaluated in a loop. Many times that condition is quite simple (e.g. a counter
>> being non-zero). If it was a function the caller would have to pass in a
>> pointer to a function that does the evaluation, as in:
>
> We do pointers to callback functions all the time. We try *really* hard
> to avoid anonymous lambda functions (which is basically what we have here).
>
> The problem here is that there's about 3 zillion ways to screw up the inline
> version, starting with the compiler optimizing the control variable into a
> hoisted load outside the loop and causing the test to always fail - note that
> the macro does *not* use any barriers or volatile or anything like that.
We could go a couple of more rounds on this, but I don't think there is
much point. It is sufficent to note that there are different views on
the subject. None of them are "right" or "wrong". Use a function if you
like. There are probably 3 zillion ways to screw up either way :-)
Bj?rn
next prev parent reply other threads:[~2015-03-11 19:41 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-11 14:17 confusing code....whats the point of this construct ? Nicholas Mc Guire
2015-03-11 14:40 ` Valdis.Kletnieks at vt.edu
2015-03-11 14:50 ` Nicholas Mc Guire
2015-03-11 15:09 ` Bjørn Mork
2015-03-11 16:46 ` Nicholas Mc Guire
2015-03-11 17:00 ` Valdis.Kletnieks at vt.edu
2015-03-11 18:37 ` Jeff Haran
2015-03-11 18:47 ` Nicholas Krause
2015-03-11 18:53 ` Nicholas Mc Guire
2015-03-11 18:57 ` Valdis.Kletnieks at vt.edu
2015-03-11 19:16 ` Jeff Haran
2015-03-11 19:41 ` Bjørn Mork [this message]
2015-03-11 15:09 ` Malte Vesper
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=87a8zj48zg.fsf@nemi.mork.no \
--to=bjorn@mork.no \
--cc=kernelnewbies@lists.kernelnewbies.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).