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 "adiag_lock.h"
12 :
13 : /**
14 : * @brief initial lock
15 : * @param [in] lock: lock pointer
16 : * @return AdiagStatus
17 : */
18 8493 : AdiagStatus AdiagLockInit(AdiagLock* lock) { return (mmMutexInit(lock) == EN_OK) ? ADIAG_SUCCESS : ADIAG_FAILURE; }
19 :
20 : /**
21 : * @brief destroy lock
22 : * @param [in] lock: lock pointer
23 : * @return AdiagStatus
24 : */
25 6525 : AdiagStatus AdiagLockDestroy(AdiagLock* lock)
26 : {
27 6525 : return (mmMutexDestroy(lock) == EN_OK) ? ADIAG_SUCCESS : ADIAG_FAILURE;
28 : }
29 :
30 : /**
31 : * @brief lock
32 : * @param [in] lock: lock pointer
33 : * @return AdiagStatus
34 : */
35 3707868 : AdiagStatus AdiagLockGet(AdiagLock* lock) { return (mmMutexLock(lock) == EN_OK) ? ADIAG_SUCCESS : ADIAG_FAILURE; }
36 :
37 : /**
38 : * @brief unlock
39 : * @param [in] lock: lock pointer
40 : * @return AdiagStatus
41 : */
42 3707867 : AdiagStatus AdiagLockRelease(AdiagLock* lock) { return (mmMutexUnLock(lock) == EN_OK) ? ADIAG_SUCCESS : ADIAG_FAILURE; }
|