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 : #include "awatchdog.h"
11 : #include <unistd.h>
12 : #include "adiag_print.h"
13 : #include "awatchdog_core.h"
14 :
15 16 : AwdHandle AwdCreateThreadWatchdog(uint32_t dogId, uint32_t timeout, AwatchdogCallbackFunc callback)
16 : {
17 16 : AwdThreadWatchdog *dog = AwdWatchdogCreate(dogId, timeout, callback, AWD_WATCHDOG_TYPE_THREAD);
18 16 : if (dog == NULL) {
19 6 : return AWD_INVALID_HANDLE;
20 : }
21 10 : return (AwdHandle)dog;
22 : }
23 :
24 11 : void AwdDestroyThreadWatchdog(AwdHandle handle)
25 : {
26 11 : if (handle == AWD_INVALID_HANDLE) {
27 0 : return;
28 : }
29 11 : AwdThreadWatchdog *dog = (AwdThreadWatchdog *)handle;
30 11 : AWD_ATOMIC_TEST_AND_SET(&dog->startCount, AWD_STATUS_DESTROYED);
31 : }
|