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