Skip to content

Commit

Permalink
komi
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmilk committed Sep 21, 2024
1 parent 3014dcb commit 00e1c9e
Show file tree
Hide file tree
Showing 2 changed files with 1,036 additions and 0 deletions.
63 changes: 63 additions & 0 deletions module/zcommon/cityhash.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,11 @@
* Copyright (c) 2017 by Delphix. All rights reserved.
*/

#include "komihash.h"

#include <cityhash.h>

#if 0
#define HASH_K1 0xb492b66fbe98f273ULL
#define HASH_K2 0x9ae16a3b2f90404fULL

Expand Down Expand Up @@ -87,6 +90,66 @@ cityhash4(uint64_t w1, uint64_t w2, uint64_t w3, uint64_t w4)
{
return (cityhash_impl(w1, w2, w3, w4));
}
#endif

/*
* impl via komihash
*/
uint64_t
cityhash1(uint64_t w)
{
komihash_stream_t ctx;
void *p1 = w;

komihash_stream_init( &ctx, 0);
komihash_stream_update( &ctx, p1, 8);
return( komihash_stream_final( &ctx ));
}

uint64_t
cityhash2(uint64_t w1, uint64_t w2)
{
komihash_stream_t ctx;
void *p1 = w1;
void *p2 = w2;

komihash_stream_init( &ctx, 0);
komihash_stream_update( &ctx, p1, 8);
komihash_stream_update( &ctx, p2, 8);
return( komihash_stream_final( &ctx ));
}

uint64_t
cityhash3(uint64_t w1, uint64_t w2, uint64_t w3)
{
komihash_stream_t ctx;
void *p1 = w1;
void *p2 = w2;
void *p3 = w3;

komihash_stream_init( &ctx, 0);
komihash_stream_update( &ctx, p1, 8);
komihash_stream_update( &ctx, p2, 8);
komihash_stream_update( &ctx, p3, 8);
return( komihash_stream_final( &ctx ));
}

uint64_t
cityhash4(uint64_t w1, uint64_t w2, uint64_t w3, uint64_t w4)
{
komihash_stream_t ctx;
void *p1 = w1;
void *p2 = w2;
void *p3 = w3;
void *p4 = w4;

komihash_stream_init( &ctx, 0);
komihash_stream_update( &ctx, p1, 8);
komihash_stream_update( &ctx, p2, 8);
komihash_stream_update( &ctx, p3, 8);
komihash_stream_update( &ctx, p4, 8);
return( komihash_stream_final( &ctx ));
}

#if defined(_KERNEL)
EXPORT_SYMBOL(cityhash1);
Expand Down
Loading

0 comments on commit 00e1c9e

Please sign in to comment.