Home | History | Annotate | Line # | Download | only in libprop
prop_object_impl.h revision 1.15.4.2
      1  1.15.4.2  ad /*	$NetBSD: prop_object_impl.h,v 1.15.4.2 2007/07/29 11:25:02 ad Exp $	*/
      2  1.15.4.2  ad 
      3  1.15.4.2  ad /*-
      4  1.15.4.2  ad  * Copyright (c) 2006 The NetBSD Foundation, Inc.
      5  1.15.4.2  ad  * All rights reserved.
      6  1.15.4.2  ad  *
      7  1.15.4.2  ad  * This code is derived from software contributed to The NetBSD Foundation
      8  1.15.4.2  ad  * by Jason R. Thorpe.
      9  1.15.4.2  ad  *
     10  1.15.4.2  ad  * Redistribution and use in source and binary forms, with or without
     11  1.15.4.2  ad  * modification, are permitted provided that the following conditions
     12  1.15.4.2  ad  * are met:
     13  1.15.4.2  ad  * 1. Redistributions of source code must retain the above copyright
     14  1.15.4.2  ad  *    notice, this list of conditions and the following disclaimer.
     15  1.15.4.2  ad  * 2. Redistributions in binary form must reproduce the above copyright
     16  1.15.4.2  ad  *    notice, this list of conditions and the following disclaimer in the
     17  1.15.4.2  ad  *    documentation and/or other materials provided with the distribution.
     18  1.15.4.2  ad  * 3. All advertising materials mentioning features or use of this software
     19  1.15.4.2  ad  *    must display the following acknowledgement:
     20  1.15.4.2  ad  *      This product includes software developed by the NetBSD
     21  1.15.4.2  ad  *      Foundation, Inc. and its contributors.
     22  1.15.4.2  ad  * 4. Neither the name of The NetBSD Foundation nor the names of its
     23  1.15.4.2  ad  *    contributors may be used to endorse or promote products derived
     24  1.15.4.2  ad  *    from this software without specific prior written permission.
     25  1.15.4.2  ad  *
     26  1.15.4.2  ad  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     27  1.15.4.2  ad  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     28  1.15.4.2  ad  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     29  1.15.4.2  ad  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     30  1.15.4.2  ad  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     31  1.15.4.2  ad  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     32  1.15.4.2  ad  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     33  1.15.4.2  ad  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     34  1.15.4.2  ad  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     35  1.15.4.2  ad  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     36  1.15.4.2  ad  * POSSIBILITY OF SUCH DAMAGE.
     37  1.15.4.2  ad  */
     38  1.15.4.2  ad 
     39  1.15.4.2  ad #ifndef _PROPLIB_PROP_OBJECT_IMPL_H_
     40  1.15.4.2  ad #define	_PROPLIB_PROP_OBJECT_IMPL_H_
     41  1.15.4.2  ad 
     42  1.15.4.2  ad #if defined(_KERNEL) || defined(_STANDALONE)
     43  1.15.4.2  ad #include <lib/libkern/libkern.h>
     44  1.15.4.2  ad #else
     45  1.15.4.2  ad #include <inttypes.h>
     46  1.15.4.2  ad #endif
     47  1.15.4.2  ad 
     48  1.15.4.2  ad struct _prop_object_externalize_context {
     49  1.15.4.2  ad 	char *		poec_buf;		/* string buffer */
     50  1.15.4.2  ad 	size_t		poec_capacity;		/* capacity of buffer */
     51  1.15.4.2  ad 	size_t		poec_len;		/* current length of string */
     52  1.15.4.2  ad 	unsigned int	poec_depth;		/* nesting depth */
     53  1.15.4.2  ad };
     54  1.15.4.2  ad 
     55  1.15.4.2  ad boolean_t	_prop_object_externalize_start_tag(
     56  1.15.4.2  ad 				struct _prop_object_externalize_context *,
     57  1.15.4.2  ad 				const char *);
     58  1.15.4.2  ad boolean_t	_prop_object_externalize_end_tag(
     59  1.15.4.2  ad 				struct _prop_object_externalize_context *,
     60  1.15.4.2  ad 				const char *);
     61  1.15.4.2  ad boolean_t	_prop_object_externalize_empty_tag(
     62  1.15.4.2  ad 				struct _prop_object_externalize_context *,
     63  1.15.4.2  ad 				const char *);
     64  1.15.4.2  ad boolean_t	_prop_object_externalize_append_cstring(
     65  1.15.4.2  ad 				struct _prop_object_externalize_context *,
     66  1.15.4.2  ad 				const char *);
     67  1.15.4.2  ad boolean_t	_prop_object_externalize_append_encoded_cstring(
     68  1.15.4.2  ad 				struct _prop_object_externalize_context *,
     69  1.15.4.2  ad 				const char *);
     70  1.15.4.2  ad boolean_t	_prop_object_externalize_append_char(
     71  1.15.4.2  ad 				struct _prop_object_externalize_context *,
     72  1.15.4.2  ad 				unsigned char);
     73  1.15.4.2  ad boolean_t	_prop_object_externalize_header(
     74  1.15.4.2  ad 				struct _prop_object_externalize_context *);
     75  1.15.4.2  ad boolean_t	_prop_object_externalize_footer(
     76  1.15.4.2  ad 				struct _prop_object_externalize_context *);
     77  1.15.4.2  ad 
     78  1.15.4.2  ad struct _prop_object_externalize_context *
     79  1.15.4.2  ad 		_prop_object_externalize_context_alloc(void);
     80  1.15.4.2  ad void		_prop_object_externalize_context_free(
     81  1.15.4.2  ad 				struct _prop_object_externalize_context *);
     82  1.15.4.2  ad 
     83  1.15.4.2  ad typedef enum {
     84  1.15.4.2  ad 	_PROP_TAG_TYPE_START,			/* e.g. <dict> */
     85  1.15.4.2  ad 	_PROP_TAG_TYPE_END,			/* e.g. </dict> */
     86  1.15.4.2  ad 	_PROP_TAG_TYPE_EITHER
     87  1.15.4.2  ad } _prop_tag_type_t;
     88  1.15.4.2  ad 
     89  1.15.4.2  ad struct _prop_object_internalize_context {
     90  1.15.4.2  ad 	const char *poic_xml;
     91  1.15.4.2  ad 	const char *poic_cp;
     92  1.15.4.2  ad 
     93  1.15.4.2  ad 	const char *poic_tag_start;
     94  1.15.4.2  ad 
     95  1.15.4.2  ad 	const char *poic_tagname;
     96  1.15.4.2  ad 	size_t      poic_tagname_len;
     97  1.15.4.2  ad 	const char *poic_tagattr;
     98  1.15.4.2  ad 	size_t      poic_tagattr_len;
     99  1.15.4.2  ad 	const char *poic_tagattrval;
    100  1.15.4.2  ad 	size_t      poic_tagattrval_len;
    101  1.15.4.2  ad 
    102  1.15.4.2  ad 	boolean_t   poic_is_empty_element;
    103  1.15.4.2  ad 	_prop_tag_type_t poic_tag_type;
    104  1.15.4.2  ad };
    105  1.15.4.2  ad 
    106  1.15.4.2  ad #define	_PROP_EOF(c)		((c) == '\0')
    107  1.15.4.2  ad #define	_PROP_ISSPACE(c)	\
    108  1.15.4.2  ad 	((c) == ' ' || (c) == '\t' || (c) == '\n' || (c) == '\r' || \
    109  1.15.4.2  ad 	 _PROP_EOF(c))
    110  1.15.4.2  ad 
    111  1.15.4.2  ad #define	_PROP_TAG_MATCH(ctx, t)					\
    112  1.15.4.2  ad 	_prop_object_internalize_match((ctx)->poic_tagname,	\
    113  1.15.4.2  ad 				       (ctx)->poic_tagname_len,	\
    114  1.15.4.2  ad 				       (t), strlen(t))
    115  1.15.4.2  ad 
    116  1.15.4.2  ad #define	_PROP_TAGATTR_MATCH(ctx, a)				\
    117  1.15.4.2  ad 	_prop_object_internalize_match((ctx)->poic_tagattr,	\
    118  1.15.4.2  ad 				       (ctx)->poic_tagattr_len,	\
    119  1.15.4.2  ad 				       (a), strlen(a))
    120  1.15.4.2  ad 
    121  1.15.4.2  ad #define	_PROP_TAGATTRVAL_MATCH(ctx, a)				  \
    122  1.15.4.2  ad 	_prop_object_internalize_match((ctx)->poic_tagattrval,	  \
    123  1.15.4.2  ad 				       (ctx)->poic_tagattrval_len,\
    124  1.15.4.2  ad 				       (a), strlen(a))
    125  1.15.4.2  ad 
    126  1.15.4.2  ad boolean_t	_prop_object_internalize_find_tag(
    127  1.15.4.2  ad 				struct _prop_object_internalize_context *,
    128  1.15.4.2  ad 				const char *, _prop_tag_type_t);
    129  1.15.4.2  ad boolean_t	_prop_object_internalize_match(const char *, size_t,
    130  1.15.4.2  ad 					       const char *, size_t);
    131  1.15.4.2  ad prop_object_t	_prop_object_internalize_by_tag(
    132  1.15.4.2  ad 				struct _prop_object_internalize_context *);
    133  1.15.4.2  ad boolean_t	_prop_object_internalize_decode_string(
    134  1.15.4.2  ad 				struct _prop_object_internalize_context *,
    135  1.15.4.2  ad 				char *, size_t, size_t *, const char **);
    136  1.15.4.2  ad prop_object_t	_prop_generic_internalize(const char *, const char *);
    137  1.15.4.2  ad 
    138  1.15.4.2  ad struct _prop_object_internalize_context *
    139  1.15.4.2  ad 		_prop_object_internalize_context_alloc(const char *);
    140  1.15.4.2  ad void		_prop_object_internalize_context_free(
    141  1.15.4.2  ad 				struct _prop_object_internalize_context *);
    142  1.15.4.2  ad 
    143  1.15.4.2  ad #if !defined(_KERNEL) && !defined(_STANDALONE)
    144  1.15.4.2  ad boolean_t	_prop_object_externalize_write_file(const char *,
    145  1.15.4.2  ad 						    const char *, size_t);
    146  1.15.4.2  ad 
    147  1.15.4.2  ad struct _prop_object_internalize_mapped_file {
    148  1.15.4.2  ad 	char *	poimf_xml;
    149  1.15.4.2  ad 	size_t	poimf_mapsize;
    150  1.15.4.2  ad };
    151  1.15.4.2  ad 
    152  1.15.4.2  ad struct _prop_object_internalize_mapped_file *
    153  1.15.4.2  ad 		_prop_object_internalize_map_file(const char *);
    154  1.15.4.2  ad void		_prop_object_internalize_unmap_file(
    155  1.15.4.2  ad 				struct _prop_object_internalize_mapped_file *);
    156  1.15.4.2  ad #endif /* !_KERNEL && !_STANDALONE */
    157  1.15.4.2  ad 
    158  1.15.4.2  ad 	/* These are here because they're required by shared code. */
    159  1.15.4.2  ad prop_object_t	_prop_array_internalize(
    160  1.15.4.2  ad 				struct _prop_object_internalize_context *);
    161  1.15.4.2  ad prop_object_t	_prop_bool_internalize(
    162  1.15.4.2  ad 				struct _prop_object_internalize_context *);
    163  1.15.4.2  ad prop_object_t	_prop_data_internalize(
    164  1.15.4.2  ad 				struct _prop_object_internalize_context *);
    165  1.15.4.2  ad prop_object_t	_prop_dictionary_internalize(
    166  1.15.4.2  ad 				struct _prop_object_internalize_context *);
    167  1.15.4.2  ad prop_object_t	_prop_number_internalize(
    168  1.15.4.2  ad 				struct _prop_object_internalize_context *);
    169  1.15.4.2  ad prop_object_t	_prop_string_internalize(
    170  1.15.4.2  ad 				struct _prop_object_internalize_context *);
    171  1.15.4.2  ad 
    172  1.15.4.2  ad struct _prop_object_type {
    173  1.15.4.2  ad 	uint32_t	pot_type;		/* type indicator */
    174  1.15.4.2  ad 	void		(*pot_free)(void *);	/* func to free object */
    175  1.15.4.2  ad 	boolean_t	(*pot_extern)		/* func to externalize object */
    176  1.15.4.2  ad 			    (struct _prop_object_externalize_context *,
    177  1.15.4.2  ad 			     void *);
    178  1.15.4.2  ad 	boolean_t	(*pot_equals)		/* func to test quality */
    179  1.15.4.2  ad 			    (void *, void *);
    180  1.15.4.2  ad };
    181  1.15.4.2  ad 
    182  1.15.4.2  ad struct _prop_object {
    183  1.15.4.2  ad 	const struct _prop_object_type *po_type;/* type descriptor */
    184  1.15.4.2  ad 	uint32_t	po_refcnt;		/* reference count */
    185  1.15.4.2  ad };
    186  1.15.4.2  ad 
    187  1.15.4.2  ad void	_prop_object_init(struct _prop_object *,
    188  1.15.4.2  ad 			  const struct _prop_object_type *);
    189  1.15.4.2  ad void	_prop_object_fini(struct _prop_object *);
    190  1.15.4.2  ad 
    191  1.15.4.2  ad struct _prop_object_iterator {
    192  1.15.4.2  ad 	prop_object_t	(*pi_next_object)(void *);
    193  1.15.4.2  ad 	void		(*pi_reset)(void *);
    194  1.15.4.2  ad 	prop_object_t	pi_obj;
    195  1.15.4.2  ad 	uint32_t	pi_version;
    196  1.15.4.2  ad };
    197  1.15.4.2  ad 
    198  1.15.4.2  ad #if defined(_KERNEL)
    199  1.15.4.2  ad 
    200  1.15.4.2  ad /*
    201  1.15.4.2  ad  * proplib in the kernel...
    202  1.15.4.2  ad  */
    203  1.15.4.2  ad 
    204  1.15.4.2  ad #include <sys/param.h>
    205  1.15.4.2  ad #include <sys/malloc.h>
    206  1.15.4.2  ad #include <sys/pool.h>
    207  1.15.4.2  ad #include <sys/systm.h>
    208  1.15.4.2  ad #include <sys/lock.h>
    209  1.15.4.2  ad #include <sys/rwlock.h>
    210  1.15.4.2  ad 
    211  1.15.4.2  ad #define	_PROP_ASSERT(x)		KASSERT(x)
    212  1.15.4.2  ad 
    213  1.15.4.2  ad #define	_PROP_MALLOC(s, t)	malloc((s), (t), M_WAITOK)
    214  1.15.4.2  ad #define	_PROP_CALLOC(s, t)	malloc((s), (t), M_WAITOK | M_ZERO)
    215  1.15.4.2  ad #define	_PROP_REALLOC(v, s, t)	realloc((v), (s), (t), M_WAITOK)
    216  1.15.4.2  ad #define	_PROP_FREE(v, t)	free((v), (t))
    217  1.15.4.2  ad 
    218  1.15.4.2  ad #define	_PROP_POOL_GET(p)	pool_get(&(p), PR_WAITOK)
    219  1.15.4.2  ad #define	_PROP_POOL_PUT(p, v)	pool_put(&(p), (v))
    220  1.15.4.2  ad 
    221  1.15.4.2  ad #define	_PROP_POOL_INIT(p, s, d)					\
    222  1.15.4.2  ad 		POOL_INIT(p, s, 0, 0, 0, d, &pool_allocator_nointr, IPL_NONE);
    223  1.15.4.2  ad 
    224  1.15.4.2  ad #define	_PROP_MALLOC_DEFINE(t, s, l)					\
    225  1.15.4.2  ad 		MALLOC_DEFINE(t, s, l);
    226  1.15.4.2  ad 
    227  1.15.4.2  ad #define	_PROP_MUTEX_DECL_STATIC(x)					\
    228  1.15.4.2  ad 		static struct simplelock x = SIMPLELOCK_INITIALIZER;
    229  1.15.4.2  ad #define	_PROP_MUTEX_LOCK(x)	simple_lock(&(x))
    230  1.15.4.2  ad #define	_PROP_MUTEX_UNLOCK(x)	simple_unlock(&(x))
    231  1.15.4.2  ad 
    232  1.15.4.2  ad #define	_PROP_RWLOCK_DECL(x)	krwlock_t x ;
    233  1.15.4.2  ad #define	_PROP_RWLOCK_INIT(x)	rw_init(&(x))
    234  1.15.4.2  ad #define	_PROP_RWLOCK_RDLOCK(x)	rw_enter(&(x), RW_READER)
    235  1.15.4.2  ad #define	_PROP_RWLOCK_WRLOCK(x)	rw_enter(&(x), RW_WRITER)
    236  1.15.4.2  ad #define	_PROP_RWLOCK_UNLOCK(x)	rw_exit(&(x))
    237  1.15.4.2  ad #define	_PROP_RWLOCK_DESTROY(x)	rw_destroy(&(x))
    238  1.15.4.2  ad 
    239  1.15.4.2  ad #elif defined(_STANDALONE)
    240  1.15.4.2  ad 
    241  1.15.4.2  ad /*
    242  1.15.4.2  ad  * proplib in a standalone environment...
    243  1.15.4.2  ad  */
    244  1.15.4.2  ad 
    245  1.15.4.2  ad #include <lib/libsa/stand.h>
    246  1.15.4.2  ad 
    247  1.15.4.2  ad void *		_prop_standalone_calloc(size_t);
    248  1.15.4.2  ad void *		_prop_standalone_realloc(void *, size_t);
    249  1.15.4.2  ad 
    250  1.15.4.2  ad #define	_PROP_ASSERT(x)		/* nothing */
    251  1.15.4.2  ad 
    252  1.15.4.2  ad #define	_PROP_MALLOC(s, t)	alloc((s))
    253  1.15.4.2  ad #define	_PROP_CALLOC(s, t)	_prop_standalone_calloc((s))
    254  1.15.4.2  ad #define	_PROP_REALLOC(v, s, t)	_prop_standalone_realloc((v), (s))
    255  1.15.4.2  ad #define	_PROP_FREE(v, t)	dealloc((v), 0)		/* XXX */
    256  1.15.4.2  ad 
    257  1.15.4.2  ad #define	_PROP_POOL_GET(p)	alloc((p))
    258  1.15.4.2  ad #define	_PROP_POOL_PUT(p, v)	dealloc((v), (p))
    259  1.15.4.2  ad 
    260  1.15.4.2  ad #define	_PROP_POOL_INIT(p, s, d)	static const size_t p = s;
    261  1.15.4.2  ad 
    262  1.15.4.2  ad #define	_PROP_MALLOC_DEFINE(t, s, l)	/* nothing */
    263  1.15.4.2  ad 
    264  1.15.4.2  ad #define	_PROP_MUTEX_DECL_STATIC(x)	/* nothing */
    265  1.15.4.2  ad #define	_PROP_MUTEX_LOCK(x)		/* nothing */
    266  1.15.4.2  ad #define	_PROP_MUTEX_UNLOCK(x)		/* nothing */
    267  1.15.4.2  ad 
    268  1.15.4.2  ad #define	_PROP_RWLOCK_DECL(x)	/* nothing */
    269  1.15.4.2  ad #define	_PROP_RWLOCK_INIT(x)	/* nothing */
    270  1.15.4.2  ad #define	_PROP_RWLOCK_RDLOCK(x)	/* nothing */
    271  1.15.4.2  ad #define	_PROP_RWLOCK_WRLOCK(x)	/* nothing */
    272  1.15.4.2  ad #define	_PROP_RWLOCK_UNLOCK(x)	/* nothing */
    273  1.15.4.2  ad #define	_PROP_RWLOCK_DESTROY(x)	/* nothing */
    274  1.15.4.2  ad 
    275  1.15.4.2  ad #else
    276  1.15.4.2  ad 
    277  1.15.4.2  ad /*
    278  1.15.4.2  ad  * proplib in user space...
    279  1.15.4.2  ad  */
    280  1.15.4.2  ad 
    281  1.15.4.2  ad #include <assert.h>
    282  1.15.4.2  ad #include <string.h>
    283  1.15.4.2  ad #include <stdio.h>
    284  1.15.4.2  ad #include <stdlib.h>
    285  1.15.4.2  ad #include <stddef.h>
    286  1.15.4.2  ad 
    287  1.15.4.2  ad #define	_PROP_ASSERT(x)		/*LINTED*/assert(x)
    288  1.15.4.2  ad 
    289  1.15.4.2  ad #define	_PROP_MALLOC(s, t)	malloc((s))
    290  1.15.4.2  ad #define	_PROP_CALLOC(s, t)	calloc(1, (s))
    291  1.15.4.2  ad #define	_PROP_REALLOC(v, s, t)	realloc((v), (s))
    292  1.15.4.2  ad #define	_PROP_FREE(v, t)	free((v))
    293  1.15.4.2  ad 
    294  1.15.4.2  ad #define	_PROP_POOL_GET(p)	malloc((p))
    295  1.15.4.2  ad #define	_PROP_POOL_PUT(p, v)	free((v))
    296  1.15.4.2  ad 
    297  1.15.4.2  ad #define	_PROP_POOL_INIT(p, s, d)	static const size_t p = s;
    298  1.15.4.2  ad 
    299  1.15.4.2  ad #define	_PROP_MALLOC_DEFINE(t, s, l)	/* nothing */
    300  1.15.4.2  ad 
    301  1.15.4.2  ad #if defined(__NetBSD__) && defined(_LIBPROP)
    302  1.15.4.2  ad /*
    303  1.15.4.2  ad  * Use the same mechanism as libc; we get pthread mutexes for threaded
    304  1.15.4.2  ad  * programs and do-nothing stubs for non-threaded programs.
    305  1.15.4.2  ad  */
    306  1.15.4.2  ad #include "reentrant.h"
    307  1.15.4.2  ad #define	_PROP_MUTEX_DECL_STATIC(x)	static mutex_t x = MUTEX_INITIALIZER;
    308  1.15.4.2  ad #define	_PROP_MUTEX_LOCK(x)		mutex_lock(&(x))
    309  1.15.4.2  ad #define	_PROP_MUTEX_UNLOCK(x)		mutex_unlock(&(x))
    310  1.15.4.2  ad 
    311  1.15.4.2  ad #define	_PROP_RWLOCK_DECL(x)	rwlock_t x ;
    312  1.15.4.2  ad #define	_PROP_RWLOCK_INIT(x)	rwlock_init(&(x), NULL)
    313  1.15.4.2  ad #define	_PROP_RWLOCK_RDLOCK(x)	rwlock_rdlock(&(x))
    314  1.15.4.2  ad #define	_PROP_RWLOCK_WRLOCK(x)	rwlock_wrlock(&(x))
    315  1.15.4.2  ad #define	_PROP_RWLOCK_UNLOCK(x)	rwlock_unlock(&(x))
    316  1.15.4.2  ad #define	_PROP_RWLOCK_DESTROY(x)	rwlock_destroy(&(x))
    317  1.15.4.2  ad #elif defined(HAVE_NBTOOL_CONFIG_H)
    318  1.15.4.2  ad /*
    319  1.15.4.2  ad  * None of NetBSD's build tools are multi-threaded.
    320  1.15.4.2  ad  */
    321  1.15.4.2  ad #define	_PROP_MUTEX_DECL_STATIC(x)	/* nothing */
    322  1.15.4.2  ad #define	_PROP_MUTEX_LOCK(x)		/* nothing */
    323  1.15.4.2  ad #define	_PROP_MUTEX_UNLOCK(x)		/* nothing */
    324  1.15.4.2  ad 
    325  1.15.4.2  ad #define	_PROP_RWLOCK_DECL(x)	/* nothing */
    326  1.15.4.2  ad #define	_PROP_RWLOCK_INIT(x)	/* nothing */
    327  1.15.4.2  ad #define	_PROP_RWLOCK_RDLOCK(x)	/* nothing */
    328  1.15.4.2  ad #define	_PROP_RWLOCK_WRLOCK(x)	/* nothing */
    329  1.15.4.2  ad #define	_PROP_RWLOCK_UNLOCK(x)	/* nothing */
    330  1.15.4.2  ad #define	_PROP_RWLOCK_DESTROY(x)	/* nothing */
    331  1.15.4.2  ad #else
    332  1.15.4.2  ad /*
    333  1.15.4.2  ad  * Use pthread mutexes everywhere else.
    334  1.15.4.2  ad  */
    335  1.15.4.2  ad #include <pthread.h>
    336  1.15.4.2  ad #define	_PROP_MUTEX_DECL_STATIC(x)					\
    337  1.15.4.2  ad 		static pthread_mutex_t x = PTHREAD_MUTEX_INITIALIZER;
    338  1.15.4.2  ad #define	_PROP_MUTEX_LOCK(x)	pthread_mutex_lock(&(x))
    339  1.15.4.2  ad #define	_PROP_MUTEX_UNLOCK(x)	pthread_mutex_unlock(&(x))
    340  1.15.4.2  ad 
    341  1.15.4.2  ad #define	_PROP_RWLOCK_DECL(x)	pthread_rwlock_t x ;
    342  1.15.4.2  ad #define	_PROP_RWLOCK_INIT(x)	pthread_rwlock_init(&(x), NULL)
    343  1.15.4.2  ad #define	_PROP_RWLOCK_RDLOCK(x)	pthread_rwlock_rdlock(&(x))
    344  1.15.4.2  ad #define	_PROP_RWLOCK_WRLOCK(x)	pthread_rwlock_wrlock(&(x))
    345  1.15.4.2  ad #define	_PROP_RWLOCK_UNLOCK(x)	pthread_rwlock_unlock(&(x))
    346  1.15.4.2  ad #define	_PROP_RWLOCK_DESTROY(x)	pthread_rwlock_destroy(&(x))
    347  1.15.4.2  ad #endif
    348  1.15.4.2  ad 
    349  1.15.4.2  ad #endif /* _KERNEL */
    350  1.15.4.2  ad 
    351  1.15.4.2  ad /*
    352  1.15.4.2  ad  * Language features.
    353  1.15.4.2  ad  */
    354  1.15.4.2  ad #if defined(__NetBSD__)
    355  1.15.4.2  ad #include <sys/cdefs.h>
    356  1.15.4.2  ad #define	_PROP_ARG_UNUSED	__unused
    357  1.15.4.2  ad #else
    358  1.15.4.2  ad #define	_PROP_ARG_UNUSED	/* delete */
    359  1.15.4.2  ad #endif /* __NetBSD__ */
    360  1.15.4.2  ad 
    361  1.15.4.2  ad #endif /* _PROPLIB_PROP_OBJECT_IMPL_H_ */
    362