Changeset dc747e3 in mainline for generic/include


Ignore:
Timestamp:
2005-12-15T10:27:59Z (20 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
7dd2561
Parents:
3fc03fd
Message:

Add SPINLOCK_DECLARE and SPINLOCK_INITIALIZE macros.
SPINLOCK_DECLARE is to be used instead of direct spinlock_t declarations
in dynamically allocated structures on which spinlock_initialize() is called after
their creation.
SPINLOCK_INITIALIZE is to be used instead of direct spinlock_t declarations
of global spinlocks. It declares and initializes the spinlock.
Moreover, both macros are empty on UP so that -Wall warnings about unused structures
get supressed.

Location:
generic/include
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • generic/include/console/chardev.h

    r3fc03fd rdc747e3  
    5353       
    5454        waitq_t wq;
    55         spinlock_t lock;                /**< Protects everything below. */
     55        SPINLOCK_DECLARE(lock);         /**< Protects everything below. */
    5656        __u8 buffer[CHARDEV_BUFLEN];
    5757        count_t counter;
  • generic/include/console/kconsole.h

    r3fc03fd rdc747e3  
    5656struct cmd_info {
    5757        link_t link;                    /**< Command list link. */
    58         spinlock_t lock;                /**< This lock protects everything below. */
     58        SPINLOCK_DECLARE(lock);         /**< This lock protects everything below. */
    5959        const char *name;               /**< Command name. */
    6060        const char *description;        /**< Textual description. */
  • generic/include/cpu.h

    r3fc03fd rdc747e3  
    4343
    4444struct cpu {
    45         spinlock_t lock;
     45        SPINLOCK_DECLARE(lock);
    4646        context_t saved_context;
    4747
     
    5050        volatile count_t needs_relink;
    5151
    52         spinlock_t timeoutlock;
     52        SPINLOCK_DECLARE(timeoutlock);
    5353        link_t timeout_active_head;
    5454
  • generic/include/mm/frame.h

    r3fc03fd rdc747e3  
    5555        link_t link;            /**< link to previous and next zone */
    5656
    57         spinlock_t lock;        /**< this lock protects everything below */
     57        SPINLOCK_DECLARE(lock); /**< this lock protects everything below */
    5858        __address base;         /**< physical address of the first frame in the frames array */
    5959        frame_t *frames;        /**< array of frame_t structures in this zone */
  • generic/include/mm/vm.h

    r3fc03fd rdc747e3  
    5858 */
    5959struct vm_area {
    60         spinlock_t lock;
     60        SPINLOCK_DECLARE(lock);
    6161        link_t link;
    6262        vm_type_t type;
     
    7373 */
    7474struct vm {
    75         spinlock_t lock;
     75        SPINLOCK_DECLARE(lock);
    7676        link_t vm_area_head;
    7777        pte_t *ptl0;
  • generic/include/proc/scheduler.h

    r3fc03fd rdc747e3  
    4141/** Scheduler run queue structure. */
    4242struct runq {
    43         spinlock_t lock;
     43        SPINLOCK_DECLARE(lock);
    4444        link_t rq_head;         /**< List of ready threads. */
    4545        count_t n;              /**< Number of threads in rq_ready. */
  • generic/include/proc/task.h

    r3fc03fd rdc747e3  
    3535
    3636struct task {
    37         spinlock_t lock;
     37        SPINLOCK_DECLARE(lock);
    3838        link_t th_head;         /**< List of threads contained in this task. */
    3939        link_t tasks_link;      /**< Link to other tasks within the system. */
  • generic/include/proc/thread.h

    r3fc03fd rdc747e3  
    7171         *
    7272         */
    73         spinlock_t lock;
     73        SPINLOCK_DECLARE(lock);
    7474
    7575        void (* thread_code)(void *);           /**< Function implementing the thread. */
  • generic/include/synch/rwlock.h

    r3fc03fd rdc747e3  
    3434#include <synch/mutex.h>
    3535#include <synch/synch.h>
     36#include <synch/spinlock.h>
    3637
    3738enum rwlock_type {
     
    4243
    4344struct rwlock {
    44         spinlock_t lock;
     45        SPINLOCK_DECLARE(lock);
    4546        mutex_t exclusive;      /**< Mutex for writers, readers can bypass it if readers_in is positive. */
    4647        count_t readers_in;     /**< Number of readers in critical section. */
  • generic/include/synch/spinlock.h

    r3fc03fd rdc747e3  
    4242};
    4343
     44/*
     45 * SPINLOCK_DECLARE is to be used for dynamically allocated spinlocks,
     46 * where the lock gets initialized in run time.
     47 */
     48#define SPINLOCK_DECLARE(slname)        spinlock_t slname
     49
     50/*
     51 * SPINLOCK_INITIALIZE is to be used for statically allocated spinlocks.
     52 * It declares and initializes the lock.
     53 */
     54#ifdef CONFIG_DEBUG_SPINLOCK
     55#define SPINLOCK_INITIALIZE(slname)     \
     56        spinlock_t slname = {           \
     57                .name = #slname,        \
     58                .val = 0                \
     59        }
     60#else
     61#define SPINLOCK_INITIALIZE(slname)     \
     62        spinlock_t slname = {           \
     63                .val = 0                \
     64        }
     65#endif
     66
    4467extern void spinlock_initialize(spinlock_t *sl, char *name);
    4568extern void spinlock_lock(spinlock_t *sl);
     
    4972#else
    5073
    51 struct spinlock {
    52 };
     74/* On UP systems, spinlocks are effectively left out. */
     75#define SPINLOCK_DECLARE(name)
     76#define SPINLOCK_INITIALIZE(name)
    5377
    5478#define spinlock_initialize(x,name)
  • generic/include/synch/waitq.h

    r3fc03fd rdc747e3  
    4646         * Must be acquired before T.lock for each T of type thread_t.
    4747         */
    48         spinlock_t lock;
     48        SPINLOCK_DECLARE(lock);
    4949
    5050        int missed_wakeups;     /**< Number of waitq_wakeup() calls that didn't find a thread to wake up. */
  • generic/include/time/timeout.h

    r3fc03fd rdc747e3  
    4040
    4141struct timeout {
    42         spinlock_t lock;
     42        SPINLOCK_DECLARE(lock);
    4343
    4444        link_t link;                    /**< Link to the list of active timeouts on THE->cpu */
Note: See TracChangeset for help on using the changeset viewer.