Minor header cleanup: moved some headers to better matching directories,

removed unused headers. Adapted sources to still compile with the new
header locations.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@11913 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2005-03-19 01:58:05 +00:00
parent 46c1b0d6db
commit 52fe8bf7a8
28 changed files with 63 additions and 248 deletions
+53
View File
@@ -0,0 +1,53 @@
/*
** Copyright 2001-2002, Travis Geiselbrecht. All rights reserved.
** Distributed under the terms of the NewOS License.
*/
#ifndef _KERNEL_KHASH_H
#define _KERNEL_KHASH_H
// can be allocated on the stack
typedef struct hash_iterator {
void *current;
int bucket;
} hash_iterator;
typedef struct hash_table hash_table;
#ifdef __cplusplus
extern "C" {
#endif
struct hash_table *hash_init(uint32 table_size, int next_ptr_offset,
int compare_func(void *element, const void *key),
uint32 hash_func(void *element, const void *key, uint32 range));
int hash_uninit(struct hash_table *table);
status_t hash_insert(struct hash_table *table, void *_element);
status_t hash_remove(struct hash_table *table, void *_element);
void *hash_remove_first(struct hash_table *table, uint32 *_cookie);
void *hash_find(struct hash_table *table, void *e);
void *hash_lookup(struct hash_table *table, const void *key);
struct hash_iterator *hash_open(struct hash_table *table, struct hash_iterator *i);
void hash_close(struct hash_table *table, struct hash_iterator *i, bool free_iterator);
void *hash_next(struct hash_table *table, struct hash_iterator *i);
void hash_rewind(struct hash_table *table, struct hash_iterator *i);
/* function ptrs must look like this:
*
* uint32 hash_func(void *e, const void *key, uint32 range);
* hash function should calculate hash on either e or key,
* depending on which one is not NULL
* int compare_func(void *e, const void *key);
* compare function should compare the element with
* the key, returning 0 if equal, other if not
* NOTE: compare func can be null, in which case the hash
* code will compare the key pointer with the target
* ToDo: check this!
*/
uint32 hash_hash_string(const char *str);
#ifdef __cplusplus
}
#endif
#endif /* _KERNEL_KHASH_H */
+63
View File
@@ -0,0 +1,63 @@
/*
** Copyright 2002, Axel Dörfler, [email protected]. All rights reserved.
** Distributed under the terms of the OpenBeOS License.
*/
#ifndef KQUEUE_H
#define KQUEUE_H
/* The name "que" actually means that it is a very
* light-weight implementation of a queue ;-))
*/
/* The object that is put into a queue must begin with these
* fields, but it doesn't have to be this structure.
*/
struct quehead {
struct quehead *next;
struct quehead *prev;
};
/* You can use this macro to iterate through the queue. */
#define kqueue_foreach(head, element) \
for ((element) = (void *)(head)->next; (element) != (void *)(head); (element) = (void *)((struct quehead *)(element))->next)
/** Initializes a queue to be used */
static inline void
initque(void *_head)
{
struct quehead *head = (struct quehead *)_head;
head->next = head->prev = head;
}
/** Inserts an element (_element) to the queue (_head) */
static inline void
insque(void *_element, void *_head)
{
struct quehead *element = (struct quehead *)_element,
*head = (struct quehead *)_head;
element->next = head->next;
element->prev = head;
head->next = element;
element->next->prev = element;
}
/** removes an element from the queue it's currently in */
static inline void
remque(void *_element)
{
struct quehead *element = (struct quehead *)_element;
element->next->prev = element->prev;
element->prev->next = element->next;
element->prev = 0;
}
#endif /* KQUEUE_H */
+37
View File
@@ -0,0 +1,37 @@
/*
** Copyright 2001-2002, Travis Geiselbrecht. All rights reserved.
** Distributed under the terms of the NewOS License.
*/
#ifndef _KERNEL_QUEUE_H
#define _KERNEL_QUEUE_H
#include <kernel.h>
typedef struct queue {
void *head;
void *tail;
int count;
} queue;
int queue_init(queue *q);
int queue_remove_item(queue *q, void *e);
int queue_enqueue(queue *q, void *e);
void *queue_dequeue(queue *q);
void *queue_peek(queue *q);
typedef struct fixed_queue {
void **table;
int head;
int tail;
int count;
int size;
} fixed_queue;
int fixed_queue_init(fixed_queue *q, int size);
void fixed_queue_destroy(fixed_queue *q);
int fixed_queue_enqueue(fixed_queue *q, void *e);
void *fixed_queue_dequeue(fixed_queue *q);
void *fixed_queue_peek(fixed_queue *q);
#endif