Front Page All Articles Recent Changes Random Article

Contents

Concatenative language

  • ACL
  • Ait
  • Aocla
  • Breeze
  • Callisto
  • Cat
  • Cognate
  • colorForth
  • Concata
  • CoSy
  • Deque
  • DSSP
  • dt
  • Elymas
  • Enchilada
  • ETAC
  • F
  • Factor
  • Fiveth
  • Forth
  • Fourth
  • Freelang
  • Gershwin
  • hex
  • iNet
  • Joy
  • Joy of Postfix App
  • kcats
  • Kitten
  • lang5
  • Listack
  • LSE64
  • Lviv
  • Meow5
  • min
  • Mirth
  • mjoy
  • Mlatu
  • Ode
  • OForth
  • Om
  • Onyx
  • Plorth
  • Popr
  • Porth
  • PostScript
  • Prowl
  • Quest32
  • Quackery
  • r3
  • Raven
  • Retro
  • RPL
  • SPL
  • Staapl
  • Stabel
  • Tal
  • Titan
  • Trith
  • Uiua
  • Worst
  • xs
  • XY
  • 5th
  • 8th

Concatenative topics

  • Compilers
  • Interpreters
  • Type systems
  • Object systems
  • Quotations
  • Variables
  • Garbage collection
  • Example programs

Concatenative meta

  • People
  • Communities

Other languages

  • APL
  • C++
  • Erlang
  • FP trivia
  • Haskell
  • Io
  • Java
  • JavaScript
  • Lisp
  • ML
  • Oberon
  • RPL
  • Self
  • Slate
  • Smalltalk

Meta

  • Search
  • Farkup wiki format
  • Etiquette
  • Sandbox

FFI/StructReturns

Returning structs by value on different platforms.

x86-32

On x86-32, we distinguish between "small structs" and "large structs".

On Linux, NetBSD and Solaris, all structs are large structs. On Mac OS X, Windows, FreeBSD and OpenBSD, all structs are large structs except those that satisfy one of the following:

  • The struct is 1, 2, 4 or 8 bytes in size
  • The struct is a C99 complex float value

Note that a struct that's, for instance, 3 bytes in size is considered a large struct.

Small structs

Small structs are returned in EAX:EDX, with the first 4 bytes in EAX and the second 4 bytes in EDX. If the struct is smaller than 4 bytes in size, EDX is undefined.

Large structs

Large structs are handled as follows. The struct-returning function actually has a hidden first parameter which must be a pointer to a memory area large enough to store the returned struct. This memory area must be supplied by the caller. The EAX and EDX registers are unused in this case.

If the struct-returning function uses the stdcall calling convention (Windows only), then it behaves exactly like a void-returning function with an extra first parameter. However, on non-Windows platforms where the C calling convention is used, the struct-returning function returns with the stack pointer incremented by 4 bytes. So after calling such a function, if you care about the value of ESP, you must decrement ESP by 4 bytes, by pushing a dummy value, for instance.

x86-64

PowerPC

This revision created on Tue, 21 Jul 2009 00:30:10 by slava

Latest Revisions Edit

All content is © 2008-2024 by its respective authors. By adding content to this wiki, you agree to release it under the BSD license.