GNOME Bugzilla – Bug 648330
Vala silently ignores marking field as volatile
Last modified: 2011-08-12 10:17:09 UTC
Created attachment 186380 [details] [review] 0001-Fix-parsing-volatile-fields.patch Vala silently ignores marking field as volatile and it does not go to the code generation. This patch fixes the problem.
Created attachment 186384 [details] [review] 0001-Fix-parsing-volatile-fields.patch
Comment on attachment 186384 [details] [review] 0001-Fix-parsing-volatile-fields.patch Ups. Sorry - I forgot to state what are the changes - I interpreted the following: volatile void *x = 0; As volatile pointer x (i.e. bracketing is volatile (void *) not as in C (volatile void)* and previous patch. it also emits the volatile in any case not only I belive it is more consistend and what would people expect. PS. Patch is broken and I'm working on it.
Created attachment 186386 [details] [review] 0001-Fix-handling-volatile-fields.patch
Created attachment 186388 [details] [review] 0001-Fix-handling-volatile-fields.patch
Created attachment 186389 [details] [review] 0001-Fix-handling-volatile-fields.patch Sorry for spamming but I keep attaching wrong patches...
Sight. glib-2.0.vapi shouldn't be modified.
Created attachment 186544 [details] [review] 0001-Implement-more-advanced-handling-of-volatile.patch A patch implementing more advanced handling of volatile. It makes it property of type (ones derived from VolatileType) - currently they are ValueType and PointerType. Bracekting is as follows: - volatile referes to LHS of it as in C (int volatile * is pointer to volatile int while int * volatile is volatile pointer to int) - if on LHS there is no type *unlike* C it referes to the whole type. However it have highier precedence then array so (volatile int * is volatile pointer to int while volatile int[] is array of volatile ints). Rationale: - Keep more or less compatibility with C - Make it less confusing what volatile int * is - Don't worry what precise semantic is of: volatile Gtk.Lable l = new Gtk.Label (null); As the copy of value and incrementing the reference count is not atomic on many platforms and with volatile you probably want to hand-manage memory anyway
Created attachment 186545 [details] [review] 0001-Implement-more-advanced-handling-of-volatile.patch After thought - due to way it is parsed it is unfortunatly ambigous is "int volatile" a variable volatile with type int or int that is volatile. The patch was altered to disallow volatile as identifier.
Created attachment 186546 [details] [review] 0001-Implement-more-advanced-handling-of-volatile.patch Sorry for amount of patches but I'm still beginner in vala sourcecode and I've found a few cornercases.
Created attachment 188344 [details] [review] 0001-Implement-more-advanced-handling-of-volatile.patch Hopefully working rebase against newer vala (I hadn't tested it yet).
Created attachment 189714 [details] [review] 0001-Implement-more-advanced-handling-of-volatile.patch
After talk with Jürg on Desktop Summit: he found much cleaner workaround for atomics.