Subject: RE: _get_osfhandle and/or mmap under cygwin.dll on NT?
From: [email-masked] (Colin Peters)

14 Jan 1997 03:18:12 -0800
Approved: [email-masked]
Distribution: cygnus
Message-ID: <01BC0251.4D542D20.cygnus.gnu-win32@gbird0>
Mime-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Original-To: "'Henry Minsky'" <[email-masked]>, "'GNU-Win32'" <[email-masked]>
Original-Sender: [email-masked]

Henry Minsky[SMTP:[email-masked]] wrote:
>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
><[email-masked]>, which says it implements mmap using
>the Win32 memory mapping routines.
>
>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?

I know less than nothing about mmap, but I do know something about
_get_osfhandle. The implementation of _get_osfhandle is in CRTDLL.DLL
(the C run time library included with Windows 95 and NT) and you could
fairly easily link a reference to it into your application by creating
and import library for it. In fact you could just grab the relevant
..def file and prototype out of the Minimalist GNU Win-32 files (download
mingw32-0.1.1.tar.gz from 
http://www.fu.is.saga-u.ac.jp/~colin/mingw32-download.html and dig out
the relevant information) or you could fairly easily write the necessary
stuff yourself (a very short .def file and a prototype for _get_osfhandle).
Then you could link your application with your new import library and voila, _get_osfhandle will work.

One warning however: crtdll is a full implementation of the C run-time
library, and _get_osfhandle is a fairly low-level non-portable call. This
sends up warning flags in my mind that you may encounter trouble with the
code that uses this function if you use the Cygwin version of the run time
library functions in concert with it... but then again you could be lucky.
It also means that you have to avoid using the import library and/or full
..def file from mingw32 if you don't want all your run time library calls
to be handled by crtdll.dll (which implies basically compiling with mingw32
*instead* of with a "normal" Cygnus/cygwin setup).

Other than these (honestly minor) caveats it shouldn't be too hard.

Good luck,
Colin.

-- Colin Peters - [email-masked]
-- Saga University Dept. of Information Science
-- Fundamentals of Information Science
-- http://www.fu.is.saga-u.ac.jp/~colin/home.html

-
For help on using this list, send a message to
"[email-masked]" with one line of text: "help".