Re: system call library functions
Ronnie Misra <[email protected]>
| Newsgroups | gmane.os.opendarwin.general |
|---|---|
| Message-ID | <[email protected]> |
It's relatively straightforward to make a function that calls the
kernel getpid every time:
(mygetpid.s)
.globl _mygetpid
_mygetpid:
li r0,20
sc
blr
blr
(main.c)
#include <stdio.h>
int mygetpid();
int main(int argc, char *argv[]) {
printf("%d\n", mygetpid());
return 0;
}
There are two blrs because the kernel returns to either PC+4 or PC+8
depending on whether there was an error.
Ronnie