コード例 #1
0
ファイル: display.c プロジェクト: amarao/flashnul
void print_footer(dev_ctrl_t* dev){
        printf("\n");
	print_header( "[Operation result]" );
	printf( "passes:\t\t\t%I64d\n", dev->pass_count  );
	printf( "errors:\t\t\t%I64d\n", dev->error_count  );
	if(!dev->size)
		printf("warining:\t\tdevice size unknown, all test skipped\n");
	if( dev->read_bytes )
		printf( "read bytes:\t\t%I64d (%s)\n", dev->read_bytes, human_view( dev->read_bytes, 'b' ) );
	if(dev->read_counts){
		printf( "avg. read speed:\t%I64d (%s/s)\n",
			MULDIV (dev->read_bytes, dev->freq, dev->read_counts ), 
			human_view( MULDIV( dev->read_bytes, dev->freq, dev->read_counts ), 'b' )
		);		
		printf("max/min read speed:\t%I64d (%s/s) / ", dev->max_read_speed, human_view( dev->max_read_speed, 'b' ) );
		printf("%I64d (%s/s)\n", dev->min_read_speed, human_view( dev->min_read_speed, 'b' ) );
	}
	if( dev->write_bytes )
		printf( "write bytes:\t\t%I64d (%s)\n", dev->write_bytes, human_view( dev->write_bytes, 'b' ) );
	if( dev->write_counts ){
		printf( "avg. write speed:\t%I64d (%s/s)\n",
			MULDIV( dev->write_bytes, dev->freq, dev->write_counts ), 
			human_view( MULDIV (dev->write_bytes, dev->freq, dev->write_counts), 'b' )
		);		
		printf("max/min write speed:\t%I64d (%s/s) / ", dev->max_write_speed, human_view( dev->max_write_speed, 'b' ) );
		printf("%I64d (%s/s)\n", dev->min_write_speed, human_view( dev->min_write_speed, 'b' ) );
	}	
}
コード例 #2
0
void
mpz_bin_uiui (mpz_ptr r, unsigned long int n, unsigned long int k)
{
    unsigned long int  i, j;
    mp_limb_t          nacc, kacc;
    unsigned long int  cnt;
    mp_size_t          rsize, ralloc;
    mp_ptr             rp;

    /* bin(n,k) = 0 if k>n. */
    if (n < k)
    {
        SIZ(r) = 0;
        return;
    }

    rp = PTR(r);

    /* Rewrite bin(n,k) as bin(n,n-k) if that is smaller. */
    k = MIN (k, n-k);

    /* bin(n,0) = 1 */
    if (k == 0)
    {
        SIZ(r) = 1;
        rp[0] = 1;
        return;
    }

    j = n - k + 1;
    rp[0] = j;
    rsize = 1;
    ralloc = ALLOC(r);

    /* Initialize accumulators.  */
    nacc = 1;
    kacc = 1;

    cnt = 0;
    for (i = 2; i <= k; i++)
    {
        mp_limb_t n1, n0, k0;

        j++;
#if 0
        /* Remove common multiples of 2.  This will allow us to accumulate
           more in nacc and kacc before we need a bignum step.  It would make
           sense to cancel factors of 3, 5, etc too, but this would be best
           handled by sieving out factors.  Alternatively, we could perform a
           gcd of the accumulators just as they have overflown, and keep
           accumulating until the gcd doesn't remove a significant factor.  */
        while (((nacc | kacc) & 1) == 0)
        {
            nacc >>= 1;
            kacc >>= 1;
        }
#else
        cnt = ((nacc | kacc) & 1) ^ 1;
        nacc >>= cnt;
        kacc >>= cnt;
#endif
        /* Accumulate next multiples.  */
        umul_ppmm (n1, n0, nacc, (mp_limb_t) j << GMP_NAIL_BITS);
        k0 = kacc * i;
        n0 >>= GMP_NAIL_BITS;
        if (n1 != 0)
        {
            /* Accumulator overflow.  Perform bignum step. */
            MULDIV (32);
            nacc = j;
            kacc = i;
        }
        else
        {
            /* k<=n, so should have no overflow from k0 = kacc*i */
            ASSERT (kacc <= GMP_NUMB_MAX / i);

            /* Save new products in accumulators to keep accumulating.  */
            nacc = n0;
            kacc = k0;
        }
    }

    /* Take care of whatever is left in accumulators.  */
    MULDIV (1);

    ALLOC(r) = ralloc;
    SIZ(r) = rsize;
    PTR(r) = rp;
}
コード例 #3
0
ファイル: time.c プロジェクト: Distrotech/gmerlin
int64_t gavl_time_rescale(int scale1, int scale2, int64_t time)
  {
  if(scale1 == scale2)
    return time;
  return MULDIV(time, scale2, scale1);
  }
コード例 #4
0
ファイル: time.c プロジェクト: Distrotech/gmerlin
int64_t gavl_time_scale(int scale, gavl_time_t time)
  {
  return MULDIV(time, scale, GAVL_TIME_SCALE);
  }
コード例 #5
0
ファイル: time.c プロジェクト: Distrotech/gmerlin
gavl_time_t gavl_time_unscale(int scale, int64_t time)
  {
  return MULDIV(time, GAVL_TIME_SCALE, scale);
  }
コード例 #6
0
ファイル: time.c プロジェクト: Distrotech/gmerlin
int64_t gavl_time_to_samples(int samplerate, gavl_time_t time)
  {
  return MULDIV(time, samplerate, GAVL_TIME_SCALE);
  }
コード例 #7
0
ファイル: time.c プロジェクト: Distrotech/gmerlin
gavl_time_t gavl_samples_to_time(int samplerate, int64_t samples)
  {
  return MULDIV(samples, GAVL_TIME_SCALE, samplerate);
  }