Skip to content

Commit

Permalink
Merge pull request #7662 from nabobalis/ana_fix
Browse files Browse the repository at this point in the history
Update ANA for GCC 14
  • Loading branch information
nabobalis committed Jun 10, 2024
2 parents ca6f09e + 9c434c8 commit 09319a1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
1 change: 1 addition & 0 deletions changelog/7662.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix compilation with gcc 14, avoid implicit pointer conversions.
7 changes: 2 additions & 5 deletions sunpy/io/src/ana/_pyana.c
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ static PyObject * pyana_fzwrite(PyObject *self, PyObject *args) {
int compress = 1, debug=0;
char *header = NULL;
// Processed data goes here
PyObject *anadata_align;
PyArrayObject *anadata_align;
uint8_t *anadata_bytes;
// ANA file writing
int type, d;
Expand Down Expand Up @@ -334,7 +334,7 @@ static PyObject * pyana_fzwrite(PyObject *self, PyObject *args) {
// Sanitize data, make a new array from the old array and force the
// NPY_ARRAY_CARRAY_RO requirement which ensures a C-contiguous and aligned
// array will be made
anadata_align = PyArray_FromArray(anadata, PyArray_DESCR(anadata),NPY_ARRAY_CARRAY_RO);
anadata_align = (PyArrayObject*) PyArray_FromArray(anadata, PyArray_DESCR(anadata),NPY_ARRAY_CARRAY_RO);

// Get a pointer to the aligned data
anadata_bytes = (uint8_t*) PyArray_DATA(anadata_align);
Expand All @@ -344,12 +344,10 @@ static PyObject * pyana_fzwrite(PyObject *self, PyObject *args) {
int *dims = malloc(nd*sizeof(int));
// Get the dimensions and number of elements
npy_intp *npy_dims = PyArray_DIMS(anadata_align);
//npy_intp npy_nelem = PyArray_SIZE(anadata_align);

if (debug == 1) printf("pyana_fzwrite(): Dimensions: ");
for (d=0; d<nd; d++) {
// ANA stores dimensions the other way around?
//dims[d] = npy_dims[d];
dims[d] = npy_dims[nd-1-d];
if (debug == 1) printf(" %d", dims[d]);
}
Expand All @@ -363,6 +361,5 @@ static PyObject * pyana_fzwrite(PyObject *self, PyObject *args) {
ana_fzwrite(anadata_bytes, filename, dims, nd, header, type);

free(dims);
// If we didn't crash up to here, we're probably ok :P
return Py_BuildValue("i", 1);
}

0 comments on commit 09319a1

Please sign in to comment.