Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 23 Jul 2009 23:33:15 +0200
From:      Ulf Lilleengen <lulf@freebsd.org>
To:        Oleksandr Tymoshenko <gonzo@FreeBSD.org>
Cc:        perforce@FreeBSD.org
Subject:   Re: PERFORCE change 166470 for review
Message-ID:  <4A68D71B.3010909@freebsd.org>
In-Reply-To: <200907232022.n6NKMpKH074697@repoman.freebsd.org>
References:  <200907232022.n6NKMpKH074697@repoman.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
Oleksandr Tymoshenko wrote:
> http://perforce.freebsd.org/chv.cgi?CH=166470
> 
> Change 166470 by gonzo@gonzo_figaro on 2009/07/23 20:22:08
> 
> 	- Replace overengineered version of power of 2 calcualtion
> 	    with shift operator
> 
Boy do I feel silly :)

> Affected files ...
> 
> .. //depot/projects/avr32/src/sys/avr32/avr32/cache.c#5 edit
> 
> Differences ...
> 
> ==== //depot/projects/avr32/src/sys/avr32/avr32/cache.c#5 (text+ko) ====
> 
> @@ -112,21 +112,6 @@
>  u_int avr32_dcache_line_size;
>  u_int avr32_dcache_ways;
>  
> -/* XXX: there must be a library function for this? */
> -u_int
> -pow(u_int base, u_int power)
> -{
> -	u_int i, result;
> -
> -	if (power == 0)
> -		return (1);
> -
> -	result = base;
> -	for (i = 1; i < power; i++)
> -		result *= base;
> -	return (result);
> -}
> -
>  /* Set up the cache operations according to config. */
>  void
>  avr32_config_cache(void)
> @@ -135,16 +120,16 @@
>  
>  	config = sysreg_read(CONFIG1);
>  	/* Read instruction cache parameters. */
> -	avr32_icache_size = pow(2, bit_value(SYS, CONFIG1, ISET, config));
> -	avr32_icache_line_size = pow(2, bit_value(SYS, CONFIG1, ILSZ, config) +
> -	    1);
> -	avr32_icache_ways = pow(2, bit_value(SYS, CONFIG1, IASS, config));
> +	avr32_icache_size = 1 << bit_value(SYS, CONFIG1, ISET, config);
> +	avr32_icache_line_size = 1 << 
> +	    (bit_value(SYS, CONFIG1, ILSZ, config) + 1);
> +	avr32_icache_ways = 1 << bit_value(SYS, CONFIG1, IASS, config);
>  
>  	/* Read data cache parameters. */
> -	avr32_dcache_size = pow(2, bit_value(SYS, CONFIG1, DSET, config));
> -	avr32_dcache_line_size = pow(2, bit_value(SYS, CONFIG1, DLSZ, config) +
> -	    1);
> -	avr32_dcache_ways = pow(2, bit_value(SYS, CONFIG1, DASS, config));
> +	avr32_dcache_size = 1 << bit_value(SYS, CONFIG1, DSET, config);
> +	avr32_dcache_line_size = 1 << 
> +	    (bit_value(SYS, CONFIG1, DLSZ, config) + 1);
> +	avr32_dcache_ways = 1 << bit_value(SYS, CONFIG1, DASS, config);
>  	printf("ICACHE: sz %d lsz %d assoc %d\n", avr32_icache_size,
>  	    avr32_icache_line_size, avr32_icache_ways);
>  	printf("DCACHE: sz %d lsz %d assoc %d\n", avr32_dcache_size,
> 




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4A68D71B.3010909>