view release on metacpan or search on metacpan
xs/const/ppport.h view on Meta::CPAN
#ifndef UV_MAX
# define UV_MAX PERL_ULONG_MAX
#endif
#endif
#ifndef IVSIZE
# ifdef LONGSIZE
# define IVSIZE LONGSIZE
# else
# define IVSIZE 4 /* A bold guess, but the best we can make. */
# endif
#endif
#ifndef UVTYPE
# define UVTYPE unsigned IVTYPE
#endif
#ifndef UVSIZE
# define UVSIZE IVSIZE
#endif
xs/const/ppport.h view on Meta::CPAN
#endif
#ifndef get_cvs
# define get_cvs(name, flags) get_cvn_flags(name "", sizeof(name)-1, flags)
#endif
#undef SvGETMAGIC
#ifndef SvGETMAGIC
# define SvGETMAGIC(x) ((void)(UNLIKELY(SvGMAGICAL(x)) && mg_get(x)))
#endif
/* That's the best we can do... */
#ifndef sv_catpvn_nomg
# define sv_catpvn_nomg sv_catpvn
#endif
#ifndef sv_catsv_nomg
# define sv_catsv_nomg sv_catsv
#endif
#ifndef sv_setsv_nomg
# define sv_setsv_nomg sv_setsv
xs/doubly/ppport.h view on Meta::CPAN
#ifndef UV_MAX
# define UV_MAX PERL_ULONG_MAX
#endif
#endif
#ifndef IVSIZE
# ifdef LONGSIZE
# define IVSIZE LONGSIZE
# else
# define IVSIZE 4 /* A bold guess, but the best we can make. */
# endif
#endif
#ifndef UVTYPE
# define UVTYPE unsigned IVTYPE
#endif
#ifndef UVSIZE
# define UVSIZE IVSIZE
#endif
xs/doubly/ppport.h view on Meta::CPAN
#endif
#ifndef get_cvs
# define get_cvs(name, flags) get_cvn_flags(name "", sizeof(name)-1, flags)
#endif
#undef SvGETMAGIC
#ifndef SvGETMAGIC
# define SvGETMAGIC(x) ((void)(UNLIKELY(SvGMAGICAL(x)) && mg_get(x)))
#endif
/* That's the best we can do... */
#ifndef sv_catpvn_nomg
# define sv_catpvn_nomg sv_catpvn
#endif
#ifndef sv_catsv_nomg
# define sv_catsv_nomg sv_catsv
#endif
#ifndef sv_setsv_nomg
# define sv_setsv_nomg sv_setsv
xs/file/ppport.h view on Meta::CPAN
#ifndef UV_MAX
# define UV_MAX PERL_ULONG_MAX
#endif
#endif
#ifndef IVSIZE
# ifdef LONGSIZE
# define IVSIZE LONGSIZE
# else
# define IVSIZE 4 /* A bold guess, but the best we can make. */
# endif
#endif
#ifndef UVTYPE
# define UVTYPE unsigned IVTYPE
#endif
#ifndef UVSIZE
# define UVSIZE IVSIZE
#endif
xs/file/ppport.h view on Meta::CPAN
#endif
#ifndef get_cvs
# define get_cvs(name, flags) get_cvn_flags(name "", sizeof(name)-1, flags)
#endif
#undef SvGETMAGIC
#ifndef SvGETMAGIC
# define SvGETMAGIC(x) ((void)(UNLIKELY(SvGMAGICAL(x)) && mg_get(x)))
#endif
/* That's the best we can do... */
#ifndef sv_catpvn_nomg
# define sv_catpvn_nomg sv_catpvn
#endif
#ifndef sv_catsv_nomg
# define sv_catsv_nomg sv_catsv
#endif
#ifndef sv_setsv_nomg
# define sv_setsv_nomg sv_setsv
xs/heap/heap.c view on Meta::CPAN
/* Sift down for raw array - min heap */
static void raw_sift_down_min(pTHX_ AV *av, IV idx, IV size) {
SV **arr = AvARRAY(av);
SV *val = arr[idx];
NV val_nv = SvNV(val);
IV half = size >> 1;
while (idx < half) {
IV left = (idx << 1) + 1;
IV right = left + 1;
IV best = left;
NV best_nv = SvNV(arr[left]);
if (right < size) {
NV right_nv = SvNV(arr[right]);
if (right_nv < best_nv) {
best = right;
best_nv = right_nv;
}
}
if (best_nv < val_nv) {
arr[idx] = arr[best];
idx = best;
} else {
break;
}
}
arr[idx] = val;
}
/* Sift down for raw array - max heap */
static void raw_sift_down_max(pTHX_ AV *av, IV idx, IV size) {
SV **arr = AvARRAY(av);
SV *val = arr[idx];
NV val_nv = SvNV(val);
IV half = size >> 1;
while (idx < half) {
IV left = (idx << 1) + 1;
IV right = left + 1;
IV best = left;
NV best_nv = SvNV(arr[left]);
if (right < size) {
NV right_nv = SvNV(arr[right]);
if (right_nv > best_nv) {
best = right;
best_nv = right_nv;
}
}
if (best_nv > val_nv) {
arr[idx] = arr[best];
idx = best;
} else {
break;
}
}
arr[idx] = val;
}
/* push_heap_min(\@array, $value) */
XS_EXTERNAL(XS_push_heap_min) {
dXSARGS;
xs/heap/heap.c view on Meta::CPAN
/* Sift down for NV min-heap */
static void nv_sift_down_min(NumericHeap *h, IV idx) {
NV *data = h->data;
IV size = h->size;
NV val = data[idx];
IV half = size >> 1;
while (idx < half) {
IV left = (idx << 1) + 1;
IV right = left + 1;
IV best = left;
NV best_nv = data[left];
if (right < size && data[right] < best_nv) {
best = right;
best_nv = data[right];
}
if (best_nv < val) {
data[idx] = data[best];
idx = best;
} else {
break;
}
}
data[idx] = val;
}
/* Sift down for NV max-heap */
static void nv_sift_down_max(NumericHeap *h, IV idx) {
NV *data = h->data;
IV size = h->size;
NV val = data[idx];
IV half = size >> 1;
while (idx < half) {
IV left = (idx << 1) + 1;
IV right = left + 1;
IV best = left;
NV best_nv = data[left];
if (right < size && data[right] > best_nv) {
best = right;
best_nv = data[right];
}
if (best_nv > val) {
data[idx] = data[best];
idx = best;
} else {
break;
}
}
data[idx] = val;
}
static int numeric_heap_free(pTHX_ SV *sv, MAGIC *mg) {
NumericHeap *h = (NumericHeap*)mg->mg_ptr;
PERL_UNUSED_ARG(sv);
xs/heap/heap.c view on Meta::CPAN
static void heap_sift_down_min(Heap *h, IV idx) {
SV **data = h->data;
IV size = h->size;
SV *val = data[idx];
NV val_nv = SvNV(val);
IV half = size >> 1;
while (idx < half) {
IV left = (idx << 1) + 1;
IV right = left + 1;
IV best = left;
NV best_nv = SvNV(data[left]);
if (right < size) {
NV right_nv = SvNV(data[right]);
if (right_nv < best_nv) {
best = right;
best_nv = right_nv;
}
}
if (best_nv < val_nv) {
data[idx] = data[best];
idx = best;
} else {
break;
}
}
data[idx] = val;
}
static void heap_sift_down_max(Heap *h, IV idx) {
SV **data = h->data;
IV size = h->size;
SV *val = data[idx];
NV val_nv = SvNV(val);
IV half = size >> 1;
while (idx < half) {
IV left = (idx << 1) + 1;
IV right = left + 1;
IV best = left;
NV best_nv = SvNV(data[left]);
if (right < size) {
NV right_nv = SvNV(data[right]);
if (right_nv > best_nv) {
best = right;
best_nv = right_nv;
}
}
if (best_nv > val_nv) {
data[idx] = data[best];
idx = best;
} else {
break;
}
}
data[idx] = val;
}
/* Custom comparator sift operations */
static bool heap_compare_custom(pTHX_ Heap *h, SV *a, SV *b) {
dSP;
xs/heap/heap.c view on Meta::CPAN
} else {
break;
}
}
}
static void heap_sift_down_custom(pTHX_ Heap *h, IV idx) {
while (1) {
IV left = (idx << 1) + 1;
IV right = left + 1;
IV best = idx;
if (left < h->size && heap_compare_custom(aTHX_ h, h->data[left], h->data[best])) {
best = left;
}
if (right < h->size && heap_compare_custom(aTHX_ h, h->data[right], h->data[best])) {
best = right;
}
if (best != idx) {
SV *tmp = h->data[idx];
h->data[idx] = h->data[best];
h->data[best] = tmp;
idx = best;
} else {
break;
}
}
}
static void heap_sift_up(pTHX_ Heap *h, IV idx) {
if (h->comparator) {
heap_sift_up_custom(aTHX_ h, idx);
} else if (h->type == HEAP_MIN) {
xs/heap/ppport.h view on Meta::CPAN
#ifndef UV_MAX
# define UV_MAX PERL_ULONG_MAX
#endif
#endif
#ifndef IVSIZE
# ifdef LONGSIZE
# define IVSIZE LONGSIZE
# else
# define IVSIZE 4 /* A bold guess, but the best we can make. */
# endif
#endif
#ifndef UVTYPE
# define UVTYPE unsigned IVTYPE
#endif
#ifndef UVSIZE
# define UVSIZE IVSIZE
#endif
xs/heap/ppport.h view on Meta::CPAN
#endif
#ifndef get_cvs
# define get_cvs(name, flags) get_cvn_flags(name "", sizeof(name)-1, flags)
#endif
#undef SvGETMAGIC
#ifndef SvGETMAGIC
# define SvGETMAGIC(x) ((void)(UNLIKELY(SvGMAGICAL(x)) && mg_get(x)))
#endif
/* That's the best we can do... */
#ifndef sv_catpvn_nomg
# define sv_catpvn_nomg sv_catpvn
#endif
#ifndef sv_catsv_nomg
# define sv_catsv_nomg sv_catsv
#endif
#ifndef sv_setsv_nomg
# define sv_setsv_nomg sv_setsv
xs/lru/ppport.h view on Meta::CPAN
#ifndef UV_MAX
# define UV_MAX PERL_ULONG_MAX
#endif
#endif
#ifndef IVSIZE
# ifdef LONGSIZE
# define IVSIZE LONGSIZE
# else
# define IVSIZE 4 /* A bold guess, but the best we can make. */
# endif
#endif
#ifndef UVTYPE
# define UVTYPE unsigned IVTYPE
#endif
#ifndef UVSIZE
# define UVSIZE IVSIZE
#endif
xs/lru/ppport.h view on Meta::CPAN
#endif
#ifndef get_cvs
# define get_cvs(name, flags) get_cvn_flags(name "", sizeof(name)-1, flags)
#endif
#undef SvGETMAGIC
#ifndef SvGETMAGIC
# define SvGETMAGIC(x) ((void)(UNLIKELY(SvGMAGICAL(x)) && mg_get(x)))
#endif
/* That's the best we can do... */
#ifndef sv_catpvn_nomg
# define sv_catpvn_nomg sv_catpvn
#endif
#ifndef sv_catsv_nomg
# define sv_catsv_nomg sv_catsv
#endif
#ifndef sv_setsv_nomg
# define sv_setsv_nomg sv_setsv
xs/noop/ppport.h view on Meta::CPAN
#ifndef UV_MAX
# define UV_MAX PERL_ULONG_MAX
#endif
#endif
#ifndef IVSIZE
# ifdef LONGSIZE
# define IVSIZE LONGSIZE
# else
# define IVSIZE 4 /* A bold guess, but the best we can make. */
# endif
#endif
#ifndef UVTYPE
# define UVTYPE unsigned IVTYPE
#endif
#ifndef UVSIZE
# define UVSIZE IVSIZE
#endif
xs/noop/ppport.h view on Meta::CPAN
#endif
#ifndef get_cvs
# define get_cvs(name, flags) get_cvn_flags(name "", sizeof(name)-1, flags)
#endif
#undef SvGETMAGIC
#ifndef SvGETMAGIC
# define SvGETMAGIC(x) ((void)(UNLIKELY(SvGMAGICAL(x)) && mg_get(x)))
#endif
/* That's the best we can do... */
#ifndef sv_catpvn_nomg
# define sv_catpvn_nomg sv_catpvn
#endif
#ifndef sv_catsv_nomg
# define sv_catsv_nomg sv_catsv
#endif
#ifndef sv_setsv_nomg
# define sv_setsv_nomg sv_setsv
xs/nvec/ppport.h view on Meta::CPAN
#ifndef UV_MAX
# define UV_MAX PERL_ULONG_MAX
#endif
#endif
#ifndef IVSIZE
# ifdef LONGSIZE
# define IVSIZE LONGSIZE
# else
# define IVSIZE 4 /* A bold guess, but the best we can make. */
# endif
#endif
#ifndef UVTYPE
# define UVTYPE unsigned IVTYPE
#endif
#ifndef UVSIZE
# define UVSIZE IVSIZE
#endif
xs/nvec/ppport.h view on Meta::CPAN
#endif
#ifndef get_cvs
# define get_cvs(name, flags) get_cvn_flags(name "", sizeof(name)-1, flags)
#endif
#undef SvGETMAGIC
#ifndef SvGETMAGIC
# define SvGETMAGIC(x) ((void)(UNLIKELY(SvGMAGICAL(x)) && mg_get(x)))
#endif
/* That's the best we can do... */
#ifndef sv_catpvn_nomg
# define sv_catpvn_nomg sv_catpvn
#endif
#ifndef sv_catsv_nomg
# define sv_catsv_nomg sv_catsv
#endif
#ifndef sv_setsv_nomg
# define sv_setsv_nomg sv_setsv
xs/object/ppport.h view on Meta::CPAN
#ifndef UV_MAX
# define UV_MAX PERL_ULONG_MAX
#endif
#endif
#ifndef IVSIZE
# ifdef LONGSIZE
# define IVSIZE LONGSIZE
# else
# define IVSIZE 4 /* A bold guess, but the best we can make. */
# endif
#endif
#ifndef UVTYPE
# define UVTYPE unsigned IVTYPE
#endif
#ifndef UVSIZE
# define UVSIZE IVSIZE
#endif
xs/object/ppport.h view on Meta::CPAN
#endif
#ifndef get_cvs
# define get_cvs(name, flags) get_cvn_flags(name "", sizeof(name)-1, flags)
#endif
#undef SvGETMAGIC
#ifndef SvGETMAGIC
# define SvGETMAGIC(x) ((void)(UNLIKELY(SvGMAGICAL(x)) && mg_get(x)))
#endif
/* That's the best we can do... */
#ifndef sv_catpvn_nomg
# define sv_catpvn_nomg sv_catpvn
#endif
#ifndef sv_catsv_nomg
# define sv_catsv_nomg sv_catsv
#endif
#ifndef sv_setsv_nomg
# define sv_setsv_nomg sv_setsv
xs/ppport.h view on Meta::CPAN
#ifndef UV_MAX
# define UV_MAX PERL_ULONG_MAX
#endif
#endif
#ifndef IVSIZE
# ifdef LONGSIZE
# define IVSIZE LONGSIZE
# else
# define IVSIZE 4 /* A bold guess, but the best we can make. */
# endif
#endif
#ifndef UVTYPE
# define UVTYPE unsigned IVTYPE
#endif
#ifndef UVSIZE
# define UVSIZE IVSIZE
#endif
xs/ppport.h view on Meta::CPAN
#endif
#ifndef get_cvs
# define get_cvs(name, flags) get_cvn_flags(name "", sizeof(name)-1, flags)
#endif
#undef SvGETMAGIC
#ifndef SvGETMAGIC
# define SvGETMAGIC(x) ((void)(UNLIKELY(SvGMAGICAL(x)) && mg_get(x)))
#endif
/* That's the best we can do... */
#ifndef sv_catpvn_nomg
# define sv_catpvn_nomg sv_catpvn
#endif
#ifndef sv_catsv_nomg
# define sv_catsv_nomg sv_catsv
#endif
#ifndef sv_setsv_nomg
# define sv_setsv_nomg sv_setsv
xs/slot/ppport.h view on Meta::CPAN
#ifndef UV_MAX
# define UV_MAX PERL_ULONG_MAX
#endif
#endif
#ifndef IVSIZE
# ifdef LONGSIZE
# define IVSIZE LONGSIZE
# else
# define IVSIZE 4 /* A bold guess, but the best we can make. */
# endif
#endif
#ifndef UVTYPE
# define UVTYPE unsigned IVTYPE
#endif
#ifndef UVSIZE
# define UVSIZE IVSIZE
#endif
xs/slot/ppport.h view on Meta::CPAN
#endif
#ifndef get_cvs
# define get_cvs(name, flags) get_cvn_flags(name "", sizeof(name)-1, flags)
#endif
#undef SvGETMAGIC
#ifndef SvGETMAGIC
# define SvGETMAGIC(x) ((void)(UNLIKELY(SvGMAGICAL(x)) && mg_get(x)))
#endif
/* That's the best we can do... */
#ifndef sv_catpvn_nomg
# define sv_catpvn_nomg sv_catpvn
#endif
#ifndef sv_catsv_nomg
# define sv_catsv_nomg sv_catsv
#endif
#ifndef sv_setsv_nomg
# define sv_setsv_nomg sv_setsv
xs/util/ppport.h view on Meta::CPAN
#ifndef UV_MAX
# define UV_MAX PERL_ULONG_MAX
#endif
#endif
#ifndef IVSIZE
# ifdef LONGSIZE
# define IVSIZE LONGSIZE
# else
# define IVSIZE 4 /* A bold guess, but the best we can make. */
# endif
#endif
#ifndef UVTYPE
# define UVTYPE unsigned IVTYPE
#endif
#ifndef UVSIZE
# define UVSIZE IVSIZE
#endif
#ifndef sv_setuv
xs/util/ppport.h view on Meta::CPAN
#endif
#ifndef PERL_MAGIC_backref
# define PERL_MAGIC_backref '<'
#endif
#ifndef PERL_MAGIC_ext
# define PERL_MAGIC_ext '~'
#endif
/* That's the best we can do... */
#ifndef sv_catpvn_nomg
# define sv_catpvn_nomg sv_catpvn
#endif
#ifndef sv_catsv_nomg
# define sv_catsv_nomg sv_catsv
#endif
#ifndef sv_setsv_nomg
# define sv_setsv_nomg sv_setsv