2 * omp-state.cpp -- OMPD states
5 //===----------------------------------------------------------------------===//
7 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
8 // See https://llvm.org/LICENSE.txt for license information.
9 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
11 //===----------------------------------------------------------------------===//
13 #include "omp-debug.h"
14 #include "ompd-private.h"
17 void __ompd_init_states(const ompd_callbacks_t
*table
) { callbacks
= table
; }
19 static const char *get_ompd_state_name(ompd_word_t state
) {
21 #define ompd_state_macro(state, code) \
24 FOREACH_OMPD_STATE(ompd_state_macro
)
25 #undef ompd_state_macro
32 ompd_enumerate_states(ompd_address_space_handle_t
*address_space_handle
,
33 ompd_word_t current_state
, ompd_word_t
*next_state
,
34 const char **next_state_name
, ompd_word_t
*more_enums
) {
36 if (current_state
> ompt_state_undefined
&&
37 current_state
>= OMPD_LAST_OMP_STATE
) {
38 return ompd_rc_bad_input
;
40 const char *find_next_state_name
;
41 *next_state
= (current_state
== ompt_state_undefined
? ompt_state_work_serial
43 while (!(find_next_state_name
= get_ompd_state_name(*next_state
))) {
47 char *next_state_name_cpy
;
48 ret
= callbacks
->alloc_memory(strlen(find_next_state_name
) + 1,
49 (void **)&next_state_name_cpy
);
50 if (ret
!= ompd_rc_ok
) {
53 strcpy(next_state_name_cpy
, find_next_state_name
);
55 *next_state_name
= next_state_name_cpy
;
57 if (*next_state
== OMPD_LAST_OMP_STATE
) {