solaris port
Brad Roberts
braddr at puremagic.com
Thu Apr 27 21:12:27 PDT 2006
I've been working on getting gdc working on solaris and have hit an
interesting issue concerning a difference between the x86 and sparc abi's.
The dynamic array struct looks like:
struct dynamic_array
{
int length;
void *ptr;
}
(work with me, that's approximate)
On x86, when a da is passed to a function, both words of the structure are
pushed and can be pulled off as individual words. This is particularly
useful with printf, as in this form:
printf("%.*s\n", dynamicString);
That's 100% the same as, on x86:
printf("%.*s\n", dynamicString.length, dynamicString.ptr);
On solaris, an indirect reference it passed as a single argument, so the
first form of printf fails, though of course the second form works as
expected.
While printf isn't part of D, it's a rather common idiom that's offered
and used by many.
An 'obvious' thing to do would be to teach gdc to split dynamic arrays up
and manually treat as two args to variadic functions. I don't like that
as a general solution. Maybe do that for just extern (C)'ed functions,
but even that I don't thing is a good idea. I could be talked into it for
just the printf family of functions, but that's a pretty disgusting hack.
Anyone have any suggestions / thoughts for other ways to handle this?
Later,
Brad
More information about the D.gnu
mailing list