1*019c3c43Sraf /*
2*019c3c43Sraf * CDDL HEADER START
3*019c3c43Sraf *
4*019c3c43Sraf * The contents of this file are subject to the terms of the
5*019c3c43Sraf * Common Development and Distribution License (the "License").
6*019c3c43Sraf * You may not use this file except in compliance with the License.
7*019c3c43Sraf *
8*019c3c43Sraf * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*019c3c43Sraf * or http://www.opensolaris.org/os/licensing.
10*019c3c43Sraf * See the License for the specific language governing permissions
11*019c3c43Sraf * and limitations under the License.
12*019c3c43Sraf *
13*019c3c43Sraf * When distributing Covered Code, include this CDDL HEADER in each
14*019c3c43Sraf * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*019c3c43Sraf * If applicable, add the following below this CDDL HEADER, with the
16*019c3c43Sraf * fields enclosed by brackets "[]" replaced with your own identifying
17*019c3c43Sraf * information: Portions Copyright [yyyy] [name of copyright owner]
18*019c3c43Sraf *
19*019c3c43Sraf * CDDL HEADER END
20*019c3c43Sraf */
21*019c3c43Sraf
22*019c3c43Sraf /*
23*019c3c43Sraf * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
24*019c3c43Sraf * Use is subject to license terms.
25*019c3c43Sraf */
26*019c3c43Sraf
27*019c3c43Sraf #include "lint.h"
28*019c3c43Sraf #include <sys/types.h>
29*019c3c43Sraf #include <sys/mman.h>
30*019c3c43Sraf #include <errno.h>
31*019c3c43Sraf
32*019c3c43Sraf /*
33*019c3c43Sraf * SUSv3 - memory advisory information and alignment control
34*019c3c43Sraf *
35*019c3c43Sraf * The POSIX_MADV_* constants below are defined in <sys/mman.h>
36*019c3c43Sraf * to have the same values as the corresponding MADV_* constants,
37*019c3c43Sraf * also defined in <sys/mman.h>, so a direct call to madvise()
38*019c3c43Sraf * can be made here without further ado.
39*019c3c43Sraf */
40*019c3c43Sraf int
posix_madvise(void * addr,size_t len,int advice)41*019c3c43Sraf posix_madvise(void *addr, size_t len, int advice)
42*019c3c43Sraf {
43*019c3c43Sraf switch (advice) {
44*019c3c43Sraf case POSIX_MADV_NORMAL:
45*019c3c43Sraf case POSIX_MADV_SEQUENTIAL:
46*019c3c43Sraf case POSIX_MADV_RANDOM:
47*019c3c43Sraf case POSIX_MADV_WILLNEED:
48*019c3c43Sraf case POSIX_MADV_DONTNEED:
49*019c3c43Sraf break;
50*019c3c43Sraf default:
51*019c3c43Sraf return (EINVAL);
52*019c3c43Sraf }
53*019c3c43Sraf if (madvise(addr, len, advice) == 0)
54*019c3c43Sraf return (0);
55*019c3c43Sraf return (errno);
56*019c3c43Sraf }
57