/* * This file was generated automatically by ExtUtils::ParseXS version 2.22 from the * contents of bitvector.xs. Do not edit this file, edit bitvector.xs instead. * * ANY CHANGES MADE HERE WILL BE LOST! * */ #line 1 "bitvector.xs" #include "EXTERN.h" #include "perl.h" #include "XSUB.h" #include "INLINE.h" typedef unsigned __int64 U64; char *newxz( U64 bytes ) { char *p; Newxz( p, bytes, char ); if( !p ) croak( "Couldn't allocate %I64u bytes\n", bytes ); return p; } SV* new( const char *classname, SV *bits ) { U64 bytes = ( SvUV( bits )+7 ) / 8; unsigned char *vector = newxz( bytes ); SV *obj = newSV_type( SVt_PV ); SV *obj_ref = newRV_noinc( obj ); SvPOK_only( obj ); SvPV_set( obj, vector ); SvCUR_set( obj, bytes-1 ); SvLEN_set( obj, bytes ); sv_bless( obj_ref, gv_stashpv( classname, GV_ADD) ); return obj_ref; } U64 setbit( SV *self, SV *offset ) { U64 *vec = (U64*)SvPVX( SvRV( self ) ); U64 bit = SvUV( offset ) & 0x000000000000003fULL; U64 quad = SvUV( offset ) >> 6; //return _bittestandset64( vec+quad, bit ); return vec[ quad ] |= 1ULL << bit; } U64 tstbit( SV *self, SV *offset ) { U64 *vec = (U64*)SvPVX( SvRV( self ) ); U64 bit = SvUV( offset ) & 0x000000000000003fULL; U64 quad = SvUV( offset ) >> 6; //return _bittest64( vec+quad, bit ); return ( vec[ quad ] & ( 1ULL << bit ) ) ? 1 : 0; } U64 clrbit( SV *self, SV *offset ) { U64 *vec = (U64*)SvPVX( SvRV( self ) ); U64 bit = SvUV( offset ) & 0x000000000000003fULL; U64 quad = SvUV( offset ) >> 6; //return _bittestandreset64( vec+quad, bit ); return vec[ quad ] &= ~( 1ULL << bit ); } _inline int _popcnt( U64 x ) { x -=( x >> 1 ) & 0x5555555555555555ULL; x = ( x & 0x3333333333333333Ul ) + ( ( x >> 2 ) & 0x3333333333333333ULL ); x = ( x + (x >> 4)) & 0x0f0f0f0f0f0f0f0fULL; return ( x * 0x0101010101010101ULL ) >> 56; } U64 cntbit( SV *self ) { STRLEN l = 0; U64 *vec = (U64*)SvPV( SvRV( self ), l ); U64 cnt = 0ULL; int i; l /= 8; ++l; for( i = 0; i = 9) if (PL_unitcheckav) call_list(PL_scopestack_ix, PL_unitcheckav); #endif XSRETURN_YES; }