summaryrefslogtreecommitdiff
path: root/apps/plugins/lib
diff options
context:
space:
mode:
authorJens Arnold <amiconn@rockbox.org>2009-06-07 21:27:05 +0000
committerJens Arnold <amiconn@rockbox.org>2009-06-07 21:27:05 +0000
commit1d6df54df27cb41c02226678a2c8f9feddd1a1e0 (patch)
tree5fdc6dd98ac0208f5c3351b062063af6914cbefb /apps/plugins/lib
parentc3182ec333982e961d3babfbdb1125fd5bac7fb8 (diff)
downloadrockbox-1d6df54df27cb41c02226678a2c8f9feddd1a1e0.zip
rockbox-1d6df54df27cb41c02226678a2c8f9feddd1a1e0.tar.gz
rockbox-1d6df54df27cb41c02226678a2c8f9feddd1a1e0.tar.bz2
rockbox-1d6df54df27cb41c02226678a2c8f9feddd1a1e0.tar.xz
Convert a number of places in core and plugins to use the BIT_N() macro instead of 1<<n. Speeds up things on SH1, and also reduces core binsize. Most notable speedups: 1 bit lcd driver: drawpixel +20%, drawline + 27%, hline +5%; jpeg viewer: +8% for 1/8 scaling. Other targets are unaffected.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@21205 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins/lib')
-rw-r--r--apps/plugins/lib/fixedpoint.c3
-rw-r--r--apps/plugins/lib/grey_core.c2
-rw-r--r--apps/plugins/lib/helper.c14
3 files changed, 17 insertions, 2 deletions
diff --git a/apps/plugins/lib/fixedpoint.c b/apps/plugins/lib/fixedpoint.c
index 7b9b68a..0ae2cde 100644
--- a/apps/plugins/lib/fixedpoint.c
+++ b/apps/plugins/lib/fixedpoint.c
@@ -22,6 +22,7 @@
****************************************************************************/
#include <inttypes.h>
+#include "plugin.h"
#include "fixedpoint.h"
/* Inverse gain of circular cordic rotation in s0.31 format. */
@@ -144,7 +145,7 @@ long fsincos(unsigned long phase, long *cos)
*/
long fsqrt(long a, unsigned int fracbits)
{
- long b = a/2 + (1 << fracbits); /* initial approximation */
+ long b = a/2 + BIT_N(fracbits); /* initial approximation */
unsigned n;
const unsigned iterations = 4;
diff --git a/apps/plugins/lib/grey_core.c b/apps/plugins/lib/grey_core.c
index 18b2716..ea70ae9 100644
--- a/apps/plugins/lib/grey_core.c
+++ b/apps/plugins/lib/grey_core.c
@@ -860,7 +860,7 @@ static void grey_screendump_hook(int fd)
+ _GREY_MULUQ(_grey_info.width, gy & ~_GREY_BMASK);
#if LCD_DEPTH == 1
- mask = 1 << (y & 7);
+ mask = BIT_N(y & 7);
src = rb->lcd_framebuffer + _GREY_MULUQ(LCD_WIDTH, y >> 3);
do
diff --git a/apps/plugins/lib/helper.c b/apps/plugins/lib/helper.c
index e35e43a..b95ee7a 100644
--- a/apps/plugins/lib/helper.c
+++ b/apps/plugins/lib/helper.c
@@ -22,6 +22,20 @@
#include "plugin.h"
#include "helper.h"
+#ifdef CPU_SH
+/* Lookup table for using the BIT_N() macro in plugins */
+const unsigned bit_n_table[32] = {
+ 1LU<< 0, 1LU<< 1, 1LU<< 2, 1LU<< 3,
+ 1LU<< 4, 1LU<< 5, 1LU<< 6, 1LU<< 7,
+ 1LU<< 8, 1LU<< 9, 1LU<<10, 1LU<<11,
+ 1LU<<12, 1LU<<13, 1LU<<14, 1LU<<15,
+ 1LU<<16, 1LU<<17, 1LU<<18, 1LU<<19,
+ 1LU<<20, 1LU<<21, 1LU<<22, 1LU<<23,
+ 1LU<<24, 1LU<<25, 1LU<<26, 1LU<<27,
+ 1LU<<28, 1LU<<29, 1LU<<30, 1LU<<31
+};
+#endif
+
/* Force the backlight on */
void backlight_force_on(void)
{