|
33 | 33 |
|
34 | 34 |
|
35 | 35 | /* |
36 | | - * Distributate lock handling |
| 36 | + * Distributed lock handling |
37 | 37 | */ |
38 | | -static dlock_mutex_t * |
39 | | -dlock_hash(dlock_mutex_t *__array, uint32_t w1, uint32_t w2) |
| 38 | +static pthread_mutex_t * |
| 39 | +dlock_hash(pthread_mutex_t *__array, uint32_t w1, uint32_t w2) |
40 | 40 | { |
41 | | - return __array + (jhash_2words(w1, w2, 0) & DLOCK_HASHTAB_MASK); |
| 41 | + return &__array[(jhash_2words(w1, w2, 0) & DLOCK_HASHTAB_MASK)]; |
42 | 42 | } |
43 | 43 |
|
44 | 44 | int |
45 | | -dlock_lock_id(dlock_mutex_t *__array, uint32_t w1, uint32_t w2) |
| 45 | +dlock_lock_id(pthread_mutex_t *__array, uint32_t w1, uint32_t w2) |
46 | 46 | { |
47 | | - dlock_mutex_t *m = dlock_hash(__array, w1, w2); |
48 | | - pthread_mutex_lock(&m->mutex); |
49 | | - __sync_add_and_fetch(&m->refcnt, 1); |
| 47 | + pthread_mutex_t *m = dlock_hash(__array, w1, w2); |
| 48 | + pthread_mutex_lock(m); |
50 | 49 | return 0; |
51 | 50 | } |
52 | 51 |
|
53 | 52 | int |
54 | | -dlock_unlock_id(dlock_mutex_t *__array, uint32_t w1, uint32_t w2) |
| 53 | +dlock_unlock_id(pthread_mutex_t *__array, uint32_t w1, uint32_t w2) |
55 | 54 | { |
56 | | - dlock_mutex_t *m = dlock_hash(__array, w1, w2); |
57 | | - if (__sync_sub_and_fetch(&m->refcnt, 1) == 0) |
58 | | - pthread_mutex_unlock(&m->mutex); |
| 55 | + pthread_mutex_t *m = dlock_hash(__array, w1, w2); |
| 56 | + pthread_mutex_unlock(m); |
59 | 57 | return 0; |
60 | 58 | } |
61 | 59 |
|
62 | | -dlock_mutex_t * |
| 60 | +pthread_mutex_t * |
63 | 61 | dlock_init(void) |
64 | 62 | { |
65 | | - dlock_mutex_t *new; |
66 | | - new = (dlock_mutex_t *) MALLOC(DLOCK_HASHTAB_SIZE * sizeof(dlock_mutex_t)); |
67 | | - return new; |
68 | | -} |
69 | | - |
70 | | -int |
71 | | -dlock_destroy(dlock_mutex_t *__array) |
72 | | -{ |
73 | | - FREE(__array); |
74 | | - return 0; |
| 63 | + return MALLOC(DLOCK_HASHTAB_SIZE * sizeof(pthread_mutex_t)); |
75 | 64 | } |
76 | 65 |
|
77 | 66 | /* |
|
0 commit comments