[U-Boot-Users] cramfs voodoo

Haavard Skinnemoen hskinnemoen at atmel.com
Sat Nov 24 22:20:14 CET 2007


Does anyone know why the following deep voodoo magic in
include/cramfs/cramfs_fs.h is needed?

#define CRAMFS_GET_NAMELEN(x)	(((u8*)(x))[8] & 0x3f)
#define CRAMFS_GET_OFFSET(x)	((CRAMFS_24(((u32*)(x))[2] & 0xffffff) << 2) |\
				 ((((u32*)(x))[2] & 0xc0000000) >> 30))
#define CRAMFS_SET_NAMELEN(x,y)	(((u8*)(x))[8] = (((0x3f & (y))) | \
						  (0xc0 & ((u8*)(x))[8])))
#define CRAMFS_SET_OFFSET(x,y)	(((u32*)(x))[2] = (((y) & 3) << 30) | \
				 CRAMFS_24((((y) & 0x03ffffff) >> 2)) | \
				 (((u32)(((u8*)(x))[8] & 0x3f)) << 24))

It looks like a workaround for buggy bitfield handling in the compiler,
but newer versions of gcc are not at all happy with it and spews
warnings like this:

cramfs.c:82: warning: dereferencing type-punned pointer will break
strict-aliasing rules

which indicates that the generated code is probably wrong.

Can we get rid of it somehow?

Haavard




More information about the U-Boot mailing list