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