_DBSWAP() macro is identical between lmdb.c and db3.c, consolidate to dbi.h

This commit is contained in:
Panu Matilainen 2017-08-17 13:08:37 +03:00
parent 18a2fc0744
commit 0cbcf9b9c3
3 changed files with 13 additions and 26 deletions

View File

@ -919,19 +919,6 @@ static int db3_dbiOpen(rpmdb rdb, rpmDbiTagVal rpmtag, dbiIndex * dbip, int flag
return rc;
}
union _dbswap {
unsigned int ui;
unsigned char uc[4];
};
#define _DBSWAP(_a) \
\
{ unsigned char _b, *_c = (_a).uc; \
_b = _c[3]; _c[3] = _c[0]; _c[0] = _b; \
_b = _c[2]; _c[2] = _c[1]; _c[1] = _b; \
\
}
/**
* Convert retrieved data to index set.
* @param dbi index database handle

View File

@ -110,6 +110,19 @@ struct dbiIndex_s {
void * dbi_db; /*!< Backend private handle */
};
union _dbswap {
unsigned int ui;
unsigned char uc[4];
};
#define _DBSWAP(_a) \
\
{ unsigned char _b, *_c = (_a).uc; \
_b = _c[3]; _c[3] = _c[0]; _c[0] = _b; \
_b = _c[2]; _c[2] = _c[1]; _c[1] = _b; \
\
}
#ifdef __cplusplus
extern "C" {
#endif

View File

@ -477,19 +477,6 @@ exit:
return rc;
}
union _dbswap {
unsigned int ui;
unsigned char uc[4];
};
#define _DBSWAP(_a) \
\
{ unsigned char _b, *_c = (_a).uc; \
_b = _c[3]; _c[3] = _c[0]; _c[0] = _b; \
_b = _c[2]; _c[2] = _c[1]; _c[1] = _b; \
\
}
/* The LMDB btree implementation needs BIGENDIAN primary keys. */
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
static int _dbibyteswapped = 1;