Skip to content

Commit 969dcd5

Browse files
committed
Added status.h header, containing useful macros for checking
nixl_status_t
1 parent 49e5754 commit 969dcd5

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

src/utils/common/status.h

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*
2+
* SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
3+
* SPDX-License-Identifier: Apache-2.0
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
#ifndef STATUS_H
19+
#define STATUS_H
20+
21+
#include <iostream>
22+
#include <absl/log/log.h>
23+
#include <absl/strings/str_format.h>
24+
#include "nixl_log.h"
25+
26+
#define NIXL_LOG_AND_RETURN_IF_ERROR(status, message) \
27+
do { \
28+
if ((status) != NIXL_SUCCESS && (status) != NIXL_IN_PROG) { \
29+
NIXL_ERROR << absl::StrFormat("Error: %d - %s", (status), (message)); \
30+
return (status); \
31+
} \
32+
} while (0)
33+
34+
#define NIXL_RETURN_IF_NOT_IN_PROG(status) \
35+
do { \
36+
if ((status) != NIXL_IN_PROG) { \
37+
NIXL_LOG_AND_RETURN_IF_ERROR(status, " Received handle with pre-existing error"); \
38+
return (status); \
39+
} \
40+
} while (0)
41+
42+
#endif /* STATUS_H */

0 commit comments

Comments
 (0)