xref: /minix3/minix/lib/libc/sys/syscall.c (revision 433d6423c39e34ec4b79c950597bb2d236f886be)
1*433d6423SLionel Sambuc #include <sys/cdefs.h>
2*433d6423SLionel Sambuc #include <lib.h>
3*433d6423SLionel Sambuc #include "namespace.h"
4*433d6423SLionel Sambuc 
5*433d6423SLionel Sambuc #ifdef __weak_alias
__weak_alias(syscall,_syscall)6*433d6423SLionel Sambuc __weak_alias(syscall, _syscall)
7*433d6423SLionel Sambuc #endif
8*433d6423SLionel Sambuc 
9*433d6423SLionel Sambuc int _syscall(endpoint_t who, int syscallnr, message *msgptr)
10*433d6423SLionel Sambuc {
11*433d6423SLionel Sambuc   int status;
12*433d6423SLionel Sambuc 
13*433d6423SLionel Sambuc   msgptr->m_type = syscallnr;
14*433d6423SLionel Sambuc   status = ipc_sendrec(who, msgptr);
15*433d6423SLionel Sambuc   if (status != 0) {
16*433d6423SLionel Sambuc 	/* 'ipc_sendrec' itself failed. */
17*433d6423SLionel Sambuc 	/* XXX - strerror doesn't know all the codes */
18*433d6423SLionel Sambuc 	msgptr->m_type = status;
19*433d6423SLionel Sambuc   }
20*433d6423SLionel Sambuc   if (msgptr->m_type < 0) {
21*433d6423SLionel Sambuc 	errno = -msgptr->m_type;
22*433d6423SLionel Sambuc 	return(-1);
23*433d6423SLionel Sambuc   }
24*433d6423SLionel Sambuc   return(msgptr->m_type);
25*433d6423SLionel Sambuc }
26