~ubuntu-branches/ubuntu/trusty/wayland/trusty-proposed

« back to all changes in this revision

Viewing changes to src/wayland-util.c

  • Committer: Package Import Robot
  • Author(s): Emilio Pozuelo Monfort, Sven Joachim, Emilio Pozuelo Monfort
  • Date: 2013-09-08 19:46:04 UTC
  • mfrom: (1.1.6)
  • Revision ID: package-import@ubuntu.com-20130908194604-q8wdr5xrw6iaty55
Tags: 1.2.1-1
[ Sven Joachim ]
* New upstream release (1.2.0).
* Update symbols files and bump shlibs of libwayland-{client,server}0.
  - ABI break: libwayland-server0 removed several symbols used by
    weston releases prior to 1.2, add a Breaks to accommodate that.

[ Emilio Pozuelo Monfort ]
* New upstream stable release (1.2.1).
* Add myself to Uploaders.

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
#include "wayland-util.h"
30
30
#include "wayland-private.h"
31
31
 
 
32
struct wl_object global_zombie_object;
 
33
 
32
34
WL_EXPORT void
33
35
wl_list_init(struct wl_list *list)
34
36
{
151
153
        void *data;
152
154
};
153
155
 
 
156
#define map_entry_is_free(entry) ((entry).next & 0x1)
 
157
#define map_entry_get_data(entry) ((void *)((entry).next & ~(uintptr_t)0x3))
 
158
#define map_entry_get_flags(entry) (((entry).next >> 1) & 0x1)
 
159
 
154
160
WL_EXPORT void
155
 
wl_map_init(struct wl_map *map)
 
161
wl_map_init(struct wl_map *map, uint32_t side)
156
162
{
157
163
        memset(map, 0, sizeof *map);
 
164
        map->side = side;
158
165
}
159
166
 
160
167
WL_EXPORT void
165
172
}
166
173
 
167
174
WL_EXPORT uint32_t
168
 
wl_map_insert_new(struct wl_map *map, uint32_t side, void *data)
 
175
wl_map_insert_new(struct wl_map *map, uint32_t flags, void *data)
169
176
{
170
177
        union map_entry *start, *entry;
171
178
        struct wl_array *entries;
172
179
        uint32_t base;
173
180
 
174
 
        if (side == WL_MAP_CLIENT_SIDE) {
 
181
        if (map->side == WL_MAP_CLIENT_SIDE) {
175
182
                entries = &map->client_entries;
176
183
                base = 0;
177
184
        } else {
191
198
        }
192
199
 
193
200
        entry->data = data;
 
201
        entry->next |= (flags & 0x1) << 1;
194
202
 
195
203
        return (entry - start) + base;
196
204
}
197
205
 
198
206
WL_EXPORT int
199
 
wl_map_insert_at(struct wl_map *map, uint32_t i, void *data)
 
207
wl_map_insert_at(struct wl_map *map, uint32_t flags, uint32_t i, void *data)
200
208
{
201
209
        union map_entry *start;
202
210
        uint32_t count;
218
226
 
219
227
        start = entries->data;
220
228
        start[i].data = data;
 
229
        start[i].next |= (flags & 0x1) << 1;
221
230
 
222
231
        return 0;
223
232
}
230
239
        struct wl_array *entries;
231
240
 
232
241
        if (i < WL_SERVER_ID_START) {
 
242
                if (map->side == WL_MAP_CLIENT_SIDE)
 
243
                        return -1;
 
244
 
233
245
                entries = &map->client_entries;
234
246
        } else {
 
247
                if (map->side == WL_MAP_SERVER_SIDE)
 
248
                        return -1;
 
249
 
235
250
                entries = &map->server_entries;
236
251
                i -= WL_SERVER_ID_START;
237
252
        }
262
277
        struct wl_array *entries;
263
278
 
264
279
        if (i < WL_SERVER_ID_START) {
 
280
                if (map->side == WL_MAP_SERVER_SIDE)
 
281
                        return;
 
282
 
265
283
                entries = &map->client_entries;
266
284
        } else {
 
285
                if (map->side == WL_MAP_CLIENT_SIDE)
 
286
                        return;
 
287
 
267
288
                entries = &map->server_entries;
268
289
                i -= WL_SERVER_ID_START;
269
290
        }
290
311
        start = entries->data;
291
312
        count = entries->size / sizeof *start;
292
313
 
293
 
        if (i < count && !(start[i].next & 1))
294
 
                return start[i].data;
 
314
        if (i < count && !map_entry_is_free(start[i]))
 
315
                return map_entry_get_data(start[i]);
295
316
 
296
317
        return NULL;
297
318
}
298
319
 
 
320
WL_EXPORT uint32_t
 
321
wl_map_lookup_flags(struct wl_map *map, uint32_t i)
 
322
{
 
323
        union map_entry *start;
 
324
        uint32_t count;
 
325
        struct wl_array *entries;
 
326
 
 
327
        if (i < WL_SERVER_ID_START) {
 
328
                entries = &map->client_entries;
 
329
        } else {
 
330
                entries = &map->server_entries;
 
331
                i -= WL_SERVER_ID_START;
 
332
        }
 
333
 
 
334
        start = entries->data;
 
335
        count = entries->size / sizeof *start;
 
336
 
 
337
        if (i < count && !map_entry_is_free(start[i]))
 
338
                return map_entry_get_flags(start[i]);
 
339
 
 
340
        return 0;
 
341
}
 
342
 
299
343
static void
300
344
for_each_helper(struct wl_array *entries, wl_iterator_func_t func, void *data)
301
345
{
305
349
        end = (union map_entry *) ((char *) entries->data + entries->size);
306
350
 
307
351
        for (p = start; p < end; p++)
308
 
                if (p->data && !(p->next & 1))
309
 
                        func(p->data, data);
 
352
                if (p->data && !map_entry_is_free(*p))
 
353
                        func(map_entry_get_data(*p), data);
310
354
}
311
355
 
312
356
WL_EXPORT void