summaryrefslogtreecommitdiff
path: root/lib/tdb2
diff options
context:
space:
mode:
Diffstat (limited to 'lib/tdb2')
-rw-r--r--lib/tdb2/private.h5
-rw-r--r--lib/tdb2/tdb2.h19
2 files changed, 22 insertions, 2 deletions
diff --git a/lib/tdb2/private.h b/lib/tdb2/private.h
index 91d3ca0933..31790bc335 100644
--- a/lib/tdb2/private.h
+++ b/lib/tdb2/private.h
@@ -18,7 +18,12 @@
License along with this library; if not, see <http://www.gnu.org/licenses/>.
*/
+#include "config.h"
+#ifndef HAVE_CCAN
+#error You need ccan to build tdb2!
+#endif
#include "tdb2.h"
+#include <ccan/compiler/compiler.h>
#include <ccan/likely/likely.h>
#include <ccan/endian/endian.h>
diff --git a/lib/tdb2/tdb2.h b/lib/tdb2/tdb2.h
index 44e7897993..4782117e97 100644
--- a/lib/tdb2/tdb2.h
+++ b/lib/tdb2/tdb2.h
@@ -29,9 +29,8 @@
extern "C" {
#endif
-#include "config.h"
#ifdef HAVE_LIBREPLACE
-#include "replace.h"
+#include <replace.h>
#else
#if HAVE_FILE_OFFSET_BITS
#define _FILE_OFFSET_BITS 64
@@ -49,9 +48,25 @@ extern "C" {
/* For memcmp */
#include <string.h>
#endif
+
+#if HAVE_CCAN
#include <ccan/compiler/compiler.h>
#include <ccan/typesafe_cb/typesafe_cb.h>
#include <ccan/cast/cast.h>
+#else
+#ifndef typesafe_cb_preargs
+/* Failing to have CCAN just mean less typesafe protection, etc. */
+#define typesafe_cb_preargs(rtype, atype, fn, arg, ...) \
+ ((rtype (*)(__VA_ARGS__, atype))(fn))
+#endif
+#ifndef cast_const
+#if defined(__intptr_t_defined) || defined(HAVE_INTPTR_T)
+#define cast_const(type, expr) ((type)((intptr_t)(expr)))
+#else
+#define cast_const(type, expr) ((type *)(expr))
+#endif
+#endif
+#endif /* !HAVE_CCAN */
union tdb_attribute;
struct tdb_context;