msgq.c 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. #include <errno.h>
  2. #include <sys/msg.h>
  3. #include "ipc.h"
  4. #ifdef L_msgctl
  5. #ifdef __NR_msgctl
  6. _syscall3(int, msgctl, int, msqid, int, cmd, struct msqid_ds *, buf);
  7. #else
  8. /* Message queue control operation. */
  9. int msgctl (int msqid, int cmd, struct msqid_ds *buf)
  10. {
  11. return __ipc(IPCOP_msgctl ,msqid ,cmd ,0 ,buf);
  12. }
  13. #endif
  14. #endif
  15. #ifdef L_msgget
  16. #ifdef __NR_msgget
  17. _syscall2(int, msgget, key_t, key, int, msgflg)
  18. #else
  19. /* Get messages queue. */
  20. int msgget (key_t key, int msgflg)
  21. {
  22. return __ipc(IPCOP_msgget ,key ,msgflg ,0 ,0);
  23. }
  24. #endif
  25. #endif
  26. struct new_msg_buf{
  27. struct msgbuf * oldmsg;
  28. long int r_msgtyp; /* the fifth arg of __ipc */
  29. };
  30. /* Receive message from message queue. */
  31. #ifdef L_msgrcv
  32. #ifdef __NR_msgrcv
  33. _syscall5(int, msgrcv, int, msqid, void *, msgp, size_t, msgsz, long int, msgtyp, int, msgflg);
  34. #else
  35. int msgrcv (int msqid, void *msgp, size_t msgsz,
  36. long int msgtyp, int msgflg)
  37. {
  38. struct new_msg_buf temp;
  39. temp.r_msgtyp = msgtyp;
  40. temp.oldmsg = msgp;
  41. return __ipc(IPCOP_msgrcv ,msqid ,msgsz ,msgflg ,&temp);
  42. }
  43. #endif
  44. #endif
  45. #ifdef L_msgsnd
  46. #ifdef __NR_msgsnd
  47. _syscall4(int, msgsnd, int, msqid, const void *, msgp, size_t, msgsz, int, msgflg);
  48. #else
  49. /* Send message to message queue. */
  50. int msgsnd (int msqid, const void *msgp, size_t msgsz, int msgflg)
  51. {
  52. return __ipc(IPCOP_msgsnd, msqid, msgsz, msgflg, (void *)msgp);
  53. }
  54. #endif
  55. #endif