diff --git a/headers/posix/lock.h b/headers/posix/lock.h deleted file mode 100644 index 05ad4e9330..0000000000 --- a/headers/posix/lock.h +++ /dev/null @@ -1,128 +0,0 @@ -#ifndef LOCK_H -#define LOCK_H -/* lock.h - benaphore locking, "faster semaphores", read/write locks -** sorry for all those macros; I wish C would support C++-style -** inline functions. -** -** Initial version by Axel Dörfler, axeld@pinc-software.de -** -** This file may be used under the terms of the OpenBeOS License. -*/ - - -#include - -// for read/write locks -#define MAX_READERS 100000 - - -struct benaphore { - sem_id sem; - int32 count; -}; - -typedef struct benaphore benaphore; - -// it may make sense to add a status field to the rw_lock to -// be able to check if the semaphore could be locked - -struct rw_lock { - sem_id sem; - int32 count; - benaphore writeLock; -}; - -typedef struct rw_lock rw_lock; - -#ifndef _KERNEL_ -#define INIT_BENAPHORE(lock,name) \ - { \ - (lock).count = 1; \ - (lock).sem = create_sem(0, name); \ - } - -#else - -#define INIT_BENAPHORE(lock,name) \ - { \ - (lock).count = 1; \ - (lock).sem = create_sem(0, name); \ - set_sem_owner((lock).sem, B_SYSTEM_TEAM); \ - } -#endif - - -#define CHECK_BENAPHORE(lock) \ - ((lock).sem) - -#define UNINIT_BENAPHORE(lock) \ - delete_sem((lock).sem); - -#define ACQUIRE_BENAPHORE(lock) \ - (atomic_add(&((lock).count), -1) <= 0 ? \ - acquire_sem_etc((lock).sem, 1, B_CAN_INTERRUPT, 0) \ - : B_OK) - -#define RELEASE_BENAPHORE(lock) \ - { \ - if (atomic_add(&((lock).count), 1) < 0) \ - release_sem((lock).sem); \ - } - -/* read/write lock */ -#ifndef _KERNEL_ -#define INIT_RW_LOCK(lock,name) \ - { \ - (lock).sem = create_sem(0, name); \ - (lock).count = MAX_READERS; \ - INIT_BENAPHORE((lock).writeLock, "r/w write lock"); \ - } - -#else - -#define INIT_RW_LOCK(lock,name) \ - { \ - (lock).sem = create_sem(0, name); \ - set_sem_owner((lock).sem, B_SYSTEM_TEAM); \ - (lock).count = MAX_READERS; \ - INIT_BENAPHORE((lock).writeLock, "r/w write lock"); \ - } - -#endif -#define CHECK_RW_LOCK(lock) \ - ((lock).sem) - -#define UNINIT_RW_LOCK(lock) \ - delete_sem((lock).sem); \ - UNINIT_BENAPHORE((lock).writeLock) - -#define ACQUIRE_READ_LOCK(lock) \ - { \ - if (atomic_add(&(lock).count, -1) <= 0) \ - acquire_sem((lock).sem); \ - } - -#define RELEASE_READ_LOCK(lock) \ - { \ - if (atomic_add(&(lock).count, 1) < 0) \ - release_sem((lock).sem); \ - } - -#define ACQUIRE_WRITE_LOCK(lock) \ - { \ - int32 readers; \ - ACQUIRE_BENAPHORE((lock).writeLock); \ - readers = atomic_add(&(lock).count, -MAX_READERS); \ - if (readers < MAX_READERS) \ - acquire_sem_etc((lock).sem,readers <= 0 ? 1 : MAX_READERS - readers,0,0); \ - RELEASE_BENAPHORE((lock).writeLock); \ - } - -#define RELEASE_WRITE_LOCK(lock) \ - { \ - int32 readers = atomic_add(&(lock).count,MAX_READERS); \ - if (readers < 0) \ - release_sem_etc((lock).sem,readers <= -MAX_READERS ? 1 : -readers,B_CAN_INTERRUPT); \ - } - -#endif /* LOCK_H */ diff --git a/headers/posix/net_timer.h b/headers/posix/net_timer.h deleted file mode 100644 index c700d76d56..0000000000 --- a/headers/posix/net_timer.h +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef NET_TIMER_H -#define NET_TIMER_H -/* net_timer.h - a small and more or less inaccurate timer for net modules. -** The registered hooks will be called in the thread of the timer. -** -** Initial version by Axel Dörfler, axeld@pinc-software.de -** -** This file may be used under the terms of the OpenBeOS License. -*/ - - -#include - - -typedef void (*net_timer_hook)(void *); -typedef int32 net_timer_id; - - -extern status_t net_init_timer(void); -extern void net_shutdown_timer(void); - -extern net_timer_id net_add_timer(net_timer_hook hook, void *data, bigtime_t interval); -extern status_t net_remove_timer(net_timer_id); - - -#endif /* NET_TIMER_H */ diff --git a/headers/posix/pools.h b/headers/posix/pools.h deleted file mode 100644 index 61d3b1d182..0000000000 --- a/headers/posix/pools.h +++ /dev/null @@ -1,55 +0,0 @@ -/* pools.h - * simple fixed size block allocator - */ - -#ifndef OBOS_POOLS_H -#define OBOS_POOLS_H - - -#include - -#include "lock.h" - - -typedef struct pool_ctl pool_ctl; - -struct pool_mem { - struct pool_mem *next; - area_id aid; - char *base_addr; - size_t mem_size; - char *ptr; - size_t avail; - benaphore lock; -}; - -struct free_blk { - char *next; -}; - -#define POOL_USES_BENAPHORES 0 -#define POOL_DEBUG_NAME_SZ 32 - -struct pool_ctl { - struct pool_mem *list; - char *freelist; - size_t alloc_size; - size_t block_size; -#if POOL_USES_BENAPHORES - benaphore lock; -#else - rw_lock lock; -#endif - int debug; - char name[POOL_DEBUG_NAME_SZ]; -}; - -status_t pool_init(pool_ctl **p, size_t sz); -char *pool_get(pool_ctl *p); -void pool_put(pool_ctl *p, void *ptr); -void pool_destroy(pool_ctl *p); -void pool_debug(struct pool_ctl *p, char *name); - -void pool_debug_walk(pool_ctl *p); - -#endif /* OBOS_POOLS_H */