File: dietstring.h

package info (click to toggle)
dietlibc 0.33~cvs20120325-6%2Bdeb8u1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-backports
  • size: 9,624 kB
  • ctags: 22,841
  • sloc: ansic: 57,783; asm: 11,606; cpp: 1,856; makefile: 739; sh: 104; perl: 62
file content (26 lines) | stat: -rw-r--r-- 814 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#ifndef _DIET_STRING_H_
#define _DIET_STRING_H_

#include <endian.h>

#if __WORDSIZE == 64
# define MKW(x) (x|x<<8|x<<16|x<<24|x<<32|x<<40|x<<48|x<<56)
# define STRALIGN(x) (((unsigned long)x&7)?8-((unsigned long)x&7):0)
#else /* __WORDSIZE == 32 */
# define MKW(x) (x|x<<8|x<<16|x<<24)
# define STRALIGN(x) (((unsigned long)x&3)?4-((unsigned long)x&3):0)
#endif

/* GFC(x)    - returns first character */
/* INCSTR(x) - moves to next character */
#if __BYTE_ORDER == __LITTLE_ENDIAN
# define GFC(x) ((x)&0xff)
# define INCSTR(x) do { x >>= 8; } while (0)
#else
# define GFC(x) (((x)>>(sizeof(x)*8-8))&0xff)
# define INCSTR(x) do { x <<= 8; } while (0)
#endif

#define UNALIGNED(x,y) (((unsigned long)x & (sizeof (unsigned long)-1)) ^ ((unsigned long)y & (sizeof (unsigned long)-1)))

#endif /* _DIET_STRING_H_ */