delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/1997/01/14/14:56:13

From: D DOT Makepeace AT mailbox DOT uq DOT oz DOT au (David Makepeace)
Subject: Re: _get_osfhandle and/or mmap under cygwin.dll on NT?
14 Jan 1997 14:56:13 -0800 :
Approved: cygnus DOT gnu-win32 AT cygnus DOT com
Distribution: cygnus
Message-ID: <32DBE631.6F72.cygnus.gnu-win32@mailbox.uq.oz.au>
References: <199701140726 DOT XAA23090 AT teller DOT datawave DOT net>
Mime-Version: 1.0
X-Mailer: Mozilla 3.01Gold (X11; I; SunOS 5.5 i86pc)
Original-To: Henry Minsky <hqm AT ua DOT com>
Original-CC: gnu-win32 AT cygnus DOT com
Original-Sender: owner-gnu-win32 AT cygnus DOT com

This is a multi-part message in MIME format.

--------------651970E7330E
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Henry Minsky wrote:
> 
> Hi,
> 
> Does anyone know if mmap is supposed to work under the current (v B
> 17.1) cygwin.dll?  I get undefined symbol errors when I try to compile
> programs with calls to mmap().
> 
> If mmap() has not yet been implemented, I was given an implementation
> called mman.c written by a fellow in Australia, David Makepeace
> <D DOT Makepeace AT mailbox DOT uq DOT oz DOT au>, which says it implements mmap using
> the Win32 memory mapping routines.

I plan to do a port of my basic mmap() support to gnu-win32 within the
next
few days and then start on a better implementation which will support
shared
memory IPC and address other limitations.  The new one will probably
live
inside cygwin.dll.

BTW, you probably have an old version of my mman.c which has a handle
leak in
munmap().

> I cannot compile this version of mmap under gcc on Windows NT,
> however, because it references a function called _get_osfhandle. This
> seems to be defined in the Microsoft LIBC, but not in the gnu-win32
> libraries. Can anyone tell me how to link with this function, or more
> generally how to link with a .lib or other object file produced by
> Mirosoft's compiler?
> 
> Thanks,
>         Henry

I have added _get_osfhandle() to my copy of cygwin.dll (patches
attached).

I have put io.h and binaries of cygwin.dll and libcygwin.a - based on
b17, not
b17.1 - (for anyone who wants them) in:

	http://www.uq.oz.au/~zzdmakep/pub/getosfh.zip

The zip file contains three files (io.h, cygwin.dll and libcygwin.a).
These should go in the following locations:

	\cygnus\H-i386-cygwin32\bin\cygwin.dll
	\cygnus\H-i386-cygwin32\i386-cygwin32\lib\libcygwin.a
	\cygnus\H-i386-cygwin32\i386-cygwin32\include\io.h

Back up your original copies of cygwin.dll and libcygwin.a and make sure
you are
not running any programs which use cygwin.dll (such as bash) when it
gets
overwritten.  e.g. Use COPY (not cp) to copy in the new cygwin.dll.

David.

---------------------------------------------------------------------
David Makepeace   Ph:  +61 7 3378 4299
KEAYS Software    Fax: +61 7 3378 7922   D DOT Makepeace AT mailbox DOT uq DOT oz DOT au
---------------------------------------------------------------------

--------------651970E7330E
Content-Type: text/plain; charset=us-ascii; name="io.h"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline; filename="io.h"

#ifndef _IO_H_
#ifdef __cplusplus
extern "C" {
#endif
#define _IO_H_

long _get_osfhandle(int fd);

#ifdef __cplusplus
}
#endif
#endif /* _IO_H_ */

--------------651970E7330E
Content-Type: text/plain; charset=us-ascii; name="getosfh.pat"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline; filename="getosfh.pat"

*** syscalls.cc	Wed Dec 04 13:23:02 1996
--- syscalls.cc	Tue Dec 31 16:53:13 1996
***************
*** 1037,1042 ****
--- 1037,1060 ----
  	}
      }
    syscall_printf ("%d = ftruncate (%d, %d); \n", fd, length);
+ 
+   return res;
+ }
+ 
+ extern "C"
+ long
+ _get_osfhandle (int fd) 
+ {
+   long res = -1;
+ 
+   if (NOT_OPEN_FD(fd))
+     {
+       set_errno ( EBADF);
+     }
+   else
+     {
+       res = (long)u->self->hmap[fd].h->get_handle ();
+     }
  
    return res;
  }

*** cygwin.din	Sat Dec 07 08:38:58 1996
--- cygwin.din	Tue Dec 31 16:55:51 1996
***************
*** 938,940 ****
--- 938,941 ----
  cygwin32_posix_to_win32_path_list = posix_to_win32_path_list
  cygwin32_split_path = split_path
  __small_printf = small_printf__FPCce
+ _get_osfhandle

--------------651970E7330E--

-
For help on using this list, send a message to
"gnu-win32-request AT cygnus DOT com" with one line of text: "help".

- Raw text -


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