-
Notifications
You must be signed in to change notification settings - Fork 951
Refactor volatile operations (try 2) #334
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This refactor is also part of #285. Removing |
My first impression is really positive. The code looks a lot clearer and cleaner this way than using all the operators. |
f0f0c82
to
9dca67f
Compare
I fixed it (mostly) with Unfortunately, code size does change. For examples/blinky1 and examples/adc it gets slightly smaller, and for examples/echo it gets a bit bigger. Behavior is unchanged in my tests. I'm slightly worried it might badly affect the other targets but if it does, we can look for alternatives. I prefer this API much more than the current/old compiler hints/hacks so we should make the compiler smart enough to optimize it away. |
OK, so seems like we will need the equivilent PR for the various ARM-based MCUs. There are a lot more implementations to port, I am happy to help with that once you have the core code. We should merge any outstanding machine package commits first, if possible. Also, just wondering if perhaps the AVR SPI implementation that @torntrousers was working on might be ready to merge before this PR lands? Otherwise there will be some changes he will need to make first. I looked at the code size differences a little, and they were very small, as in 16-64 bytes total. That is easily worth the benefits, IMO. Anyhow, we should figure out how to proceed, and do it as soon as possible. I really want this API now that I have seen it. |
So which one should go in first? I see there is a merge conflict that's trivial to resolve (EDIT: fixed), but other than that I would prefer to merge this one first as long as there is no PR from @torntrousers (unless he intends to make one soon). The longer this one waits, the more maintenance it will require. |
This does increase code size, but it is necessary to avoid undefined behavior.
The long term goal is to remove the //go:volatile hack.
This avoids the //go:volatile pragma on types in Go source code, at least for AVR targets.
9dca67f
to
edfbae5
Compare
Please don't wait for me. Been held up by life and all the i2c things. |
Thanks for the update @torntrousers when you do get around to it, the changes should not be very substantial. OK I will merge this PR so we can keep going. The only ARM-based PR still outstanding is the one from @Munsio #333 which would appear to be nearly complete. Seems like would be very good to merge that one before starting the ARM migration, probably. |
This replaces #325 with a better to use API.
I tested examples/blinky1 and examples/blinky2 on an Arduino Uno, and tested examples/blinky1 on a digispark. They all still work, but code size is significantly increased. I'll improve this PR to avoid that.