msgq.c 983 B

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