Re: system call library functions
Kevin Van Vechten <[email protected]>
| Newsgroups | gmane.os.opendarwin.general |
|---|---|
| Message-ID | <[email protected]> |
For the best compatibility with different versions of Mac OS X /
Darwin, applications should always use the wrapper functions in Libc
and never invoke syscalls directly. I realize this might not be much
of a concern for a bench mark, but it's worth pointing out for the sake
of the list archives.
- Kevin
On Nov 29, 2004, at 3:15 PM, Ronnie Misra wrote:
> 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_______________________________________________
> Discuss mailing list
> [email protected]
> http://www.opendarwin.org/mailman/listinfo/discuss