hc
2024-11-01 2f529f9b558ca1c1bd74be7437a84e4711743404
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
/*
 * Copyright (C) 2010 Philippe Gerum <rpm@xenomai.org>.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.
 */
 
#ifndef _COPPERPLATE_CLUSTER_H
#define _COPPERPLATE_CLUSTER_H
 
#include <boilerplate/hash.h>
#include <copperplate/syncobj.h>
 
#ifdef CONFIG_XENO_PSHARED
 
struct clusterobj {
   pid_t cnode;
   struct hashobj hobj;
};
 
struct dictionary {
   struct hash_table table;
   struct hashobj hobj;
};
 
struct cluster {
   struct dictionary *d;
};
 
struct syndictionary {
   struct hash_table table;
   struct syncobj sobj;
   struct hashobj hobj;
};
 
struct syncluster {
   struct syndictionary *d;
};
 
struct pvclusterobj {
   struct pvhashobj hobj;
};
 
struct pvcluster {
   struct pvhash_table table;
};
 
struct pvsyncluster {
   struct pvcluster c;
   struct syncobj sobj;
};
 
static inline
const void *clusterobj_key(const struct clusterobj *cobj)
{
   return __memptr(__main_heap, cobj->hobj.key);
}
 
static inline
size_t clusterobj_keylen(const struct clusterobj *cobj)
{
   return cobj->hobj.len;
}
 
static inline
pid_t clusterobj_cnode(const struct clusterobj *cobj)
{
   return cobj->cnode;
}
 
static inline
const void *pvclusterobj_key(const struct pvclusterobj *cobj)
{
   return cobj->hobj.key;
}
 
static inline
size_t pvclusterobj_keylen(const struct pvclusterobj *cobj)
{
   return cobj->hobj.len;
}
 
static inline
pid_t pvclusterobj_cnode(const struct pvclusterobj *cobj)
{
   return -1;
}
 
#else /* !CONFIG_XENO_PSHARED */
 
struct clusterobj {
   struct pvhashobj hobj;
};
 
struct cluster {
   struct pvhash_table table;
};
 
struct syncluster {
   struct cluster c;
   struct syncobj sobj;
};
 
#define pvclusterobj  clusterobj
#define pvcluster     cluster
#define pvsyncluster  syncluster
 
static inline
const void *clusterobj_key(const struct pvclusterobj *cobj)
{
   return cobj->hobj.key;
}
 
static inline
size_t clusterobj_keylen(const struct pvclusterobj *cobj)
{
   return cobj->hobj.len;
}
 
static inline
pid_t clusterobj_cnode(const struct pvclusterobj *cobj)
{
   return -1;
}
 
static inline
const void *pvclusterobj_key(const struct pvclusterobj *cobj)
{
   return clusterobj_key(cobj);
}
 
static inline
size_t pvclusterobj_keylen(const struct pvclusterobj *cobj)
{
   return clusterobj_keylen(cobj);
}
 
static inline
pid_t pvclusterobj_cnode(const struct pvclusterobj *cobj)
{
   return clusterobj_cnode(cobj);
}
 
#endif /* !CONFIG_XENO_PSHARED */
 
struct syncluster_wait_struct {
   union {
       dref_type(char *) name_ref;
       const char *name;
   };
};
 
#ifdef __cplusplus
extern "C" {
#endif
 
int pvcluster_init(struct pvcluster *c, const char *name);
 
void pvcluster_destroy(struct pvcluster *c);
 
int pvcluster_addobj(struct pvcluster *c, const char *name,
            struct pvclusterobj *cobj);
 
int pvcluster_addobj_dup(struct pvcluster *c, const char *name,
            struct pvclusterobj *cobj);
 
int pvcluster_delobj(struct pvcluster *c,
            struct pvclusterobj *cobj);
 
struct pvclusterobj *pvcluster_findobj(struct pvcluster *c,
                      const char *name);
 
int pvcluster_walk(struct pvcluster *c,
          int (*walk)(struct pvcluster *c,
                  struct pvclusterobj *cobj));
  
int pvsyncluster_init(struct pvsyncluster *sc, const char *name);
 
void pvsyncluster_destroy(struct pvsyncluster *sc);
 
int pvsyncluster_addobj(struct pvsyncluster *sc, const char *name,
           struct pvclusterobj *cobj);
 
int pvsyncluster_delobj(struct pvsyncluster *sc,
           struct pvclusterobj *cobj);
 
int pvsyncluster_findobj(struct pvsyncluster *sc,
            const char *name,
            const struct timespec *timeout,
            struct pvclusterobj **cobjp) __must_check;
 
#ifdef CONFIG_XENO_PSHARED
 
int cluster_init(struct cluster *c, const char *name);
 
int cluster_addobj(struct cluster *c, const char *name,
          struct clusterobj *cobj);
 
int cluster_addobj_dup(struct cluster *c, const char *name,
              struct clusterobj *cobj);
 
int cluster_delobj(struct cluster *c,
          struct clusterobj *cobj);
 
struct clusterobj *cluster_findobj(struct cluster *c,
                  const char *name);
 
int cluster_walk(struct cluster *c,
        int (*walk)(struct cluster *c,
                struct clusterobj *cobj));
 
int syncluster_init(struct syncluster *sc, const char *name);
 
int syncluster_addobj(struct syncluster *sc, const char *name,
             struct clusterobj *cobj);
 
int syncluster_delobj(struct syncluster *sc,
             struct clusterobj *cobj);
 
int syncluster_findobj(struct syncluster *sc,
              const char *name,
              const struct timespec *timeout,
              struct clusterobj **cobjp) __must_check;
 
#else /* !CONFIG_XENO_PSHARED */
 
static inline int cluster_init(struct cluster *c, const char *name)
{
   return pvcluster_init(c, name);
}
 
static inline int cluster_addobj(struct cluster *c, const char *name,
                struct clusterobj *cobj)
{
   return pvcluster_addobj(c, name, cobj);
}
 
static inline int cluster_addobj_dup(struct cluster *c, const char *name,
                    struct clusterobj *cobj)
{
   return pvcluster_addobj_dup(c, name, cobj);
}
 
static inline int cluster_delobj(struct cluster *c,
                struct clusterobj *cobj)
{
   return pvcluster_delobj(c, cobj);
}
 
static inline struct clusterobj *cluster_findobj(struct cluster *c,
                        const char *name)
{
   return pvcluster_findobj(c, name);
}
 
static inline int cluster_walk(struct cluster *c,
                  int (*walk)(struct cluster *c,
                      struct clusterobj *cobj))
{
   return pvcluster_walk(c, walk);
}
 
static inline int syncluster_init(struct syncluster *sc,
                 const char *name)
{
   return pvsyncluster_init(sc, name);
}
 
static inline int syncluster_addobj(struct syncluster *sc,
                   const char *name,
                   struct clusterobj *cobj)
{
   return pvsyncluster_addobj(sc, name, cobj);
}
 
static inline int syncluster_delobj(struct syncluster *sc,
                   struct clusterobj *cobj)
{
   return pvsyncluster_delobj(sc, cobj);
}
 
static inline  __must_check
int syncluster_findobj(struct syncluster *sc,
              const char *name,
              const struct timespec *timeout,
              struct clusterobj **cobjp)
{
   return pvsyncluster_findobj(sc, name, timeout, cobjp);
}
 
#endif /* !CONFIG_XENO_PSHARED */
 
#ifdef __cplusplus
}
#endif
 
#endif /* _COPPERPLATE_CLUSTER_H */