bunxsysc.inc 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654
  1. {
  2. This file is part of the Free Pascal run time library.
  3. Copyright (c) 2002 by Marco van de Voort
  4. Calls needed for the POSIX unit, but not for system.
  5. Some calls that can be used for both Linux and *BSD will be
  6. moved to a /unix/ includedfile later.
  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 FPKill(Pid:pid_t;Sig:cint):cint;
  14. {
  15. Send signal 'sig' to a process, or a group of processes.
  16. If Pid > 0 then the signal is sent to pid
  17. pid=-1 to all processes except process 1
  18. pid < -1 to process group -pid
  19. Return value is zero, except for case three, where the return value
  20. is the number of processes to which the signal was sent.
  21. }
  22. begin
  23. FPkill:=do_syscall(syscall_nr_kill,pid,sig);
  24. // if kill<0 THEN
  25. // Kill:=0;
  26. end;
  27. Function FPSigPending(var nset: sigset_t):cint;
  28. {
  29. Allows examination of pending signals. The signal mask of pending
  30. signals is set in SSet
  31. }
  32. begin
  33. FPsigpending:=do_syscall(syscall_nr_sigpending,TSysParam(@nset));
  34. end;
  35. function FPsigsuspend(const sigmask:sigset_t):cint;
  36. {
  37. Set the signal mask with Mask, and suspend the program until a signal
  38. is received.
  39. }
  40. begin
  41. {$ifdef OPENBSD}
  42. { OpenBSD sigsuspend syscall wants a simple int as arg }
  43. FPsigsuspend:= do_syscall(syscall_nr_sigsuspend,TSysParam(sigmask[0]));
  44. {$else}
  45. FPsigsuspend:= do_syscall(syscall_nr_sigsuspend,TSysParam(@sigmask));
  46. {$endif}
  47. end;
  48. {$ifndef FPC_SYS_SIGTIMEDWAIT_UNAVAILABLE}
  49. function fpsigtimedwait(const sigset:TSigSet;info:Psiginfo;timeout:Ptimespec):cint;
  50. begin
  51. FpSigTimedWait:=do_syscall(syscall_nr_sigtimedwait,
  52. Tsysparam(@sigset),
  53. Tsysparam(info),
  54. Tsysparam(timeout));
  55. end;
  56. {$endif ndef FPC_SYS_SIGTIMEDWAIT_UNAVAILABLE}
  57. Type // implementation side for now. Should move to BSD unit.
  58. ITimerVal= Record
  59. It_Interval,
  60. It_Value : TimeVal;
  61. end;
  62. Const ITimer_Real =0;
  63. ITimer_Virtual =1;
  64. ITimer_Prof =2;
  65. Function SetITimer(Which : Longint;Const value : ItimerVal; var VarOValue:ItimerVal):Longint;
  66. Begin
  67. SetItimer:=Do_Syscall(syscall_nr_setitimer,Which,TSysParam(@Value),TSysParam(@varovalue));
  68. End;
  69. Function GetITimer(Which : Longint;Var value : ItimerVal):Longint;
  70. Begin
  71. GetItimer:=Do_Syscall(syscall_nr_getItimer,Which,TSysParam(@value));
  72. End;
  73. Function FPalarm(Seconds: cuint):cuint;
  74. Var it,oitv : Itimerval;
  75. Begin
  76. // register struct itimerval *itp = &it;
  77. it.it_interval.tv_sec:=0;
  78. it.it_interval.tv_usec:=0;
  79. it.it_value.tv_sec:=seconds;
  80. it.it_value.tv_usec:=0;
  81. If SetITimer(ITIMER_REAL,it,oitv)<0 Then
  82. Exit(cuint(-1));
  83. if oitv.it_value.tv_usec<>0 Then
  84. Inc(oitv.it_value.tv_sec);
  85. FPAlarm:=oitv.it_value.tv_sec;
  86. End;
  87. function sigblock(mask:cuint):cint;
  88. {Depreciated, but used by pause.}
  89. var nset,oset: sigset_t;
  90. begin
  91. FPsigemptyset(nset);
  92. nset[0]:=mask;
  93. sigblock:= FPsigprocmask(SIG_BLOCK,@nset,@oset); // SIG_BLOCK=1
  94. if sigblock=0 Then
  95. sigblock:=oset[0];
  96. end;
  97. function sigpause(sigmask:cint):cint;
  98. {Depreciated, but used by pause.}
  99. var nset: sigset_t;
  100. begin
  101. FPsigemptyset(nset);
  102. nset[0]:=sigmask;
  103. sigpause:= FPsigsuspend(nset);
  104. end;
  105. function FPpause:cint;
  106. begin
  107. FPpause:=sigpause(sigblock(cuint(0)));
  108. end;
  109. function FPsleep(seconds:cuint):cuint;
  110. var time_to_sleep,time_remaining : timespec;
  111. begin
  112. {
  113. * Avoid overflow when `seconds' is huge. This assumes that
  114. * the maximum value for a time_t is >= INT_MAX.
  115. }
  116. if seconds > high(cint) Then
  117. FPsleep:= (seconds - high(cint)) + FPsleep(HIGH(cint));
  118. time_to_sleep.tv_sec := seconds;
  119. time_to_sleep.tv_nsec := 0;
  120. if (FPnanosleep(@time_to_sleep, @time_remaining) <> -1) Then
  121. Exit(0);
  122. if (fpgeterrno <> ESysEINTR) Then // EAGAIN?
  123. Exit (seconds); { best guess }
  124. FPsleep:= time_remaining.tv_sec;
  125. if (time_remaining.tv_nsec <> 0) Then
  126. inc(FPsleep);
  127. End;
  128. function FPuname(var name:utsname):cint; [public,alias:'FPC_SYSC_UNAME'];
  129. Var
  130. mib : array[0..1] of cint;
  131. rval : cint;
  132. len : size_t;
  133. i : longint;
  134. oerrno : cint;
  135. procedure Doone(pz:PAnsiChar;pzsize:cint;val1,val2:cint);
  136. Begin
  137. mib[0] := val1;
  138. mib[1] := val2;
  139. len := pzsize;
  140. oerrno := fpgeterrno;
  141. if (FPsysctl(@mib, 2, pz, @len, NIL, 0) = -1) Then
  142. Begin
  143. if (fpgeterrno = ESysENOMEM) Then
  144. fpseterrno(oerrno)
  145. else
  146. rval := -1;
  147. End;
  148. pz[pzsize- 1] := #0;
  149. End;
  150. Begin
  151. rval := 0;
  152. DoOne(@name.sysname,sizeof(name.sysname),CTL_KERN,KERN_OSTYPE);
  153. DoOne(@name.nodename,sizeof(name.nodename),CTL_KERN,KERN_HOSTNAME);
  154. DoOne(@name.release,sizeof(name.release),CTL_KERN,KERN_OSRELEASE);
  155. { The version may have newlines in it, turn them into spaces. }
  156. DoOne(@name.version,sizeof(name.version),CTL_KERN,KERN_VERSION);
  157. For I:=0 to sizeof(name.sysname)-2 Do
  158. If (name.version[i]=#13) or (name.version[i]=#9) Then
  159. name.version[i]:=' ';
  160. DoOne(@name.machine,sizeof(name.machine),CTL_HW,HW_MACHINE);
  161. FPUname:=rval;
  162. end;
  163. function GetDomainName(Name:PAnsiChar; NameLen:Cint):cint; [public,alias:'FPC_SYSC_GETDOMAINNAME'];
  164. Const Mib_GetDomainName : array[0..1] of cint=(CTL_KERN,{$ifdef OpenBSD}KERN_DOMAINNAME{$ELSE}KERN_NISDOMAINNAME{$endif});
  165. VAR
  166. tsize : size_t;
  167. begin
  168. tsize := namelen;
  169. if (FPsysctl(@Mib_GetDomainname, 2, name, @tsize, NIL, 0) = -1) Then
  170. GetDomainName:=-1
  171. Else
  172. GetDomainName:=0;
  173. end;
  174. function GetHostName(Name:PAnsiChar; NameLen:Cint):cint;[public,alias:'FPC_SYSC_GETHOSTNAME'];
  175. Const Mib_GetHostName : array[0..1] of cint=(CTL_KERN,KERN_HOSTNAME);
  176. Var
  177. tsize : size_t;
  178. begin
  179. tsize := namelen;
  180. if (FPsysctl(@Mib_GetHostName, 2, name, @tsize, NIL, 0) = -1) Then
  181. GetHostName:=-1
  182. Else
  183. GetHostName:=0;
  184. End;
  185. const WAIT_ANY = -1;
  186. function FPwait(var stat_loc:cint): pid_t;
  187. {
  188. Waits until a child with PID Pid exits, or returns if it is exited already.
  189. Any resources used by the child are freed.
  190. The exit status is reported in the adress referred to by Status. It should
  191. be a longint.
  192. }
  193. begin // actually a wait4() call with 4th arg 0.
  194. FPWait:=do_syscall(syscall_nr_WaitPID,WAIT_ANY,TSysParam(@Stat_loc),0,0);
  195. end;
  196. //function FPgetpid : pid_t;
  197. // begin
  198. // FPgetpid:=do_syscall(syscall_nr_getpid);
  199. // end;
  200. function FPgetppid : pid_t;
  201. begin
  202. FPgetppid:=do_syscall(syscall_nr_getppid);
  203. end;
  204. function FPgetuid : uid_t;
  205. begin
  206. FPgetuid:=do_syscall(syscall_nr_getuid);
  207. end;
  208. function FPgeteuid : uid_t;
  209. begin
  210. FPgeteuid:=do_syscall(syscall_nr_geteuid);
  211. end;
  212. function FPgetgid : gid_t;
  213. begin
  214. FPgetgid:=do_syscall(syscall_nr_getgid);
  215. end;
  216. function FPgetegid : gid_t;
  217. begin
  218. FPgetegid:=do_syscall(syscall_nr_getegid);
  219. end;
  220. function FPsetuid(uid : uid_t): cint;
  221. begin
  222. FPsetuid:=do_syscall(syscall_nr_setuid,uid);
  223. end;
  224. function FPsetgid(gid : gid_t): cint;
  225. begin
  226. FPsetgid:=do_syscall(syscall_nr_setgid,gid);
  227. end;
  228. // type tgrparr=array[0..0] of gid_t;
  229. function FPgetgroups(gidsetsize : cint; var grouplist:tgrparr): cint;
  230. begin
  231. FPgetgroups:=do_syscall(syscall_nr_getgroups,gidsetsize,TSysParam(@grouplist));
  232. end;
  233. function FPgetpgrp : pid_t;
  234. begin
  235. FPgetpgrp:=do_syscall(syscall_nr_getpgrp);
  236. end;
  237. function FPsetsid : pid_t;
  238. begin
  239. FPsetsid:=do_syscall(syscall_nr_setsid);
  240. end;
  241. function fpgetsid (pid:TPid): pid_t;
  242. begin
  243. fpgetsid:=do_syscall(syscall_nr_getsid,TSysParam(pid));
  244. end;
  245. Function FPumask(cmask:mode_t):mode_t;
  246. {
  247. Sets file creation mask to (Mask and 0777 (octal) ), and returns the
  248. previous value.
  249. }
  250. begin
  251. FPumask:=Do_syscall(syscall_nr_umask,cmask);
  252. end;
  253. Function FPlink(existing:PAnsiChar;newone:PAnsiChar):cint;
  254. {
  255. Proceduces a hard link from new to old.
  256. In effect, new will be the same file as old.
  257. }
  258. begin
  259. FPLink:=Do_Syscall(syscall_nr_link,TSysParam(existing),TSysParam(newone));
  260. end;
  261. Function FPmkfifo(path:PAnsiChar;mode:mode_t):cint;
  262. begin
  263. FPmkfifo:=do_syscall(syscall_nr_mkfifo,TSysParam(path),TSysParam(mode));
  264. end;
  265. Function FPchmod(path:PAnsiChar;mode:mode_t):cint;
  266. begin
  267. FPchmod:=do_syscall(syscall_nr_chmod,TSysParam(path),TSysParam(mode));
  268. end;
  269. Function FPchown(path:PAnsiChar;owner:uid_t;group:gid_t):cint;
  270. begin
  271. FPChOwn:=do_syscall(syscall_nr_chown,TSysParam(path),TSysParam(owner),TSysParam(group));
  272. end;
  273. Function FPUtime(path:PAnsiChar;times:putimbuf):cint;
  274. var tv : array[0..1] of timeval;
  275. tvp : ^timeval;
  276. begin
  277. if times=nil Then
  278. tvp:=nil
  279. else
  280. begin
  281. tv[0].tv_sec :=times^.actime;
  282. tv[1].tv_sec :=times^.modtime;
  283. tv[0].tv_usec:=0;
  284. tv[1].tv_usec:=0;
  285. tvp:=@tv;
  286. end;
  287. FPutime:=do_syscall(syscall_nr_utimes,TSysParam(path),TSysParam(tvp));
  288. end;
  289. Function FpFutimens (handle: cint;constref times: TTimespecArr):cint;
  290. begin
  291. FpFutimens:=do_syscall(syscall_nr_futimens,TSysParam(handle),TSysParam(@times));
  292. end;
  293. {$if (defined (freebsd))}
  294. function FPpipe(var fildes : tfildes; flags:cint):cint;
  295. begin
  296. fppipe:=do_syscall(syscall_nr_pipe2,TSysParam(@fildes), TSysParam(flags));
  297. end;
  298. {$else}
  299. function __pipe_call(sysnr:TSysParam):TSysResult; {$ifdef cpui386}oldfpccall{$endif} external name 'FPC_DOSYS0';
  300. {$if defined (dragonfly) and (defined(CPUi386) or defined(CPUX86_64))}
  301. {$define PIPE_RESULT_IN_EAX_AND_EDX}
  302. {$endif}
  303. Function FPpipe(var fildes : tfildes):cint;
  304. {$ifndef PIPE_RESULT_IN_EAX_AND_EDX}
  305. begin
  306. fppipe:=do_syscall(syscall_nr_pipe,TSysParam(@fildes));
  307. end;
  308. {$else}
  309. var
  310. a, b: cInt;
  311. begin
  312. asm
  313. {$ifdef CPUi386}
  314. pushl syscall_nr_pipe
  315. call __pipe_call
  316. movl %eax, a
  317. movl %edx, b
  318. {$else}
  319. movq syscall_nr_pipe, %rdi
  320. call __pipe_call
  321. movl %eax, a
  322. movl %edx, b
  323. {$endif}
  324. end;
  325. fpPipe := a; // eax is in a, no matter if it worked or not
  326. fildes[0] := a;
  327. fildes[1] := b;
  328. end;
  329. {$endif}
  330. {$endif}
  331. function FPfcntl(fildes:cint;Cmd:cint;Arg:cint):cint;
  332. begin
  333. FPfcntl:=do_syscall(syscall_nr_fcntl,fildes,cmd,arg);
  334. end;
  335. function FPfcntl(fildes:cint;Cmd:cint;var Arg:flock):cint;
  336. begin
  337. FPfcntl:=do_syscall(syscall_nr_fcntl,fildes,cmd,TSysParam(@arg));
  338. end;
  339. function FPfcntl(fildes:cint;Cmd:cint):cint;
  340. begin
  341. FPfcntl:=do_syscall(syscall_nr_fcntl,fildes,cmd);
  342. end;
  343. function FPexecve(path:PAnsiChar;argv:PPAnsiChar;envp:PPAnsiChar):cint;
  344. Begin
  345. FPexecve:=do_syscall(syscall_nr_Execve,TSysParam(path),TSysParam(argv),TSysParam(envp));
  346. End;
  347. function FPexecv(path:PAnsiChar;argv:PPAnsiChar):cint;
  348. Begin
  349. FPexecv:=do_syscall(syscall_nr_Execve,TSysParam(path),TSysParam(argv),TSysParam(envp));
  350. End;
  351. CONST RUSAGE_SELF = 0;
  352. RUSAGE_CHILDREN = -1;
  353. function FPgetrusage(who:cint;var ru : rusage):cint;
  354. begin
  355. FPgetrusage:=do_syscall(syscall_nr_getrusage,longint(who),TSysParam(@ru));
  356. end;
  357. function FPtimes(var buffer : tms):clock_t;
  358. var ru : rusage;
  359. t : timeval;
  360. CONST CLK_TCK=128;
  361. function CONVTCK(r:timeval):clock_t;
  362. {
  363. * Convert usec to clock ticks; could do (usec * CLK_TCK) / 1000000,
  364. * but this would overflow if we switch to nanosec.
  365. }
  366. begin
  367. CONVTCK:=(r.tv_sec * CLK_TCK + r.tv_usec DIV (1000000 DIV CLK_TCK));
  368. end;
  369. begin
  370. if (FPgetrusage(RUSAGE_SELF, ru) < 0) Then
  371. exit(clock_t(-1));
  372. buffer.tms_utime := CONVTCK(ru.ru_utime);
  373. buffer.tms_stime := CONVTCK(ru.ru_stime);
  374. if (FPgetrusage(RUSAGE_CHILDREN, ru) < 0) Then
  375. exit(clock_t(-1));
  376. buffer.tms_cutime := CONVTCK(ru.ru_utime);
  377. buffer.tms_cstime := CONVTCK(ru.ru_stime);
  378. if do_syscall(syscall_nr_gettimeofday,TSysParam(@t),0)<>0 Then
  379. exit(clock_t(-1));
  380. FPtimes:=clock_t(CONVTCK(t));
  381. end;
  382. Function fpSelect(N:cint;readfds,writefds,exceptfds:pfdSet;TimeOut:PTimeVal):cint;
  383. {
  384. Select checks whether the file descriptor sets in readfs/writefs/exceptfs
  385. have changed.
  386. }
  387. begin
  388. fpSelect:=do_syscall(syscall_nr_select,n,TSysParam(readfds),TSysParam(writefds),TSysParam(exceptfds),TSysParam(timeout));
  389. end;
  390. function fpPoll(fds: ppollfd; nfds: cuint; timeout: clong): cint;
  391. begin
  392. fpPoll:=do_syscall(syscall_nr_poll,tsysparam(fds),tsysparam(nfds),tsysparam(timeout));
  393. end;
  394. Function fpLstat(path:PAnsiChar;Info:pstat):cint;
  395. {
  396. Get all information on a link (the link itself), and return it in info.
  397. }
  398. const
  399. AT_FDCWD=-100;
  400. AT_SYMLINK_NOFOLLOW=$0200;
  401. begin
  402. {$ifdef freebsd}
  403. fpLStat:=do_syscall(syscall_nr_fstatat,AT_FDCWD,TSysParam(path),TSysParam(Info),AT_SYMLINK_NOFOLLOW);
  404. {$else}
  405. fpLStat:=do_syscall(syscall_nr_lstat,TSysParam(path),TSysParam(info));
  406. {$endif}
  407. end;
  408. function fpNice(N:cint):cint;
  409. {
  410. Set process priority. A positive N means a lower priority.
  411. A negative N decreases priority.
  412. Doesn't exist in BSD. Linux emu uses setpriority in a construct as below:
  413. }
  414. var prio : cint;
  415. begin
  416. fpseterrno(0);
  417. prio:=fpgetpriority(PRIO_PROCESS,0);
  418. if (prio=-1) and (fpgeterrno<>0) then
  419. exit(-1);
  420. fpNice:=fpSetPriority(Prio_Process,0,prio+N);
  421. end;
  422. Function fpGetPriority(Which,Who:cint):cint;
  423. {
  424. Get Priority of process, process group, or user.
  425. Which : selects what kind of priority is used.
  426. can be one of the following predefined Constants :
  427. Prio_User.
  428. Prio_PGrp.
  429. Prio_Process.
  430. Who : depending on which, this is , respectively :
  431. Uid
  432. Pid
  433. Process Group id
  434. Errors are reported in linuxerror _only_. (priority can be negative)
  435. }
  436. begin
  437. if (which<prio_process) or (which>prio_user) then
  438. begin
  439. { We can save an interrupt here }
  440. fpgetpriority:=0;
  441. fpseterrno(ESysEinval);
  442. end
  443. else
  444. begin
  445. fpGetPriority:=do_syscall(syscall_nr_GetPriority,which,who);
  446. end;
  447. end;
  448. Function fpSetPriority(Which,Who,What:cint):cint;
  449. {
  450. Set Priority of process, process group, or user.
  451. Which : selects what kind of priority is used.
  452. can be one of the following predefined Constants :
  453. Prio_User.
  454. Prio_PGrp.
  455. Prio_Process.
  456. Who : depending on value of which, this is, respectively :
  457. Uid
  458. Pid
  459. Process Group id
  460. what : A number between -20 and 20. -20 is most favorable, 20 least.
  461. 0 is the default.
  462. }
  463. begin
  464. if ((which<prio_process) or (which>prio_user)) or ((what<-20) or (what>20)) then
  465. fpseterrno(ESyseinval) { We can save an interrupt here }
  466. else
  467. begin
  468. fpSetPriority:=do_syscall(Syscall_nr_Setpriority,which,who,what);
  469. end;
  470. end;
  471. Function fpSymlink(oldname,newname:PAnsiChar):cint;
  472. {
  473. We need this for erase
  474. }
  475. begin
  476. fpsymlink:=do_syscall(syscall_nr_symlink,TSysParam(oldname),TSysParam(newname));
  477. end;
  478. function Fppread(fd: cint; buf: PAnsiChar; nbytes : size_t; offset:Toff): ssize_t; [public, alias : 'FPC_SYSC_PREAD'];
  479. begin
  480. {$ifdef CPU64}
  481. Fppread:=do_syscall(syscall_nr_pread,Fd,TSysParam(buf),nbytes,TSysParam(OffSet));
  482. {$else}
  483. Fppread:=do_syscall(syscall_nr_pread,Fd,TSysParam(buf),nbytes,
  484. {$ifdef 64bitfs}
  485. {$ifdef FPC_BIG_ENDIAN} hi(offset),lo(offset){$endif}
  486. {$ifdef FPC_LITTLE_ENDIAN} lo(offset),hi(offset){$endif}
  487. {$else}
  488. {$ifdef FPC_BIG_ENDIAN} 0,lo(offset){$endif}
  489. {$ifdef FPC_LITTLE_ENDIAN} lo(offset),0{$endif}
  490. {$endif}
  491. );
  492. {$endif}
  493. end;
  494. function Fppwrite(fd: cint;buf:PAnsiChar; nbytes : size_t; offset:Toff): ssize_t; [public, alias : 'FPC_SYSC_PWRITE'];
  495. begin
  496. {$ifdef CPU64}
  497. Fppwrite:=do_syscall(syscall_nr_pwrite,Fd,TSysParam(buf),nbytes,TSysParam(OffSet));
  498. {$else}
  499. Fppwrite:=do_syscall(syscall_nr_pwrite,Fd,TSysParam(buf),nbytes,
  500. // ,0 = possible alignment here.
  501. {$ifdef 64bitfs}
  502. {$ifdef FPC_BIG_ENDIAN} hi(offset),lo(offset){$endif}
  503. {$ifdef FPC_LITTLE_ENDIAN} lo(offset),hi(offset){$endif}
  504. {$else}
  505. {$ifdef FPC_BIG_ENDIAN} 0,lo(offset){$endif}
  506. {$ifdef FPC_LITTLE_ENDIAN} lo(offset),0{$endif}
  507. {$endif}
  508. );
  509. {$endif}
  510. end;
  511. function Fpreadv(fd: cint; const iov : piovec; iovcnt : cint):ssize_t; [public, alias : 'FPC_SYSC_READV'];
  512. begin
  513. Fpreadv:=do_syscall(syscall_nr_readv,Fd,TSysParam(iov),iovcnt);
  514. end;
  515. function Fpwritev(fd: cint; const iov : piovec; iovcnt : cint):ssize_t; [public, alias : 'FPC_SYSC_WRITEV'];
  516. begin
  517. Fpwritev:=do_syscall(syscall_nr_writev,Fd,TSysParam(iov),iovcnt);
  518. end;