Skip to content

Commit 605d403

Browse files
authored
CDRIVER-4454 fix VS 2013 compile (#1106)
1 parent 671a151 commit 605d403

File tree

3 files changed

+20
-18
lines changed

3 files changed

+20
-18
lines changed

src/libmongoc/src/mongoc/mcd-azure.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ mcd_azure_access_token_try_init_from_json_str (mcd_azure_access_token *out,
7777

7878
if (len < 0) {
7979
// Detect from a null-terminated string
80-
len = strlen (json);
80+
len = (int) strlen (json);
8181
}
8282

8383
// Zero the output

src/libmongoc/src/mongoc/mcd-integer.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,13 @@
1919

2020
#include "mongoc-prelude.h"
2121

22+
#include <bson/bson.h>
23+
2224
#include <stdint.h>
2325
#include <stdbool.h>
2426

2527
/// Return 'true' iff (left * right) would overflow with int64
26-
static inline bool
28+
static BSON_INLINE bool
2729
_mcd_i64_mul_would_overflow (int64_t left, int64_t right)
2830
{
2931
if (right == -1) {
@@ -180,7 +182,7 @@ _mcd_i64_mul_would_overflow (int64_t left, int64_t right)
180182
}
181183

182184
/// Return 'true' iff (left + right) would overflow with int64
183-
static inline bool
185+
static BSON_INLINE bool
184186
_mcd_i64_add_would_overflow (int64_t left, int64_t right)
185187
{
186188
/**
@@ -362,7 +364,7 @@ _mcd_i64_add_would_overflow (int64_t left, int64_t right)
362364
}
363365

364366
/// Return 'true' iff (left - right) would overflow with int64
365-
static inline bool
367+
static BSON_INLINE bool
366368
_mcd_i64_sub_would_overflow (int64_t left, int64_t right)
367369
{
368370
// Lemma: N - M = N + (-M), therefore (N - M) is bounded iff (N + -M)

src/libmongoc/src/mongoc/mcd-time.h

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ typedef struct mcd_duration {
6767
* monotonically increasing time, and does not necessarily correlate with
6868
* any real-world clock.
6969
*/
70-
static inline mcd_time_point
70+
static BSON_INLINE mcd_time_point
7171
mcd_now (void)
7272
{
7373
// Create a time point representing the current time.
@@ -83,7 +83,7 @@ mcd_now (void)
8383
* @note Saturates to the min/max duration if the duration is too great in
8484
* magnitude.
8585
*/
86-
static inline mcd_duration
86+
static BSON_INLINE mcd_duration
8787
mcd_microseconds (int64_t s)
8888
{
8989
// 'mcd_duration' is encoded in a number of microseconds, so we don't need to
@@ -100,7 +100,7 @@ mcd_microseconds (int64_t s)
100100
* @note Saturates to the min/max duration if the duration is too great in
101101
* magnitude.
102102
*/
103-
static inline mcd_duration
103+
static BSON_INLINE mcd_duration
104104
mcd_milliseconds (int64_t s)
105105
{
106106
// 1'000 microseconds per millisecond:
@@ -119,7 +119,7 @@ mcd_milliseconds (int64_t s)
119119
* @note Saturates to the min/max duration if the duration is too great in
120120
* magnitude.
121121
*/
122-
static inline mcd_duration
122+
static BSON_INLINE mcd_duration
123123
mcd_seconds (int64_t s)
124124
{
125125
// 1'000 milliseconds per second:
@@ -138,7 +138,7 @@ mcd_seconds (int64_t s)
138138
* @note Saturates to the min/max duration if the duration is too great in
139139
* magnitude.
140140
*/
141-
static inline mcd_duration
141+
static BSON_INLINE mcd_duration
142142
mcd_minutes (int64_t m)
143143
{
144144
// Sixty seconds per minute:
@@ -157,7 +157,7 @@ mcd_minutes (int64_t m)
157157
* @note Does not round-trip with `mcd_milliseconds(N)` if N-milliseconds is
158158
* unrepresentable in the duration type. This only occurs in extreme durations
159159
*/
160-
static inline int64_t
160+
static BSON_INLINE int64_t
161161
mcd_get_milliseconds (mcd_duration d)
162162
{
163163
return d._rep / 1000;
@@ -176,7 +176,7 @@ mcd_get_milliseconds (mcd_duration d)
176176
* @note If the resulting point-in-time is unrepresentable, the return value
177177
* will be clamped to MCD_TIME_POINT_MIN or MCD_TIME_POINT_MAX.
178178
*/
179-
static inline mcd_time_point
179+
static BSON_INLINE mcd_time_point
180180
mcd_later (mcd_time_point from, mcd_duration delta)
181181
{
182182
if (_mcd_i64_add_would_overflow (from._rep, delta._rep)) {
@@ -202,7 +202,7 @@ mcd_later (mcd_time_point from, mcd_duration delta)
202202
* "from", you will receive a paradoxical *negative* duration, indicating
203203
* the amount of time needed to time-travel backwards to reach "then."
204204
*/
205-
static inline mcd_duration
205+
static BSON_INLINE mcd_duration
206206
mcd_time_difference (mcd_time_point then, mcd_time_point from)
207207
{
208208
if (_mcd_i64_sub_would_overflow (then._rep, from._rep)) {
@@ -229,7 +229,7 @@ mcd_time_difference (mcd_time_point then, mcd_time_point from)
229229
* @retval >0 If 'right' is before 'left'
230230
* @retval 0 If 'left' and 'right' are equivalent
231231
*/
232-
static inline int
232+
static BSON_INLINE int
233233
mcd_time_compare (mcd_time_point left, mcd_time_point right)
234234
{
235235
// Obtain the amount of time needed to wait from 'right' to reach
@@ -257,7 +257,7 @@ mcd_time_compare (mcd_time_point left, mcd_time_point right)
257257
* @retval >0 If left is "greater than" right
258258
* @retval 0 If left and right are equivalent
259259
*/
260-
static inline int
260+
static BSON_INLINE int
261261
mcd_duration_compare (mcd_duration left, mcd_duration right)
262262
{
263263
if (left._rep < right._rep) {
@@ -279,7 +279,7 @@ mcd_duration_compare (mcd_duration left, mcd_duration right)
279279
* @retval max If `dur` > `max`
280280
* @retval dur Otherwise
281281
*/
282-
static inline mcd_duration
282+
static BSON_INLINE mcd_duration
283283
mcd_duration_clamp (mcd_duration dur, mcd_duration min, mcd_duration max)
284284
{
285285
BSON_ASSERT (mcd_duration_compare (min, max) <= 0 &&
@@ -303,7 +303,7 @@ typedef struct mcd_timer {
303303
} mcd_timer;
304304

305305
/// Create a time that will expire at the given time
306-
static inline mcd_timer
306+
static BSON_INLINE mcd_timer
307307
mcd_timer_expire_at (mcd_time_point time)
308308
{
309309
return (mcd_timer){time};
@@ -316,7 +316,7 @@ mcd_timer_expire_at (mcd_time_point time)
316316
* @note If the duration is less-than or equal-to zero, the timer will already
317317
* have expired
318318
*/
319-
static inline mcd_timer
319+
static BSON_INLINE mcd_timer
320320
mcd_timer_expire_after (mcd_duration after)
321321
{
322322
return mcd_timer_expire_at (mcd_later (mcd_now (), after));
@@ -331,7 +331,7 @@ mcd_timer_expire_after (mcd_duration after)
331331
* @note If the timer is already expired, returns a zero duration. Will never
332332
* return a negative duration.
333333
*/
334-
static inline mcd_duration
334+
static BSON_INLINE mcd_duration
335335
mcd_timer_remaining (mcd_timer timer)
336336
{
337337
// Compute the distance until the expiry time relative to now

0 commit comments

Comments
 (0)