mmap.c 433 B

12345678910111213141516171819202122232425262728
  1. /* The mmap test is useful, since syscalls with 6 arguments
  2. * (as mmap) are done differently on various architectures.
  3. */
  4. #include <unistd.h>
  5. #include <sys/mman.h>
  6. #include <stdlib.h>
  7. int main(int argc,char *argv)
  8. {
  9. void *ptr;
  10. ptr = mmap(NULL, 4096, PROT_READ|PROT_WRITE,
  11. MAP_PRIVATE|MAP_ANONYMOUS,
  12. 0, 0);
  13. if(ptr==MAP_FAILED){
  14. perror("mmap");
  15. exit(1);
  16. }else{
  17. printf("mmap returned %p\n",ptr);
  18. exit(0);
  19. }
  20. }