mirror of
https://github.com/adtools/clib2.git
synced 2025-12-08 14:59:05 +00:00
with the library yet. - The byteswap code was contributed by Peter Bengtsson. Thank you very much! git-svn-id: file:///Users/olsen/Code/migration-svn-zu-git/logical-line-staging/clib2/trunk@15163 87f5fb63-7c3d-0410-a384-fd976d0f7a62
32 lines
420 B
C
32 lines
420 B
C
|
|
#if defined(__PPC__) && defined(__GNUC__)
|
|
|
|
asm(" .text\n\
|
|
.align 2\n\
|
|
.globl bswap32\n\
|
|
.type bswap32, @function\n\
|
|
bswap32:\n\
|
|
rlwinm %r4,%r3,8,8,31\n\
|
|
rlwimi %r4,%r3,24,0,7\n\
|
|
rlwimi %r4,%r3,24,16,23\n\
|
|
or %r3,%r4,%r4\n\
|
|
blr\n\
|
|
");
|
|
|
|
#else
|
|
|
|
#include <stdint.h>
|
|
|
|
uint32_t bswap32(uint32_t u32)
|
|
{
|
|
return(
|
|
((u32&0xff)<<24)|
|
|
((u32&0xff00)<<8)|
|
|
((u32&0xff0000)>>8)|
|
|
((u32&0xff000000)>>24)
|
|
);
|
|
}
|
|
|
|
#endif
|
|
|