The CLI may install the sink more than once in one process (notably tests), * so keep one process-lifetime mutex rather than destroying it at fini. */
| 40 | /* The CLI may install the sink more than once in one process (notably tests), |
| 41 | * so keep one process-lifetime mutex rather than destroying it at fini. */ |
| 42 | static void progress_sink_mutex_ensure(void) { |
| 43 | int expected = LOCK_UNINITIALIZED; |
| 44 | if (atomic_compare_exchange_strong_explicit(&s_sink_mutex_state, &expected, LOCK_INITIALIZING, |
| 45 | memory_order_acq_rel, memory_order_acquire)) { |
| 46 | cbm_mutex_init(&s_sink_mutex); |
| 47 | atomic_store_explicit(&s_sink_mutex_state, LOCK_READY, memory_order_release); |
| 48 | return; |
| 49 | } |
| 50 | while (atomic_load_explicit(&s_sink_mutex_state, memory_order_acquire) != LOCK_READY) {} |
| 51 | } |
| 52 | |
| 53 | bool cbm_cli_output_flags_parse(int *argc, char **argv, cbm_cli_output_flags_t *flags, char *error, |
| 54 | size_t error_size) { |
no test coverage detected