source: trunk/sys/dietlibc/dietstring.h @ 131

Last change on this file since 131 was 1, checked in by alain, 8 years ago

First import

File size: 814 bytes
RevLine 
[1]1#ifndef _DIET_STRING_H_
2#define _DIET_STRING_H_
3
4#include <endian.h>
5
6#if __WORDSIZE == 64
7# define MKW(x) (x|x<<8|x<<16|x<<24|x<<32|x<<40|x<<48|x<<56)
8# define STRALIGN(x) (((unsigned long)x&7)?8-((unsigned long)x&7):0)
9#else /* __WORDSIZE == 32 */
10# define MKW(x) (x|x<<8|x<<16|x<<24)
11# define STRALIGN(x) (((unsigned long)x&3)?4-((unsigned long)x&3):0)
12#endif
13
14/* GFC(x)    - returns first character */
15/* INCSTR(x) - moves to next character */
16#if __BYTE_ORDER == __LITTLE_ENDIAN
17# define GFC(x) ((x)&0xff)
18# define INCSTR(x) do { x >>= 8; } while (0)
19#else
20# define GFC(x) (((x)>>(sizeof(x)*8-8))&0xff)
21# define INCSTR(x) do { x <<= 8; } while (0)
22#endif
23
24#define UNALIGNED(x,y) (((unsigned long)x & (sizeof (unsigned long)-1)) ^ ((unsigned long)y & (sizeof (unsigned long)-1)))
25
26#endif /* _DIET_STRING_H_ */
Note: See TracBrowser for help on using the repository browser.