[petsc-dev] macro functions growing like rabbits
Jed Brown
jedbrown at mcs.anl.gov
Wed Feb 6 22:12:21 CST 2013
On Wed, Feb 6, 2013 at 10:07 PM, Barry Smith <bsmith at mcs.anl.gov> wrote:
>
>
> While I'm busy converting macro functions to C functions, others
> (unnamed, but Jed knows how to find them using the revision control system)
> are adding new ones like there is no tomorrow.
>
> For example below.
>
> Yes CPP is unfairly useful and some of the uses below do pass types that
> cannot trivially be handled with pure C code, please try to restrict your
> love of CPP to only when absolutely necessary; for example the first one
> below doesn't need to be a macro I think.
>
The first example below was added by Barry in 2008 and can soon be deleted.
https://bitbucket.org/petsc/petsc-dev/commits/2c4d80a83ccb656c1ab09c5dcec9c685c121655f
The second is like PetscTryMethod in that it really needs to be a macro.
> Barry
>
> /*
> Allocates enough space to store Fortran function pointers in PETSc
> object
> that are needed by the Fortran interface.
> */
> #define PetscObjectAllocateFortranPointers(obj,N) do { \
> if (!((PetscObject)(obj))->fortran_func_pointers) { \
> *ierr =
> PetscMalloc((N)*sizeof(void(*)(void)),&((PetscObject)(obj))->fortran_func_pointers);if
> (*ierr) return; \
> *ierr =
> PetscMemzero(((PetscObject)(obj))->fortran_func_pointers,(N)*sizeof(void(*)(void)));if
> (*ierr) return; \
> ((PetscObject)obj)->num_fortran_func_pointers = (N); \
> } \
> } while (0)
>
> /* Entire function body, _ctx is a "special" variable that can be passed
> along */
> #define PetscObjectUseFortranCallback_Private(obj,cid,types,args,cbclass)
> { \
> PetscErrorCode ierr; \
> void (PETSC_STDCALL *func) types,*_ctx; \
> PetscFunctionBegin; \
> ierr =
> PetscObjectGetFortranCallback((PetscObject)(obj),(cbclass),(cid),(PetscVoidFunction*)&func,&_ctx);CHKERRQ(ierr);
> \
> (*func)args;CHKERRQ(ierr); \
> PetscFunctionReturn(0); \
> }
> #define PetscObjectUseFortranCallback(obj,cid,types,args)
> PetscObjectUseFortranCallback_Private(obj,cid,types,args,PETSC_FORTRAN_CALLBACK_CLASS)
> #define PetscObjectUseFortranCallbackSubType(obj,cid,types,args)
> PetscObjectUseFortranCallback_Private(obj,cid,types,args,PETSC_FORTRAN_CALLBACK_SUBTYPE)
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-dev/attachments/20130206/d5a55973/attachment.html>
More information about the petsc-dev
mailing list