If you want to use volatile notice that written to a volatile int is
safe a least in C language (therefore extern C), because int read is
in pratice atomic and if not it will break a lot of code. Thus a
portable solution will be to compute your value in a tempory struct
union
{
struct {
char m_l1CacheSize;
char m_l2CacheSize;
char power;
char initialized;
};
int word;
}
The problem with that solution is that's not possible to initialize
the 'initialized' or whole 'word' variable because they are part of a
union.
You could do manually using bitfield or even simplier, if you could
guaranted that int is initialised to zero at init you test if it is
equal to zero, and write if not equal.Or if you are worried about
this, you could add a depend on libatomic see
http://packages.qa.debian.org/liba/libatomic-ops.html
And it is portable and it will not add a depend if you use thread,
because pthread and gcc use it internally.