November 10, 2013
Am Fri, 08 Nov 2013 21:00:18 +0100
schrieb "Timo Sintonen" <t.sintonen@luukku.com>:

> Now returning to my original problem.
> 
> I tested various loops and it seems that write to a variable is
> not volatile even if the variable is marked shared. If I write to
> a variable several times in a loop, all but the last write are
> optimized out. The only write is put after the loop.
> Read works fine now with shared.
> 
> How can I do volatile writes?

In case you need a workaround right now:
----------------------------------------
shared struct Register //Also working without shared here
{
    size_t a;
}

shared(Register*) reg = cast(shared(Register*))0xFFDDCCAA;

void main()
{
     for(size_t i = 0; i < 10; i++)
         reg.a = i;
}
----------------------------------------

But of course this needs to be fixed in gdc.
November 10, 2013
On Sunday, 10 November 2013 at 09:20:11 UTC, Johannes Pfau wrote:
> In case you need a workaround right now:
> ----------------------------------------
> shared struct Register //Also working without shared here
> {
>     size_t a;
> }
>
> shared(Register*) reg = cast(shared(Register*))0xFFDDCCAA;
>
> void main()
> {
>      for(size_t i = 0; i < 10; i++)
>          reg.a = i;
> }
> ----------------------------------------
>
> But of course this needs to be fixed in gdc.

Yes, this works when I do it in main but not when I call the original member function.
The struct has to be marked shared in this case. Otherwise the compiler does not allow to call member functions with shared pointer. It still does not work.
It works when I move the function out of the struct. Thanks to ufcs, I do not have to change any other code: sendtext(uart,text) is the same than uart.sendtext(text)

I think the problem is here: when outside, the functon gets the real pointer with all additions. When inside, the function gets only bare 'this' without additional info.

I have no idea what to do for this but now I have a workaround and I can get one step ahead again.
1 2
Next ›   Last »