FreeBSD/tools/test/upsdl/upsdl.c
/* mmap a 2 page buffer - first page is from fd1, second page from fd2 */
mmap a 2 page buffer - first page is from fd1, second page from fd2
mmap a 2 page buffer - first page is from fd1 second page from fd2
int mapBuffer(char** bufferp,int fd1,int fd2)
{
  void* addr;
  char *buffer;
  addr = mmap(NULL,pagesize*2, PROT_READ | PROT_WRITE , MAP_SHARED, fd1, 0);
  if (addr == MAP_FAILED)
    {
      perror("Mmap failed");
      return 1;
    }
  buffer = addr;
  addr = mmap(buffer + pagesize,pagesize, PROT_READ | PROT_WRITE , MAP_FIXED | 
MAP_SHARED, fd2, 0);
  if (addr == MAP_FAILED)
    {
      perror("Mmap2 failed");
      return 1;
    }
  *bufferp = buffer;
  return 0;
}
int mapBuffer ( char * * bufferp , int fd1 , int fd2 ) { void * addr ; char * buffer ; addr = mmap ( NULL , pagesize * 2 , PROT_READ | PROT_WRITE , MAP_SHARED , fd1 , 0 ) ; if ( addr == MAP_FAILED ) { perror ( " " ) ; return 1 ; } buffer = addr ; addr = mmap ( buffer + pagesize , pagesize , PROT_READ | PROT_WRITE , MAP_FIXED | MAP_SHARED , fd2 , 0 ) ; if ( addr == MAP_FAILED ) { perror ( " " ) ; return 1 ; } * bufferp = buffer ; return 0 ; }
mmap a 2 page buffer - first page is from fd1, second page from fd2
mmap a 2 page buffer - first page is from fd1 second page from fd2