Line data Source code
1 : /**
2 : * Copyright (c) 2026 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 <string>
12 : #include "adapter_error_manager.h"
13 : #include "base/err_mgr.h"
14 : #include "log.h"
15 :
16 52 : ErrContext hrtErrMGetErrorContext(void)
17 : {
18 52 : error_message::ErrorManagerContext sdk_ctx = error_message::GetErrMgrContext();
19 :
20 52 : ErrContext local_ctx;
21 52 : local_ctx.work_stream_id = sdk_ctx.work_stream_id;
22 : // 复制 reserved 数组
23 52 : errno_t ret = memcpy_s(local_ctx.reserved, sizeof(local_ctx.reserved), sdk_ctx.reserved, sizeof(sdk_ctx.reserved));
24 :
25 52 : CHK_PRT_RET(ret != EOK, HCCL_ERROR("[%s]memcpy failed. errorno[%d]:", __func__, ret), local_ctx);
26 :
27 52 : return local_ctx;
28 : }
29 :
30 53 : void hrtErrMSetErrorContext(ErrContext error_context)
31 : {
32 53 : error_message::ErrorManagerContext sdk_ctx;
33 53 : sdk_ctx.work_stream_id = error_context.work_stream_id;
34 : // 复制 reserved 数组
35 : errno_t ret
36 53 : = memcpy_s(sdk_ctx.reserved, sizeof(sdk_ctx.reserved), error_context.reserved, sizeof(error_context.reserved));
37 :
38 53 : if (ret != EOK) {
39 0 : HCCL_ERROR("[%s]memcpy failed. errorno[%d]:", __func__, ret);
40 0 : return;
41 : }
42 :
43 53 : error_message::SetErrMgrContext(sdk_ctx);
44 : }
|