types.h
author Kristian H?gsberg <krh@redhat.com>
Mon Apr 07 00:35:27 2008 -0400 (2008-04-07)
changeset 197 d29026900856
parent 140 017f92f7039a
permissions -rw-r--r--
Create the new repo file O_EXCL to prevent racing with another razor process.

And remember to clean it up on exit paths.
danw@115
     1
#ifndef _RAZOR_TYPES_H_
danw@115
     2
#define _RAZOR_TYPES_H_
danw@115
     3
danw@115
     4
#include <stdint.h>
danw@115
     5
danw@115
     6
struct array {
danw@115
     7
	void *data;
danw@115
     8
	int size, alloc;
danw@115
     9
};
danw@115
    10
danw@115
    11
void array_init(struct array *array);
danw@115
    12
void array_release(struct array *array);
danw@115
    13
void *array_add(struct array *array, int size);
danw@115
    14
danw@115
    15
danw@117
    16
struct list_head {
danw@118
    17
	uint list_ptr : 24;
danw@118
    18
	uint flags    : 8;
danw@117
    19
};
danw@117
    20
danw@117
    21
struct list {
danw@118
    22
	uint data  : 24;
danw@118
    23
	uint flags : 8;
danw@117
    24
};
danw@117
    25
danw@117
    26
void list_set_empty(struct list_head *head);
danw@117
    27
void list_set_ptr(struct list_head *head, uint32_t ptr);
danw@124
    28
void list_set_array(struct list_head *head, struct array *pool, struct array *items, int force_indirect);
danw@117
    29
danw@117
    30
struct list *list_first(struct list_head *head, struct array *pool);
danw@117
    31
struct list *list_next(struct list *list);
danw@117
    32
danw@116
    33
void list_remap_pool(struct array *pool, uint32_t *map);
danw@117
    34
void list_remap_head(struct list_head *list, uint32_t *map);
danw@117
    35
danw@116
    36
danw@115
    37
struct hashtable {
danw@115
    38
	struct array buckets;
danw@115
    39
	struct array *pool;
danw@115
    40
};
danw@115
    41
danw@115
    42
void hashtable_init(struct hashtable *table, struct array *pool);
danw@115
    43
void hashtable_release(struct hashtable *table);
danw@115
    44
uint32_t hashtable_insert(struct hashtable *table, const char *key);
danw@115
    45
uint32_t hashtable_lookup(struct hashtable *table, const char *key);
danw@115
    46
uint32_t hashtable_tokenize(struct hashtable *table, const char *string);
danw@115
    47
danw@140
    48
danw@140
    49
struct bitarray {
danw@140
    50
	uint32_t *bits;
danw@140
    51
};
danw@140
    52
danw@140
    53
void bitarray_init(struct bitarray *bitarray, int size, int intial_value);
krh@195
    54
void bitarray_release(struct bitarray *bitarray);
danw@140
    55
void bitarray_set(struct bitarray *bitarray, int bit, int value);
danw@140
    56
int bitarray_get(struct bitarray *bitarray, int bit);
danw@140
    57
danw@140
    58
danw@115
    59
#endif /* _RAZOR_TYPES_H_ */