[Bug 266] New: Can threadasm.S be replaced with generics?

via D.gnu d.gnu at puremagic.com
Tue Jul 18 17:02:50 PDT 2017


https://bugzilla.gdcproject.org/show_bug.cgi?id=266

            Bug ID: 266
           Summary: Can threadasm.S be replaced with generics?
           Product: GDC
           Version: development
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: Normal
         Component: libgdruntime
          Assignee: ibuclaw at gdcproject.org
          Reporter: ibuclaw at gdcproject.org

Having a small play around, these seem to generate what looks like correct code
on x86/64.  Would be nice if confirmed to work with more, then we can get rid
of one extra non-portable file.

---
import gcc.builtins;

// 
void callWithStackShell(scope void delegate(void* sp) nothrow fn) nothrow
{
  version (GNU)
  {
    __builtin_unwind_init();
    asm { ""; }
    fn(__builtin_stack_save());
    asm { ""; }
  }
  else
    static assert(0);
}

//
extern (C) void fiber_switchContext(void** oldp, void* newp) nothrow
{
  version (GNU)
  {
    __builtin_unwind_init();
    asm { ""; }
    *oldp = __builtin_stack_save();
    __builtin_stack_restore(newp);
    asm { ""; }
  }
  else
    static assert(0);
}
---

https://explore.dgnu.org/g/W7zrb8

-- 
You are receiving this mail because:
You are watching all bug changes.


More information about the D.gnu mailing list