Macro cleanup: Parenthesize, simplify, remove a ;

vmware
Hallvard B Furuseth 13 years ago committed by Howard Chu
parent a1b4144b80
commit 3029bb694d
  1. 4
      libraries/libmdb/mdb.c
  2. 2
      libraries/libmdb/mdb.h
  3. 4
      libraries/libmdb/midl.c
  4. 8
      libraries/libmdb/midl.h

@ -178,7 +178,7 @@ typedef struct MDB_page { /* represents a page of storage */
#define IS_BRANCH(p) F_ISSET((p)->mp_flags, P_BRANCH) #define IS_BRANCH(p) F_ISSET((p)->mp_flags, P_BRANCH)
#define IS_OVERFLOW(p) F_ISSET((p)->mp_flags, P_OVERFLOW) #define IS_OVERFLOW(p) F_ISSET((p)->mp_flags, P_OVERFLOW)
#define OVPAGES(size, psize) (PAGEHDRSZ + size + psize - 1) / psize; #define OVPAGES(size, psize) ((PAGEHDRSZ-1 + (size)) / (psize) + 1)
typedef struct MDB_db { typedef struct MDB_db {
uint32_t md_pad; uint32_t md_pad;
@ -252,7 +252,7 @@ struct MDB_cursor {
struct MDB_xcursor *mc_xcursor; struct MDB_xcursor *mc_xcursor;
}; };
#define METADATA(p) ((void *)((char *)p + PAGEHDRSZ)) #define METADATA(p) ((void *)((char *)(p) + PAGEHDRSZ))
typedef struct MDB_node { typedef struct MDB_node {
#define mn_pgno mn_p.np_pgno #define mn_pgno mn_p.np_pgno

@ -35,7 +35,7 @@
#define MDB_VERSION_MAJOR 0 #define MDB_VERSION_MAJOR 0
#define MDB_VERSION_MINOR 8 #define MDB_VERSION_MINOR 8
#define MDB_VERSION_PATCH 0 #define MDB_VERSION_PATCH 0
#define MDB_VERINT(a,b,c) ((a << 24) | (b << 16) | c) #define MDB_VERINT(a,b,c) (((a) << 24) | ((b) << 16) | (c))
#define MDB_VERSION_FULL \ #define MDB_VERSION_FULL \
MDB_VERINT(MDB_VERSION_MAJOR,MDB_VERSION_MINOR,MDB_VERSION_PATCH) MDB_VERINT(MDB_VERSION_MAJOR,MDB_VERSION_MINOR,MDB_VERSION_PATCH)
#define MDB_VERSION_DATE "August 11, 2011" #define MDB_VERSION_DATE "August 11, 2011"

@ -22,10 +22,10 @@
typedef unsigned long pgno_t; typedef unsigned long pgno_t;
/* Sort the IDLs from highest to lowest */ /* Sort the IDLs from highest to lowest */
#define IDL_CMP(x,y) ( x > y ? -1 : ( x < y ? 1 : 0 ) ) #define IDL_CMP(x,y) ( (x) > (y) ? -1 : (x) < (y) )
/* Sort the IDL2s from lowest to highest */ /* Sort the IDL2s from lowest to highest */
#define IDL2_CMP(x,y) ( x < y ? -1 : ( x > y ? 1 : 0 ) ) #define IDL2_CMP(x,y) ( (x) < (y) ? -1 : (x) > (y) )
unsigned mdb_midl_search( ID *ids, ID id ) unsigned mdb_midl_search( ID *ids, ID id )
{ {

@ -18,7 +18,7 @@
#define _MDB_MIDL_H_ #define _MDB_MIDL_H_
#define ID unsigned long #define ID unsigned long
#define NOID ((ID)~0) #define NOID (~(ID)0)
/* IDL sizes - likely should be even bigger /* IDL sizes - likely should be even bigger
* limiting factors: sizeof(ID), thread stack size * limiting factors: sizeof(ID), thread stack size
@ -64,12 +64,12 @@
#define MDB_IDL_ID( bdb, ids, id ) MDB_IDL_RANGE( ids, id, ((bdb)->bi_lastid) ) #define MDB_IDL_ID( bdb, ids, id ) MDB_IDL_RANGE( ids, id, ((bdb)->bi_lastid) )
#define MDB_IDL_ALL( bdb, ids ) MDB_IDL_RANGE( ids, 1, ((bdb)->bi_lastid) ) #define MDB_IDL_ALL( bdb, ids ) MDB_IDL_RANGE( ids, 1, ((bdb)->bi_lastid) )
#define MDB_IDL_FIRST( ids ) ( ids[1] ) #define MDB_IDL_FIRST( ids ) ( (ids)[1] )
#define MDB_IDL_LAST( ids ) ( MDB_IDL_IS_RANGE(ids) \ #define MDB_IDL_LAST( ids ) ( MDB_IDL_IS_RANGE(ids) \
? ids[2] : ids[ids[0]] ) ? (ids)[2] : (ids)[(ids)[0]] )
#define MDB_IDL_N( ids ) ( MDB_IDL_IS_RANGE(ids) \ #define MDB_IDL_N( ids ) ( MDB_IDL_IS_RANGE(ids) \
? (ids[2]-ids[1])+1 : ids[0] ) ? ((ids)[2]-(ids)[1])+1 : (ids)[0] )
int mdb_midl_insert( ID *ids, ID id ); int mdb_midl_insert( ID *ids, ID id );

Loading…
Cancel
Save