Home | History | Annotate | Download | only in munmap
      1 /*
      2  * Copyright (c) 2002, Intel Corporation. All rights reserved.
      3  * This file is licensed under the GPL license.  For the full content
      4  * of this license, see the COPYING file at the top level of this
      5  * source tree.
      6  *
      7  * The munmap() function shall fail if:
      8  * [EINVAL] Addresses in the range [addr,addr+len)
      9  * are outside the valid range for the
     10  * address space of a process.
     11  *
     12  */
     13 
     14 #define _XOPEN_SOURCE 600
     15 
     16 #include <pthread.h>
     17 #include <stdio.h>
     18 #include <stdlib.h>
     19 #include <unistd.h>
     20 #include <sys/mman.h>
     21 #include <sys/types.h>
     22 #include <sys/stat.h>
     23 #include <sys/wait.h>
     24 #include <fcntl.h>
     25 #include <string.h>
     26 #include <errno.h>
     27 #include "posixtest.h"
     28 
     29 #define TNAME "munmap/8-1.c"
     30 
     31 int main(void)
     32 {
     33 	int rc;
     34 	void *pa;
     35 
     36 	/* -1 should be an invalid address */
     37 	pa = (void *)-1;
     38 	rc = munmap(pa, 1);
     39 	if (rc == -1 && errno == EINVAL) {
     40 		printf("Got EINVAL\n");
     41 		printf("Test PASSED\n");
     42 		exit(PTS_PASS);
     43 	} else {
     44 		printf("Test FAILED: Expect EINVAL but get: %s\n",
     45 		       strerror(errno));
     46 		return PTS_FAIL;
     47 	}
     48 }
     49