automotive-dlt
city_c.c File Reference
#include "city_c.h"
#include <string.h>
Include dependency graph for city_c.c:

Go to the source code of this file.

Macros

#define uint32_in_expected_order(x)   (x)
 
#define uint64_in_expected_order(x)   (x)
 
#define LIKELY(x)   (x)
 
#define UNSAFE_SWAP(type, a, b)   do {type tmp;tmp=(a);(a)=(b);(b)=tmp;} while (0)
 

Functions

static uint128 UInt128 (uint64 low, uint64 high)
 
static uint64 UNALIGNED_LOAD64 (const char *p)
 
static uint32 UNALIGNED_LOAD32 (const char *p)
 
static uint64 Hash64Pairto64 (uint64 u, uint64 v)
 
static uint64 Fetch64 (const char *p)
 
static uint32 Fetch32 (const char *p)
 
static uint64 Rotate (uint64 val, int shift)
 
static uint64 RotateByAtLeast1 (uint64 val, int shift)
 
static uint64 ShiftMix (uint64 val)
 
static uint64 HashLen16 (uint64 u, uint64 v)
 
static uint64 HashLen0to16 (const char *s, size_t len)
 
static uint64 HashLen17to32 (const char *s, size_t len)
 
static uint128 WeakHashLen32WithSeeds6 (uint64 w, uint64 x, uint64 y, uint64 z, uint64 a, uint64 b)
 
static uint128 WeakHashLen32WithSeeds3 (const char *s, uint64 a, uint64 b)
 
static uint64 HashLen33to64 (const char *s, size_t len)
 
uint64 CityHash64 (const char *s, size_t len)
 
uint64 CityHash64WithSeed (const char *s, size_t len, uint64 seed)
 
uint64 CityHash64WithSeeds (const char *s, size_t len, uint64 seed0, uint64 seed1)
 
static uint128 CityMurmur (const char *s, size_t len, uint128 seed)
 
uint128 CityHash128WithSeed (const char *s, size_t len, uint128 seed)
 
uint128 CityHash128 (const char *s, size_t len)
 

Variables

static const uint64 k0 = 0xc3a5c85c97cb3127ULL
 
static const uint64 k1 = 0xb492b66fbe98f273ULL
 
static const uint64 k2 = 0x9ae16a3b2f90404fULL
 
static const uint64 k3 = 0xc949d7c7509e6557ULL
 

Macro Definition Documentation

#define LIKELY (   x)    (x)

Definition at line 79 of file city_c.c.

Referenced by CityHash128(), and CityHash128WithSeed().

#define uint32_in_expected_order (   x)    (x)

Definition at line 50 of file city_c.c.

Referenced by Fetch32().

#define uint64_in_expected_order (   x)    (x)

Definition at line 51 of file city_c.c.

Referenced by Fetch64().

#define UNSAFE_SWAP (   type,
  a,
 
)    do {type tmp;tmp=(a);(a)=(b);(b)=tmp;} while (0)

Definition at line 83 of file city_c.c.

Referenced by CityHash128WithSeed(), and CityHash64().

Function Documentation

uint128 CityHash128 ( const char *  s,
size_t  len 
)
uint128 CityHash128WithSeed ( const char *  s,
size_t  len,
uint128  seed 
)
uint64 CityHash64WithSeed ( const char *  s,
size_t  len,
uint64  seed 
)

Definition at line 273 of file city_c.c.

References CityHash64WithSeeds(), and k2.

Referenced by Test().

uint64 CityHash64WithSeeds ( const char *  s,
size_t  len,
uint64  seed0,
uint64  seed1 
)

Definition at line 277 of file city_c.c.

References CityHash64(), and HashLen16().

Referenced by CityHash64WithSeed(), and Test().

static uint128 CityMurmur ( const char *  s,
size_t  len,
uint128  seed 
)
static

Definition at line 283 of file city_c.c.

References Fetch64(), HashLen0to16(), HashLen16(), k1, ShiftMix(), UInt128(), Uint128High64, and Uint128Low64.

Referenced by CityHash128WithSeed().

static uint32 Fetch32 ( const char *  p)
inlinestatic

Definition at line 120 of file city_c.c.

References uint32_in_expected_order, and UNALIGNED_LOAD32().

Referenced by HashLen0to16().

static uint64 Fetch64 ( const char *  p)
inlinestatic
static uint64 Hash64Pairto64 ( uint64  u,
uint64  v 
)
static

Definition at line 104 of file city_c.c.

Referenced by HashLen16().

static uint64 HashLen0to16 ( const char *  s,
size_t  len 
)
static

Definition at line 153 of file city_c.c.

References Fetch32(), Fetch64(), HashLen16(), k2, k3, RotateByAtLeast1(), and ShiftMix().

Referenced by CityHash64(), and CityMurmur().

static uint64 HashLen16 ( uint64  u,
uint64  v 
)
inlinestatic
static uint64 HashLen17to32 ( const char *  s,
size_t  len 
)
static

Definition at line 176 of file city_c.c.

References Fetch64(), HashLen16(), k0, k1, k2, k3, and Rotate().

Referenced by CityHash64().

static uint64 HashLen33to64 ( const char *  s,
size_t  len 
)
static

Definition at line 209 of file city_c.c.

References Fetch64(), k0, k2, Rotate(), and ShiftMix().

Referenced by CityHash64().

static uint64 Rotate ( uint64  val,
int  shift 
)
inlinestatic
static uint64 RotateByAtLeast1 ( uint64  val,
int  shift 
)
inlinestatic

Definition at line 140 of file city_c.c.

Referenced by HashLen0to16().

static uint64 ShiftMix ( uint64  val)
inlinestatic

Definition at line 144 of file city_c.c.

Referenced by CityHash128(), CityHash64(), CityMurmur(), HashLen0to16(), and HashLen33to64().

static uint128 UInt128 ( uint64  low,
uint64  high 
)
inlinestatic

Definition at line 85 of file city_c.c.

References uint128::first, and uint128::second.

Referenced by CityHash128(), CityHash128WithSeed(), CityMurmur(), and WeakHashLen32WithSeeds6().

static uint32 UNALIGNED_LOAD32 ( const char *  p)
inlinestatic

Definition at line 98 of file city_c.c.

Referenced by Fetch32().

static uint64 UNALIGNED_LOAD64 ( const char *  p)
inlinestatic

Definition at line 92 of file city_c.c.

Referenced by Fetch64().

static uint128 WeakHashLen32WithSeeds3 ( const char *  s,
uint64  a,
uint64  b 
)
static

Definition at line 199 of file city_c.c.

References Fetch64(), and WeakHashLen32WithSeeds6().

Referenced by CityHash128WithSeed(), and CityHash64().

static uint128 WeakHashLen32WithSeeds6 ( uint64  w,
uint64  x,
uint64  y,
uint64  z,
uint64  a,
uint64  b 
)
static

Definition at line 187 of file city_c.c.

References Rotate(), and UInt128().

Referenced by WeakHashLen32WithSeeds3().

Variable Documentation

const uint64 k0 = 0xc3a5c85c97cb3127ULL
static

Definition at line 125 of file city_c.c.

Referenced by CityHash128(), CityHash128WithSeed(), HashLen17to32(), and HashLen33to64().

const uint64 k1 = 0xb492b66fbe98f273ULL
static

Definition at line 126 of file city_c.c.

Referenced by CityHash128(), CityHash128WithSeed(), CityHash64(), CityMurmur(), and HashLen17to32().

const uint64 k2 = 0x9ae16a3b2f90404fULL
static

Definition at line 127 of file city_c.c.

Referenced by CityHash64WithSeed(), HashLen0to16(), HashLen17to32(), and HashLen33to64().

const uint64 k3 = 0xc949d7c7509e6557ULL
static

Definition at line 128 of file city_c.c.

Referenced by CityHash128(), HashLen0to16(), and HashLen17to32().