backport fix from trunk

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/branches/stable@26792 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-MacDonald 2008-07-17 13:52:02 +00:00
parent a4ee2a9628
commit c6d085e3ae
2 changed files with 24 additions and 15 deletions

View file

@ -1,3 +1,8 @@
2008-07-17 Richard Frith-Macdonald <rfm@gnu.org>
* Source/Additions/GSCategories.m: littleEndian() fix to work on
systems with other word sizes.
2008-07-05 Richard Frith-Macdonald <rfm@gnu.org>
* Version 1.16.3

View file

@ -392,23 +392,27 @@ static void MD5Transform (uint32_t buf[4], uint32_t const in[16]);
*/
static void littleEndian (void *buf, unsigned words)
{
uint32_t *ptr = (uint32_t*)buf;
if (NSHostByteOrder() == NS_BigEndian)
{
while (words-- > 0)
{
union swap {
uint32_t num;
uint8_t byt[4];
} tmp;
uint8_t b0;
uint8_t b1;
#if (INT_MAX == 2147483647)
do
{
*ptr = NSSwapHostIntToLittle(*ptr);
ptr++;
tmp.num = ((uint32_t*)buf)[words];
b0 = tmp.byt[0];
b1 = tmp.byt[1];
tmp.byt[0] = tmp.byt[3];
tmp.byt[1] = tmp.byt[2];
tmp.byt[2] = b1;
tmp.byt[3] = b0;
((uint32_t*)buf)[words] = tmp.num;
}
}
while (--words);
#else
do
{
*ptr = NSSwapHostLongToLittle(*ptr);
ptr++;
}
while (--words);
#endif
}
/*