ipcbsd.inc 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. {
  2. This file is part of the Free Pascal run time library.
  3. Copyright (c) 1999-2004 by Marco van de Voort
  4. member of the Free Pascal development team
  5. *BSD syscalls for ipc unit.
  6. See the file COPYING.FPC, included in this distribution,
  7. for details about the copyright.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  11. **********************************************************************}
  12. function ftok(path:Pchar; id:cint):key_t;
  13. var st:stat;
  14. begin
  15. if fpstat(path,st)<0 then
  16. ftok:=key_t(-1)
  17. else
  18. ftok:=key_t( byte(id) shl 24 + ((st.st_dev and 255) shl 16) + (st.st_ino and $ffff));
  19. end;
  20. function shmget(key:key_t;size:size_t;flag:cint):cint;
  21. begin
  22. {$ifdef NetBSD}
  23. shmget:=do_syscall(syscall_nr_shmget, key, size, flag);
  24. {$else NetBSD}
  25. shmget:=do_syscall(syscall_nr_shmsys,3, key, size, flag);
  26. {$endif NetBSD}
  27. end;
  28. Function shmat (shmid:cint; shmaddr:pointer; shmflg:cint):pointer;
  29. begin
  30. {$ifdef NetBSD}
  31. shmat:=pointer(do_syscall(syscall_nr_shmat, shmid, TSysParam(shmaddr), shmflg));
  32. {$else NetBSD}
  33. shmat:=pointer(do_syscall(syscall_nr_shmsys,0, shmid, TSysParam(shmaddr), shmflg));
  34. {$endif NetBSD}
  35. end;
  36. Function shmdt (shmaddr:pointer):cint;
  37. begin
  38. {$ifdef NetBSD}
  39. shmdt:=do_syscall(syscall_nr_shmdt, TSysParam(shmaddr));
  40. {$else NetBSD}
  41. shmdt:=do_syscall(syscall_nr_shmsys,2, TSysParam(shmaddr));
  42. {$endif NetBSD}
  43. end;
  44. Function shmctl(shmid:cint; cmd:cint; buf: pshmid_ds): cint;
  45. begin
  46. {$ifdef NetBSD}
  47. shmctl:= do_syscall(syscall_nr___shmctl13, shmid, cmd, TSysParam(buf));
  48. {$else NetBSD}
  49. shmctl:= do_syscall(syscall_nr_shmsys,4, shmid, cmd, TSysParam(buf));
  50. {$endif NetBSD}
  51. end;
  52. Function semget(key:Tkey; nsems:cint; semflg:cint): cint;
  53. begin
  54. {$ifdef NetBSD}
  55. semget:=do_syscall(syscall_nr_semget, key, nsems, semflg);
  56. {$else NetBSD}
  57. semget:=do_syscall(syscall_nr_semsys,1, key, nsems, semflg);
  58. {$endif NetBSD}
  59. end;
  60. Function semop(semid:cint; sops: psembuf; nsops: cuint): cint;
  61. begin
  62. {$ifdef NetBSD}
  63. semop:=do_syscall(syscall_nr_semop, semid, TSysParam(sops), nsops, 0);
  64. {$else NetBSD}
  65. semop:=do_syscall(syscall_nr_semsys,2, semid, TSysParam(sops), nsops, 0);
  66. {$endif NetBSD}
  67. end;
  68. Function semctl(semid:cint; semnum:cint; cmd:cint; var arg: tsemun): cint;
  69. begin
  70. {$ifdef NetBSD}
  71. semctl:=cint(do_syscall(syscall_nr_semconfig, semid, semnum, cmd,TSysParam(@arg)));
  72. {$else NetBSD}
  73. semctl:=cint(do_syscall(syscall_nr_semsys, 0, semid, semnum, cmd,TSysParam(@arg)));
  74. {$endif NetBSD}
  75. end;
  76. Function msgget(key: TKey; msgflg:cint):cint;
  77. begin
  78. {$ifdef NetBSD}
  79. msgget:=do_syscall(syscall_nr_msgget, key, msgflg);
  80. {$else NetBSD}
  81. msgget:=do_syscall(syscall_nr_msgsys,1, key, msgflg);
  82. {$endif NetBSD}
  83. end;
  84. Function msgsnd(msqid:cint; msgp: PMSGBuf; msgsz: size_t; msgflg:cint): cint;
  85. begin
  86. {$ifdef NetBSD}
  87. msgsnd:=do_syscall(syscall_nr_msgsnd, msqid, TSysParam(msgp), TSysParam(msgsz), msgflg);
  88. {$else NetBSD}
  89. msgsnd:=do_syscall(syscall_nr_msgsys,2, msqid, TSysParam(msgp), TSysParam(msgsz), msgflg);
  90. {$endif NetBSD}
  91. end;
  92. Function msgrcv(msqid:cint; msgp: PMSGBuf; msgsz: size_t; msgtyp:clong; msgflg:cint):cint;
  93. begin
  94. {$ifdef NetBSD}
  95. msgrcv:=(do_syscall(syscall_nr_msgrcv, msqid, TSysParam(msgp), msgsz, msgtyp, msgflg));
  96. {$else NetBSD}
  97. msgrcv:=(do_syscall(syscall_nr_msgsys,3, msqid, TSysParam(msgp), msgsz, msgtyp, msgflg));
  98. {$endif NetBSD}
  99. end;
  100. Function msgctl(msqid:cint; cmd: cint; buf: PMSQid_ds): cint;
  101. begin
  102. {$ifdef NetBSD}
  103. msgctl:= (do_syscall(syscall_nr___msgctl13, msqid, cmd, tsysparam(buf)));
  104. {$else NetBSD}
  105. msgctl:= (do_syscall(syscall_nr_msgsys,0, msqid, cmd, tsysparam(buf)));
  106. {$endif NetBSD}
  107. end;