Subversion Repositories Kolibri OS

Rev

Rev 6099 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 6099 Rev 6109
Line 23... Line 23...
23
{
23
{
24
    int handle;
24
    int handle;
Line 25... Line 25...
25
 
25
 
Line 26... Line 26...
26
    mutex->lock = 0;
26
    mutex->lock = 0;
27
 
27
 
28
    asm volatile(
28
    __asm__ volatile(
29
    "int $0x40\t"
29
    "int $0x40\t"
30
    :"=a"(handle)
30
    :"=a"(handle)
Line 36... Line 36...
36
 
36
 
37
static inline int mutex_destroy(mutex_t *mutex)
37
static inline int mutex_destroy(mutex_t *mutex)
38
{
38
{
Line 39... Line 39...
39
    int retval;
39
    int retval;
40
 
40
 
41
    asm volatile(
41
    __asm__ volatile(
42
    "int $0x40\t"
42
    "int $0x40\t"
Line 43... Line 43...
43
    :"=a"(retval)
43
    :"=a"(retval)
Line 53... Line 53...
53
    if( __sync_fetch_and_add(&mutex->lock, 1) == 0)
53
    if( __sync_fetch_and_add(&mutex->lock, 1) == 0)
54
        return;
54
        return;
Line 55... Line 55...
55
 
55
 
56
    while (exchange_acquire (&mutex->lock, 2) != 0)
56
    while (exchange_acquire (&mutex->lock, 2) != 0)
57
    {
57
    {
58
        asm volatile(
58
        __asm__ volatile(
59
        "int $0x40\t\n"
59
        "int $0x40\t\n"
60
        :"=a"(tmp)
60
        :"=a"(tmp)
61
        :"a"(77),"b"(FUTEX_WAIT),
61
        :"a"(77),"b"(FUTEX_WAIT),
62
        "c"(mutex->handle),"d"(2),"S"(0));
62
        "c"(mutex->handle),"d"(2),"S"(0));
Line 70... Line 70...
70
    if( __sync_fetch_and_add(&mutex->lock, 1) == 0)
70
    if( __sync_fetch_and_add(&mutex->lock, 1) == 0)
71
        return 1;
71
        return 1;
Line 72... Line 72...
72
 
72
 
73
    while (exchange_acquire (&mutex->lock, 2) != 0)
73
    while (exchange_acquire (&mutex->lock, 2) != 0)
74
    {
74
    {
75
        asm volatile(
75
        __asm__ __volatile__(
76
        "int $0x40\t"
76
        "int $0x40\t"
77
        :"=a"(tmp)
77
        :"=a"(tmp)
78
        :"a"(77),"b"(FUTEX_WAIT),
78
        :"a"(77),"b"(FUTEX_WAIT),
Line 97... Line 97...
97
 
97
 
Line 98... Line 98...
98
    prev = exchange_release (&mutex->lock, 0);
98
    prev = exchange_release (&mutex->lock, 0);
99
 
99
 
100
    if (prev != 1)
100
    if (prev != 1)
101
    {
101
    {
102
        asm volatile(
102
        __asm__ volatile(
103
        "int $0x40\t"
103
        "int $0x40\t"
104
        :"=a"(prev)
104
        :"=a"(prev)
105
        :"a"(77),"b"(FUTEX_WAKE),
105
        :"a"(77),"b"(FUTEX_WAKE),