diff options
author | yazevnul <yazevnul@yandex-team.ru> | 2022-02-10 16:46:46 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:46:46 +0300 |
commit | 8cbc307de0221f84c80c42dcbe07d40727537e2c (patch) | |
tree | 625d5a673015d1df891e051033e9fcde5c7be4e5 /contrib/libs/base64/plain64/enc_uint64.c | |
parent | 30d1ef3941e0dc835be7609de5ebee66958f215a (diff) | |
download | ydb-8cbc307de0221f84c80c42dcbe07d40727537e2c.tar.gz |
Restoring authorship annotation for <yazevnul@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'contrib/libs/base64/plain64/enc_uint64.c')
-rw-r--r-- | contrib/libs/base64/plain64/enc_uint64.c | 54 |
1 files changed, 27 insertions, 27 deletions
diff --git a/contrib/libs/base64/plain64/enc_uint64.c b/contrib/libs/base64/plain64/enc_uint64.c index 3d5955af24..8fd60e3b79 100644 --- a/contrib/libs/base64/plain64/enc_uint64.c +++ b/contrib/libs/base64/plain64/enc_uint64.c @@ -1,31 +1,31 @@ -// If we have 64-bit ints, pick off 6 bytes at a time for as long as we can, -// but ensure that there are at least 8 bytes available to avoid segfaulting: -while (srclen >= 8) -{ - // Load string: +// If we have 64-bit ints, pick off 6 bytes at a time for as long as we can, +// but ensure that there are at least 8 bytes available to avoid segfaulting: +while (srclen >= 8) +{ + // Load string: //uint64_t str = *(uint64_t *)c; uint64_t str; - + memcpy(&str, c, sizeof(str)); - // Reorder to 64-bit big-endian, if not already in that format. The - // workset must be in big-endian, otherwise the shifted bits do not - // carry over properly among adjacent bytes: - str = cpu_to_be64(str); - - // Shift input by 6 bytes each round and mask in only the lower 6 bits; - // look up the character in the Base64 encoding table and write it to - // the output location: - *o++ = plain64_base64_table_enc[(str >> 58) & 0x3F]; - *o++ = plain64_base64_table_enc[(str >> 52) & 0x3F]; - *o++ = plain64_base64_table_enc[(str >> 46) & 0x3F]; - *o++ = plain64_base64_table_enc[(str >> 40) & 0x3F]; - *o++ = plain64_base64_table_enc[(str >> 34) & 0x3F]; - *o++ = plain64_base64_table_enc[(str >> 28) & 0x3F]; - *o++ = plain64_base64_table_enc[(str >> 22) & 0x3F]; - *o++ = plain64_base64_table_enc[(str >> 16) & 0x3F]; - - c += 6; // 6 bytes of input - outl += 8; // 8 bytes of output - srclen -= 6; -} + // Reorder to 64-bit big-endian, if not already in that format. The + // workset must be in big-endian, otherwise the shifted bits do not + // carry over properly among adjacent bytes: + str = cpu_to_be64(str); + + // Shift input by 6 bytes each round and mask in only the lower 6 bits; + // look up the character in the Base64 encoding table and write it to + // the output location: + *o++ = plain64_base64_table_enc[(str >> 58) & 0x3F]; + *o++ = plain64_base64_table_enc[(str >> 52) & 0x3F]; + *o++ = plain64_base64_table_enc[(str >> 46) & 0x3F]; + *o++ = plain64_base64_table_enc[(str >> 40) & 0x3F]; + *o++ = plain64_base64_table_enc[(str >> 34) & 0x3F]; + *o++ = plain64_base64_table_enc[(str >> 28) & 0x3F]; + *o++ = plain64_base64_table_enc[(str >> 22) & 0x3F]; + *o++ = plain64_base64_table_enc[(str >> 16) & 0x3F]; + + c += 6; // 6 bytes of input + outl += 8; // 8 bytes of output + srclen -= 6; +} |