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