digitalmars.D.bugs - [Issue 14456] New: dmd doesn't call C functions with large
- via Digitalmars-d-bugs (29/29) Apr 17 2015 https://issues.dlang.org/show_bug.cgi?id=14456
https://issues.dlang.org/show_bug.cgi?id=14456 Issue ID: 14456 Summary: dmd doesn't call C functions with large structures correctly Product: D Version: D1 Hardware: x86_64 OS: Linux Status: NEW Severity: normal Priority: P1 Component: DMD Assignee: nobody puremagic.com Reporter: andrew.stevenson sociomantic.com Created attachment 1513 --> https://issues.dlang.org/attachment.cgi?id=1513&action=edit example code On Linux/amd64 an argument to a C function which is a structure larger than 64 bits should be passed across multiple registers. Making this call with DMD however does something else (probably trying to pass on the stack). I attach some example code to demonstrate the problem. "make c" produces a binary from C code and "make d" produces a binary from D calling into C. Both should produce the same output. I currently use a workaround of calling the C function via inline ASM. The correct ASM for the attached example would be something like: mov RDI, qword ptr a; mov RSI, qword ptr a + 8; call prettify; --
Apr 17 2015