libexplain  1.4.D001
libexplain/buffer/mmap_flags.c
Go to the documentation of this file.
00001 /*
00002  * libexplain - a library of system-call-specific strerror replacements
00003  * Copyright (C) 2010, 2013 Peter Miller
00004  *
00005  * This program is free software; you can redistribute it and/or modify
00006  * it under the terms of the GNU Lesser General Public License as
00007  * published by the Free Software Foundation; either version 3 of the
00008  * License, or (at your option) any later version.
00009  *
00010  * This program is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013  * Lesser General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU Lesser General Public License
00016  * along with this program. If not, see <http://www.gnu.org/licenses/>.
00017  */
00018 
00019 #include <libexplain/ac/sys/mman.h>
00020 
00021 #include <libexplain/buffer/mmap_flags.h>
00022 #include <libexplain/parse_bits.h>
00023 
00024 
00025 static const struct explain_parse_bits_table_t table[] =
00026 {
00027 #ifdef MAP_SHARED
00028     { "MAP_SHARED", MAP_SHARED },
00029 #endif
00030 #ifdef MAP_PRIVATE
00031     { "MAP_PRIVATE", MAP_PRIVATE },
00032 #endif
00033 #ifdef MAP_FIXED
00034     { "MAP_FIXED", MAP_FIXED },
00035 #endif
00036 #ifdef MAP_FILE
00037     { "MAP_FILE", MAP_FILE },
00038 #endif
00039 #ifdef MAP_ANONYMOUS
00040     { "MAP_ANONYMOUS", MAP_ANONYMOUS },
00041 #endif
00042 #ifdef MAP_ANON
00043     { "MAP_ANON", MAP_ANON },
00044 #endif
00045 #ifdef MAP_32BIT
00046     { "MAP_32BIT", MAP_32BIT },
00047 #endif
00048 #ifdef MAP_GROWSDOWN
00049     { "MAP_GROWSDOWN", MAP_GROWSDOWN },
00050 #endif
00051 #ifdef MAP_DENYWRITE
00052     { "MAP_DENYWRITE", MAP_DENYWRITE },
00053 #endif
00054 #ifdef MAP_EXECUTABLE
00055     { "MAP_EXECUTABLE", MAP_EXECUTABLE },
00056 #endif
00057 #ifdef MAP_LOCKED
00058     { "MAP_LOCKED", MAP_LOCKED },
00059 #endif
00060 #ifdef MAP_NORESERVE
00061     { "MAP_NORESERVE", MAP_NORESERVE },
00062 #endif
00063 #ifdef MAP_POPULATE
00064     { "MAP_POPULATE", MAP_POPULATE },
00065 #endif
00066 #ifdef MAP_NONBLOCK
00067     { "MAP_NONBLOCK", MAP_NONBLOCK },
00068 #endif
00069 #ifdef MAP_STACK
00070     { "MAP_STACK", MAP_STACK },
00071 #endif
00072 };
00073 
00074 
00075 void
00076 explain_buffer_mmap_flags(explain_string_buffer_t *sb, int flags)
00077 {
00078     explain_parse_bits_print(sb, flags, table, SIZEOF(table));
00079 }
00080 
00081 
00082 int
00083 explain_parse_mmap_flags_or_die(const char *text, const char *caption)
00084 {
00085     return explain_parse_bits_or_die(text, table, SIZEOF(table), caption);
00086 }
00087 
00088 
00089 /* vim: set ts=8 sw=4 et : */