4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
30 #pragma ident "%Z%%M% %I% %E% SMI"
33 * Utility functions and macros
44 extern int _dm_assert(const char *assertion
, const char *file
, int line
,
48 #if __STDC_VERSION__ - 0 >= 199901L
49 #define dm_assert(EX) (void)((EX) ? 0 : \
50 _dm_assert(#EX, __FILE__, __LINE__, __func__))
52 #define dm_assert(EX) (void)((EX) ? 0 : \
53 _dm_assert(#EX, __FILE__, __LINE__, NULL))
54 #endif /* __STDC_VERSION__ - 0 >= 199901L */
56 #define dm_assert(EX) (void)((EX) ? 0 : \
57 _dm_assert("EX", __FILE__, __LINE__, NULL))
61 * The following structures comprise the implementation of the
62 * queue structure that's used to construct the list of state
63 * changes. Removals from the queue are blocking operations that
64 * cause the thread to wait until new entries are added.
71 typedef struct q_head
{
73 * Block On Empty (when queue is empty, the calling thread will be
74 * blocked until something is added)
77 pthread_mutex_t mutex
;
79 void *(*nalloc
)(size_t);
80 void (*nfree
)(void *, size_t);
81 void (*data_dealloc
)(void *);
85 typedef enum log_class
{
97 extern void queue_add(qu_t
*qp
, void *data
);
98 extern void *queue_remove(qu_t
*qp
);
99 extern qu_t
*new_queue(boolean_t block_on_empty
, void *(*nodealloc
)(size_t),
100 void (*nodefree
)(void *, size_t), void (*deallocator
)(void *));
101 extern void queue_free(qu_t
**qp
);
103 extern void *dmalloc(size_t sz
);
104 extern void *dzmalloc(size_t sz
);
105 extern char *dstrdup(const char *s
);
106 extern void dfree(void *p
, size_t sz
);
107 extern void dstrfree(char *s
);
109 extern void log_msg(log_class_t cl
, const char *fmt
, ...);
110 extern void log_err(const char *fmt
, ...);
111 extern void log_warn(const char *fmt
, ...);
112 extern void log_warn_e(const char *fmt
, ...);
113 extern void vcont(log_class_t cl
, const char *fmt
, va_list val
);