implement ntoh with one assembler byte
This commit is contained in:
parent
6b59593b2a
commit
7b88a9f7a9
|
@ -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)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue