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),
23 : 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 53 : errno_t ret = memcpy_s(sdk_ctx.reserved, sizeof(sdk_ctx.reserved),
36 : 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 : }
|