diff options
Diffstat (limited to 'databases/foundationdb/files/patch-flow_Platform.cpp')
| -rw-r--r-- | databases/foundationdb/files/patch-flow_Platform.cpp | 63 |
1 files changed, 32 insertions, 31 deletions
diff --git a/databases/foundationdb/files/patch-flow_Platform.cpp b/databases/foundationdb/files/patch-flow_Platform.cpp index 26127b74452a..5d08110a2a21 100644 --- a/databases/foundationdb/files/patch-flow_Platform.cpp +++ b/databases/foundationdb/files/patch-flow_Platform.cpp @@ -1,4 +1,4 @@ ---- flow/Platform.cpp.orig 2018-08-01 01:25:10 UTC +--- flow/Platform.cpp.orig 2019-01-09 22:28:32 UTC +++ flow/Platform.cpp @@ -71,6 +71,7 @@ @@ -8,7 +8,7 @@ #include <sys/mman.h> #include <unistd.h> #include <ftw.h> -@@ -119,6 +120,12 @@ +@@ -119,7 +120,13 @@ #include <IOKit/IOBSD.h> #endif @@ -17,10 +17,11 @@ +#include <sys/sysctl.h> +#include <sys/cpuset.h> +#include <sys/resource.h> -+#endif #endif ++#endif std::string removeWhitespace(const std::string &t) + { @@ -198,7 +205,7 @@ double getProcessorTimeThread() { throw platform_error(); } @@ -54,7 +55,7 @@ return 0; #endif } -@@ -427,6 +442,24 @@ void getMachineRAMInfo(MachineRAMInfo& m +@@ -427,6 +442,24 @@ void getMachineRAMInfo(MachineRAMInfo& memInfo) { memInfo.total = pagesize * (vm_stat.free_count + vm_stat.active_count + vm_stat.inactive_count + vm_stat.wire_count); memInfo.available = pagesize * vm_stat.free_count; memInfo.committed = memInfo.total - memInfo.available; @@ -79,7 +80,7 @@ #else #warning getMachineRAMInfo unimplemented on this platform #endif -@@ -435,7 +468,7 @@ void getMachineRAMInfo(MachineRAMInfo& m +@@ -451,7 +484,7 @@ Error systemErrorCodeToError() { void getDiskBytes(std::string const& directory, int64_t& free, int64_t& total) { INJECT_FAULT( platform_error, "getDiskBytes" ); #if defined(__unixish__) @@ -87,8 +88,8 @@ +#if defined(__linux__) || defined(__FreeBSD__) struct statvfs buf; if (statvfs(directory.c_str(), &buf)) { - TraceEvent(SevError, "GetDiskBytesStatvfsError").detail("Directory", directory).GetLastError(); -@@ -477,7 +510,7 @@ void getDiskBytes(std::string const& dir + Error e = systemErrorCodeToError(); +@@ -497,7 +530,7 @@ void getDiskBytes(std::string const& directory, int64_ #endif } @@ -97,13 +98,13 @@ const char* getInterfaceName(uint32_t _ip) { INJECT_FAULT( platform_error, "getInterfaceName" ); static char iname[20]; -@@ -724,6 +757,30 @@ dev_t getDeviceId(std::string path) { +@@ -744,6 +777,30 @@ dev_t getDeviceId(std::string path) { #endif +#ifdef __FreeBSD__ +void getNetworkTraffic(uint32_t ip, uint64_t& bytesSent, uint64_t& bytesReceived, -+ uint64_t& outSegs, uint64_t& retransSegs) { ++ uint64_t& outSegs, uint64_t& retransSegs) { + bytesReceived = 0; + bytesSent = 0; + outSegs = 0; @@ -128,7 +129,7 @@ #ifdef __APPLE__ void getNetworkTraffic(uint32_t ip, uint64_t& bytesSent, uint64_t& bytesReceived, uint64_t& outSegs, uint64_t& retransSegs) { -@@ -1247,7 +1304,7 @@ struct OffsetTimer { +@@ -1268,7 +1325,7 @@ struct OffsetTimer { return offset + count * secondsPerCount; } }; @@ -137,7 +138,7 @@ #define DOUBLETIME(ts) (double(ts.tv_sec) + (ts.tv_nsec * 1e-9)) #ifndef CLOCK_MONOTONIC_RAW #define CLOCK_MONOTONIC_RAW 4 // Confirmed safe to do with glibc >= 2.11 and kernel >= 2.6.28. No promises with older glibc. Older kernel definitely breaks it. -@@ -1312,7 +1369,7 @@ double timer() { +@@ -1333,7 +1390,7 @@ double timer() { GetSystemTimeAsFileTime(&fileTime); static_assert( sizeof(fileTime) == sizeof(uint64_t), "FILETIME size wrong" ); return (*(uint64_t*)&fileTime - FILETIME_C_EPOCH) * 100e-9; @@ -146,7 +147,7 @@ struct timespec ts; clock_gettime(CLOCK_REALTIME, &ts); return double(ts.tv_sec) + (ts.tv_nsec * 1e-9); -@@ -1332,7 +1389,7 @@ uint64_t timer_int() { +@@ -1353,7 +1410,7 @@ uint64_t timer_int() { GetSystemTimeAsFileTime(&fileTime); static_assert( sizeof(fileTime) == sizeof(uint64_t), "FILETIME size wrong" ); return (*(uint64_t*)&fileTime - FILETIME_C_EPOCH); @@ -155,7 +156,7 @@ struct timespec ts; clock_gettime(CLOCK_REALTIME, &ts); return uint64_t(ts.tv_sec) * 1e9 + ts.tv_nsec; -@@ -1481,7 +1538,7 @@ static void *allocateInternal(size_t len +@@ -1502,7 +1559,7 @@ static void *allocateInternal(size_t length, bool larg flags |= MAP_HUGETLB; return mmap(NULL, length, PROT_READ|PROT_WRITE, flags, -1, 0); @@ -164,7 +165,7 @@ int flags = MAP_PRIVATE|MAP_ANON; return mmap(NULL, length, PROT_READ|PROT_WRITE, flags, -1, 0); -@@ -1555,6 +1612,11 @@ void setAffinity(int proc) { +@@ -1576,6 +1633,11 @@ void setAffinity(int proc) { CPU_ZERO(&set); CPU_SET(proc, &set); sched_setaffinity(0, sizeof(cpu_set_t), &set); @@ -176,7 +177,7 @@ #endif } -@@ -1615,7 +1677,7 @@ void renameFile( std::string const& from +@@ -1636,7 +1698,7 @@ void renameFile( std::string const& fromPath, std::str //renamedFile(); return; } @@ -185,16 +186,16 @@ if (!rename( fromPath.c_str(), toPath.c_str() )) { //FIXME: We cannot inject faults after renaming the file, because we could end up with two asyncFileNonDurable open for the same file //renamedFile(); -@@ -1733,7 +1795,7 @@ bool createDirectory( std::string const& - } - TraceEvent(SevError, "CreateDirectory").detail("Directory", directory).GetLastError(); - throw platform_error(); +@@ -1759,7 +1821,7 @@ bool createDirectory( std::string const& directory ) { + Error e = systemErrorCodeToError(); + TraceEvent(SevError, "CreateDirectory").detail("Directory", directory).GetLastError().error(e); + throw e; -#elif (defined(__linux__) || defined(__APPLE__)) +#elif (defined(__linux__) || defined(__APPLE__)) || defined(__FreeBSD__) size_t sep = 0; do { sep = directory.find_first_of('/', sep + 1); -@@ -1774,7 +1836,7 @@ std::string abspath( std::string const& +@@ -1804,7 +1866,7 @@ std::string abspath( std::string const& filename ) { if (*x == '/') *x = CANONICAL_PATH_SEPARATOR; return nameBuffer; @@ -203,7 +204,7 @@ char result[PATH_MAX]; auto r = realpath( filename.c_str(), result ); if (!r) { -@@ -1839,7 +1901,7 @@ std::string getUserHomeDirectory() { +@@ -1870,7 +1932,7 @@ std::string getUserHomeDirectory() { #ifdef _WIN32 #define FILE_ATTRIBUTE_DATA DWORD @@ -212,7 +213,7 @@ #define FILE_ATTRIBUTE_DATA mode_t #else #error Port me! -@@ -1848,7 +1910,7 @@ std::string getUserHomeDirectory() { +@@ -1879,7 +1941,7 @@ std::string getUserHomeDirectory() { bool acceptFile( FILE_ATTRIBUTE_DATA fileAttributes, std::string name, std::string extension ) { #ifdef _WIN32 return !(fileAttributes & FILE_ATTRIBUTE_DIRECTORY) && StringRef(name).endsWith(extension); @@ -221,7 +222,7 @@ return S_ISREG(fileAttributes) && StringRef(name).endsWith(extension); #else #error Port me! -@@ -1858,7 +1920,7 @@ bool acceptFile( FILE_ATTRIBUTE_DATA fil +@@ -1889,7 +1951,7 @@ bool acceptFile( FILE_ATTRIBUTE_DATA fileAttributes, s bool acceptDirectory( FILE_ATTRIBUTE_DATA fileAttributes, std::string name, std::string extension ) { #ifdef _WIN32 return (fileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0; @@ -230,7 +231,7 @@ return S_ISDIR(fileAttributes); #else #error Port me! -@@ -1894,7 +1956,7 @@ std::vector<std::string> findFiles( std: +@@ -1925,7 +1987,7 @@ std::vector<std::string> findFiles( std::string const& } FindClose(h); } @@ -239,7 +240,7 @@ DIR *dip; if ((dip = opendir(directory.c_str())) != NULL) { -@@ -1958,7 +2020,7 @@ void findFilesRecursively(std::string pa +@@ -1989,7 +2051,7 @@ void findFilesRecursively(std::string path, std::vecto void threadSleep( double seconds ) { #ifdef _WIN32 Sleep( (DWORD)(seconds * 1e3) ); @@ -248,7 +249,7 @@ struct timespec req, rem; req.tv_sec = seconds; -@@ -1996,7 +2058,7 @@ void makeTemporary( const char* filename +@@ -2027,7 +2089,7 @@ void makeTemporary( const char* filename ) { THREAD_HANDLE startThread(void (*func) (void *), void *arg) { return (void *)_beginthread(func, 0, arg); } @@ -257,7 +258,7 @@ THREAD_HANDLE startThread(void *(*func) (void *), void *arg) { pthread_t t; pthread_create(&t, NULL, func, arg); -@@ -2009,7 +2071,7 @@ THREAD_HANDLE startThread(void *(*func) +@@ -2040,7 +2102,7 @@ THREAD_HANDLE startThread(void *(*func) (void *), void void waitThread(THREAD_HANDLE thread) { #ifdef _WIN32 WaitForSingleObject(thread, INFINITE); @@ -266,7 +267,7 @@ pthread_join(thread, NULL); #else #error Port me! -@@ -2038,7 +2100,7 @@ int64_t fileSize(std::string const& file +@@ -2082,7 +2144,7 @@ int64_t fileSize(std::string const& filename) { return 0; else return file_status.st_size; @@ -275,7 +276,7 @@ struct stat file_status; if(stat(filename.c_str(), &file_status) != 0) return 0; -@@ -2181,6 +2243,8 @@ std::string getDefaultPluginPath( const +@@ -2225,6 +2287,8 @@ std::string getDefaultPluginPath( const char* plugin_n return format( "/usr/lib/foundationdb/plugins/%s.so", plugin_name ); #elif defined(__APPLE__) return format( "/usr/local/foundationdb/plugins/%s.dylib", plugin_name ); @@ -284,7 +285,7 @@ #else #error Port me! #endif -@@ -2430,7 +2494,7 @@ void* getImageOffset() { return NULL; } +@@ -2475,7 +2539,7 @@ void* getImageOffset() { return NULL; } #endif bool isLibraryLoaded(const char* lib_path) { @@ -293,7 +294,7 @@ #error Port me! #endif -@@ -2446,7 +2510,7 @@ bool isLibraryLoaded(const char* lib_pat +@@ -2491,7 +2555,7 @@ bool isLibraryLoaded(const char* lib_path) { } void* loadLibrary(const char* lib_path) { |
