diff options
author | Andrew Morrow <acm@mongodb.com> | 2018-06-04 10:40:41 -0400 |
---|---|---|
committer | Andrew Morrow <acm@mongodb.com> | 2018-07-17 15:31:15 -0400 |
commit | d175ae80e6af61f9f37bdebbde3b2b5115ae2a9f (patch) | |
tree | 491b4c6d5ca985c4a31f2819b35d4d6a0683e631 /src/mongo/util | |
parent | 1c0bce5f9792f0f6d4f26cd041a0c60c0398bd5e (diff) | |
download | mongo-d175ae80e6af61f9f37bdebbde3b2b5115ae2a9f.tar.gz |
SERVER-36147 Add basic support for targeting emscripten
Diffstat (limited to 'src/mongo/util')
-rw-r--r-- | src/mongo/util/dns_query.cpp | 2 | ||||
-rw-r--r-- | src/mongo/util/errno_util.cpp | 2 | ||||
-rw-r--r-- | src/mongo/util/processinfo_emscripten.cpp | 29 | ||||
-rw-r--r-- | src/mongo/util/processinfo_unknown.cpp | 4 | ||||
-rw-r--r-- | src/mongo/util/time_support.cpp | 2 |
5 files changed, 36 insertions, 3 deletions
diff --git a/src/mongo/util/dns_query.cpp b/src/mongo/util/dns_query.cpp index 5d10b2fb82e..f73b23c049a 100644 --- a/src/mongo/util/dns_query.cpp +++ b/src/mongo/util/dns_query.cpp @@ -50,7 +50,7 @@ #define MONGO_UTIL_DNS_QUERY_PLATFORM_INCLUDE_WHITELIST #ifdef WIN32 #include "mongo/util/dns_query_windows-impl.h" -#elif __ANDROID__ +#elif defined(__ANDROID__) || defined(__EMSCRIPTEN__) #include "mongo/util/dns_query_android-impl.h" #else #include "mongo/util/dns_query_posix-impl.h" diff --git a/src/mongo/util/errno_util.cpp b/src/mongo/util/errno_util.cpp index aa6733de737..5f34233af10 100644 --- a/src/mongo/util/errno_util.cpp +++ b/src/mongo/util/errno_util.cpp @@ -58,7 +58,7 @@ std::string errnoWithDescription(int errNumber) { char buf[kBuflen]; char* msg{nullptr}; -#if defined(__GNUC__) && defined(_GNU_SOURCE) && (__ANDROID_API__ > 22) +#if defined(__GNUC__) && defined(_GNU_SOURCE) && !(__ANDROID_API__ <= 22) && !defined(EMSCRIPTEN) msg = strerror_r(errNumber, buf, kBuflen); #elif defined(_WIN32) diff --git a/src/mongo/util/processinfo_emscripten.cpp b/src/mongo/util/processinfo_emscripten.cpp new file mode 100644 index 00000000000..df5f48c9540 --- /dev/null +++ b/src/mongo/util/processinfo_emscripten.cpp @@ -0,0 +1,29 @@ +/** + * Copyright (C) 2018 MongoDB Inc. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License, version 3, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + * As a special exception, the copyright holders give permission to link the + * code of portions of this program with the OpenSSL library under certain + * conditions as described in each individual source file and distribute + * linked combinations including the program with the OpenSSL library. You + * must comply with the GNU Affero General Public License in all respects for + * all of the code used other than as permitted herein. If you modify file(s) + * with this exception, you may extend this exception to your version of the + * file(s), but you are not obligated to do so. If you do not wish to do so, + * delete this exception statement from your version. If you delete this + * exception statement from all source files in the program, then also delete + * it in the license file. + */ + +#include "processinfo_unknown.cpp" diff --git a/src/mongo/util/processinfo_unknown.cpp b/src/mongo/util/processinfo_unknown.cpp index 8984012b13c..0bb22588a87 100644 --- a/src/mongo/util/processinfo_unknown.cpp +++ b/src/mongo/util/processinfo_unknown.cpp @@ -76,4 +76,8 @@ bool ProcessInfo::blockInMemory(const void* start) { bool ProcessInfo::pagesInMemory(const void* start, size_t numPages, vector<char>* out) { verify(0); } + +boost::optional<unsigned long> ProcessInfo::getNumCoresForProcess() { + return boost::none; +} } diff --git a/src/mongo/util/time_support.cpp b/src/mongo/util/time_support.cpp index e943aca2a50..4f7a47c9fa9 100644 --- a/src/mongo/util/time_support.cpp +++ b/src/mongo/util/time_support.cpp @@ -935,7 +935,7 @@ private: // Find minimum timer resolution of OS Nanoseconds getMinimumTimerResolution() { Nanoseconds minTimerResolution; -#if defined(__linux__) || defined(__FreeBSD__) +#if defined(__linux__) || defined(__FreeBSD__) || defined(__EMSCRIPTEN__) struct timespec tp; clock_getres(CLOCK_REALTIME, &tp); minTimerResolution = Nanoseconds{tp.tv_nsec}; |