Re: Writing kernel code that can talk to 64 bit processes (was Re: Mac OS X 10.4 (Tiger) compilation errors ( GCC v3.3 ) with X Code 2.0 tool)
Re: Writing kernel code that can talk to 64 bit processes (was Re: Mac OS X 10.4 (Tiger) compilation errors ( GCC v3.3 ) with X Code 2.0 tool)
- Subject: Re: Writing kernel code that can talk to 64 bit processes (was Re: Mac OS X 10.4 (Tiger) compilation errors ( GCC v3.3 ) with X Code 2.0 tool)
- From: Andrew Gallatin <email@hidden>
- Date: Wed, 10 Aug 2005 09:32:41 -0400 (EDT)
FWIW, here's what we do when writing ioctls for use in potentially
mixed environments in a portable way:
- Never use "long" or "long long", use explicitly sized types
like int32_t, or uint64_t
- Do explict padding to keep things properly aligned (aligment
pragmas are difficult to keep track of across many different
compilers).
- Keep careful track of the size of structs so as to catch alignment
mistakes. Compile-time assertions like this help quite a bit:
#define CTA(x) do { char (*a)[(x) ? 1 : -1] = 0; (void) a; } while (0)
CTA(sizeof (foo_t) == 64);
CTA(offsetof (foo_t, basic.type) == 31);
- Always pass user pointers in a uint64_t. This will involve
casting to a uintptr_t, but its worth it for portability.
- On MacOSX, always store user pointers as a user_addr_t in the
kernel, never as a void *.
This has stood us in good stead on MacOSX, Linux, FreeBSD, Windows and
Solaris. Including running 32-bit applications with a 64-bit kernel,
and vice-versa...
Drew
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-kernel mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden