Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/ittnotify/ittnotify_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -208,10 +208,10 @@
#define ITT_MAGIC { 0xED, 0xAB, 0xAB, 0xEC, 0x0D, 0xEE, 0xDA, 0x30 }

/* Replace with snapshot date YYYYMMDD for promotion build. */
#define API_VERSION_BUILD 20250429
#define API_VERSION_BUILD 20250807

#ifndef API_VERSION_NUM
#define API_VERSION_NUM 3.26.0
#define API_VERSION_NUM 3.26.3
#endif /* API_VERSION_NUM */

#define API_VERSION "ITT-API-Version " ITT_TO_STR(API_VERSION_NUM) \
Expand Down
10 changes: 6 additions & 4 deletions src/ittnotify/ittnotify_static.c
Original file line number Diff line number Diff line change
Expand Up @@ -952,6 +952,7 @@ static void ITTAPI ITT_VERSIONIZE(ITT_JOIN(_N_(bind_context_metadata_to_counter)
{
if (PTHREAD_SYMBOLS) __itt_mutex_unlock(&_N_(_ittapi_global).mutex);
ITTNOTIFY_NAME(bind_context_metadata_to_counter)(counter, length, metadata);
return;
}
else
{
Expand Down Expand Up @@ -1344,14 +1345,12 @@ static void __itt_nullify_all_pointers(void)

static int __itt_is_collector_available(void)
{
int is_available;

ITT_MUTEX_INIT_AND_LOCK(_N_(_ittapi_global));
if (_N_(_ittapi_global).state == __itt_collection_uninitialized)
{
_N_(_ittapi_global).state = (NULL == __itt_get_lib_name()) ? __itt_collection_collector_absent : __itt_collection_collector_exists;
}
is_available = (_N_(_ittapi_global).state == __itt_collection_collector_exists ||
int is_available = (_N_(_ittapi_global).state == __itt_collection_collector_exists ||
_N_(_ittapi_global).state == __itt_collection_init_successful);
__itt_mutex_unlock(&_N_(_ittapi_global).mutex);
return is_available;
Expand Down Expand Up @@ -1663,11 +1662,14 @@ ITT_EXTERN_C void _N_(mark_pt_region_end)(__itt_pt_region region)

ITT_EXTERN_C __itt_collection_state (_N_(get_collection_state))(void)
{
ITT_MUTEX_INIT_AND_LOCK(_N_(_ittapi_global));
if (!_N_(_ittapi_global).api_initialized && _N_(_ittapi_global).thread_list == NULL)
{
__itt_init_ittlib_name(NULL, __itt_group_all);
}
return _N_(_ittapi_global).state;
__itt_collection_state state = _N_(_ittapi_global).state;
if (PTHREAD_SYMBOLS) __itt_mutex_unlock(&_N_(_ittapi_global).mutex);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why init&lock are performed with macros and unlock with function?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A macro is preferred for init and lock because it can inline platform-specific logic, atomic checks, and initialization steps directly into the calling code. This avoids function call overhead and ensures the mutex is initialized and locked efficiently.
The unlock __itt_mutex_unlock() is a simple function call of the pthread_mutex_unlock(), and it does not require the extra logic.
But I also don't like the inconsistency you pointed out, and I will take that into account in future code improvements, thanks for the comment!

return state;
}

/* !!! should be called from the library destructor !!!
Expand Down
Loading