Changeset dc747e3 in mainline for generic/include/synch/spinlock.h


Ignore:
Timestamp:
2005-12-15T10:27:59Z (19 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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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)
Note: See TracChangeset for help on using the changeset viewer.