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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.