Overview
Comment: | Add OF_BSWAP{16,32,64}_IF_{BE,LE} for conditional byte swap. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
30f6c422adf981e79703008f8ce53e3d |
User & Date: | js on 2009-08-28 00:33:15 |
Other Links: | manifest | tags |
Context
2009-08-28
| ||
02:12 | Add assembly implementation for OF_BSWAP{16,32,64} for x86 and AMD64. check-in: 42aaecc3cd user: js tags: trunk | |
00:33 | Add OF_BSWAP{16,32,64}_IF_{BE,LE} for conditional byte swap. check-in: 30f6c422ad user: js tags: trunk | |
00:18 | Improve -[isEqual:] of OFList. check-in: d68dc5201f user: js tags: trunk | |
Changes
Modified src/OFHashes.m from [8f94b0d560] to [a7bb9e72ee].
︙ | ︙ | |||
166 167 168 169 170 171 172 | if (size < t) { memcpy(p, buffer, size); return self; } memcpy(p, buffer, t); | | | | 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 | if (size < t) { memcpy(p, buffer, size); return self; } memcpy(p, buffer, t); OF_BSWAP32_V_IF_BE((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_IF_BE((uint32_t*)in, 16); md5_transform(buf, (uint32_t*)in); buffer += 64; size -= 64; } /* Handle any remaining bytes of data. */ |
︙ | ︙ | |||
214 215 216 217 218 219 220 | /* 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); | | | | | 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 242 243 244 | /* 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_IF_BE((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_IF_BE((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_IF_BE(buf, 4); calculated = YES; return (uint8_t*)buf; } @end |
︙ | ︙ |
Modified src/OFMacros.h from [f80e6add7a] to [8a995369a7].
︙ | ︙ | |||
54 55 56 57 58 59 60 | (i & UINT64_C(0x00000000FF000000)) << 8 | (i & UINT64_C(0x0000000000FF0000)) << 24 | (i & UINT64_C(0x000000000000FF00)) << 40 | (i & UINT64_C(0x00000000000000FF)) << 56; return i; } | < > > > > > > > > > > | > > > > > | 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 79 80 81 82 83 84 85 86 87 88 89 90 91 92 | (i & UINT64_C(0x00000000FF000000)) << 8 | (i & UINT64_C(0x0000000000FF0000)) << 24 | (i & UINT64_C(0x000000000000FF00)) << 40 | (i & UINT64_C(0x00000000000000FF)) << 56; return i; } static OF_INLINE void OF_BSWAP32_V(uint32_t *buf, size_t len) { while (len--) { *buf = OF_BSWAP32(*buf); buf++; } } #ifdef OF_BIG_ENDIAN #define OF_BSWAP16_IF_BE(i) OF_BSWAP16(i) #define OF_BSWAP32_IF_BE(i) OF_BSWAP32(i) #define OF_BSWAP64_IF_BE(i) OF_BSWAP64(i) #define OF_BSWAP16_IF_LE(i) i #define OF_BSWAP32_IF_LE(i) i #define OF_BSWAP64_IF_LE(i) i #define OF_BSWAP32_V_IF_BE(buf, len) OF_BSWAP32_V(buf, len) #else #define OF_BSWAP16_IF_BE(i) i #define OF_BSWAP32_IF_BE(i) i #define OF_BSWAP64_IF_BE(i) i #define OF_BSWAP16_IF_LE(i) OF_BSWAP16(i) #define OF_BSWAP32_IF_LE(i) OF_BSWAP32(i) #define OF_BSWAP64_IF_LE(i) OF_BSWAP64(i) #define OF_BSWAP32_V_IF_BE(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) \ |
︙ | ︙ |
Modified src/OFTCPSocket.m from [7e7c4b019c] to [5c57ec1e56].
︙ | ︙ | |||
102 103 104 105 106 107 108 | newWithClass: isa node: node service: service]; } if ((se = getservbyname([service cString], "TCP")) != NULL) port = se->s_port; | | | 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 | newWithClass: isa node: node service: service]; } if ((se = getservbyname([service cString], "TCP")) != NULL) port = se->s_port; else if ((port = OF_BSWAP16_IF_LE(atoi([service cString]))) == 0) { [mutex unlock]; @throw [OFAddressTranslationFailedException newWithClass: isa node: node service: service]; } |
︙ | ︙ | |||
208 209 210 211 212 213 214 | newWithClass: isa node: node service: service]; } if ((se = getservbyname([service cString], "TCP")) != NULL) port = se->s_port; | | | 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 | newWithClass: isa node: node service: service]; } if ((se = getservbyname([service cString], "TCP")) != NULL) port = se->s_port; else if ((port = OF_BSWAP16_IF_LE(atoi([service cString]))) == 0) { [mutex unlock]; @throw [OFAddressTranslationFailedException newWithClass: isa node: node service: service]; } |
︙ | ︙ |