ErrorCheckMacros.h#

Fully qualified name: public/src/operator/include/ErrorCheckMacros.h

File members: public/src/operator/include/ErrorCheckMacros.h

/*
 * SPDX-FileCopyrightText: Copyright (c) 2024-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
 * SPDX-License-Identifier: LicenseRef-NvidiaProprietary
 *
 * NVIDIA CORPORATION, its affiliates and licensors retain all intellectual
 * property and proprietary rights in and to this material, related
 * documentation and any modifications thereto. Any use, reproduction,
 * disclosure or distribution of this material and related documentation
 * without an express license agreement from NVIDIA CORPORATION or
 * its affiliates is strictly prohibited.
 */

#ifndef ERROR_CHECK_MACROS_H
#define ERROR_CHECK_MACROS_H

#include <cupva_host.h>
#include <nvcv/Status.h>

#ifdef __cplusplus
#    include <cstdio>
#else
#    include <stdio.h>
#endif

#define CUPVA_CHECK_ERROR_GOTO(__v, __e, __l)                                         \
    __e = __v;                                                                        \
    if (__e != CUPVA_ERROR_NONE)                                                      \
    {                                                                                 \
        const char *msgBuffer;                                                        \
        CupvaGetLastError(&msgBuffer);                                                \
        printf("CUPVA error: %d at line %d in function %s\n", (__v), __LINE__, #__v); \
        printf("Error message: %s\n", msgBuffer);                                     \
        goto __l;                                                                     \
    }

#define NVCV_CHECK_ERROR_GOTO(__v, __e, __l)                                         \
    __e = __v;                                                                       \
    if (__e != NVCV_SUCCESS)                                                         \
    {                                                                                \
        char msgBuffer[1024];                                                        \
        nvcvPeekAtLastErrorMessage(msgBuffer, sizeof(msgBuffer));                    \
        printf("NVCV error: %d at line %d in function %s\n", (__v), __LINE__, #__v); \
        printf("Error message: %s\n", msgBuffer);                                    \
        goto __l;                                                                    \
    }

#endif /* ERROR_CHECK_MACROS_H */