GNU Pascal Homepage - gpc - gpc-announce - gpc-de - gpc-doc
Diese Seite auf deutsch

Mail #4100

Back to main page of archive

Previous mail   Next mail   Unformatted/full headers
Overview  10 days   Subject   Date   Thread   Author  

From: Joachim Falk
Subject: p/scripts/find-sed with djgpp; cygwin rts.c; problem building rts gpc
Date: 24 Jul 2000, 21:35:27

On Mon, 24 Jul 2000, Frank Heckenbach wrote:

> Joachim Falk wrote:
[SNIP]
> > The Problem is that the latest version of cygwin downloaded just 3 days
> > ago doesnt have MAP_FAILED in /usr/include/sys/mman.h
> > this prevents rts.c to compile
> > I dont know if this is a bug in the cygwin header files or in
> > gpc
> 
> I don't know either, but it seems easy enough to change in GPC. Just
> to be sure: It does have mmap, but not MAP_FAILED? What does mmap
> return on failure? If it's either NULL or ((void *) -1), it should
> be alright after my change. If it's something else, let me know.
> 
[SNIP to end]

I have made a test program and it seams it does return (void *) -1 on
failure


#include <stdio.h>
#include <string.h>
#include <fcntl.h>
#include <errno.h>
#include <unistd.h>
#include <sys/mman.h>
#include <sys/stat.h>

char *basename( char *file ) {
  char *ptr = strrchr( file, '/' );
  if ( !ptr ) ptr = strrchr( file, '\\' );
  if ( !ptr ) ptr = file - 1;
  return ptr + 1;
}

int main( int argc, char *argv[] ) {
  char   *map_file;
  int     map_fd;
  void   *map_region;
  size_t  pagesize;
  char   *progname = "UNKNOWN";

  if ( argc > 0 ) progname = basename( argv[0] );
  if ( argc != 2 ) {
    fprintf( stderr, "%s <file to map>\n", progname );
    exit( -1 );
  }
  map_file = argv[1];
  map_fd = open( map_file, O_RDWR );
  if ( map_fd < 0 ) {
    fprintf( stderr, "%s: can't open file %s for reading: %s\n",
	     progname, map_file, strerror( errno ) );
    // exit( -1 );
    map_fd = 9999;
  }
  pagesize = getpagesize();
  map_region = mmap( NULL, pagesize, PROT_READ | PROT_WRITE,
                     MAP_SHARED, map_fd, 0 );
  printf( "map_region = %lX\n", (long) map_region );
  printf( "errno = %d => %s\n", errno, strerror( errno ) );
  return 0;
}

=> get
map_test.exe: can't open file foo for reading: No such file or directory
map_region = FFFFFFFF
errno = 9 => Bad file number
=> yep its (void *) -1 
						Joachim Falk

Previous mail   Next mail   Unformatted/full headers
Overview  10 days   Subject   Date   Thread   Author  


In reply to

Author Subject Date
Frank Heckenbach p/scripts/find-sed with djgpp; cygwin rts.c; problem building rts gpc 24 Jul 2000, 03:35:24

Back to main page of archive


Note: This page contains information that does not originate from the owner of this web site, but from the authors of the mails archived. The owner of this web site is not responsible for the content of such information. Any use of that infomation requires the consent of the respective author.

Where WWW addresses (URLs) in the mails archived are marked as hyperlinks, this is only for the comfort of the reader. The content of the web pages linked to like this does not necessarily reflect the opinion of the owner of this web site or of the authors of the mails archived. The owner of this web site is not responsible for the content of such web pages. Those pages are explicitly not to be considered as part of the content of this page, but merely as references.


This page was created by Crystal 0.999 (Linux 2.4.27/i686).