corosync  2.3.5-dirty
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 
52 typedef 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 
62 static inline void hdb_database_lock (pthread_mutex_t *mutex)
63 {
64  pthread_mutex_lock (mutex);
65 }
66 
67 static inline void hdb_database_unlock (pthread_mutex_t *mutex)
68 {
69  pthread_mutex_unlock (mutex);
70 }
71 static inline void hdb_database_lock_init (pthread_mutex_t *mutex)
72 {
73  pthread_mutex_init (mutex, NULL);
74 }
75 
76 static inline void hdb_database_lock_destroy (pthread_mutex_t *mutex)
77 {
78  pthread_mutex_destroy (mutex);
79 }
80 
81 #define DECLARE_HDB_DATABASE QB_HDB_DECLARE
82 
83 static inline void hdb_create (
84  struct hdb_handle_database *handle_database)
85 {
86  qb_hdb_create (handle_database);
87 }
88 
89 static inline void hdb_destroy (
90  struct hdb_handle_database *handle_database)
91 {
92  qb_hdb_destroy (handle_database);
93 }
94 
95 
96 static inline int hdb_handle_create (
97  struct hdb_handle_database *handle_database,
98  int instance_size,
99  hdb_handle_t *handle_id_out)
100 {
101  return (qb_hdb_handle_create (handle_database, instance_size,
102  handle_id_out));
103 }
104 
105 static inline int hdb_handle_get (
106  struct hdb_handle_database *handle_database,
107  hdb_handle_t handle_in,
108  void **instance)
109 {
110  return (qb_hdb_handle_get (handle_database, handle_in, instance));
111 }
112 
113 static inline int hdb_handle_get_always (
114  struct hdb_handle_database *handle_database,
115  hdb_handle_t handle_in,
116  void **instance)
117 {
118  return (qb_hdb_handle_get_always (handle_database, handle_in, instance));
119 }
120 
121 static inline int hdb_handle_put (
122  struct hdb_handle_database *handle_database,
123  hdb_handle_t handle_in)
124 {
125  return (qb_hdb_handle_put (handle_database, handle_in));
126 }
127 
128 static inline int hdb_handle_destroy (
129  struct hdb_handle_database *handle_database,
130  hdb_handle_t handle_in)
131 {
132  return (qb_hdb_handle_destroy (handle_database, handle_in));
133 }
134 
135 static inline int hdb_handle_refcount_get (
136  struct hdb_handle_database *handle_database,
137  hdb_handle_t handle_in)
138 {
139  return (qb_hdb_handle_refcount_get (handle_database, handle_in));
140 }
141 
142 static inline void hdb_iterator_reset (
143  struct hdb_handle_database *handle_database)
144 {
145  qb_hdb_iterator_reset (handle_database);
146 }
147 
148 static inline int hdb_iterator_next (
149  struct hdb_handle_database *handle_database,
150  void **instance,
151  hdb_handle_t *handle)
152 {
153  return (qb_hdb_iterator_next (handle_database, instance, handle));
154 }
155 
156 static inline unsigned int hdb_base_convert (hdb_handle_t handle)
157 {
158  return (qb_hdb_base_convert (handle));
159 }
160 
161 static inline unsigned long long hdb_nocheck_convert (unsigned int handle)
162 {
163  return (qb_hdb_nocheck_convert (handle));
164 }
165 
166 #endif /* HDB_H_DEFINED */
qb_handle_t hdb_handle_t
Definition: hdb.h:52
#define hdb_handle_database
Definition: hdb.h:60