-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
perl implementation of crc32 algorithm added
- Loading branch information
Pavel Berezhnoy
committed
Nov 30, 2015
1 parent
24a5091
commit f13da35
Showing
1 changed file
with
20 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
if ffi == nil then | ||
if require == nil then | ||
error('You must restart tarantool') | ||
end | ||
ffi = require('ffi') | ||
end | ||
|
||
ffi.cdef[[ | ||
unsigned perl_crc32(const char *key, unsigned len); | ||
]] | ||
|
||
local libperlcrc32 = ffi.load("perlcrc32") | ||
|
||
function perl_crc32(key) | ||
if type(key) ~= "string" then | ||
error("String key is expected in perl_crc32: '" .. key .. "'") | ||
end | ||
|
||
return libperlcrc32.perl_crc32(key, #key) | ||
end |