Object file questions

Artur Skawina via D.gnu d.gnu at puremagic.com
Sat Aug 16 02:58:49 PDT 2014


On 08/16/14 09:33, Johannes Pfau via D.gnu wrote:
> https://github.com/D-Programming-GDC/GDC/pull/82

[Only noticed this accidentally; using a mailing list
instead of some web forum would increase visibility...]

>  enum var = Volatile!(T,addr)(): doesn't allow |= on enum literals, even if the type implements opAssign as there's no this pointer

   T volatile_load(T)(ref T v) nothrow {
      asm { "" : "+m" v; }
      T res = v;
      asm { "" : "+g" res; }
      return res;
   }

   void volatile_store(T)(ref T v, const T a) nothrow {
      asm { "" : : "m" v; }
      v = a;
      asm { "" : "+m" v; }
   }
      
   struct Volatile(T, alias /* T* */ A) {
       void opOpAssign(string OP)(const T rhs) nothrow {
           auto v = volatile_load(*A);
           mixin("v " ~ OP ~ "= rhs;");
           volatile_store(*A, v);
       }
   }

   enum TimerB = Volatile!(uint, cast(uint*)0xDEADBEEF)();

   void main() {
      TimerB |= 0b1;
      TimerB += 1;
   }

> not emitting force-inlined functions is a logical optimization for forceinline (if a function is always inlined, there's no way to call it, so there's no need to output it).

Taking the address of an always_inline function is allowed.

artur


More information about the D.gnu mailing list