/*
* This file was generated automatically by ExtUtils::ParseXS version 2.19 from the
* contents of OAT.xs. Do not edit this file, edit OAT.xs instead.
*
* ANY CHANGES MADE HERE WILL BE LOST!
*
*/
#line 1 "OAT.xs"
#include <stdint.h>
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"
#include "ppport.h"
#include "const-c.inc"
/* Bob Jenkin's one at a time hash, has good avalanche behavior */
unsigned oat ( SV* key ) {
/* Perl Stuff */
int len = 0;
unsigned char* p = SvPV( key, len );
/* End Perl Stuff */
/* unsigned char *p = str; */
uint32_t h = 0;
int i;
for ( i = 0; i < len; i++ ) {
h += p[i];
h += ( h << 10 );
h ^= ( h >> 6 );
}
h += ( h << 3 );
h ^= ( h >> 11 );
h += ( h << 15 );
return h;
}
#ifndef PERL_UNUSED_VAR
# define PERL_UNUSED_VAR(var) if (0) var = var
#endif
#line 49 "OAT.c"
/* INCLUDE: Including 'const-xs.inc' from 'OAT.xs' */
XS(XS_Digest__OAT_constant); /* prototype to pass -Wmissing-prototypes */
XS(XS_Digest__OAT_constant)
{
#ifdef dVAR
dVAR; dXSARGS;
#else
dXSARGS;
#endif
if (items != 1)
Perl_croak(aTHX_ "Usage: %s(%s)", "Digest::OAT::constant", "sv");
PERL_UNUSED_VAR(cv); /* -W */
PERL_UNUSED_VAR(ax); /* -Wall */
SP -= items;
{
#line 4 "const-xs.inc"
#ifdef dXSTARG
dXSTARG; /* Faster if we have it. */
#else
dTARGET;
#endif
STRLEN len;
int type;
/* IV iv; Uncomment this if you need to return IVs */
/* NV nv; Uncomment this if you need to return NVs */
/* const char *pv; Uncomment this if you need to return PVs */
#line 79 "OAT.c"
SV * sv = ST(0);
const char * s = SvPV(sv, len);
#line 18 "const-xs.inc"
type = constant(aTHX_ s, len);
/* Return 1 or 2 items. First is error message, or undef if no error.
Second, if present, is found value */
switch (type) {
case PERL_constant_NOTFOUND:
sv = sv_2mortal(newSVpvf("%s is not a valid Digest::OAT macro", s));
PUSHs(sv);
break;
case PERL_constant_NOTDEF:
sv = sv_2mortal(newSVpvf(
"Your vendor has not defined Digest::OAT macro %s, used", s));
PUSHs(sv);
break;
/* Uncomment this if you need to return IVs
case PERL_constant_ISIV:
EXTEND(SP, 1);
PUSHs(&PL_sv_undef);
PUSHi(iv);
break; */
/* Uncomment this if you need to return NOs
case PERL_constant_ISNO:
EXTEND(SP, 1);
PUSHs(&PL_sv_undef);
PUSHs(&PL_sv_no);
break; */
/* Uncomment this if you need to return NVs
case PERL_constant_ISNV:
EXTEND(SP, 1);
PUSHs(&PL_sv_undef);
PUSHn(nv);
break; */
/* Uncomment this if you need to return PVs
case PERL_constant_ISPV:
EXTEND(SP, 1);
PUSHs(&PL_sv_undef);
PUSHp(pv, strlen(pv));
break; */
/* Uncomment this if you need to return PVNs
case PERL_constant_ISPVN:
EXTEND(SP, 1);
PUSHs(&PL_sv_undef);
PUSHp(pv, iv);
break; */
/* Uncomment this if you need to return SVs
case PERL_constant_ISSV:
EXTEND(SP, 1);
PUSHs(&PL_sv_undef);
PUSHs(sv);
break; */
/* Uncomment this if you need to return UNDEFs
case PERL_constant_ISUNDEF:
break; */
/* Uncomment this if you need to return UVs
case PERL_constant_ISUV:
EXTEND(SP, 1);
PUSHs(&PL_sv_undef);
PUSHu((UV)iv);
break; */
/* Uncomment this if you need to return YESs
case PERL_constant_ISYES:
EXTEND(SP, 1);
PUSHs(&PL_sv_undef);
PUSHs(&PL_sv_yes);
break; */
default:
sv = sv_2mortal(newSVpvf(
"Unexpected return type %d while processing Digest::OAT macro %s, used",
type, s));
PUSHs(sv);
}
#line 153 "OAT.c"
PUTBACK;
return;
}
}
/* INCLUDE: Returning to 'OAT.xs' from 'const-xs.inc' */
XS(XS_Digest__OAT_oat); /* prototype to pass -Wmissing-prototypes */
XS(XS_Digest__OAT_oat)
{
#ifdef dVAR
dVAR; dXSARGS;
#else
dXSARGS;
#endif
if (items != 1)
Perl_croak(aTHX_ "Usage: %s(%s)", "Digest::OAT::oat", "key");
PERL_UNUSED_VAR(cv); /* -W */
{
SV * key = ST(0);
U32 RETVAL;
dXSTARG;
RETVAL = oat(key);
XSprePUSH; PUSHu((UV)RETVAL);
}
XSRETURN(1);
}
#ifdef __cplusplus
extern "C"
#endif
XS(boot_Digest__OAT); /* prototype to pass -Wmissing-prototypes */
XS(boot_Digest__OAT)
{
#ifdef dVAR
dVAR; dXSARGS;
#else
dXSARGS;
#endif
char* file = __FILE__;
PERL_UNUSED_VAR(cv); /* -W */
PERL_UNUSED_VAR(items); /* -W */
XS_VERSION_BOOTCHECK ;
newXS("Digest::OAT::constant", XS_Digest__OAT_constant, file);
newXS("Digest::OAT::oat", XS_Digest__OAT_oat, file);
XSRETURN_YES;
}