Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' of scm.gforge.inria.fr:/gitroot/simgrid/simgrid
[simgrid.git] / src / xbt / setset_private.h
1 /* Copyright (c) 2010, 2014. The SimGrid Team.
2  * All rights reserved.                                                     */
3
4 /* This program is free software; you can redistribute it and/or modify it
5  * under the terms of the license (GNU LGPL) which comes with this package. */
6
7 #include "xbt/base.h"
8 #include "xbt/dict.h"
9 #include "xbt/dynar.h"
10 #include "xbt/setset.h"
11 #include "xbt/fifo.h"
12
13 #define BITS_INT (8 * sizeof(int))
14
15 typedef struct s_xbt_setset_elm {
16   XBT_SETSET_HEADERS;
17 } s_xbt_setset_elm_t, *xbt_setset_elm_t;
18
19 typedef union u_xbt_setset_elm_entry {
20   /* Information when the entry is being used */
21   struct {
22     xbt_setset_elm_t obj;
23   } info;
24   /* Information when the entry is free */
25   struct {
26     unsigned long next;
27   } free;
28 } u_xbt_setset_elm_entry_t, *xbt_setset_elm_entry_t;
29
30 typedef struct s_xbt_setset_set {
31   xbt_setset_t setset;          /* setset that contains this set */
32   unsigned int size;            /* in integers */
33   unsigned int *bitmap;         /* the bit array */
34 } s_xbt_setset_set_t;
35
36 typedef struct s_xbt_setset {
37   xbt_dynar_t elm_array;        /* of s_xbt_setset_elm_entry_t, to find elements by index */
38   xbt_fifo_t sets;              /* of s_xbt_setset_set_t, memberships in actual sets of setset */
39 } s_xbt_setset_t;
40
41 typedef struct s_xbt_setset_cursor {
42   int idx;                      /* Actual postition of the cursor (bit number) */
43   xbt_setset_set_t set;         /* The set associated to the cursor */
44 } s_xbt_setset_cursor_t;
45
46 /* Some internal functions */
47
48 XBT_PRIVATE int bitcount(int);
49
50 /* Get the object associated to a given index */
51 XBT_PRIVATE void *_xbt_setset_idx_to_obj(xbt_setset_t setset, unsigned long idx);
52
53 /* Check if the nth bit of an integer is set or not*/
54 XBT_PRIVATE unsigned int _is_bit_set(unsigned int bit, unsigned int integer);
55
56 /* Set the nth bit of an array of integers */
57 XBT_PRIVATE void _set_bit(unsigned int bit, unsigned int *bitmap);
58
59 /* Unset the nth bit of an array of integers */
60 XBT_PRIVATE void _unset_bit(unsigned int bit, unsigned int *bitmap);