unxsysc.inc 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  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. var prio : cint;
  19. begin
  20. fpseterrno(0);
  21. prio:=fpgetpriority(PRIO_PROCESS,0);
  22. if (prio=-1) and (fpgeterrno<>0) then
  23. exit(-1);
  24. fpNice:=fpSetPriority(Prio_Process,0,prio+N);
  25. end;
  26. Function fpGetPriority(Which,Who:cint):cint;
  27. {
  28. Get Priority of process, process group, or user.
  29. Which : selects what kind of priority is used.
  30. can be one of the following predefined Constants :
  31. Prio_User.
  32. Prio_PGrp.
  33. Prio_Process.
  34. Who : depending on which, this is , respectively :
  35. Uid
  36. Pid
  37. Process Group id
  38. Errors are reported in linuxerror _only_. (priority can be negative)
  39. }
  40. begin
  41. if (which<prio_process) or (which>prio_user) then
  42. begin
  43. { We can save an interrupt here }
  44. fpgetpriority:=0;
  45. fpseterrno(ESysEinval);
  46. end
  47. else
  48. begin
  49. fpGetPriority:=do_syscall(syscall_nr_GetPriority,which,who);
  50. end;
  51. end;
  52. Function fpSetPriority(Which,Who,What:cint):cint;
  53. {
  54. Set Priority of process, process group, or user.
  55. Which : selects what kind of priority is used.
  56. can be one of the following predefined Constants :
  57. Prio_User.
  58. Prio_PGrp.
  59. Prio_Process.
  60. Who : depending on value of which, this is, respectively :
  61. Uid
  62. Pid
  63. Process Group id
  64. what : A number between -20 and 20. -20 is most favorable, 20 least.
  65. 0 is the default.
  66. }
  67. begin
  68. if ((which<prio_process) or (which>prio_user)) or ((what<-20) or (what>20)) then
  69. fpseterrno(ESyseinval) { We can save an interrupt here }
  70. else
  71. begin
  72. fpSetPriority:=do_syscall(Syscall_nr_Setpriority,which,who,what);
  73. end;
  74. end;
  75. Function fpLstat(path:pchar;Info:pstat):cint;
  76. {
  77. Get all information on a link (the link itself), and return it in info.
  78. }
  79. begin
  80. fpLStat:=do_syscall(syscall_nr_lstat,TSysParam(path),TSysParam(info));
  81. end;
  82. Function fpLstat(Filename: ansistring;Info:pstat):cint;
  83. {
  84. Get all information on a link (the link itself), and return it in info.
  85. }
  86. begin
  87. fpLStat:=do_syscall(syscall_nr_lstat,TSysParam(pchar(filename)),TSysParam(info));
  88. end;
  89. Function fpSymlink(oldname,newname:pchar):cint;
  90. {
  91. We need this for erase
  92. }
  93. begin
  94. fpsymlink:=do_syscall(syscall_nr_symlink,TSysParam(oldname),TSysParam(newname));
  95. end;
  96. Function fpReadLink(name,linkname:pchar;maxlen:cint):cint;
  97. begin
  98. fpreadlink:=do_syscall(syscall_nr_readlink, TSysParam(name),TSysParam(linkname),maxlen);
  99. end;
  100. {
  101. $Log$
  102. Revision 1.7 2004-11-03 15:00:43 marco
  103. * Pathstr eliminated
  104. Revision 1.6 2004/07/03 22:48:49 marco
  105. * small fix for 1.0.x cycling
  106. Revision 1.5 2004/04/22 16:22:10 marco
  107. * fpnice fixes
  108. Revision 1.4 2004/01/01 17:07:21 marco
  109. * few small freebsd fixes backported from debugging linux
  110. }