• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
struct parameter padding
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

struct parameter padding


  • Subject: struct parameter padding
  • From: Jonas Maebe <email@hidden>
  • Date: Mon, 10 Jan 2005 20:12:56 +0100

Hello,

I'm following http://developer.apple.com/documentation/DeveloperTools/Conceptual/ MachORuntime/PowerPCConventions/chapter_3_section_5.html to implement Darwin-ABI compatible parameter passing. That document states:

---
Composite parameters (arrays or data structures) 1 or 2 bytes in size are preceded by padding to 4 bytes.


This rule is inconsistent with other PowerPC ABIs. In AIX and classic Mac OS, padding bytes always follow the structure data even in the case of composite parameters smaller than 4 bytes.
---


According to my testing, that's incorrect (at least for "gcc version 3.3 20030304 (Apple Computer, Inc. build 1640)"), regardless of whether the struct is passed in a register or in memory. Example:

***
#pragma pack(1)
typedef struct t_ {
  char a, b;
} ttype;

int tt(int r3, int r4, int r5, int r6, int r7, int r8, int r9, int r10,
   ttype s) {
}


int main() { ttype a;

  a.a = 55;
  a.a = 66;

  tt(3,4,5,6,7,8,9,10,a);
  return 0;
}
***

Resulting assembler code for passing the struct:

        mr r30,r1
        li r0,55
        stb r0,80(r30)
        li r0,66
        stb r0,80(r30)
        lhz r0,80(r30)
        sth r0,56(r1)

56(r1) is the start offset of the first parameter, so the two padding bytes come after the struct. gcc version 2.9-aix51-020209 under AIX 5.1 produces the same code (don't ask me why it doesn't come with a more recent gcc).

Similarly, when the parameter is passed in a register, both under Darwin and AIX the struct is passed in the lower two bytes of the register.

Am I missing something?


Jonas

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Prev by Date: Re: db acess
  • Next by Date: Re: XCode and STL/STD code completion/code sense - possible???
  • Previous by thread: Re: db acess
  • Next by thread: Compiling Objc++
  • Index(es):
    • Date
    • Thread