30#define BREAKPOINT raise (SIGUSR1)
38#define LIKELY(x) __builtin_expect(!!(x), true)
39#define UNLIKELY(x) __builtin_expect(!!(x), false)
53#define VOLK_VERSION "1.0b10"
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}
105#define VOLK_NOACTION 88801
112#define VOLK_NORESULT 88802
119#define VOLK_END 88803
132#define VOLK_CONFLICT 88804
135#define VOLK_ERROR -88899
138#define VOLK_PARSE_ERR -88898
141#define VOLK_VALUE_ERR -88897
144#define VOLK_TXN_ERR -88896
147#define VOLK_DB_ERR -88895
150#define VOLK_NOT_IMPL_ERR -88894
153#define VOLK_IO_ERR -88893
156#define VOLK_MEM_ERR -88892
167#define VOLK_CONFLICT_ERR -88891
170#define VOLK_ENV_ERR -88890
187#ifndef VOLK_HASH_SEED
189#define VOLK_HASH_SEED 0
193#define VOLK_HASH32(buf, size, seed) XXH32 (buf, size, seed)
195#define VOLK_HASH64(buf, size, seed) XXH3_64bits_withSeed (buf, size, seed)
197#define VOLK_HASH128(buf, size, seed) XXH3_128bits_withSeed (buf, size, seed)
199#if INTPTR_MAX == INT64_MAX
200#define VOLK_HASH(...) VOLK_HASH64 (__VA_ARGS__)
202#define VOLK_HASH(...) VOLK_HASH32 (__VA_ARGS__)
227#if INTPTR_MAX == INT64_MAX
270#define VOLK_MIN_ERROR VOLK_ERROR
275#define VOLK_MAX_ERROR -88000
278#define VOLK_MIN_WARNING VOLK_NOACTION
284#define VOLK_MAX_WARNING 88899
294#define log_debug(...) do {} while(0)
296#define log_trace(...) do {} while(0)
305#define LOG_RC(rc) do { \
306 if ((rc) < 0) log_error (VOLK_strerror (rc)); \
307 else if ((rc) > 0) log_warn (VOLK_strerror (rc)); \
311#define CHECK(exp, marker) do { \
312 VOLK_rc _rc = (exp); \
314 if (UNLIKELY (_rc != VOLK_OK)) { \
316 "*** PREMATURE EXIT due to error: %s", \
317 VOLK_strerror (_rc)); \
324#define PCHECK(exp, marker) do { \
325 VOLK_rc _rc = (exp); \
326 if (UNLIKELY (_rc < VOLK_OK)) { \
328 "*** PREMATURE EXIT due to error: %s", \
329 VOLK_strerror (_rc)); \
337#define NLCHECK(exp, marker) do { \
338 if (UNLIKELY ((exp) == NULL)) { \
339 log_error ("*** PREMATURE EXIT due to NULL result."); \
346#define RCCK(exp) do { \
347 VOLK_rc _rc = (exp); \
348 if (UNLIKELY (_rc != VOLK_OK)) { \
350 "*** PREMATURE EXIT due to non-zero exit: %s (%d)", \
351 VOLK_strerror (_rc), _rc); \
358#define PRCCK(exp) do { \
359 VOLK_rc _rc = (exp); \
360 if (UNLIKELY (_rc < VOLK_OK)) { \
362 "*** PREMATURE EXIT due to error: %s (%d)", \
363 VOLK_strerror (_rc), _rc); \
370#define NLRCCK(exp, _rc) do { \
371 if (UNLIKELY ((exp) == NULL)) { \
372 log_error ("*** PREMATURE EXIT due to NULL result."); \
379#define RCNL(exp) do { \
380 VOLK_rc _rc = (exp); \
381 if (UNLIKELY (_rc != VOLK_OK)) { \
383 "*** PREMATURE EXIT due to non-zero exit: %s (%d)", \
384 VOLK_strerror (_rc), _rc); \
390#define PRCNL(exp) do { \
391 VOLK_rc _rc = (exp); \
392 if (UNLIKELY (_rc < VOLK_OK)) { \
394 "*** PREMATURE EXIT due to error: %s (%d)", \
395 VOLK_strerror (_rc), _rc); \
401#define NLNL(exp) do { \
402 if (UNLIKELY ((exp) == NULL)) { \
403 log_error ("*** PREMATURE EXIT due to NULL result."); \
409#define MALLOC_GUARD(var, rc) do { \
410 (var) = malloc (sizeof *(var)); \
411 if (UNLIKELY (var == NULL)) return (rc); \
415#define CALLOC_GUARD(var, rc) do { \
416 (var) = calloc (1, sizeof *(var)); \
417 if (UNLIKELY (var == NULL)) return (rc); \
445char *
strndup (
const char *src,
size_t max);
454char *
strdup (
const char *src);
463mkdir_p (
const char *path, mode_t mode);
471rm_r (
const char *path);
495 else if (utf <= 0x07FF) {
497 out[0] = (char) (((utf >> 6) & 0x1F) | 0xC0);
498 out[1] = (char) (((utf >> 0) & 0x3F) | 0x80);
502 else if (utf <= 0xFFFF) {
504 out[0] = (char) (((utf >> 12) & 0x0F) | 0xE0);
505 out[1] = (char) (((utf >> 6) & 0x3F) | 0x80);
506 out[2] = (char) (((utf >> 0) & 0x3F) | 0x80);
510 else if (utf <= 0x10FFFF) {
512 out[0] = (char) (((utf >> 18) & 0x07) | 0xF0);
513 out[1] = (char) (((utf >> 12) & 0x3F) | 0x80);
514 out[2] = (char) (((utf >> 6) & 0x3F) | 0x80);
515 out[3] = (char) (((utf >> 0) & 0x3F) | 0x80);
521 out[0] = (char) 0xEF;
522 out[1] = (char) 0xBF;
523 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.
const char * VOLK_strerror(VOLK_rc rc)
Return an error message for a return code.
size_t VOLK_Key
Term key, i.e., hash of a serialized term.
char uuid_str_t[37]
UUID string tpe.
VOLK_Key VOLK_TripleKey[3]
Array of three VOLK_Key values, representing a triple.
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.