ipcbsd.inc 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  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:PAnsiChar; 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. {$if defined(dragonfly) or defined(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. {$if defined(dragonfly) or defined(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. {$if defined(dragonfly) or defined(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. {$if defined(dragonfly)}
  47. shmctl:= do_syscall(syscall_nr_shmctl, shmid, cmd, TSysParam(buf));
  48. {$elseif defined(NetBSD)}
  49. shmctl:= do_syscall(syscall_nr___shmctl13, shmid, cmd, TSysParam(buf));
  50. {$else NetBSD}
  51. shmctl:= do_syscall(syscall_nr_shmsys,4, shmid, cmd, TSysParam(buf));
  52. {$endif NetBSD}
  53. end;
  54. Function semget(key:Tkey; nsems:cint; semflg:cint): cint;
  55. begin
  56. {$if defined(dragonfly) or defined(NetBSD)}
  57. semget:=do_syscall(syscall_nr_semget, key, nsems, semflg);
  58. {$else NetBSD}
  59. semget:=do_syscall(syscall_nr_semsys,1, key, nsems, semflg);
  60. {$endif NetBSD}
  61. end;
  62. Function semop(semid:cint; sops: psembuf; nsops: cuint): cint;
  63. begin
  64. {$if defined(dragonfly) or defined(NetBSD)}
  65. semop:=do_syscall(syscall_nr_semop, semid, TSysParam(sops), nsops, 0);
  66. {$else NetBSD}
  67. semop:=do_syscall(syscall_nr_semsys,2, semid, TSysParam(sops), nsops, 0);
  68. {$endif NetBSD}
  69. end;
  70. Function semctl(semid:cint; semnum:cint; cmd:cint; var arg: tsemun): cint;
  71. begin
  72. {$if defined(dragonfly)}
  73. semctl:=cint(do_syscall(syscall_nr___semctl, semid, semnum, cmd,TSysParam(@arg)));
  74. {$elseif defined(NetBSD)}
  75. semctl:=cint(do_syscall(syscall_nr_semconfig, semid, semnum, cmd,TSysParam(@arg)));
  76. {$else NetBSD}
  77. semctl:=cint(do_syscall(syscall_nr_semsys, 0, semid, semnum, cmd,TSysParam(@arg)));
  78. {$endif NetBSD}
  79. end;
  80. Function msgget(key: TKey; msgflg:cint):cint;
  81. begin
  82. {$if defined(dragonfly) or defined(NetBSD)}
  83. msgget:=do_syscall(syscall_nr_msgget, key, msgflg);
  84. {$else NetBSD}
  85. msgget:=do_syscall(syscall_nr_msgsys,1, key, msgflg);
  86. {$endif NetBSD}
  87. end;
  88. Function msgsnd(msqid:cint; msgp: PMSGBuf; msgsz: size_t; msgflg:cint): cint;
  89. begin
  90. {$if defined(dragonfly) or defined(NetBSD)}
  91. msgsnd:=do_syscall(syscall_nr_msgsnd, msqid, TSysParam(msgp), TSysParam(msgsz), msgflg);
  92. {$else NetBSD}
  93. msgsnd:=do_syscall(syscall_nr_msgsys,2, msqid, TSysParam(msgp), TSysParam(msgsz), msgflg);
  94. {$endif NetBSD}
  95. end;
  96. Function msgrcv(msqid:cint; msgp: PMSGBuf; msgsz: size_t; msgtyp:clong; msgflg:cint):cint;
  97. begin
  98. {$if defined(dragonfly) or defined(NetBSD)}
  99. msgrcv:=(do_syscall(syscall_nr_msgrcv, msqid, TSysParam(msgp), msgsz, msgtyp, msgflg));
  100. {$else NetBSD}
  101. msgrcv:=(do_syscall(syscall_nr_msgsys,3, msqid, TSysParam(msgp), msgsz, msgtyp, msgflg));
  102. {$endif NetBSD}
  103. end;
  104. Function msgctl(msqid:cint; cmd: cint; buf: PMSQid_ds): cint;
  105. begin
  106. {$if defined(dragonfly)}
  107. msgctl:= (do_syscall(syscall_nr_msgctl, msqid, cmd, tsysparam(buf)));
  108. {$elseif defined(NetBSD)}
  109. msgctl:= (do_syscall(syscall_nr___msgctl13, msqid, cmd, tsysparam(buf)));
  110. {$else NetBSD}
  111. msgctl:= (do_syscall(syscall_nr_msgsys,0, msqid, cmd, tsysparam(buf)));
  112. {$endif NetBSD}
  113. end;