OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [tags/] [LINUX_2_4_26_OR32/] [linux/] [linux-2.4/] [include/] [linux/] [wait.h] - Diff between revs 1279 and 1765

Only display areas with differences | Details | Blame | View Log

Rev 1279 Rev 1765
#ifndef _LINUX_WAIT_H
#ifndef _LINUX_WAIT_H
#define _LINUX_WAIT_H
#define _LINUX_WAIT_H
 
 
#define WNOHANG         0x00000001
#define WNOHANG         0x00000001
#define WUNTRACED       0x00000002
#define WUNTRACED       0x00000002
 
 
#define __WNOTHREAD     0x20000000      /* Don't wait on children of other threads in this group */
#define __WNOTHREAD     0x20000000      /* Don't wait on children of other threads in this group */
#define __WALL          0x40000000      /* Wait on all children, regardless of type */
#define __WALL          0x40000000      /* Wait on all children, regardless of type */
#define __WCLONE        0x80000000      /* Wait only on non-SIGCHLD children */
#define __WCLONE        0x80000000      /* Wait only on non-SIGCHLD children */
 
 
#ifdef __KERNEL__
#ifdef __KERNEL__
 
 
#include <linux/kernel.h>
#include <linux/kernel.h>
#include <linux/list.h>
#include <linux/list.h>
#include <linux/stddef.h>
#include <linux/stddef.h>
#include <linux/spinlock.h>
#include <linux/spinlock.h>
#include <linux/config.h>
#include <linux/config.h>
 
 
#include <asm/page.h>
#include <asm/page.h>
#include <asm/processor.h>
#include <asm/processor.h>
 
 
/*
/*
 * Debug control.  Slow but useful.
 * Debug control.  Slow but useful.
 */
 */
#if defined(CONFIG_DEBUG_WAITQ)
#if defined(CONFIG_DEBUG_WAITQ)
#define WAITQUEUE_DEBUG 1
#define WAITQUEUE_DEBUG 1
#else
#else
#define WAITQUEUE_DEBUG 0
#define WAITQUEUE_DEBUG 0
#endif
#endif
 
 
struct __wait_queue {
struct __wait_queue {
        unsigned int flags;
        unsigned int flags;
#define WQ_FLAG_EXCLUSIVE       0x01
#define WQ_FLAG_EXCLUSIVE       0x01
        struct task_struct * task;
        struct task_struct * task;
        struct list_head task_list;
        struct list_head task_list;
#if WAITQUEUE_DEBUG
#if WAITQUEUE_DEBUG
        long __magic;
        long __magic;
        long __waker;
        long __waker;
#endif
#endif
};
};
typedef struct __wait_queue wait_queue_t;
typedef struct __wait_queue wait_queue_t;
 
 
/*
/*
 * 'dual' spinlock architecture. Can be switched between spinlock_t and
 * 'dual' spinlock architecture. Can be switched between spinlock_t and
 * rwlock_t locks via changing this define. Since waitqueues are quite
 * rwlock_t locks via changing this define. Since waitqueues are quite
 * decoupled in the new architecture, lightweight 'simple' spinlocks give
 * decoupled in the new architecture, lightweight 'simple' spinlocks give
 * us slightly better latencies and smaller waitqueue structure size.
 * us slightly better latencies and smaller waitqueue structure size.
 */
 */
#define USE_RW_WAIT_QUEUE_SPINLOCK 0
#define USE_RW_WAIT_QUEUE_SPINLOCK 0
 
 
#if USE_RW_WAIT_QUEUE_SPINLOCK
#if USE_RW_WAIT_QUEUE_SPINLOCK
# define wq_lock_t rwlock_t
# define wq_lock_t rwlock_t
# define WAITQUEUE_RW_LOCK_UNLOCKED RW_LOCK_UNLOCKED
# define WAITQUEUE_RW_LOCK_UNLOCKED RW_LOCK_UNLOCKED
 
 
# define wq_read_lock read_lock
# define wq_read_lock read_lock
# define wq_read_lock_irqsave read_lock_irqsave
# define wq_read_lock_irqsave read_lock_irqsave
# define wq_read_unlock_irqrestore read_unlock_irqrestore
# define wq_read_unlock_irqrestore read_unlock_irqrestore
# define wq_read_unlock read_unlock
# define wq_read_unlock read_unlock
# define wq_write_lock_irq write_lock_irq
# define wq_write_lock_irq write_lock_irq
# define wq_write_lock_irqsave write_lock_irqsave
# define wq_write_lock_irqsave write_lock_irqsave
# define wq_write_unlock_irqrestore write_unlock_irqrestore
# define wq_write_unlock_irqrestore write_unlock_irqrestore
# define wq_write_unlock write_unlock
# define wq_write_unlock write_unlock
#else
#else
# define wq_lock_t spinlock_t
# define wq_lock_t spinlock_t
# define WAITQUEUE_RW_LOCK_UNLOCKED SPIN_LOCK_UNLOCKED
# define WAITQUEUE_RW_LOCK_UNLOCKED SPIN_LOCK_UNLOCKED
 
 
# define wq_read_lock spin_lock
# define wq_read_lock spin_lock
# define wq_read_lock_irqsave spin_lock_irqsave
# define wq_read_lock_irqsave spin_lock_irqsave
# define wq_read_unlock spin_unlock
# define wq_read_unlock spin_unlock
# define wq_read_unlock_irqrestore spin_unlock_irqrestore
# define wq_read_unlock_irqrestore spin_unlock_irqrestore
# define wq_write_lock_irq spin_lock_irq
# define wq_write_lock_irq spin_lock_irq
# define wq_write_lock_irqsave spin_lock_irqsave
# define wq_write_lock_irqsave spin_lock_irqsave
# define wq_write_unlock_irqrestore spin_unlock_irqrestore
# define wq_write_unlock_irqrestore spin_unlock_irqrestore
# define wq_write_unlock spin_unlock
# define wq_write_unlock spin_unlock
#endif
#endif
 
 
struct __wait_queue_head {
struct __wait_queue_head {
        wq_lock_t lock;
        wq_lock_t lock;
        struct list_head task_list;
        struct list_head task_list;
#if WAITQUEUE_DEBUG
#if WAITQUEUE_DEBUG
        long __magic;
        long __magic;
        long __creator;
        long __creator;
#endif
#endif
};
};
typedef struct __wait_queue_head wait_queue_head_t;
typedef struct __wait_queue_head wait_queue_head_t;
 
 
 
 
/*
/*
 * Debugging macros.  We eschew `do { } while (0)' because gcc can generate
 * Debugging macros.  We eschew `do { } while (0)' because gcc can generate
 * spurious .aligns.
 * spurious .aligns.
 */
 */
#if WAITQUEUE_DEBUG
#if WAITQUEUE_DEBUG
#define WQ_BUG()        BUG()
#define WQ_BUG()        BUG()
#define CHECK_MAGIC(x)                                                  \
#define CHECK_MAGIC(x)                                                  \
        do {                                                                    \
        do {                                                                    \
                if ((x) != (long)&(x)) {                                        \
                if ((x) != (long)&(x)) {                                        \
                        printk("bad magic %lx (should be %lx), ",               \
                        printk("bad magic %lx (should be %lx), ",               \
                                (long)x, (long)&(x));                           \
                                (long)x, (long)&(x));                           \
                        WQ_BUG();                                               \
                        WQ_BUG();                                               \
                }                                                               \
                }                                                               \
        } while (0)
        } while (0)
#define CHECK_MAGIC_WQHEAD(x)                                                   \
#define CHECK_MAGIC_WQHEAD(x)                                                   \
        do {                                                                    \
        do {                                                                    \
                if ((x)->__magic != (long)&((x)->__magic)) {                    \
                if ((x)->__magic != (long)&((x)->__magic)) {                    \
                        printk("bad magic %lx (should be %lx, creator %lx), ",  \
                        printk("bad magic %lx (should be %lx, creator %lx), ",  \
                        (x)->__magic, (long)&((x)->__magic), (x)->__creator);   \
                        (x)->__magic, (long)&((x)->__magic), (x)->__creator);   \
                        WQ_BUG();                                               \
                        WQ_BUG();                                               \
                }                                                               \
                }                                                               \
        } while (0)
        } while (0)
#define WQ_CHECK_LIST_HEAD(list)                                                \
#define WQ_CHECK_LIST_HEAD(list)                                                \
        do {                                                                    \
        do {                                                                    \
                if (!(list)->next || !(list)->prev)                             \
                if (!(list)->next || !(list)->prev)                             \
                        WQ_BUG();                                               \
                        WQ_BUG();                                               \
        } while(0)
        } while(0)
#define WQ_NOTE_WAKER(tsk)                                                      \
#define WQ_NOTE_WAKER(tsk)                                                      \
        do {                                                                    \
        do {                                                                    \
                (tsk)->__waker = (long)__builtin_return_address(0);              \
                (tsk)->__waker = (long)__builtin_return_address(0);              \
        } while (0)
        } while (0)
#else
#else
#define WQ_BUG()
#define WQ_BUG()
#define CHECK_MAGIC(x)
#define CHECK_MAGIC(x)
#define CHECK_MAGIC_WQHEAD(x)
#define CHECK_MAGIC_WQHEAD(x)
#define WQ_CHECK_LIST_HEAD(list)
#define WQ_CHECK_LIST_HEAD(list)
#define WQ_NOTE_WAKER(tsk)
#define WQ_NOTE_WAKER(tsk)
#endif
#endif
 
 
/*
/*
 * Macros for declaration and initialization of the datatypes
 * Macros for declaration and initialization of the datatypes
 */
 */
 
 
#if WAITQUEUE_DEBUG
#if WAITQUEUE_DEBUG
# define __WAITQUEUE_DEBUG_INIT(name) (long)&(name).__magic, 0
# define __WAITQUEUE_DEBUG_INIT(name) (long)&(name).__magic, 0
# define __WAITQUEUE_HEAD_DEBUG_INIT(name) (long)&(name).__magic, (long)&(name).__magic
# define __WAITQUEUE_HEAD_DEBUG_INIT(name) (long)&(name).__magic, (long)&(name).__magic
#else
#else
# define __WAITQUEUE_DEBUG_INIT(name)
# define __WAITQUEUE_DEBUG_INIT(name)
# define __WAITQUEUE_HEAD_DEBUG_INIT(name)
# define __WAITQUEUE_HEAD_DEBUG_INIT(name)
#endif
#endif
 
 
#define __WAITQUEUE_INITIALIZER(name, tsk) {                            \
#define __WAITQUEUE_INITIALIZER(name, tsk) {                            \
        task:           tsk,                                            \
        task:           tsk,                                            \
        task_list:      { NULL, NULL },                                 \
        task_list:      { NULL, NULL },                                 \
                         __WAITQUEUE_DEBUG_INIT(name)}
                         __WAITQUEUE_DEBUG_INIT(name)}
 
 
#define DECLARE_WAITQUEUE(name, tsk)                                    \
#define DECLARE_WAITQUEUE(name, tsk)                                    \
        wait_queue_t name = __WAITQUEUE_INITIALIZER(name, tsk)
        wait_queue_t name = __WAITQUEUE_INITIALIZER(name, tsk)
 
 
#define __WAIT_QUEUE_HEAD_INITIALIZER(name) {                           \
#define __WAIT_QUEUE_HEAD_INITIALIZER(name) {                           \
        lock:           WAITQUEUE_RW_LOCK_UNLOCKED,                     \
        lock:           WAITQUEUE_RW_LOCK_UNLOCKED,                     \
        task_list:      { &(name).task_list, &(name).task_list },       \
        task_list:      { &(name).task_list, &(name).task_list },       \
                        __WAITQUEUE_HEAD_DEBUG_INIT(name)}
                        __WAITQUEUE_HEAD_DEBUG_INIT(name)}
 
 
#define DECLARE_WAIT_QUEUE_HEAD(name) \
#define DECLARE_WAIT_QUEUE_HEAD(name) \
        wait_queue_head_t name = __WAIT_QUEUE_HEAD_INITIALIZER(name)
        wait_queue_head_t name = __WAIT_QUEUE_HEAD_INITIALIZER(name)
 
 
static inline void init_waitqueue_head(wait_queue_head_t *q)
static inline void init_waitqueue_head(wait_queue_head_t *q)
{
{
#if WAITQUEUE_DEBUG
#if WAITQUEUE_DEBUG
        if (!q)
        if (!q)
                WQ_BUG();
                WQ_BUG();
#endif
#endif
        q->lock = WAITQUEUE_RW_LOCK_UNLOCKED;
        q->lock = WAITQUEUE_RW_LOCK_UNLOCKED;
        INIT_LIST_HEAD(&q->task_list);
        INIT_LIST_HEAD(&q->task_list);
#if WAITQUEUE_DEBUG
#if WAITQUEUE_DEBUG
        q->__magic = (long)&q->__magic;
        q->__magic = (long)&q->__magic;
        q->__creator = (long)current_text_addr();
        q->__creator = (long)current_text_addr();
#endif
#endif
}
}
 
 
static inline void init_waitqueue_entry(wait_queue_t *q, struct task_struct *p)
static inline void init_waitqueue_entry(wait_queue_t *q, struct task_struct *p)
{
{
#if WAITQUEUE_DEBUG
#if WAITQUEUE_DEBUG
        if (!q || !p)
        if (!q || !p)
                WQ_BUG();
                WQ_BUG();
#endif
#endif
        q->flags = 0;
        q->flags = 0;
        q->task = p;
        q->task = p;
#if WAITQUEUE_DEBUG
#if WAITQUEUE_DEBUG
        q->__magic = (long)&q->__magic;
        q->__magic = (long)&q->__magic;
#endif
#endif
}
}
 
 
static inline int waitqueue_active(wait_queue_head_t *q)
static inline int waitqueue_active(wait_queue_head_t *q)
{
{
#if WAITQUEUE_DEBUG
#if WAITQUEUE_DEBUG
        if (!q)
        if (!q)
                WQ_BUG();
                WQ_BUG();
        CHECK_MAGIC_WQHEAD(q);
        CHECK_MAGIC_WQHEAD(q);
#endif
#endif
 
 
        return !list_empty(&q->task_list);
        return !list_empty(&q->task_list);
}
}
 
 
static inline void __add_wait_queue(wait_queue_head_t *head, wait_queue_t *new)
static inline void __add_wait_queue(wait_queue_head_t *head, wait_queue_t *new)
{
{
#if WAITQUEUE_DEBUG
#if WAITQUEUE_DEBUG
        if (!head || !new)
        if (!head || !new)
                WQ_BUG();
                WQ_BUG();
        CHECK_MAGIC_WQHEAD(head);
        CHECK_MAGIC_WQHEAD(head);
        CHECK_MAGIC(new->__magic);
        CHECK_MAGIC(new->__magic);
        if (!head->task_list.next || !head->task_list.prev)
        if (!head->task_list.next || !head->task_list.prev)
                WQ_BUG();
                WQ_BUG();
#endif
#endif
        list_add(&new->task_list, &head->task_list);
        list_add(&new->task_list, &head->task_list);
}
}
 
 
/*
/*
 * Used for wake-one threads:
 * Used for wake-one threads:
 */
 */
static inline void __add_wait_queue_tail(wait_queue_head_t *head,
static inline void __add_wait_queue_tail(wait_queue_head_t *head,
                                                wait_queue_t *new)
                                                wait_queue_t *new)
{
{
#if WAITQUEUE_DEBUG
#if WAITQUEUE_DEBUG
        if (!head || !new)
        if (!head || !new)
                WQ_BUG();
                WQ_BUG();
        CHECK_MAGIC_WQHEAD(head);
        CHECK_MAGIC_WQHEAD(head);
        CHECK_MAGIC(new->__magic);
        CHECK_MAGIC(new->__magic);
        if (!head->task_list.next || !head->task_list.prev)
        if (!head->task_list.next || !head->task_list.prev)
                WQ_BUG();
                WQ_BUG();
#endif
#endif
        list_add_tail(&new->task_list, &head->task_list);
        list_add_tail(&new->task_list, &head->task_list);
}
}
 
 
static inline void __remove_wait_queue(wait_queue_head_t *head,
static inline void __remove_wait_queue(wait_queue_head_t *head,
                                                        wait_queue_t *old)
                                                        wait_queue_t *old)
{
{
#if WAITQUEUE_DEBUG
#if WAITQUEUE_DEBUG
        if (!old)
        if (!old)
                WQ_BUG();
                WQ_BUG();
        CHECK_MAGIC(old->__magic);
        CHECK_MAGIC(old->__magic);
#endif
#endif
        list_del(&old->task_list);
        list_del(&old->task_list);
}
}
 
 
#endif /* __KERNEL__ */
#endif /* __KERNEL__ */
 
 
#endif
#endif
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.