MCPcopy Create free account
hub / github.com/catboost/catboost / _cmsGetTime

Function _cmsGetTime

contrib/libs/lcms2/src/cmsplugin.c:1028–1055  ·  view source on GitHub ↗

Use context mutex to provide thread-safe time

Source from the content-addressed store, hash-verified

1026
1027// Use context mutex to provide thread-safe time
1028cmsBool _cmsGetTime(struct tm* ptr_time)
1029{
1030 struct tm* t;
1031#if defined(HAVE_GMTIME_R) || defined(HAVE_GMTIME_S)
1032 struct tm tm;
1033#endif
1034
1035 time_t now = time(NULL);
1036
1037#ifdef HAVE_GMTIME_R
1038 t = gmtime_r(&now, &tm);
1039#elif defined(HAVE_GMTIME_S)
1040 t = gmtime_s(&tm, &now) == 0 ? &tm : NULL;
1041#else
1042 if (!InitContextMutex()) return FALSE;
1043
1044 _cmsEnterCriticalSectionPrimitive(&_cmsContextPoolHeadMutex);
1045 t = gmtime(&now);
1046 _cmsLeaveCriticalSectionPrimitive(&_cmsContextPoolHeadMutex);
1047#endif
1048
1049 if (t == NULL)
1050 return FALSE;
1051 else {
1052 *ptr_time = *t;
1053 return TRUE;
1054 }
1055}

Callers 1

Calls 4

gmtime_rFunction · 0.85
InitContextMutexFunction · 0.85

Tested by

no test coverage detected