This is the mail archive of the cygwin@sourceware.cygnus.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

gnuwin32 & mmap


I see mmap in the header files, but when I try to use
it in a program (I am trying to port mSQL), I get errors.

mSQL comes with a simple prog for testing mmap,
if I just:
$ gcc mmap.c
I get:
G:\TEMP/cc0010201.o(.text+0xbe):mmap.c: undefined reference to `mmap'
G:\TEMP/cc0010201.o(.text+0xf6):mmap.c: undefined reference to `munmap'

from the program (which comes with mSQL):

#include <stdio.h>
#include <sys/types.h>
#include <fcntl.h>
#include <sys/mman.h>

#define PATH    "/tmp/MmAp-TeSt"

main()
{
        int     fd,
                res;
        static   char   text[] = "Test Data";
        caddr_t cp;

        fd = open(PATH,O_CREAT|O_RDWR|O_TRUNC);
        if (fd < 0)
        {
                fprintf(stderr,"mmap test : couldn't create tmp file!\n\n");
                exit(1);
        }
        write(fd,text,strlen(text));
        cp = mmap(NULL,strlen(text), PROT_READ|PROT_WRITE, MAP_SHARED, fd,0);
        if (cp == (caddr_t) -1)
        {
                res = 1;
        }
        else
        {
                res=0;
                munmap(cp,strlen(text));
        }
        close(fd);
        unlink(PATH);
        exit(res);
}

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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]