Xv6 with picoc & Linkage editor
v1.0
The project delineate mutual cohesion between c library, linkage editor ( linker), interpreter and operating system by porting the same on xv6 kernel
|
00001 #ifndef _DIET_STRING_H_ 00002 #define _DIET_STRING_H_ 00003 00004 #include <endian.h> 00005 00006 #if __WORDSIZE == 64 00007 # define MKW(x) (x|x<<8|x<<16|x<<24|x<<32|x<<40|x<<48|x<<56) 00008 # define STRALIGN(x) (((unsigned long)x&7)?8-((unsigned long)x&7):0) 00009 #else /* __WORDSIZE == 32 */ 00010 # define MKW(x) (x|x<<8|x<<16|x<<24) 00011 # define STRALIGN(x) (((unsigned long)x&3)?4-((unsigned long)x&3):0) 00012 #endif 00013 00014 /* GFC(x) - returns first character */ 00015 /* INCSTR(x) - moves to next character */ 00016 #if __BYTE_ORDER == __LITTLE_ENDIAN 00017 # define GFC(x) ((x)&0xff) 00018 # define INCSTR(x) do { x >>= 8; } while (0) 00019 #else 00020 # define GFC(x) (((x)>>(sizeof(x)*8-8))&0xff) 00021 # define INCSTR(x) do { x <<= 8; } while (0) 00022 #endif 00023 00024 #define UNALIGNED(x,y) (((unsigned long)x & (sizeof (unsigned long)-1)) ^ ((unsigned long)y & (sizeof (unsigned long)-1))) 00025 00026 #endif /* _DIET_STRING_H_ */