bunxsysc.inc 18 KB

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