ipcbsd.inc 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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,3, 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. shmat:=pointer(do_syscall(syscall_nr_shmsys,0, shmid, TSysParam(shmaddr), shmflg));
  31. end;
  32. Function shmdt (shmaddr:pointer):cint;
  33. begin
  34. {$ifdef NetBSD}
  35. shmdt:=do_syscall(syscall_nr_shmdt,2, TSysParam(shmaddr));
  36. {$else NetBSD}
  37. shmdt:=do_syscall(syscall_nr_shmsys,2, TSysParam(shmaddr));
  38. {$endif NetBSD}
  39. end;
  40. Function shmctl(shmid:cint; cmd:cint; buf: pshmid_ds): cint;
  41. begin
  42. shmctl:= do_syscall(syscall_nr_shmsys,4, shmid, cmd, TSysParam(buf));
  43. end;
  44. Function semget(key:Tkey; nsems:cint; semflg:cint): cint;
  45. begin
  46. semget:=do_syscall(syscall_nr_semsys,1, key, nsems, semflg);
  47. end;
  48. Function semop(semid:cint; sops: psembuf; nsops: cuint): cint;
  49. begin
  50. semop:=do_syscall(syscall_nr_semsys,2, semid, TSysParam(sops), nsops, 0);
  51. end;
  52. Function semctl(semid:cint; semnum:cint; cmd:cint; var arg: tsemun): cint;
  53. begin
  54. semctl:=cint(do_syscall(syscall_nr_semsys, 0, semid, semnum, cmd,TSysParam(@arg)));
  55. end;
  56. Function msgget(key: TKey; msgflg:cint):cint;
  57. begin
  58. msgget:=do_syscall(syscall_nr_msgsys,1, key, msgflg);
  59. end;
  60. Function msgsnd(msqid:cint; msgp: PMSGBuf; msgsz: size_t; msgflg:cint): cint;
  61. begin
  62. msgsnd:=do_syscall(syscall_nr_msgsys,2, msqid, TSysParam(msgp), TSysParam(msgsz), msgflg);
  63. end;
  64. Function msgrcv(msqid:cint; msgp: PMSGBuf; msgsz: size_t; msgtyp:clong; msgflg:cint):cint;
  65. begin
  66. msgrcv:=(do_syscall(syscall_nr_msgsys,3, msqid, TSysParam(msgp), msgsz, msgtyp, msgflg));
  67. end;
  68. Function msgctl(msqid:cint; cmd: cint; buf: PMSQid_ds): cint;
  69. begin
  70. msgctl:= (do_syscall(syscall_nr_msgsys,0, msqid, cmd, tsysparam(buf)));
  71. end;