Skip to content

Commit

Permalink
Merge pull request numpy#22674 from rgommers/npy-inline-cleanup
Browse files Browse the repository at this point in the history
MAINT: replace `NPY_INLINE` with `inline`

[ci skip]
  • Loading branch information
rgommers committed Nov 25, 2022
2 parents 73cf4dd + 3947b1a commit d4b2d4f
Show file tree
Hide file tree
Showing 70 changed files with 353 additions and 378 deletions.
2 changes: 1 addition & 1 deletion numpy/core/code_generators/generate_ufunc_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
%s
static NPY_INLINE int
static inline int
_import_umath(void)
{
PyObject *numpy = PyImport_ImportModule("numpy.core._multiarray_umath");
Expand Down
10 changes: 5 additions & 5 deletions numpy/core/include/numpy/_neighborhood_iterator_imp.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
/*
* Private API (here for inline)
*/
static NPY_INLINE int
static inline int
_PyArrayNeighborhoodIter_IncrCoord(PyArrayNeighborhoodIterObject* iter);

/*
Expand Down Expand Up @@ -34,7 +34,7 @@ _PyArrayNeighborhoodIter_IncrCoord(PyArrayNeighborhoodIterObject* iter);
iter->coordinates[c] = iter->bounds[c][0]; \
}

static NPY_INLINE int
static inline int
_PyArrayNeighborhoodIter_IncrCoord(PyArrayNeighborhoodIterObject* iter)
{
npy_intp i, wb;
Expand All @@ -49,7 +49,7 @@ _PyArrayNeighborhoodIter_IncrCoord(PyArrayNeighborhoodIterObject* iter)
/*
* Version optimized for 2d arrays, manual loop unrolling
*/
static NPY_INLINE int
static inline int
_PyArrayNeighborhoodIter_IncrCoord2D(PyArrayNeighborhoodIterObject* iter)
{
npy_intp wb;
Expand All @@ -64,7 +64,7 @@ _PyArrayNeighborhoodIter_IncrCoord2D(PyArrayNeighborhoodIterObject* iter)
/*
* Advance to the next neighbour
*/
static NPY_INLINE int
static inline int
PyArrayNeighborhoodIter_Next(PyArrayNeighborhoodIterObject* iter)
{
_PyArrayNeighborhoodIter_IncrCoord (iter);
Expand All @@ -76,7 +76,7 @@ PyArrayNeighborhoodIter_Next(PyArrayNeighborhoodIterObject* iter)
/*
* Reset functions
*/
static NPY_INLINE int
static inline int
PyArrayNeighborhoodIter_Reset(PyArrayNeighborhoodIterObject* iter)
{
npy_intp i;
Expand Down
2 changes: 1 addition & 1 deletion numpy/core/include/numpy/experimental_dtype_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ typedef PyArray_Descr *__get_default_descr(
#define _PyArray_GetDefaultDescr \
((__get_default_descr *)(__experimental_dtype_api_table[6]))

static NPY_INLINE PyArray_Descr *
static inline PyArray_Descr *
PyArray_GetDefaultDescr(PyArray_DTypeMeta *DType)
{
if (DType->singleton != NULL) {
Expand Down
4 changes: 2 additions & 2 deletions numpy/core/include/numpy/ndarrayobject.h
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ extern "C" {
(k)*PyArray_STRIDES(obj)[2] + \
(l)*PyArray_STRIDES(obj)[3]))

static NPY_INLINE void
static inline void
PyArray_DiscardWritebackIfCopy(PyArrayObject *arr)
{
PyArrayObject_fields *fa = (PyArrayObject_fields *)arr;
Expand Down Expand Up @@ -214,7 +214,7 @@ PyArray_DiscardWritebackIfCopy(PyArrayObject *arr)
dict).
*/

static NPY_INLINE int
static inline int
NPY_TITLE_KEY_check(PyObject *key, PyObject *value)
{
PyObject *title;
Expand Down
46 changes: 23 additions & 23 deletions numpy/core/include/numpy/ndarraytypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -1463,12 +1463,12 @@ typedef struct {
*/

/* General: those work for any mode */
static NPY_INLINE int
static inline int
PyArrayNeighborhoodIter_Reset(PyArrayNeighborhoodIterObject* iter);
static NPY_INLINE int
static inline int
PyArrayNeighborhoodIter_Next(PyArrayNeighborhoodIterObject* iter);
#if 0
static NPY_INLINE int
static inline int
PyArrayNeighborhoodIter_Next2D(PyArrayNeighborhoodIterObject* iter);
#endif

Expand Down Expand Up @@ -1514,85 +1514,85 @@ PyArrayNeighborhoodIter_Next2D(PyArrayNeighborhoodIterObject* iter);
* ABI compatibility.
*/

static NPY_INLINE int
static inline int
PyArray_NDIM(const PyArrayObject *arr)
{
return ((PyArrayObject_fields *)arr)->nd;
}

static NPY_INLINE void *
static inline void *
PyArray_DATA(PyArrayObject *arr)
{
return ((PyArrayObject_fields *)arr)->data;
}

static NPY_INLINE char *
static inline char *
PyArray_BYTES(PyArrayObject *arr)
{
return ((PyArrayObject_fields *)arr)->data;
}

static NPY_INLINE npy_intp *
static inline npy_intp *
PyArray_DIMS(PyArrayObject *arr)
{
return ((PyArrayObject_fields *)arr)->dimensions;
}

static NPY_INLINE npy_intp *
static inline npy_intp *
PyArray_STRIDES(PyArrayObject *arr)
{
return ((PyArrayObject_fields *)arr)->strides;
}

static NPY_INLINE npy_intp
static inline npy_intp
PyArray_DIM(const PyArrayObject *arr, int idim)
{
return ((PyArrayObject_fields *)arr)->dimensions[idim];
}

static NPY_INLINE npy_intp
static inline npy_intp
PyArray_STRIDE(const PyArrayObject *arr, int istride)
{
return ((PyArrayObject_fields *)arr)->strides[istride];
}

static NPY_INLINE NPY_RETURNS_BORROWED_REF PyObject *
static inline NPY_RETURNS_BORROWED_REF PyObject *
PyArray_BASE(PyArrayObject *arr)
{
return ((PyArrayObject_fields *)arr)->base;
}

static NPY_INLINE NPY_RETURNS_BORROWED_REF PyArray_Descr *
static inline NPY_RETURNS_BORROWED_REF PyArray_Descr *
PyArray_DESCR(PyArrayObject *arr)
{
return ((PyArrayObject_fields *)arr)->descr;
}

static NPY_INLINE int
static inline int
PyArray_FLAGS(const PyArrayObject *arr)
{
return ((PyArrayObject_fields *)arr)->flags;
}

static NPY_INLINE npy_intp
static inline npy_intp
PyArray_ITEMSIZE(const PyArrayObject *arr)
{
return ((PyArrayObject_fields *)arr)->descr->elsize;
}

static NPY_INLINE int
static inline int
PyArray_TYPE(const PyArrayObject *arr)
{
return ((PyArrayObject_fields *)arr)->descr->type_num;
}

static NPY_INLINE int
static inline int
PyArray_CHKFLAGS(const PyArrayObject *arr, int flags)
{
return (PyArray_FLAGS(arr) & flags) == flags;
}

static NPY_INLINE PyObject *
static inline PyObject *
PyArray_GETITEM(const PyArrayObject *arr, const char *itemptr)
{
return ((PyArrayObject_fields *)arr)->descr->f->getitem(
Expand All @@ -1604,7 +1604,7 @@ PyArray_GETITEM(const PyArrayObject *arr, const char *itemptr)
* and of a type understood by the arrays dtype.
* Use `PyArray_Pack` if the value may be of a different dtype.
*/
static NPY_INLINE int
static inline int
PyArray_SETITEM(PyArrayObject *arr, char *itemptr, PyObject *v)
{
return ((PyArrayObject_fields *)arr)->descr->f->setitem(v, itemptr, arr);
Expand Down Expand Up @@ -1639,13 +1639,13 @@ PyArray_SETITEM(PyArrayObject *arr, char *itemptr, PyObject *v)
(PyArrayObject *)(obj))
#endif

static NPY_INLINE PyArray_Descr *
static inline PyArray_Descr *
PyArray_DTYPE(PyArrayObject *arr)
{
return ((PyArrayObject_fields *)arr)->descr;
}

static NPY_INLINE npy_intp *
static inline npy_intp *
PyArray_SHAPE(PyArrayObject *arr)
{
return ((PyArrayObject_fields *)arr)->dimensions;
Expand All @@ -1655,7 +1655,7 @@ PyArray_SHAPE(PyArrayObject *arr)
* Enables the specified array flags. Does no checking,
* assumes you know what you're doing.
*/
static NPY_INLINE void
static inline void
PyArray_ENABLEFLAGS(PyArrayObject *arr, int flags)
{
((PyArrayObject_fields *)arr)->flags |= flags;
Expand All @@ -1665,13 +1665,13 @@ PyArray_ENABLEFLAGS(PyArrayObject *arr, int flags)
* Clears the specified array flags. Does no checking,
* assumes you know what you're doing.
*/
static NPY_INLINE void
static inline void
PyArray_CLEARFLAGS(PyArrayObject *arr, int flags)
{
((PyArrayObject_fields *)arr)->flags &= ~flags;
}

static NPY_INLINE NPY_RETURNS_BORROWED_REF PyObject *
static inline NPY_RETURNS_BORROWED_REF PyObject *
PyArray_HANDLER(PyArrayObject *arr)
{
return ((PyArrayObject_fields *)arr)->mem_handler;
Expand Down

0 comments on commit d4b2d4f

Please sign in to comment.