1/** 2 * @copyright 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 * @endcopyright 22 * 23 * @file svn_compat.h 24 * @brief Compatibility macros and functions. 25 * @since New in 1.5.0. 26 */ 27 28#ifndef SVN_DEP_COMPAT_H 29#define SVN_DEP_COMPAT_H 30 31#include <apr_version.h> 32 33#ifdef __cplusplus 34extern "C" { 35#endif /* __cplusplus */ 36 37/** 38 * Check at compile time if the APR version is at least a certain 39 * level. 40 * @param major The major version component of the version checked 41 * for (e.g., the "1" of "1.3.0"). 42 * @param minor The minor version component of the version checked 43 * for (e.g., the "3" of "1.3.0"). 44 * @param patch The patch level component of the version checked 45 * for (e.g., the "0" of "1.3.0"). 46 * 47 * @since New in 1.5. 48 */ 49#ifndef APR_VERSION_AT_LEAST /* Introduced in APR 1.3.0 */ 50#define APR_VERSION_AT_LEAST(major,minor,patch) \ 51(((major) < APR_MAJOR_VERSION) \ 52 || ((major) == APR_MAJOR_VERSION && (minor) < APR_MINOR_VERSION) \ 53 || ((major) == APR_MAJOR_VERSION && (minor) == APR_MINOR_VERSION && \ 54 (patch) <= APR_PATCH_VERSION)) 55#endif /* APR_VERSION_AT_LEAST */ 56 57/** 58 * If we don't have a recent enough APR, emulate the behavior of the 59 * apr_array_clear() API. 60 */ 61#if !APR_VERSION_AT_LEAST(1,3,0) 62#define apr_array_clear(arr) (arr)->nelts = 0 63#endif 64 65#if !APR_VERSION_AT_LEAST(1,3,0) 66/* Equivalent to the apr_hash_clear() function in APR >= 1.3.0. Used to 67 * implement the 'apr_hash_clear' macro if the version of APR that 68 * we build against does not provide the apr_hash_clear() function. */ 69void svn_hash__clear(struct apr_hash_t *ht); 70 71/** 72 * If we don't have a recent enough APR, emulate the behavior of the 73 * apr_hash_clear() API. 74 */ 75#define apr_hash_clear(ht) svn_hash__clear(ht) 76#endif 77 78#if !APR_VERSION_AT_LEAST(1,0,0) 79#define APR_UINT64_C(val) UINT64_C(val) 80#define APR_FPROT_OS_DEFAULT APR_OS_DEFAULT 81#endif 82 83#if !APR_VERSION_AT_LEAST(1,3,0) 84#define APR_UINT16_MAX 0xFFFFU 85#define APR_INT16_MAX 0x7FFF 86#define APR_INT16_MIN (-APR_INT16_MAX-1) 87#define APR_UINT32_MAX 0xFFFFFFFFU 88#define APR_INT32_MAX 0x7FFFFFFF 89#define APR_INT32_MIN (-APR_INT32_MAX-1) 90#define APR_UINT64_MAX APR_UINT64_C(0xFFFFFFFFFFFFFFFF) 91#define APR_INT64_MAX APR_INT64_C(0x7FFFFFFFFFFFFFFF) 92#define APR_INT64_MIN (-APR_INT64_MAX-1) 93#define APR_SIZE_MAX (~(apr_size_t)0) 94 95#if APR_SIZEOF_VOIDP == 8 96typedef apr_uint64_t apr_uintptr_t; 97#else 98typedef apr_uint32_t apr_uintptr_t; 99#endif 100#endif /* !APR_VERSION_AT_LEAST(1,3,0) */ 101 102/** 103 * Work around a platform dependency issue. apr_thread_rwlock_trywrlock() 104 * will make APR_STATUS_IS_EBUSY() return TRUE if the lock could not be 105 * acquired under Unix. Under Windows, this will not work. So, provide 106 * a more portable substitute. 107 * 108 * @since New in 1.8. 109 */ 110#ifdef WIN32 111#define SVN_LOCK_IS_BUSY(x) \ 112 (APR_STATUS_IS_EBUSY(x) || (x) == APR_FROM_OS_ERROR(WAIT_TIMEOUT)) 113#else 114#define SVN_LOCK_IS_BUSY(x) APR_STATUS_IS_EBUSY(x) 115#endif 116 117/** 118 * Check at compile time if the Serf version is at least a certain 119 * level. 120 * @param major The major version component of the version checked 121 * for (e.g., the "1" of "1.3.0"). 122 * @param minor The minor version component of the version checked 123 * for (e.g., the "3" of "1.3.0"). 124 * @param patch The patch level component of the version checked 125 * for (e.g., the "0" of "1.3.0"). 126 * 127 * @since New in 1.5. 128 */ 129#ifndef SERF_VERSION_AT_LEAST /* Introduced in Serf 0.1.1 */ 130#define SERF_VERSION_AT_LEAST(major,minor,patch) \ 131(((major) < SERF_MAJOR_VERSION) \ 132 || ((major) == SERF_MAJOR_VERSION && (minor) < SERF_MINOR_VERSION) \ 133 || ((major) == SERF_MAJOR_VERSION && (minor) == SERF_MINOR_VERSION && \ 134 (patch) <= SERF_PATCH_VERSION)) 135#endif /* SERF_VERSION_AT_LEAST */ 136 137/** 138 * By default, if libsvn is built against one version of SQLite 139 * and then run using an older version, svn will error out: 140 * 141 * svn: Couldn't perform atomic initialization 142 * svn: SQLite compiled for 3.7.4, but running with 3.7.3 143 * 144 * That can be annoying when building on a modern system in order 145 * to deploy on a less modern one. So these constants allow one 146 * to specify how old the system being deployed on might be. 147 * For example, 148 * 149 * EXTRA_CFLAGS += -DSVN_SQLITE_MIN_VERSION_NUMBER=3007003 150 * EXTRA_CFLAGS += '-DSVN_SQLITE_MIN_VERSION="3.7.3"' 151 * 152 * turns on code that works around infelicities in older versions 153 * as far back as 3.7.3 and relaxes the check at initialization time 154 * to permit them. 155 * 156 * @since New in 1.8. 157 */ 158#ifndef SVN_SQLITE_MIN_VERSION_NUMBER 159#define SVN_SQLITE_MIN_VERSION_NUMBER SQLITE_VERSION_NUMBER 160#define SVN_SQLITE_MIN_VERSION SQLITE_VERSION 161#endif /* SVN_SQLITE_MIN_VERSION_NUMBER */ 162 163/** 164 * Check at compile time if the SQLite version is at least a certain 165 * level. 166 * @param major The major version component of the version checked 167 * for (e.g., the "1" of "1.3.0"). 168 * @param minor The minor version component of the version checked 169 * for (e.g., the "3" of "1.3.0"). 170 * @param patch The patch level component of the version checked 171 * for (e.g., the "0" of "1.3.0"). 172 * 173 * @since New in 1.6. 174 */ 175#ifndef SQLITE_VERSION_AT_LEAST 176#define SQLITE_VERSION_AT_LEAST(major,minor,patch) \ 177((major*1000000 + minor*1000 + patch) <= SVN_SQLITE_MIN_VERSION_NUMBER) 178#endif /* SQLITE_VERSION_AT_LEAST */ 179 180#ifdef __cplusplus 181} 182#endif /* __cplusplus */ 183 184#endif /* SVN_DEP_COMPAT_H */ 185