i91@nikhefh.nikhef.nl (Fons Rademakers) (03/21/91)
Hi, I am having problems with the mmap routines on the Apollo. My system is an SR10.3 9000/400 machine. I am trying to use mmap in the following way but I get all the time the error message: mmap: Invalid argument The same routine works fine on a SUN (except for the fact that len instead of the address of len is passed to mmap). The program that uses this routine is linked in the following way: bind -b producer producer.bin ftn/*.bin -align aap page (the address of aap is passed in comaddr). Could somebody tell me what Apollo specific changes should be made? Or show me a piece of code, using mmap, that runs on the Apollo? Thanks, Fons Rademakers. ============================= code fragment ==================== #include <stdio.h> #include <errno.h> #include <fcntl.h> #include <sys/types.h> #include <sys/mman.h> #include <sys/file.h> #include <sys/stat.h> int fd_pawc; long len; int hcreatei(mfile, mflen, comaddr, size) /* * mfile name of file to be mapped * mflen length of filename * comaddr address of common to be mapped * size length of common in 32 bit words */ long comaddr; int *size, *mflen; char *mfile; { caddr_t paddr; int istat; char *path, *file, dir[100], *cmd, csiz[10]; char *strncat(); path = "/tmp/"; strcpy(dir,path); file = strncat(dir,mfile,*mflen); len = *size * 4; fd_pawc = open(file,O_RDWR|O_CREAT,0666); if (fd_pawc < 0) istat = -errno; else { paddr = mmap((caddr_t) comaddr, &len, PROT_READ|PROT_WRITE, MAP_SHARED|MAP_FIXED, fd_pawc, 0); if (paddr == NULL || (int)paddr%getpagesize() != 0 || (int)len%getpagesize() != 0) { perror("mmap"); istat = -errno; close(fd_pawc); } else istat = len/getpagesize(); } return(istat); } -- Org: NIKHEF-H, National Institute for Nuclear and High-Energy Physics. Mail: Kruislaan 409, P.O. Box 41882, 1009 DB Amsterdam, the Netherlands Phone: (20)5925018 or 5925003 Telex: 10262 (hef nl) UUCP: i91@nikhefh.nikhef.nl BITNET: nikhefh!i91@mcvax.bitnet