Annotation of dietlibc/dietstring.h, revision 1.3

1.1       leitner     1: #ifndef _DIET_STRING_H_
                      2: #define _DIET_STRING_H_
                      3: 
                      4: #include <endian.h>
                      5: 
1.3     ! leitner     6: /* STRALIGN returns the number of bytes to add to a pointer to make it
        !             7:  * point to a (unsigned long)-aligned piece of memory */
        !             8: #define STRALIGN(x) ((((uintptr_t)x+sizeof(long)-1)&(-sizeof(long)))-(uintptr_t)x)
        !             9: 
        !            10: /* MKW returns an unsigned long vector where every byte is x */
        !            11: #define MKW(x) ((unsigned long)x*0x0101010101010101)
        !            12: 
        !            13: /*
1.1       leitner    14: #if __WORDSIZE == 64
                     15: # define MKW(x) (x|x<<8|x<<16|x<<24|x<<32|x<<40|x<<48|x<<56)
                     16: # define STRALIGN(x) (((unsigned long)x&7)?8-((unsigned long)x&7):0)
1.3     ! leitner    17: #else
1.1       leitner    18: # define MKW(x) (x|x<<8|x<<16|x<<24)
                     19: # define STRALIGN(x) (((unsigned long)x&3)?4-((unsigned long)x&3):0)
                     20: #endif
1.3     ! leitner    21: */
1.1       leitner    22: 
1.2       leitner    23: /* GFC(x)    - returns first character */
                     24: /* INCSTR(x) - moves to next character */
                     25: #if __BYTE_ORDER == __LITTLE_ENDIAN
                     26: # define GFC(x) ((x)&0xff)
                     27: # define INCSTR(x) do { x >>= 8; } while (0)
                     28: #else
                     29: # define GFC(x) (((x)>>(sizeof(x)*8-8))&0xff)
                     30: # define INCSTR(x) do { x <<= 8; } while (0)
                     31: #endif
                     32: 
1.1       leitner    33: #define UNALIGNED(x,y) (((unsigned long)x & (sizeof (unsigned long)-1)) ^ ((unsigned long)y & (sizeof (unsigned long)-1)))
                     34: 
                     35: #endif /* _DIET_STRING_H_ */

LinuxTV legacy CVS <linuxtv.org/cvs>