ipcbsd.inc 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. {
  2. $Id$
  3. This file is part of the Free Pascal run time library.
  4. Copyright (c) 1999-2004 by Marco van de Voort
  5. member of the Free Pascal development team
  6. *BSD syscalls for ipc unit.
  7. See the file COPYING.FPC, included in this distribution,
  8. for details about the copyright.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  12. **********************************************************************}
  13. function ftok(path:Pchar; id:cint):key_t;
  14. var st:stat;
  15. begin
  16. if fpstat(path,st)<0 then
  17. ftok:=key_t(-1)
  18. else
  19. ftok:=key_t( byte(id) shl 24 + ((st.st_dev and 255) shl 16) + (st.st_ino and $ffff));
  20. end;
  21. function shmget(key:key_t;size:cint;flag:cint):cint;
  22. begin
  23. shmget:=do_syscall(syscall_nr_shmsys,3, key, size, flag);
  24. end;
  25. Function shmat (shmid:cint; shmaddr:pointer; shmflg:cint):pointer;
  26. begin
  27. shmat:=pointer(do_syscall(syscall_nr_shmsys,0, shmid, TSysParam(shmaddr), shmflg));
  28. end;
  29. Function shmdt (shmaddr:pointer):cint;
  30. begin
  31. shmdt:=do_syscall(syscall_nr_shmsys,2, TSysParam(shmaddr));
  32. end;
  33. Function shmctl(shmid:cint; cmd:cint; buf: pshmid_ds): cint;
  34. begin
  35. shmctl:= do_syscall(syscall_nr_shmsys,4, shmid, cmd, TSysParam(buf));
  36. end;
  37. Function semget(key:Tkey; nsems:cint; semflg:cint): cint;
  38. begin
  39. semget:=do_syscall(syscall_nr_semsys,1, key, nsems, semflg);
  40. end;
  41. Function semop(semid:cint; sops: psembuf; nsops: cuint): cint;
  42. begin
  43. semop:=do_syscall(syscall_nr_semsys,2, semid, TSysParam(sops), nsops, 0);
  44. end;
  45. Function semctl(semid:cint; semnum:cint; cmd:cint; var arg: tsemun): cint;
  46. begin
  47. semctl:=cint(do_syscall(syscall_nr_semsys, 0, semid, semnum, cmd,TSysParam(@arg)));
  48. end;
  49. Function msgget(key: TKey; msgflg:cint):cint;
  50. begin
  51. msgget:=do_syscall(syscall_nr_msgsys,1, key, msgflg);
  52. end;
  53. Function msgsnd(msqid:cint; msgp: PMSGBuf; msgsz: size_t; msgflg:cint): cint;
  54. begin
  55. msgsnd:=do_syscall(syscall_nr_msgsys,2, msqid, TSysParam(msgp), TSysParam(msgsz), msgflg);
  56. end;
  57. Function msgrcv(msqid:cint; msgp: PMSGBuf; msgsz: size_t; msgtyp:cint; msgflg:cint):cint;
  58. begin
  59. msgrcv:=(do_syscall(syscall_nr_msgsys,3, msqid, TSysParam(msgp), msgsz, msgtyp, msgflg));
  60. end;
  61. Function msgctl(msqid:cint; cmd: cint; buf: PMSQid_ds): cint;
  62. begin
  63. msgctl:= (do_syscall(syscall_nr_msgsys,0, msqid, cmd, tsysparam(buf)));
  64. end;
  65. {
  66. $Log$
  67. Revision 1.1 2004-04-25 19:15:43 marco
  68. * IPC reform
  69. }