[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20110427013541.18526.qmail@science.horizon.com>
Date: 26 Apr 2011 21:35:41 -0400
From: "George Spelvin" <linux@...izon.com>
To: torvalds@...ux-foundation.org
Cc: linux@...izon.com, linux-kernel@...r.kernel.org, oleg@...hat.com
Subject: Re: [PATCH v2 5/6] signal: sys_sigprocmask() needs retarget_shared_pending()
> and notice how you now can do that helper function *WITHOUT* any
> conditionals, and just make it do
>
> sigprocmask(&clear, &set, NULL);
>
> which handles all cases correctly (just "andn clear" + "or set") with
> no if's or switch'es.
Gripe: Arrgh, apostrophe disease! Linus, youre picking up nasty habits.
Suggestion: Actually, the usual, more flexible implementation, is
"andn mask" + "xor set". That gives all 4 bit operations (nop, set,
clear, and toggle) unique bit combinations.
Not that it's of any use in many cases, but it has better hack value.
That would convert to:
switch (how) {
case SIG_BLOCK:
mask_bits = new_set;
set_bits = new_set;
break;
case SIG_UNBLOCK:
mask_bits = new_set;
set_bits = 0;
break
case SIG_SET:
mask_bits = low_bits | new_set;
set_bits = new_set;
break;
default:
return -EINVAL;
}
If you prefer separate set & clear fields, with both set meaning "toggle",
which admittedly is a more elegant representation, then it's
"andn (set|clear)" + "xor set".
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists