Path: blob/main/contrib/llvm-project/openmp/runtime/src/kmp_environment.h
35258 views
/*1* kmp_environment.h -- Handle environment variables OS-independently.2*/34//===----------------------------------------------------------------------===//5//6// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.7// See https://llvm.org/LICENSE.txt for license information.8// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception9//10//===----------------------------------------------------------------------===//1112#ifndef KMP_ENVIRONMENT_H13#define KMP_ENVIRONMENT_H1415#ifdef __cplusplus16extern "C" {17#endif1819// Return a copy of the value of environment variable or NULL if the variable20// does not exist.21// *Note*: Returned pointed *must* be freed after use with __kmp_env_free().22char *__kmp_env_get(char const *name);23void __kmp_env_free(char const **value);2425// Return 1 if the environment variable exists or 0 if does not exist.26int __kmp_env_exists(char const *name);2728// Set the environment variable.29void __kmp_env_set(char const *name, char const *value, int overwrite);3031// Unset (remove) environment variable.32void __kmp_env_unset(char const *name);3334// -----------------------------------------------------------------------------35// Working with environment blocks.3637/* kmp_env_blk_t is read-only collection of environment variables (or38environment-like). Usage:3940kmp_env_blk_t block;41__kmp_env_blk_init( & block, NULL ); // Initialize block from process42// environment.43// or44__kmp_env_blk_init( & block, "KMP_WARNING=1|KMP_AFFINITY=none" ); // from string45__kmp_env_blk_sort( & block ); // Optionally, sort list.46for ( i = 0; i < block.count; ++ i ) {47// Process block.vars[ i ].name and block.vars[ i ].value...48}49__kmp_env_block_free( & block );50*/5152struct __kmp_env_var {53char *name;54char *value;55};56typedef struct __kmp_env_var kmp_env_var_t;5758struct __kmp_env_blk {59char *bulk;60kmp_env_var_t *vars;61int count;62};63typedef struct __kmp_env_blk kmp_env_blk_t;6465void __kmp_env_blk_init(kmp_env_blk_t *block, char const *bulk);66void __kmp_env_blk_free(kmp_env_blk_t *block);67void __kmp_env_blk_sort(kmp_env_blk_t *block);68char const *__kmp_env_blk_var(kmp_env_blk_t *block, char const *name);6970#ifdef __cplusplus71}72#endif7374#endif // KMP_ENVIRONMENT_H7576// end of file //777879