Committer: Michael Beasley <mike@snafu.setup>
[mikesnafu-overlay.git] / include / net / irda / irqueue.h
blob37f512bd673321e2fb0eed0bd8ce2653cfe7b850
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 (some flags can be xored)
40 * See comments in irqueue.c for which one to use...
42 #define HB_NOLOCK 0 /* No concurent access prevention */
43 #define HB_LOCK 1 /* Prevent concurent write with global lock */
46 * Hash defines
48 #define HASHBIN_SIZE 8
49 #define HASHBIN_MASK 0x7
51 #ifndef IRDA_ALIGN
52 #define IRDA_ALIGN __attribute__((aligned))
53 #endif
55 #define Q_NULL { NULL, NULL, "", 0 }
57 typedef void (*FREE_FUNC)(void *arg);
59 struct irda_queue {
60 struct irda_queue *q_next;
61 struct irda_queue *q_prev;
63 char q_name[NAME_SIZE];
64 long q_hash; /* Must be able to cast a (void *) */
66 typedef struct irda_queue irda_queue_t;
68 typedef struct hashbin_t {
69 __u32 magic;
70 int hb_type;
71 int hb_size;
72 spinlock_t hb_spinlock; /* HB_LOCK - Can be used by the user */
74 irda_queue_t* hb_queue[HASHBIN_SIZE] IRDA_ALIGN;
76 irda_queue_t* hb_current;
77 } hashbin_t;
79 hashbin_t *hashbin_new(int type);
80 int hashbin_delete(hashbin_t* hashbin, FREE_FUNC func);
81 int hashbin_clear(hashbin_t* hashbin, FREE_FUNC free_func);
82 void hashbin_insert(hashbin_t* hashbin, irda_queue_t* entry, long hashv,
83 const char* name);
84 void* hashbin_remove(hashbin_t* hashbin, long hashv, const char* name);
85 void* hashbin_remove_first(hashbin_t *hashbin);
86 void* hashbin_remove_this( hashbin_t* hashbin, irda_queue_t* entry);
87 void* hashbin_find(hashbin_t* hashbin, long hashv, const char* name);
88 void* hashbin_lock_find(hashbin_t* hashbin, long hashv, const char* name);
89 void* hashbin_find_next(hashbin_t* hashbin, long hashv, const char* name,
90 void ** pnext);
91 irda_queue_t *hashbin_get_first(hashbin_t *hashbin);
92 irda_queue_t *hashbin_get_next(hashbin_t *hashbin);
94 #define HASHBIN_GET_SIZE(hashbin) hashbin->hb_size
96 #endif