mmap.c 442 B

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