Subversion Repositories HelenOS-historic

Rev

Rev 623 | Rev 1100 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 623 Rev 625
Line 30... Line 30...
30
#define __SPINLOCK_H__
30
#define __SPINLOCK_H__
31
 
31
 
32
#include <arch/types.h>
32
#include <arch/types.h>
33
#include <typedefs.h>
33
#include <typedefs.h>
34
#include <preemption.h>
34
#include <preemption.h>
-
 
35
#include <arch/atomic.h>
35
 
36
 
36
#ifdef CONFIG_SMP
37
#ifdef CONFIG_SMP
37
struct spinlock {
38
struct spinlock {
38
#ifdef CONFIG_DEBUG_SPINLOCK
39
#ifdef CONFIG_DEBUG_SPINLOCK
39
    char *name;
40
    char *name;
40
#endif
41
#endif
41
    int val;
42
    atomic_t val;
42
};
43
};
43
 
44
 
44
/*
45
/*
45
 * SPINLOCK_DECLARE is to be used for dynamically allocated spinlocks,
46
 * SPINLOCK_DECLARE is to be used for dynamically allocated spinlocks,
46
 * where the lock gets initialized in run time.
47
 * where the lock gets initialized in run time.
Line 53... Line 54...
53
 */
54
 */
54
#ifdef CONFIG_DEBUG_SPINLOCK
55
#ifdef CONFIG_DEBUG_SPINLOCK
55
#define SPINLOCK_INITIALIZE(slname)     \
56
#define SPINLOCK_INITIALIZE(slname)     \
56
    spinlock_t slname = {       \
57
    spinlock_t slname = {       \
57
        .name = #slname,    \
58
        .name = #slname,    \
58
        .val = 0        \
59
        .val = { 0 }        \
59
    }
60
    }
60
#else
61
#else
61
#define SPINLOCK_INITIALIZE(slname)     \
62
#define SPINLOCK_INITIALIZE(slname)     \
62
    spinlock_t slname = {       \
63
    spinlock_t slname = {       \
63
        .val = 0        \
64
        .val = { 0 }        \
64
    }
65
    }
65
#endif
66
#endif
66
 
67
 
67
extern void spinlock_initialize(spinlock_t *sl, char *name);
68
extern void spinlock_initialize(spinlock_t *sl, char *name);
68
extern void spinlock_lock(spinlock_t *sl);
69
extern void spinlock_lock(spinlock_t *sl);