Messages in this thread | | | Date | Sun, 22 Jan 2006 19:36:40 -0500 | From | Albert Cahalan <> | Subject | anon unions are cool |
| |
Now that the kernel requires a compiler that supports anonymous unions, we can do some really neat stuff.
For example, suppose we wanted to rename a badly-named struct member. If the struct is used all over the kernel, this becomes a giant project with huge potential for patch conflicts.
Anonymous unions solve this. First, we replace the badly-named struct member with an anonymous union containing both the old name and the new name. Second, we change much of the kernel to use the new name. Third, we mark the old name with the __depricated tag to generate warnings. Fourth, we get the stragglers over days or months. Fifth, we get rid of the anonymous union by replacing it with the new name.
The struct evolves like so:
struct a { int foo; int bad; int bar; };
struct a { int foo; union { int bad; int baz; }; int bar; };
struct a { int foo; union { int __deprecated bad; int baz; }; int bar; };
struct a { int foo; int baz; int bar; }; - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
| |