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