* use ctypes instead of defining own types

git-svn-id: trunk@5918 -
This commit is contained in:
florian 2007-01-12 10:56:29 +00:00
parent 7afbe22031
commit f7da932aa4
4 changed files with 39 additions and 44 deletions

View File

@ -14,24 +14,23 @@
**********************************************************************} **********************************************************************}
unit initc; unit initc;
interface interface
uses
ctypes;
{$i nwsys.inc} {$i nwsys.inc}
type libcint = longint; function fpgetCerrno:cint;
plibcint = ^libcint; procedure fpsetCerrno(err:cint);
function fpgetCerrno:libcint; property cerrno:cint read fpgetCerrno write fpsetcerrno;
procedure fpsetCerrno(err:libcint);
property cerrno:libcint read fpgetCerrno write fpsetcerrno;
implementation implementation
function fpgetCerrno:libcint; function fpgetCerrno:cint;
begin begin
fpgetCerrno:=__get_errno_ptr^; fpgetCerrno:=__get_errno_ptr^;
end; end;
procedure fpsetCerrno(err:libcint); procedure fpsetCerrno(err:cint);
begin begin
__get_errno_ptr^:=err; __get_errno_ptr^:=err;
end; end;

View File

@ -15,28 +15,27 @@
unit initc; unit initc;
interface interface
uses
ctypes;
type libcint = longint; function fpgetCerrno:cint;
plibcint = ^libcint; procedure fpsetCerrno(err:cint);
function fpgetCerrno:libcint; property cerrno:cint read fpgetCerrno write fpsetcerrno;
procedure fpsetCerrno(err:libcint);
property cerrno:libcint read fpgetCerrno write fpsetcerrno;
implementation implementation
const clib = 'libc'; const clib = 'libc';
function geterrnolocation: Plibcint; cdecl;external clib name '___errno'; function geterrnolocation: pcint; cdecl;external clib name '___errno';
function fpgetCerrno:libcint; function fpgetCerrno:cint;
begin begin
fpgetCerrno:=geterrnolocation^; fpgetCerrno:=geterrnolocation^;
end; end;
procedure fpsetCerrno(err:libcint); procedure fpsetCerrno(err:cint);
begin begin
geterrnolocation^:=err; geterrnolocation^:=err;
end; end;

View File

@ -15,15 +15,14 @@
**********************************************************************} **********************************************************************}
unit initc; unit initc;
interface interface
uses
ctypes;
{$linklib c} {$linklib c}
type libcint = longint; function fpgetCerrno:cint;
plibcint = ^libcint; procedure fpsetCerrno(err:cint);
function fpgetCerrno:libcint; property cerrno:cint read fpgetCerrno write fpsetcerrno;
procedure fpsetCerrno(err:libcint);
property cerrno:libcint read fpgetCerrno write fpsetcerrno;
const clib = 'c'; const clib = 'c';
@ -37,15 +36,15 @@ implementation
{$ifdef UseOldErrnoDirectLink} {$ifdef UseOldErrnoDirectLink}
Var Var
interrno : libcint;external name {$ifdef OpenBSD} '_errno' {$else} 'h_errno'{$endif}; interrno : cint;external name {$ifdef OpenBSD} '_errno' {$else} 'h_errno'{$endif};
function fpgetCerrno:libcint; function fpgetCerrno:cint;
begin begin
fpgetCerrno:=interrno; fpgetCerrno:=interrno;
end; end;
procedure fpsetCerrno(err:libcint); procedure fpsetCerrno(err:cint);
begin begin
interrno:=err; interrno:=err;
end; end;
@ -53,33 +52,33 @@ end;
{$ifdef Linux} {$ifdef Linux}
function geterrnolocation: Plibcint; cdecl;external clib name '__errno_location'; function geterrnolocation: pcint; cdecl;external clib name '__errno_location';
{$endif} {$endif}
{$ifdef FreeBSD} // tested on x86 {$ifdef FreeBSD} // tested on x86
function geterrnolocation: Plibcint; cdecl;external clib name '__error'; function geterrnolocation: pcint; cdecl;external clib name '__error';
{$endif} {$endif}
{$ifdef NetBSD} // from a sparc dump. {$ifdef NetBSD} // from a sparc dump.
function geterrnolocation: Plibcint; cdecl;external clib name '__errno'; function geterrnolocation: pcint; cdecl;external clib name '__errno';
{$endif} {$endif}
{$ifdef Darwin} {$ifdef Darwin}
function geterrnolocation: Plibcint; cdecl;external clib name '__error'; function geterrnolocation: pcint; cdecl;external clib name '__error';
{$endif} {$endif}
{$ifdef SunOS} {$ifdef SunOS}
function geterrnolocation: Plibcint; cdecl;external clib name '___errno'; function geterrnolocation: pcint; cdecl;external clib name '___errno';
{$endif} {$endif}
function fpgetCerrno:libcint; function fpgetCerrno:cint;
begin begin
fpgetCerrno:=geterrnolocation^; fpgetCerrno:=geterrnolocation^;
end; end;
procedure fpsetCerrno(err:libcint); procedure fpsetCerrno(err:cint);
begin begin
geterrnolocation^:=err; geterrnolocation^:=err;
end; end;

View File

@ -14,27 +14,25 @@
unit initc; unit initc;
interface interface
uses
ctypes;
type function fpgetCerrno:cint;
libcint = longint; procedure fpsetCerrno(err:cint);
plibcint = ^libcint;
function fpgetCerrno:libcint; property cerrno:cint read fpgetCerrno write fpsetcerrno;
procedure fpsetCerrno(err:libcint);
property cerrno:libcint read fpgetCerrno write fpsetcerrno;
implementation implementation
function geterrnolocation: Plibcint; cdecl;external 'cygwin1.dll' name '__errno'; function geterrnolocation: pcint; cdecl;external 'cygwin1.dll' name '__errno';
function fpgetCerrno:libcint; function fpgetCerrno:cint;
begin begin
fpgetCerrno:=geterrnolocation^; fpgetCerrno:=geterrnolocation^;
end; end;
procedure fpsetCerrno(err:libcint); procedure fpsetCerrno(err:cint);
begin begin
geterrnolocation^:=err; geterrnolocation^:=err;
end; end;