From 95cf600b6cbc4529a181ab8f60b552138d998a03 Mon Sep 17 00:00:00 2001 From: Nils Wallménius Date: Sat, 22 Nov 2008 16:56:20 +0000 Subject: Macros should be ALL CAPS, so rename (un)likely() to (UN)LIKELY() git-svn-id: svn://svn.rockbox.org/rockbox/trunk@19181 a1c6a512-1295-4272-9138-f99709370657 --- apps/codecs/libtremor/codebook.c | 10 +++++----- apps/plugins/midi/synth.c | 36 ++++++++++++++++++------------------ apps/plugins/mpegplayer/attributes.h | 8 ++++++++ firmware/export/system.h | 8 ++++---- 4 files changed, 35 insertions(+), 27 deletions(-) diff --git a/apps/codecs/libtremor/codebook.c b/apps/codecs/libtremor/codebook.c index 5ffd0e308b..f291686870 100644 --- a/apps/codecs/libtremor/codebook.c +++ b/apps/codecs/libtremor/codebook.c @@ -154,9 +154,9 @@ STIN long decode_packed_entry_number(codebook *book, long lo,hi; long lok = oggpack_look(b,book->dec_firsttablen); - if (likely(lok >= 0)) { + if (LIKELY(lok >= 0)) { long entry = book->dec_firsttable[lok]; - if(unlikely(entry&0x80000000UL)){ + if(UNLIKELY(entry&0x80000000UL)){ lo=(entry>>15)&0x7fff; hi=book->used_entries-(entry&0x7fff); }else{ @@ -218,7 +218,7 @@ static long decode_packed_block(codebook *book, oggpack_buffer *b, bitend = ((adr&3)+b->headend)*8; while (bufptrdec_maxlength)) { + if (UNLIKELY(cachesizedec_maxlength)) { if (bit-cachesize+32>=bitend) break; bit-=cachesize; @@ -230,13 +230,13 @@ static long decode_packed_block(codebook *book, oggpack_buffer *b, } entry=book->dec_firsttable[cache&((1<dec_firsttablen)-1)]; - if(unlikely(entry&0x80000000UL)){ + if(UNLIKELY(entry&0x80000000UL)){ lo=(entry>>15)&0x7fff; hi=book->used_entries-(entry&0x7fff); { ogg_uint32_t testword=bitreverse((ogg_uint32_t)cache); - while(likely(hi-lo>1)){ + while(LIKELY(hi-lo>1)){ long p=(hi-lo)>>1; if (book->codelist[lo+p]>testword) hi-=p; diff --git a/apps/plugins/midi/synth.c b/apps/plugins/midi/synth.c index 7e283d4ef1..969d9b939a 100644 --- a/apps/plugins/midi/synth.c +++ b/apps/plugins/midi/synth.c @@ -293,10 +293,10 @@ static inline void synthVoice(struct SynthObject * so, int32_t * out, unsigned i const unsigned int start_loop = wf->startLoop << FRACTSIZE; const int diff_loop = end_loop-start_loop; - while(likely(samples-- > 0)) + while(LIKELY(samples-- > 0)) { /* Is voice being ramped? */ - if(unlikely(so->state == STATE_RAMPDOWN)) + if(UNLIKELY(so->state == STATE_RAMPDOWN)) { if(so->decay != 0) /* Ramp has been started */ { @@ -318,12 +318,12 @@ static inline void synthVoice(struct SynthObject * so, int32_t * out, unsigned i s2 = getSample((cp_temp >> FRACTSIZE)+1, wf); - if(likely(mode_mask28)) + if(LIKELY(mode_mask28)) { /* LOOP_REVERSE|LOOP_PINGPONG = 24 */ - if(unlikely(mode_mask24 && so->loopState == STATE_LOOPING && (cp_temp < start_loop))) + if(UNLIKELY(mode_mask24 && so->loopState == STATE_LOOPING && (cp_temp < start_loop))) { - if(unlikely(mode_mask_looprev)) + if(UNLIKELY(mode_mask_looprev)) { cp_temp += diff_loop; s2=getSample((cp_temp >> FRACTSIZE), wf); @@ -334,10 +334,10 @@ static inline void synthVoice(struct SynthObject * so, int32_t * out, unsigned i } } - if(unlikely(cp_temp >= end_loop)) + if(UNLIKELY(cp_temp >= end_loop)) { so->loopState = STATE_LOOPING; - if(unlikely(!mode_mask24)) + if(UNLIKELY(!mode_mask24)) { cp_temp -= diff_loop; s2=getSample((cp_temp >> FRACTSIZE), wf); @@ -350,7 +350,7 @@ static inline void synthVoice(struct SynthObject * so, int32_t * out, unsigned i } /* Have we overrun? */ - if(unlikely(cp_temp >= num_samples)) + if(UNLIKELY(cp_temp >= num_samples)) { cp_temp -= so->delta; s2 = getSample((cp_temp >> FRACTSIZE)+1, wf); @@ -362,21 +362,21 @@ static inline void synthVoice(struct SynthObject * so, int32_t * out, unsigned i s1 +=((signed)((s2 - s1) * (cp_temp & ((1<>FRACTSIZE); - if(unlikely(so->curRate == 0)) + if(UNLIKELY(so->curRate == 0)) { stopVoice(so); // so->isUsed = false; } - if(likely(so->ch != 9 && so->state != STATE_RAMPDOWN)) /* Stupid ADSR code... and don't do ADSR for drums */ + if(LIKELY(so->ch != 9 && so->state != STATE_RAMPDOWN)) /* Stupid ADSR code... and don't do ADSR for drums */ { - if(unlikely(so->curOffset < so->targetOffset)) + if(UNLIKELY(so->curOffset < so->targetOffset)) { so->curOffset += (so->curRate); - if(unlikely(so -> curOffset > so->targetOffset && so->curPoint != 2)) + if(UNLIKELY(so -> curOffset > so->targetOffset && so->curPoint != 2)) { - if(unlikely(so->curPoint != 5)) + if(UNLIKELY(so->curPoint != 5)) { setPoint(so, so->curPoint+1); } @@ -388,9 +388,9 @@ static inline void synthVoice(struct SynthObject * so, int32_t * out, unsigned i } else { so->curOffset -= (so->curRate); - if(unlikely(so -> curOffset < so->targetOffset && so->curPoint != 2)) + if(UNLIKELY(so -> curOffset < so->targetOffset && so->curPoint != 2)) { - if(unlikely(so->curPoint != 5)) + if(UNLIKELY(so->curPoint != 5)) { setPoint(so, so->curPoint+1); } @@ -403,7 +403,7 @@ static inline void synthVoice(struct SynthObject * so, int32_t * out, unsigned i } } - if(unlikely(so->curOffset < 0)) + if(UNLIKELY(so->curOffset < 0)) { so->curOffset = so->targetOffset; stopVoice(so); @@ -416,7 +416,7 @@ static inline void synthVoice(struct SynthObject * so, int32_t * out, unsigned i s1 = s1 * volscale >> 14; /* need to set ramp beginning */ - if(unlikely(so->state == STATE_RAMPDOWN && so->decay == 0)) + if(UNLIKELY(so->state == STATE_RAMPDOWN && so->decay == 0)) { so->decay = s1; if(so->decay == 0) @@ -442,7 +442,7 @@ int32_t samp_buf[512] IBSS_ATTR; void synthSamples(int32_t *buf_ptr, unsigned int num_samples) ICODE_ATTR; void synthSamples(int32_t *buf_ptr, unsigned int num_samples) { - if (unlikely(num_samples > 512)) + if (UNLIKELY(num_samples > 512)) DEBUGF("num_samples is too big!\n"); else { diff --git a/apps/plugins/mpegplayer/attributes.h b/apps/plugins/mpegplayer/attributes.h index 7ad83a3e6e..24b069223b 100644 --- a/apps/plugins/mpegplayer/attributes.h +++ b/apps/plugins/mpegplayer/attributes.h @@ -32,3 +32,11 @@ #define ATTR_ALIGN(align) #endif +#if defined(LIKELY) && defined (UNLIKELY) +#define likely(x) LIKELY(x) +#define unlikely(x) UNLIKELY(x) +#else +#define likely(x) (x) +#define unlikely(x) (x) +#endif + diff --git a/firmware/export/system.h b/firmware/export/system.h index cce7df6884..b82e2b1ad0 100644 --- a/firmware/export/system.h +++ b/firmware/export/system.h @@ -170,11 +170,11 @@ int get_cpu_boost_counter(void); /* Use to give gcc hints on which branch is most likely taken */ #if defined(__GNUC__) && __GNUC__ >= 3 -#define likely(x) __builtin_expect(!!(x), 1) -#define unlikely(x) __builtin_expect(!!(x), 0) +#define LIKELY(x) __builtin_expect(!!(x), 1) +#define UNLIKELY(x) __builtin_expect(!!(x), 0) #else -#define likely(x) (x) -#define unlikely(x) (x) +#define LIKELY(x) (x) +#define UNLIKELY(x) (x) #endif /* returns index of first set bit + 1 or 0 if no bits are set */ -- cgit v1.2.3