1/* svn_bdb_compat.h --- Compatibility wrapper for different BDB versions. 2 * 3 * ==================================================================== 4 * Licensed to the Apache Software Foundation (ASF) under one 5 * or more contributor license agreements. See the NOTICE file 6 * distributed with this work for additional information 7 * regarding copyright ownership. The ASF licenses this file 8 * to you under the Apache License, Version 2.0 (the 9 * "License"); you may not use this file except in compliance 10 * with the License. You may obtain a copy of the License at 11 * 12 * http://www.apache.org/licenses/LICENSE-2.0 13 * 14 * Unless required by applicable law or agreed to in writing, 15 * software distributed under the License is distributed on an 16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 * KIND, either express or implied. See the License for the 18 * specific language governing permissions and limitations 19 * under the License. 20 * ==================================================================== 21 */ 22 23#ifndef SVN_LIBSVN_FS_BDB_COMPAT_H 24#define SVN_LIBSVN_FS_BDB_COMPAT_H 25 26#define SVN_WANT_BDB 27#include "svn_private_config.h" 28 29#ifdef __cplusplus 30extern "C" { 31#endif /* __cplusplus */ 32 33 34/* Symbols and constants */ 35 36/* BDB 4.1 introduced the DB_AUTO_COMMIT flag. Older versions can just 37 use 0 instead. */ 38#ifdef DB_AUTO_COMMIT 39#define SVN_BDB_AUTO_COMMIT (DB_AUTO_COMMIT) 40#else 41#define SVN_BDB_AUTO_COMMIT (0) 42#endif 43 44/* DB_INCOMPLETE is obsolete in BDB 4.1. */ 45#ifdef DB_INCOMPLETE 46#define SVN_BDB_HAS_DB_INCOMPLETE 1 47#else 48#define SVN_BDB_HAS_DB_INCOMPLETE 0 49#endif 50 51/* In BDB 4.3, "buffer too small" errors come back with 52 DB_BUFFER_SMALL (instead of ENOMEM, which is now fatal). */ 53#ifdef DB_BUFFER_SMALL 54#define SVN_BDB_DB_BUFFER_SMALL DB_BUFFER_SMALL 55#else 56#define SVN_BDB_DB_BUFFER_SMALL ENOMEM 57#endif 58 59/* BDB 4.4 introdiced the DB_REGISTER flag for DBEnv::open that allows 60 for automatic recovery of the databases after a program crash. */ 61#ifdef DB_REGISTER 62#define SVN_BDB_AUTO_RECOVER (DB_REGISTER | DB_RECOVER) 63#else 64#define SVN_BDB_AUTO_RECOVER (0) 65#endif 66 67 68/* Explicit BDB version check. */ 69#define SVN_BDB_VERSION_AT_LEAST(major,minor) \ 70 (DB_VERSION_MAJOR > (major) \ 71 || (DB_VERSION_MAJOR == (major) && DB_VERSION_MINOR >= (minor))) 72 73 74/* Parameter lists */ 75 76/* In BDB 4.1, DB->open takes a transaction parameter. We'll ignore it 77 when building with 4.0. */ 78#if SVN_BDB_VERSION_AT_LEAST(4,1) 79#define SVN_BDB_OPEN_PARAMS(env,txn) (env), (txn) 80#else 81#define SVN_BDB_OPEN_PARAMS(env,txn) (env) 82#endif 83 84/* In BDB 4.3, the error gatherer function grew a new DBENV parameter, 85 and the MSG parameter's type changed. */ 86#if SVN_BDB_VERSION_AT_LEAST(4,3) 87/* Prevents most compilers from whining about unused parameters. */ 88#define SVN_BDB_ERROR_GATHERER_IGNORE(varname) ((void)(varname)) 89#else 90#define bdb_error_gatherer(param1, param2, param3) \ 91 bdb_error_gatherer(param2, char *msg) 92#define SVN_BDB_ERROR_GATHERER_IGNORE(varname) ((void)0) 93#endif 94 95/* In BDB 4.3 and later, the file names in DB_ENV->open and DB->open 96 are assumed to be encoded in UTF-8 on Windows. */ 97#if defined(WIN32) && SVN_BDB_VERSION_AT_LEAST(4,3) 98#define SVN_BDB_PATH_UTF8 (1) 99#else 100#define SVN_BDB_PATH_UTF8 (0) 101#endif 102 103/* In BDB 4.6, the cursor routines were renamed, and the old names 104 deprecated. */ 105#if SVN_BDB_VERSION_AT_LEAST(4,6) 106#define svn_bdb_dbc_close(c) ((c)->close(c)) 107#define svn_bdb_dbc_count(c,r,f) ((c)->count(c,r,f)) 108#define svn_bdb_dbc_del(c,f) ((c)->del(c,f)) 109#define svn_bdb_dbc_dup(c,p,f) ((c)->dup(c,p,f)) 110#define svn_bdb_dbc_get(c,k,d,f) ((c)->get(c,k,d,f)) 111#define svn_bdb_dbc_pget(c,k,p,d,f) ((c)->pget(c,k,p,d,f)) 112#define svn_bdb_dbc_put(c,k,d,f) ((c)->put(c,k,d,f)) 113#else 114#define svn_bdb_dbc_close(c) ((c)->c_close(c)) 115#define svn_bdb_dbc_count(c,r,f) ((c)->c_count(c,r,f)) 116#define svn_bdb_dbc_del(c,f) ((c)->c_del(c,f)) 117#define svn_bdb_dbc_dup(c,p,f) ((c)->c_dup(c,p,f)) 118#define svn_bdb_dbc_get(c,k,d,f) ((c)->c_get(c,k,d,f)) 119#define svn_bdb_dbc_pget(c,k,p,d,f) ((c)->c_pget(c,k,p,d,f)) 120#define svn_bdb_dbc_put(c,k,d,f) ((c)->c_put(c,k,d,f)) 121#endif 122 123/* Before calling db_create, we must check that the version of the BDB 124 libraries we're linking with is the same as the one we compiled 125 against, because the DB->open call is not binary compatible between 126 BDB 4.0 and 4.1. This function returns DB_OLD_VERSION if the 127 compile-time and run-time versions of BDB don't match. */ 128int svn_fs_bdb__check_version(void); 129 130 131#ifdef __cplusplus 132} 133#endif /* __cplusplus */ 134 135#endif /* SVN_LIBSVN_FS_BDB_COMPAT_H */ 136