ipcsys.inc 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. {
  2. $Id$
  3. This file is part of the Free Pascal run time library.
  4. Copyright (c) 2001 by Free Pascal development team
  5. Ipc body implemented using direct linux syscalls
  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) : TKey;
  13. Var Info : TStat;
  14. begin
  15. If fpstat(path,info)<0 then
  16. ftok:=-1
  17. else
  18. begin
  19. ftok:= (info.st_ino and $FFFF) or ((info.st_dev and $ff) shl 16) or (byte(ID) shl 24)
  20. end;
  21. end;
  22. function shmget(key: Tkey; size:cint; flag:cint):cint;
  23. begin
  24. shmget:=do_syscall (syscall_nr_SHMGET,TSysParam(key),TSysParam(size),TSysParam(flag),TSysParam(0));
  25. end;
  26. function shmat (shmid:cint; shmaddr:pointer; shmflg:cint): pointer;
  27. Var raddr : pointer;
  28. error : ptrint;
  29. begin
  30. error:=do_syscall(syscall_nr_SHMAT,TSysParam(shmid),TSysParam(shmflg),TSysParam(@raddr),TSysParam(shmaddr));
  31. If Error<0 then
  32. shmat:=pointer(error)
  33. else
  34. shmat:=raddr;
  35. end;
  36. function shmdt (shmaddr:pointer): cint;
  37. begin
  38. shmdt:=do_syscall(syscall_nr_SHMDT,TSysParam(0),TSysParam(0),TSysParam(0),TSysParam(shmaddr));
  39. end;
  40. function shmctl(shmid:cint; cmd:cint; buf: pshmid_ds): cint;
  41. begin
  42. shmctl:=do_syscall(syscall_nr_SHMCTL,TSysParam(shmid),TSysParam(cmd),TSysParam(0),TSysParam(buf));
  43. end;
  44. function msgget(key:Tkey; msgflg:cint):cint;
  45. begin
  46. msgget:=do_syscall(syscall_nr_MSGGET,TSysParam(key),TSysParam(msgflg),TSysParam(0),TSysParam(0));
  47. end;
  48. function msgsnd(msqid:cint; msgp: pmsgbuf; msgsz: size_t; msgflg:cint):cint;
  49. begin
  50. msgsnd:=do_syscall(syscall_nr_MSGSND,TSysParam(msqid),TSysParam(msgsz),TSysParam(msgflg),TSysParam(msgp));
  51. end;
  52. function msgrcv(msqid:cint; msgp: PMSGBuf; msgsz: size_t; msgtyp:cint; msgflg:cint):cint;
  53. Type
  54. TIPC_Kludge = Record
  55. msgp : pmsgbuf;
  56. msgtyp : cint;
  57. end;
  58. Var
  59. tmp : TIPC_Kludge;
  60. begin
  61. tmp.msgp := msgp;
  62. tmp.msgtyp := msgtyp;
  63. msgrcv:=do_syscall(syscall_nr_MSGRCV,TSysParam(msqid),TSysParam(msgsz),TSysParam(msgflg),TSysParam(@tmp));
  64. end;
  65. Function msgctl(msqid:cint; cmd: cint; buf: PMSQid_ds): cint;
  66. begin
  67. msgctl:=do_syscall(syscall_nr_MSGCTL,TSysParam(msqid),TSysParam(cmd),TSysParam(0),TSysParam(buf));
  68. end;
  69. Function semget(key:Tkey; nsems:cint; semflg:cint): cint;
  70. begin
  71. semget:=do_syscall (syscall_nr_SEMGET,TSysParam(key),TSysParam(nsems),TSysParam(semflg),TSysParam(0));
  72. end;
  73. Function semop(semid:cint; sops: psembuf; nsops:cuint): cint;
  74. begin
  75. semop:=do_syscall (syscall_nr_SEMOP,TSysParam(semid),TSysParam(nsops),TSysParam(0),TSysParam(sops));
  76. end;
  77. Function semctl(semid:cint; semnum:cint; cmd:cint; var arg: tsemun): cint;
  78. begin
  79. semctl:=do_syscall(syscall_nr_SEMCTL,TSysParam(semid),TSysParam(semnum),TSysParam(cmd),TSysParam(@arg));
  80. end;
  81. {
  82. $Log$
  83. Revision 1.2 2004-04-28 20:48:20 peter
  84. * ordinal-pointer conversions fixed
  85. Revision 1.1 2004/04/25 19:15:43 marco
  86. * IPC reform
  87. }