Lines Matching refs:rw

14 void eMrwlock_read_enter(eMrwlock_t *rw, char *file, int line)  in eMrwlock_read_enter()  argument
16 if (rw->eMrw_magic != EMM_MAGIC) { in eMrwlock_read_enter()
18 rw->eMrw_owner, rw, rw->eMrw_magic); in eMrwlock_read_enter()
21 if (rw->eMrw_read != 0 || rw->eMrw_write != 0) { in eMrwlock_read_enter()
24 rw->eMrw_owner, rw, rw->eMrw_read, rw->eMrw_write); in eMrwlock_read_enter()
27 rw->eMrw_read++; in eMrwlock_read_enter()
28 rw->eMrw_heldin = file; in eMrwlock_read_enter()
29 rw->eMrw_heldat = line; in eMrwlock_read_enter()
33 void eMrwlock_write_enter(eMrwlock_t *rw, char *file, int line) in eMrwlock_write_enter() argument
35 if (rw->eMrw_magic != EMM_MAGIC) { in eMrwlock_write_enter()
37 rw->eMrw_owner, rw, rw->eMrw_magic); in eMrwlock_write_enter()
40 if (rw->eMrw_read != 0 || rw->eMrw_write != 0) { in eMrwlock_write_enter()
43 rw->eMrw_owner, rw, rw->eMrw_read, rw->eMrw_write); in eMrwlock_write_enter()
46 rw->eMrw_write++; in eMrwlock_write_enter()
47 rw->eMrw_heldin = file; in eMrwlock_write_enter()
48 rw->eMrw_heldat = line; in eMrwlock_write_enter()
52 void eMrwlock_try_upgrade(eMrwlock_t *rw, char *file, int line) in eMrwlock_try_upgrade() argument
54 if (rw->eMrw_magic != EMM_MAGIC) { in eMrwlock_try_upgrade()
56 rw->eMrw_owner, rw, rw->eMrw_magic); in eMrwlock_try_upgrade()
59 if (rw->eMrw_read != 0 || rw->eMrw_write != 0) { in eMrwlock_try_upgrade()
62 rw->eMrw_owner, rw, rw->eMrw_read, rw->eMrw_write); in eMrwlock_try_upgrade()
65 rw->eMrw_write++; in eMrwlock_try_upgrade()
66 rw->eMrw_heldin = file; in eMrwlock_try_upgrade()
67 rw->eMrw_heldat = line; in eMrwlock_try_upgrade()
70 void eMrwlock_downgrade(eMrwlock_t *rw, char *file, int line) in eMrwlock_downgrade() argument
72 if (rw->eMrw_magic != EMM_MAGIC) { in eMrwlock_downgrade()
74 rw->eMrw_owner, rw, rw->eMrw_magic); in eMrwlock_downgrade()
77 if (rw->eMrw_read != 0 || rw->eMrw_write != 1) { in eMrwlock_downgrade()
80 rw->eMrw_owner, rw, rw->eMrw_read, rw->eMrw_write); in eMrwlock_downgrade()
83 rw->eMrw_write--; in eMrwlock_downgrade()
84 rw->eMrw_read++; in eMrwlock_downgrade()
85 rw->eMrw_heldin = file; in eMrwlock_downgrade()
86 rw->eMrw_heldat = line; in eMrwlock_downgrade()
90 void eMrwlock_exit(eMrwlock_t *rw) in eMrwlock_exit() argument
92 if (rw->eMrw_magic != EMM_MAGIC) { in eMrwlock_exit()
94 rw->eMrw_owner, rw, rw->eMrw_magic); in eMrwlock_exit()
97 if (rw->eMrw_read != 1 && rw->eMrw_write != 1) { in eMrwlock_exit()
99 rw->eMrw_owner, rw, rw->eMrw_read, rw->eMrw_write); in eMrwlock_exit()
102 if (rw->eMrw_read == 1) in eMrwlock_exit()
103 rw->eMrw_read--; in eMrwlock_exit()
104 else if (rw->eMrw_write == 1) in eMrwlock_exit()
105 rw->eMrw_write--; in eMrwlock_exit()
106 rw->eMrw_heldin = NULL; in eMrwlock_exit()
107 rw->eMrw_heldat = 0; in eMrwlock_exit()
113 void eMrwlock_init(eMrwlock_t *rw, char *who) in eMrwlock_init() argument
115 if (rw->eMrw_magic == EMM_MAGIC) { /* safe bet ? */ in eMrwlock_init()
118 rw->eMrw_owner, rw, rw->eMrw_magic); in eMrwlock_init()
121 rw->eMrw_magic = EMM_MAGIC; in eMrwlock_init()
122 rw->eMrw_read = 0; in eMrwlock_init()
123 rw->eMrw_write = 0; in eMrwlock_init()
125 rw->eMrw_owner = strdup(who); in eMrwlock_init()
127 rw->eMrw_owner = NULL; in eMrwlock_init()
132 void eMrwlock_destroy(eMrwlock_t *rw) in eMrwlock_destroy() argument
134 if (rw->eMrw_magic != EMM_MAGIC) { in eMrwlock_destroy()
136 rw->eMrw_owner, rw, rw->eMrw_magic); in eMrwlock_destroy()
139 if (rw->eMrw_owner != NULL) in eMrwlock_destroy()
140 free(rw->eMrw_owner); in eMrwlock_destroy()
141 memset(rw, 0xa5, sizeof(*rw)); in eMrwlock_destroy()