Requesting D ABI clarifications

Anders F Björklund afb at algonet.se
Thu May 11 00:14:35 PDT 2006


Gregor Richards wrote:

> Could somebody (Walter?) either explain how these work in DMD or point 
> me to where these are explained?  I would really like to be compatible, 
> or at least as compatible as possible, with the reference ABI ... 
> hopefully this is doable from C (I'm willing to use GCC __attribute__'s 
> and inline assembly where necessary, this is how I got a parameter into 
> %eax).

Seconded, this would be a good thing for GDC compatibility as well...


Currently one difference that I know about is how arrays are passed:

typedef struct dstr     dstr;  // D string

#ifndef __GDC__

// DMD currently uses a 32-bit hack
typedef unsigned long long dstrret;
static inline dstrret dstr_ret(const wxString& str) { return 
str.length() | (((dstrret)(unsigned long)str.data())<<32); }
static inline dstrret dstr_ret(const wxString* str) { return 
str->length() | (((dstrret)(unsigned long)str->data())<<32); }

#else

#define dstrret       dstr
#define dstr_ret(str) dstr(str)

#endif

That is, they are returned as a struct in GDC and as a ulong in DMD.

--anders

PS. Example from wxD



More information about the Digitalmars-d mailing list