[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: RFC: Support non-standard extension (call via casted function pointer)

On Thu, 28 Jan 2016 19:10:03 +0100
Andreas Schwab <schwab@linux-m68k.org> wrote:

> Why does the dummy declaration need to use a pointer type?

Just a historical remnant.

Historically it was a single declaration used for both "known"
prototypes (for functions generated by GHC) and "unknown"
prototypes (arbitrary C functions called by haskell code).

GHC-generated "known" functions have prototype
    void * (*)(void);
Historically it was a shortcut to reuse the same prototype
for "unknown" functions. It was a mistake.

This mistake led to breakage for powerpc64le and this shared
prototype was relaxed down to incomplete prototype both for
"known" and "unknown" functions to:
    void * (*)();
at a performance and type safety cost for "known" functions.

Splitting "known"/"unknown" cases is an obvious change in GHC
which was done in
a few days ago.

Now "known" functions have precise type of
    void * (*)(void);
and "unknown" functions have incomplete type
    void (*)();

It seems to fix m68k but there is no reason not to break later
if gcc will assume stack layout setup by caller (if there are targets
in the world passing all results using stack).

GHC only calls C functions that can fit the result in a single register
thus 'void *' did look safe safe :)

It would be nice to have more stable workaround :)



Attachment: signature.asc
Description: PGP signature

Reply to: