implement ntoh with one assembler byte

This commit is contained in:
Stefan `Sec` Zehl 2011-07-18 21:42:17 +02:00
parent 6b59593b2a
commit 7b88a9f7a9
1 changed files with 9 additions and 0 deletions

View File

@ -11,6 +11,7 @@
#include <stdint.h>
#include "xxtea.h"
#ifdef SAFE
uint32_t htonl(uint32_t v)
{
uint32_t r=0;
@ -20,6 +21,14 @@ uint32_t htonl(uint32_t v)
r |= (v>>24)&0xFF;
return r;
}
#else
uint32_t htonl(uint32_t v){
__asm("rev %[value], %[value];" \
: [value] "+r" (v) : );
return v;
};
#endif
void htonlp(uint32_t *v, uint8_t n)
{