Imported portableproplib-0.6.4.

This commit is contained in:
Juan RP
2014-05-17 20:25:14 +02:00
parent a3f2898ea6
commit cafbca06e7
12 changed files with 117 additions and 104 deletions

View File

@ -17,5 +17,5 @@ internal use in the code:
- libfetch-2.34 from NetBSD (pkgsrc/net/libfetch): lib/fetch - libfetch-2.34 from NetBSD (pkgsrc/net/libfetch): lib/fetch
- portableproplib-0.6.3 (lib/portableproplib) from - portableproplib-0.6.4 (lib/portableproplib) from
http://code.google.com/p/portableproplib https://github.com/xtraeme/portableproplib

2
NEWS
View File

@ -1,5 +1,7 @@
xbps-0.37 (???): xbps-0.37 (???):
* Imported portable proplib 0.6.4 from https://github.com/xtraeme/portableproplib.
* Fixed a new issue with virtual packages, if a pkg provides a virtual package * Fixed a new issue with virtual packages, if a pkg provides a virtual package
that is already installed but with lesser version, do not update to it that is already installed but with lesser version, do not update to it
unnecessarily (in some cases results in a crash). unnecessarily (in some cases results in a crash).

View File

@ -15,7 +15,7 @@ LIBPROP_OBJS += portableproplib/prop_array_util.o portableproplib/prop_number.o
LIBPROP_OBJS += portableproplib/prop_dictionary_util.o portableproplib/prop_zlib.o LIBPROP_OBJS += portableproplib/prop_dictionary_util.o portableproplib/prop_zlib.o
LIBPROP_OBJS += portableproplib/prop_data.o LIBPROP_OBJS += portableproplib/prop_data.o
LIBPROP_CPPFLAGS = -D_GNU_SOURCE LIBPROP_CPPFLAGS = -D_GNU_SOURCE
LIBPROP_CFLAGS = -Wno-old-style-definition -Wno-cast-qual -Wno-unused-parameter LIBPROP_CFLAGS = -Wno-old-style-definition -Wno-cast-qual -Wno-unused-parameter -Wno-unused-but-set-variable
LIBPROP_CFLAGS += -fvisibility=hidden LIBPROP_CFLAGS += -fvisibility=hidden
# libfetch # libfetch

View File

@ -1,4 +1,4 @@
/* $NetBSD: prop_array.c,v 1.20 2008/08/11 05:54:21 christos Exp $ */ /* $NetBSD: prop_array.c,v 1.21 2012/07/27 09:10:59 pooka Exp $ */
/*- /*-
* Copyright (c) 2006, 2007 The NetBSD Foundation, Inc. * Copyright (c) 2006, 2007 The NetBSD Foundation, Inc.
@ -29,8 +29,9 @@
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
*/ */
#include <prop/prop_array.h>
#include "prop_object_impl.h" #include "prop_object_impl.h"
#include <prop/prop_array.h>
#include <errno.h> #include <errno.h>
struct _prop_array { struct _prop_array {
@ -107,8 +108,6 @@ _prop_array_free(prop_stack_t stack, prop_object_t *obj)
return (_PROP_OBJECT_FREE_DONE); return (_PROP_OBJECT_FREE_DONE);
} }
if (pa->pa_array == NULL)
return _PROP_OBJECT_FREE_DONE;
po = pa->pa_array[pa->pa_count - 1]; po = pa->pa_array[pa->pa_count - 1];
_PROP_ASSERT(po != NULL); _PROP_ASSERT(po != NULL);
@ -337,7 +336,7 @@ static prop_object_t
_prop_array_iterator_next_object(void *v) _prop_array_iterator_next_object(void *v)
{ {
struct _prop_array_iterator *pai = v; struct _prop_array_iterator *pai = v;
prop_array_t pa = pai->pai_base.pi_obj; prop_array_t pa _PROP_ARG_UNUSED = pai->pai_base.pi_obj;
prop_object_t po; prop_object_t po;
_PROP_ASSERT(prop_object_is_array(pa)); _PROP_ASSERT(prop_object_is_array(pa));
@ -364,7 +363,7 @@ static void
_prop_array_iterator_reset(void *v) _prop_array_iterator_reset(void *v)
{ {
struct _prop_array_iterator *pai = v; struct _prop_array_iterator *pai = v;
prop_array_t pa = pai->pai_base.pi_obj; prop_array_t pa _PROP_ARG_UNUSED = pai->pai_base.pi_obj;
_PROP_ASSERT(prop_object_is_array(pa)); _PROP_ASSERT(prop_object_is_array(pa));

View File

@ -1,4 +1,4 @@
/* $NetBSD: prop_array_util.c,v 1.2 2008/09/11 13:15:13 haad Exp $ */ /* $NetBSD: prop_array_util.c,v 1.4 2012/07/27 09:10:59 pooka Exp $ */
/*- /*-
* Copyright (c) 2006 The NetBSD Foundation, Inc. * Copyright (c) 2006 The NetBSD Foundation, Inc.
@ -38,8 +38,8 @@
* exactly what we're doing here. * exactly what we're doing here.
*/ */
#include "prop_object_impl.h" /* hide kernel vs. not-kernel vs. standalone */
#include <prop/proplib.h> #include <prop/proplib.h>
#include "prop_object_impl.h"
bool bool
prop_array_get_bool(prop_array_t array, prop_array_get_bool(prop_array_t array,

View File

@ -1,4 +1,4 @@
/* $NetBSD: prop_dictionary.c,v 1.37 2011/04/20 19:40:00 martin Exp $ */ /* $NetBSD: prop_dictionary.c,v 1.39 2013/10/18 18:26:20 martin Exp $ */
/*- /*-
* Copyright (c) 2006, 2007 The NetBSD Foundation, Inc. * Copyright (c) 2006, 2007 The NetBSD Foundation, Inc.
@ -29,10 +29,10 @@
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
*/ */
#include "prop_object_impl.h"
#include <prop/prop_array.h> #include <prop/prop_array.h>
#include <prop/prop_dictionary.h> #include <prop/prop_dictionary.h>
#include <prop/prop_string.h> #include <prop/prop_string.h>
#include "prop_object_impl.h"
#include "prop_rb_impl.h" #include "prop_rb_impl.h"
#include <errno.h> #include <errno.h>
@ -169,7 +169,7 @@ struct _prop_dictionary_iterator {
static int static int
/*ARGSUSED*/ /*ARGSUSED*/
_prop_dict_keysym_rb_compare_nodes(void *ctx, _prop_dict_keysym_rb_compare_nodes(void *ctx _PROP_ARG_UNUSED,
const void *n1, const void *n2) const void *n1, const void *n2)
{ {
const struct _prop_dictionary_keysym *pdk1 = n1; const struct _prop_dictionary_keysym *pdk1 = n1;
@ -180,7 +180,7 @@ _prop_dict_keysym_rb_compare_nodes(void *ctx,
static int static int
/*ARGSUSED*/ /*ARGSUSED*/
_prop_dict_keysym_rb_compare_key(void *ctx, _prop_dict_keysym_rb_compare_key(void *ctx _PROP_ARG_UNUSED,
const void *n, const void *v) const void *n, const void *v)
{ {
const struct _prop_dictionary_keysym *pdk = n; const struct _prop_dictionary_keysym *pdk = n;
@ -278,10 +278,7 @@ _prop_dict_keysym_equals(prop_object_t v1, prop_object_t v2,
static prop_dictionary_keysym_t static prop_dictionary_keysym_t
_prop_dict_keysym_alloc(const char *key) _prop_dict_keysym_alloc(const char *key)
{ {
#ifdef DEBUG prop_dictionary_keysym_t opdk, pdk, rpdk;
prop_dictionary_keysym_t rpdk;
#endif
prop_dictionary_keysym_t opdk, pdk;
size_t size; size_t size;
_PROP_ONCE_RUN(_prop_dict_init_once, _prop_dict_init); _PROP_ONCE_RUN(_prop_dict_init_once, _prop_dict_init);
@ -334,12 +331,10 @@ _prop_dict_keysym_alloc(const char *key)
_prop_dict_keysym_put(pdk); _prop_dict_keysym_put(pdk);
return (opdk); return (opdk);
} }
#ifdef DEBUG
rpdk = _prop_rb_tree_insert_node(&_prop_dict_keysym_tree, pdk); rpdk = _prop_rb_tree_insert_node(&_prop_dict_keysym_tree, pdk);
_PROP_ASSERT(rpdk == pdk); _PROP_ASSERT(rpdk == pdk);
#endif
_PROP_MUTEX_UNLOCK(_prop_dict_keysym_tree_mutex); _PROP_MUTEX_UNLOCK(_prop_dict_keysym_tree_mutex);
return (pdk); return (rpdk);
} }
static _prop_object_free_rv_t static _prop_object_free_rv_t
@ -364,8 +359,6 @@ _prop_dictionary_free(prop_stack_t stack, prop_object_t *obj)
return (_PROP_OBJECT_FREE_DONE); return (_PROP_OBJECT_FREE_DONE);
} }
if (pd->pd_array == NULL)
return _PROP_OBJECT_FREE_DONE;
po = pd->pd_array[pd->pd_count - 1].pde_objref; po = pd->pd_array[pd->pd_count - 1].pde_objref;
_PROP_ASSERT(po != NULL); _PROP_ASSERT(po != NULL);
@ -631,7 +624,7 @@ static prop_object_t
_prop_dictionary_iterator_next_object(void *v) _prop_dictionary_iterator_next_object(void *v)
{ {
struct _prop_dictionary_iterator *pdi = v; struct _prop_dictionary_iterator *pdi = v;
prop_dictionary_t pd = pdi->pdi_base.pi_obj; prop_dictionary_t pd _PROP_ARG_UNUSED = pdi->pdi_base.pi_obj;
prop_dictionary_keysym_t pdk; prop_dictionary_keysym_t pdk;
_PROP_ASSERT(prop_object_is_dictionary(pd)); _PROP_ASSERT(prop_object_is_dictionary(pd));
@ -658,7 +651,7 @@ static void
_prop_dictionary_iterator_reset(void *v) _prop_dictionary_iterator_reset(void *v)
{ {
struct _prop_dictionary_iterator *pdi = v; struct _prop_dictionary_iterator *pdi = v;
prop_dictionary_t pd = pdi->pdi_base.pi_obj; prop_dictionary_t pd _PROP_ARG_UNUSED = pdi->pdi_base.pi_obj;
_PROP_RWLOCK_RDLOCK(pd->pd_rwlock); _PROP_RWLOCK_RDLOCK(pd->pd_rwlock);
_prop_dictionary_iterator_reset_locked(pdi); _prop_dictionary_iterator_reset_locked(pdi);
@ -1391,8 +1384,7 @@ prop_dictionary_externalize_to_file(prop_dictionary_t dict, const char *fname)
xml = prop_dictionary_externalize(dict); xml = prop_dictionary_externalize(dict);
if (xml == NULL) if (xml == NULL)
return (false); return (false);
rv = _prop_object_externalize_write_file(fname, xml, strlen(xml), rv = _prop_object_externalize_write_file(fname, xml, strlen(xml), false);
false);
if (rv == false) if (rv == false)
save_errno = errno; save_errno = errno;
_PROP_FREE(xml, M_TEMP); _PROP_FREE(xml, M_TEMP);

View File

@ -1,4 +1,4 @@
/* $NetBSD: prop_ingest.c,v 1.3 2008/04/28 20:22:53 martin Exp $ */ /* $NetBSD: prop_ingest.c,v 1.4 2012/07/27 09:10:59 pooka Exp $ */
/*- /*-
* Copyright (c) 2006 The NetBSD Foundation, Inc. * Copyright (c) 2006 The NetBSD Foundation, Inc.
@ -29,8 +29,8 @@
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
*/ */
#include <prop/proplib.h>
#include "prop_object_impl.h" #include "prop_object_impl.h"
#include <prop/proplib.h>
struct _prop_ingest_context { struct _prop_ingest_context {
prop_ingest_error_t pic_error; prop_ingest_error_t pic_error;

View File

@ -1,4 +1,4 @@
/* $NetBSD: prop_number.c,v 1.23 2010/09/24 22:51:52 rmind Exp $ */ /* $NetBSD: prop_number.c,v 1.26 2014/03/26 18:12:46 christos Exp $ */
/*- /*-
* Copyright (c) 2006 The NetBSD Foundation, Inc. * Copyright (c) 2006 The NetBSD Foundation, Inc.
@ -112,7 +112,7 @@ _prop_number_compare_values(const struct _prop_number_value *pnv1,
static int static int
/*ARGSUSED*/ /*ARGSUSED*/
_prop_number_rb_compare_nodes(void *ctx, _prop_number_rb_compare_nodes(void *ctx _PROP_ARG_UNUSED,
const void *n1, const void *n2) const void *n1, const void *n2)
{ {
const struct _prop_number *pn1 = n1; const struct _prop_number *pn1 = n1;
@ -123,7 +123,8 @@ _prop_number_rb_compare_nodes(void *ctx,
static int static int
/*ARGSUSED*/ /*ARGSUSED*/
_prop_number_rb_compare_key(void *ctx, const void *n, const void *v) _prop_number_rb_compare_key(void *ctx _PROP_ARG_UNUSED,
const void *n, const void *v)
{ {
const struct _prop_number *pn = n; const struct _prop_number *pn = n;
const struct _prop_number_value *pnv = v; const struct _prop_number_value *pnv = v;
@ -187,15 +188,15 @@ _prop_number_externalize(struct _prop_object_externalize_context *ctx,
char tmpstr[32]; char tmpstr[32];
/* /*
* For the record: * For unsigned numbers, we output in hex. For signed numbers,
* the original NetBSD implementation used hexadecimal for unsigned * we output in decimal.
* numbers, but in the portable proplib we changed it to be human
* readable (base 10).
*/ */
if (pn->pn_value.pnv_is_unsigned) if (pn->pn_value.pnv_is_unsigned)
sprintf(tmpstr, "%" PRIu64, pn->pn_value.pnv_unsigned); snprintf(tmpstr, sizeof(tmpstr), "%" PRIu64,
pn->pn_value.pnv_unsigned);
else else
sprintf(tmpstr, "%" PRIi64, pn->pn_value.pnv_signed); snprintf(tmpstr, sizeof(tmpstr), "%" PRIi64,
pn->pn_value.pnv_signed);
if (_prop_object_externalize_start_tag(ctx, "integer") == false || if (_prop_object_externalize_start_tag(ctx, "integer") == false ||
_prop_object_externalize_append_cstring(ctx, tmpstr) == false || _prop_object_externalize_append_cstring(ctx, tmpstr) == false ||
@ -264,10 +265,7 @@ _prop_number_equals(prop_object_t v1, prop_object_t v2,
static prop_number_t static prop_number_t
_prop_number_alloc(const struct _prop_number_value *pnv) _prop_number_alloc(const struct _prop_number_value *pnv)
{ {
#ifdef DEBUG prop_number_t opn, pn, rpn;
prop_number_t rpn;
#endif
prop_number_t opn, pn;
_PROP_ONCE_RUN(_prop_number_init_once, _prop_number_init); _PROP_ONCE_RUN(_prop_number_init_once, _prop_number_init);
@ -308,12 +306,10 @@ _prop_number_alloc(const struct _prop_number_value *pnv)
_PROP_POOL_PUT(_prop_number_pool, pn); _PROP_POOL_PUT(_prop_number_pool, pn);
return (opn); return (opn);
} }
#ifdef DEBUG
rpn = _prop_rb_tree_insert_node(&_prop_number_tree, pn); rpn = _prop_rb_tree_insert_node(&_prop_number_tree, pn);
_PROP_ASSERT(rpn == pn); _PROP_ASSERT(rpn == pn);
#endif
_PROP_MUTEX_UNLOCK(_prop_number_tree_mutex); _PROP_MUTEX_UNLOCK(_prop_number_tree_mutex);
return (pn); return (rpn);
} }
/* /*

View File

@ -1,4 +1,4 @@
/* $NetBSD: prop_object.c,v 1.23 2008/11/30 00:17:07 haad Exp $ */ /* $NetBSD: prop_object.c,v 1.29 2013/10/18 18:26:20 martin Exp $ */
/*- /*-
* Copyright (c) 2006, 2007 The NetBSD Foundation, Inc. * Copyright (c) 2006, 2007 The NetBSD Foundation, Inc.
@ -29,10 +29,16 @@
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
*/ */
#include "compat.h" #ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <prop/prop_object.h>
#include "prop_object_impl.h" #include "prop_object_impl.h"
#include <prop/prop_object.h>
#ifdef _PROP_NEED_REFCNT_MTX
static pthread_mutex_t _prop_refcnt_mtx = PTHREAD_MUTEX_INITIALIZER;
#endif /* _PROP_NEED_REFCNT_MTX */
#include <sys/mman.h> #include <sys/mman.h>
#include <sys/stat.h> #include <sys/stat.h>
@ -40,7 +46,6 @@
#include <fcntl.h> #include <fcntl.h>
#include <limits.h> #include <limits.h>
#include <unistd.h> #include <unistd.h>
#include <zlib.h> #include <zlib.h>
/* /*
@ -63,7 +68,7 @@ _prop_object_init(struct _prop_object *po, const struct _prop_object_type *pot)
*/ */
/*ARGSUSED*/ /*ARGSUSED*/
void void
_prop_object_fini(struct _prop_object *po) _prop_object_fini(struct _prop_object *po _PROP_ARG_UNUSED)
{ {
/* Nothing to do, currently. */ /* Nothing to do, currently. */
} }
@ -252,10 +257,8 @@ _prop_object_externalize_footer(struct _prop_object_externalize_context *ctx)
{ {
if (_prop_object_externalize_end_tag(ctx, "plist") == false || if (_prop_object_externalize_end_tag(ctx, "plist") == false ||
_prop_object_externalize_append_char(ctx, '\0') == false) { _prop_object_externalize_append_char(ctx, '\0') == false)
free(ctx->poec_buf);
return (false); return (false);
}
return (true); return (true);
} }
@ -602,7 +605,7 @@ match_start:
poi->poi_taglen)) poi->poi_taglen))
break; break;
} }
if (poi == NULL) { if ((poi == NULL) || (poi->poi_tag == NULL)) {
while (_prop_stack_pop(&stack, &obj, &iter, &data, NULL)) { while (_prop_stack_pop(&stack, &obj, &iter, &data, NULL)) {
iter_func = (prop_object_internalizer_continue_t)iter; iter_func = (prop_object_internalizer_continue_t)iter;
(*iter_func)(&stack, &obj, ctx, data, NULL); (*iter_func)(&stack, &obj, ctx, data, NULL);
@ -831,11 +834,14 @@ _prop_object_externalize_write_file(const char *fname, const char *xml,
* and create the temporary file. * and create the temporary file.
*/ */
_prop_object_externalize_file_dirname(fname, tname); _prop_object_externalize_file_dirname(fname, tname);
#define PLISTTMP "/.plistXXXXXX"
if (strlcat(tname, "/.plistXXXXXX", sizeof(tname)) >= sizeof(tname)) { if (strlen(tname) + strlen(PLISTTMP) >= sizeof(tname)) {
errno = ENAMETOOLONG; errno = ENAMETOOLONG;
return (false); return (false);
} }
strcat(tname, PLISTTMP);
#undef PLISTTMP
if ((fd = mkstemp(tname)) == -1) if ((fd = mkstemp(tname)) == -1)
return (false); return (false);
@ -869,6 +875,7 @@ _prop_object_externalize_write_file(const char *fname, const char *xml,
(void)gzclose(gzf); (void)gzclose(gzf);
else else
(void)close(fd); (void)close(fd);
fd = -1; fd = -1;
if (rename(tname, fname) == -1) if (rename(tname, fname) == -1)
@ -970,24 +977,6 @@ _prop_object_internalize_unmap_file(
_PROP_FREE(mf, M_TEMP); _PROP_FREE(mf, M_TEMP);
} }
/*
* Retain / release serialization --
*
* Eventually we would like to use atomic operations. But until we have
* an MI API for them that is common to userland and the kernel, we will
* use a lock instead.
*
* We use a single global mutex for all serialization. In the kernel, because
* we are still under a biglock, this will basically never contend (properties
* cannot be manipulated at interrupt level). In userland, this will cost
* nothing for single-threaded programs. For multi-threaded programs, there
* could be contention, but it probably won't cost that much unless the program
* makes heavy use of property lists.
*/
_PROP_MUTEX_DECL_STATIC(_prop_refcnt_mutex)
#define _PROP_REFCNT_LOCK() _PROP_MUTEX_LOCK(_prop_refcnt_mutex)
#define _PROP_REFCNT_UNLOCK() _PROP_MUTEX_UNLOCK(_prop_refcnt_mutex)
/* /*
* prop_object_retain -- * prop_object_retain --
* Increment the reference count on an object. * Increment the reference count on an object.
@ -995,18 +984,11 @@ _PROP_MUTEX_DECL_STATIC(_prop_refcnt_mutex)
void void
prop_object_retain(prop_object_t obj) prop_object_retain(prop_object_t obj)
{ {
#ifdef DEBUG
uint32_t ocnt;
#endif
struct _prop_object *po = obj; struct _prop_object *po = obj;
uint32_t ncnt _PROP_ARG_UNUSED;
_PROP_REFCNT_LOCK(); _PROP_ATOMIC_INC32_NV(&po->po_refcnt, ncnt);
po->po_refcnt++; _PROP_ASSERT(ncnt != 0);
#ifdef DEBUG
ocnt = po->po_refcnt;
_PROP_ASSERT(ocnt != 0xffffffffU);
#endif
_PROP_REFCNT_UNLOCK();
} }
/* /*
@ -1036,11 +1018,11 @@ prop_object_release_emergency(prop_object_t obj)
/* Save pointerto unlock function */ /* Save pointerto unlock function */
unlock = po->po_type->pot_unlock; unlock = po->po_type->pot_unlock;
_PROP_REFCNT_LOCK(); /* Dance a bit to make sure we always get the non-racy ocnt */
ocnt = po->po_refcnt--; _PROP_ATOMIC_DEC32_NV(&po->po_refcnt, ocnt);
_PROP_REFCNT_UNLOCK(); ocnt++;
_PROP_ASSERT(ocnt != 0); _PROP_ASSERT(ocnt != 0);
if (ocnt != 1) { if (ocnt != 1) {
if (unlock != NULL) if (unlock != NULL)
unlock(); unlock();
@ -1059,9 +1041,7 @@ prop_object_release_emergency(prop_object_t obj)
unlock(); unlock();
parent = po; parent = po;
_PROP_REFCNT_LOCK(); _PROP_ATOMIC_INC32(&po->po_refcnt);
++po->po_refcnt;
_PROP_REFCNT_UNLOCK();
} }
_PROP_ASSERT(parent); _PROP_ASSERT(parent);
/* One object was just freed. */ /* One object was just freed. */
@ -1098,11 +1078,10 @@ prop_object_release(prop_object_t obj)
/* Save pointer to object unlock function */ /* Save pointer to object unlock function */
unlock = po->po_type->pot_unlock; unlock = po->po_type->pot_unlock;
_PROP_REFCNT_LOCK(); _PROP_ATOMIC_DEC32_NV(&po->po_refcnt, ocnt);
ocnt = po->po_refcnt--; ocnt++;
_PROP_REFCNT_UNLOCK();
_PROP_ASSERT(ocnt != 0); _PROP_ASSERT(ocnt != 0);
if (ocnt != 1) { if (ocnt != 1) {
ret = 0; ret = 0;
if (unlock != NULL) if (unlock != NULL)
@ -1118,9 +1097,7 @@ prop_object_release(prop_object_t obj)
if (ret == _PROP_OBJECT_FREE_DONE) if (ret == _PROP_OBJECT_FREE_DONE)
break; break;
_PROP_REFCNT_LOCK(); _PROP_ATOMIC_INC32(&po->po_refcnt);
++po->po_refcnt;
_PROP_REFCNT_UNLOCK();
} while (ret == _PROP_OBJECT_FREE_RECURSE); } while (ret == _PROP_OBJECT_FREE_RECURSE);
if (ret == _PROP_OBJECT_FREE_FAILED) if (ret == _PROP_OBJECT_FREE_FAILED)
prop_object_release_emergency(obj); prop_object_release_emergency(obj);
@ -1187,6 +1164,7 @@ prop_object_equals_with_error(prop_object_t obj1, prop_object_t obj2,
&stored_pointer1, &stored_pointer2)) &stored_pointer1, &stored_pointer2))
return true; return true;
po1 = obj1; po1 = obj1;
po2 = obj2;
goto continue_subtree; goto continue_subtree;
} }
_PROP_ASSERT(ret == _PROP_OBJECT_EQUALS_RECURSE); _PROP_ASSERT(ret == _PROP_OBJECT_EQUALS_RECURSE);

View File

@ -1,4 +1,4 @@
/* $NetBSD: prop_object_impl.h,v 1.30 2009/09/13 18:45:10 pooka Exp $ */ /* $NetBSD: prop_object_impl.h,v 1.31 2012/07/27 09:10:59 pooka Exp $ */
/*- /*-
* Copyright (c) 2006 The NetBSD Foundation, Inc. * Copyright (c) 2006 The NetBSD Foundation, Inc.
@ -224,6 +224,15 @@ struct _prop_object_iterator {
uint32_t pi_version; uint32_t pi_version;
}; };
#define _PROP_NOTHREAD_ONCE_DECL(x) static bool x = false;
#define _PROP_NOTHREAD_ONCE_RUN(x,f) \
do { \
if ((x) == false) { \
f(); \
x = true; \
} \
} while (/*CONSTCOND*/0)
/* /*
* proplib in user space... * proplib in user space...
*/ */
@ -246,6 +255,8 @@ struct _prop_object_iterator {
#define _PROP_POOL_INIT(p, s, d) static const size_t p = s; #define _PROP_POOL_INIT(p, s, d) static const size_t p = s;
#define _PROP_MALLOC_DEFINE(t, s, l) /* nothing */
/* /*
* Use pthread mutexes everywhere else. * Use pthread mutexes everywhere else.
*/ */
@ -266,4 +277,39 @@ struct _prop_object_iterator {
static pthread_once_t x = PTHREAD_ONCE_INIT; static pthread_once_t x = PTHREAD_ONCE_INIT;
#define _PROP_ONCE_RUN(x,f) pthread_once(&(x),(void(*)(void))f) #define _PROP_ONCE_RUN(x,f) pthread_once(&(x),(void(*)(void))f)
#define _PROP_NEED_REFCNT_MTX
#define _PROP_ATOMIC_INC32(x) \
do { \
pthread_mutex_lock(&_prop_refcnt_mtx); \
(*(x))++; \
pthread_mutex_unlock(&_prop_refcnt_mtx); \
} while (/*CONSTCOND*/0)
#define _PROP_ATOMIC_DEC32(x) \
do { \
pthread_mutex_lock(&_prop_refcnt_mtx); \
(*(x))--; \
pthread_mutex_unlock(&_prop_refcnt_mtx); \
} while (/*CONSTCOND*/0)
#define _PROP_ATOMIC_INC32_NV(x, v) \
do { \
pthread_mutex_lock(&_prop_refcnt_mtx); \
v = ++(*(x)); \
pthread_mutex_unlock(&_prop_refcnt_mtx); \
} while (/*CONSTCOND*/0)
#define _PROP_ATOMIC_DEC32_NV(x, v) \
do { \
pthread_mutex_lock(&_prop_refcnt_mtx); \
v = --(*(x)); \
pthread_mutex_unlock(&_prop_refcnt_mtx); \
} while (/*CONSTCOND*/0)
/*
* Language features.
*/
#define _PROP_ARG_UNUSED /* delete */
#endif /* _PROPLIB_PROP_OBJECT_IMPL_H_ */ #endif /* _PROPLIB_PROP_OBJECT_IMPL_H_ */

View File

@ -1,4 +1,4 @@
/* $NetBSD: prop_string.c,v 1.11 2008/08/03 04:00:12 thorpej Exp $ */ /* $NetBSD: prop_string.c,v 1.12 2014/03/26 18:12:46 christos Exp $ */
/*- /*-
* Copyright (c) 2006 The NetBSD Foundation, Inc. * Copyright (c) 2006 The NetBSD Foundation, Inc.
@ -337,7 +337,7 @@ prop_string_append(prop_string_t dst, prop_string_t src)
cp = _PROP_MALLOC(len + 1, M_PROP_STRING); cp = _PROP_MALLOC(len + 1, M_PROP_STRING);
if (cp == NULL) if (cp == NULL)
return (false); return (false);
sprintf(cp, "%s%s", prop_string_contents(dst), snprintf(cp, len + 1, "%s%s", prop_string_contents(dst),
prop_string_contents(src)); prop_string_contents(src));
ocp = dst->ps_mutable; ocp = dst->ps_mutable;
dst->ps_mutable = cp; dst->ps_mutable = cp;
@ -371,7 +371,7 @@ prop_string_append_cstring(prop_string_t dst, const char *src)
cp = _PROP_MALLOC(len + 1, M_PROP_STRING); cp = _PROP_MALLOC(len + 1, M_PROP_STRING);
if (cp == NULL) if (cp == NULL)
return (false); return (false);
sprintf(cp, "%s%s", prop_string_contents(dst), src); snprintf(cp, len + 1, "%s%s", prop_string_contents(dst), src);
ocp = dst->ps_mutable; ocp = dst->ps_mutable;
dst->ps_mutable = cp; dst->ps_mutable = cp;
dst->ps_size = len; dst->ps_size = len;

View File

@ -69,7 +69,7 @@ rb_tree_init(struct rb_tree *rbt, const rb_tree_ops_t *ops)
{ {
rbt->rbt_ops = ops; rbt->rbt_ops = ops;
*((const struct rb_node **)&rbt->rbt_root) = RB_SENTINEL_NODE; rbt->rbt_root = RB_SENTINEL_NODE;
RB_TAILQ_INIT(&rbt->rbt_nodes); RB_TAILQ_INIT(&rbt->rbt_nodes);
#ifndef RBSMALL #ifndef RBSMALL
rbt->rbt_minmax[RB_DIR_LEFT] = rbt->rbt_root; /* minimum node */ rbt->rbt_minmax[RB_DIR_LEFT] = rbt->rbt_root; /* minimum node */