POSIX_MADVISE(3)           POSIX Programmer's Manual          POSIX_MADVISE(3)



PPRROOLLOOGG
       This manual page is part of the POSIX Programmer's Manual.  The OS
       implementation of this interface may differ (consult the corresponding
       OS manual page for details of OS behavior), or the interface may not be
       implemented on OS.


NNAAMMEE
       posix_madvise -- memory advisory information and alignment control
       (AADDVVAANNCCEEDD RREEAALLTTIIMMEE)

SSYYNNOOPPSSIISS
       #include <sys/mman.h>

       int posix_madvise(void *_a_d_d_r, size_t _l_e_n, int _a_d_v_i_c_e);

DDEESSCCRRIIPPTTIIOONN
       The _p_o_s_i_x___m_a_d_v_i_s_e() function shall advise the implementation on the
       expected behavior of the application with respect to the data in the
       memory starting at address _a_d_d_r, and continuing for _l_e_n bytes. The
       implementation may use this information to optimize handling of the
       specified data. The _p_o_s_i_x___m_a_d_v_i_s_e() function shall have no effect on
       the semantics of access to memory in the specified range, although it
       may affect the performance of access.

       The implementation may require that _a_d_d_r be a multiple of the page
       size, which is the value returned by _s_y_s_c_o_n_f() when the name value
       _SC_PAGESIZE is used.

       The advice to be applied to the memory range is specified by the _a_d_v_i_c_e
       parameter and may be one of the following values:

       POSIX_MADV_NORMAL
             Specifies that the application has no advice to give on its
             behavior with respect to the specified range. It is the default
             characteristic if no advice is given for a range of memory.

       POSIX_MADV_SEQUENTIAL
             Specifies that the application expects to access the specified
             range sequentially from lower addresses to higher addresses.

       POSIX_MADV_RANDOM
             Specifies that the application expects to access the specified
             range in a random order.

       POSIX_MADV_WILLNEED
             Specifies that the application expects to access the specified
             range in the near future.

       POSIX_MADV_DONTNEED
             Specifies that the application expects that it will not access
             the specified range in the near future.

       These values are defined in the _<_s_y_s_/_m_m_a_n_._h_> header.

RREETTUURRNN VVAALLUUEE
       Upon successful completion, _p_o_s_i_x___m_a_d_v_i_s_e() shall return zero;
       otherwise, an error number shall be returned to indicate the error.

EERRRROORRSS
       The _p_o_s_i_x___m_a_d_v_i_s_e() function shall fail if:

       EEIINNVVAALL The value of _a_d_v_i_c_e is invalid.

       EENNOOMMEEMM Addresses in the range starting at _a_d_d_r and continuing for _l_e_n
              bytes are partly or completely outside the range allowed for the
              address space of the calling process.

       The _p_o_s_i_x___m_a_d_v_i_s_e() function may fail if:

       EEIINNVVAALL The value of _a_d_d_r is not a multiple of the value returned by
              _s_y_s_c_o_n_f() when the name value _SC_PAGESIZE is used.

       EEIINNVVAALL The value of _l_e_n is zero.

       _T_h_e _f_o_l_l_o_w_i_n_g _s_e_c_t_i_o_n_s _a_r_e _i_n_f_o_r_m_a_t_i_v_e_.

EEXXAAMMPPLLEESS
       None.

AAPPPPLLIICCAATTIIOONN UUSSAAGGEE
       The _p_o_s_i_x___m_a_d_v_i_s_e() function is part of the Advisory Information option
       and need not be provided on all implementations.

RRAATTIIOONNAALLEE
       None.

FFUUTTUURREE DDIIRREECCTTIIOONNSS
       None.

SSEEEE AALLSSOO
       _m_m_a_p(), _p_o_s_i_x___f_a_d_v_i_s_e(), _s_y_s_c_o_n_f()

       The Base Definitions volume of POSIX.1-2008, <<ssyyss__mmmmaann..hh>>

CCOOPPYYRRIIGGHHTT
       Portions of this text are reprinted and reproduced in electronic form
       from IEEE Std 1003.1, 2013 Edition, Standard for Information Technology
       -- Portable Operating System Interface (POSIX), The Open Group Base
       Specifications Issue 7, Copyright (C) 2013 by the Institute of
       Electrical and Electronics Engineers, Inc and The Open Group.  (This is
       POSIX.1-2008 with the 2013 Technical Corrigendum 1 applied.) In the
       event of any discrepancy between this version and the original IEEE and
       The Open Group Standard, the original IEEE and The Open Group Standard
       is the referee document. The original Standard can be obtained online
       at http://www.unix.org/online.html .

       Any typographical or formatting errors that appear in this page are
       most likely to have been introduced during the conversion of the source
       files to man page format. To report such errors, see
       https://www.kernel.org/doc/man-pages/reporting_bugs.html .



IEEE/The Open Group                  2013                     POSIX_MADVISE(3)
