Changeset 279733d
- Timestamp:
- 03/12/08 14:40:30 (4 years ago)
- Branches:
- master, ketama-compat
- Children:
- b1cbae
- Parents:
- 272c52
- git-author:
- Tomash Brechko <tomash.brechko@…> (03/12/08 14:09:36)
- git-committer:
- Tomash Brechko <tomash.brechko@…> (03/12/08 14:40:30)
- File:
-
- 1 edited
-
src/gencrc32.pl (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/gencrc32.pl
rcd76f9 r279733d 1 1 #! /usr/bin/perl 2 2 # 3 # Copyright (C) 2007 Tomash Brechko. All rights reserved.3 # Copyright (C) 2007-2008 Tomash Brechko. All rights reserved. 4 4 # 5 5 # This program is free software; you can redistribute it and/or modify … … 70 70 71 71 72 staticconst unsigned int crc32lookup[256] = {72 const unsigned int crc32lookup[256] = { 73 73 $table 74 74 }; 75 76 77 unsigned int78 compute_crc32_add(unsigned int crc32, const char *s, size_t len)79 {80 const char *end = s + len;81 82 crc32 = ~crc32;83 84 while (s < end)85 {86 unsigned int index = (crc32 ^ (unsigned char) *s) & 0x000000ffU;87 crc32 = (crc32 >> 8) ^ crc32lookup[index];88 ++s;89 }90 91 return (~crc32);92 }93 75 EOF 94 76 … … 112 94 113 95 114 extern 115 unsigned int 116 compute_crc32_add(unsigned int crc32, const char *s, size_t len); 96 extern const unsigned int crc32lookup[]; 117 97 98 99 #define compute_crc32(s, l) \\ 100 compute_crc32_add(@{[ sprintf("0x%08xU", $init) ]}, (s), (l)) 118 101 119 102 static inline 120 103 unsigned int 121 compute_crc32 (const char *s, size_t len)104 compute_crc32_add(unsigned int crc32, const char *s, size_t len) 122 105 { 123 return compute_crc32_add(@{[ sprintf("0x%08xU", $init) ]}, s, len); 106 const char *end = s + len; 107 108 crc32 = ~crc32; 109 110 while (s < end) 111 { 112 unsigned int index = (crc32 ^ (unsigned char) *s) & 0x000000ffU; 113 crc32 = (crc32 >> 8) ^ crc32lookup[index]; 114 ++s; 115 } 116 117 return (~crc32); 124 118 } 125 119
Note: See TracChangeset
for help on using the changeset viewer.
