This is the mail archive of the libffi-discuss@sourceware.org mailing list for the libffi project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [patch] port libffi to x86/msvc



On Jan 13, 2010, at 11:17 PM, Dan Witte wrote:


I haven't looked at the patch yet, but ffi_call_SYSV and
ffi_call_STDCALL are not identical, since stdcall must pop its own
args from the stack. I think I originally wrote it to share code
between two functions, with only a little bit on the ends for stdcall,


but someone added some debug/stack metadata that required the two
functions be distinct, thus the duplicated code.

Hmm. Both functions save 'esp' on entry, and restore it on exit, so whether the caller or callee pops the args doesn't matter, and both functions can be identical. Is this correct?


(Looking at history, in an older libffi release, they were different and the SYSV variant adjusted 'esp' appropriately after the foreign call. But this was dropped when 'esp' was saved & restored.)

I have no idea what the eh_frame stuff is doing, so if the two functions need to be distinct for that reason, I can produce a new patch. Presumably the functions can still be merged for MSVC, just not for gcc. Should I do that?

I may be thinking of the closure code. At any rate, if the code is truly identical, and the stdcall tests still pass (and they actually cover what you're changing), then there's no reason not to remove the duplicate code.




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]