The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/sys/nv_impl.h

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*-
    2  * Copyright (c) 2013 The FreeBSD Foundation
    3  * All rights reserved.
    4  *
    5  * This software was developed by Pawel Jakub Dawidek under sponsorship from
    6  * the FreeBSD Foundation.
    7  *
    8  * Redistribution and use in source and binary forms, with or without
    9  * modification, are permitted provided that the following conditions
   10  * are met:
   11  * 1. Redistributions of source code must retain the above copyright
   12  *    notice, this list of conditions and the following disclaimer.
   13  * 2. Redistributions in binary form must reproduce the above copyright
   14  *    notice, this list of conditions and the following disclaimer in the
   15  *    documentation and/or other materials provided with the distribution.
   16  *
   17  * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
   18  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   20  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
   21  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   22  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   23  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   24  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   25  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   26  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   27  * SUCH DAMAGE.
   28  *
   29  * $FreeBSD$
   30  */
   31 
   32 #ifndef _NV_IMPL_H_
   33 #define _NV_IMPL_H_
   34 
   35 #ifndef _NVPAIR_T_DECLARED
   36 #define _NVPAIR_T_DECLARED
   37 struct nvpair;
   38 
   39 typedef struct nvpair nvpair_t;
   40 #endif
   41 
   42 #define NV_TYPE_NVLIST_UP               255
   43 
   44 #define NV_TYPE_FIRST           NV_TYPE_NULL
   45 #define NV_TYPE_LAST            NV_TYPE_BINARY
   46 
   47 #define NV_FLAG_BIG_ENDIAN              0x80
   48 
   49 #ifdef _KERNEL
   50 #define nv_malloc(size)                 malloc((size), M_NVLIST, M_NOWAIT)
   51 #define nv_calloc(n, size)              malloc((n) * (size), M_NVLIST, \
   52                                             M_NOWAIT | M_ZERO)
   53 #define nv_realloc(buf, size)           realloc((buf), (size), M_NVLIST, \
   54                                             M_NOWAIT)
   55 #define nv_free(buf)                    free((buf), M_NVLIST)
   56 #define nv_strdup(buf)                  strdup((buf), M_NVLIST)
   57 #define nv_vasprintf(ptr, ...)          vasprintf(ptr, M_NVLIST, __VA_ARGS__)
   58 
   59 #define SAVE_ERRNO(var)                 ((void)(var))
   60 #define RESTORE_ERRNO(var)              ((void)(var))
   61 
   62 #define ERRNO_OR_DEFAULT(default)       (default)
   63 
   64 #else
   65 
   66 #define nv_malloc(size)                 malloc((size))
   67 #define nv_calloc(n, size)              calloc((n), (size))
   68 #define nv_realloc(buf, size)           realloc((buf), (size))
   69 #define nv_free(buf)                    free((buf))
   70 #define nv_strdup(buf)                  strdup((buf))
   71 #define nv_vasprintf(ptr, ...)          vasprintf(ptr, __VA_ARGS__)
   72 
   73 #define SAVE_ERRNO(var)                 (var) = errno
   74 #define RESTORE_ERRNO(var)              errno = (var)
   75 
   76 #define ERRNO_OR_DEFAULT(default)       (errno == 0 ? (default) : errno)
   77 
   78 #endif
   79 
   80 int     *nvlist_descriptors(const nvlist_t *nvl, size_t *nitemsp);
   81 size_t   nvlist_ndescriptors(const nvlist_t *nvl);
   82 
   83 nvpair_t *nvlist_first_nvpair(const nvlist_t *nvl);
   84 nvpair_t *nvlist_next_nvpair(const nvlist_t *nvl, const nvpair_t *nvp);
   85 nvpair_t *nvlist_prev_nvpair(const nvlist_t *nvl, const nvpair_t *nvp);
   86 
   87 void nvlist_add_nvpair(nvlist_t *nvl, const nvpair_t *nvp);
   88 
   89 void nvlist_move_nvpair(nvlist_t *nvl, nvpair_t *nvp);
   90 
   91 void nvlist_set_parent(nvlist_t *nvl, nvpair_t *parent);
   92 
   93 const nvpair_t *nvlist_get_nvpair(const nvlist_t *nvl, const char *name);
   94 
   95 nvpair_t *nvlist_take_nvpair(nvlist_t *nvl, const char *name);
   96 
   97 /* Function removes the given nvpair from the nvlist. */
   98 void nvlist_remove_nvpair(nvlist_t *nvl, nvpair_t *nvp);
   99 
  100 void nvlist_free_nvpair(nvlist_t *nvl, nvpair_t *nvp);
  101 
  102 int nvpair_type(const nvpair_t *nvp);
  103 const char *nvpair_name(const nvpair_t *nvp);
  104 
  105 nvpair_t *nvpair_clone(const nvpair_t *nvp);
  106 
  107 nvpair_t *nvpair_create_null(const char *name);
  108 nvpair_t *nvpair_create_bool(const char *name, bool value);
  109 nvpair_t *nvpair_create_number(const char *name, uint64_t value);
  110 nvpair_t *nvpair_create_string(const char *name, const char *value);
  111 nvpair_t *nvpair_create_stringf(const char *name, const char *valuefmt, ...) __printflike(2, 3);
  112 nvpair_t *nvpair_create_stringv(const char *name, const char *valuefmt, va_list valueap) __printflike(2, 0);
  113 nvpair_t *nvpair_create_nvlist(const char *name, const nvlist_t *value);
  114 nvpair_t *nvpair_create_descriptor(const char *name, int value);
  115 nvpair_t *nvpair_create_binary(const char *name, const void *value, size_t size);
  116 
  117 nvpair_t *nvpair_move_string(const char *name, char *value);
  118 nvpair_t *nvpair_move_nvlist(const char *name, nvlist_t *value);
  119 nvpair_t *nvpair_move_descriptor(const char *name, int value);
  120 nvpair_t *nvpair_move_binary(const char *name, void *value, size_t size);
  121 
  122 bool             nvpair_get_bool(const nvpair_t *nvp);
  123 uint64_t         nvpair_get_number(const nvpair_t *nvp);
  124 const char      *nvpair_get_string(const nvpair_t *nvp);
  125 const nvlist_t  *nvpair_get_nvlist(const nvpair_t *nvp);
  126 int              nvpair_get_descriptor(const nvpair_t *nvp);
  127 const void      *nvpair_get_binary(const nvpair_t *nvp, size_t *sizep);
  128 
  129 void nvpair_free(nvpair_t *nvp);
  130 
  131 #endif  /* !_NV_IMPL_H_ */

Cache object: 9bd49d6ea2f35a5075bc39d4411c5919


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.