delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/1997/02/22/08:41:57

From: phurley AT umd DOT umich DOT edu ("Patrick T. Hurley")
Subject: gnuwin32 & mmap
22 Feb 1997 08:41:57 -0800 :
Approved: cygnus DOT gnu-win32 AT cygnus DOT com
Distribution: cygnus
Message-ID: <199702221504.KAA26226.cygnus.gnu-win32@null.umd.umich.edu>
Mime-Version: 1.0
Original-To: gnu-win32 AT cygnus DOT com (gwin)
X-Mailer: ELM [version 2.4.25 PGP3A]
Original-Sender: owner-gnu-win32 AT cygnus DOT com

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 AT cygnus DOT com" with one line of text: "help".

- Raw text -


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