Actual source code: petsc_p4est_package.h

  1: #pragma once
  2: #include <petscsys.h>
  3: #if PetscDefined(HAVE_MPIUNI)
  4:   #undef MPI_SUCCESS
  5: #endif
  6: #include <p4est_base.h>
  7: #if PetscDefined(HAVE_MPIUNI)
  8:   #define MPI_SUCCESS 0
  9: #endif

 11: #if PetscDefined(HAVE_SETJMP_H) && PetscDefined(USE_DEBUG)
 12:   #include <setjmp.h>
 13: PETSC_INTERN jmp_buf PetscScJumpBuf;

 15:   #define PetscCallP4est(func, ...) \
 16:     do { \
 17:       if (setjmp(PetscScJumpBuf)) { \
 18:         return PetscError(PETSC_COMM_SELF, __LINE__, PETSC_FUNCTION_NAME, __FILE__, PETSC_ERR_LIB, PETSC_ERROR_REPEAT, "Error in p4est/libsc call %s()", #func); \
 19:       } else { \
 20:         PetscStackPushExternal(#func); \
 21:         func(__VA_ARGS__); \
 22:         PetscStackPop; \
 23:       } \
 24:     } while (0)
 25:   #define PetscCallP4estReturn(ret, func, ...) \
 26:     do { \
 27:       if (setjmp(PetscScJumpBuf)) { \
 28:         return PetscError(PETSC_COMM_SELF, __LINE__, PETSC_FUNCTION_NAME, __FILE__, PETSC_ERR_LIB, PETSC_ERROR_REPEAT, "Error in p4est/libsc call %s()", #func); \
 29:       } else { \
 30:         PetscStackPushExternal(#func); \
 31:         ret = func(__VA_ARGS__); \
 32:         PetscStackPop; \
 33:       } \
 34:     } while (0)
 35: #else
 36:   #define PetscCallP4est(func, ...) \
 37:     do { \
 38:       PetscStackPushExternal(#func); \
 39:       func(__VA_ARGS__); \
 40:       PetscStackPop; \
 41:     } while (0)
 42:   #define PetscCallP4estReturn(ret, func, ...) \
 43:     do { \
 44:       PetscStackPushExternal(#func); \
 45:       ret = func(__VA_ARGS__); \
 46:       PetscStackPop; \
 47:     } while (0)
 48: #endif

 50: #if defined(P4EST_ENABLE_DEBUG)
 51:   #define PETSC_P4EST_ASSERT(x) P4EST_ASSERT(x)
 52: #else
 53:   #define PETSC_P4EST_ASSERT(x) (void)(x)
 54: #endif

 56: PETSC_EXTERN PetscErrorCode PetscP4estInitialize(void);

 58: static inline PetscErrorCode P4estLocidxCast(PetscInt a, p4est_locidx_t *b)
 59: {
 60:   PetscFunctionBegin;
 61:   *b = (p4est_locidx_t)(a);
 62:   PetscCheck(!PetscDefined(USE_64BIT_INDICES) || (a) <= P4EST_LOCIDX_MAX, PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Index to large for p4est_locidx_t");
 63:   PetscFunctionReturn(PETSC_SUCCESS);
 64: }

 66: static inline PetscErrorCode P4estTopidxCast(PetscInt a, p4est_topidx_t *b)
 67: {
 68:   PetscFunctionBegin;
 69:   *b = (p4est_topidx_t)(a);
 70:   PetscCheck(!PetscDefined(USE_64BIT_INDICES) || (a) <= P4EST_TOPIDX_MAX, PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Index to large for p4est_topidx_t");
 71:   PetscFunctionReturn(PETSC_SUCCESS);
 72: }