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 VOLK_ERROR
254#define VOLK_MAX_ERROR -88000
257#define VOLK_MIN_WARNING VOLK_NOACTION
263#define VOLK_MAX_WARNING 88899
273#define log_debug(...) do {} while(0)
275#define log_trace(...) do {} while(0)
284#define LOG_RC(rc) do { \
285 if ((rc) < 0) log_error (VOLK_strerror (rc)); \
286 else if ((rc) > 0) log_warn (VOLK_strerror (rc)); \
290#define CHECK(exp, marker) do { \
291 VOLK_rc _rc = (exp); \
293 if (UNLIKELY (_rc != VOLK_OK)) { \
295 "*** PREMATURE EXIT due to error: %s", \
296 VOLK_strerror (_rc)); \
302#define PCHECK(exp, marker) do { \
303 VOLK_rc _rc = (exp); \
304 if (UNLIKELY (_rc < VOLK_OK)) { \
306 "*** PREMATURE EXIT due to error: %s", \
307 VOLK_strerror (_rc)); \
314#define NLCHECK(exp, marker) do { \
315 if (UNLIKELY ((exp) == NULL)) { \
316 log_error ("*** PREMATURE EXIT due to NULL result."); \
322#define RCCK(exp) do { \
323 VOLK_rc _rc = (exp); \
324 if (UNLIKELY (_rc != VOLK_OK)) { \
326 "*** PREMATURE EXIT due to error: %s (%d)", \
327 VOLK_strerror (_rc), _rc); \
333#define PRCCK(exp) do { \
334 VOLK_rc _rc = (exp); \
335 if (UNLIKELY (_rc < VOLK_OK)) { \
337 "*** PREMATURE EXIT due to error: %s (%d)", \
338 VOLK_strerror (_rc), _rc); \
344#define NLRCCK(exp, _rc) do { \
345 if (UNLIKELY ((exp) == NULL)) { \
346 log_error ("*** PREMATURE EXIT due to NULL result."); \
352#define RCNL(exp) do { \
353 VOLK_rc _rc = (exp); \
354 if (UNLIKELY (_rc != VOLK_OK)) { \
356 "*** PREMATURE EXIT due to error: %s (%d)", \
357 VOLK_strerror (_rc), _rc); \
363#define PRCNL(exp) do { \
364 VOLK_rc _rc = (exp); \
365 if (UNLIKELY (_rc < VOLK_OK)) { \
367 "*** PREMATURE EXIT due to error: %s (%d)", \
368 VOLK_strerror (_rc), _rc); \
374#define NLNL(exp) do { \
375 if (UNLIKELY ((exp) == NULL)) { \
376 log_error ("*** PREMATURE EXIT due to NULL result."); \
382#define MALLOC_GUARD(var, rc) do { \
383 (var) = malloc (sizeof *(var)); \
384 if (UNLIKELY (var == NULL)) return (rc); \
388#define CALLOC_GUARD(var, rc) do { \
389 (var) = calloc (1, sizeof *(var)); \
390 if (UNLIKELY (var == NULL)) return (rc); \
410char *
strndup (
const char *src,
size_t max);
419char *
strdup (
const char *src);
428mkdir_p (
const char *path, mode_t mode);
436rm_r (
const char *path);
460 else if (utf <= 0x07FF) {
462 out[0] = (char) (((utf >> 6) & 0x1F) | 0xC0);
463 out[1] = (char) (((utf >> 0) & 0x3F) | 0x80);
467 else if (utf <= 0xFFFF) {
469 out[0] = (char) (((utf >> 12) & 0x0F) | 0xE0);
470 out[1] = (char) (((utf >> 6) & 0x3F) | 0x80);
471 out[2] = (char) (((utf >> 0) & 0x3F) | 0x80);
475 else if (utf <= 0x10FFFF) {
477 out[0] = (char) (((utf >> 18) & 0x07) | 0xF0);
478 out[1] = (char) (((utf >> 12) & 0x3F) | 0x80);
479 out[2] = (char) (((utf >> 6) & 0x3F) | 0x80);
480 out[3] = (char) (((utf >> 0) & 0x3F) | 0x80);
486 out[0] = (char) 0xEF;
487 out[1] = (char) 0xBF;
488 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.