LCOV - code coverage report
Current view: top level - base_comm/resources/endpoint_pairs/channels - channel_config.cc (source / functions) Coverage Total Hit
Test: coverage.info Lines: 91.7 % 24 22
Test Date: 2026-08-29 17:38:31 Functions: 100.0 % 3 3

            Line data    Source code
       1              : /**
       2              :  * Copyright (c) 2025 Huawei Technologies Co., Ltd.
       3              :  * This program is free software, you can redistribute it and/or modify it under the terms and conditions of
       4              :  * CANN Open Software License Agreement Version 2.0 (the "License").
       5              :  * Please refer to the License for details. You may not use this file except in compliance with the License.
       6              :  * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
       7              :  * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
       8              :  * See LICENSE in the root of the software repository for the full text of the License.
       9              :  */
      10              : 
      11              : #include "channel_config.h"
      12              : #include "log.h"
      13              : #include "exception_handler.h"
      14              : 
      15              : namespace hcomm {
      16              : 
      17            6 : HcommResult ChannelConfigCreate(HcommChannelConfig* config)
      18              : {
      19            6 :     CHK_PTR_NULL(config);
      20            5 :     NEW_NOTHROW(*config, HcommChannelConfigData(), return HCCL_E_PTR);
      21            5 :     return HCCL_SUCCESS;
      22              : }
      23              : 
      24            6 : HcommResult ChannelConfigDestroy(HcommChannelConfig config)
      25              : {
      26            6 :     CHK_PTR_NULL(config);
      27            5 :     auto* cfg = static_cast<HcommChannelConfigData*>(config);
      28            5 :     if (cfg->destroyed_.exchange(true)) {
      29            0 :         HCCL_WARNING("[%s] config[%p] is already destroyed, skip to avoid double-free.", __func__, config);
      30            0 :         return HCCL_SUCCESS;
      31              :     }
      32            5 :     delete cfg;
      33            5 :     return HCCL_SUCCESS;
      34              : }
      35              : 
      36            3 : HcommResult ChannelConfigSetInt(HcommChannelConfig config, HcommChannelConfigType type, uint32_t value)
      37              : {
      38            3 :     CHK_PTR_NULL(config);
      39            2 :     auto* cfg = static_cast<HcommChannelConfigData*>(config);
      40            2 :     switch (type) {
      41            1 :         case HCOMM_CHANNEL_CONFIG_TYPE_IS_SHARED_QUEUE:
      42            1 :             cfg->isSharedQueue = (value != 0);
      43            1 :             HCCL_INFO("[%s] set IS_SHARED_QUEUE=%d.", __func__, static_cast<int>(cfg->isSharedQueue));
      44            1 :             break;
      45            1 :         default:
      46            1 :             HCCL_ERROR("[%s] invalid int config type[%d].", __func__, static_cast<int>(type));
      47            1 :             return HCCL_E_PARA;
      48              :     }
      49            1 :     return HCCL_SUCCESS;
      50              : }
      51              : 
      52              : } // namespace hcomm
        

Generated by: LCOV version 2.0-1