Hi Rob,
I've been working on very similar code for RPerl recently, and I've been able to do it without any use of GMP_HAS_MAGICEXT whatsoever, so that may be an indicator that you can safely remove it?
I have created a typedef to make the mpz_t type accessible via the gmp_integer alias.
https://github.com/wbraswell/rperl/blob/master/lib/RPerl/DataType/GMPInteger.h#L14
Pertinent X_pack*() & X_unpack*() subroutines, with multiple code options and comments:
https://github.com/wbraswell/rperl/blob/master/lib/RPerl/DataType/GMPInteger.cpp#L69-L215
Hope it might help a bit!
Perling,
~ Will the Chill