| 1183 | } // namespace bthread |
| 1184 | |
| 1185 | __BEGIN_DECLS |
| 1186 | |
| 1187 | int bthread_mutex_init(bthread_mutex_t* __restrict m, |
| 1188 | const bthread_mutexattr_t* __restrict attr) { |
| 1189 | bthread::make_contention_site_invalid(&m->csite); |
| 1190 | MUTEX_RESET_OWNER_COMMON(m->owner); |
| 1191 | m->butex = bthread::butex_create_checked<unsigned>(); |
| 1192 | if (!m->butex) { |
| 1193 | return ENOMEM; |
| 1194 | } |
| 1195 | *m->butex = 0; |
| 1196 | m->enable_csite = NULL == attr ? true : attr->enable_csite; |
| 1197 | return 0; |
| 1198 | } |
| 1199 | |
| 1200 | int bthread_mutex_destroy(bthread_mutex_t* m) { |
| 1201 | bthread::butex_destroy(m->butex); |