LCOV - code coverage report
Current view: top level - include - kernel_print_lock.h (source / functions) Coverage Total Hit
Test: coverage.info_filtered Lines: 100.0 % 4 4
Test Date: 2026-07-27 14:41:20 Functions: 100.0 % 1 1

            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              : /*!
      12              :  * \file kernel_print_lock.h
      13              :  * \brief
      14              :  */
      15              : #ifndef ASCENDC_KERNEL_PRINT_LOCK_H
      16              : #define ASCENDC_KERNEL_PRINT_LOCK_H
      17              : #include <pthread.h>
      18              : 
      19              : namespace AscendC {
      20              : class KernelPrintLock {
      21              : public:
      22              :     int Lock();
      23              :     int Unlock();
      24              :     void UnInit();
      25              :     static void FreeLock();
      26              :     static KernelPrintLock* CreateLock();
      27           16 :     static KernelPrintLock* GetLock()
      28              :     {
      29           16 :         if (printLock == nullptr) {
      30           12 :             printLock = CreateLock();
      31              :         }
      32           16 :         return printLock;
      33              :     }
      34              : 
      35              : private:
      36              :     KernelPrintLock();
      37              :     ~KernelPrintLock();
      38              : 
      39              : private:
      40              :     pthread_rwlock_t lock;
      41              :     pthread_rwlockattr_t attr;
      42              :     inline void Init();
      43              :     static KernelPrintLock* printLock;
      44              : };
      45              : } // namespace AscendC
      46              : 
      47              : #endif // ASCENDC_KERNEL_PRINT_LOCK_H
        

Generated by: LCOV version 2.0-1