Linus Torvalds wrote:Bitfields also generate lower-quality assembly than masks&shifts (typically more instructions using additional temporaries to accomplish the same thing), based on my own informal gcc testing. You would think gcc would be advanced enough to turn bitfield use into masks and shifts under the hood, but for whatever reason that often is not the case in kernel code. Due to the way they're used, bitfields make more difficult the common code pattern of setting several flags at once: (assuming 'foo', 'bar' and 'baz' are bitfields in a struct) pdev->foo = 1; pdev->bar = 0; pdev->baz = 1; versus flag_foo = (1 << 0); flag_bar = (1 << 1); flag_baz = (1 << 2); ... pdev->flags = flag_foo | flag_bar; </pet peeve> And getting back on topic, I think "pdev->flags = cpu_to_le32(flag1|flag2)" is nicer than dealing with bitfields, when your data structures are fixed-endian. Jeff - To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
| Greg Kroah-Hartman | [PATCH 002/196] Chinese: rephrase English introduction in HOWTO |
| Tarkan Erimer | Re: Dual-Licensing Linux Kernel with GPL V2 and GPL V3 |
| Roland Dreier | Re: Integration of SCST in the mainstream Linux kernel |
git: | |
| Radu Rendec | htb parallelism on multi-core platforms |
| David Miller | Re: [PATCH] pkt_sched: Destroy gen estimators under rtnl_lock(). |
| David Miller | [GIT]: Networking |
| Gerrit Renker | [PATCH 27/37] dccp: Integration of dynamic feature activation - part 2 (server side) |
