cleanup C - Julia BigFloat interop #104
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
C controls
mpfr_t
memory, Julia controlsBigFloat
memory.BigFloat
s have an extra field,sizeof(BigFloat) == 40
, an array is passed asmpfr_t **
, and implicitly the only datum in the second level of addressing is dereferenced by[0]
.BigFloat
is a mutable struct, there is no guarantee that each entry inan
Array{BigFloat}
has a unique pointer. For example, looking at theLimb
s,shows that the ones and the zeros all share the same pointers. If a C function
assumes unicity of each datum, then the array must be renewed with a
deepcopy
.Before this PR, some of the
BigFloat
tests were skipped becauseBigFloat
was unsafely converted tompfr_t
before passing to C. I suspect this was unsafe because the garbage collector could free someBigFloat
data after the conversion tompfr_t
but before functions were done executing.