On Thursday, 24 October 2013 at 06:25:20 UTC, Arjan wrote:
On Thursday, 24 October 2013 at 00:43:11 UTC, Mike wrote:
Hello again,

I'm interested in ARM bare-metal programming with D, and I'm trying to get my head wrapped around how to approach this. I'm making progress, but I found something that was surprising to me: deprecation of the volatile keyword.

In the bare-metal/hardware/driver world, this keyword is important to ensure the optimizer doesn't cache reads to memory-mapped IO, as some hardware peripheral may modify the value without involving the processor.

I've read a few discussions on the D forums about the volatile keyword debate, but noone seemed to reconcile the need for volatile in memory-mapped IO. Was this an oversight?

What's D's answer to this? If one were to use D to read from memory-mapped IO, how would one ensure the compiler doesn't cache the value?

This article might also give some insight in the problems with volatile:
http://blog.regehr.org/archives/28

Arjan, Thanks for the information. I basically agree with premise of that blog, but the author also said "If you are writing code for an in-order embedded processor and have little or no infrastructure besides the C compiler, you may need to lean more heavily on volatile". Well, that's me.

My goal is to target bare-metal embedded systems with D, so I'm looking for a volatile-like solution in D. I don't care if the language has the "volatile" keyword or not, I just want to be able to read and write to my IO as fast as possible, and I'm wondering if D has a way to do this in a way that is comparable to what can be achieved in C.

Reply via email to