]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/subversion/subversion/include/private/svn_dep_compat.h
Update svn-1.9.7 to 1.10.0.
[FreeBSD/FreeBSD.git] / contrib / subversion / subversion / include / private / svn_dep_compat.h
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_dep_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
34 extern "C" {
35 #endif /* __cplusplus */
36
37 /**
38  * We assume that 'int' and 'unsigned' are at least 32 bits wide.
39  * This also implies that long (rev numbers) is 32 bits or wider.
40  *
41  * @since New in 1.9.
42  */
43 #if    defined(APR_HAVE_LIMITS_H) \
44     && !defined(SVN_ALLOW_SHORT_INTS) \
45     && (INT_MAX < 0x7FFFFFFFl)
46 #error int is shorter than 32 bits and may break Subversion. Define SVN_ALLOW_SHORT_INTS to skip this check.
47 #endif
48
49 /**
50  * We assume that 'char' is 8 bits wide.  The critical interfaces are
51  * our repository formats and RA encodings.  E.g. a 32 bit wide char may
52  * mess up UTF8 parsing, how we interpret size values etc.
53  *
54  * @since New in 1.9.
55  */
56 #if    defined(CHAR_BIT) \
57     && !defined(SVN_ALLOW_NON_8_BIT_CHARS) \
58     && (CHAR_BIT != 8)
59 #error char is not 8 bits and may break Subversion. Define SVN_ALLOW_NON_8_BIT_CHARS to skip this check.
60 #endif
61
62 /**
63  * Work around a platform dependency issue. apr_thread_rwlock_trywrlock()
64  * will make APR_STATUS_IS_EBUSY() return TRUE if the lock could not be
65  * acquired under Unix. Under Windows, this will not work. So, provide
66  * a more portable substitute.
67  *
68  * @since New in 1.8.
69  */
70 #ifdef WIN32
71 #define SVN_LOCK_IS_BUSY(x) \
72     (APR_STATUS_IS_EBUSY(x) || (x) == APR_FROM_OS_ERROR(WAIT_TIMEOUT))
73 #else
74 #define SVN_LOCK_IS_BUSY(x) APR_STATUS_IS_EBUSY(x)
75 #endif
76
77 /**
78  * Indicate whether we are running on a POSIX platform.  This has
79  * implications on the way e.g. fsync() works.
80  *
81  * For details on this check, see
82  * http://nadeausoftware.com/articles/2012/01/c_c_tip_how_use_compiler_predefined_macros_detect_operating_system#POSIX
83  *
84  * @since New in 1.10.
85  */
86 #ifndef SVN_ON_POSIX
87 #if    !defined(_WIN32) \
88     && (   defined(__unix__) \
89         || defined(__unix) \
90         || (defined(__APPLE__) && defined(__MACH__)))  /* UNIX-style OS? */
91 #  include <unistd.h>
92 #  if defined(_POSIX_VERSION)
93 #    define SVN_ON_POSIX
94 #  endif
95 #endif
96 #endif
97
98 /**
99  * APR keeps a few interesting defines hidden away in its private
100  * headers apr_arch_file_io.h, so we redefined them here.
101  *
102  * @since New in 1.9
103  */
104 #ifndef APR_FREADONLY
105 #define APR_FREADONLY 0x10000000
106 #endif
107 #ifndef APR_OPENINFO
108 #define APR_OPENINFO  0x00100000
109 #endif
110
111 #if !APR_VERSION_AT_LEAST(1,4,0)
112 #ifndef apr_time_from_msec
113 #define apr_time_from_msec(msec) ((apr_time_t)(msec) * 1000)
114 #endif
115 #endif
116
117 /**
118  * APR 1 has volatile qualifier bugs in some atomic prototypes that
119  * are fixed in APR 2:
120  *   https://issues.apache.org/bugzilla/show_bug.cgi?id=50731
121  * Subversion code should put the volatile qualifier in the correct
122  * place when declaring variables which means that casting at the call
123  * site is necessary when using APR 1.  No casts should be used with
124  * APR 2 as this allows the compiler to check that the variable has
125  * the correct volatile qualifier.
126  */
127 #if APR_VERSION_AT_LEAST(2,0,0)
128 #define svn_atomic_casptr(mem, with, cmp) \
129   apr_atomic_casptr((mem), (with), (cmp))
130 #define svn_atomic_xchgptr(mem, val) \
131   apr_atomic_xchgptr((mem), (val))
132 #else
133 #define svn_atomic_casptr(mem, with, cmp) \
134   apr_atomic_casptr((void volatile **)(mem), (with), (cmp))
135 #define svn_atomic_xchgptr(mem, val) \
136   apr_atomic_xchgptr((void volatile **)(mem), (val))
137 #endif
138
139 /**
140  * Check at compile time if the Serf version is at least a certain
141  * level.
142  * @param major The major version component of the version checked
143  * for (e.g., the "1" of "1.3.0").
144  * @param minor The minor version component of the version checked
145  * for (e.g., the "3" of "1.3.0").
146  * @param patch The patch level component of the version checked
147  * for (e.g., the "0" of "1.3.0").
148  *
149  * @since New in 1.5.
150  */
151 #ifndef SERF_VERSION_AT_LEAST /* Introduced in Serf 0.1.1 */
152 #define SERF_VERSION_AT_LEAST(major,minor,patch)                       \
153 (((major) < SERF_MAJOR_VERSION)                                        \
154  || ((major) == SERF_MAJOR_VERSION && (minor) < SERF_MINOR_VERSION)    \
155  || ((major) == SERF_MAJOR_VERSION && (minor) == SERF_MINOR_VERSION && \
156      (patch) <= SERF_PATCH_VERSION))
157 #endif /* SERF_VERSION_AT_LEAST */
158
159 /**
160  * By default, if libsvn is built against one version of SQLite
161  * and then run using an older version, svn will error out:
162  *
163  *     svn: Couldn't perform atomic initialization
164  *     svn: SQLite compiled for 3.7.4, but running with 3.7.3
165  *
166  * That can be annoying when building on a modern system in order
167  * to deploy on a less modern one.  So these constants allow one
168  * to specify how old the system being deployed on might be.
169  * For example,
170  *
171  *     EXTRA_CFLAGS += -DSVN_SQLITE_MIN_VERSION_NUMBER=3007003
172  *     EXTRA_CFLAGS += '-DSVN_SQLITE_MIN_VERSION="3.7.3"'
173  *
174  * turns on code that works around infelicities in older versions
175  * as far back as 3.7.3 and relaxes the check at initialization time
176  * to permit them.
177  *
178  * @since New in 1.8.
179  */
180 #ifndef SVN_SQLITE_MIN_VERSION_NUMBER
181 #define SVN_SQLITE_MIN_VERSION_NUMBER SQLITE_VERSION_NUMBER
182 #define SVN_SQLITE_MIN_VERSION SQLITE_VERSION
183 #endif /* SVN_SQLITE_MIN_VERSION_NUMBER */
184
185 /**
186  * Check at compile time if the SQLite version is at least a certain
187  * level.
188  * @param major The major version component of the version checked
189  * for (e.g., the "1" of "1.3.0").
190  * @param minor The minor version component of the version checked
191  * for (e.g., the "3" of "1.3.0").
192  * @param patch The patch level component of the version checked
193  * for (e.g., the "0" of "1.3.0").
194  *
195  * @since New in 1.6.
196  */
197 #ifndef SQLITE_VERSION_AT_LEAST
198 #define SQLITE_VERSION_AT_LEAST(major,minor,patch)                     \
199 ((major*1000000 + minor*1000 + patch) <= SVN_SQLITE_MIN_VERSION_NUMBER)
200 #endif /* SQLITE_VERSION_AT_LEAST */
201
202 #ifdef __cplusplus
203 }
204 #endif /* __cplusplus */
205
206 #endif /* SVN_DEP_COMPAT_H */