"Fossies" - the Fresh Open Source Software Archive

Member "stress-ng-0.09.56/test/test-posix-madvise.c" (15 Mar 2019, 1755 Bytes) of package /linux/privat/stress-ng-0.09.56.tar.xz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 /*
    2  * Copyright (C) 2013-2019 Canonical, Ltd.
    3  *
    4  * This program is free software; you can redistribute it and/or
    5  * modify it under the terms of the GNU General Public License
    6  * as published by the Free Software Foundation; either version 2
    7  * of the License, or (at your option) any later version.
    8  *
    9  * This program is distributed in the hope that it will be useful,
   10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
   11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   12  * GNU General Public License for more details.
   13  *
   14  * You should have received a copy of the GNU General Public License
   15  * along with this program; if not, write to the Free Software
   16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
   17  *
   18  * This code is a complete clean re-write of the stress tool by
   19  * Colin Ian King <colin.king@canonical.com> and attempts to be
   20  * backwardly compatible with the stress tool by Amos Waterland
   21  * <apw@rossby.metr.ou.edu> but has more stress tests and more
   22  * functionality.
   23  *
   24  */
   25 #include <sys/mman.h>
   26 
   27 static char buffer[8192];
   28 
   29 static const int posix_madvise_options[] = {
   30 #if defined(POSIX_MADV_NORMAL)
   31     POSIX_MADV_NORMAL,
   32 #endif
   33 #if defined(POSIX_MADV_RANDOM)
   34     POSIX_MADV_RANDOM,
   35 #endif
   36 #if defined(POSIX_MADV_SEQUENTIAL)
   37     POSIX_MADV_SEQUENTIAL,
   38 #endif
   39 #if defined(POSIX_MADV_WILLNEED)
   40     POSIX_MADV_WILLNEED,
   41 #endif
   42 #if defined(POSIX_MADV_DONTNEED)
   43     POSIX_MADV_DONTNEED,
   44 #endif
   45 };
   46 
   47 /*
   48  *  The following enum will cause test build failure
   49  *  if there are no madvise options
   50  */
   51 enum {
   52     NO_POSIX_MADVISE_OPTIONS = 1 / sizeof(posix_madvise_options)
   53 };
   54 
   55 int main(void)
   56 {
   57     /* should have at least POSIX_MADV_NORMAL */
   58     return posix_madvise(buffer, sizeof(buffer), POSIX_MADV_NORMAL);
   59 }