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. */
| 37 | /* The CLI may install the sink more than once in one process (notably tests), |
| 38 | * so keep one process-lifetime mutex rather than destroying it at fini. */ |
| 39 | static void progress_sink_mutex_ensure(void) { |
| 40 | int expected = LOCK_UNINITIALIZED; |
| 41 | if (atomic_compare_exchange_strong_explicit(&s_sink_mutex_state, &expected, LOCK_INITIALIZING, |
| 42 | memory_order_acq_rel, memory_order_acquire)) { |
| 43 | cbm_mutex_init(&s_sink_mutex); |
| 44 | atomic_store_explicit(&s_sink_mutex_state, LOCK_READY, memory_order_release); |
| 45 | return; |
| 46 | } |
| 47 | while (atomic_load_explicit(&s_sink_mutex_state, memory_order_acquire) != LOCK_READY) {} |
| 48 | } |
| 49 | |
| 50 | bool cbm_cli_progress_enabled(bool explicitly_requested, bool stderr_is_tty) { |
| 51 | return explicitly_requested || stderr_is_tty; |
no test coverage detected