In article
<dfd380e6-6c6b-40d2-81c8-31805120704f@[EMAIL PROTECTED]
>,
Robert Spykerman <robert.spykerman@[EMAIL PROTECTED]
> wrote:
> I am fairly new to OS X having just got a penryn/leopard. I'm trying
> to ****t some IA-32 asm code over to the XNU kernel from linux, and I'm
> just having a bit of trouble understanding what actually is going on
> when I call a sys_fork.
>
> on the man 2 pages it gives me this:
>
> pid_t fork (void) where pid_t is an unsigned 32 bit.
>
> Much the same as linux, fine, good. No worries, should be a piece of
> cake right? I know the different calling conventions.. I've already
> fixed the bit of code dealing with lseek, I should be grand right?
Are you sure you know the calling conventions? They are do***ented at
<http://developer.apple.com/do***entation/DeveloperTools/Conceptual/LowLevelABI/A
rticles/IA32.html#//apple_ref/doc/uid/TP40002492> for IA-32 and
<http://developer.apple.com/do***entation/DeveloperTools/Conceptual/LowLevelABI/A
rticles/x86_64.html#//apple_ref/doc/uid/TP40005035> for x86-64
I am unclear on why you are referring to BSD do***entation, when Apple's
do***entation is available (and possibly different -- Mac OS X does not
use the
BSD kernel).
> What gives?
The source for the fork syscall is in
<http://www.opensource.apple.com/darwinsource/10.5.2/xnu-1228.3.13/bsd/kern/kern_
fork.c>. One notable aspect of it is:
retval[0] = child->p_pid;
retval[1] = 0; /* flag parent */
which does, indeed indicate that the return value of the fork syscall on
Mach
consists of two parts; if you look in the calling convention do***ents I
mentioned above, I believe that you will find that those two parts are
returned
in EAX and EDX, respectively.
> BUT still I have NO idea what EDX actually represents actually and
> where I should be expecting to get my error code, ie in EAX or EDX.
I am not sure either, off-hand; spelunking in the source and reading the
do***entation should provide the answer.
> I could not find the source to syscall fork (0x02) - to find out what
> the heck all this EDX business is... I mean, from the prototype, one
> would imagine you'd only get one 32 bit value returned..
That prototype is for the C library fork() call, not for the fork syscall.
I am
wondering whether you'd be better off calling the C library, which has a
sane
calling convention.
hth
Ben
--
If this message helped you, consider buying an item
from my wish list: <http://artins.org/ben/wishlist>


|