bunxsysc.inc 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671
  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 baseunix 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,TSysParam(pid),TSysParam(sig));
  24. // if kill<0 THEN
  25. // Kill:=0;
  26. end;
  27. Function fpSigPending(var nset: TSigSet):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_rt_sigpending,TSysParam(@nset));
  34. end;
  35. function fpsigsuspend(const sigmask:TSigSet):cint;
  36. {
  37. Set the signal mask with Mask, and suspend the program until a signal
  38. is received.
  39. }
  40. begin
  41. fpsigsuspend:= do_syscall(syscall_nr_rt_sigsuspend,TSysParam(@sigmask),TSysParam(8));
  42. end;
  43. function fpsigtimedwait(const sigset:TSigSet;info:Psiginfo;timeout:Ptimespec):cint;
  44. begin
  45. {Sizeof(Tsigset)=16 for Free Pascal, but the Linux kernel has a different idea,
  46. it wants a Tsigset of 8 bytes. So we have to hardcode :( }
  47. FpSigTimedWait:=do_syscall(syscall_nr_rt_sigtimedwait,
  48. Tsysparam(@sigset),
  49. Tsysparam(info),
  50. Tsysparam(timeout),
  51. Tsysparam(8 {sizeof(Tsigset)}));
  52. end;
  53. Type
  54. ITimerVal= Record
  55. It_Interval,
  56. It_Value : TimeVal;
  57. end;
  58. Const ITimer_Real =0;
  59. ITimer_Virtual =1;
  60. ITimer_Prof =2;
  61. Function SetITimer(Which : Longint;Const value : ItimerVal; var VarOValue:ItimerVal):Longint;
  62. Begin
  63. SetItimer:=Do_Syscall(syscall_nr_setitimer,Which,TSysParam(@Value),TSysParam(@varovalue));
  64. End;
  65. Function GetITimer(Which : Longint;Var value : ItimerVal):Longint;
  66. Begin
  67. GetItimer:=Do_Syscall(syscall_nr_getItimer,Which,TSysParam(@value));
  68. End;
  69. Function fpalarm(Seconds: cuint):cuint;
  70. Var it,oitv : Itimerval;
  71. retval : cuint;
  72. Begin
  73. // register struct itimerval *itp = &it;
  74. it.it_interval.tv_sec:=0;
  75. it.it_interval.tv_usec:=0;
  76. it.it_value.tv_usec:=0;
  77. it.it_value.tv_sec:=seconds;
  78. If SetITimer(ITIMER_REAL,it,oitv)<0 Then
  79. Exit(0); // different from *BSD!
  80. retval:= oitv.it_value.tv_usec;
  81. if retval<>0 Then
  82. inc(retval);
  83. fpAlarm:=retval;
  84. End;
  85. // The following versions are for internal use _ONLY_
  86. // This because it works for the first 32 signals _ONLY_, but that
  87. // is enough since they are depreciated, and for legacy applications
  88. // anyway.
  89. function sigblock(mask:cuint):cint;
  90. var nset,oset: TSigSet;
  91. begin
  92. fpsigemptyset(nset);
  93. // fpsigaddset(nset,mask); needs _mask_
  94. nset[0]:=mask;
  95. sigblock:= fpsigprocmask(SIG_BLOCK,@nset,@oset); // SIG_BLOCK=1
  96. if sigblock=0 Then
  97. sigblock:=oset[0];
  98. end;
  99. function sigpause(sigmask:cint):cint;
  100. var nset: TSigSet;
  101. begin
  102. fpsigemptyset(nset);
  103. nset[0]:=sigmask;
  104. sigpause:= fpsigsuspend(nset);
  105. end;
  106. function fppause:cint;
  107. begin
  108. fppause:=sigpause(sigblock(cuint(0)));
  109. end;
  110. function fpsleep(seconds:cuint):cuint;
  111. {see comments in libc}
  112. var time_to_sleep,time_remaining : timespec;
  113. nset,oset : TSigSet;
  114. oerrno : cint;
  115. oact : sigactionrec;
  116. begin
  117. time_to_sleep.tv_sec := seconds;
  118. time_to_sleep.tv_nsec := 0;
  119. fpsigemptyset(nset);
  120. fpsigaddset (nset,SIGCHLD);
  121. if fpsigprocmask(SIG_BLOCK,@nset,@oset)=-1 Then
  122. exit(cuint(-1));
  123. if fpsigismember(oset,SIGCHLD)<>0 Then
  124. Begin
  125. fpsigemptyset(nset);
  126. fpsigaddset (nset,SIGCHLD);
  127. if fpsigaction(SIGCHLD,NIL,@oact)<0 Then
  128. begin
  129. oerrno:=fpgeterrno;
  130. fpsigprocmask(SIG_SETMASK,@oset,NIL);
  131. fpseterrno(oerrno);
  132. exit(cuint(-1));
  133. End;
  134. if oact.sa_handler=SigActionhandler(SIG_IGN) Then
  135. Begin
  136. fpsleep:=fpnanosleep(@time_to_sleep, @time_remaining);
  137. oerrno:=fpgeterrno;
  138. fpsigprocmask(SIG_SETMASK,@oset,NIL);
  139. fpseterrno(oerrno);
  140. End
  141. Else
  142. Begin
  143. fpsigprocmask(SIG_SETMASK,@oset,NIL);
  144. fpsleep:=fpnanosleep(@time_to_sleep, @time_remaining)
  145. End;
  146. end
  147. else
  148. fpsleep:=fpnanosleep(@time_to_sleep, @time_remaining);
  149. if fpsleep<>0 Then
  150. if time_remaining.tv_nsec>=500000000 Then
  151. inc(fpsleep);
  152. End;
  153. function fpuname(var name:utsname):cint; [public,alias:'FPC_SYSC_UNAME'];
  154. begin
  155. fpuname:=Do_Syscall(syscall_nr_uname,TSysParam(@name));
  156. end;
  157. Function fpGetDomainName(Name:PChar; NameLen:size_t):cint;
  158. Var
  159. srec : utsname;
  160. tsize : size_t;
  161. Begin
  162. if fpuname(srec)<0 Then
  163. exit(-1);
  164. tsize:=strlen(@srec.domain[0]);
  165. if tsize>(namelen-1) Then
  166. tsize:=namelen-1;
  167. move(srec.domain[0],name[0],tsize);
  168. name[namelen-1]:=#0;
  169. fpgetDomainName:=0;
  170. End;
  171. function fpGetHostName(Name:PChar; NameLen:size_t):cint;
  172. Var
  173. srec : utsname;
  174. tsize : size_t;
  175. begin
  176. if fpuname(srec)<0 Then
  177. exit(-1);
  178. tsize:=strlen(@srec.nodename[0]);
  179. if tsize>(namelen-1) Then
  180. tsize:=namelen-1;
  181. move(srec.nodename[0],name[0],tsize);
  182. name[namelen-1]:=#0;
  183. fpgethostName:=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_Wait4,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. {$if defined(generic_linux_syscalls)}
  236. fpgetpgrp:=do_syscall(syscall_nr_getpgid,0);
  237. {$else}
  238. fpgetpgrp:=do_syscall(syscall_nr_getpgrp);
  239. {$endif}
  240. end;
  241. function fpsetsid : pid_t;
  242. begin
  243. fpsetsid:=do_syscall(syscall_nr_setsid);
  244. end;
  245. function fpgetsid (pid:TPid): pid_t;
  246. begin
  247. fpgetsid:=do_syscall(syscall_nr_getsid,pid);
  248. end;
  249. Function fpumask(cmask:mode_t):mode_t;
  250. {
  251. Sets file creation mask to (Mask and 0777 (octal) ), and returns the
  252. previous value.
  253. }
  254. begin
  255. fpumask:=Do_syscall(syscall_nr_umask,cmask);
  256. end;
  257. Function fplink(existing:pchar;newone:pchar):cint;
  258. {
  259. Proceduces a hard link from new to old.
  260. In effect, new will be the same file as old.
  261. }
  262. begin
  263. {$if defined(generic_linux_syscalls)}
  264. fpLink:=Do_Syscall(syscall_nr_linkat,AT_FDCWD,TSysParam(existing),AT_FDCWD,TSysParam(newone),0);
  265. {$else}
  266. fpLink:=Do_Syscall(syscall_nr_link,TSysParam(existing),TSysParam(newone));
  267. {$endif}
  268. end;
  269. Function fpmkfifo(path:pchar;mode:mode_t):cint;
  270. begin
  271. {$if defined(generic_linux_syscalls)}
  272. fpmkfifo:=do_syscall(syscall_nr_mknodat,AT_FDCWD,TSysParam(path),TSysParam(mode or S_IFIFO),TSysParam(0));
  273. {$else}
  274. fpmkfifo:=do_syscall(syscall_nr_mknod,TSysParam(path),TSysParam(mode or S_IFIFO),TSysParam(0));
  275. {$endif}
  276. end;
  277. Function fpchmod(path:pchar;mode:mode_t):cint;
  278. begin
  279. {$if defined(generic_linux_syscalls)}
  280. fpchmod:=do_syscall(syscall_nr_fchmodat,AT_FDCWD,TSysParam(path),TSysParam(mode),0);
  281. {$else}
  282. fpchmod:=do_syscall(syscall_nr_chmod,TSysParam(path),TSysParam(mode));
  283. {$endif}
  284. end;
  285. Function fpchown(path:pchar;owner:uid_t;group:gid_t):cint;
  286. begin
  287. {$if defined(generic_linux_syscalls)}
  288. fpChOwn:=do_syscall(syscall_nr_fchownat,AT_FDCWD,TSysParam(path),TSysParam(owner),TSysParam(group),0);
  289. {$else}
  290. fpChOwn:=do_syscall(syscall_nr_chown,TSysParam(path),TSysParam(owner),TSysParam(group));
  291. {$endif}
  292. end;
  293. {$if defined(generic_linux_syscalls)}
  294. Function fpUtime(path:pchar;times:putimbuf):cint;
  295. var
  296. tsa: Array[0..1] of timespec;
  297. begin
  298. tsa[0].tv_sec := times^.actime;
  299. tsa[0].tv_nsec := 0;
  300. tsa[1].tv_sec := times^.modtime;
  301. tsa[1].tv_nsec := 0;
  302. fputime:=do_syscall(syscall_nr_utimensat,AT_FDCWD,TSysParam(path),
  303. TSysParam(@tsa),0);
  304. end;
  305. {$elseif not defined(NO_SYSCALL_UTIME)}
  306. Function fpUtime(path:pchar;times:putimbuf):cint;
  307. begin
  308. fputime:=do_syscall(syscall_nr_utime,TSysParam(path),TSysParam(times));
  309. end;
  310. {$else}
  311. Function fpUtime(path:pchar;times:putimbuf):cint;
  312. var
  313. tva: Array[0..1] of timeval;
  314. begin
  315. tva[0].tv_sec := times^.actime;
  316. tva[0].tv_usec := 0;
  317. tva[1].tv_sec := times^.modtime;
  318. tva[1].tv_usec := 0;
  319. fputime:=do_syscall(syscall_nr_utimes,TSysParam(path),TSysParam(@tva));
  320. end;
  321. {$endif}
  322. {$ifndef FPC_BASEUNIX_HAS_FPPIPE}
  323. Function fppipe(var fildes : tfildes):cint;
  324. begin
  325. {$if defined(generic_linux_syscalls)}
  326. fppipe:=do_syscall(syscall_nr_pipe2,TSysParam(@fildes),0);
  327. {$else}
  328. fppipe:=do_syscall(syscall_nr_pipe,TSysParam(@fildes));
  329. {$endif}
  330. end;
  331. {$endif FPC_BASEUNIX_HAS_FPPIPE}
  332. function fpfcntl(fildes:cint;Cmd:cint;Arg:cint):cint;
  333. begin
  334. fpfcntl:=do_syscall(syscall_nr_fcntl,fildes,cmd,arg);
  335. end;
  336. function fpfcntl(fildes:cint;Cmd:cint;var Arg:flock):cint;
  337. begin
  338. fpfcntl:=do_syscall(syscall_nr_fcntl,fildes,cmd,TSysParam(@arg));
  339. end;
  340. function fpfcntl(fildes:cint;Cmd:cint):cint;
  341. begin
  342. fpfcntl:=do_syscall(syscall_nr_fcntl,fildes,cmd);
  343. end;
  344. function fpexecve(path:pchar;argv:ppchar;envp:ppchar):cint;
  345. Begin
  346. fpexecve:=do_syscall(syscall_nr_Execve,TSysParam(path),TSysParam(argv),TSysParam(envp));
  347. End;
  348. function fpexecv(path:pchar;argv:ppchar):cint;
  349. Begin
  350. fpexecv:=do_syscall(syscall_nr_Execve,TSysParam(path),TSysParam(argv),TSysParam(envp));
  351. End;
  352. function fptimes(var buffer : tms):clock_t;
  353. begin
  354. fptimes:=Do_syscall(syscall_nr_times,TSysParam(@buffer));
  355. end;
  356. Function fpSelect(N:cint;readfds,writefds,exceptfds:pfdSet;TimeOut:PTimeVal):cint;
  357. {
  358. Select checks whether the file descriptor sets in readfs/writefs/exceptfs
  359. have changed.
  360. }
  361. {$if defined(generic_linux_syscalls) and not defined(NO_SYSCALL_PSELECT6)}
  362. var ts : timespec;
  363. pts : PTimeSpec;
  364. begin
  365. pts:=nil;
  366. if assigned(timeout) then
  367. begin
  368. pts:=@ts;
  369. ts.tv_sec := timeout^.tv_sec;
  370. ts.tv_nsec := timeout^.tv_usec * 1000;
  371. end;
  372. fpSelect:=do_syscall(syscall_nr_pselect6,n,
  373. tsysparam(readfds),tsysparam(writefds),
  374. tsysparam(exceptfds),tsysparam(pts),0);
  375. end;
  376. {$else}
  377. begin
  378. {$ifdef cpux86_64}
  379. {$define bunxfunc_fpselect_implemented}
  380. fpSelect:=do_syscall(syscall_nr_select,n,tsysparam(readfds),tsysparam(writefds),tsysparam(exceptfds),tsysparam(timeout));
  381. {$else}
  382. {$define bunxfunc_fpselect_implemented}
  383. fpSelect:=do_syscall(syscall_nr__newselect,n,tsysparam(readfds),tsysparam(writefds),tsysparam(exceptfds),tsysparam(timeout));
  384. {$endif}
  385. {$ifndef bunxfunc_fpselect_implemented}
  386. {$error Implement fpselect}
  387. {$endif bunxfunc_fpselect_implemented}
  388. end;
  389. {$endif}
  390. function fpPoll(fds: ppollfd; nfds: cuint; timeout: clong): cint;
  391. {$if defined(generic_linux_syscalls) and not defined(NO_SYSCALL_PPOLL)}
  392. var ts : timespec;
  393. begin
  394. if timeout<0 then
  395. fpPoll:=do_syscall(syscall_nr_ppoll,tsysparam(fds),tsysparam(nfds),0,0)
  396. else
  397. begin
  398. ts.tv_sec := timeout div 1000;
  399. ts.tv_nsec := (timeout mod 1000) * 1000000;
  400. fpPoll:=do_syscall(syscall_nr_ppoll,tsysparam(fds),tsysparam(nfds),
  401. tsysparam(@ts),0);
  402. end
  403. end;
  404. {$else}
  405. begin
  406. fpPoll:=do_syscall(syscall_nr_poll,tsysparam(fds),tsysparam(nfds),tsysparam(timeout));
  407. end;
  408. {$endif}
  409. Function fpLstat(path:pchar;Info:pstat):cint;
  410. {
  411. Get all information on a link (the link itself), and return it in info.
  412. }
  413. begin
  414. {$if defined(generic_linux_syscalls)}
  415. fpLStat:=do_syscall(syscall_nr_fstatat,AT_FDCWD,TSysParam(path),TSysParam(info),0)
  416. {$else}
  417. fpLStat:=do_syscall(
  418. {$ifdef cpu64}
  419. syscall_nr_lstat,
  420. {$else}
  421. syscall_nr_lstat64,
  422. {$endif}
  423. TSysParam(path),TSysParam(info));
  424. {$endif}
  425. end;
  426. function fpNice(N:cint):cint;
  427. {
  428. Set process priority. A positive N means a lower priority.
  429. A negative N increases priority.
  430. Doesn't exist in BSD. Linux emu uses setpriority in a construct as below:
  431. }
  432. {$if defined(generic_linux_syscalls) or defined(cpux86_64)}
  433. var
  434. oldprio : cint;
  435. {$endif}
  436. begin
  437. {$if defined(generic_linux_syscalls) or defined(cpux86_64)}
  438. oldprio:=fpGetPriority(Prio_Process,0);
  439. fpNice:=fpSetPriority(Prio_Process,0,oldprio+N);
  440. if fpNice=0 then
  441. fpNice:=fpGetPriority(Prio_Process,0);
  442. {$else}
  443. fpNice:=do_syscall(Syscall_nr_nice,N);
  444. {$endif}
  445. end;
  446. Function fpGetPriority(Which,Who:cint):cint;
  447. {
  448. Get Priority of process, process group, or user.
  449. Which : selects what kind of priority is used.
  450. can be one of the following predefined Constants :
  451. Prio_User.
  452. Prio_PGrp.
  453. Prio_Process.
  454. Who : depending on which, this is , respectively :
  455. Uid
  456. Pid
  457. Process Group id
  458. Errors are reported in linuxerror _only_. (priority can be negative)
  459. }
  460. begin
  461. if (which<prio_process) or (which>prio_user) then
  462. begin
  463. { We can save an interrupt here }
  464. fpgetpriority:=-1;
  465. fpsetErrno(ESysEinval);
  466. end
  467. else
  468. fpGetPriority:=do_syscall(syscall_nr_GetPriority,which,who);
  469. end;
  470. Function fpSetPriority(Which,Who,What:cint):cint;
  471. {
  472. Set Priority of process, process group, or user.
  473. Which : selects what kind of priority is used.
  474. can be one of the following predefined Constants :
  475. Prio_User.
  476. Prio_PGrp.
  477. Prio_Process.
  478. Who : depending on value of which, this is, respectively :
  479. Uid
  480. Pid
  481. Process Group id
  482. what : A number between -20 and 20. -20 is most favorable, 20 least.
  483. 0 is the default.
  484. }
  485. begin
  486. if ((which<prio_process) or (which>prio_user)) or ((what<-20) or (what>20)) then
  487. fpseterrno(ESyseinval) { We can save an interrupt here }
  488. else
  489. begin
  490. fpSetPriority:=do_syscall(Syscall_nr_Setpriority,which,who,what);
  491. end;
  492. end;
  493. Function fpSymlink(oldname,newname:pchar):cint;
  494. {
  495. We need this for erase
  496. }
  497. begin
  498. {$if defined(generic_linux_syscalls)}
  499. fpsymlink:=do_syscall(syscall_nr_symlinkat,TSysParam(oldname),AT_FDCWD,TSysParam(newname));
  500. {$else}
  501. fpsymlink:=do_syscall(syscall_nr_symlink,TSysParam(oldname),TSysParam(newname));
  502. {$endif}
  503. end;
  504. { this is used by the Fppread/Fppwrite below. for more information,
  505. check the syscall() Linux man page (KB) }
  506. {$if defined(FPC_ABI_EABI) or defined(CPUMIPS32) or defined(CPUMIPSEL32) or defined(CPUPOWERPC32)}
  507. {$define FPC_ALIGN_DUMMY}
  508. {$endif}
  509. function Fppread(fd: cint; buf: pchar; nbytes : size_t; offset:Toff): ssize_t; [public, alias : 'FPC_SYSC_PREAD'];
  510. begin
  511. {$ifdef CPU64}
  512. Fppread:=do_syscall(syscall_nr_pread64,Fd,TSysParam(buf),nbytes,TSysParam(OffSet));
  513. {$else}
  514. Fppread:=do_syscall(syscall_nr_pread64,Fd,TSysParam(buf),nbytes,
  515. {$ifdef FPC_ALIGN_DUMMY} 0, {$endif FPC_ALIGN_DUMMY} { align parameters as required with dummy }
  516. {$ifdef FPC_BIG_ENDIAN} hi(offset),lo(offset){$endif}
  517. {$ifdef FPC_LITTLE_ENDIAN} lo(offset),hi(offset){$endif}
  518. );
  519. {$endif}
  520. end;
  521. function Fppwrite(fd: cint;buf:pchar; nbytes : size_t; offset:Toff): ssize_t; [public, alias : 'FPC_SYSC_PWRITE'];
  522. begin
  523. {$ifdef CPU64}
  524. Fppwrite:=do_syscall(syscall_nr_pwrite64,Fd,TSysParam(buf),nbytes,TSysParam(OffSet));
  525. {$else}
  526. Fppwrite:=do_syscall(syscall_nr_pwrite64,Fd,TSysParam(buf),nbytes,
  527. {$ifdef FPC_ALIGN_DUMMY} 0, {$endif FPC_ALIGN_DUMMY} { align parameters as required with dummy }
  528. {$ifdef FPC_BIG_ENDIAN} hi(offset),lo(offset){$endif}
  529. {$ifdef FPC_LITTLE_ENDIAN} lo(offset),hi(offset){$endif}
  530. );
  531. {$endif}
  532. end;
  533. {$undef FPC_ALIGN_DUMMY}
  534. function Fpreadv(fd: cint; const iov : piovec; iovcnt : cint):ssize_t; [public, alias : 'FPC_SYSC_READV'];
  535. begin
  536. Fpreadv:=do_syscall(syscall_nr_readv,Fd,TSysParam(iov),iovcnt);
  537. end;
  538. function Fpwritev(fd: cint; const iov : piovec; iovcnt : cint):ssize_t; [public, alias : 'FPC_SYSC_WRITEV'];
  539. begin
  540. Fpwritev:=do_syscall(syscall_nr_writev,Fd,TSysParam(iov),iovcnt);
  541. end;