Intel(R) Threading Building Blocks Doxygen Documentation  version 4.2.3
tbb_environment.h
Go to the documentation of this file.
1 /*
2  Copyright (c) 2005-2019 Intel Corporation
3 
4  Licensed under the Apache License, Version 2.0 (the "License");
5  you may not use this file except in compliance with the License.
6  You may obtain a copy of the License at
7 
8  http://www.apache.org/licenses/LICENSE-2.0
9 
10  Unless required by applicable law or agreed to in writing, software
11  distributed under the License is distributed on an "AS IS" BASIS,
12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  See the License for the specific language governing permissions and
14  limitations under the License.
15 
16 
17 
18 
19 */
20 
21 #ifndef __TBB_tbb_environment_H
22 #define __TBB_tbb_environment_H
23 
24 #include <cstdlib>
25 #include <cstring>
26 
27 namespace tbb {
28 
29 namespace internal {
30 
31 #if __TBB_WIN8UI_SUPPORT
32 static inline bool GetBoolEnvironmentVariable( const char * ) {
33  return false;
34 }
35 #else /* __TBB_WIN8UI_SUPPORT */
36 static inline bool GetBoolEnvironmentVariable( const char * name ) {
37  if( const char* s = std::getenv(name) )
38  {
39  // The result is defined as true only if the environment variable contains
40  // no characters except one '1' character and an arbitrary number of spaces
41  // (including the absence of spaces).
42  size_t index = std::strspn(s, " ");
43  if (s[index] != '1') return false;
44  index++;
45  // Memory access after incrementing is safe, since the getenv() returns a
46  // NULL terminated string, and even if the character getting by index is '1',
47  // and this character is the end of string, after incrementing we will get
48  // an index of character, that contains '\0'
49  index += std::strspn(&s[index], " ");
50  return !s[index];
51  }
52  return false;
53 }
54 #endif /* __TBB_WIN8UI_SUPPORT */
55 
56 } // namespace internal
57 } // namespace tbb
58 
59 #endif // __TBB_tbb_environment_H
The graph class.
void const char const char int ITT_FORMAT __itt_group_sync s
static bool GetBoolEnvironmentVariable(const char *name)
void const char const char int ITT_FORMAT __itt_group_sync x void const char * name

Copyright © 2005-2019 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.