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
29 lines
368 B
C
29 lines
368 B
C
|
|
#if defined(__PPC__) && defined(__GNUC__)
|
|
|
|
asm("\
|
|
.text\n\
|
|
.align 2\n\
|
|
.globl bswap16\n\
|
|
.type bswap16, @function\n\
|
|
bswap16:\n\
|
|
# rlwinm %r4,%r3,8,16,24\n\
|
|
# rlwimi %r4,%r3,24,24,31\n\
|
|
# or %r3,%r4,%r4\n\
|
|
rlwimi %r3,%r3,16,8,15\n\
|
|
srwi %r3,%r3,8\n\
|
|
blr\n\
|
|
");
|
|
|
|
#else
|
|
|
|
#include <stdint.h>
|
|
|
|
uint16_t bswap16(uint16_t u16)
|
|
{
|
|
return(u16>>8|u16<<8);
|
|
}
|
|
|
|
#endif
|
|
|