Yeah, 'void *' should be fine -- the difference between 'void*' and 'char*'
is in pointer arithmetic (i.e. relative comparisons of memory location),
not casting to integer (absolute measurement of memory location).

In practice 'alignment' is always going to be <1000, and 'foo % alignment'
likewise, so the signedness of the output type won't matter.

uintptr_t is the standard type here yeah. But while relying on stdint.h
would be nice, it'd definitely be a big change from current numpy
practice...


On Thu, May 23, 2013 at 4:51 PM, Charles Harris <notifications@github.com>wrote:

> In numpy/core/src/private/lowlevel_strided_loops.h:
>
> > @@ -396,6 +396,52 @@ typedef void (PyArray_StridedBinaryOp)(char *dst, npy_intp dst_stride,
> >                              char **out_dataB, npy_intp *out_stridesB,
> >                              char **out_dataC, npy_intp *out_stridesC);
> >
> > +
> > +/*
> > + * Return number of elements that must be peeled from
> > + * the start of 'addr' with 'nvals' elements of size 'esize'
> > + * in order to reach 'alignment'.
> > + * see npy_blocked_end for an example
> > + */
> > +static NPY_INLINE npy_intp
> > +npy_blocked_peel(const void * addr, const npy_intp esize,
> > +                 const npy_intp alignment, const npy_intp nvals)
> > +{
> > +    const npy_intp offset = (size_t)addr % alignment;
>
> Googling about, looks like void * is the right thing here, but uintptr_tis suggested as the variable type. I'm not clear on how portable that type
> is. Seems to have come in with C99.
>
> —
> Reply to this email directly or view it on GitHub<https://github.com/numpy/numpy/pull/3341/files#r4363531>
> .
>