tbb_environment.h
Go to the documentation of this file.
/*
Copyright (c) 2018-2020 Intel Corporation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
#ifndef __TBB_tbb_environment_H
#define __TBB_tbb_environment_H
#include <cstdlib>
#include <cstring>
#include <cerrno>
#include <cctype>
namespace tbb {
namespace internal {
#if __TBB_WIN8UI_SUPPORT
static inline bool GetBoolEnvironmentVariable( const char * ) {
return false;
}
static inline long GetIntegralEnvironmentVariable( const char * ) {
return -1;
}
#else /* __TBB_WIN8UI_SUPPORT */
static inline bool GetBoolEnvironmentVariable( const char * name ) {
if( const char* s = std::getenv(name) )
{
// The result is defined as true only if the environment variable contains
// no characters except one '1' character and an arbitrary number of spaces
// (including the absence of spaces).
size_t index = std::strspn(s, " ");
if (s[index] != '1') return false;
index++;
// Memory access after incrementing is safe, since the getenv() returns a
// NULL terminated string, and even if the character getting by index is '1',
// and this character is the end of string, after incrementing we will get
// an index of character, that contains '\0'
index += std::strspn(&s[index], " ");
return !s[index];
}
return false;
}
static inline long GetIntegralEnvironmentVariable( const char * name ) {
if( const char* s = std::getenv(name) )
{
char* end = NULL;
errno = 0;
long value = std::strtol(s, &end, 10);
// We have exceeded the range, value is negative or string is incovertable
if ( errno == ERANGE || value < 0 || end==s )
{
return -1;
}
for ( ; *end != '\0'; end++ )
{
if ( !std::isspace(*end) )
return -1;
}
return value;
}
return -1;
}
#endif /* __TBB_WIN8UI_SUPPORT */
} // namespace internal
} // namespace tbb
#endif // __TBB_tbb_environment_H
s
void const char const char int ITT_FORMAT __itt_group_sync s
Definition: ittnotify_static.h:91
end
void const char const char int ITT_FORMAT __itt_group_sync x void const char ITT_FORMAT __itt_group_sync s void ITT_FORMAT __itt_group_sync p void ITT_FORMAT p void ITT_FORMAT p no args __itt_suppress_mode_t unsigned int void size_t ITT_FORMAT d void ITT_FORMAT p void ITT_FORMAT p __itt_model_site __itt_model_site_instance ITT_FORMAT p __itt_model_task __itt_model_task_instance ITT_FORMAT p void ITT_FORMAT p void ITT_FORMAT p void size_t ITT_FORMAT d void ITT_FORMAT p const wchar_t ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s no args void ITT_FORMAT p size_t ITT_FORMAT d no args const wchar_t const wchar_t ITT_FORMAT s __itt_heap_function void size_t int ITT_FORMAT d __itt_heap_function void ITT_FORMAT p __itt_heap_function void void size_t int ITT_FORMAT d no args no args unsigned int ITT_FORMAT u const __itt_domain __itt_id ITT_FORMAT lu const __itt_domain __itt_id __itt_id __itt_string_handle ITT_FORMAT p const __itt_domain __itt_id ITT_FORMAT p const __itt_domain __itt_id __itt_timestamp __itt_timestamp end
Definition: ittnotify_static.h:182
name
void const char const char int ITT_FORMAT __itt_group_sync x void const char * name
Definition: ittnotify_static.h:93
value
void const char const char int ITT_FORMAT __itt_group_sync x void const char ITT_FORMAT __itt_group_sync s void ITT_FORMAT __itt_group_sync p void ITT_FORMAT p void ITT_FORMAT p no args __itt_suppress_mode_t unsigned int void size_t ITT_FORMAT d void ITT_FORMAT p void ITT_FORMAT p __itt_model_site __itt_model_site_instance ITT_FORMAT p __itt_model_task __itt_model_task_instance ITT_FORMAT p void ITT_FORMAT p void ITT_FORMAT p void size_t ITT_FORMAT d void ITT_FORMAT p const wchar_t ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s no args void ITT_FORMAT p size_t ITT_FORMAT d no args const wchar_t const wchar_t ITT_FORMAT s __itt_heap_function void size_t int ITT_FORMAT d __itt_heap_function void ITT_FORMAT p __itt_heap_function void void size_t int ITT_FORMAT d no args no args unsigned int ITT_FORMAT u const __itt_domain __itt_id ITT_FORMAT lu const __itt_domain __itt_id __itt_id __itt_string_handle ITT_FORMAT p const __itt_domain __itt_id ITT_FORMAT p const __itt_domain __itt_id __itt_timestamp __itt_timestamp ITT_FORMAT lu const __itt_domain __itt_id __itt_id __itt_string_handle ITT_FORMAT p const __itt_domain ITT_FORMAT p const __itt_domain __itt_string_handle unsigned long long value
Definition: ittnotify_static.h:192
tbb
The graph class.
Definition: serial/tbb/parallel_for.h:46
tbb::internal::GetBoolEnvironmentVariable
static bool GetBoolEnvironmentVariable(const char *name)
Definition: tbb_environment.h:38
tbb::internal::GetIntegralEnvironmentVariable
static long GetIntegralEnvironmentVariable(const char *name)
Definition: tbb_environment.h:57
internal
Definition: _flow_graph_async_msg_impl.h:24

Copyright © 2005-2020 Intel Corporation. All Rights Reserved.

Intel, Pentium, Intel Xeon, Itanium, Intel XScale and VTune are registered trademarks or trademarks of Intel Corporation or its subsidiaries in the United States and other countries.

* Other names and brands may be claimed as the property of others.