[PATCH] fixing SSE detection in solid
Thiago Macieira
thiago at kde.org
Fri Feb 8 17:06:44 GMT 2008
On Friday 08 February 2008 17:20:08 Friedrich W. H. Kossebau wrote:
> Am Freitag, 8. Februar 2008, um 15:10 Uhr, schrieb Thiago Macieira:
> > On Friday 08 February 2008 07:27:52 Tobias Koenig wrote:
> > > Hmm isn't msb the bit that represents 2^0? You see I'm not good at
> > > binary level ;)
> >
> > MSB = Most significant bit.
>
> As in: the bit which makes the greatest change in the value if swapped.
>
> > 2^0 is always LSB (Least significant bit).
>
> As in: the bit which makes the smallest change.
>
> > Little-endian == LSB-first or LSB left or left-to-right
> > Big-endian == MSB-first or MSB left or right-to-left (like our normal
> > numbers)
>
> You mixed up bytes and bits ;)
No, I didn't. The only thing is that you only get access to the bits by the
byteful. So you never know how the memory arranges them. :-)
Try an architecture that supports both endiannesses and then try sharing
memory between two different programs. At least on the IA-64, you'll see all
bits inverted, not just the bytes (like ntohl/htonl).
This is specially important with bitfield structures. Here's an example,
extracted from /usr/include/arpa/nameser_compat.h:
typedef struct {
unsigned id :16; /* query identification number */
#if BYTE_ORDER == BIG_ENDIAN
/* fields in third byte */
unsigned qr: 1; /* response flag */
unsigned opcode: 4; /* purpose of message */
unsigned aa: 1; /* authoritive answer */
unsigned tc: 1; /* truncated message */
unsigned rd: 1; /* recursion desired */
/* fields in fourth byte */
unsigned ra: 1; /* recursion available */
unsigned unused :1; /* unused bits (MBZ as of 4.9.3a3) */
unsigned ad: 1; /* authentic data from named */
unsigned cd: 1; /* checking disabled by resolver */
unsigned rcode :4; /* response code */
#endif
#if BYTE_ORDER == LITTLE_ENDIAN || BYTE_ORDER == PDP_ENDIAN
/* fields in third byte */
unsigned rd :1; /* recursion desired */
unsigned tc :1; /* truncated message */
unsigned aa :1; /* authoritive answer */
unsigned opcode :4; /* purpose of message */
unsigned qr :1; /* response flag */
/* fields in fourth byte */
unsigned rcode :4; /* response code */
unsigned cd: 1; /* checking disabled by resolver */
unsigned ad: 1; /* authentic data from named */
unsigned unused :1; /* unused bits (MBZ as of 4.9.3a3) */
unsigned ra :1; /* recursion available */
#endif
The "aa" field is the third bit in the little-endian order. It is accessed as
follows in Q3Dns:
bool aa = (answer[2] & 4) != 0;
Same for the "rd" field:
p[2] = 1; // recursion desired, rest is 0
> Endianess is about bytes, not bits (at least with the machines we care
> about AFAIK). Cmp. http://en.wikipedia.org/wiki/Endianness
>
> Inside a byte the MSB is the first and the LSB is the last bit.
The example above disproves that. The LSB is "rd", which is last in big endian
architectures.
--
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
PGP/GPG: 0x6EF45358; fingerprint:
E067 918B B660 DBD1 105C 966C 33F5 F005 6EF4 5358
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20080208/cef98733/attachment.sig>
More information about the kde-core-devel
mailing list