delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2002/06/10/09:18:23

Date: Mon, 10 Jun 2002 13:31:14 +0100
From: "Richard Dawe" <rich AT phekda DOT freeserve DOT co DOT uk>
Sender: rich AT phekda DOT freeserve DOT co DOT uk
To: djgpp-workers AT delorie DOT com
X-Mailer: Emacs 21.3.50 (via feedmail 8.3.emacs20_6 I) and Blat ver 1.8.6
Subject: Patch for FSEXT hooks and gcc 3.1, mark 2
Message-Id: <E17HOED-0000jv-00@phekda.freeserve.co.uk>
Reply-To: djgpp-workers AT delorie DOT com

Hello.

Below is version 2 of the patch to allow building of code with
FSEXT hooks with gcc 3.1 and -Werror. This patch introduces
a new library-private header <libc/fsexthlp.h>, which has
some wrapper functions.

As stated in another mail, this has mostly been tested. The symlink,
llseek and fchown hooks need more testing. I plan to test out llseek
and fchown as part of adding support for them to /dev/zero & /dev/full.

OK to commit?

Bye, Rich =]

Index: src/libc/ansi/stdio/remove.c
===================================================================
RCS file: /cvs/djgpp/djgpp/src/libc/ansi/stdio/remove.c,v
retrieving revision 1.6
diff -p -u -3 -r1.6 remove.c
--- src/libc/ansi/stdio/remove.c	2001/06/09 10:56:23	1.6
+++ src/libc/ansi/stdio/remove.c	2002/06/10 12:19:09
@@ -1,9 +1,11 @@
+/* Copyright (C) 2002 DJ Delorie, see COPYING.DJ for details */
 /* Copyright (C) 2000 DJ Delorie, see COPYING.DJ for details */
 /* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */
 /* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */
 /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
 #include <libc/stubs.h>
 #include <libc/symlink.h>
+#include <stdarg.h>
 #include <io.h>
 #include <stdio.h>
 #include <fcntl.h>
@@ -12,6 +14,7 @@
 #include <go32.h>
 #include <libc/dosio.h>
 #include <sys/fsext.h>
+#include <libc/fsexthlp.h>
 
 int
 remove(const char *fn)
@@ -24,7 +27,7 @@ remove(const char *fn)
   int rv;
 
   /* see if a file system extension wants to handle this */
-  if (__FSEXT_call_open_handlers(__FSEXT_unlink, &rv, &fn))
+  if (__FSEXT_call_open_handlers_wrapper(__FSEXT_unlink, &rv, fn))
     return rv;
 
   /* Handle symlinks */
Index: src/libc/compat/time/select.c
===================================================================
RCS file: /cvs/djgpp/djgpp/src/libc/compat/time/select.c,v
retrieving revision 1.5
diff -p -u -3 -r1.5 select.c
--- src/libc/compat/time/select.c	2001/03/31 10:33:42	1.5
+++ src/libc/compat/time/select.c	2002/06/10 12:19:09
@@ -1,3 +1,4 @@
+/* Copyright (C) 2002 DJ Delorie, see COPYING.DJ for details */
 /* Copyright (C) 2001 DJ Delorie, see COPYING.DJ for details */
 /* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */
 /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
@@ -25,6 +26,7 @@
 #include <libc/getdinfo.h>
 #include <libc/ttyprvt.h>
 #include <sys/fsext.h>
+#include <libc/fsexthlp.h>
 
 inline static int
 fp_output_ready(FILE *fp)
@@ -165,7 +167,7 @@ select(int nfds,
       int fsext_ready = -1;
 
       if (func)
-	func(__FSEXT_ready, &fsext_ready, &i);
+	__FSEXT_func_wrapper(func, __FSEXT_ready, &fsext_ready, i);
 
       if (readfds && FD_ISSET (i, readfds))
       {
Index: src/libc/compat/unistd/_irdlink.c
===================================================================
RCS file: /cvs/djgpp/djgpp/src/libc/compat/unistd/_irdlink.c,v
retrieving revision 1.4
diff -p -u -3 -r1.4 _irdlink.c
--- src/libc/compat/unistd/_irdlink.c	2002/01/09 22:00:10	1.4
+++ src/libc/compat/unistd/_irdlink.c	2002/06/10 12:19:12
@@ -1,13 +1,16 @@
+/* Copyright (C) 2002 DJ Delorie, see COPYING.DJ for details */
 /* Copyright (C) 2001 DJ Delorie, see COPYING.DJ for details */
 /* Copyright (C) 2000 DJ Delorie, see COPYING.DJ for details */
 
 #include <libc/stubs.h>
 #include <libc/symlink.h>
 #include <sys/fsext.h>
+#include <libc/fsexthlp.h>
 #include <dir.h>
 #include <errno.h>
 #include <fcntl.h>
 #include <io.h>
+#include <stdarg.h>
 #include <stddef.h>
 #include <stdio.h>
 #include <string.h>
@@ -37,7 +40,8 @@ int __internal_readlink(const char * __p
    if (__path)
    {
       struct ffblk  file_info;
-      if (__FSEXT_call_open_handlers(__FSEXT_readlink, &ret, &__path))
+      if (__FSEXT_call_open_handlers_wrapper(__FSEXT_readlink, &ret,
+					     __path, __buf, __max))
          return ret;
       /* We will check if file exists by the way */
       if (findfirst(__path, &file_info, 0))
@@ -53,7 +57,7 @@ int __internal_readlink(const char * __p
       if (func)
       {
          int rv;
-         if (func(__FSEXT_readlink, &rv, &__path))
+         if (__FSEXT_func_wrapper(func, __FSEXT_readlink, &rv, __path))
             return rv;
       }
       file_size = filelength(__fhandle);
Index: src/libc/compat/unistd/fchown.c
===================================================================
RCS file: /cvs/djgpp/djgpp/src/libc/compat/unistd/fchown.c,v
retrieving revision 1.1
diff -p -u -3 -r1.1 fchown.c
--- src/libc/compat/unistd/fchown.c	2002/04/13 07:43:29	1.1
+++ src/libc/compat/unistd/fchown.c	2002/06/10 12:19:12
@@ -1,9 +1,11 @@
 /* Copyright (C) 2002 DJ Delorie, see COPYING.DJ for details */
 #include <libc/stubs.h>
+#include <stdarg.h>
 #include <sys/fsext.h>
+#include <libc/fsexthlp.h>
 #include <io.h>
 #include <unistd.h>
- 
+
 /* MS-DOS couldn't care less about file ownerships, so we 
    at least check if given handle is valid. */
  
@@ -13,7 +15,7 @@ int fchown(int fd, uid_t owner, gid_t gr
   if (func)
   {
     int rv;
-    if (func(__FSEXT_fchown, &rv, &fd))
+    if (__FSEXT_func_wrapper(func, __FSEXT_fchown, &rv, fd, owner, group))
       return rv;
   }
   return (_get_dev_info(fd) == -1) ? 1 : 0;
Index: src/libc/compat/unistd/llseek.c
===================================================================
RCS file: /cvs/djgpp/djgpp/src/libc/compat/unistd/llseek.c,v
retrieving revision 1.5
diff -p -u -3 -r1.5 llseek.c
--- src/libc/compat/unistd/llseek.c	2001/10/14 20:50:16	1.5
+++ src/libc/compat/unistd/llseek.c	2002/06/10 12:19:15
@@ -1,3 +1,4 @@
+/* Copyright (C) 2002 DJ Delorie, see COPYING.DJ for details */
 /* Copyright (C) 2001 DJ Delorie, see COPYING.DJ for details */
 /*
  * File llseek.c.
@@ -10,11 +11,13 @@
  */
 
 #include <libc/stubs.h>
+#include <stdarg.h>
 #include <unistd.h>
 #include <dpmi.h>
 #include <errno.h>
 #include <libc/dosio.h>
 #include <sys/fsext.h>
+#include <libc/fsexthlp.h>
 #include <libc/fd_props.h>
 
 offset_t
@@ -27,7 +30,8 @@ llseek( int handle, offset_t offset, int
   if( func )
   {
     int rv;
-    if( func(__FSEXT_llseek, &rv, &handle) )
+    if( __FSEXT_func_wrapper(func, __FSEXT_llseek, &rv,
+			     handle, offset, whence) )
     {
       return rv;
     }
Index: src/libc/compat/unistd/symlink.c
===================================================================
RCS file: /cvs/djgpp/djgpp/src/libc/compat/unistd/symlink.c,v
retrieving revision 1.3
diff -p -u -3 -r1.3 symlink.c
--- src/libc/compat/unistd/symlink.c	2001/05/11 17:52:27	1.3
+++ src/libc/compat/unistd/symlink.c	2002/06/10 12:19:15
@@ -1,9 +1,12 @@
+/* Copyright (C) 2002 DJ Delorie, see COPYING.DJ for details */
 /* Copyright (C) 2000 DJ Delorie, see COPYING.DJ for details */
 /* Copyright (C) 1999 DJ Delorie, see COPYING.DJ for details */
 /* Copyright (C) 1997 DJ Delorie, see COPYING.DJ for details */
 #include <libc/stubs.h>
 #include <libc/symlink.h>
 #include <sys/fsext.h>
+#include <libc/fsexthlp.h>
+#include <stdarg.h>
 #include <errno.h>
 #include <unistd.h>
 #include <io.h>
@@ -33,7 +36,7 @@ int symlink(const char *source, const ch
    }
 
    /* Provide ability to hook symlink support */
-   if (__FSEXT_call_open_handlers(__FSEXT_symlink, &ret, &source))
+   if (__FSEXT_call_open_handlers_wrapper(__FSEXT_symlink, &ret, source, dest))
       return ret;
 
 
Index: src/libc/dos/io/_close.c
===================================================================
RCS file: /cvs/djgpp/djgpp/src/libc/dos/io/_close.c,v
retrieving revision 1.3
diff -p -u -3 -r1.3 _close.c
--- src/libc/dos/io/_close.c	2001/03/07 05:40:27	1.3
+++ src/libc/dos/io/_close.c	2002/06/10 12:19:18
@@ -1,12 +1,14 @@
+/* Copyright (C) 2002 DJ Delorie, see COPYING.DJ for details */
 /* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */
 /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
+#include <stdarg.h>
 #include <unistd.h>
 #include <errno.h>
 #include <go32.h>
 #include <dpmi.h>
 #include <io.h>
 #include <sys/fsext.h>
-
+#include <libc/fsexthlp.h>
 #include <libc/dosio.h>
 #include <libc/fd_props.h>
 
@@ -19,7 +21,7 @@ _close(int handle)
   if (func)
   {
     int rv;
-    if (func(__FSEXT_close, &rv, &handle))
+    if (__FSEXT_func_wrapper(func, __FSEXT_close, &rv, handle))
     {
       /* So that we don't try to use it later!
 	 The extension *should* do this itself! */
Index: src/libc/dos/io/_creat.c
===================================================================
RCS file: /cvs/djgpp/djgpp/src/libc/dos/io/_creat.c,v
retrieving revision 1.11
diff -p -u -3 -r1.11 _creat.c
--- src/libc/dos/io/_creat.c	2001/09/25 00:48:55	1.11
+++ src/libc/dos/io/_creat.c	2002/06/10 12:19:18
@@ -1,7 +1,9 @@
+/* Copyright (C) 2002 DJ Delorie, see COPYING.DJ for details */
 /* Copyright (C) 2001 DJ Delorie, see COPYING.DJ for details */
 /* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */
 /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
 #include <libc/stubs.h>
+#include <stdarg.h>
 #include <fcntl.h>
 #include <errno.h>
 #include <go32.h>
@@ -11,6 +13,7 @@
 #include <unistd.h>
 #include <libc/dosio.h>
 #include <sys/fsext.h>
+#include <libc/fsexthlp.h>
 
 int
 _creat(const char* filename, int attrib)
@@ -25,7 +28,7 @@ _creat(const char* filename, int attrib)
     return -1;
   }
 
-  if (__FSEXT_call_open_handlers(__FSEXT_creat, &rv, &filename))
+  if (__FSEXT_call_open_handlers_wrapper(__FSEXT_creat, &rv, filename, attrib))
     return rv;
 
   if(use_lfn) {
Index: src/libc/dos/io/_creat_n.c
===================================================================
RCS file: /cvs/djgpp/djgpp/src/libc/dos/io/_creat_n.c,v
retrieving revision 1.7
diff -p -u -3 -r1.7 _creat_n.c
--- src/libc/dos/io/_creat_n.c	2001/09/25 00:48:55	1.7
+++ src/libc/dos/io/_creat_n.c	2002/06/10 12:19:21
@@ -1,6 +1,8 @@
+/* Copyright (C) 2002 DJ Delorie, see COPYING.DJ for details */
 /* Copyright (C) 2001 DJ Delorie, see COPYING.DJ for details */
 /* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */
 #include <libc/stubs.h>
+#include <stdarg.h>
 #include <fcntl.h>
 #include <errno.h>
 #include <go32.h>
@@ -10,6 +12,7 @@
 #include <unistd.h>
 #include <libc/dosio.h>
 #include <sys/fsext.h>
+#include <libc/fsexthlp.h>
 
 int
 _creatnew(const char* filename, int attrib, int flags)
@@ -24,7 +27,8 @@ _creatnew(const char* filename, int attr
     return -1;
   }
 
-  if (__FSEXT_call_open_handlers(__FSEXT_creat, &rv, &filename))
+  if (__FSEXT_call_open_handlers_wrapper(__FSEXT_creat, &rv,
+					 filename, attrib, flags))
     return rv;
 
   _put_path(filename);
Index: src/libc/dos/io/_open.c
===================================================================
RCS file: /cvs/djgpp/djgpp/src/libc/dos/io/_open.c,v
retrieving revision 1.8
diff -p -u -3 -r1.8 _open.c
--- src/libc/dos/io/_open.c	2001/09/25 00:48:55	1.8
+++ src/libc/dos/io/_open.c	2002/06/10 12:19:21
@@ -1,7 +1,9 @@
+/* Copyright (C) 2002 DJ Delorie, see COPYING.DJ for details */
 /* Copyright (C) 2001 DJ Delorie, see COPYING.DJ for details */
 /* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */
 /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
 #include <libc/stubs.h>
+#include <stdarg.h>
 #include <string.h>
 #include <fcntl.h>
 #include <errno.h>
@@ -11,6 +13,7 @@
 #include <dos.h>
 #include <libc/dosio.h>
 #include <sys/fsext.h>
+#include <libc/fsexthlp.h>
 
 int
 _open(const char* filename, int oflag)
@@ -25,7 +28,7 @@ _open(const char* filename, int oflag)
     return -1;
   }
 
-  if (__FSEXT_call_open_handlers(__FSEXT_open, &rv, &filename))
+  if (__FSEXT_call_open_handlers_wrapper(__FSEXT_open, &rv, filename, oflag))
     return rv;
 
   if(use_lfn && _os_trueversion == 0x532) {
Index: src/libc/dos/io/_read.c
===================================================================
RCS file: /cvs/djgpp/djgpp/src/libc/dos/io/_read.c,v
retrieving revision 1.1
diff -p -u -3 -r1.1 _read.c
--- src/libc/dos/io/_read.c	1995/11/25 21:48:30	1.1
+++ src/libc/dos/io/_read.c	2002/06/10 12:19:24
@@ -1,5 +1,7 @@
+/* Copyright (C) 2002 DJ Delorie, see COPYING.DJ for details */
 /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
 #include <libc/stubs.h>
+#include <stdarg.h>
 #include <unistd.h>
 #include <string.h>
 #include <errno.h>
@@ -7,7 +9,7 @@
 #include <dpmi.h>
 #include <io.h>
 #include <sys/fsext.h>
-
+#include <libc/fsexthlp.h>
 #include <libc/dosio.h>
 
 int
@@ -22,7 +24,7 @@ _read(int handle, void* buffer, size_t c
   if (func)
   {
     int rv;
-    if (func(__FSEXT_read, &rv, &handle))
+    if (__FSEXT_func_wrapper(func, __FSEXT_read, &rv, handle, buffer, count))
       return rv;
   }
 
Index: src/libc/dos/io/_write.c
===================================================================
RCS file: /cvs/djgpp/djgpp/src/libc/dos/io/_write.c,v
retrieving revision 1.7
diff -p -u -3 -r1.7 _write.c
--- src/libc/dos/io/_write.c	2001/05/19 18:31:35	1.7
+++ src/libc/dos/io/_write.c	2002/06/10 12:19:25
@@ -1,6 +1,8 @@
+/* Copyright (C) 2002 DJ Delorie, see COPYING.DJ for details */
 /* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */
 /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
 #include <libc/stubs.h>
+#include <stdarg.h>
 #include <unistd.h>
 #include <string.h>
 #include <errno.h>
@@ -8,13 +10,12 @@
 #include <dpmi.h>
 #include <io.h>
 #include <sys/fsext.h>
-
+#include <libc/fsexthlp.h>
 #include <libc/dosio.h>
 #include <libc/fd_props.h>
 #include <libc/farptrgs.h>
 #include <libc/getdinfo.h>
 
-
 int
 _write(int handle, const void* buffer, size_t count)
 {
@@ -22,7 +23,7 @@ _write(int handle, const void* buffer, s
   if (func)
   {
     int rv;
-    if (func(__FSEXT_write, &rv, &handle))
+    if (__FSEXT_func_wrapper(func, __FSEXT_write, &rv, handle, buffer, count))
       return rv;
   }
 
Index: src/libc/posix/sys/stat/fstat.c
===================================================================
RCS file: /cvs/djgpp/djgpp/src/libc/posix/sys/stat/fstat.c,v
retrieving revision 1.8
diff -p -u -3 -r1.8 fstat.c
--- src/libc/posix/sys/stat/fstat.c	2001/12/01 20:22:37	1.8
+++ src/libc/posix/sys/stat/fstat.c	2002/06/10 12:19:31
@@ -1,3 +1,4 @@
+/* Copyright (C) 2002 DJ Delorie, see COPYING.DJ for details */
 /* Copyright (C) 2001 DJ Delorie, see COPYING.DJ for details */
 /* Copyright (C) 2000 DJ Delorie, see COPYING.DJ for details */
 /* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */
@@ -95,6 +96,7 @@
  */
 
 #include <libc/stubs.h>
+#include <stdarg.h>
 #include <string.h>
 #include <stdlib.h>
 #include <stdio.h>
@@ -115,6 +117,7 @@
 #include <libc/bss.h>
 #include <libc/symlink.h>
 #include <sys/fsext.h>
+#include <libc/fsexthlp.h>
 #include "xstat.h"
 
 /* Should we bother about executables at all? */
@@ -900,7 +903,7 @@ fstat(int handle, struct stat *statbuf)
 
   /* see if this is file system extension file */
   func = __FSEXT_get_function(handle);
-  if (func && func(__FSEXT_fstat, &rv, &handle))
+  if (func && __FSEXT_func_wrapper(func, __FSEXT_fstat, &rv, handle, statbuf))
     {
        return rv;
     }
Index: src/libc/posix/sys/stat/lstat.c
===================================================================
RCS file: /cvs/djgpp/djgpp/src/libc/posix/sys/stat/lstat.c,v
retrieving revision 1.11
diff -p -u -3 -r1.11 lstat.c
--- src/libc/posix/sys/stat/lstat.c	2002/01/16 04:25:15	1.11
+++ src/libc/posix/sys/stat/lstat.c	2002/06/10 12:19:36
@@ -1,3 +1,4 @@
+/* Copyright (C) 2002 DJ Delorie, see COPYING.DJ for details */
 /* Copyright (C) 2001 DJ Delorie, see COPYING.DJ for details */
 /* Copyright (C) 2000 DJ Delorie, see COPYING.DJ for details */
 /* Copyright (C) 1999 DJ Delorie, see COPYING.DJ for details */
@@ -114,6 +115,7 @@
 #include <dos.h>
 #include <dir.h>
 #include <sys/fsext.h>
+#include <libc/fsexthlp.h>
 #include <dpmi.h>
 #include <go32.h>
 #include <libc/farptrgs.h>
@@ -889,16 +891,6 @@ stat_assist(const char *path, struct sta
   return 0;
 }
 
-/* A wrapper around __FSEXT_call_open_handlers(), to provide its
- * arguments properly.
- */
-static int fsext_wrapper(int * ret, const char * path, 
-                         struct stat * statbuf __attribute__((unused)))
-{
-   return __FSEXT_call_open_handlers(__FSEXT_stat, ret, &path);
-}
-
-
 /* Main entry point.  This is library lstat() function.
  */
 
@@ -934,7 +926,8 @@ lstat(const char *path, struct stat *sta
       return -1;
     }
 
-  if (fsext_wrapper(&ret, real_path, statbuf))
+  if (__FSEXT_call_open_handlers_wrapper(__FSEXT_stat, &ret,
+					 real_path, statbuf))
     return ret;
 
   if (stat_assist(real_path, statbuf) == -1)
Index: src/libc/posix/unistd/link.c
===================================================================
RCS file: /cvs/djgpp/djgpp/src/libc/posix/unistd/link.c,v
retrieving revision 1.2
diff -p -u -3 -r1.2 link.c
--- src/libc/posix/unistd/link.c	1998/06/28 17:27:32	1.2
+++ src/libc/posix/unistd/link.c	2002/06/10 12:19:42
@@ -1,6 +1,8 @@
+/* Copyright (C) 2002 DJ Delorie, see COPYING.DJ for details */
 /* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */
 /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
 #include <libc/stubs.h>
+#include <stdarg.h>
 #include <sys/stat.h>		/* For stat() */
 #include <fcntl.h>		/* For O_RDONLY, etc. */
 #include <unistd.h>		/* For read(), write(), etc. */
@@ -8,6 +10,7 @@
 #include <utime.h>		/* For utime() */
 #include <errno.h>		/* For errno */
 #include <sys/fsext.h>
+#include <libc/fsexthlp.h>
 
 /* Of course, DOS can't really do a link.  We just do a copy instead,
    which is as close as DOS gets.  Alternatively, we could always fail
@@ -33,7 +36,7 @@ link(const char *path1, const char *path
   }
 
   /* see if a file system extension implements the link */
-  if (__FSEXT_call_open_handlers(__FSEXT_link, &rv, &path1))
+  if (__FSEXT_call_open_handlers_wrapper(__FSEXT_link, &rv, path1, path2))
     return rv;
 
   /* Fail if path1 does not exist - stat() will set errno */
Index: src/libc/posix/unistd/lseek.c
===================================================================
RCS file: /cvs/djgpp/djgpp/src/libc/posix/unistd/lseek.c,v
retrieving revision 1.5
diff -p -u -3 -r1.5 lseek.c
--- src/libc/posix/unistd/lseek.c	2001/10/14 20:50:16	1.5
+++ src/libc/posix/unistd/lseek.c	2002/06/10 12:19:42
@@ -1,12 +1,15 @@
+/* Copyright (C) 2002 DJ Delorie, see COPYING.DJ for details */
 /* Copyright (C) 2001 DJ Delorie, see COPYING.DJ for details */
 /* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */
 /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
 #include <libc/stubs.h>
+#include <stdarg.h>
 #include <unistd.h>
 #include <errno.h>
 #include <go32.h>
 #include <dpmi.h>
 #include <sys/fsext.h>
+#include <libc/fsexthlp.h>
 #include <libc/dosio.h>
 #include <libc/fd_props.h>
 
@@ -20,7 +23,7 @@ lseek(int handle, off_t offset, int when
   if (func)
   {
     int rv;
-    if (func(__FSEXT_lseek, &rv, &handle))
+    if (__FSEXT_func_wrapper(func, __FSEXT_lseek, &rv, handle, offset, whence))
       return rv;
   }
 
Index: src/libc/posix/unistd/write.c
===================================================================
RCS file: /cvs/djgpp/djgpp/src/libc/posix/unistd/write.c,v
retrieving revision 1.7
diff -p -u -3 -r1.7 write.c
--- src/libc/posix/unistd/write.c	2001/06/09 20:49:46	1.7
+++ src/libc/posix/unistd/write.c	2002/06/10 12:19:45
@@ -1,8 +1,10 @@
+/* Copyright (C) 2002 DJ Delorie, see COPYING.DJ for details */
 /* Copyright (C) 2001 DJ Delorie, see COPYING.DJ for details */
 /* Copyright (C) 1997 DJ Delorie, see COPYING.DJ for details */
 /* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */
 /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
 #include <libc/stubs.h>
+#include <stdarg.h>
 #include <unistd.h>
 #include <fcntl.h>
 #include <go32.h>
@@ -11,12 +13,14 @@
 #include <errno.h>
 #include <libc/farptrgs.h>
 #include <sys/fsext.h>
+#include <libc/fsexthlp.h>
 #include <libc/dosio.h>
 #include <libc/ttyprvt.h>
 #include <libc/fd_props.h>
 
 #define tblen _go32_info_block.size_of_transfer_buffer
 
+
 int (*__libc_write_termios_hook)(int handle, const void *buffer, size_t count,
 				 ssize_t *rv) = NULL;
 
@@ -52,9 +56,10 @@ write(int handle, const void* buffer, si
     return _write(handle, buf, count);
 
   /* Let's handle FSEXT_write ! */
-  if(func &&				/* if handler is installed, ...*/
-     func(__FSEXT_write, &rv, &handle)) /* ... call extension ... */
-      return rv;			/* ... and exit if handled. */
+  /* if handler is installed, call extension and exit if handled. */
+  if(func &&				
+     __FSEXT_func_wrapper(func, __FSEXT_write, &rv, handle, buffer, count))
+      return rv;
 
   if (__has_fd_properties(handle)
       && (__fd_properties[handle]->flags & FILE_DESC_ZERO_FILL_EOF_GAP))
Index: include/libc/fsexthlp.h
===================================================================
RCS file: fsexthlp.h
diff -N fsexthlp.h
--- /dev/null	Tue May  5 16:32:27 1998
+++ fsexthlp.h	Mon Jun 10 08:19:45 2002
@@ -0,0 +1,64 @@
+/* Copyright (C) 2002 DJ Delorie, see COPYING.DJ for details */
+#ifndef __dj_include_libc_fsexthlp_h__
+#define __dj_include_libc_fsexthlp_h__
+
+#include <stdarg.h>
+#include <sys/fsext.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef __dj_ENFORCE_ANSI_FREESTANDING
+
+#ifndef __STRICT_ANSI__
+
+#ifndef _POSIX_SOURCE
+
+/* This is a wrapper for an FSEXT function that allows it to be called
+ * with a variable number of arguments. */
+
+static inline int
+__FSEXT_func_wrapper (__FSEXT_Function *func,
+		      __FSEXT_Fnumber fnum,
+		      int *rv,
+		      ...)
+{
+  va_list args;
+  int ret;
+
+  va_start(args, rv);
+  ret = func(fnum, rv, args);
+  va_end(args);
+
+  return(ret);
+}
+
+/* This is a wrapper for __FSEXT_call_open_handlers that allows it
+ * to be called with a variable number of arguments. */
+
+static inline int
+__FSEXT_call_open_handlers_wrapper (__FSEXT_Fnumber fnum, int *rv, ...)
+{
+  va_list args;
+  int ret;
+
+  va_start(args, rv);
+  ret = __FSEXT_call_open_handlers(fnum, rv, args);
+  va_end(args);
+
+  return(ret);
+}
+
+#endif /* !_POSIX_SOURCE */
+#endif /* !__STRICT_ANSI__ */
+#endif /* !__dj_ENFORCE_ANSI_FREESTANDING */
+
+#ifndef __dj_ENFORCE_FUNCTION_CALLS
+#endif /* !__dj_ENFORCE_FUNCTION_CALLS */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __dj_include_libc_fsexthlp_h__ */

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019