Browse Source

tdb2: Fix to always use 64-bit offset definition

We use off_t in the tdb2 interface (for tdb_attribute_flock); we need
to make sure that all callers agree on the size.

This also causes a problem in the tests: it's not enough to include
config.h first, we need the _FILE_OFFSET_BITS define from private.h.
Otherwise, we can disagree about the definitions of F_SETLK, F_SETLKW
and off_t, causing strange problems.
Rusty Russell 14 years ago
parent
commit
baa17ee2d5

+ 1 - 9
ccan/tdb2/private.h

@@ -18,26 +18,18 @@
    License along with this library; if not, see <http://www.gnu.org/licenses/>.
    License along with this library; if not, see <http://www.gnu.org/licenses/>.
 */
 */
 
 
-#include "config.h"
-#if HAVE_FILE_OFFSET_BITS
-#define _FILE_OFFSET_BITS 64
-#endif
-#include <stdint.h>
-#include <stdbool.h>
+#include <ccan/tdb2/tdb2.h>
 #include <stdlib.h>
 #include <stdlib.h>
 #include <stddef.h>
 #include <stddef.h>
 #include <sys/time.h>
 #include <sys/time.h>
 #include <sys/mman.h>
 #include <sys/mman.h>
 #include <unistd.h>
 #include <unistd.h>
 #include <fcntl.h>
 #include <fcntl.h>
-#include <string.h>
 #include <errno.h>
 #include <errno.h>
 #include <stdio.h>
 #include <stdio.h>
 #include <utime.h>
 #include <utime.h>
 #include <unistd.h>
 #include <unistd.h>
-#include <ccan/tdb2/tdb2.h>
 #include <ccan/likely/likely.h>
 #include <ccan/likely/likely.h>
-#include <ccan/compiler/compiler.h>
 #include <ccan/endian/endian.h>
 #include <ccan/endian/endian.h>
 
 
 #ifndef TEST_IT
 #ifndef TEST_IT

+ 4 - 0
ccan/tdb2/tdb2.h

@@ -30,6 +30,10 @@ extern "C" {
 #endif
 #endif
 
 
 #ifndef _SAMBA_BUILD_
 #ifndef _SAMBA_BUILD_
+#include "config.h"
+#if HAVE_FILE_OFFSET_BITS
+#define _FILE_OFFSET_BITS 64
+#endif
 /* For mode_t */
 /* For mode_t */
 #include <sys/types.h>
 #include <sys/types.h>
 /* For O_* flags. */
 /* For O_* flags. */

+ 1 - 1
ccan/tdb2/test/lock-tracking.c

@@ -1,10 +1,10 @@
 /* We save the locks so we can reaquire them. */
 /* We save the locks so we can reaquire them. */
+#include <ccan/tdb2/private.h>
 #include <unistd.h>
 #include <unistd.h>
 #include <fcntl.h>
 #include <fcntl.h>
 #include <stdarg.h>
 #include <stdarg.h>
 #include <stdlib.h>
 #include <stdlib.h>
 #include <ccan/tap/tap.h>
 #include <ccan/tap/tap.h>
-#include <ccan/tdb2/private.h>
 #include "lock-tracking.h"
 #include "lock-tracking.h"
 
 
 struct lock {
 struct lock {

+ 1 - 1
ccan/tdb2/test/run-56-open-during-transaction.c

@@ -1,4 +1,4 @@
-#include "config.h"
+#include <ccan/tdb2/private.h>
 #include <unistd.h>
 #include <unistd.h>
 #include "lock-tracking.h"
 #include "lock-tracking.h"
 
 

+ 1 - 1
ccan/tdb2/test/run-57-die-during-transaction.c

@@ -1,4 +1,4 @@
-#include "config.h"
+#include <ccan/tdb2/private.h>
 #include <unistd.h>
 #include <unistd.h>
 #include "lock-tracking.h"
 #include "lock-tracking.h"
 #include <ccan/tap/tap.h>
 #include <ccan/tap/tap.h>

+ 1 - 1
ccan/tdb2/test/run-lockall.c

@@ -1,4 +1,4 @@
-#include "config.h"
+#include <ccan/tdb2/private.h>
 #include <unistd.h>
 #include <unistd.h>
 #include "lock-tracking.h"
 #include "lock-tracking.h"