Index: subversion/include/private/svn_compat.h =================================================================== --- subversion/include/private/svn_compat.h (revision 0) +++ subversion/include/private/svn_compat.h (revision 0) @@ -0,0 +1,58 @@ +/** + * @copyright + * ==================================================================== + * Copyright (c) 2006 CollabNet. All rights reserved. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://subversion.tigris.org/license-1.html. + * If newer versions of this license are posted there, you may use a + * newer version instead, at your option. + * + * This software consists of voluntary contributions made by many + * individuals. For exact contribution history, see the revision + * history and logs, available at http://subversion.tigris.org/. + * ==================================================================== + * @endcopyright + * + * @file svn_compat.h + * @brief Compatibility macros and functions. + * @since New in 1.5.0. + */ + +#ifndef SVN_COMPAT_H +#define SVN_COMPAT_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** + * Check at compile time if the APR version is at least a certain + * level. + * @param major The major version component of the version checked + * for (e.g., the "1" of "1.3.0"). + * @param minor The minor version component of the version checked + * for (e.g., the "3" of "1.3.0"). + * @param patch The patch level component of the version checked + * for (e.g., the "0" of "1.3.0"). + * + * @since New in 1.5.0 + */ +#ifdef APR_VERSION_AT_LEAST /* Introduced in APR 1.3.0 */ +#define SVN_APR_VERSION_AT_LEAST APR_VERSION_AT_LEAST +#else +#define SVN_APR_VERSION_AT_LEAST(major,minor,patch) \ +(((major) < APR_MAJOR_VERSION) \ + || ((major) == APR_MAJOR_VERSION && (minor) < APR_MINOR_VERSION) \ + || ((major) == APR_MAJOR_VERSION && (minor) == APR_MINOR_VERSION && \ + (patch) <= APR_PATCH_VERSION)) +#endif /* APR_VERSION_AT_LEAST */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* SVN_COMPAT_H */ Index: subversion/include/private/svn_atomic.h =================================================================== --- subversion/include/private/svn_atomic.h (revision 21572) +++ subversion/include/private/svn_atomic.h (working copy) @@ -26,6 +26,7 @@ #include #include "svn_error.h" +#include "private/svn_compat.h" #ifdef __cplusplus extern "C" { @@ -40,39 +41,39 @@ */ /** The type used by all the other atomic operations. */ -#if APR_MAJOR_VERSION > 0 +#if SVN_APR_VERSION_AT_LEAST(1, 0, 0) #define svn_atomic_t apr_uint32_t #else #define svn_atomic_t apr_atomic_t -#endif /* APR_MAJOR_VERSION */ +#endif /** Atomically read an #svn_atomic_t from memory. */ -#if APR_MAJOR_VERSION > 0 +#if SVN_APR_VERSION_AT_LEAST(1, 0, 0) #define svn_atomic_read(mem) apr_atomic_read32((mem)) #else #define svn_atomic_read(mem) apr_atomic_read((mem)) -#endif /* APR_MAJOR_VERSION */ +#endif /** Atomically set an #svn_atomic_t in memory. */ -#if APR_MAJOR_VERSION > 0 +#if SVN_APR_VERSION_AT_LEAST(1, 0, 0) #define svn_atomic_set(mem, val) apr_atomic_set32((mem), (val)) #else #define svn_atomic_set(mem, val) apr_atomic_set((mem), (val)) -#endif /* APR_MAJOR_VERSION */ +#endif /** Atomically increment an #svn_atomic_t. */ -#if APR_MAJOR_VERSION > 0 +#if SVN_APR_VERSION_AT_LEAST(1, 0, 0) #define svn_atomic_inc(mem) apr_atomic_inc32(mem) #else #define svn_atomic_inc(mem) apr_atomic_inc(mem) -#endif /* APR_MAJOR_VERSION */ +#endif /** Atomically decrement an #svn_atomic_t. */ -#if APR_MAJOR_VERSION > 0 +#if SVN_APR_VERSION_AT_LEAST(1, 0, 0) #define svn_atomic_dec(mem) apr_atomic_dec32(mem) #else #define svn_atomic_dec(mem) apr_atomic_dec(mem) -#endif /* APR_MAJOR_VERSION */ +#endif /** * Atomic compare-and-swap. @@ -85,13 +86,13 @@ * that on some platforms, the CAS function is implemented in a * way that is incompatible with the other atomic operations. */ -#if APR_MAJOR_VERSION > 0 +#if SVN_APR_VERSION_AT_LEAST(1, 0, 0) #define svn_atomic_cas(mem, with, cmp) \ apr_atomic_cas32((mem), (with), (cmp)) #else #define svn_atomic_cas(mem, with, cmp) \ apr_atomic_cas((mem), (with), (cmp)) -#endif /* APR_MAJOR_VERSION */ +#endif /** @} */ /** Index: subversion/libsvn_subr/hash.c =================================================================== --- subversion/libsvn_subr/hash.c (revision 21572) +++ subversion/libsvn_subr/hash.c (working copy) @@ -32,6 +32,7 @@ #include "svn_sorts.h" #include "svn_io.h" #include "svn_pools.h" +#include "private/svn_compat.h" @@ -437,9 +438,7 @@ svn_error_t * svn_hash_clear(apr_hash_t *hash) { -/* The APR_VERSION_AT_LEAST() macro is new in APR 1.3.0, which also - happens to be the minimum version we require. */ -#ifdef APR_VERSION_AT_LEAST /* 1.3.0 */ +#if SVN_APR_VERSION_AT_LEAST(1, 3, 0) apr_hash_clear(hash); #else apr_hash_index_t *hi;