Author: oshogbo
Date: Sat Jul  4 16:33:37 2015
New Revision: 285139
URL: https://svnweb.freebsd.org/changeset/base/285139

Log:
  Move the nvlist source and private includes from sys/kern to seperate
  directory sys/contrib/libnv.
  
  The goal of this operation is to NOT install header files which shouldn't
  be used outside the nvlist library.
  
  Approved by:  pjd (mentor)

Added:
  head/sys/contrib/libnv/
  head/sys/contrib/libnv/dnvlist.c
     - copied, changed from r285138, head/sys/kern/subr_dnvlist.c
  head/sys/contrib/libnv/nv_impl.h
     - copied unchanged from r285128, head/sys/sys/nv_impl.h
  head/sys/contrib/libnv/nvlist.c
     - copied, changed from r285128, head/sys/kern/subr_nvlist.c
  head/sys/contrib/libnv/nvlist_impl.h
     - copied, changed from r285128, head/sys/sys/nvlist_impl.h
  head/sys/contrib/libnv/nvpair.c
     - copied, changed from r285128, head/sys/kern/subr_nvpair.c
  head/sys/contrib/libnv/nvpair_impl.h
     - copied, changed from r285128, head/sys/sys/nvpair_impl.h
Deleted:
  head/sys/kern/subr_dnvlist.c
  head/sys/kern/subr_nvlist.c
  head/sys/kern/subr_nvpair.c
  head/sys/sys/nv_impl.h
  head/sys/sys/nvlist_impl.h
  head/sys/sys/nvpair_impl.h
Modified:
  head/lib/libnv/Makefile
  head/sys/conf/files

Modified: head/lib/libnv/Makefile
==============================================================================
--- head/lib/libnv/Makefile     Sat Jul  4 16:19:38 2015        (r285138)
+++ head/lib/libnv/Makefile     Sat Jul  4 16:33:37 2015        (r285139)
@@ -7,13 +7,13 @@ SHLIBDIR?= /lib
 LIB=   nv
 SHLIB_MAJOR= 0
 
-.PATH: ${.CURDIR}/../../sys/kern ${.CURDIR}/../../sys/sys
+.PATH: ${.CURDIR}/../../sys/contrib/libnv ${.CURDIR}/../../sys/sys
 CFLAGS+=-I${.CURDIR}/../../sys -I${.CURDIR}
 
-SRCS=  subr_dnvlist.c
+SRCS=  dnvlist.c
 SRCS+= msgio.c
-SRCS+= subr_nvlist.c
-SRCS+= subr_nvpair.c
+SRCS+= nvlist.c
+SRCS+= nvpair.c
 
 WARNS?=        6
 

Modified: head/sys/conf/files
==============================================================================
--- head/sys/conf/files Sat Jul  4 16:19:38 2015        (r285138)
+++ head/sys/conf/files Sat Jul  4 16:33:37 2015        (r285139)
@@ -476,6 +476,9 @@ contrib/libfdt/fdt_rw.c             optional fdt
 contrib/libfdt/fdt_strerror.c  optional fdt
 contrib/libfdt/fdt_sw.c                optional fdt
 contrib/libfdt/fdt_wip.c       optional fdt
+contrib/libnv/dnvlist.c                standard
+contrib/libnv/nvlist.c         standard
+contrib/libnv/nvpair.c         standard
 contrib/ngatm/netnatm/api/cc_conn.c optional ngatm_ccatm \
        compile-with "${NORMAL_C_NOWERROR} -I$S/contrib/ngatm"
 contrib/ngatm/netnatm/api/cc_data.c optional ngatm_ccatm \
@@ -3054,7 +3057,6 @@ kern/subr_clock.c         standard
 kern/subr_counter.c            standard
 kern/subr_devstat.c            standard
 kern/subr_disk.c               standard
-kern/subr_dnvlist.c            standard
 kern/subr_eventhandler.c       standard
 kern/subr_fattime.c            standard
 kern/subr_firmware.c           optional firmware
@@ -3068,8 +3070,6 @@ kern/subr_mbpool.c                optional libmbpool
 kern/subr_mchain.c             optional libmchain
 kern/subr_module.c             standard
 kern/subr_msgbuf.c             standard
-kern/subr_nvlist.c             standard
-kern/subr_nvpair.c             standard
 kern/subr_param.c              standard
 kern/subr_pcpu.c               standard
 kern/subr_pctrie.c             standard

Copied and modified: head/sys/contrib/libnv/dnvlist.c (from r285138, 
head/sys/kern/subr_dnvlist.c)
==============================================================================
--- head/sys/kern/subr_dnvlist.c        Sat Jul  4 16:19:38 2015        
(r285138, copy source)
+++ head/sys/contrib/libnv/dnvlist.c    Sat Jul  4 16:33:37 2015        
(r285139)
@@ -47,10 +47,10 @@ __FBSDID("$FreeBSD$");
 #include <stdlib.h>
 #endif
 
+#include <sys/dnv.h>
 #include <sys/nv.h>
-#include <sys/nv_impl.h>
 
-#include <sys/dnv.h>
+#include "nv_impl.h"
 
 #define        DNVLIST_GET(ftype, type)                                        
\
 ftype                                                                  \

Copied: head/sys/contrib/libnv/nv_impl.h (from r285128, head/sys/sys/nv_impl.h)
==============================================================================
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/sys/contrib/libnv/nv_impl.h    Sat Jul  4 16:33:37 2015        
(r285139, copy of r285128, head/sys/sys/nv_impl.h)
@@ -0,0 +1,138 @@
+/*-
+ * Copyright (c) 2013 The FreeBSD Foundation
+ * All rights reserved.
+ *
+ * This software was developed by Pawel Jakub Dawidek under sponsorship from
+ * the FreeBSD Foundation.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#ifndef        _NV_IMPL_H_
+#define        _NV_IMPL_H_
+
+#ifndef        _NVPAIR_T_DECLARED
+#define        _NVPAIR_T_DECLARED
+struct nvpair;
+
+typedef struct nvpair nvpair_t;
+#endif
+
+#define        NV_TYPE_NVLIST_UP               255
+
+#define        NV_TYPE_FIRST                   NV_TYPE_NULL
+#define        NV_TYPE_LAST                    NV_TYPE_BINARY
+
+#define        NV_FLAG_BIG_ENDIAN              0x80
+
+#ifdef _KERNEL
+#define        nv_malloc(size)                 malloc((size), M_NVLIST, 
M_WAITOK)
+#define        nv_calloc(n, size)              malloc((n) * (size), M_NVLIST, \
+                                           M_WAITOK | M_ZERO)
+#define        nv_realloc(buf, size)           realloc((buf), (size), 
M_NVLIST, \
+                                           M_WAITOK)
+#define        nv_free(buf)                    free((buf), M_NVLIST)
+#define        nv_strdup(buf)                  strdup((buf), M_NVLIST)
+#define        nv_vasprintf(ptr, ...)          vasprintf(ptr, M_NVLIST, 
__VA_ARGS__)
+
+#define        ERRNO_SET(var)                  do { } while (0)
+#define        ERRNO_SAVE()                    do { do { } while(0)
+#define        ERRNO_RESTORE()                 } while (0)
+
+#define        ERRNO_OR_DEFAULT(default)       (default)
+
+#else
+
+#define        nv_malloc(size)                 malloc((size))
+#define        nv_calloc(n, size)              calloc((n), (size))
+#define        nv_realloc(buf, size)           realloc((buf), (size))
+#define        nv_free(buf)                    free((buf))
+#define        nv_strdup(buf)                  strdup((buf))
+#define        nv_vasprintf(ptr, ...)          vasprintf(ptr, __VA_ARGS__)
+
+#define        ERRNO_SET(var)                  do { errno = (var); } while (0)
+#define        ERRNO_SAVE()                    do {                            
\
+                                               int _serrno;            \
+                                                                       \
+                                               _serrno = errno
+
+#define        ERRNO_RESTORE()                         errno = _serrno;        
\
+                                       } while (0)
+
+#define        ERRNO_OR_DEFAULT(default)       (errno == 0 ? (default) : errno)
+
+#endif
+
+int    *nvlist_descriptors(const nvlist_t *nvl, size_t *nitemsp);
+size_t  nvlist_ndescriptors(const nvlist_t *nvl);
+
+nvpair_t *nvlist_first_nvpair(const nvlist_t *nvl);
+nvpair_t *nvlist_next_nvpair(const nvlist_t *nvl, const nvpair_t *nvp);
+nvpair_t *nvlist_prev_nvpair(const nvlist_t *nvl, const nvpair_t *nvp);
+
+void nvlist_add_nvpair(nvlist_t *nvl, const nvpair_t *nvp);
+
+void nvlist_move_nvpair(nvlist_t *nvl, nvpair_t *nvp);
+
+void nvlist_set_parent(nvlist_t *nvl, nvpair_t *parent);
+
+const nvpair_t *nvlist_get_nvpair(const nvlist_t *nvl, const char *name);
+
+nvpair_t *nvlist_take_nvpair(nvlist_t *nvl, const char *name);
+
+/* Function removes the given nvpair from the nvlist. */
+void nvlist_remove_nvpair(nvlist_t *nvl, nvpair_t *nvp);
+
+void nvlist_free_nvpair(nvlist_t *nvl, nvpair_t *nvp);
+
+int nvpair_type(const nvpair_t *nvp);
+const char *nvpair_name(const nvpair_t *nvp);
+
+nvpair_t *nvpair_clone(const nvpair_t *nvp);
+
+nvpair_t *nvpair_create_null(const char *name);
+nvpair_t *nvpair_create_bool(const char *name, bool value);
+nvpair_t *nvpair_create_number(const char *name, uint64_t value);
+nvpair_t *nvpair_create_string(const char *name, const char *value);
+nvpair_t *nvpair_create_stringf(const char *name, const char *valuefmt, ...) 
__printflike(2, 3);
+nvpair_t *nvpair_create_stringv(const char *name, const char *valuefmt, 
va_list valueap) __printflike(2, 0);
+nvpair_t *nvpair_create_nvlist(const char *name, const nvlist_t *value);
+nvpair_t *nvpair_create_descriptor(const char *name, int value);
+nvpair_t *nvpair_create_binary(const char *name, const void *value, size_t 
size);
+
+nvpair_t *nvpair_move_string(const char *name, char *value);
+nvpair_t *nvpair_move_nvlist(const char *name, nvlist_t *value);
+nvpair_t *nvpair_move_descriptor(const char *name, int value);
+nvpair_t *nvpair_move_binary(const char *name, void *value, size_t size);
+
+bool            nvpair_get_bool(const nvpair_t *nvp);
+uint64_t        nvpair_get_number(const nvpair_t *nvp);
+const char     *nvpair_get_string(const nvpair_t *nvp);
+const nvlist_t *nvpair_get_nvlist(const nvpair_t *nvp);
+int             nvpair_get_descriptor(const nvpair_t *nvp);
+const void     *nvpair_get_binary(const nvpair_t *nvp, size_t *sizep);
+
+void nvpair_free(nvpair_t *nvp);
+
+#endif /* !_NV_IMPL_H_ */

Copied and modified: head/sys/contrib/libnv/nvlist.c (from r285128, 
head/sys/kern/subr_nvlist.c)
==============================================================================
--- head/sys/kern/subr_nvlist.c Sat Jul  4 08:40:48 2015        (r285128, copy 
source)
+++ head/sys/contrib/libnv/nvlist.c     Sat Jul  4 16:33:37 2015        
(r285139)
@@ -65,9 +65,10 @@ __FBSDID("$FreeBSD$");
 #endif
 
 #include <sys/nv.h>
-#include <sys/nv_impl.h>
-#include <sys/nvlist_impl.h>
-#include <sys/nvpair_impl.h>
+
+#include "nv_impl.h"
+#include "nvlist_impl.h"
+#include "nvpair_impl.h"
 
 #ifndef        HAVE_PJDLOG
 #ifdef _KERNEL

Copied and modified: head/sys/contrib/libnv/nvlist_impl.h (from r285128, 
head/sys/sys/nvlist_impl.h)
==============================================================================
--- head/sys/sys/nvlist_impl.h  Sat Jul  4 08:40:48 2015        (r285128, copy 
source)
+++ head/sys/contrib/libnv/nvlist_impl.h        Sat Jul  4 16:33:37 2015        
(r285139)
@@ -32,12 +32,12 @@
 #ifndef        _NVLIST_IMPL_H_
 #define        _NVLIST_IMPL_H_
 
+#include <sys/nv.h>
+
 #ifndef _KERNEL
 #include <stdint.h>
 #endif
 
-#include "nv.h"
-
 nvpair_t *nvlist_get_nvpair_parent(const nvlist_t *nvl);
 const unsigned char *nvlist_unpack_header(nvlist_t *nvl,
     const unsigned char *ptr, size_t nfds, bool *isbep, size_t *leftp);

Copied and modified: head/sys/contrib/libnv/nvpair.c (from r285128, 
head/sys/kern/subr_nvpair.c)
==============================================================================
--- head/sys/kern/subr_nvpair.c Sat Jul  4 08:40:48 2015        (r285128, copy 
source)
+++ head/sys/contrib/libnv/nvpair.c     Sat Jul  4 16:33:37 2015        
(r285139)
@@ -61,9 +61,10 @@ __FBSDID("$FreeBSD$");
 #endif
 
 #include <sys/nv.h>
-#include <sys/nv_impl.h>
-#include <sys/nvlist_impl.h>
-#include <sys/nvpair_impl.h>
+
+#include "nv_impl.h"
+#include "nvlist_impl.h"
+#include "nvpair_impl.h"
 
 #ifndef        HAVE_PJDLOG
 #ifdef _KERNEL

Copied and modified: head/sys/contrib/libnv/nvpair_impl.h (from r285128, 
head/sys/sys/nvpair_impl.h)
==============================================================================
--- head/sys/sys/nvpair_impl.h  Sat Jul  4 08:40:48 2015        (r285128, copy 
source)
+++ head/sys/contrib/libnv/nvpair_impl.h        Sat Jul  4 16:33:37 2015        
(r285139)
@@ -32,14 +32,13 @@
 #ifndef        _NVPAIR_IMPL_H_
 #define        _NVPAIR_IMPL_H_
 
+#include <sys/nv.h>
 #include <sys/queue.h>
 
 #ifndef _KERNEL
 #include <stdint.h>
 #endif
 
-#include "nv.h"
-
 TAILQ_HEAD(nvl_head, nvpair);
 
 void nvpair_assert(const nvpair_t *nvp);
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to