unxsysc.inc 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. {
  2. $Id$
  3. This file is part of the Free Pascal run time library.
  4. Copyright (c) 2003 Marco van de Voort
  5. member of the Free Pascal development team.
  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 fpNice(N:cint):cint;
  13. {
  14. Set process priority. A positive N means a lower priority.
  15. A negative N decreases priority.
  16. Doesn't exist in BSD. Linux emu uses setpriority in a construct as below:
  17. }
  18. begin
  19. fpNice:=fpSetPriority(Prio_Process,0,N);
  20. end;
  21. Function fpGetPriority(Which,Who:cint):cint;
  22. {
  23. Get Priority of process, process group, or user.
  24. Which : selects what kind of priority is used.
  25. can be one of the following predefined Constants :
  26. Prio_User.
  27. Prio_PGrp.
  28. Prio_Process.
  29. Who : depending on which, this is , respectively :
  30. Uid
  31. Pid
  32. Process Group id
  33. Errors are reported in linuxerror _only_. (priority can be negative)
  34. }
  35. begin
  36. if (which<prio_process) or (which>prio_user) then
  37. begin
  38. { We can save an interrupt here }
  39. fpgetpriority:=0;
  40. fpseterrno(ESysEinval);
  41. end
  42. else
  43. begin
  44. fpGetPriority:=do_syscall(syscall_nr_GetPriority,which,who);
  45. end;
  46. end;
  47. Function fpSetPriority(Which,Who,What:cint):cint;
  48. {
  49. Set Priority of process, process group, or user.
  50. Which : selects what kind of priority is used.
  51. can be one of the following predefined Constants :
  52. Prio_User.
  53. Prio_PGrp.
  54. Prio_Process.
  55. Who : depending on value of which, this is, respectively :
  56. Uid
  57. Pid
  58. Process Group id
  59. what : A number between -20 and 20. -20 is most favorable, 20 least.
  60. 0 is the default.
  61. }
  62. begin
  63. if ((which<prio_process) or (which>prio_user)) or ((what<-20) or (what>20)) then
  64. fpseterrno(ESyseinval) { We can save an interrupt here }
  65. else
  66. begin
  67. fpSetPriority:=do_syscall(Syscall_nr_Setpriority,which,who,what);
  68. end;
  69. end;
  70. Function fpLstat(path:pchar;Info:pstat):cint;
  71. {
  72. Get all information on a link (the link itself), and return it in info.
  73. }
  74. begin
  75. fpLStat:=do_syscall(syscall_nr_lstat,TSysParam(path),TSysParam(info));
  76. end;
  77. Function fpLstat(Filename: PathStr;Info:pstat):cint;
  78. {
  79. Get all information on a link (the link itself), and return it in info.
  80. }
  81. begin
  82. FileName:=FileName+#0;
  83. fpLStat:=do_syscall(syscall_nr_lstat,TSysParam(@filename[1]),TSysParam(info));
  84. end;
  85. Function fpSymlink(oldname,newname:pchar):cint;
  86. {
  87. We need this for erase
  88. }
  89. begin
  90. fpsymlink:=do_syscall(syscall_nr_symlink,TSysParam(oldname),TSysParam(newname));
  91. end;
  92. Function fpReadLink(name,linkname:pchar;maxlen:cint):cint;
  93. begin
  94. fpreadlink:=do_syscall(syscall_nr_readlink, TSysParam(name),TSysParam(linkname),maxlen);
  95. end;
  96. {
  97. $Log$
  98. Revision 1.4 2004-01-01 17:07:21 marco
  99. * few small freebsd fixes backported from debugging linux
  100. }