summaryrefslogtreecommitdiff
path: root/lib/tdb2
diff options
context:
space:
mode:
authorAmitay Isaacs <amitay@gmail.com>2012-02-21 15:29:17 +1030
committerRusty Russell <rusty@rustcorp.com.au>2012-02-21 15:29:17 +1030
commita63d731ae05af78bdc33db58880387169429753e (patch)
treed9a982ea780c7bd87edf9624d19f22a483e3d1df /lib/tdb2
parente6901fa35069e234044c94b87ac9df4064b31d1c (diff)
downloadsamba-a63d731ae05af78bdc33db58880387169429753e.tar.gz
samba-a63d731ae05af78bdc33db58880387169429753e.tar.bz2
samba-a63d731ae05af78bdc33db58880387169429753e.zip
lib/tdb2: Do not include config.h in (to-be) public library, use replace.
Like tdb1, it's the caller's responsibility to set up various config options (eg. by #include "config.h") before including the public header. We use HAVE_CCAN for including the (private) CCAN headers, otherwise dummy macros are used. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
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;