//-----------------------------------------------------------
// Some Useful Functions
//-----------------------------------------------------------
//

static __forceinline void
helper_plugin_cntr_zero( int counter_id ) {
    get_pcntr( pluginId, counter_id );
    WU_LoadGlobalRegister( stats_regnum, 0, stats_cerr );
}

static __forceinline void
helper_ultohex_lmem(
	__declspec(local_mem) unsigned int val,
	__declspec(local_mem) char *val_str )
{
    __declspec(local_mem) char zero_str[2] = "0";
    if( val > 0 )	onl_api_int2str( val, val_str );
    else		strcpy_lmem( val_str, zero_str );
}

//						<<< helper_ultodec_lmem >>>
//
// convert the unsigned long 'val' to a decimal string and copy to 'p'
//
//XXX static __forceinline void
void
helper_ultodec_lmem(
		__declspec(local_mem) unsigned long val,
		__declspec(local_mem) char *p )
{
    __declspec(local_mem)	char tmp[12];
    __declspec(local_mem)	char *tptr;
    __declspec(local_mem)	char *pp;

    tptr = &(tmp[11]);
    if( val == 0 ) {		// handle 0 value
        *tptr = '0';
	--tptr;
    } else {
	do {			// produce digits
	    if( val > 0 ) {
		*tptr = '0' + val%10;
		val = val/10;
		--tptr;
	    } else {
		break;
	    }
	} while( tptr > tmp );
    }

    pp = p;
    while( tptr < tmp+11 ) {	// copy digits out
	++tptr;
    	*pp = *tptr;
	++pp;
    }
    *pp = '\0';
}

