~ubuntu-branches/ubuntu/utopic/xen/utopic

« back to all changes in this revision

Viewing changes to extras/mini-os/include/sys/lock.h

  • Committer: Bazaar Package Importer
  • Author(s): Bastian Blank
  • Date: 2010-05-06 15:47:38 UTC
  • mto: (1.3.1) (15.1.1 sid) (4.1.1 experimental)
  • mto: This revision was merged to the branch mainline in revision 3.
  • Revision ID: james.westby@ubuntu.com-20100506154738-agoz0rlafrh1fnq7
Tags: upstream-4.0.0
ImportĀ upstreamĀ versionĀ 4.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifndef _MINIOS_SYS_LOCK_H_
 
2
#define _MINIOS_SYS_LOCK_H_
 
3
 
 
4
#ifdef HAVE_LIBC
 
5
 
 
6
/* Due to inclusion loop, we can not include sched.h, so have to hide things */
 
7
 
 
8
#include <mini-os/waittypes.h>
 
9
 
 
10
 
 
11
typedef struct {
 
12
        int busy;
 
13
        struct wait_queue_head wait;
 
14
} _LOCK_T;
 
15
 
 
16
#define __LOCK_INIT(class,lock) \
 
17
    class _LOCK_T lock = { .wait = __WAIT_QUEUE_HEAD_INITIALIZER(lock.wait) }
 
18
int ___lock_init(_LOCK_T *lock);
 
19
int ___lock_acquire(_LOCK_T *lock);
 
20
int ___lock_try_acquire(_LOCK_T *lock);
 
21
int ___lock_release(_LOCK_T *lock);
 
22
int ___lock_close(_LOCK_T *lock);
 
23
#define __lock_init(__lock) ___lock_init(&__lock)
 
24
#define __lock_acquire(__lock) ___lock_acquire(&__lock)
 
25
#define __lock_release(__lock) ___lock_release(&__lock)
 
26
#define __lock_try_acquire(__lock) ___lock_try_acquire(&__lock)
 
27
#define __lock_close(__lock) 0
 
28
 
 
29
 
 
30
typedef struct {
 
31
    struct thread *owner;
 
32
    int count;
 
33
    struct wait_queue_head wait;
 
34
} _LOCK_RECURSIVE_T;
 
35
 
 
36
#define __LOCK_INIT_RECURSIVE(class, lock) \
 
37
    class _LOCK_RECURSIVE_T lock = { .wait = __WAIT_QUEUE_HEAD_INITIALIZER((lock).wait) }
 
38
 
 
39
int ___lock_init_recursive(_LOCK_RECURSIVE_T *lock);
 
40
int ___lock_acquire_recursive(_LOCK_RECURSIVE_T *lock);
 
41
int ___lock_try_acquire_recursive(_LOCK_RECURSIVE_T *lock);
 
42
int ___lock_release_recursive(_LOCK_RECURSIVE_T *lock);
 
43
int ___lock_close_recursive(_LOCK_RECURSIVE_T *lock);
 
44
#define __lock_init_recursive(__lock) ___lock_init_recursive(&__lock)
 
45
#define __lock_acquire_recursive(__lock) ___lock_acquire_recursive(&__lock)
 
46
#define __lock_release_recursive(__lock) ___lock_release_recursive(&__lock)
 
47
#define __lock_try_acquire_recursive(__lock) ___lock_try_acquire_recursive(&__lock)
 
48
#define __lock_close_recursive(__lock) 0
 
49
 
 
50
#endif
 
51
 
 
52
#endif /* _MINIOS_SYS_LOCK_H_ */