30#define BREAKPOINT raise (SIGINT)
38#define LIKELY(x) __builtin_expect(!!(x), true)
39#define UNLIKELY(x) __builtin_expect(!!(x), false)
53#define VOLK_VERSION "1.0b7"
55#define VOLK_NS "info:volksdata:"
57#define KLEN sizeof(VOLK_Key)
58#define DBL_KLEN sizeof(VOLK_DoubleKey)
59#define TRP_KLEN sizeof(VOLK_TripleKey)
60#define QUAD_KLEN sizeof(VOLK_QuadKey)
62# define UUIDSTR_SIZE 37
66#define NULL_TRP {NULL_KEY, NULL_KEY, NULL_KEY}
93#define VOLK_NOACTION 88801
100#define VOLK_NORESULT 88802
107#define VOLK_END 88803
120#define VOLK_CONFLICT 88804
123#define VOLK_ERROR -88899
126#define VOLK_PARSE_ERR -88898
129#define VOLK_VALUE_ERR -88897
132#define VOLK_TXN_ERR -88896
135#define VOLK_DB_ERR -88895
138#define VOLK_NOT_IMPL_ERR -88894
141#define VOLK_IO_ERR -88893
144#define VOLK_MEM_ERR -88892
155#define VOLK_CONFLICT_ERR -88891
158#define VOLK_ENV_ERR -88890
173#ifndef VOLK_HASH_SEED
175#define VOLK_HASH_SEED 0
179#define VOLK_HASH32(buf, size, seed) XXH32 (buf, size, seed)
181#define VOLK_HASH64(buf, size, seed) XXH3_64bits_withSeed (buf, size, seed)
183#define VOLK_HASH128(buf, size, seed) XXH3_128bits_withSeed (buf, size, seed)
185#if INTPTR_MAX == INT64_MAX
186#define VOLK_HASH(...) VOLK_HASH64 (__VA_ARGS__)
188#define VOLK_HASH(...) VOLK_HASH32 (__VA_ARGS__)
213#if INTPTR_MAX == INT64_MAX
249#define VOLK_MIN_ERROR -88899
254#define VOLK_MAX_ERROR -88000
257#define VOLK_MIN_WARNING 88800
263#define VOLK_MAX_WARNING 88899
272#define LOG_DEBUG(...) log_debug(__VA_ARGS__)
273#define LOG_TRACE(...) log_trace(__VA_ARGS__)
275#define LOG_DEBUG(...)
276#define LOG_TRACE(...)
285#define LOG_RC(rc) do { \
286 if ((rc) < 0) log_error (VOLK_strerror (rc)); \
287 else if ((rc) > 0) log_warn (VOLK_strerror (rc)); \
291#define CHECK(exp, marker) do { \
292 VOLK_rc _rc = (exp); \
294 if (UNLIKELY (_rc != VOLK_OK)) { \
296 "*** PREMATURE EXIT due to error: %s", \
297 VOLK_strerror (_rc)); \
303#define PCHECK(exp, marker) do { \
304 VOLK_rc _rc = (exp); \
305 if (UNLIKELY (_rc < VOLK_OK)) { \
307 "*** PREMATURE EXIT due to error: %s", \
308 VOLK_strerror (_rc)); \
315#define NLCHECK(exp, marker) do { \
316 if (UNLIKELY ((exp) == NULL)) { \
317 log_error ("*** PREMATURE EXIT due to NULL result."); \
323#define RCCK(exp) do { \
324 VOLK_rc _rc = (exp); \
325 if (UNLIKELY (_rc != VOLK_OK)) { \
327 "*** PREMATURE EXIT due to error: %s", \
328 VOLK_strerror (_rc)); \
334#define PRCCK(exp) do { \
335 VOLK_rc _rc = (exp); \
336 if (UNLIKELY (_rc < VOLK_OK)) { \
338 "*** PREMATURE EXIT due to error: %s", \
339 VOLK_strerror (_rc)); \
345#define RCNL(exp) do { \
346 VOLK_rc _rc = (exp); \
347 if (UNLIKELY (_rc != VOLK_OK)) { \
349 "*** PREMATURE EXIT due to error: %s", \
350 VOLK_strerror (_rc)); \
356#define PRCNL(exp) do { \
357 VOLK_rc _rc = (exp); \
358 if (UNLIKELY (_rc < VOLK_OK)) { \
360 "*** PREMATURE EXIT due to error: %s", \
361 VOLK_strerror (_rc)); \
367#define NLNL(exp) do { \
368 if (UNLIKELY ((exp) == NULL)) { \
369 log_error ("*** PREMATURE EXIT due to NULL result."); \
375#define MALLOC_GUARD(var, rc) do { \
376 (var) = malloc (sizeof *(var)); \
377 if (UNLIKELY (var == NULL)) return (rc); \
381#define CALLOC_GUARD(var, rc) do { \
382 (var) = calloc (1, sizeof *(var)); \
383 if (UNLIKELY (var == NULL)) return (rc); \
403char *
strndup (
const char *src,
size_t max);
412char *
strdup (
const char *src);
421mkdir_p (
const char *path, mode_t mode);
429rm_r (
const char *path);
453 else if (utf <= 0x07FF) {
455 out[0] = (char) (((utf >> 6) & 0x1F) | 0xC0);
456 out[1] = (char) (((utf >> 0) & 0x3F) | 0x80);
460 else if (utf <= 0xFFFF) {
462 out[0] = (char) (((utf >> 12) & 0x0F) | 0xE0);
463 out[1] = (char) (((utf >> 6) & 0x3F) | 0x80);
464 out[2] = (char) (((utf >> 0) & 0x3F) | 0x80);
468 else if (utf <= 0x10FFFF) {
470 out[0] = (char) (((utf >> 18) & 0x07) | 0xF0);
471 out[1] = (char) (((utf >> 12) & 0x3F) | 0x80);
472 out[2] = (char) (((utf >> 6) & 0x3F) | 0x80);
473 out[3] = (char) (((utf >> 0) & 0x3F) | 0x80);
479 out[0] = (char) 0xEF;
480 out[1] = (char) 0xBF;
481 out[2] = (char) 0xBD;
XXH64_hash_t VOLK_Hash64
64-bit hash data type.
VOLK_Hash64 VOLK_Hash
Default hash data type.
XXH128_hash_t VOLK_Hash128
128-bit hash data type.
bool VOLK_env_is_init
Whether the environment is initialized.
char * warning_msg[]
Warning messages.
XXH32_hash_t VOLK_Hash32
32-bit hash data type.
char * strdup(const char *src)
Replacement for GNU strdup.
int utf8_encode(const uint32_t utf, unsigned char *out)
Encode a code point using UTF-8.
VOLK_rc rm_r(const char *path)
Remove a directory recursively, as in Unix "rm -r".
char * strndup(const char *src, size_t max)
Replacement for GNU strndup.
VOLK_rc mkdir_p(const char *path, mode_t mode)
Make recursive directories.
size_t VOLK_Key
Term key, i.e., hash of a serialized term.
VOLK_Key VOLK_TripleKey[3]
Array of three VOLK_Key values, representing a triple.
char uuid_str_t[UUIDSTR_SIZE]
UUID string tpe.
VOLK_bool_op
Boolean operations that can be performed on a graph.
VOLK_Key VOLK_DoubleKey[2]
Array of two VOLK_Key values.
VOLK_Key VOLK_QuadKey[4]
Array of three VOLK_Key values, representing a triple with context.
@ VOLK_BOOL_XOR
Boolean XOR.
@ VOLK_BOOL_UNION
Boolean union.
@ VOLK_BOOL_SUBTRACTION
Boolean subtraction.
@ VOLK_BOOL_INTERSECTION
Boolean intersection.
const char * VOLK_strerror(VOLK_rc rc)
Return an error message for a return code.