libweed  2.0.0
Macros | Functions
weed.c File Reference
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <weed/weed.h>
#include <pthread.h>

Macros

#define __LIBWEED__
 
#define WEED_MAGIC_HASH   0xB82E802F
 
#define WEED_FLAG_OP_DELETE   WEED_FLAG_RESERVED_0
 
#define GNU_FLATTEN
 
#define GNU_CONST
 
#define GNU_HOT
 
#define GNU_PURE
 
#define EXPORTED
 
#define NOT_EXPORTED
 
#define is_plant(leaf)   (leaf->key_hash == WEED_MAGIC_HASH)
 
#define get_data_lock(leaf)
 
#define get_chain_lock(leaf)
 
#define get_data_mutex(leaf)
 
#define get_structure_mutex(plant)   (&(((plant_priv_data_t *)((plant)->private_data))->structure_mutex))
 
#define get_count_lock(plant)   (&(((plant_priv_data_t *)((plant)->private_data))->reader_count))
 
#define data_lock_unlock(obj)
 
#define data_lock_writelock(obj)
 
#define data_lock_readlock(obj)
 
#define chain_lock_unlock(obj)
 
#define chain_lock_writelock(obj)
 
#define chain_lock_readlock(obj)
 
#define chain_lock_try_writelock(obj)   (pthread_rwlock_trywrlock(get_chain_lock((obj))))
 
#define chain_lock_try_readlock(obj)   (pthread_rwlock_tryrdlock(get_chain_lock((obj))))
 
#define structure_mutex_trylock(obj)   (pthread_mutex_trylock(get_structure_mutex((obj))))
 
#define structure_mutex_lock(obj)
 
#define structure_mutex_unlock(obj)
 
#define reader_count_add(obj)
 
#define reader_count_sub(obj)
 
#define reader_count_wait(obj)
 
#define return_unlock(obj, val)
 
#define weed_malloc   malloc
 
#define weed_malloc_sizeof(t)   malloc(sizeof(t))
 
#define weed_unmalloc_sizeof(t, ptr)   free(ptr)
 
#define weed_unmalloc_and_copy(size, ptr)   free(ptr)
 
#define weed_malloc_and_copy(size, src)   memcpy(malloc(size), src, size)
 
#define weed_strdup(oldstring, size)
 
#define IS_VALID_SEED_TYPE(seed_type)   ((seed_type >=64 || (seed_type >= 1 && seed_type <= 5) ? 1 : 0))
 
#define weed_strlen(s)   ((s) ? strlen((s)) : 0)
 
#define weed_strcmp(s1, s2)   ((!(s1) || !(s2)) ? (s1 != s2) : strcmp(s1, s2))
 
#define get16bits(d)   (*((const uint16_t *) (d)))
 
#define HASHROOT   5381
 
#define weed_seed_is_ptr(seed_type)   (seed_type >= 64 ? 1 : 0)
 
#define weed_seed_get_size(seed_type, size)
 

Functions

EXPORTED int32_t weed_get_abi_version (void)
 
EXPORTED weed_error_t weed_init (int32_t abi, uint64_t init_flags)
 

Macro Definition Documentation

◆ __LIBWEED__

#define __LIBWEED__

◆ chain_lock_readlock

#define chain_lock_readlock (   obj)
Value:
do { \
if ((obj)) pthread_rwlock_rdlock(get_chain_lock((obj)));} while (0)

◆ chain_lock_try_readlock

#define chain_lock_try_readlock (   obj)    (pthread_rwlock_tryrdlock(get_chain_lock((obj))))

◆ chain_lock_try_writelock

#define chain_lock_try_writelock (   obj)    (pthread_rwlock_trywrlock(get_chain_lock((obj))))

◆ chain_lock_unlock

#define chain_lock_unlock (   obj)
Value:
do { \
if ((obj)) pthread_rwlock_unlock(get_chain_lock((obj)));} while (0)

◆ chain_lock_writelock

#define chain_lock_writelock (   obj)
Value:
do { \
if ((obj)) pthread_rwlock_wrlock(get_chain_lock((obj)));} while (0)

◆ data_lock_readlock

#define data_lock_readlock (   obj)
Value:
do { \
if ((obj)) pthread_rwlock_rdlock(get_data_lock((obj)));} while (0)

◆ data_lock_unlock

#define data_lock_unlock (   obj)
Value:
do { \
if ((obj)) pthread_rwlock_unlock(get_data_lock((obj)));} while (0)

◆ data_lock_writelock

#define data_lock_writelock (   obj)
Value:
do { \
if ((obj)) pthread_rwlock_wrlock(get_data_lock((obj)));} while (0)

◆ EXPORTED

#define EXPORTED

◆ get16bits

#define get16bits (   d)    (*((const uint16_t *) (d)))

◆ get_chain_lock

#define get_chain_lock (   leaf)
Value:
(is_plant(leaf) ? \
&(((plant_priv_data_t *)((leaf)->private_data))->ldata.chain_lock) : \
&(((leaf_priv_data_t *)((leaf)->private_data))->chain_lock))

◆ get_count_lock

#define get_count_lock (   plant)    (&(((plant_priv_data_t *)((plant)->private_data))->reader_count))

◆ get_data_lock

#define get_data_lock (   leaf)
Value:
(is_plant(leaf) ? \
&(((plant_priv_data_t *)((leaf)->private_data))->ldata.data_lock) : \
&(((leaf_priv_data_t *)((leaf)->private_data))->data_lock))

◆ get_data_mutex

#define get_data_mutex (   leaf)
Value:
(is_plant(leaf) ? \
&(((plant_priv_data_t *)((leaf)->private_data))->ldata.data_mutex) : \
&(((leaf_priv_data_t *)((leaf)->private_data))->data_mutex))

◆ get_structure_mutex

#define get_structure_mutex (   plant)    (&(((plant_priv_data_t *)((plant)->private_data))->structure_mutex))

◆ GNU_CONST

#define GNU_CONST

◆ GNU_FLATTEN

#define GNU_FLATTEN

◆ GNU_HOT

#define GNU_HOT

◆ GNU_PURE

#define GNU_PURE

◆ HASHROOT

#define HASHROOT   5381

◆ is_plant

#define is_plant (   leaf)    (leaf->key_hash == WEED_MAGIC_HASH)

◆ IS_VALID_SEED_TYPE

#define IS_VALID_SEED_TYPE (   seed_type)    ((seed_type >=64 || (seed_type >= 1 && seed_type <= 5) ? 1 : 0))

◆ NOT_EXPORTED

#define NOT_EXPORTED

◆ reader_count_add

#define reader_count_add (   obj)
Value:
do { \
if ((obj)) pthread_rwlock_rdlock(get_count_lock((obj)));} while (0)

◆ reader_count_sub

#define reader_count_sub (   obj)
Value:
do { \
if ((obj)) pthread_rwlock_unlock(get_count_lock((obj)));} while (0)

◆ reader_count_wait

#define reader_count_wait (   obj)
Value:
do { \
if ((obj)) pthread_rwlock_wrlock(get_count_lock((obj))); \
pthread_rwlock_unlock(get_count_lock((obj)));} while (0)

◆ return_unlock

#define return_unlock (   obj,
  val 
)
Value:
do { \
typeof(val) myval = (val); data_lock_unlock((obj)); return myval;} while (0)

◆ structure_mutex_lock

#define structure_mutex_lock (   obj)
Value:
do { \
if ((obj)) pthread_mutex_lock(get_structure_mutex((obj)));} while (0)

◆ structure_mutex_trylock

#define structure_mutex_trylock (   obj)    (pthread_mutex_trylock(get_structure_mutex((obj))))

◆ structure_mutex_unlock

#define structure_mutex_unlock (   obj)
Value:
do { \
if ((obj)) pthread_mutex_unlock(get_structure_mutex((obj)));} while (0)

◆ WEED_FLAG_OP_DELETE

#define WEED_FLAG_OP_DELETE   WEED_FLAG_RESERVED_0

◆ WEED_MAGIC_HASH

#define WEED_MAGIC_HASH   0xB82E802F

◆ weed_malloc

#define weed_malloc   malloc

◆ weed_malloc_and_copy

#define weed_malloc_and_copy (   size,
  src 
)    memcpy(malloc(size), src, size)

◆ weed_malloc_sizeof

#define weed_malloc_sizeof (   t)    malloc(sizeof(t))

◆ weed_seed_get_size

#define weed_seed_get_size (   seed_type,
  size 
)
Value:
weed_seed_is_ptr(seed_type) ? WEED_VOIDPTR_SIZE : \
(seed_type == WEED_SEED_BOOLEAN || \
seed_type == WEED_SEED_INT) ? 4 : \
seed_type == WEED_SEED_DOUBLE ? 8 : \
seed_type == WEED_SEED_INT64 ? 8 : \
seed_type == WEED_SEED_STRING ? size : 0)

◆ weed_seed_is_ptr

#define weed_seed_is_ptr (   seed_type)    (seed_type >= 64 ? 1 : 0)

◆ weed_strcmp

#define weed_strcmp (   s1,
  s2 
)    ((!(s1) || !(s2)) ? (s1 != s2) : strcmp(s1, s2))

◆ weed_strdup

#define weed_strdup (   oldstring,
  size 
)
Value:
(!oldstring ? (char *)NULL : \
size < _WEED_PADBYTES_ ? memcpy(leaf->padding, key, size + 1) : \
(char *)(weed_malloc_and_copy(weed_strlen(oldstring) + 1, \
oldstring)))

◆ weed_strlen

#define weed_strlen (   s)    ((s) ? strlen((s)) : 0)

◆ weed_unmalloc_and_copy

#define weed_unmalloc_and_copy (   size,
  ptr 
)    free(ptr)

◆ weed_unmalloc_sizeof

#define weed_unmalloc_sizeof (   t,
  ptr 
)    free(ptr)

Function Documentation

◆ weed_get_abi_version()

EXPORTED int32_t weed_get_abi_version ( void  )

◆ weed_init()

EXPORTED weed_error_t weed_init ( int32_t  abi,
uint64_t  init_flags 
)
WEED_FUNCPTR_SIZE
#define WEED_FUNCPTR_SIZE
Definition: weed.h:75
data_lock_unlock
#define data_lock_unlock(obj)
Definition: weed.c:126
is_plant
#define is_plant(leaf)
Definition: weed.c:107
get_count_lock
#define get_count_lock(plant)
Definition: weed.c:124
weed_malloc_and_copy
#define weed_malloc_and_copy(size, src)
WEED_SEED_STRING
#define WEED_SEED_STRING
Definition: weed.h:229
get_chain_lock
#define get_chain_lock(leaf)
Definition: weed.c:113
WEED_VOIDPTR_SIZE
#define WEED_VOIDPTR_SIZE
Definition: weed.h:74
WEED_SEED_INT
#define WEED_SEED_INT
Definition: weed.h:226
weed_strlen
#define weed_strlen(s)
Definition: weed.c:320
get_structure_mutex
#define get_structure_mutex(plant)
Definition: weed.c:121
get_data_lock
#define get_data_lock(leaf)
Definition: weed.c:109
WEED_SEED_BOOLEAN
#define WEED_SEED_BOOLEAN
Definition: weed.h:228
WEED_SEED_FUNCPTR
#define WEED_SEED_FUNCPTR
Definition: weed.h:233
WEED_SEED_DOUBLE
#define WEED_SEED_DOUBLE
Definition: weed.h:227
WEED_SEED_INT64
#define WEED_SEED_INT64
Definition: weed.h:230