78 lines · c
1/*2 * kmp_environment.h -- Handle environment variables OS-independently.3 */4 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-exception10//11//===----------------------------------------------------------------------===//12 13#ifndef KMP_ENVIRONMENT_H14#define KMP_ENVIRONMENT_H15 16#ifdef __cplusplus17extern "C" {18#endif19 20// Return a copy of the value of environment variable or NULL if the variable21// does not exist.22// *Note*: Returned pointed *must* be freed after use with __kmp_env_free().23char *__kmp_env_get(char const *name);24void __kmp_env_free(char const **value);25 26// Return 1 if the environment variable exists or 0 if does not exist.27int __kmp_env_exists(char const *name);28 29// Set the environment variable.30void __kmp_env_set(char const *name, char const *value, int overwrite);31 32// Unset (remove) environment variable.33void __kmp_env_unset(char const *name);34 35// -----------------------------------------------------------------------------36// Working with environment blocks.37 38/* kmp_env_blk_t is read-only collection of environment variables (or39 environment-like). Usage:40 41kmp_env_blk_t block;42__kmp_env_blk_init( & block, NULL ); // Initialize block from process43 // environment.44// or45__kmp_env_blk_init( & block, "KMP_WARNING=1|KMP_AFFINITY=none" ); // from string46__kmp_env_blk_sort( & block ); // Optionally, sort list.47for ( i = 0; i < block.count; ++ i ) {48 // Process block.vars[ i ].name and block.vars[ i ].value...49}50__kmp_env_block_free( & block );51*/52 53struct __kmp_env_var {54 char *name;55 char *value;56};57typedef struct __kmp_env_var kmp_env_var_t;58 59struct __kmp_env_blk {60 char *bulk;61 kmp_env_var_t *vars;62 int count;63};64typedef struct __kmp_env_blk kmp_env_blk_t;65 66void __kmp_env_blk_init(kmp_env_blk_t *block, char const *bulk);67void __kmp_env_blk_free(kmp_env_blk_t *block);68void __kmp_env_blk_sort(kmp_env_blk_t *block);69char const *__kmp_env_blk_var(kmp_env_blk_t *block, char const *name);70 71#ifdef __cplusplus72}73#endif74 75#endif // KMP_ENVIRONMENT_H76 77// end of file //78