1303bf60bSsdebnath /*
2303bf60bSsdebnath * CDDL HEADER START
3303bf60bSsdebnath *
4303bf60bSsdebnath * The contents of this file are subject to the terms of the
5f841f6adSraf * Common Development and Distribution License (the "License").
6f841f6adSraf * You may not use this file except in compliance with the License.
7303bf60bSsdebnath *
8303bf60bSsdebnath * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9303bf60bSsdebnath * or http://www.opensolaris.org/os/licensing.
10303bf60bSsdebnath * See the License for the specific language governing permissions
11303bf60bSsdebnath * and limitations under the License.
12303bf60bSsdebnath *
13303bf60bSsdebnath * When distributing Covered Code, include this CDDL HEADER in each
14303bf60bSsdebnath * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15303bf60bSsdebnath * If applicable, add the following below this CDDL HEADER, with the
16303bf60bSsdebnath * fields enclosed by brackets "[]" replaced with your own identifying
17303bf60bSsdebnath * information: Portions Copyright [yyyy] [name of copyright owner]
18303bf60bSsdebnath *
19303bf60bSsdebnath * CDDL HEADER END
20303bf60bSsdebnath */
21e8031f0aSraf
22303bf60bSsdebnath /*
237257d1b4Sraf * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
24303bf60bSsdebnath * Use is subject to license terms.
25303bf60bSsdebnath */
26303bf60bSsdebnath
277257d1b4Sraf #include "lint.h"
28303bf60bSsdebnath #include <sys/types.h>
29*019c3c43Sraf #include <sys/mman.h>
30*019c3c43Sraf #include <errno.h>
31303bf60bSsdebnath
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 */
40303bf60bSsdebnath int
posix_madvise(void * addr,size_t len,int advice)41*019c3c43Sraf posix_madvise(void *addr, size_t len, int advice)
42303bf60bSsdebnath {
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);
52303bf60bSsdebnath }
53*019c3c43Sraf if (madvise(addr, len, advice) == 0)
54*019c3c43Sraf return (0);
55*019c3c43Sraf return (errno);
56303bf60bSsdebnath }
57