sysos.inc 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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. This file implements all the base types and limits required
  6. for a minimal POSIX compliant subset required to port the compiler
  7. to a new OS.
  8. See the file COPYING.FPC, included in this distribution,
  9. for details about the copyright.
  10. This program is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  13. **********************************************************************}
  14. const clib = 'c';
  15. type libcint=longint;
  16. plibcint=^libcint;
  17. function geterrnolocation: Plibcint; cdecl;external clib name'__errno_location';
  18. function geterrno:libcint; [public, alias: 'FPC_SYS_GETERRNO'];
  19. begin
  20. geterrno:=geterrnolocation^;
  21. end;
  22. procedure seterrno(err:libcint); [public, alias: 'FPC_SYS_SETERRNO'];
  23. begin
  24. geterrnolocation^:=err;
  25. end;
  26. { OS dependant parts }
  27. {$I errno.inc} // error numbers
  28. {$I ostypes.inc} // c-types, unix base types, unix base structures
  29. {$I osmacro.inc}
  30. {$Linklib c}
  31. {$i oscdeclh.inc}
  32. {*****************************************************************************
  33. Error conversion
  34. *****************************************************************************}
  35. Function PosixToRunError (PosixErrno : longint) : longint;
  36. {
  37. Convert ErrNo error to the correct Inoutres value
  38. }
  39. begin
  40. if PosixErrNo=0 then { Else it will go through all the cases }
  41. exit(0);
  42. case PosixErrNo of
  43. ESysENFILE,
  44. ESysEMFILE : Inoutres:=4;
  45. ESysENOENT : Inoutres:=2;
  46. ESysEBADF : Inoutres:=6;
  47. ESysENOMEM,
  48. ESysEFAULT : Inoutres:=217;
  49. ESysEINVAL : Inoutres:=218;
  50. ESysEPIPE,
  51. ESysEINTR,
  52. ESysEIO,
  53. ESysEAGAIN,
  54. ESysENOSPC : Inoutres:=101;
  55. ESysENAMETOOLONG : Inoutres := 3;
  56. ESysEROFS,
  57. ESysEEXIST,
  58. ESysENOTEMPTY,
  59. ESysEACCES : Inoutres:=5;
  60. ESysEISDIR : InOutRes:=5;
  61. else
  62. begin
  63. InOutRes := Integer(PosixErrno);
  64. end;
  65. end;
  66. PosixToRunError:=InOutRes;
  67. end;
  68. Function Errno2InoutRes : longint;
  69. begin
  70. Errno2InoutRes:=PosixToRunError(getErrno);
  71. InoutRes:=Errno2InoutRes;
  72. end;
  73. {*****************************************************************************
  74. Low Level File Routines
  75. *****************************************************************************}
  76. function do_isdevice(handle:longint):boolean;
  77. begin
  78. do_isdevice:= (handle=StdInputHandle) or
  79. (handle=StdOutputHandle) or
  80. (handle=StdErrorHandle);
  81. end;
  82. {
  83. $Log$
  84. Revision 1.2 2005-02-13 22:13:20 peter
  85. * get solaris back in shape
  86. Revision 1.1 2005/02/10 17:30:54 peter
  87. * renamed to solaris
  88. Revision 1.1 2005/02/07 22:17:26 peter
  89. * updated for 1.9.x unix rtl
  90. Revision 1.2 2005/02/06 13:06:20 peter
  91. * moved file and dir functions to sysfile/sysdir
  92. * win32 thread in systemunit
  93. Revision 1.1 2005/02/06 11:20:52 peter
  94. * threading in system unit
  95. * removed systhrds unit
  96. }