1 // Copyright (c) 2017-2025, Lawrence Livermore National Security, LLC and other CEED contributors. 2 // All Rights Reserved. See the top-level LICENSE and NOTICE files for details. 3 // 4 // SPDX-License-Identifier: BSD-2-Clause 5 // 6 // This file is part of CEED: http://github.com/ceed 7 #pragma once 8 9 #include <petscsys.h> 10 11 #if defined(__clang_analyzer__) 12 #define PETSC_CEED_EXTERN extern 13 #elif defined(__cplusplus) 14 #define PETSC_CEED_EXTERN extern "C" 15 #else 16 #define PETSC_CEED_EXTERN extern 17 #endif 18 19 #if defined(__clang_analyzer__) 20 #define PETSC_CEED_INTERN 21 #else 22 #define PETSC_CEED_INTERN PETSC_CEED_EXTERN __attribute__((visibility("hidden"))) 23 #endif 24 25 /** 26 @brief Calls a libCEED function and then checks the resulting error code. 27 If the error code is non-zero, then a PETSc error is set with the libCEED error message. 28 **/ 29 /// @ingroup RatelInternal 30 #ifndef PetscCallCeed 31 #define PetscCallCeed(ceed_, ...) \ 32 do { \ 33 int ierr_q_; \ 34 PetscStackUpdateLine; \ 35 ierr_q_ = __VA_ARGS__; \ 36 if (PetscUnlikely(ierr_q_ != CEED_ERROR_SUCCESS)) { \ 37 const char *error_message; \ 38 CeedGetErrorMessage(ceed_, &error_message); \ 39 SETERRQ(PETSC_COMM_SELF, PETSC_ERR_LIB, "%s", error_message); \ 40 } \ 41 } while (0) 42 #endif 43