xref: /freebsd/lib/libc/gen/pmadvise.c (revision 1843dfb05ed80149f5a412180af882e3cb8f451b)
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/cdefs.h>
8 #include <sys/mman.h>
9 #include <errno.h>
10 
11 int
12 posix_madvise(void *address, size_t size, int how)
13 {
14 	int ret, saved_errno;
15 
16 	saved_errno = errno;
17 	if (madvise(address, size, how) == -1) {
18 		ret = errno;
19 		errno = saved_errno;
20 	} else {
21 		ret = 0;
22 	}
23 	return (ret);
24 }
25