1 #if !defined(__PETSC_P4EST_PACKAGE_H) 2 #define __PETSC_P4EST_PACKAGE_H 3 #include <petscsys.h> 4 #include <p4est_base.h> 5 6 #if defined(PETSC_HAVE_SETJMP_H) && defined(PETSC_USE_ERRORCHECKING) 7 #include <setjmp.h> 8 PETSC_INTERN jmp_buf PetscScJumpBuf; 9 10 #define PetscStackCallP4est(func,args) do { \ 11 if (setjmp(PetscScJumpBuf)) { \ 12 return PetscError(PETSC_COMM_SELF,__LINE__,PETSC_FUNCTION_NAME,__FILE__,PETSC_ERR_LIB,PETSC_ERROR_REPEAT,"Error in p4est/libsc call %s()",#func); \ 13 } \ 14 else { \ 15 PetscStackPush(#func); \ 16 func args; \ 17 PetscStackPop; \ 18 } \ 19 } while (0) 20 #define PetscStackCallP4estReturn(ret,func,args) do { \ 21 if (setjmp(PetscScJumpBuf)) { \ 22 return PetscError(PETSC_COMM_SELF,__LINE__,PETSC_FUNCTION_NAME,__FILE__,PETSC_ERR_LIB,PETSC_ERROR_REPEAT,"Error in p4est/libsc call %s()",#func); \ 23 } \ 24 else { \ 25 PetscStackPush(#func); \ 26 ret = func args; \ 27 PetscStackPop; \ 28 } \ 29 } while (0) 30 #else 31 #define PetscStackCallP4est(func,args) do { \ 32 PetscStackPush(#func); \ 33 func args; \ 34 PetscStackPop; \ 35 } while (0) 36 #define PetscStackCallP4estReturn(ret,func,args) do { \ 37 PetscStackPush(#func); \ 38 ret = func args; \ 39 PetscStackPop; \ 40 } while (0) 41 #endif 42 43 PETSC_EXTERN PetscErrorCode PetscP4estInitialize(); 44 45 PETSC_STATIC_INLINE PetscErrorCode P4estLocidxCast(PetscInt a,p4est_locidx_t *b) 46 { 47 PetscFunctionBegin; 48 *b = (p4est_locidx_t)(a); 49 #if defined(PETSC_USE_64BIT_INDICES) 50 if ((a) > P4EST_LOCIDX_MAX) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_OUTOFRANGE,"Index to large for p4est_locidx_t"); 51 #endif 52 PetscFunctionReturn(0); 53 } 54 55 PETSC_STATIC_INLINE PetscErrorCode P4estTopidxCast(PetscInt a,p4est_topidx_t *b) 56 { 57 PetscFunctionBegin; 58 *b = (p4est_topidx_t)(a); 59 #if defined(PETSC_USE_64BIT_INDICES) 60 if ((a) > P4EST_TOPIDX_MAX) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_OUTOFRANGE,"Index to large for p4est_topidx_t"); 61 #endif 62 PetscFunctionReturn(0); 63 } 64 65 #endif 66