From: Amitay Isaacs Date: Tue, 21 Feb 2012 04:59:17 +0000 (+1030) Subject: lib/tdb2: Do not include config.h in (to-be) public library, use replace. X-Git-Url: http://git.samba.org/?a=commitdiff_plain;h=a63d731ae05af78bdc33db58880387169429753e;p=metze%2Fsamba%2Fwip.git 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 --- diff --git a/lib/tdb2/private.h b/lib/tdb2/private.h index 91d3ca09333d..31790bc3351c 100644 --- a/lib/tdb2/private.h +++ b/lib/tdb2/private.h @@ -18,7 +18,12 @@ License along with this library; if not, see . */ +#include "config.h" +#ifndef HAVE_CCAN +#error You need ccan to build tdb2! +#endif #include "tdb2.h" +#include #include #include diff --git a/lib/tdb2/tdb2.h b/lib/tdb2/tdb2.h index 44e7897993fa..4782117e9751 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 #else #if HAVE_FILE_OFFSET_BITS #define _FILE_OFFSET_BITS 64 @@ -49,9 +48,25 @@ extern "C" { /* For memcmp */ #include #endif + +#if HAVE_CCAN #include #include #include +#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;