diff --git a/.gitattributes b/.gitattributes index 849b0741c9..dc5c8aef2e 100644 --- a/.gitattributes +++ b/.gitattributes @@ -5445,6 +5445,7 @@ rtl/unix/ipc.pp svneol=native#text/plain rtl/unix/ipccdecl.inc svneol=native#text/plain rtl/unix/keyboard.pp svneol=native#text/plain rtl/unix/mouse.pp svneol=native#text/plain +rtl/unix/oscdecl.inc svneol=native#text/plain rtl/unix/oscdeclh.inc svneol=native#text/plain rtl/unix/ports.pp svneol=native#text/plain rtl/unix/printer.pp svneol=native#text/plain diff --git a/rtl/beos/sysos.inc b/rtl/beos/sysos.inc index becac71528..afb18f962c 100644 --- a/rtl/beos/sysos.inc +++ b/rtl/beos/sysos.inc @@ -65,6 +65,7 @@ end; {$ifdef FPC_USE_LIBC} {$Linklib c} {$i oscdeclh.inc} + {$i oscdecl.inc} {$else} {$I syscallh.inc} {$I syscall.inc} diff --git a/rtl/bsd/sysos.inc b/rtl/bsd/sysos.inc index ea72ae67fe..5a1dd61666 100644 --- a/rtl/bsd/sysos.inc +++ b/rtl/bsd/sysos.inc @@ -84,6 +84,7 @@ end; {$ifdef FPC_USE_LIBC} {$Linklib c} {$i oscdeclh.inc} + {$i oscdecl.inc} {$else} {$I syscallh.inc} {$I syscall.inc} diff --git a/rtl/linux/sysos.inc b/rtl/linux/sysos.inc index 063aa6d122..9402ad885d 100644 --- a/rtl/linux/sysos.inc +++ b/rtl/linux/sysos.inc @@ -61,6 +61,7 @@ end; {$ifdef FPC_USE_LIBC} {$Linklib c} {$i oscdeclh.inc} + {$i oscdecl.inc} {$else} {$I syscallh.inc} {$I syscall.inc} diff --git a/rtl/solaris/sysos.inc b/rtl/solaris/sysos.inc index d95f4d6963..d4b17b126c 100644 --- a/rtl/solaris/sysos.inc +++ b/rtl/solaris/sysos.inc @@ -40,6 +40,7 @@ end; {$Linklib c} {$i oscdeclh.inc} +{$i oscdecl.inc} {***************************************************************************** Error conversion diff --git a/rtl/unix/baseunix.pp b/rtl/unix/baseunix.pp index d7bb5b6240..f306662980 100644 --- a/rtl/unix/baseunix.pp +++ b/rtl/unix/baseunix.pp @@ -76,7 +76,9 @@ Uses Sysctl; {$I gensigset.inc} // general sigset funcs implementation. {$I genfdset.inc} // general fdset funcs. -{$ifndef FPC_USE_LIBC} +{$ifdef FPC_USE_LIBC} + {$i oscdecl.inc} // implementation of wrappers in oscdeclh.inc +{$else} {$i syscallh.inc} // do_syscall declarations themselves {$i sysnr.inc} // syscall numbers. {$i bsyscall.inc} // cpu specific syscalls diff --git a/rtl/unix/oscdecl.inc b/rtl/unix/oscdecl.inc new file mode 100644 index 0000000000..58b7273016 --- /dev/null +++ b/rtl/unix/oscdecl.inc @@ -0,0 +1,27 @@ +{ + This file is part of the Free Pascal run time library. + Copyright (c) 2007 by the Free Pascal development team + + This file should become an alternative to the syscalls in due time, + to import the base calls from libc. + Be very careful though. Kernel types and libc types are often not the + same on Linux. + + See the file COPYING.FPC, included in this distribution, + for details about the copyright. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + + ***********************************************************************} + +{$if defined(bsd) or defined(solaris)} +function real_FpIOCtl (Handle:cint;Ndx: TIOCtlRequest):cint; cdecl; varargs; external clib name 'ioctl'; + +function FpIOCtl (Handle:cint;Ndx: TIOCtlRequest;Data: Pointer):cint; +begin + FpIOCtl:=real_FpIOCtl(Handle, Ndx, Data); +end; +{$endif bsd or solaris} + diff --git a/rtl/unix/oscdeclh.inc b/rtl/unix/oscdeclh.inc index f8756ade56..0860683bec 100644 --- a/rtl/unix/oscdeclh.inc +++ b/rtl/unix/oscdeclh.inc @@ -1,6 +1,6 @@ { This file is part of the Free Pascal run time library. - Copyright (c) 2001 by Free Pascal development team + Copyright (c) 2001 by the Free Pascal development team This file should become an alternative to the syscalls in due time, to import the base calls from libc. @@ -74,7 +74,14 @@ const procedure FpExit (status : cint); cdecl; external clib name '_exit'; function fpmmap (addr:pointer;len:size_t;prot:cint;flags:cint;fd:cint;ofs:off_t):pointer; cdecl; external clib name 'mmap'+suffix64bit; function fpmunmap (addr:pointer;len:size_t):cint; cdecl; external clib name 'munmap'; +{$if defined(bsd) or defined(solaris)} + { The BSD/Solaris version has "..." as third parameter -> wrap for } + { interface compatibility with Linux } + function FpIOCtl (Handle:cint;Ndx: TIOCtlRequest;Data: Pointer):cint; + {$ifdef FPC_IS_SYSTEM}forward;{$endif} +{$else bsd or solaris} function FpIOCtl (Handle:cint;Ndx: TIOCtlRequest;Data: Pointer):cint; cdecl; external clib name 'ioctl'; +{$endif bsd or solaris} {$ifdef beos} Function FPSelect (N:cint;readfds,writefds,exceptfds:pfdSet;TimeOut:PTimeVal):cint; cdecl; external 'net' name 'select'; {$else}