NCBI C++ ToolKit
Macros | Typedefs
Compatibility Macros

A bunch of macros to minimize the amount of platform-specific ifdefs needed throughout the rest of the code. More...

+ Collaboration diagram for Compatibility Macros:

Macros

#define MDB_DEVEL   0
 Features under development. More...
 
#define mdb_func_   "<mdb_unknown>"
 Wrapper around __func__, which is a C99 feature. More...
 
#define MDB_NO_ROOT   (MDB_LAST_ERRCODE + 10)
 
#define MDB_USE_ROBUST   1
 Some platforms define the EOWNERDEAD error code even though they don't support Robust Mutexes. More...
 
#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 Z   "z"
 printf format modifier for size_t More...
 
#define MDB_PIDLOCK   1
 For MDB_LOCK_FORMAT: True if readers take a pid lock in the lockfile. More...
 
#define LOCK_MUTEX0(mutex)   pthread_mutex_lock(mutex)
 Lock the reader or writer mutex. More...
 
#define UNLOCK_MUTEX(mutex)   pthread_mutex_unlock(mutex)
 Unlock the reader or writer mutex. More...
 
#define mdb_mutex_consistent(mutex)   pthread_mutex_consistent(mutex)
 Mark mutex-protected data as repaired, after death of previous owner. More...
 
#define ErrCode()   errno
 Get the error code for the last failed system function. More...
 
#define HANDLE   int
 An abstraction for a file handle. More...
 
#define INVALID_HANDLE_VALUE   (-1)
 A value for an invalid file handle. More...
 
#define GET_PAGESIZE(x)   ((x) = sysconf(_SC_PAGE_SIZE))
 Get the size of a memory page for the system. More...
 
#define MNAME_LEN   (sizeof(pthread_mutex_t))
 

Typedefs

typedef pthread_mutex_t mdb_mutex_t[1]
 Shared mutex/semaphore as the original is stored. More...
 
typedef pthread_mutex_t * mdb_mutexref_t
 Reference to an mdb_mutex_t. More...
 

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

◆ ErrCode

#define ErrCode ( )    errno

Get the error code for the last failed system function.

Definition at line 377 of file mdb.c.

◆ 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.

Definition at line 395 of file mdb.c.

◆ HANDLE

#define HANDLE   int

An abstraction for a file handle.

On POSIX systems file handles are small integers. On Windows they're opaque pointers.

Examples
/home/coremake/doxygen/cxx/include/corelib/interprocess_lock.hpp.

Definition at line 383 of file mdb.c.

◆ 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.

Definition at line 389 of file mdb.c.

◆ 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().

Definition at line 366 of file mdb.c.

◆ MDB_DEVEL

#define MDB_DEVEL   0

Features under development.

Definition at line 230 of file mdb.c.

◆ mdb_func_

#define mdb_func_   "<mdb_unknown>"

Wrapper around __func__, which is a C99 feature.

Definition at line 240 of file mdb.c.

◆ mdb_mutex_consistent

#define mdb_mutex_consistent (   mutex)    pthread_mutex_consistent(mutex)

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

Definition at line 372 of file mdb.c.

◆ MDB_NO_ROOT

#define MDB_NO_ROOT   (MDB_LAST_ERRCODE + 10)

Definition at line 244 of file mdb.c.

◆ MDB_PIDLOCK

#define MDB_PIDLOCK   1

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

Definition at line 337 of file mdb.c.

◆ 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_POSIX_SEM instead of -DMDB_USE_POSIX_MUTEX. (Posix semaphores are not robust.)

Definition at line 273 of file mdb.c.

◆ MNAME_LEN

#define MNAME_LEN   (sizeof(pthread_mutex_t))

Definition at line 401 of file mdb.c.

◆ THREAD_CREATE

#define THREAD_CREATE (   thr,
  start,
  arg 
)    pthread_create(&thr,NULL,start,arg)

Definition at line 332 of file mdb.c.

◆ THREAD_FINISH

#define THREAD_FINISH (   thr)    pthread_join(thr,NULL)

Definition at line 333 of file mdb.c.

◆ THREAD_RET

#define THREAD_RET   void *

Definition at line 331 of file mdb.c.

◆ UNLOCK_MUTEX

#define UNLOCK_MUTEX (   mutex)    pthread_mutex_unlock(mutex)

Unlock the reader or writer mutex.

Definition at line 369 of file mdb.c.

◆ Z

#define Z   "z"

printf format modifier for size_t

Definition at line 334 of file mdb.c.

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.

Definition at line 360 of file mdb.c.

◆ mdb_mutexref_t

typedef pthread_mutex_t* mdb_mutexref_t

Reference to an mdb_mutex_t.

Definition at line 362 of file mdb.c.

Modified on Fri Sep 20 14:58:27 2024 by modify_doxy.py rev. 669887