ipcsys.inc 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. {
  2. This file is part of the Free Pascal run time library.
  3. Copyright (c) 2001 by Free Pascal development team
  4. Ipc body implemented using direct linux syscalls
  5. See the file COPYING.FPC, included in this distribution,
  6. for details about the copyright.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  10. ***********************************************************************}
  11. Function ftok (Path : pchar; ID : cint) : TKey;
  12. Var Info : TStat;
  13. begin
  14. If fpstat(path,info)<0 then
  15. ftok:=-1
  16. else
  17. begin
  18. ftok:= (info.st_ino and $FFFF) or ((info.st_dev and $ff) shl 16) or (byte(ID) shl 24)
  19. end;
  20. end;
  21. function shmget(key: Tkey; size:size_t; flag:cint):cint;
  22. begin
  23. shmget:=do_syscall (syscall_nr_SHMGET,TSysParam(key),TSysParam(size),TSysParam(flag));
  24. end;
  25. function shmat (shmid:cint; shmaddr:pointer; shmflg:cint): pointer;
  26. begin
  27. shmat:=pointer(do_syscall(syscall_nr_SHMAT,TSysParam(shmid),TSysParam(shmaddr),TSysParam(shmflg)));
  28. end;
  29. function shmdt (shmaddr:pointer): cint;
  30. begin
  31. shmdt:=do_syscall(syscall_nr_SHMDT,TSysParam(shmaddr));
  32. end;
  33. function shmctl(shmid:cint; cmd:cint; buf: pshmid_ds): cint;
  34. begin
  35. shmctl:=do_syscall(syscall_nr_SHMCTL,TSysParam(shmid),TSysParam(cmd),TSysParam(buf));
  36. end;
  37. function msgget(key:Tkey; msgflg:cint):cint;
  38. begin
  39. msgget:=do_syscall(syscall_nr_MSGGET,TSysParam(key),TSysParam(msgflg));
  40. end;
  41. function msgsnd(msqid:cint; msgp: pmsgbuf; msgsz: size_t; msgflg:cint):cint;
  42. begin
  43. msgsnd:=do_syscall(syscall_nr_MSGSND,TSysParam(msqid),TSysParam(msgsz),TSysParam(msgflg),TSysParam(msgp));
  44. end;
  45. function msgrcv(msqid:cint; msgp: PMSGBuf; msgsz: size_t; msgtyp:cint; msgflg:cint):cint;
  46. Type
  47. TIPC_Kludge = Record
  48. msgp : pmsgbuf;
  49. msgtyp : cint;
  50. end;
  51. Var
  52. tmp : TIPC_Kludge;
  53. begin
  54. tmp.msgp := msgp;
  55. tmp.msgtyp := msgtyp;
  56. msgrcv:=do_syscall(syscall_nr_MSGRCV,TSysParam(msqid),TSysParam(msgsz),TSysParam(msgflg),TSysParam(@tmp));
  57. end;
  58. Function msgctl(msqid:cint; cmd: cint; buf: PMSQid_ds): cint;
  59. begin
  60. msgctl:=do_syscall(syscall_nr_MSGCTL,TSysParam(msqid),TSysParam(cmd),TSysParam(buf));
  61. end;
  62. Function semget(key:Tkey; nsems:cint; semflg:cint): cint;
  63. begin
  64. semget:=do_syscall (syscall_nr_SEMGET,TSysParam(key),TSysParam(nsems),TSysParam(semflg));
  65. end;
  66. Function semop(semid:cint; sops: psembuf; nsops:cuint): cint;
  67. begin
  68. semop:=do_syscall (syscall_nr_SEMOP,TSysParam(semid),TSysParam(sops),TSysParam(nsops));
  69. end;
  70. Function semctl(semid:cint; semnum:cint; cmd:cint; var arg: tsemun): cint;
  71. begin
  72. semctl:=do_syscall(syscall_nr_SEMCTL,TSysParam(semid),TSysParam(semnum),TSysParam(cmd),TSysParam(@arg));
  73. end;