Skip to content

Commit 6f6bbf0

Browse files
committed
CXX-204 Use vendored timegm implementation if platform does not offer it
(cherry picked from commit 5bf477a) Conflicts: SConstruct src/mongo/util/time_support.cpp
1 parent f50196e commit 6f6bbf0

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

SConstruct

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1434,6 +1434,11 @@ def doConfigure(myenv):
14341434
if not conf.CheckLib("execinfo"):
14351435
Exit(1)
14361436

1437+
conf.env['MONGO_HAVE_TIMEGM'] = conf.CheckDeclaration(
1438+
'timegm', includes="#include <time.h>", language='C')
1439+
if conf.env['MONGO_HAVE_TIMEGM']:
1440+
conf.env.Append(CPPDEFINES=['MONGO_HAVE_TIMEGM'])
1441+
14371442
# 'tcmalloc' needs to be the last library linked. Please, add new libraries before this
14381443
# point.
14391444
if get_option('allocator') == 'tcmalloc':

src/SConscript.client

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,13 +107,15 @@ clientSourceBasic = [
107107
'third_party/murmurhash3/MurmurHash3.cpp',
108108
]
109109

110+
clientSourceTz = [] if clientEnv['MONGO_HAVE_TIMEGM'] else ['third_party/tz/timegm.c']
111+
110112
clientSourceSasl = [
111113
'mongo/client/sasl_client_authenticate_impl.cpp',
112114
'mongo/client/sasl_client_session.cpp',
113115
'mongo/client/sasl_sspi.cpp',
114116
]
115117

116-
clientSourceAll = clientSourceBasic + clientSourceSasl
118+
clientSourceAll = clientSourceBasic + clientSourceTz + clientSourceSasl
117119

118120
usingSasl = libEnv['MONGO_BUILD_SASL_CLIENT']
119121

src/mongo/util/time_support.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,13 @@
4040
#define snprintf _snprintf
4141
#endif
4242

43+
#if !defined(MONGO_HAVE_TIMEGM)
44+
// Not all systems have timegm defined (it isn't part of POSIX), so fall back to our vendored
45+
// implementation if our configure checks did not detect it as available on the current
46+
// system. See SERVER-13446, SERVER-14019, and CXX-204.
47+
extern "C" time_t timegm(struct tm *const tmp);
48+
#endif
49+
4350
namespace mongo {
4451

4552
// jsTime_virtual_skew is just for testing. a test command manipulates it.

0 commit comments

Comments
 (0)