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#include <linux/types.h>
31#include <linux/spinlock.h>
32
33#ifndef IRDA_QUEUE_H
34#define IRDA_QUEUE_H
35
36#define NAME_SIZE 32
37
38
39
40
41
42#define HB_NOLOCK 0
43#define HB_LOCK 1
44
45
46
47
48#define HASHBIN_SIZE 8
49#define HASHBIN_MASK 0x7
50
51#ifndef IRDA_ALIGN
52#define IRDA_ALIGN __attribute__((aligned))
53#endif
54
55#define Q_NULL { NULL, NULL, "", 0 }
56
57typedef void (*FREE_FUNC)(void *arg);
58
59struct irda_queue {
60 struct irda_queue *q_next;
61 struct irda_queue *q_prev;
62
63 char q_name[NAME_SIZE];
64 long q_hash;
65};
66typedef struct irda_queue irda_queue_t;
67
68typedef struct hashbin_t {
69 __u32 magic;
70 int hb_type;
71 int hb_size;
72 spinlock_t hb_spinlock;
73
74 irda_queue_t* hb_queue[HASHBIN_SIZE] IRDA_ALIGN;
75
76 irda_queue_t* hb_current;
77} hashbin_t;
78
79hashbin_t *hashbin_new(int type);
80int hashbin_delete(hashbin_t* hashbin, FREE_FUNC func);
81int hashbin_clear(hashbin_t* hashbin, FREE_FUNC free_func);
82void hashbin_insert(hashbin_t* hashbin, irda_queue_t* entry, long hashv,
83 const char* name);
84void* hashbin_remove(hashbin_t* hashbin, long hashv, const char* name);
85void* hashbin_remove_first(hashbin_t *hashbin);
86void* hashbin_remove_this( hashbin_t* hashbin, irda_queue_t* entry);
87void* hashbin_find(hashbin_t* hashbin, long hashv, const char* name);
88void* hashbin_lock_find(hashbin_t* hashbin, long hashv, const char* name);
89void* hashbin_find_next(hashbin_t* hashbin, long hashv, const char* name,
90 void ** pnext);
91irda_queue_t *hashbin_get_first(hashbin_t *hashbin);
92irda_queue_t *hashbin_get_next(hashbin_t *hashbin);
93
94#define HASHBIN_GET_SIZE(hashbin) hashbin->hb_size
95
96#endif
97