semver: 1.0 -> 1
[m6w6/libmemcached] / include / libhashkit-1 / types.h
1 /*
2 +--------------------------------------------------------------------+
3 | libmemcached - C/C++ Client Library for memcached |
4 +--------------------------------------------------------------------+
5 | Redistribution and use in source and binary forms, with or without |
6 | modification, are permitted under the terms of the BSD license. |
7 | You should have received a copy of the license in a bundled file |
8 | named LICENSE; in case you did not receive a copy you can review |
9 | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
10 +--------------------------------------------------------------------+
11 | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
12 | Copyright (c) 2020 Michael Wallner <mike@php.net> |
13 +--------------------------------------------------------------------+
14 */
15
16 #pragma once
17
18 typedef enum {
19 HASHKIT_SUCCESS,
20 HASHKIT_FAILURE,
21 HASHKIT_MEMORY_ALLOCATION_FAILURE,
22 HASHKIT_INVALID_HASH,
23 HASHKIT_INVALID_ARGUMENT,
24 HASHKIT_MAXIMUM_RETURN /* Always add new error code before */
25 } hashkit_return_t;
26
27 static inline bool hashkit_success(const hashkit_return_t rc) {
28 return (rc == HASHKIT_SUCCESS);
29 }
30
31 static inline bool hashkit_failed(const hashkit_return_t rc) {
32 return (rc != HASHKIT_SUCCESS);
33 }
34
35 typedef enum {
36 HASHKIT_HASH_DEFAULT = 0, // hashkit_one_at_a_time()
37 HASHKIT_HASH_MD5,
38 HASHKIT_HASH_CRC,
39 HASHKIT_HASH_FNV1_64,
40 HASHKIT_HASH_FNV1A_64,
41 HASHKIT_HASH_FNV1_32,
42 HASHKIT_HASH_FNV1A_32,
43 HASHKIT_HASH_HSIEH,
44 HASHKIT_HASH_MURMUR,
45 HASHKIT_HASH_JENKINS,
46 HASHKIT_HASH_MURMUR3,
47 HASHKIT_HASH_CUSTOM,
48 HASHKIT_HASH_MAX
49 } hashkit_hash_algorithm_t;
50
51 /**
52 * Hash distributions that are available to use.
53 */
54 typedef enum {
55 HASHKIT_DISTRIBUTION_MODULA,
56 HASHKIT_DISTRIBUTION_RANDOM,
57 HASHKIT_DISTRIBUTION_KETAMA,
58 HASHKIT_DISTRIBUTION_MAX /* Always add new values before this. */
59 } hashkit_distribution_t;
60
61 #ifdef __cplusplus
62 extern "C" {
63 #endif
64
65 typedef struct hashkit_st hashkit_st;
66 typedef struct hashkit_string_st hashkit_string_st;
67
68 typedef uint32_t (*hashkit_hash_fn)(const char *key, size_t key_length, void *context);
69
70 #ifdef __cplusplus
71 }
72 #endif