unxsysc.inc 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. {
  2. $Id$
  3. This file is part of the Free Pascal run time library.
  4. Copyright (c) 2001 by Free Pascal development team
  5. Some calls for the unix unit.
  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 increases priority.
  16. Doesn't exist in BSD. Linux emu uses setpriority in a construct as below:
  17. }
  18. {$ifdef cpux86_64}
  19. var
  20. oldprio : cint;
  21. {$endif}
  22. begin
  23. {$ifdef cpux86_64}
  24. oldprio:=fpGetPriority(Prio_Process,0);
  25. fpNice:=fpSetPriority(Prio_Process,0,oldprio+N);
  26. if fpNice=0 then
  27. fpNice:=fpGetPriority(Prio_Process,0);
  28. {$else}
  29. fpNice:=do_syscall(Syscall_nr_nice,N);
  30. {$endif}
  31. end;
  32. Function fpGetPriority(Which,Who:cint):cint;
  33. {
  34. Get Priority of process, process group, or user.
  35. Which : selects what kind of priority is used.
  36. can be one of the following predefined Constants :
  37. Prio_User.
  38. Prio_PGrp.
  39. Prio_Process.
  40. Who : depending on which, this is , respectively :
  41. Uid
  42. Pid
  43. Process Group id
  44. Errors are reported in linuxerror _only_. (priority can be negative)
  45. }
  46. begin
  47. if (which<prio_process) or (which>prio_user) then
  48. begin
  49. { We can save an interrupt here }
  50. fpgetpriority:=-1;
  51. fpsetErrno(ESysEinval);
  52. end
  53. else
  54. fpGetPriority:=do_syscall(syscall_nr_GetPriority,which,who);
  55. end;
  56. Function fpSetPriority(Which,Who,What:cint):cint;
  57. {
  58. Set Priority of process, process group, or user.
  59. Which : selects what kind of priority is used.
  60. can be one of the following predefined Constants :
  61. Prio_User.
  62. Prio_PGrp.
  63. Prio_Process.
  64. Who : depending on value of which, this is, respectively :
  65. Uid
  66. Pid
  67. Process Group id
  68. what : A number between -20 and 20. -20 is most favorable, 20 least.
  69. 0 is the default.
  70. }
  71. begin
  72. if ((which<prio_process) or (which>prio_user)) or ((what<-20) or (what>20)) then
  73. fpseterrno(ESyseinval) { We can save an interrupt here }
  74. else
  75. begin
  76. fpSetPriority:=do_syscall(Syscall_nr_Setpriority,which,who,what);
  77. end;
  78. end;
  79. Function fpLstat(path:pchar;Info:pstat):cint;
  80. {
  81. Get all information on a link (the link itself), and return it in info.
  82. }
  83. begin
  84. fpLStat:=do_syscall(syscall_nr_lstat,TSysParam(path),TSysParam(info));
  85. end;
  86. Function fpLstat(Filename: PathStr;Info:pstat):cint;
  87. {
  88. Get all information on a link (the link itself), and return it in info.
  89. }
  90. begin
  91. FileName:=FileName+#0;
  92. fpLStat:=do_syscall(syscall_nr_lstat,TSysParam(@filename[1]),TSysParam(info));
  93. end;
  94. Function fpSymlink(oldname,newname:pchar):cint;
  95. {
  96. We need this for erase
  97. }
  98. begin
  99. fpsymlink:=do_syscall(syscall_nr_symlink,TSysParam(oldname),TSysParam(newname));
  100. end;
  101. {
  102. $Log$
  103. Revision 1.5 2004-04-22 17:17:23 peter
  104. * x86-64 fixes
  105. Revision 1.4 2004/01/01 16:10:23 marco
  106. * fpreadlink(pathstr) moved to unxovl (since not platform specific),
  107. small fixes for "make all OPT='-dFPC_USE_LIBC'
  108. Revision 1.3 2003/11/13 13:11:55 marco
  109. * Linuxerror remove + hdr+log added
  110. }