LMDB
Macros | Typedefs
Compatibility Macros

A bunch of macros to minimize the amount of platform-specific ifdefs needed throughout the rest of the code. When the features this library needs are similar enough to POSIX to be hidden in a one-or-two line replacement, this macro approach is used. More...

Macros

#define MDB_DEVEL   0
 
#define mdb_func_   "<mdb_unknown>"
 
#define MDB_NO_ROOT   (MDB_LAST_ERRCODE + 10)
 
#define MDB_USE_ROBUST   1
 
#define THREAD_RET   void *
 
#define THREAD_CREATE(thr, start, arg)   pthread_create(&thr,NULL,start,arg)
 
#define THREAD_FINISH(thr)   pthread_join(thr,NULL)
 
#define MDB_PIDLOCK   1
 
#define LOCK_MUTEX0(mutex)   pthread_mutex_lock(mutex)
 
#define UNLOCK_MUTEX(mutex)   pthread_mutex_unlock(mutex)
 
#define mdb_mutex_consistent(mutex)   pthread_mutex_consistent(mutex)
 
#define ErrCode()   errno
 
#define HANDLE   int
 
#define INVALID_HANDLE_VALUE   (-1)
 
#define GET_PAGESIZE(x)   ((x) = sysconf(_SC_PAGE_SIZE))
 
#define Z   MDB_FMT_Z
 
#define Yu   MDB_PRIy(u)
 
#define Yd   MDB_PRIy(d)
 
#define MNAME_LEN   (sizeof(pthread_mutex_t))
 

Typedefs

typedef pthread_mutex_t mdb_mutex_t[1]
 
typedef pthread_mutex_t * mdb_mutexref_t
 

Detailed Description

A bunch of macros to minimize the amount of platform-specific ifdefs needed throughout the rest of the code. When the features this library needs are similar enough to POSIX to be hidden in a one-or-two line replacement, this macro approach is used.

Macro Definition Documentation

 ◆ MDB_DEVEL

#define MDB_DEVEL   0

Features under development

 ◆ mdb_func_

#define mdb_func_   "<mdb_unknown>"

Wrapper around func, which is a C99 feature

 ◆ MDB_USE_ROBUST

#define MDB_USE_ROBUST   1

Some platforms define the EOWNERDEAD error code even though they don't support Robust Mutexes. Compile with -DMDB_USE_ROBUST=0, or use some other mechanism like -DMDB_USE_SYSV_SEM instead of -DMDB_USE_POSIX_MUTEX. (SysV semaphores are also Robust, but some systems don't support them either.)

 ◆ MDB_PIDLOCK

#define MDB_PIDLOCK   1

For MDB_LOCK_FORMAT: True if readers take a pid lock in the lockfile

 ◆ LOCK_MUTEX0

#define LOCK_MUTEX0 (   mutex)    pthread_mutex_lock(mutex)

Lock the reader or writer mutex. Returns 0 or a code to give mdb_mutex_failed(), as in LOCK_MUTEX().

 ◆ UNLOCK_MUTEX

#define UNLOCK_MUTEX (   mutex)    pthread_mutex_unlock(mutex)

Unlock the reader or writer mutex.

 ◆ mdb_mutex_consistent

#define mdb_mutex_consistent (   mutex)    pthread_mutex_consistent(mutex)

Mark mutex-protected data as repaired, after death of previous owner.

 ◆ ErrCode

#define ErrCode ( )    errno

Get the error code for the last failed system function.

 ◆ HANDLE

#define HANDLE   int

An abstraction for a file handle. On POSIX systems file handles are small integers. On Windows they're opaque pointers.

 ◆ INVALID_HANDLE_VALUE

#define INVALID_HANDLE_VALUE   (-1)

A value for an invalid file handle. Mainly used to initialize file variables and signify that they are unused.

 ◆ GET_PAGESIZE

#define GET_PAGESIZE (   x)    ((x) = sysconf(_SC_PAGE_SIZE))

Get the size of a memory page for the system. This is the basic size that the platform's memory manager uses, and is fundamental to the use of memory-mapped files.

 ◆ Z

#define Z   MDB_FMT_Z

printf/scanf format modifier for size_t

 ◆ Yu

#define Yu   MDB_PRIy(u)

printf format for #mdb_size_t

 ◆ Yd

#define Yd   MDB_PRIy(d)

printf format for 'signed #mdb_size_t'

Typedef Documentation

 ◆ mdb_mutex_t

typedef pthread_mutex_t mdb_mutex_t[1]

Shared mutex/semaphore as the original is stored.

Not for copies. Instead it can be assigned to an mdb_mutexref_t. When mdb_mutexref_t is a pointer and mdb_mutex_t is not, then it is array[size 1] so it can be assigned to the pointer.

 ◆ mdb_mutexref_t

typedef pthread_mutex_t* mdb_mutexref_t

Reference to an mdb_mutex_t