diff options
| author | Grant Limberg <glimberg@gmail.com> | 2015-07-08 17:30:22 -0700 |
|---|---|---|
| committer | Grant Limberg <glimberg@gmail.com> | 2015-07-08 17:30:22 -0700 |
| commit | f67ddb579de173d96cfca7ea45704f193f92183e (patch) | |
| tree | 2739a674a2b898235bc62293f847d4bcd87eb2ca /node/Salsa20.cpp | |
| parent | 1ad2cfeedfa2a9f4fc1f512e1009e5bb1b0630cb (diff) | |
| parent | a297e4a5bf5f6a8e9ba2a811f36a1a885131f66d (diff) | |
| download | infinitytier-f67ddb579de173d96cfca7ea45704f193f92183e.tar.gz infinitytier-f67ddb579de173d96cfca7ea45704f193f92183e.zip | |
Merge branch 'adamierymenko-dev' into android-jni
Diffstat (limited to 'node/Salsa20.cpp')
| -rw-r--r-- | node/Salsa20.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/node/Salsa20.cpp b/node/Salsa20.cpp index ae8e1802..de8f1569 100644 --- a/node/Salsa20.cpp +++ b/node/Salsa20.cpp @@ -19,13 +19,15 @@ #if __BYTE_ORDER == __LITTLE_ENDIAN -// Slow version that does not use type punning -//#define U8TO32_LITTLE(p) ( ((uint32_t)(p)[0]) | ((uint32_t)(p)[1] << 8) | ((uint32_t)(p)[2] << 16) | ((uint32_t)(p)[3] << 24) ) -//static inline void U32TO8_LITTLE(uint8_t *const c,const uint32_t v) { c[0] = (uint8_t)v; c[1] = (uint8_t)(v >> 8); c[2] = (uint8_t)(v >> 16); c[3] = (uint8_t)(v >> 24); } - +#ifdef ZT_NO_TYPE_PUNNING +// Slower version that does not use type punning +#define U8TO32_LITTLE(p) ( ((uint32_t)(p)[0]) | ((uint32_t)(p)[1] << 8) | ((uint32_t)(p)[2] << 16) | ((uint32_t)(p)[3] << 24) ) +static inline void U32TO8_LITTLE(uint8_t *const c,const uint32_t v) { c[0] = (uint8_t)v; c[1] = (uint8_t)(v >> 8); c[2] = (uint8_t)(v >> 16); c[3] = (uint8_t)(v >> 24); } +#else // Fast version that just does 32-bit load/store #define U8TO32_LITTLE(p) (*((const uint32_t *)((const void *)(p)))) #define U32TO8_LITTLE(c,v) *((uint32_t *)((void *)(c))) = (v) +#endif // ZT_NO_TYPE_PUNNING #else // __BYTE_ORDER == __BIG_ENDIAN (we don't support anything else... does MIDDLE_ENDIAN even still exist?) |
