diff options
author | schmidt <douglascraigschmidt@users.noreply.github.com> | 2002-12-02 21:41:53 +0000 |
---|---|---|
committer | schmidt <douglascraigschmidt@users.noreply.github.com> | 2002-12-02 21:41:53 +0000 |
commit | 5caf48e0733cf8a5a38c4c2fb8589a85046d1b73 (patch) | |
tree | bc9f6e4f36dda40cee1a35d3c0fce3332fec5b58 /ace | |
parent | e917886f0885e8949335885c885eae09ef62992f (diff) | |
download | ATCD-5caf48e0733cf8a5a38c4c2fb8589a85046d1b73.tar.gz |
ChangeLogTag:Sat Nov 30 09:18:51 2002 Douglas C. Schmidt <schmidt@ace.cs.wustl.edu>
Diffstat (limited to 'ace')
-rw-r--r-- | ace/ACE.cpp | 29 | ||||
-rw-r--r-- | ace/ACE.h | 4 |
2 files changed, 30 insertions, 3 deletions
diff --git a/ace/ACE.cpp b/ace/ACE.cpp index 8271cdb2c9c..b3492d70c7b 100644 --- a/ace/ACE.cpp +++ b/ace/ACE.cpp @@ -473,9 +473,7 @@ ACE::crc32 (const char *buffer, ACE_UINT32 len) for (const char *p = buffer; p != buffer + len; ++p) - { - COMPUTE (crc, *p); - } + COMPUTE (crc, *p); // Include the length of the string. @@ -485,6 +483,31 @@ ACE::crc32 (const char *buffer, ACE_UINT32 len) return ~crc; } +u_long +ACE::crc32 (iovec *iov, int len) +{ + register ACE_UINT32 crc = 0; + + int total_len = 0; + + for (int i = 0; i < len; ++i) + { + for (const char *p = iov[i].iov_base; + p != iov[i].iov_base + iov[i].iov_len; + ++p) + COMPUTE (crc, *p); + + total_len += iov[i].iov_len; + } + + // Include the length of the string. + + for (; total_len != 0; total_len >>= 8) + COMPUTE (crc, total_len & 0xff); + + return ~crc; +} + #undef COMPUTE #if !defined (ACE_HAS_WINCE) diff --git a/ace/ACE.h b/ace/ACE.h index 14fad8aae3a..3fef3fae893 100644 --- a/ace/ACE.h +++ b/ace/ACE.h @@ -494,6 +494,10 @@ public: /// buffer (the length is included in the CRC). static u_long crc32 (const char *buf, ACE_UINT32 len); + /// Computes the ISO 8802-3 standard 32 bits CRC for the + /// @ len iovec buffers. + static u_long crc32 (iovec *iov, int len); + /// Euclid's greatest common divisor algorithm. static u_long gcd (u_long x, u_long y); |