diff --git a/3RDPARTY b/3RDPARTY index 18999f77..d01c944d 100644 --- a/3RDPARTY +++ b/3RDPARTY @@ -17,5 +17,5 @@ internal use in the code: - libfetch-2.34 from NetBSD (pkgsrc/net/libfetch): lib/fetch -- portableproplib-0.6.2 (lib/portableproplib) from +- portableproplib-0.6.3 (lib/portableproplib) from http://code.google.com/p/portableproplib diff --git a/NEWS b/NEWS index 8c3576a4..b5c427f7 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,7 @@ xbps-0.21 (???): + * Imported Portable proplib 0.6.3 from http://code.google.com/p/portableproplib. + * xbps-query(8): a full dependency tree can now be shown in the show-deps mode, by specifying -x twice (--show-deps), e.g: diff --git a/configure b/configure index 7fbf91ae..1545ddd1 100755 --- a/configure +++ b/configure @@ -495,6 +495,7 @@ if $XCC -lprop _$func.c -o _$func 2>/dev/null; then else PROPLIB=no echo "CPPFLAGS += -I\$(TOPDIR)/lib/portableproplib" >>$CONFIG_MK + echo "CPPFLAGS += -I\$(TOPDIR)/lib/portableproplib/prop" >>$CONFIG_MK echo "LDFLAGS += -lpthread" >>$CONFIG_MK echo "STATIC_LIBS += -lpthread" >>$CONFIG_MK fi diff --git a/lib/portableproplib/prop/prop_array.h b/lib/portableproplib/prop/prop_array.h index 8a2e012e..513299fc 100644 --- a/lib/portableproplib/prop/prop_array.h +++ b/lib/portableproplib/prop/prop_array.h @@ -37,7 +37,10 @@ typedef struct _prop_array *prop_array_t; -__BEGIN_DECLS +#ifdef __cplusplus +extern "C" { +#endif + prop_array_t prop_array_create(void); prop_array_t prop_array_create_with_capacity(unsigned int); @@ -140,6 +143,8 @@ bool prop_array_set_cstring_nocopy(prop_array_t, const char *); bool prop_array_add_and_rel(prop_array_t, prop_object_t); -__END_DECLS +#ifdef __cplusplus +} +#endif #endif /* _PROPLIB_PROP_ARRAY_H_ */ diff --git a/lib/portableproplib/prop/prop_bool.h b/lib/portableproplib/prop/prop_bool.h index c21d28bd..f6b1250d 100644 --- a/lib/portableproplib/prop/prop_bool.h +++ b/lib/portableproplib/prop/prop_bool.h @@ -37,13 +37,19 @@ typedef struct _prop_bool *prop_bool_t; -__BEGIN_DECLS +#ifdef __cplusplus +extern "C" { +#endif + prop_bool_t prop_bool_create(bool); prop_bool_t prop_bool_copy(prop_bool_t); bool prop_bool_true(prop_bool_t); bool prop_bool_equals(prop_bool_t, prop_bool_t); -__END_DECLS + +#ifdef __cplusplus +} +#endif #endif /* _PROPLIB_PROP_BOOL_H_ */ diff --git a/lib/portableproplib/prop/prop_data.h b/lib/portableproplib/prop/prop_data.h index a8976e3f..b2450fda 100644 --- a/lib/portableproplib/prop/prop_data.h +++ b/lib/portableproplib/prop/prop_data.h @@ -38,7 +38,10 @@ typedef struct _prop_data *prop_data_t; -__BEGIN_DECLS +#ifdef __cplusplus +extern "C" { +#endif + prop_data_t prop_data_create_data(const void *, size_t); prop_data_t prop_data_create_data_nocopy(const void *, size_t); @@ -51,6 +54,9 @@ const void * prop_data_data_nocopy(prop_data_t); bool prop_data_equals(prop_data_t, prop_data_t); bool prop_data_equals_data(prop_data_t, const void *, size_t); -__END_DECLS + +#ifdef __cplusplus +} +#endif #endif /* _PROPLIB_PROP_DATA_H_ */ diff --git a/lib/portableproplib/prop/prop_dictionary.h b/lib/portableproplib/prop/prop_dictionary.h index 7890e311..1d506ba9 100644 --- a/lib/portableproplib/prop/prop_dictionary.h +++ b/lib/portableproplib/prop/prop_dictionary.h @@ -39,7 +39,10 @@ typedef struct _prop_dictionary *prop_dictionary_t; typedef struct _prop_dictionary_keysym *prop_dictionary_keysym_t; -__BEGIN_DECLS +#ifdef __cplusplus +extern "C" { +#endif + prop_dictionary_t prop_dictionary_create(void); prop_dictionary_t prop_dictionary_create_with_capacity(unsigned int); @@ -148,6 +151,8 @@ bool prop_dictionary_set_and_rel(prop_dictionary_t, const char *, prop_object_t); -__END_DECLS +#ifdef __cplusplus +} +#endif #endif /* _PROPLIB_PROP_DICTIONARY_H_ */ diff --git a/lib/portableproplib/prop/prop_ingest.h b/lib/portableproplib/prop/prop_ingest.h index b6878a97..fd8f941b 100644 --- a/lib/portableproplib/prop/prop_ingest.h +++ b/lib/portableproplib/prop/prop_ingest.h @@ -72,7 +72,10 @@ typedef struct { #define PROP_INGEST_END \ { .pite_key = NULL } -__BEGIN_DECLS +#ifdef __cplusplus +extern "C" { +#endif + prop_ingest_context_t prop_ingest_context_alloc(void *); void prop_ingest_context_free(prop_ingest_context_t); @@ -86,6 +89,8 @@ void * prop_ingest_context_private(prop_ingest_context_t); bool prop_dictionary_ingest(prop_dictionary_t, const prop_ingest_table_entry[], prop_ingest_context_t); -__END_DECLS +#ifdef __cplusplus +} +#endif #endif /* _PROPLIB_PROP_INGEST_H_ */ diff --git a/lib/portableproplib/prop/prop_number.h b/lib/portableproplib/prop/prop_number.h index 234e0df4..86d16db2 100644 --- a/lib/portableproplib/prop/prop_number.h +++ b/lib/portableproplib/prop/prop_number.h @@ -37,7 +37,10 @@ typedef struct _prop_number *prop_number_t; -__BEGIN_DECLS +#ifdef __cplusplus +extern "C" { +#endif + prop_number_t prop_number_create_integer(int64_t); prop_number_t prop_number_create_unsigned_integer(uint64_t); @@ -52,6 +55,9 @@ uint64_t prop_number_unsigned_integer_value(prop_number_t); bool prop_number_equals(prop_number_t, prop_number_t); bool prop_number_equals_integer(prop_number_t, int64_t); bool prop_number_equals_unsigned_integer(prop_number_t, uint64_t); -__END_DECLS + +#ifdef __cplusplus +} +#endif #endif /* _PROPLIB_PROP_NUMBER_H_ */ diff --git a/lib/portableproplib/prop/prop_object.h b/lib/portableproplib/prop/prop_object.h index 82f9c061..ce6229a5 100644 --- a/lib/portableproplib/prop/prop_object.h +++ b/lib/portableproplib/prop/prop_object.h @@ -48,7 +48,10 @@ typedef enum { PROP_TYPE_DICT_KEYSYM = 0x646b6579 /* 'dkey' */ } prop_type_t; -__BEGIN_DECLS +#ifdef __cplusplus +extern "C" { +#endif + void prop_object_retain(prop_object_t); void prop_object_release(prop_object_t); @@ -62,6 +65,9 @@ typedef struct _prop_object_iterator *prop_object_iterator_t; prop_object_t prop_object_iterator_next(prop_object_iterator_t); void prop_object_iterator_reset(prop_object_iterator_t); void prop_object_iterator_release(prop_object_iterator_t); -__END_DECLS + +#ifdef __cplusplus +} +#endif #endif /* _PROPLIB_PROP_OBJECT_H_ */ diff --git a/lib/portableproplib/prop/prop_string.h b/lib/portableproplib/prop/prop_string.h index b5f04765..1a56ea56 100644 --- a/lib/portableproplib/prop/prop_string.h +++ b/lib/portableproplib/prop/prop_string.h @@ -38,7 +38,10 @@ typedef struct _prop_string *prop_string_t; -__BEGIN_DECLS +#ifdef __cplusplus +extern "C" { +#endif + prop_string_t prop_string_create(void); prop_string_t prop_string_create_cstring(const char *); prop_string_t prop_string_create_cstring_nocopy(const char *); @@ -57,6 +60,9 @@ bool prop_string_append_cstring(prop_string_t, const char *); bool prop_string_equals(prop_string_t, prop_string_t); bool prop_string_equals_cstring(prop_string_t, const char *); -__END_DECLS + +#ifdef __cplusplus +} +#endif #endif /* _PROPLIB_PROP_STRING_H_ */ diff --git a/lib/portableproplib/prop/rbtree.h b/lib/portableproplib/prop/rbtree.h index 349d7062..298cc412 100644 --- a/lib/portableproplib/prop/rbtree.h +++ b/lib/portableproplib/prop/rbtree.h @@ -39,10 +39,16 @@ #include #include #endif -#include -#include #include +/* GCC version checking borrowed from glibc. */ +#if defined(__GNUC__) && defined(__GNUC_MINOR__) +# define __GNUC_PREREQ(maj,min) \ + ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min)) +#else +# define __GNUC_PREREQ(maj,min) 0 +#endif + #if __GNUC_PREREQ(2, 96) # ifndef __predict_true # define __predict_true(exp) __builtin_expect((exp), 1) @@ -59,7 +65,9 @@ # endif #endif -__BEGIN_DECLS +#ifdef __cplusplus +extern "C" { +#endif typedef struct rb_node { struct rb_node *rb_nodes[2]; @@ -207,6 +215,8 @@ void rb_tree_check(const rb_tree_t *, bool); void rb_tree_depths(const rb_tree_t *, size_t *); #endif -__END_DECLS +#ifdef __cplusplus +extern "C" { +#endif #endif /* _SYS_RBTREE_H_*/ diff --git a/lib/portableproplib/prop_array.c b/lib/portableproplib/prop_array.c index 3baa1d92..565418b1 100644 --- a/lib/portableproplib/prop_array.c +++ b/lib/portableproplib/prop_array.c @@ -31,10 +31,7 @@ #include #include "prop_object_impl.h" - -#if !defined(_KERNEL) && !defined(_STANDALONE) #include -#endif struct _prop_array { struct _prop_object pa_obj; @@ -50,8 +47,6 @@ struct _prop_array { #define PA_F_IMMUTABLE 0x01 /* array is immutable */ _PROP_POOL_INIT(_prop_array_pool, sizeof(struct _prop_array), "proparay") -_PROP_MALLOC_DEFINE(M_PROP_ARRAY, "prop array", - "property array container object") static _prop_object_free_rv_t _prop_array_free(prop_stack_t, prop_object_t *); @@ -340,7 +335,7 @@ static prop_object_t _prop_array_iterator_next_object(void *v) { struct _prop_array_iterator *pai = v; - prop_array_t pa __unused = pai->pai_base.pi_obj; + prop_array_t pa = pai->pai_base.pi_obj; prop_object_t po; _PROP_ASSERT(prop_object_is_array(pa)); @@ -367,7 +362,7 @@ static void _prop_array_iterator_reset(void *v) { struct _prop_array_iterator *pai = v; - prop_array_t pa __unused = pai->pai_base.pi_obj; + prop_array_t pa = pai->pai_base.pi_obj; _PROP_ASSERT(prop_object_is_array(pa)); @@ -865,7 +860,6 @@ prop_array_internalize(const char *xml) return _prop_generic_internalize(xml, "array"); } -#if !defined(_KERNEL) && !defined(_STANDALONE) /* * prop_array_externalize_to_file -- * Externalize an array to the specified file. @@ -908,4 +902,3 @@ prop_array_internalize_from_file(const char *fname) return (array); } -#endif /* _KERNEL && !_STANDALONE */ diff --git a/lib/portableproplib/prop_data.c b/lib/portableproplib/prop_data.c index da07fd2e..abb7b18d 100644 --- a/lib/portableproplib/prop_data.c +++ b/lib/portableproplib/prop_data.c @@ -52,9 +52,6 @@ struct _prop_data { _PROP_POOL_INIT(_prop_data_pool, sizeof(struct _prop_data), "propdata") -_PROP_MALLOC_DEFINE(M_PROP_DATA, "prop data", - "property data container object") - static _prop_object_free_rv_t _prop_data_free(prop_stack_t, prop_object_t *); static bool _prop_data_externalize( diff --git a/lib/portableproplib/prop_dictionary.c b/lib/portableproplib/prop_dictionary.c index 40db81d0..8b329fbb 100644 --- a/lib/portableproplib/prop_dictionary.c +++ b/lib/portableproplib/prop_dictionary.c @@ -35,9 +35,7 @@ #include "prop_object_impl.h" #include "prop_rb_impl.h" -#if !defined(_KERNEL) && !defined(_STANDALONE) #include -#endif /* * We implement these like arrays, but we keep them sorted by key. @@ -97,8 +95,6 @@ struct _prop_dictionary { _PROP_POOL_INIT(_prop_dictionary_pool, sizeof(struct _prop_dictionary), "propdict") -_PROP_MALLOC_DEFINE(M_PROP_DICT, "prop dictionary", - "property dictionary container object") static _prop_object_free_rv_t _prop_dictionary_free(prop_stack_t, prop_object_t *); @@ -173,7 +169,7 @@ struct _prop_dictionary_iterator { static int /*ARGSUSED*/ -_prop_dict_keysym_rb_compare_nodes(void *ctx __unused, +_prop_dict_keysym_rb_compare_nodes(void *ctx, const void *n1, const void *n2) { const struct _prop_dictionary_keysym *pdk1 = n1; @@ -184,7 +180,7 @@ _prop_dict_keysym_rb_compare_nodes(void *ctx __unused, static int /*ARGSUSED*/ -_prop_dict_keysym_rb_compare_key(void *ctx __unused, +_prop_dict_keysym_rb_compare_key(void *ctx, const void *n, const void *v) { const struct _prop_dictionary_keysym *pdk = n; @@ -628,7 +624,7 @@ static prop_object_t _prop_dictionary_iterator_next_object(void *v) { struct _prop_dictionary_iterator *pdi = v; - prop_dictionary_t pd __unused = pdi->pdi_base.pi_obj; + prop_dictionary_t pd = pdi->pdi_base.pi_obj; prop_dictionary_keysym_t pdk; _PROP_ASSERT(prop_object_is_dictionary(pd)); @@ -655,7 +651,7 @@ static void _prop_dictionary_iterator_reset(void *v) { struct _prop_dictionary_iterator *pdi = v; - prop_dictionary_t pd __unused = pdi->pdi_base.pi_obj; + prop_dictionary_t pd = pdi->pdi_base.pi_obj; _PROP_RWLOCK_RDLOCK(pd->pd_rwlock); _prop_dictionary_iterator_reset_locked(pdi); @@ -1374,7 +1370,6 @@ prop_dictionary_internalize(const char *xml) return _prop_generic_internalize(xml, "dict"); } -#if !defined(_KERNEL) && !defined(_STANDALONE) /* * prop_dictionary_externalize_to_file -- * Externalize a dictionary to the specified file. @@ -1418,4 +1413,3 @@ prop_dictionary_internalize_from_file(const char *fname) return (dict); } -#endif /* !_KERNEL && !_STANDALONE */ diff --git a/lib/portableproplib/prop_number.c b/lib/portableproplib/prop_number.c index 03f88228..ab3013aa 100644 --- a/lib/portableproplib/prop_number.c +++ b/lib/portableproplib/prop_number.c @@ -33,15 +33,8 @@ #include "prop_object_impl.h" #include "prop_rb_impl.h" -#if defined(_KERNEL) -#include -#elif defined(_STANDALONE) -#include -#include -#else #include #include -#endif struct _prop_number { struct _prop_object pn_obj; @@ -119,7 +112,7 @@ _prop_number_compare_values(const struct _prop_number_value *pnv1, static int /*ARGSUSED*/ -_prop_number_rb_compare_nodes(void *ctx __unused, +_prop_number_rb_compare_nodes(void *ctx, const void *n1, const void *n2) { const struct _prop_number *pn1 = n1; @@ -130,7 +123,7 @@ _prop_number_rb_compare_nodes(void *ctx __unused, static int /*ARGSUSED*/ -_prop_number_rb_compare_key(void *ctx __unused, const void *n, const void *v) +_prop_number_rb_compare_key(void *ctx, const void *n, const void *v) { const struct _prop_number *pn = n; const struct _prop_number_value *pnv = v; @@ -511,14 +504,11 @@ _prop_number_internalize_unsigned(struct _prop_object_internalize_context *ctx, _PROP_ASSERT(/*CONSTCOND*/sizeof(unsigned long long) == sizeof(uint64_t)); -#ifndef _KERNEL errno = 0; -#endif pnv->pnv_unsigned = (uint64_t) strtoull(ctx->poic_cp, &cp, 0); -#ifndef _KERNEL /* XXX can't check for ERANGE in the kernel */ if (pnv->pnv_unsigned == UINT64_MAX && errno == ERANGE) return (false); -#endif + pnv->pnv_is_unsigned = true; ctx->poic_cp = cp; @@ -533,15 +523,12 @@ _prop_number_internalize_signed(struct _prop_object_internalize_context *ctx, _PROP_ASSERT(/*CONSTCOND*/sizeof(long long) == sizeof(int64_t)); -#ifndef _KERNEL errno = 0; -#endif pnv->pnv_signed = (int64_t) strtoll(ctx->poic_cp, &cp, 0); -#ifndef _KERNEL /* XXX can't check for ERANGE in the kernel */ if ((pnv->pnv_signed == INT64_MAX || pnv->pnv_signed == INT64_MIN) && errno == ERANGE) return (false); -#endif + pnv->pnv_is_unsigned = false; ctx->poic_cp = cp; diff --git a/lib/portableproplib/prop_object.c b/lib/portableproplib/prop_object.c index 3a7caef8..ec764530 100644 --- a/lib/portableproplib/prop_object.c +++ b/lib/portableproplib/prop_object.c @@ -29,6 +29,9 @@ * POSSIBILITY OF SUCH DAMAGE. */ +#include +#include "prop_object_impl.h" + #include #include #include @@ -37,9 +40,6 @@ #include #include -#include -#include "prop_object_impl.h" - /* * _prop_object_init -- @@ -61,7 +61,7 @@ _prop_object_init(struct _prop_object *po, const struct _prop_object_type *pot) */ /*ARGSUSED*/ void -_prop_object_fini(struct _prop_object *po _PROP_ARG_UNUSED) +_prop_object_fini(struct _prop_object *po) { /* Nothing to do, currently. */ } @@ -812,10 +812,7 @@ _prop_object_externalize_write_file(const char *fname, const char *xml, size_t len, bool do_compress) { gzFile gzf = NULL; - char tname[PATH_MAX]; -#ifndef HAVE_STRLCAT - char *otname; -#endif + char tname[PATH_MAX], *otname; int fd; int save_errno; mode_t myumask; diff --git a/lib/portableproplib/prop_object_impl.h b/lib/portableproplib/prop_object_impl.h index 8be821f5..65b1739a 100644 --- a/lib/portableproplib/prop_object_impl.h +++ b/lib/portableproplib/prop_object_impl.h @@ -32,12 +32,7 @@ #ifndef _PROPLIB_PROP_OBJECT_IMPL_H_ #define _PROPLIB_PROP_OBJECT_IMPL_H_ -#if defined(_KERNEL) || defined(_STANDALONE) -#include -#else #include -#endif - #include "prop_stack.h" struct _prop_object_externalize_context { @@ -147,7 +142,6 @@ struct _prop_object_internalize_context * void _prop_object_internalize_context_free( struct _prop_object_internalize_context *); -#if !defined(_KERNEL) && !defined(_STANDALONE) bool _prop_object_externalize_write_file(const char *, const char *, size_t, bool); @@ -160,7 +154,6 @@ struct _prop_object_internalize_mapped_file * _prop_object_internalize_map_file(const char *); void _prop_object_internalize_unmap_file( struct _prop_object_internalize_mapped_file *); -#endif /* !_KERNEL && !_STANDALONE */ typedef bool (*prop_object_internalizer_t)(prop_stack_t, prop_object_t *, struct _prop_object_internalize_context *); @@ -231,110 +224,6 @@ struct _prop_object_iterator { 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) - -#if defined(_KERNEL) - -/* - * proplib in the kernel... - */ - -#include -#include -#include -#include -#include -#include - -#define _PROP_ASSERT(x) KASSERT(x) - -#define _PROP_MALLOC(s, t) malloc((s), (t), M_WAITOK) -#define _PROP_CALLOC(s, t) malloc((s), (t), M_WAITOK | M_ZERO) -#define _PROP_REALLOC(v, s, t) realloc((v), (s), (t), M_WAITOK) -#define _PROP_FREE(v, t) free((v), (t)) - -#define _PROP_POOL_GET(p) pool_get(&(p), PR_WAITOK) -#define _PROP_POOL_PUT(p, v) pool_put(&(p), (v)) - -struct prop_pool_init { - struct pool *pp; - size_t size; - const char *wchan; -}; -#define _PROP_POOL_INIT(pp, size, wchan) \ -struct pool pp; \ -static const struct prop_pool_init _link_ ## pp[1] = { \ - { &pp, size, wchan } \ -}; \ -__link_set_add_rodata(prop_linkpools, _link_ ## pp); - -#define _PROP_MALLOC_DEFINE(t, s, l) \ - MALLOC_DEFINE(t, s, l); - -#define _PROP_MUTEX_DECL_STATIC(x) static kmutex_t x; -#define _PROP_MUTEX_INIT(x) mutex_init(&(x),MUTEX_DEFAULT,IPL_NONE) -#define _PROP_MUTEX_LOCK(x) mutex_enter(&(x)) -#define _PROP_MUTEX_UNLOCK(x) mutex_exit(&(x)) - -#define _PROP_RWLOCK_DECL(x) krwlock_t x ; -#define _PROP_RWLOCK_INIT(x) rw_init(&(x)) -#define _PROP_RWLOCK_RDLOCK(x) rw_enter(&(x), RW_READER) -#define _PROP_RWLOCK_WRLOCK(x) rw_enter(&(x), RW_WRITER) -#define _PROP_RWLOCK_UNLOCK(x) rw_exit(&(x)) -#define _PROP_RWLOCK_DESTROY(x) rw_destroy(&(x)) - -#define _PROP_ONCE_DECL(x) static ONCE_DECL(x); -#define _PROP_ONCE_RUN(x,f) RUN_ONCE(&(x), f) - -#elif defined(_STANDALONE) - -/* - * proplib in a standalone environment... - */ - -#include - -void * _prop_standalone_calloc(size_t); -void * _prop_standalone_realloc(void *, size_t); - -#define _PROP_ASSERT(x) /* nothing */ - -#define _PROP_MALLOC(s, t) alloc((s)) -#define _PROP_CALLOC(s, t) _prop_standalone_calloc((s)) -#define _PROP_REALLOC(v, s, t) _prop_standalone_realloc((v), (s)) -#define _PROP_FREE(v, t) dealloc((v), 0) /* XXX */ - -#define _PROP_POOL_GET(p) alloc((p)) -#define _PROP_POOL_PUT(p, v) dealloc((v), (p)) - -#define _PROP_POOL_INIT(p, s, d) static const size_t p = s; - -#define _PROP_MALLOC_DEFINE(t, s, l) /* nothing */ - -#define _PROP_MUTEX_DECL_STATIC(x) /* nothing */ -#define _PROP_MUTEX_INIT(x) /* nothing */ -#define _PROP_MUTEX_LOCK(x) /* nothing */ -#define _PROP_MUTEX_UNLOCK(x) /* nothing */ - -#define _PROP_RWLOCK_DECL(x) /* nothing */ -#define _PROP_RWLOCK_INIT(x) /* nothing */ -#define _PROP_RWLOCK_RDLOCK(x) /* nothing */ -#define _PROP_RWLOCK_WRLOCK(x) /* nothing */ -#define _PROP_RWLOCK_UNLOCK(x) /* nothing */ -#define _PROP_RWLOCK_DESTROY(x) /* nothing */ - -#define _PROP_ONCE_DECL(x) _PROP_NOTHREAD_ONCE_DECL(x) -#define _PROP_ONCE_RUN(x,f) _PROP_NOTHREAD_ONCE_RUN(x,f) - -#else - /* * proplib in user space... */ @@ -357,49 +246,6 @@ void * _prop_standalone_realloc(void *, size_t); #define _PROP_POOL_INIT(p, s, d) static const size_t p = s; -#define _PROP_MALLOC_DEFINE(t, s, l) /* nothing */ - -#if defined(__NetBSD__) && defined(_LIBPROP) -/* - * Use the same mechanism as libc; we get pthread mutexes for threaded - * programs and do-nothing stubs for non-threaded programs. - */ -#include "reentrant.h" -#define _PROP_MUTEX_DECL_STATIC(x) static mutex_t x; -#define _PROP_MUTEX_INIT(x) mutex_init(&(x), NULL) -#define _PROP_MUTEX_LOCK(x) mutex_lock(&(x)) -#define _PROP_MUTEX_UNLOCK(x) mutex_unlock(&(x)) - -#define _PROP_RWLOCK_DECL(x) rwlock_t x ; -#define _PROP_RWLOCK_INIT(x) rwlock_init(&(x), NULL) -#define _PROP_RWLOCK_RDLOCK(x) rwlock_rdlock(&(x)) -#define _PROP_RWLOCK_WRLOCK(x) rwlock_wrlock(&(x)) -#define _PROP_RWLOCK_UNLOCK(x) rwlock_unlock(&(x)) -#define _PROP_RWLOCK_DESTROY(x) rwlock_destroy(&(x)) - -#define _PROP_ONCE_DECL(x) \ - static pthread_once_t x = PTHREAD_ONCE_INIT; -#define _PROP_ONCE_RUN(x,f) thr_once(&(x), (void(*)(void))f); - -#elif defined(HAVE_NBTOOL_CONFIG_H) -/* - * None of NetBSD's build tools are multi-threaded. - */ -#define _PROP_MUTEX_DECL_STATIC(x) /* nothing */ -#define _PROP_MUTEX_INIT(x) /* nothing */ -#define _PROP_MUTEX_LOCK(x) /* nothing */ -#define _PROP_MUTEX_UNLOCK(x) /* nothing */ - -#define _PROP_RWLOCK_DECL(x) /* nothing */ -#define _PROP_RWLOCK_INIT(x) /* nothing */ -#define _PROP_RWLOCK_RDLOCK(x) /* nothing */ -#define _PROP_RWLOCK_WRLOCK(x) /* nothing */ -#define _PROP_RWLOCK_UNLOCK(x) /* nothing */ -#define _PROP_RWLOCK_DESTROY(x) /* nothing */ - -#define _PROP_ONCE_DECL(x) _PROP_NOTHREAD_ONCE_DECL(x) -#define _PROP_ONCE_RUN(x,f) _PROP_NOTHREAD_ONCE_RUN(x,f) -#else /* * Use pthread mutexes everywhere else. */ @@ -419,21 +265,5 @@ void * _prop_standalone_realloc(void *, size_t); #define _PROP_ONCE_DECL(x) \ static pthread_once_t x = PTHREAD_ONCE_INIT; #define _PROP_ONCE_RUN(x,f) pthread_once(&(x),(void(*)(void))f) -#endif - -#endif /* _KERNEL */ - -/* - * Language features. - */ -#if defined(__NetBSD__) -#include -#define _PROP_ARG_UNUSED __unused -#else -#ifndef __unused -#define __unused /* delete */ -#endif -#define _PROP_ARG_UNUSED /* delete */ -#endif /* __NetBSD__ */ #endif /* _PROPLIB_PROP_OBJECT_IMPL_H_ */ diff --git a/lib/portableproplib/prop_rb_impl.h b/lib/portableproplib/prop_rb_impl.h index ae1df338..54e064ac 100644 --- a/lib/portableproplib/prop_rb_impl.h +++ b/lib/portableproplib/prop_rb_impl.h @@ -32,11 +32,7 @@ #ifndef _PROP_RB_IMPL_H_ #define _PROP_RB_IMPL_H_ -#ifdef __NetBSD__ -#include -#else -#include -#endif +#include /* * Define local names for common rb_tree functions. diff --git a/lib/portableproplib/prop_string.c b/lib/portableproplib/prop_string.c index 4f9ed886..6daddbd6 100644 --- a/lib/portableproplib/prop_string.c +++ b/lib/portableproplib/prop_string.c @@ -48,8 +48,6 @@ struct _prop_string { _PROP_POOL_INIT(_prop_string_pool, sizeof(struct _prop_string), "propstng") -_PROP_MALLOC_DEFINE(M_PROP_STRING, "prop string", - "property string container object") static _prop_object_free_rv_t _prop_string_free(prop_stack_t, prop_object_t *); diff --git a/lib/portableproplib/prop_zlib.c b/lib/portableproplib/prop_zlib.c index 1f5c0e70..f764eee4 100644 --- a/lib/portableproplib/prop_zlib.c +++ b/lib/portableproplib/prop_zlib.c @@ -31,7 +31,7 @@ #define _READ_CHUNK 8192 -#define TEMPLATE(type) \ +#define TEMPLATE(type, objtype) \ bool \ prop ## type ## _externalize_to_zfile(prop ## type ## _t obj, const char *fname) \ { \ @@ -56,7 +56,7 @@ prop ## type ## _t \ prop ## type ## _internalize_from_zfile(const char *fname) \ { \ struct _prop_object_internalize_mapped_file *mf; \ - prop ## type ## _t obj; \ + prop ## type ## _t obj = NULL; \ z_stream strm; \ unsigned char *out; \ char *uncomp_xml = NULL; \ @@ -68,19 +68,21 @@ prop ## type ## _internalize_from_zfile(const char *fname) \ if (mf == NULL) \ return NULL; \ \ + /* If it's an ordinary uncompressed plist we are done */ \ + obj = prop ## type ## _internalize(mf->poimf_xml); \ + if (prop_object_type(obj) == PROP_TYPE_## objtype) \ + goto out; \ + \ /* Output buffer (uncompressed) */ \ uncomp_xml = _PROP_MALLOC(_READ_CHUNK, M_TEMP); \ - if (uncomp_xml == NULL) { \ - _prop_object_internalize_unmap_file(mf); \ - return NULL; \ - } \ + if (uncomp_xml == NULL) \ + goto out; \ \ /* temporary output buffer for inflate */ \ out = _PROP_MALLOC(_READ_CHUNK, M_TEMP); \ if (out == NULL) { \ _PROP_FREE(uncomp_xml, M_TEMP); \ - _prop_object_internalize_unmap_file(mf); \ - return NULL; \ + goto out; \ } \ \ /* Decompress the mmap'ed buffer with zlib */ \ @@ -91,12 +93,9 @@ prop ## type ## _internalize_from_zfile(const char *fname) \ strm.next_in = Z_NULL; \ \ /* 15+16 to use gzip method */ \ - if (inflateInit2(&strm, 15+16) != Z_OK) { \ - _PROP_FREE(out, M_TEMP); \ - _PROP_FREE(uncomp_xml, M_TEMP); \ - _prop_object_internalize_unmap_file(mf); \ - return NULL; \ - } \ + if (inflateInit2(&strm, 15+16) != Z_OK) \ + goto out2; \ + \ strm.avail_in = mf->poimf_mapsize; \ strm.next_in = (unsigned char *)mf->poimf_xml; \ \ @@ -107,22 +106,11 @@ prop ## type ## _internalize_from_zfile(const char *fname) \ rv = inflate(&strm, Z_NO_FLUSH); \ switch (rv) { \ case Z_DATA_ERROR: \ - /* Wrong compressed data or uncompressed, try normal method. */ \ - (void)inflateEnd(&strm); \ - _PROP_FREE(out, M_TEMP); \ - _PROP_FREE(uncomp_xml, M_TEMP); \ - obj = prop ## type ## _internalize(mf->poimf_xml); \ - _prop_object_internalize_unmap_file(mf); \ - return obj; \ case Z_STREAM_ERROR: \ case Z_NEED_DICT: \ case Z_MEM_ERROR: \ - (void)inflateEnd(&strm); \ - _PROP_FREE(out, M_TEMP); \ - _PROP_FREE(uncomp_xml, M_TEMP); \ - _prop_object_internalize_unmap_file(mf); \ - errno = rv; \ - return NULL; \ + errno = EINVAL; \ + goto out1; \ } \ have = _READ_CHUNK - strm.avail_out; \ totalsize += have; \ @@ -131,16 +119,19 @@ prop ## type ## _internalize_from_zfile(const char *fname) \ } while (strm.avail_out == 0); \ \ /* we are done */ \ +out2: \ (void)inflateEnd(&strm); \ +out1: \ obj = prop ## type ## _internalize(uncomp_xml); \ _PROP_FREE(out, M_TEMP); \ _PROP_FREE(uncomp_xml, M_TEMP); \ +out: \ _prop_object_internalize_unmap_file(mf); \ \ return obj; \ } -TEMPLATE(_array) -TEMPLATE(_dictionary) +TEMPLATE(_array, ARRAY) +TEMPLATE(_dictionary, DICTIONARY) #undef TEMPLATE diff --git a/lib/portableproplib/rb.c b/lib/portableproplib/rb.c index 8a6f3ed5..8be152a2 100644 --- a/lib/portableproplib/rb.c +++ b/lib/portableproplib/rb.c @@ -29,7 +29,6 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#if !defined(_KERNEL) && !defined(_STANDALONE) #include #include #include @@ -39,30 +38,11 @@ #else #define KASSERT(s) do { } while (/*CONSTCOND*/ 0) #endif -#else -#include -#endif - -#ifdef _LIBC -__weak_alias(rb_tree_init, _rb_tree_init) -__weak_alias(rb_tree_find_node, _rb_tree_find_node) -__weak_alias(rb_tree_find_node_geq, _rb_tree_find_node_geq) -__weak_alias(rb_tree_find_node_leq, _rb_tree_find_node_leq) -__weak_alias(rb_tree_insert_node, _rb_tree_insert_node) -__weak_alias(rb_tree_remove_node, _rb_tree_remove_node) -__weak_alias(rb_tree_iterate, _rb_tree_iterate) -#ifdef RBDEBUG -__weak_alias(rb_tree_check, _rb_tree_check) -__weak_alias(rb_tree_depths, _rb_tree_depths) -#endif - -#include "namespace.h" -#endif #ifdef RBTEST #include "rbtree.h" #else -#include +#include #endif static void rb_tree_insert_rebalance(struct rb_tree *, struct rb_node *);