Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / openmp / runtime / src / kmp_environment.h
bloba7ea9e955788dae85056cb1932181fe2b47edae0
1 /*
2 * kmp_environment.h -- Handle environment variables OS-independently.
3 */
5 //===----------------------------------------------------------------------===//
6 //
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 #ifndef KMP_ENVIRONMENT_H
14 #define KMP_ENVIRONMENT_H
16 #ifdef __cplusplus
17 extern "C" {
18 #endif
20 // Return a copy of the value of environment variable or NULL if the variable
21 // does not exist.
22 // *Note*: Returned pointed *must* be freed after use with __kmp_env_free().
23 char *__kmp_env_get(char const *name);
24 void __kmp_env_free(char const **value);
26 // Return 1 if the environment variable exists or 0 if does not exist.
27 int __kmp_env_exists(char const *name);
29 // Set the environment variable.
30 void __kmp_env_set(char const *name, char const *value, int overwrite);
32 // Unset (remove) environment variable.
33 void __kmp_env_unset(char const *name);
35 // -----------------------------------------------------------------------------
36 // Working with environment blocks.
38 /* kmp_env_blk_t is read-only collection of environment variables (or
39 environment-like). Usage:
41 kmp_env_blk_t block;
42 __kmp_env_blk_init( & block, NULL ); // Initialize block from process
43 // environment.
44 // or
45 __kmp_env_blk_init( & block, "KMP_WARNING=1|KMP_AFFINITY=none" ); // from string
46 __kmp_env_blk_sort( & block ); // Optionally, sort list.
47 for ( i = 0; i < block.count; ++ i ) {
48 // Process block.vars[ i ].name and block.vars[ i ].value...
50 __kmp_env_block_free( & block );
53 struct __kmp_env_var {
54 char *name;
55 char *value;
57 typedef struct __kmp_env_var kmp_env_var_t;
59 struct __kmp_env_blk {
60 char *bulk;
61 kmp_env_var_t *vars;
62 int count;
64 typedef struct __kmp_env_blk kmp_env_blk_t;
66 void __kmp_env_blk_init(kmp_env_blk_t *block, char const *bulk);
67 void __kmp_env_blk_free(kmp_env_blk_t *block);
68 void __kmp_env_blk_sort(kmp_env_blk_t *block);
69 char const *__kmp_env_blk_var(kmp_env_blk_t *block, char const *name);
71 #ifdef __cplusplus
73 #endif
75 #endif // KMP_ENVIRONMENT_H
77 // end of file //