1 // Copyright (c) 2017-2024, 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 #ifndef PetscCallCeed 30 #define PetscCallCeed(ceed_, ...) \ 31 do { \ 32 int ierr_q_; \ 33 PetscStackUpdateLine; \ 34 ierr_q_ = __VA_ARGS__; \ 35 if (PetscUnlikely(ierr_q_ != CEED_ERROR_SUCCESS)) { \ 36 const char *error_message; \ 37 CeedGetErrorMessage(ceed_, &error_message); \ 38 SETERRQ(PETSC_COMM_SELF, PETSC_ERR_LIB, "%s", error_message); \ 39 } \ 40 } while (0) 41 #endif 42