xref: /freebsd/lib/libc/gen/pmadvise.c (revision 95eb4b873b6a8b527c5bd78d7191975dfca38998)
1 /*
2  * The contents of this file are in the public domain.
3  * Written by Garrett A. Wollman, 2000-10-07.
4  *
5  */
6 
7 #include <sys/mman.h>
8 #include <errno.h>
9 
10 int
11 posix_madvise(void *address, size_t size, int how)
12 {
13 	int ret, saved_errno;
14 
15 	saved_errno = errno;
16 	if (madvise(address, size, how) == -1) {
17 		ret = errno;
18 		errno = saved_errno;
19 	} else {
20 		ret = 0;
21 	}
22 	return (ret);
23 }
24