Skip to content

Commit a77a833

Browse files
committed
Fix build on windows -- no strtoll()
1 parent c6d29b3 commit a77a833

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

php_compat_53.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
#ifdef PHP_WIN32
2+
# include "config.w32.h"
3+
#else
4+
# include <php_config.h>
5+
#endif
6+
17
#ifndef PHP_FE_END
28
# define PHP_FE_END { NULL, NULL, NULL }
39
#endif
@@ -72,3 +78,14 @@
7278
# define ADD_INDEX_INT64(zval, index, value) add_index_long(zval, index, value)
7379
# define ADD_ASSOC_INT64(zval, key, value) add_assoc_long(zval, key, value);
7480
#endif
81+
82+
#ifdef HAVE_ATOLL
83+
# define STRTOLL(s) atoll(s)
84+
#else
85+
# if defined(PHP_WIN32)
86+
# define STRTOLL(s) _atoi64(s)
87+
# else
88+
# define STRTOLL(s) strtoll(s, NULL, 10)
89+
# endif
90+
#endif
91+

src/BSON/UTCDatetime.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ PHP_METHOD(UTCDatetime, __construct)
7070
return;
7171
}
7272

73-
intern->milliseconds = strtoll(s_milliseconds, NULL, 10);
73+
intern->milliseconds = STRTOLL(s_milliseconds);
7474
#else
7575
intern->milliseconds = milliseconds;
7676
#endif
@@ -94,7 +94,7 @@ PHP_METHOD(UTCDatetime, __toString)
9494
return;
9595
}
9696

97-
tmp_len = spprintf(&tmp, 0, "%lld", intern->milliseconds);
97+
tmp_len = spprintf(&tmp, 0, "%" PRId64, intern->milliseconds);
9898
RETVAL_STRINGL(tmp, tmp_len, 0);
9999
}
100100
/* }}} */

0 commit comments

Comments
 (0)