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 15 #include <pthread.h> 16 #include <stdio.h> 17 #include <stdlib.h> 18 #include <unistd.h> 19 #include <sys/mman.h> 20 #include <sys/types.h> 21 #include <sys/stat.h> 22 #include <sys/wait.h> 23 #include <fcntl.h> 24 #include <string.h> 25 #include <errno.h> 26 #include "posixtest.h" 27 28 #define TNAME "munmap/8-1.c" 29 main(void)30int main(void) 31 { 32 int rc; 33 void *pa; 34 35 /* -1 should be an invalid address */ 36 pa = (void *)-1; 37 rc = munmap(pa, 1); 38 if (rc == -1 && errno == EINVAL) { 39 printf("Got EINVAL\n"); 40 printf("Test PASSED\n"); 41 exit(PTS_PASS); 42 } else { 43 printf("Test FAILED: Expect EINVAL but get: %s\n", 44 strerror(errno)); 45 return PTS_FAIL; 46 } 47 } 48