Home | History | Annotate | Download | only in mips32
      1 #include <sys/types.h>
      2 #include <sys/stat.h>
      3 #include <fcntl.h>
      4 #include <unistd.h>
      5 #include "tests/sys_mman.h"
      6 #include <errno.h>
      7 #include <stdio.h>
      8 #include <string.h>
      9 
     10 /* Test case supplied by Vasile Floroiu. */
     11 
     12 #define DO(cmd) printf(#cmd "; status: %s\n", strerror(errno))
     13 #define SZ 48216 + 1024
     14 
     15 int main()
     16 {
     17    int fd;
     18 
     19    fd = shm_open("/hw_mngr.c", (O_CREAT | O_EXCL | O_RDWR),
     20                  (S_IREAD | S_IWRITE));
     21    DO(shm_open());
     22    {
     23       void *ptr;
     24       ftruncate(fd, SZ);
     25       DO(ftruncate(fd, SZ));
     26 
     27       ptr = mmap(0, SZ, (PROT_READ | PROT_WRITE), MAP_SHARED, fd, 0);
     28       DO(mmap());
     29 
     30       munmap(ptr, SZ);
     31       DO(munmap());
     32    }
     33    shm_unlink("/hw_mngr.c");
     34    DO(shm_unlink());
     35    return 0;
     36 }
     37