corosync 3.1.7
hdb.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2002-2006 MontaVista Software, Inc.
3 * Copyright (c) 2006-2011 Red Hat, Inc.
4 *
5 * All rights reserved.
6 *
7 * Author: Steven Dake (sdake@redhat.com)
8 *
9 * This software licensed under BSD license, the text of which follows:
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions are met:
13 *
14 * - Redistributions of source code must retain the above copyright notice,
15 * this list of conditions and the following disclaimer.
16 * - Redistributions in binary form must reproduce the above copyright notice,
17 * this list of conditions and the following disclaimer in the documentation
18 * and/or other materials provided with the distribution.
19 * - Neither the name of the MontaVista Software, Inc. nor the names of its
20 * contributors may be used to endorse or promote products derived from this
21 * software without specific prior written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
24 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
27 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
29 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
30 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
31 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
32 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
33 * THE POSSIBILITY OF SUCH DAMAGE.
34 */
35
36#ifndef HDB_H_DEFINED
37#define HDB_H_DEFINED
38
39#ifndef _GNU_SOURCE
40#define _GNU_SOURCE
41#endif
42
43#include <errno.h>
44#include <assert.h>
45#include <stdlib.h>
46#include <string.h>
47#include <pthread.h>
48#include <stdint.h>
49#include <inttypes.h>
50#include <qb/qbhdb.h>
51
52typedef qb_handle_t hdb_handle_t;
53
54/*
55 * Formatting for string printing on 32/64 bit systems
56 */
57#define HDB_D_FORMAT QB_HDB_D_FORMAT
58#define HDB_X_FORMAT QB_HDB_X_FORMAT
59
60#define hdb_handle_database qb_hdb
61
66static inline void hdb_database_lock (pthread_mutex_t *mutex)
67{
68 pthread_mutex_lock (mutex);
69}
70
75static inline void hdb_database_unlock (pthread_mutex_t *mutex)
76{
77 pthread_mutex_unlock (mutex);
78}
79
84static inline void hdb_database_lock_init (pthread_mutex_t *mutex)
85{
86 pthread_mutex_init (mutex, NULL);
87}
88
93static inline void hdb_database_lock_destroy (pthread_mutex_t *mutex)
94{
95 pthread_mutex_destroy (mutex);
96}
97
98#define DECLARE_HDB_DATABASE QB_HDB_DECLARE
99
104static inline void hdb_create (
105 struct hdb_handle_database *handle_database)
106{
107 qb_hdb_create (handle_database);
108}
109
114static inline void hdb_destroy (
115 struct hdb_handle_database *handle_database)
116{
117 qb_hdb_destroy (handle_database);
118}
119
127static inline int hdb_handle_create (
128 struct hdb_handle_database *handle_database,
129 int instance_size,
130 hdb_handle_t *handle_id_out)
131{
132 return (qb_hdb_handle_create (handle_database, instance_size,
133 handle_id_out));
134}
135
143static inline int hdb_handle_get (
144 struct hdb_handle_database *handle_database,
145 hdb_handle_t handle_in,
146 void **instance)
147{
148 return (qb_hdb_handle_get (handle_database, handle_in, instance));
149}
150
158static inline int hdb_handle_get_always (
159 struct hdb_handle_database *handle_database,
160 hdb_handle_t handle_in,
161 void **instance)
162{
163 return (qb_hdb_handle_get_always (handle_database, handle_in, instance));
164}
165
172static inline int hdb_handle_put (
173 struct hdb_handle_database *handle_database,
174 hdb_handle_t handle_in)
175{
176 return (qb_hdb_handle_put (handle_database, handle_in));
177}
178
185static inline int hdb_handle_destroy (
186 struct hdb_handle_database *handle_database,
187 hdb_handle_t handle_in)
188{
189 return (qb_hdb_handle_destroy (handle_database, handle_in));
190}
191
198static inline int hdb_handle_refcount_get (
199 struct hdb_handle_database *handle_database,
200 hdb_handle_t handle_in)
201{
202 return (qb_hdb_handle_refcount_get (handle_database, handle_in));
203}
204
209static inline void hdb_iterator_reset (
210 struct hdb_handle_database *handle_database)
211{
212 qb_hdb_iterator_reset (handle_database);
213}
214
222static inline int hdb_iterator_next (
223 struct hdb_handle_database *handle_database,
224 void **instance,
225 hdb_handle_t *handle)
226{
227 return (qb_hdb_iterator_next (handle_database, instance, handle));
228}
229
235static inline unsigned int hdb_base_convert (hdb_handle_t handle)
236{
237 return (qb_hdb_base_convert (handle));
238}
239
245static inline unsigned long long hdb_nocheck_convert (unsigned int handle)
246{
247 return (qb_hdb_nocheck_convert (handle));
248}
249
250#endif /* HDB_H_DEFINED */
#define hdb_handle_database
Definition: hdb.h:60
qb_handle_t hdb_handle_t
Definition: hdb.h:52