Procházet zdrojové kódy

* fixed ioctl for non-linux: the third parameter is "..." there rather
than a pointer. The interface still accepts a plain pointer for
backwards compatibility.

git-svn-id: trunk@9176 -

Jonas Maebe před 17 roky
rodič
revize
f60c72b773

+ 1 - 0
.gitattributes

@@ -5445,6 +5445,7 @@ rtl/unix/ipc.pp svneol=native#text/plain
 rtl/unix/ipccdecl.inc svneol=native#text/plain
 rtl/unix/ipccdecl.inc svneol=native#text/plain
 rtl/unix/keyboard.pp svneol=native#text/plain
 rtl/unix/keyboard.pp svneol=native#text/plain
 rtl/unix/mouse.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/oscdeclh.inc svneol=native#text/plain
 rtl/unix/ports.pp svneol=native#text/plain
 rtl/unix/ports.pp svneol=native#text/plain
 rtl/unix/printer.pp svneol=native#text/plain
 rtl/unix/printer.pp svneol=native#text/plain

+ 1 - 0
rtl/beos/sysos.inc

@@ -65,6 +65,7 @@ end;
 {$ifdef FPC_USE_LIBC}
 {$ifdef FPC_USE_LIBC}
   {$Linklib c}
   {$Linklib c}
   {$i oscdeclh.inc}
   {$i oscdeclh.inc}
+  {$i oscdecl.inc}
 {$else}
 {$else}
   {$I syscallh.inc}
   {$I syscallh.inc}
   {$I syscall.inc}
   {$I syscall.inc}

+ 1 - 0
rtl/bsd/sysos.inc

@@ -84,6 +84,7 @@ end;
 {$ifdef FPC_USE_LIBC}
 {$ifdef FPC_USE_LIBC}
   {$Linklib c}
   {$Linklib c}
   {$i oscdeclh.inc}
   {$i oscdeclh.inc}
+  {$i oscdecl.inc}
 {$else}
 {$else}
   {$I syscallh.inc}
   {$I syscallh.inc}
   {$I syscall.inc}
   {$I syscall.inc}

+ 1 - 0
rtl/linux/sysos.inc

@@ -61,6 +61,7 @@ end;
 {$ifdef FPC_USE_LIBC}
 {$ifdef FPC_USE_LIBC}
   {$Linklib c}
   {$Linklib c}
   {$i oscdeclh.inc}
   {$i oscdeclh.inc}
+  {$i oscdecl.inc}
 {$else}
 {$else}
   {$I syscallh.inc}
   {$I syscallh.inc}
   {$I syscall.inc}
   {$I syscall.inc}

+ 1 - 0
rtl/solaris/sysos.inc

@@ -40,6 +40,7 @@ end;
 
 
 {$Linklib c}
 {$Linklib c}
 {$i oscdeclh.inc}
 {$i oscdeclh.inc}
+{$i oscdecl.inc}
 
 
 {*****************************************************************************
 {*****************************************************************************
                             Error conversion
                             Error conversion

+ 3 - 1
rtl/unix/baseunix.pp

@@ -76,7 +76,9 @@ Uses Sysctl;
 {$I gensigset.inc}     // general sigset funcs implementation.
 {$I gensigset.inc}     // general sigset funcs implementation.
 {$I genfdset.inc}      // general fdset funcs.
 {$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 syscallh.inc}       // do_syscall declarations themselves
   {$i sysnr.inc}          // syscall numbers.
   {$i sysnr.inc}          // syscall numbers.
   {$i bsyscall.inc}       // cpu specific syscalls
   {$i bsyscall.inc}       // cpu specific syscalls

+ 27 - 0
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}
+

+ 8 - 1
rtl/unix/oscdeclh.inc

@@ -1,6 +1,6 @@
 {
 {
     This file is part of the Free Pascal run time library.
     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,
     This file should become an alternative to the syscalls in due time,
     to import the base calls from libc.
     to import the base calls from libc.
@@ -74,7 +74,14 @@ const
     procedure FpExit    (status : cint); cdecl; external clib name '_exit';
     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  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';
     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';
     function  FpIOCtl   (Handle:cint;Ndx: TIOCtlRequest;Data: Pointer):cint; cdecl; external clib name 'ioctl';
+{$endif bsd or solaris}
 {$ifdef beos}
 {$ifdef beos}
     Function  FPSelect  (N:cint;readfds,writefds,exceptfds:pfdSet;TimeOut:PTimeVal):cint; cdecl; external 'net' name 'select';
     Function  FPSelect  (N:cint;readfds,writefds,exceptfds:pfdSet;TimeOut:PTimeVal):cint; cdecl; external 'net' name 'select';
 {$else}
 {$else}