diff options
Diffstat (limited to 'libc/misc/sysvipc/msgq.c')
-rw-r--r-- | libc/misc/sysvipc/msgq.c | 102 |
1 files changed, 45 insertions, 57 deletions
diff --git a/libc/misc/sysvipc/msgq.c b/libc/misc/sysvipc/msgq.c index fc0279119..59fd47424 100644 --- a/libc/misc/sysvipc/msgq.c +++ b/libc/misc/sysvipc/msgq.c @@ -1,6 +1,11 @@ #include <errno.h> #include <sys/msg.h> #include "ipc.h" +#ifdef __UCLIBC_HAS_THREADS_NATIVE__ +#include "sysdep-cancel.h" +#else +#define SINGLE_THREAD_P 1 +#endif #ifdef L_msgctl @@ -42,83 +47,66 @@ struct new_msg_buf{ #ifdef L_msgrcv -#ifdef __UCLIBC_HAS_THREADS_NATIVE__ -#include <sysdep-cancel.h> - -int -__libc_msgrcv (int msqid, void *msgp, size_t msgsz, long int msgtyp, int msgflg) +#ifdef __NR_msgrcv +#define __NR___syscall_msgrcv __NR_msgrcv +static inline _syscall5(int, __syscall_msgrcv, int, msqid, void *, msgp, + size_t, msgsz, long int, msgtyp, int, msgflg); +#endif +static inline int do_msgrcv (int msqid, void *msgp, size_t msgsz, + long int msgtyp, int msgflg) { - /* The problem here is that Linux' calling convention only allows up to - fives parameters to a system call. */ - struct new_msg_buf tmp; - - tmp.oldmsg = msgp; - tmp.r_msgtyp = msgtyp; - - if (SINGLE_THREAD_P) - return INLINE_SYSCALL (ipc, 5, IPCOP_msgrcv, msqid, msgsz, msgflg, - __ptrvalue (&tmp)); - - int oldtype = LIBC_CANCEL_ASYNC (); - - int result = INLINE_SYSCALL (ipc, 5, IPCOP_msgrcv, msqid, msgsz, msgflg, - __ptrvalue (&tmp)); - - LIBC_CANCEL_RESET (oldtype); - - return result; -} -weak_alias(__libc_msgrcv, msgrcv) -#else #ifdef __NR_msgrcv -_syscall5(int, msgrcv, int, msqid, void *, msgp, size_t, msgsz, long int, msgtyp, int, msgflg); + return __syscall_msgrcv(msqid, msgp, msgsz, msgtyp, msgflg); #else -int msgrcv (int msqid, void *msgp, size_t msgsz, - long int msgtyp, int msgflg) -{ struct new_msg_buf temp; temp.r_msgtyp = msgtyp; temp.oldmsg = msgp; return __syscall_ipc(IPCOP_msgrcv ,msqid ,msgsz ,msgflg ,&temp, 0); -} #endif +} +int msgrcv (int msqid, void *msgp, size_t msgsz, + long int msgtyp, int msgflg) +{ + if (SINGLE_THREAD_P) + return do_msgrcv(msqid, msgp, msgsz, msgtyp, msgflg); +#ifdef __UCLIBC_HAS_THREADS_NATIVE__ + int oldtype = LIBC_CANCEL_ASYNC (); + int result = do_msgrcv(msqid, msgp, msgsz, msgtyp, msgflg); + LIBC_CANCEL_RESET (oldtype); + return result; #endif +} #endif #ifdef L_msgsnd -#ifdef __UCLIBC_HAS_THREADS_NATIVE__ -#include <sysdep-cancel.h> - -int -__libc_msgsnd (int msqid, const void *msgp, size_t msgsz, int msgflg) -{ - if (SINGLE_THREAD_P) - return INLINE_SYSCALL (ipc, 5, IPCOP_msgsnd, msqid, msgsz, - msgflg, msgp); - - int oldtype = LIBC_CANCEL_ASYNC (); - - int result = INLINE_SYSCALL (ipc, 5, IPCOP_msgsnd, msqid, msgsz, - msgflg, msgp); - - LIBC_CANCEL_RESET (oldtype); - - return result; -} -weak_alias(__libc_msgsnd, msgsnd) -#else #ifdef __NR_msgsnd -_syscall4(int, msgsnd, int, msqid, const void *, msgp, size_t, msgsz, int, msgflg); -#else +#define __NR___syscall_msgsnd __NR_msgsnd +static inline _syscall4(int, __syscall_msgsnd, int, msqid, const void *, msgp, + size_t, msgsz, int, msgflg); +#endif /* Send message to message queue. */ -int msgsnd (int msqid, const void *msgp, size_t msgsz, int msgflg) +static inline int do_msgsnd (int msqid, const void *msgp, size_t msgsz, + int msgflg) { +#ifdef __NR_msgsnd + return __syscall_msgsnd(msqid, msgp, msgsz, msgflg); +#else return __syscall_ipc(IPCOP_msgsnd, msqid, msgsz, msgflg, (void *)msgp, 0); -} #endif +} +int msgsnd (int msqid, const void *msgp, size_t msgsz, int msgflg) +{ + if (SINGLE_THREAD_P) + return do_msgsnd(msqid, msgp, msgsz, msgflg); +#ifdef __UCLIBC_HAS_THREADS_NATIVE__ + int oldtype = LIBC_CANCEL_ASYNC (); + int result = do_msgsnd(msqid, msgp, msgsz, msgflg); + LIBC_CANCEL_RESET (oldtype); + return result; #endif +} #endif |