[flac-dev] bitmath.h static array
    lvqcl 
    lvqcl.mail at gmail.com
       
    Sat Oct 11 01:06:44 PDT 2014
    
    
  
There is a function FLAC__clz_soft_uint32 in bitmath.h:
static inline unsigned int FLAC__clz_soft_uint32(unsigned int word)
{
     static const unsigned char byte_to_unary_table[] = {
     8, 7, 6, 6, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4,
     ....................................
     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
     };
     return (word) > 0xffffff ? byte_to_unary_table[(word) >> 24] :
     (word) > 0xffff ? byte_to_unary_table[(word) >> 16] + 8 :
     (word) > 0xff ? byte_to_unary_table[(word) >> 8] + 16 :
     byte_to_unary_table[(word)] + 24;
}
It seems that it adds a copy of byte_to_unary_table[] array to
any file that includes this header.
Maybe it's better to move this array from bitmath.h to bitmath.c?
It will be something like this:
extern const unsigned char FLAC__byte_to_unary_table[];
static inline unsigned int FLAC__clz_soft_uint32(unsigned int word)
{
     return (word) > 0xffffff ? FLAC__byte_to_unary_table[(word) >> 24] :
     (word) > 0xffff ? FLAC__byte_to_unary_table[(word) >> 16] + 8 :
     (word) > 0xff ? FLAC__byte_to_unary_table[(word) >> 8] + 16 :
     FLAC__byte_to_unary_table[(word)] + 24;
}
    
    
More information about the flac-dev
mailing list