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