diff options
author | Philip Guenther <guenther@cvs.openbsd.org> | 2015-10-17 21:48:43 +0000 |
---|---|---|
committer | Philip Guenther <guenther@cvs.openbsd.org> | 2015-10-17 21:48:43 +0000 |
commit | 8cdc1957246698c671658c78e581fff5aaa4e0d4 (patch) | |
tree | ed291c573d55acdb5fb4cb89e13969f18ad3191c /lib/libc/hidden/db.h | |
parent | 4672f1314974ba3581d74bdc4256c558c78c6103 (diff) |
Move the last of the __DBINTERFACE_PRIVATE bits from <db.h> to libc's wrapper
and eliminate the now superfluous -D option
ok kettenis@ millert@
Diffstat (limited to 'lib/libc/hidden/db.h')
-rw-r--r-- | lib/libc/hidden/db.h | 50 |
1 files changed, 49 insertions, 1 deletions
diff --git a/lib/libc/hidden/db.h b/lib/libc/hidden/db.h index a8bc9ca9469..57eb5558010 100644 --- a/lib/libc/hidden/db.h +++ b/lib/libc/hidden/db.h @@ -1,4 +1,4 @@ -/* $OpenBSD: db.h,v 1.2 2015/09/10 18:13:46 guenther Exp $ */ +/* $OpenBSD: db.h,v 1.3 2015/10/17 21:48:42 guenther Exp $ */ /* * Copyright (c) 2015 Philip Guenther <guenther@openbsd.org> * @@ -20,6 +20,54 @@ #include_next <db.h> +/* + * Little endian <==> big endian 32-bit swap macros. + * M_32_SWAP swap a memory location + * P_32_SWAP swap a referenced memory location + * P_32_COPY swap from one location to another + */ +#define M_32_SWAP(a) { \ + u_int32_t _tmp = a; \ + ((char *)&a)[0] = ((char *)&_tmp)[3]; \ + ((char *)&a)[1] = ((char *)&_tmp)[2]; \ + ((char *)&a)[2] = ((char *)&_tmp)[1]; \ + ((char *)&a)[3] = ((char *)&_tmp)[0]; \ +} +#define P_32_SWAP(a) { \ + u_int32_t _tmp = *(u_int32_t *)a; \ + ((char *)a)[0] = ((char *)&_tmp)[3]; \ + ((char *)a)[1] = ((char *)&_tmp)[2]; \ + ((char *)a)[2] = ((char *)&_tmp)[1]; \ + ((char *)a)[3] = ((char *)&_tmp)[0]; \ +} +#define P_32_COPY(a, b) { \ + ((char *)&(b))[0] = ((char *)&(a))[3]; \ + ((char *)&(b))[1] = ((char *)&(a))[2]; \ + ((char *)&(b))[2] = ((char *)&(a))[1]; \ + ((char *)&(b))[3] = ((char *)&(a))[0]; \ +} + +/* + * Little endian <==> big endian 16-bit swap macros. + * M_16_SWAP swap a memory location + * P_16_SWAP swap a referenced memory location + * P_16_COPY swap from one location to another + */ +#define M_16_SWAP(a) { \ + u_int16_t _tmp = a; \ + ((char *)&a)[0] = ((char *)&_tmp)[1]; \ + ((char *)&a)[1] = ((char *)&_tmp)[0]; \ +} +#define P_16_SWAP(a) { \ + u_int16_t _tmp = *(u_int16_t *)a; \ + ((char *)a)[0] = ((char *)&_tmp)[1]; \ + ((char *)a)[1] = ((char *)&_tmp)[0]; \ +} +#define P_16_COPY(a, b) { \ + ((char *)&(b))[0] = ((char *)&(a))[1]; \ + ((char *)&(b))[1] = ((char *)&(a))[0]; \ +} + __BEGIN_HIDDEN_DECLS DB *__bt_open(const char *, int, int, const BTREEINFO *, int); DB *__hash_open(const char *, int, int, const HASHINFO *, int); |