initc.pp 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. {
  2. $Id$
  3. This file is part of the Free Pascal run time library.
  4. Copyright (c) 1999-2000 by Michael Van Canneyt and Peter Vreman,
  5. members of the Free Pascal development team
  6. This file links to libc, and handles the libc errno abstraction.
  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. unit initc;
  14. interface
  15. {$linklib c}
  16. type libcint = longint;
  17. plibcint = ^libcint;
  18. function fpgetCerrno:libcint;
  19. procedure fpsetCerrno(err:libcint);
  20. implementation
  21. {$ifdef useold}
  22. Var
  23. interrno : libcint;external name 'h_errno';
  24. function fpgetCerrno:libcint;
  25. begin
  26. fpgetCerrno:=interrno;
  27. end;
  28. procedure fpsetCerrno(err:libcint);
  29. begin
  30. interrno:=err;
  31. end;
  32. {$else}
  33. const clib = 'c';
  34. {$ifdef Linux}
  35. function geterrnolocation: Plibcint; cdecl;external clib name '__errno_location';
  36. {$else}
  37. {$ifdef FreeBSD}
  38. function geterrnolocation: Plibcint; cdecl;external clib name '__error';
  39. {$else}
  40. {$endif}
  41. {$endif}
  42. function fpgetCerrno:libcint;
  43. begin
  44. fpgetCerrno:=geterrnolocation^;
  45. end;
  46. procedure fpsetCerrno(err:libcint);
  47. begin
  48. geterrnolocation^:=err;
  49. end;
  50. {$endif}
  51. end.
  52. {
  53. $Log$
  54. Revision 1.4 2003-12-10 11:24:25 marco
  55. * get/setcerrno added
  56. Revision 1.3 2002/09/07 16:01:27 peter
  57. * old logs removed and tabs fixed
  58. }