forked from len0rd/rockbox
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
This commit is contained in:
parent
5dfde5c80b
commit
95cf600b6c
4 changed files with 35 additions and 27 deletions
|
@ -154,9 +154,9 @@ STIN long decode_packed_entry_number(codebook *book,
|
||||||
long lo,hi;
|
long lo,hi;
|
||||||
long lok = oggpack_look(b,book->dec_firsttablen);
|
long lok = oggpack_look(b,book->dec_firsttablen);
|
||||||
|
|
||||||
if (likely(lok >= 0)) {
|
if (LIKELY(lok >= 0)) {
|
||||||
long entry = book->dec_firsttable[lok];
|
long entry = book->dec_firsttable[lok];
|
||||||
if(unlikely(entry&0x80000000UL)){
|
if(UNLIKELY(entry&0x80000000UL)){
|
||||||
lo=(entry>>15)&0x7fff;
|
lo=(entry>>15)&0x7fff;
|
||||||
hi=book->used_entries-(entry&0x7fff);
|
hi=book->used_entries-(entry&0x7fff);
|
||||||
}else{
|
}else{
|
||||||
|
@ -218,7 +218,7 @@ static long decode_packed_block(codebook *book, oggpack_buffer *b,
|
||||||
bitend = ((adr&3)+b->headend)*8;
|
bitend = ((adr&3)+b->headend)*8;
|
||||||
while (bufptr<bufend){
|
while (bufptr<bufend){
|
||||||
long entry, lo, hi;
|
long entry, lo, hi;
|
||||||
if (unlikely(cachesize<book->dec_maxlength)) {
|
if (UNLIKELY(cachesize<book->dec_maxlength)) {
|
||||||
if (bit-cachesize+32>=bitend)
|
if (bit-cachesize+32>=bitend)
|
||||||
break;
|
break;
|
||||||
bit-=cachesize;
|
bit-=cachesize;
|
||||||
|
@ -230,13 +230,13 @@ static long decode_packed_block(codebook *book, oggpack_buffer *b,
|
||||||
}
|
}
|
||||||
|
|
||||||
entry=book->dec_firsttable[cache&((1<<book->dec_firsttablen)-1)];
|
entry=book->dec_firsttable[cache&((1<<book->dec_firsttablen)-1)];
|
||||||
if(unlikely(entry&0x80000000UL)){
|
if(UNLIKELY(entry&0x80000000UL)){
|
||||||
lo=(entry>>15)&0x7fff;
|
lo=(entry>>15)&0x7fff;
|
||||||
hi=book->used_entries-(entry&0x7fff);
|
hi=book->used_entries-(entry&0x7fff);
|
||||||
{
|
{
|
||||||
ogg_uint32_t testword=bitreverse((ogg_uint32_t)cache);
|
ogg_uint32_t testword=bitreverse((ogg_uint32_t)cache);
|
||||||
|
|
||||||
while(likely(hi-lo>1)){
|
while(LIKELY(hi-lo>1)){
|
||||||
long p=(hi-lo)>>1;
|
long p=(hi-lo)>>1;
|
||||||
if (book->codelist[lo+p]>testword)
|
if (book->codelist[lo+p]>testword)
|
||||||
hi-=p;
|
hi-=p;
|
||||||
|
|
|
@ -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 unsigned int start_loop = wf->startLoop << FRACTSIZE;
|
||||||
const int diff_loop = end_loop-start_loop;
|
const int diff_loop = end_loop-start_loop;
|
||||||
|
|
||||||
while(likely(samples-- > 0))
|
while(LIKELY(samples-- > 0))
|
||||||
{
|
{
|
||||||
/* Is voice being ramped? */
|
/* Is voice being ramped? */
|
||||||
if(unlikely(so->state == STATE_RAMPDOWN))
|
if(UNLIKELY(so->state == STATE_RAMPDOWN))
|
||||||
{
|
{
|
||||||
if(so->decay != 0) /* Ramp has been started */
|
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);
|
s2 = getSample((cp_temp >> FRACTSIZE)+1, wf);
|
||||||
|
|
||||||
if(likely(mode_mask28))
|
if(LIKELY(mode_mask28))
|
||||||
{
|
{
|
||||||
/* LOOP_REVERSE|LOOP_PINGPONG = 24 */
|
/* 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;
|
cp_temp += diff_loop;
|
||||||
s2=getSample((cp_temp >> FRACTSIZE), wf);
|
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;
|
so->loopState = STATE_LOOPING;
|
||||||
if(unlikely(!mode_mask24))
|
if(UNLIKELY(!mode_mask24))
|
||||||
{
|
{
|
||||||
cp_temp -= diff_loop;
|
cp_temp -= diff_loop;
|
||||||
s2=getSample((cp_temp >> FRACTSIZE), wf);
|
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? */
|
/* Have we overrun? */
|
||||||
if(unlikely(cp_temp >= num_samples))
|
if(UNLIKELY(cp_temp >= num_samples))
|
||||||
{
|
{
|
||||||
cp_temp -= so->delta;
|
cp_temp -= so->delta;
|
||||||
s2 = getSample((cp_temp >> FRACTSIZE)+1, wf);
|
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)-1)))>>FRACTSIZE);
|
s1 +=((signed)((s2 - s1) * (cp_temp & ((1<<FRACTSIZE)-1)))>>FRACTSIZE);
|
||||||
|
|
||||||
if(unlikely(so->curRate == 0))
|
if(UNLIKELY(so->curRate == 0))
|
||||||
{
|
{
|
||||||
stopVoice(so);
|
stopVoice(so);
|
||||||
// so->isUsed = false;
|
// 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);
|
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);
|
setPoint(so, so->curPoint+1);
|
||||||
}
|
}
|
||||||
|
@ -388,9 +388,9 @@ static inline void synthVoice(struct SynthObject * so, int32_t * out, unsigned i
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
so->curOffset -= (so->curRate);
|
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);
|
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;
|
so->curOffset = so->targetOffset;
|
||||||
stopVoice(so);
|
stopVoice(so);
|
||||||
|
@ -416,7 +416,7 @@ static inline void synthVoice(struct SynthObject * so, int32_t * out, unsigned i
|
||||||
s1 = s1 * volscale >> 14;
|
s1 = s1 * volscale >> 14;
|
||||||
|
|
||||||
/* need to set ramp beginning */
|
/* 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;
|
so->decay = s1;
|
||||||
if(so->decay == 0)
|
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) ICODE_ATTR;
|
||||||
void synthSamples(int32_t *buf_ptr, unsigned int num_samples)
|
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");
|
DEBUGF("num_samples is too big!\n");
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -32,3 +32,11 @@
|
||||||
#define ATTR_ALIGN(align)
|
#define ATTR_ALIGN(align)
|
||||||
#endif
|
#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
|
||||||
|
|
||||||
|
|
|
@ -170,11 +170,11 @@ int get_cpu_boost_counter(void);
|
||||||
|
|
||||||
/* Use to give gcc hints on which branch is most likely taken */
|
/* Use to give gcc hints on which branch is most likely taken */
|
||||||
#if defined(__GNUC__) && __GNUC__ >= 3
|
#if defined(__GNUC__) && __GNUC__ >= 3
|
||||||
#define likely(x) __builtin_expect(!!(x), 1)
|
#define LIKELY(x) __builtin_expect(!!(x), 1)
|
||||||
#define unlikely(x) __builtin_expect(!!(x), 0)
|
#define UNLIKELY(x) __builtin_expect(!!(x), 0)
|
||||||
#else
|
#else
|
||||||
#define likely(x) (x)
|
#define LIKELY(x) (x)
|
||||||
#define unlikely(x) (x)
|
#define UNLIKELY(x) (x)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* returns index of first set bit + 1 or 0 if no bits are set */
|
/* returns index of first set bit + 1 or 0 if no bits are set */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue