2 * kmp_environment.h -- Handle environment variables OS-independently.
5 //===----------------------------------------------------------------------===//
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
20 // Return a copy of the value of environment variable or NULL if the variable
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:
42 __kmp_env_blk_init( & block, NULL ); // Initialize block from process
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
{
57 typedef struct __kmp_env_var kmp_env_var_t
;
59 struct __kmp_env_blk
{
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
);
75 #endif // KMP_ENVIRONMENT_H