Overview
Comment: | Add OF_BSWAP{16,32,64}. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
c38fc9bb147da80559a870655335ec04 |
User & Date: | js on 2009-08-28 00:05:24 |
Other Links: | manifest | tags |
Context
2009-08-28
| ||
00:18 | Prevent updating a hash after it has been calculated. check-in: 5bf0f17e80 user: js tags: trunk | |
00:05 | Add OF_BSWAP{16,32,64}. check-in: c38fc9bb14 user: js tags: trunk | |
2009-08-27
| ||
20:40 | Cache the number of items in an OFList. check-in: 768108a960 user: js tags: trunk | |
Changes
Modified configure.ac from [b1bcaf4cd6] to [94f9404973].
︙ | ︙ | |||
22 23 24 25 26 27 28 | AC_SUBST(OFPLUGIN, "OFPlugin") AC_SUBST(OFPLUGIN_DEF, "-DOF_PLUGINS") fi AC_C_BIGENDIAN([ AC_DEFINE(OF_BIG_ENDIAN, 1, [Whether we are big endian]) AC_SUBST(ENDIANESS_DEF, "-DOF_BIG_ENDIAN") | | < < | 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | AC_SUBST(OFPLUGIN, "OFPlugin") AC_SUBST(OFPLUGIN_DEF, "-DOF_PLUGINS") fi AC_C_BIGENDIAN([ AC_DEFINE(OF_BIG_ENDIAN, 1, [Whether we are big endian]) AC_SUBST(ENDIANESS_DEF, "-DOF_BIG_ENDIAN") ]) AC_MSG_CHECKING(for SIZE_MAX) AC_EGREP_CPP(yes, [ #include <stdint.h> #include <limits.h> #ifdef SIZE_MAX |
︙ | ︙ |
Modified src/OFHashes.m from [3030cde43c] to [3186857f90].
︙ | ︙ | |||
163 164 165 166 167 168 169 | if (size < t) { memcpy(p, buffer, size); return self; } memcpy(p, buffer, t); | | | | 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 | if (size < t) { memcpy(p, buffer, size); return self; } memcpy(p, buffer, t); OF_BSWAP32_V((uint32_t*)in, 16); md5_transform(buf, (uint32_t*)in); buffer += t; size -= t; } /* Process data in 64-byte chunks */ while (size >= 64) { memcpy(in, buffer, 64); OF_BSWAP32_V((uint32_t*)in, 16); md5_transform(buf, (uint32_t*)in); buffer += 64; size -= 64; } /* Handle any remaining bytes of data. */ |
︙ | ︙ | |||
211 212 213 214 215 216 217 | /* Bytes of padding needed to make 64 bytes */ count = 64 - 1 - count; /* Pad out to 56 mod 64 */ if (count < 8) { /* Two lots of padding: Pad the first block to 64 bytes */ memset(p, 0, count); | | | | | 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 | /* Bytes of padding needed to make 64 bytes */ count = 64 - 1 - count; /* Pad out to 56 mod 64 */ if (count < 8) { /* Two lots of padding: Pad the first block to 64 bytes */ memset(p, 0, count); OF_BSWAP32_V((uint32_t*)in, 16); md5_transform(buf, (uint32_t*)in); /* Now fill the next block with 56 bytes */ memset(in, 0, 56); } else { /* Pad block to 56 bytes */ memset(p, 0, count - 8); } OF_BSWAP32_V((uint32_t*)in, 14); /* Append length in bits and transform */ ((uint32_t*)in)[14] = bits[0]; ((uint32_t*)in)[15] = bits[1]; md5_transform(buf, (uint32_t*)in); OF_BSWAP32_V(buf, 4); calculated = YES; return (uint8_t*)buf; } @end |
︙ | ︙ |
Modified src/OFMacros.h from [776fab6bc8] to [f80e6add7a].
︙ | ︙ | |||
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | */ #ifndef OF_CONFIGURED #error You are missing the libobjfw definitions! #error Please use objfw-config! #endif #ifdef __GNUC__ #define OF_INLINE inline __attribute__((always_inline)) #define OF_LIKELY(cond) __builtin_expect(!!(cond), 1) #define OF_UNLIKELY(cond) __builtin_expect(!!(cond), 0) #else #define OF_INLINE inline #define OF_LIKELY(cond) cond #define OF_UNLIKELY(cond) cond #endif | > > > | > > > > > | > > | > > > > > > > | | > > > > > > > > > > > > > | | < < | | < < | | 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 | */ #ifndef OF_CONFIGURED #error You are missing the libobjfw definitions! #error Please use objfw-config! #endif #include <stdint.h> #ifdef __GNUC__ #define OF_INLINE inline __attribute__((always_inline)) #define OF_LIKELY(cond) __builtin_expect(!!(cond), 1) #define OF_UNLIKELY(cond) __builtin_expect(!!(cond), 0) #else #define OF_INLINE inline #define OF_LIKELY(cond) cond #define OF_UNLIKELY(cond) cond #endif static OF_INLINE uint16_t OF_BSWAP16(uint16_t i) { i = (i & UINT16_C(0xFF00)) >> 8 | (i & UINT16_C(0x00FF)) << 8; return i; } static OF_INLINE uint32_t OF_BSWAP32(uint32_t i) { i = (i & UINT32_C(0xFF000000)) >> 24 | (i & UINT32_C(0x00FF0000)) >> 8 | (i & UINT32_C(0x0000FF00)) << 8 | (i & UINT32_C(0x000000FF)) << 24; return i; } static OF_INLINE uint64_t OF_BSWAP64(uint64_t i) { i = (i & UINT64_C(0xFF00000000000000)) >> 56 | (i & UINT64_C(0x00FF000000000000)) >> 40 | (i & UINT64_C(0x0000FF0000000000)) >> 24 | (i & UINT64_C(0x000000FF00000000)) >> 8 | (i & UINT64_C(0x00000000FF000000)) << 8 | (i & UINT64_C(0x0000000000FF0000)) << 24 | (i & UINT64_C(0x000000000000FF00)) << 40 | (i & UINT64_C(0x00000000000000FF)) << 56; return i; } #ifdef OF_BIG_ENDIAN static OF_INLINE void OF_BSWAP32_V(uint32_t *buf, size_t len) { while (len--) { *buf = OF_BSWAP32(*buf); buf++; } } #else #define OF_BSWAP32_V(buf, len) #endif #define OF_ROL(val, bits) \ (((val) << (bits)) | ((val) >> (32 - (bits)))) #define OF_HASH_INIT(hash) hash = 0 #define OF_HASH_ADD(hash, byte) \ |
︙ | ︙ |