Could FFI support pass-by-value of structs?

View: New views
2 Messages — Rating Filter:   Alert me  
< Prev | 1 - 2 | Next >

Re: Re: Could FFI support pass-by-value of structs?

by John Meacham :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Thu, Jul 02, 2009 at 03:01:48AM +0400, Bulat Ziganshin wrote:

> Hello Duncan,
>
> Thursday, July 2, 2009, 2:57:29 AM, you wrote:
>
> > You don't need it to be the same between Windows and Unix, it just has
> > to be standard on each platform, which it is. There are really only two
> > ABIs in common use on x86, the System V ABI and the MS one (which apart
> > from the stdcall calling convention only differs in the bitfield layout
> > iirc).
>
> you mean that on windows gcc, msvc and all other C compilers use the
> same ABI for passing and packing structs?

Yes. If you think about it, otherwise it would be impossible to
interface with system provided shared libraries (like libc) unless there
is a standard.

It sometimes varies across different OS's, but for any
OS/chip combo there is a single defined C ABI. It is generally called
the 'system V' ABI for historical reasons, even though chances are
people arn't using it for system V. Usually it is provided by the chip
manufacturer and all OS's follow it. Unless they feel like being a PITA,
but in that case they have their own standards document that gcc will
follow as an option. So, yes. there is always _some_ well defined ABI
for the C langauge on a given platform.


        John

--
John Meacham - ⑆repetae.net⑆john⑈ - http://notanumber.net/
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@...
http://www.haskell.org/mailman/listinfo/haskell-cafe

Re[2]: Re: Could FFI support pass-by-value of structs?

by Bulat Ziganshin-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello John,

Tuesday, July 7, 2009, 5:48:10 AM, you wrote:

>> you mean that on windows gcc, msvc and all other C compilers use the
>> same ABI for passing and packing structs?

> Yes. If you think about it, otherwise it would be impossible to
> interface with system provided shared libraries (like libc) unless there
> is a standard.

first, i asked about Windows. second, afair Win32 API doesn't have any
functions that pass or return entire records rather than pointers.
third, i've seen incompatibility problems with packing structs between
MSVC (8-byte alignment, afair) and Borland C++ (1-byte)


--
Best regards,
 Bulat                            mailto:Bulat.Ziganshin@...

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@...
http://www.haskell.org/mailman/listinfo/haskell-cafe
< Prev | 1 - 2 | Next >