1 // SPDX-FileCopyrightText: Copyright (c) 2017-2024, HONEE contributors. 2 // SPDX-License-Identifier: Apache-2.0 OR BSD-2-Clause 3 #pragma once 4 5 #include <petscsys.h> 6 7 #if defined(__clang_analyzer__) 8 #define PETSC_CEED_EXTERN extern 9 #elif defined(__cplusplus) 10 #define PETSC_CEED_EXTERN extern "C" 11 #else 12 #define PETSC_CEED_EXTERN extern 13 #endif 14 15 #if defined(__clang_analyzer__) 16 #define PETSC_CEED_INTERN 17 #else 18 #define PETSC_CEED_INTERN PETSC_CEED_EXTERN __attribute__((visibility("hidden"))) 19 #endif 20 21 /** 22 @brief Calls a libCEED function and then checks the resulting error code. 23 If the error code is non-zero, then a PETSc error is set with the libCEED error message. 24 **/ 25 #ifndef PetscCallCeed 26 #define PetscCallCeed(ceed_, ...) \ 27 do { \ 28 int ierr_q_; \ 29 PetscStackUpdateLine; \ 30 ierr_q_ = __VA_ARGS__; \ 31 if (PetscUnlikely(ierr_q_ != CEED_ERROR_SUCCESS)) { \ 32 const char *error_message; \ 33 CeedGetErrorMessage(ceed_, &error_message); \ 34 SETERRQ(PETSC_COMM_SELF, PETSC_ERR_LIB, "%s", error_message); \ 35 } \ 36 } while (0) 37 #endif 38