Ok. I didn't make 2.4.0 in 2000. Tough. I tried, but we had some
[davej-history.git] / include / net / irda / irqueue.h
blobf7c1ba65971ceaf2f1b1a24f66239899387083f0
1 /*********************************************************************
2 *
3 * Filename: irqueue.h
4 * Version: 0.3
5 * Description: General queue implementation
6 * Status: Experimental.
7 * Author: Dag Brattli <dagb@cs.uit.no>
8 * Created at: Tue Jun 9 13:26:50 1998
9 * Modified at: Thu Oct 7 13:25:16 1999
10 * Modified by: Dag Brattli <dagb@cs.uit.no>
12 * Copyright (C) 1998-1999, Aage Kvalnes <aage@cs.uit.no>
13 * Copyright (c) 1998, Dag Brattli
14 * All Rights Reserved.
16 * This code is taken from the Vortex Operating System written by Aage
17 * Kvalnes and has been ported to Linux and Linux/IR by Dag Brattli
19 * This program is free software; you can redistribute it and/or
20 * modify it under the terms of the GNU General Public License as
21 * published by the Free Software Foundation; either version 2 of
22 * the License, or (at your option) any later version.
24 * Neither Dag Brattli nor University of Tromsø admit liability nor
25 * provide warranty for any of this software. This material is
26 * provided "AS-IS" and at no charge.
28 ********************************************************************/
30 #include <linux/types.h>
31 #include <linux/spinlock.h>
33 #ifndef IRDA_QUEUE_H
34 #define IRDA_QUEUE_H
36 #define NAME_SIZE 32
39 * Hash types
41 #define HB_NOLOCK 0
42 #define HB_GLOBAL 1
43 #define HB_LOCAL 2
44 #define HB_SORTED 4
47 * Hash defines
49 #define HASHBIN_SIZE 8
50 #define HASHBIN_MASK 0x7
52 #ifndef ALIGN
53 #define ALIGN __attribute__((aligned))
54 #endif
56 #define Q_NULL { NULL, NULL, "", 0 }
58 typedef void (*FREE_FUNC)(void *arg);
61 * Hashbin
63 #define GET_HASHBIN(x) ( x & HASHBIN_MASK )
65 struct irda_queue {
66 struct irda_queue *q_next;
67 struct irda_queue *q_prev;
69 char q_name[NAME_SIZE];
70 __u32 q_hash;
72 typedef struct irda_queue irda_queue_t;
74 typedef struct hashbin_t {
75 __u32 magic;
76 int hb_type;
77 int hb_size;
78 spinlock_t hb_mutex[HASHBIN_SIZE] ALIGN;
79 irda_queue_t *hb_queue[HASHBIN_SIZE] ALIGN;
81 irda_queue_t* hb_current;
82 } hashbin_t;
84 hashbin_t *hashbin_new(int type);
85 int hashbin_delete(hashbin_t* hashbin, FREE_FUNC func);
86 int hashbin_clear(hashbin_t* hashbin, FREE_FUNC free_func);
87 void hashbin_insert(hashbin_t* hashbin, irda_queue_t* entry, __u32 hashv,
88 char* name);
89 void* hashbin_find(hashbin_t* hashbin, __u32 hashv, char* name);
90 void* hashbin_remove(hashbin_t* hashbin, __u32 hashv, char* name);
91 void* hashbin_remove_first(hashbin_t *hashbin);
92 void* hashbin_remove_this( hashbin_t* hashbin, irda_queue_t* entry);
93 irda_queue_t *hashbin_get_first(hashbin_t *hashbin);
94 irda_queue_t *hashbin_get_next(hashbin_t *hashbin);
96 void enqueue_last(irda_queue_t **queue, irda_queue_t* element);
97 void enqueue_first(irda_queue_t **queue, irda_queue_t* element);
98 irda_queue_t *dequeue_first(irda_queue_t **queue);
100 #define HASHBIN_GET_SIZE(hashbin) hashbin->hb_size
102 #endif