Index: head/databases/foundationdb/Makefile =================================================================== --- head/databases/foundationdb/Makefile (revision 471192) +++ head/databases/foundationdb/Makefile (revision 471193) @@ -1,55 +1,57 @@ # Created by: vanilla@ # $FreeBSD$ PORTNAME= foundationdb -PORTVERSION= 5.1.7 +PORTVERSION= 5.2.2 CATEGORIES= databases MAINTAINER= vanilla@FreeBSD.org COMMENT= Distributed, transactional key-value store LICENSE= APACHE20 LICENSE_FILE= ${WRKSRC}/LICENSE ONLY_FOR_ARCHS= amd64 ONLY_FOR_ARCHS_REASON= not yet ported to anything other than amd64 BUILD_DEPENDS= bash:shells/bash LIB_DEPENDS= libboost_system.so:devel/boost-libs \ libeio.so:devel/libeio USES= compiler:c++14-lang gmake mono python:build shebangfix USE_GITHUB= yes GH_ACCOUNT= apple USE_RC_SUBR= foundationdb -SHEBANG_FILES= build/link-wrapper.sh bindings/c/generate_asm.py +SHEBANG_FILES= build/csprojtom4.py build/link-wrapper.sh build/vcxprojtom4.py \ + bindings/c/generate_asm.py MAKE_ENV+= PYTHON=${PYTHON_CMD} +CXXFLAGS+= -Wno-varargs USERS= ${PORTNAME} GROUPS= ${PORTNAME} DBDIR?= /var/db/foundationdb LOGDIR?= /var/log/foundationdb PLIST_SUB+= DB_USER=${USERS} \ DB_GROUP=${GROUPS} \ DB_DIR=${DBDIR} \ LOG_DIR=${LOGDIR} post-patch: @${REINPLACE_CMD} -e 's|%%PREFIX%%|${PREFIX}|g' ${WRKSRC}/foundationdb.conf do-install: ${INSTALL_PROGRAM} ${WRKSRC}/bin/fdbbackup ${STAGEDIR}${PREFIX}/bin ${INSTALL_PROGRAM} ${WRKSRC}/bin/fdbcli ${STAGEDIR}${PREFIX}/bin ${LN} -sf ${PREFIX}/bin/fdbbackup ${STAGEDIR}${PREFIX}/bin/fdbrestore ${INSTALL_PROGRAM} ${WRKSRC}/bin/fdbmonitor ${STAGEDIR}${PREFIX}/sbin ${INSTALL_PROGRAM} ${WRKSRC}/bin/fdbserver ${STAGEDIR}${PREFIX}/sbin @${MKDIR} ${STAGEDIR}${PREFIX}/lib/foundationdb @${MKDIR} ${STAGEDIR}${PREFIX}/lib/foundationdb/backup_agent ${LN} -sf ${PREFIX}/bin/fdbbackup ${STAGEDIR}${PREFIX}/lib/foundationdb/backup_agent/backup_agent @${MKDIR} ${STAGEDIR}${PREFIX}/etc/foundationdb ${INSTALL_DATA} ${WRKSRC}/foundationdb.conf ${STAGEDIR}${PREFIX}/etc/foundationdb/foundationdb.conf.sample @${MKDIR} ${STAGEDIR}${DBDIR} @${MKDIR} ${STAGEDIR}${LOGDIR} .include Index: head/databases/foundationdb/distinfo =================================================================== --- head/databases/foundationdb/distinfo (revision 471192) +++ head/databases/foundationdb/distinfo (revision 471193) @@ -1,3 +1,3 @@ -TIMESTAMP = 1524403792 -SHA256 (apple-foundationdb-5.1.7_GH0.tar.gz) = 6dd8b391527fc8070c9714117e0ed2ced50d993b20d64f3f2981bf9ef8734870 -SIZE (apple-foundationdb-5.1.7_GH0.tar.gz) = 3982458 +TIMESTAMP = 1527730920 +SHA256 (apple-foundationdb-5.2.2_GH0.tar.gz) = f632b354cc6ebfdcb5133278901511129a341806d3aa4f4184cc13766f7d841e +SIZE (apple-foundationdb-5.2.2_GH0.tar.gz) = 4495353 Index: head/databases/foundationdb/files/patch-fdbclient_NativeAPI.actor.cpp =================================================================== --- head/databases/foundationdb/files/patch-fdbclient_NativeAPI.actor.cpp (revision 471192) +++ head/databases/foundationdb/files/patch-fdbclient_NativeAPI.actor.cpp (nonexistent) @@ -1,20 +0,0 @@ ---- fdbclient/NativeAPI.actor.cpp.orig 2018-04-28 15:48:35 UTC -+++ fdbclient/NativeAPI.actor.cpp -@@ -93,7 +93,7 @@ LocationInfo::~LocationInfo() { - for( auto const& alternative : getAlternatives() ) - handles.push_back( alternative.v.getVersion.getEndpoint().token ); // must match above choice of UID - std::sort( handles.begin(), handles.end() ); -- ASSERT( handles.size() ); -+ ASSERT_ABORT( handles.size() ); - - auto it = cx->ssid_locationInfo.find( handles ); - if( it != cx->ssid_locationInfo.end() ) -@@ -540,7 +540,7 @@ DatabaseContext::~DatabaseContext() { - monitorMasterProxiesInfoChange.cancel(); - for(auto it = ssid_locationInfo.begin(); it != ssid_locationInfo.end(); it = ssid_locationInfo.erase(it)) - it->second->notifyContextDestroyed(); -- ASSERT( ssid_locationInfo.empty() ); -+ ASSERT_ABORT( ssid_locationInfo.empty() ); - locationCache.insert( allKeys, Reference() ); - } - Property changes on: head/databases/foundationdb/files/patch-fdbclient_NativeAPI.actor.cpp ___________________________________________________________________ Deleted: fbsd:nokeywords ## -1 +0,0 ## -on \ No newline at end of property Deleted: svn:eol-style ## -1 +0,0 ## -native \ No newline at end of property Deleted: svn:mime-type ## -1 +0,0 ## -text/plain \ No newline at end of property Index: head/databases/foundationdb/files/patch-fdbrpc_AsyncFileCached.actor.h =================================================================== --- head/databases/foundationdb/files/patch-fdbrpc_AsyncFileCached.actor.h (revision 471192) +++ head/databases/foundationdb/files/patch-fdbrpc_AsyncFileCached.actor.h (nonexistent) @@ -1,11 +0,0 @@ ---- fdbrpc/AsyncFileCached.actor.h.orig 2018-04-28 14:44:18 UTC -+++ fdbrpc/AsyncFileCached.actor.h -@@ -450,7 +450,7 @@ struct AFCPage : public EvictablePage, p - - virtual ~AFCPage() { - clearDirty(); -- ASSERT( flushableIndex == -1 ); -+ ASSERT_ABORT( flushableIndex == -1 ); - } - - void setDirty() { Property changes on: head/databases/foundationdb/files/patch-fdbrpc_AsyncFileCached.actor.h ___________________________________________________________________ Deleted: fbsd:nokeywords ## -1 +0,0 ## -on \ No newline at end of property Deleted: svn:eol-style ## -1 +0,0 ## -native \ No newline at end of property Deleted: svn:mime-type ## -1 +0,0 ## -text/plain \ No newline at end of property Index: head/databases/foundationdb/files/patch-fdbserver_VFSAsync.cpp =================================================================== --- head/databases/foundationdb/files/patch-fdbserver_VFSAsync.cpp (revision 471192) +++ head/databases/foundationdb/files/patch-fdbserver_VFSAsync.cpp (nonexistent) @@ -1,11 +0,0 @@ ---- fdbserver/VFSAsync.cpp.orig 2018-04-28 14:51:27 UTC -+++ fdbserver/VFSAsync.cpp -@@ -460,7 +460,7 @@ static int asyncDeviceCharacteristics(sq - //resulting in a locking error - auto itr = SharedMemoryInfo::table.find(filename); - if(itr != SharedMemoryInfo::table.end()) { -- ASSERT(itr->second.refcount == 0); -+ ASSERT_ABORT(itr->second.refcount == 0); - itr->second.cleanup(); - } - } Property changes on: head/databases/foundationdb/files/patch-fdbserver_VFSAsync.cpp ___________________________________________________________________ Deleted: fbsd:nokeywords ## -1 +0,0 ## -on \ No newline at end of property Deleted: svn:eol-style ## -1 +0,0 ## -native \ No newline at end of property Deleted: svn:mime-type ## -1 +0,0 ## -text/plain \ No newline at end of property Index: head/databases/foundationdb/files/patch-fdbserver_TLogServer.actor.cpp =================================================================== --- head/databases/foundationdb/files/patch-fdbserver_TLogServer.actor.cpp (revision 471192) +++ head/databases/foundationdb/files/patch-fdbserver_TLogServer.actor.cpp (nonexistent) @@ -1,11 +0,0 @@ ---- fdbserver/TLogServer.actor.cpp.orig 2018-04-28 15:41:40 UTC -+++ fdbserver/TLogServer.actor.cpp -@@ -425,7 +425,7 @@ struct LogData : NonCopyable, public Ref - tLogData->bytesDurable += bytesInput.getValue() - bytesDurable.getValue(); - TraceEvent("TLogBytesWhenRemoved", tli.id()).detail("sharedBytesInput", tLogData->bytesInput).detail("sharedBytesDurable", tLogData->bytesDurable).detail("localBytesInput", bytesInput.getValue()).detail("localBytesDurable", bytesDurable.getValue()); - -- ASSERT(tLogData->bytesDurable <= tLogData->bytesInput); -+ ASSERT_ABORT(tLogData->bytesDurable <= tLogData->bytesInput); - endRole(tli.id(), "TLog", "Error", true); - - if(!tLogData->terminated) { Property changes on: head/databases/foundationdb/files/patch-fdbserver_TLogServer.actor.cpp ___________________________________________________________________ Deleted: fbsd:nokeywords ## -1 +0,0 ## -on \ No newline at end of property Deleted: svn:eol-style ## -1 +0,0 ## -native \ No newline at end of property Deleted: svn:mime-type ## -1 +0,0 ## -text/plain \ No newline at end of property Index: head/databases/foundationdb/files/patch-flow_IThreadPool.cpp =================================================================== --- head/databases/foundationdb/files/patch-flow_IThreadPool.cpp (revision 471192) +++ head/databases/foundationdb/files/patch-flow_IThreadPool.cpp (nonexistent) @@ -1,11 +0,0 @@ ---- flow/IThreadPool.cpp.orig 2018-04-28 14:40:31 UTC -+++ flow/IThreadPool.cpp -@@ -35,7 +35,7 @@ class ThreadPool : public IThreadPool, p - Event stopped; - static thread_local IThreadPoolReceiver* threadUserObject; - explicit Thread(ThreadPool *pool, IThreadPoolReceiver *userObject) : pool(pool), userObject(userObject) {} -- ~Thread() { ASSERT(!userObject); } -+ ~Thread() { ASSERT_ABORT(!userObject); } - - void run() { - deprioritizeThread(); Property changes on: head/databases/foundationdb/files/patch-flow_IThreadPool.cpp ___________________________________________________________________ Deleted: fbsd:nokeywords ## -1 +0,0 ## -on \ No newline at end of property Deleted: svn:eol-style ## -1 +0,0 ## -native \ No newline at end of property Deleted: svn:mime-type ## -1 +0,0 ## -text/plain \ No newline at end of property Index: head/databases/foundationdb/files/patch-fdbclient_MultiVersionAssignmentVars.h =================================================================== --- head/databases/foundationdb/files/patch-fdbclient_MultiVersionAssignmentVars.h (revision 471192) +++ head/databases/foundationdb/files/patch-fdbclient_MultiVersionAssignmentVars.h (nonexistent) @@ -1,11 +0,0 @@ ---- fdbclient/MultiVersionAssignmentVars.h.orig 2018-04-29 11:43:19 UTC -+++ fdbclient/MultiVersionAssignmentVars.h -@@ -135,7 +135,7 @@ public: - ~DLThreadSingleAssignmentVar() { - lock.assertNotEntered(); - if(f) { -- ASSERT(futureRefCount == 1); -+ ASSERT_ABORT(futureRefCount == 1); - api->futureDestroy(f); - } - } Property changes on: head/databases/foundationdb/files/patch-fdbclient_MultiVersionAssignmentVars.h ___________________________________________________________________ Deleted: fbsd:nokeywords ## -1 +0,0 ## -on \ No newline at end of property Deleted: svn:eol-style ## -1 +0,0 ## -native \ No newline at end of property Deleted: svn:mime-type ## -1 +0,0 ## -text/plain \ No newline at end of property Index: head/databases/foundationdb/files/patch-FDBLibTLS_local.mk =================================================================== --- head/databases/foundationdb/files/patch-FDBLibTLS_local.mk (revision 471192) +++ head/databases/foundationdb/files/patch-FDBLibTLS_local.mk (revision 471193) @@ -1,12 +1,12 @@ ---- FDBLibTLS/local.mk.orig 2018-04-19 02:55:50 UTC +--- FDBLibTLS/local.mk.orig 2018-05-16 23:59:08 UTC +++ FDBLibTLS/local.mk @@ -1,6 +1,6 @@ --FDBLibTLS_CFLAGS := -fPIC -I/usr/local/include -I$(BOOSTDIR) +-FDBLibTLS_CFLAGS := -fPIC -I/usr/local/include -I$(BOOSTDIR) -Ifdbrpc -FDBLibTLS_STATIC_LIBS := -ltls -lssl -lcrypto -FDBLibTLS_LDFLAGS := -L/usr/local/lib -static-libstdc++ -static-libgcc -lrt -+FDBLibTLS_CFLAGS := -fPIC -I/usr/local/include -I$(BOOSTDIR)/include ++FDBLibTLS_CFLAGS := -fPIC -I/usr/local/include -I$(BOOSTDIR)/include -I../fdbrpc +FDBLibTLS_LIBS := -lssl -lcrypto +FDBLibTLS_LDFLAGS := -lc++ FDBLibTLS_LDFLAGS += -Wl,-soname,FDBLibTLS.so -Wl,--version-script=FDBLibTLS/FDBLibTLS.map # The plugin isn't a typical library, so it feels more sensible to have a copy Index: head/databases/foundationdb/files/patch-Makefile =================================================================== --- head/databases/foundationdb/files/patch-Makefile (revision 471192) +++ head/databases/foundationdb/files/patch-Makefile (revision 471193) @@ -1,77 +1,77 @@ ---- Makefile.orig 2018-04-19 02:55:50 UTC +--- Makefile.orig 2018-05-11 01:30:59 UTC +++ Makefile @@ -6,6 +6,8 @@ TOPDIR := $(shell pwd) ifeq ($(ARCH),x86_64) ARCH := x64 +else ifeq ($(ARCH),amd64) + ARCH := x64 else $(error Not prepared to compile on $(ARCH)) endif @@ -15,7 +17,7 @@ ifeq ($(MONO),) MONO := /usr/bin/mono endif -MCS := $(shell which dmcs) +MCS := $(shell which mcs) ifeq ($(MCS),) MCS := /usr/bin/dmcs endif @@ -40,6 +42,15 @@ ifeq ($(PLATFORM),Linux) DLEXT := so java_DLEXT := so TARGET_LIBC_VERSION ?= 2.11 +else ifeq ($(PLATFORM),FreeBSD) + PLATFORM := freebsd + + CFLAGS += -DPREFIX=\"$(PREFIX)\" -DCONFDIR=\"$(PREFIX)/etc/foundationdb\" + CXXFLAGS += -std=c++11 -stdlib=libc++ -Wno-undefined-var-template -Wno-unknown-warning-option -msse4.2 + + BOOSTDIR ?= $(PREFIX) + DLEXT := so + java_DLEXT := so else ifeq ($(PLATFORM),Darwin) PLATFORM := osx @@ -92,7 +103,7 @@ STATIC_LIBS := VPATH += $(addprefix :,$(filter-out lib,$(patsubst -L%,%,$(filter -L%,$(LDFLAGS))))) CS_PROJECTS := flow/actorcompiler flow/coveragetool fdbclient/vexillographer -CPP_PROJECTS := flow fdbrpc fdbclient fdbbackup fdbserver fdbcli bindings/c bindings/java fdbmonitor bindings/flow/tester bindings/flow FDBLibTLS +CPP_PROJECTS := flow fdbrpc fdbclient fdbbackup fdbserver fdbcli bindings/c fdbmonitor bindings/flow/tester bindings/flow OTHER_PROJECTS := bindings/python bindings/ruby bindings/go CS_MK_GENERATED := $(CS_PROJECTS:=/generated.mk) -@@ -101,7 +112,7 @@ CPP_MK_GENERATED := $(CPP_PROJECTS:=/gen +@@ -101,7 +112,7 @@ CPP_MK_GENERATED := $(CPP_PROJECTS:=/generated.mk) MK_GENERATED := $(CS_MK_GENERATED) $(CPP_MK_GENERATED) # build/valgrind.mk needs to be included before any _MK_GENERATED (which in turn includes local.mk) -MK_INCLUDE := build/scver.mk build/valgrind.mk $(CS_MK_GENERATED) $(CPP_MK_GENERATED) $(OTHER_PROJECTS:=/include.mk) build/packages.mk +MK_INCLUDE := $(CS_MK_GENERATED) $(CPP_MK_GENERATED) ALL_MAKEFILES := Makefile $(MK_INCLUDE) $(patsubst %/generated.mk,%/local.mk,$(MK_GENERATED)) @@ -111,7 +122,7 @@ TARGETS = default: fdbserver fdbbackup fdbcli fdb_c fdb_python fdb_python_sdist -all: $(CS_PROJECTS) $(CPP_PROJECTS) $(OTHER_PROJECTS) +all: $(CS_PROJECTS) $(CPP_PROJECTS) # These are always defined and ready to use. Any target that uses them and needs them up to date # should depend on versions.target @@ -133,11 +144,11 @@ Makefiles: $(MK_GENERATED) $(CS_MK_GENERATED): build/csprojtom4.py build/csproj.mk Makefile @echo "Creating $@" - @python build/csprojtom4.py $(@D)/*.csproj | m4 -DGENDIR="$(@D)" -DGENNAME=`basename $(@D)/*.csproj .csproj` - build/csproj.mk > $(@D)/generated.mk + @$(PYTHON) build/csprojtom4.py $(@D)/*.csproj | m4 -DGENDIR="$(@D)" -DGENNAME=`basename $(@D)/*.csproj .csproj` - build/csproj.mk > $(@D)/generated.mk $(CPP_MK_GENERATED): build/vcxprojtom4.py build/vcxproj.mk Makefile @echo "Creating $@" - @python build/vcxprojtom4.py $(@D)/*.vcxproj | m4 -DGENDIR="$(@D)" -DGENNAME=`basename $(@D)/*.vcxproj .vcxproj` - build/vcxproj.mk > $(@D)/generated.mk + @$(PYTHON) build/vcxprojtom4.py $(@D)/*.vcxproj | m4 -DGENDIR="$(@D)" -DGENNAME=`basename $(@D)/*.vcxproj .vcxproj` - build/vcxproj.mk > $(@D)/generated.mk DEPSDIR := .deps OBJDIR := .objs Index: head/databases/foundationdb/files/patch-build_csprojtom4.py =================================================================== --- head/databases/foundationdb/files/patch-build_csprojtom4.py (nonexistent) +++ head/databases/foundationdb/files/patch-build_csprojtom4.py (revision 471193) @@ -0,0 +1,55 @@ +--- build/csprojtom4.py.orig 2018-05-31 02:58:48 UTC ++++ build/csprojtom4.py +@@ -1,5 +1,5 @@ + #!/usr/local/bin/python2.7 +-# ++#i + # csprojtom4.py + # + # This source file is part of the FoundationDB open source project +@@ -23,8 +23,8 @@ + import sys + + if len(sys.argv) != 2: +- print """Usage: +- %s [input]""" % sys.argv[0] ++ print("""Usage: ++ %s [input]""" % sys.argv[0]) + sys.exit() + + csproj = sys.argv[1] +@@ -34,20 +34,20 @@ from xml.dom.minidom import parse + try: + dom = parse(csproj) + except: +- print "ERROR: Unable to open CSProj file %s" % csproj ++ print("ERROR: Unable to open CSProj file %s" % csproj) + sys.exit() + + outputType = dom.getElementsByTagName("OutputType")[0].childNodes[0].data + assemblyName = dom.getElementsByTagName("AssemblyName")[0].childNodes[0].data + + if outputType == "Exe": +- print "define(`GENTARGET', `bin/%s.exe')dnl" % assemblyName +- print "define(`GENOUTPUTTYPE', `exe')dnl" ++ print("define(`GENTARGET', `bin/%s.exe')dnl" % assemblyName) ++ print("define(`GENOUTPUTTYPE', `exe')dnl") + elif outputType == "Library": +- print "define(`GENTARGET', `bin/%s.dll')dnl" % assemblyName +- print "define(`GENOUTPUTTYPE', `library')dnl" ++ print("define(`GENTARGET', `bin/%s.dll')dnl" % assemblyName) ++ print("define(`GENOUTPUTTYPE', `library')dnl") + else: +- print "ERROR: Unable to determine output type" ++ print("ERROR: Unable to determine output type") + sys.exit() + + sources = [node.getAttribute("Include").replace('\\', '/') for node in +@@ -55,5 +55,5 @@ sources = [node.getAttribute("Include").replace('\\', + assemblies = [node.getAttribute("Include") for node in + dom.getElementsByTagName("Reference")] + +-print "define(`GENSOURCES', `%s')dnl" % ' '.join(sources) +-print "define(`GENREFERENCES', `%s')dnl" % ','.join(assemblies) ++print("define(`GENSOURCES', `%s')dnl" % ' '.join(sources)) ++print("define(`GENREFERENCES', `%s')dnl" % ','.join(assemblies)) Property changes on: head/databases/foundationdb/files/patch-build_csprojtom4.py ___________________________________________________________________ Added: fbsd:nokeywords ## -0,0 +1 ## +yes \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: head/databases/foundationdb/files/patch-build_vcxprojtom4.py =================================================================== --- head/databases/foundationdb/files/patch-build_vcxprojtom4.py (nonexistent) +++ head/databases/foundationdb/files/patch-build_vcxprojtom4.py (revision 471193) @@ -0,0 +1,56 @@ +--- build/vcxprojtom4.py.orig 2018-05-31 02:52:54 UTC ++++ build/vcxprojtom4.py +@@ -23,8 +23,8 @@ + import sys + + if len(sys.argv) != 2: +- print """Usage: +- %s [input]""" % sys.argv[0] ++ print("""Usage: ++ %s [input]""" % sys.argv[0]) + sys.exit() + + vcxproj = sys.argv[1] +@@ -34,7 +34,7 @@ from xml.dom.minidom import parse + try: + dom = parse(vcxproj) + except: +- print "ERROR: Unable to open VCXProj file %s" % vcxproj ++ print("ERROR: Unable to open VCXProj file %s" % vcxproj) + sys.exit() + + # We need to find out what kind of project/configuration we're going +@@ -49,19 +49,19 @@ for group in groups: + configType = ctnodes[0].childNodes[0].data + break + +-print "define(`GENCONFIGTYPE', `%s')dnl" % configType ++print("define(`GENCONFIGTYPE', `%s')dnl" % configType) + + if configType == "StaticLibrary": +- print "define(`GENTARGET', `lib/lib`'GENNAME.a')dnl" +- print "define(`GENOUTDIR', `lib')dnl" ++ print("define(`GENTARGET', `lib/lib`'GENNAME.a')dnl") ++ print("define(`GENOUTDIR', `lib')dnl") + elif configType == "DynamicLibrary": +- print "define(`GENTARGET', `lib/lib`'GENNAME.$(DLEXT)')dnl" +- print "define(`GENOUTDIR', `lib')dnl" ++ print("define(`GENTARGET', `lib/lib`'GENNAME.$(DLEXT)')dnl") ++ print("define(`GENOUTDIR', `lib')dnl") + elif configType == "Application": +- print "define(`GENTARGET', `bin/'`GENNAME')dnl" +- print "define(`GENOUTDIR', `bin')dnl" ++ print("define(`GENTARGET', `bin/'`GENNAME')dnl") ++ print("define(`GENOUTDIR', `bin')dnl") + else: +- print "ERROR: Unable to determine configuration type" ++ print("ERROR: Unable to determine configuration type") + sys.exit() + + sources = [node.getAttribute("Include").replace('\\', '/') for node in +@@ -70,4 +70,4 @@ sources = [node.getAttribute("Include").replace('\\', + dom.getElementsByTagName("ClInclude") + if not node.getElementsByTagName("ExcludedFromBuild") and node.hasAttribute("Include")] + +-print "define(`GENSOURCES', `%s')dnl" % ' '.join(sorted(sources)) ++print("define(`GENSOURCES', `%s')dnl" % ' '.join(sorted(sources))) Property changes on: head/databases/foundationdb/files/patch-build_vcxprojtom4.py ___________________________________________________________________ Added: fbsd:nokeywords ## -0,0 +1 ## +yes \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: head/databases/foundationdb/files/patch-fdbmonitor_fdbmonitor.cpp =================================================================== --- head/databases/foundationdb/files/patch-fdbmonitor_fdbmonitor.cpp (revision 471192) +++ head/databases/foundationdb/files/patch-fdbmonitor_fdbmonitor.cpp (revision 471193) @@ -1,165 +1,165 @@ ---- fdbmonitor/fdbmonitor.cpp.orig 2018-04-19 02:55:50 UTC +--- fdbmonitor/fdbmonitor.cpp.orig 2018-05-11 01:30:59 UTC +++ fdbmonitor/fdbmonitor.cpp @@ -35,6 +35,10 @@ #include #endif +#ifdef __FreeBSD__ +#include +#endif + #ifdef __APPLE__ #include #include @@ -72,7 +76,7 @@ #ifdef __linux__ typedef fd_set* fdb_fd_set; -#elif defined __APPLE__ +#elif defined(__APPLE__) || defined(__FreeBSD__) typedef int fdb_fd_set; #endif -@@ -83,7 +87,7 @@ void monitor_fd( fdb_fd_set list, int fd +@@ -83,7 +87,7 @@ void monitor_fd( fdb_fd_set list, int fd, int* maxfd, FD_SET( fd, list ); if ( fd > *maxfd ) *maxfd = fd; -#elif defined __APPLE__ +#elif defined(__APPLE__) || defined(__FreeBSD__) /* ignore maxfd */ struct kevent ev; EV_SET( &ev, fd, EVFILT_READ, EV_ADD, 0, 0, cmd ); -@@ -94,7 +98,7 @@ void monitor_fd( fdb_fd_set list, int fd +@@ -94,7 +98,7 @@ void monitor_fd( fdb_fd_set list, int fd, int* maxfd, void unmonitor_fd( fdb_fd_set list, int fd ) { #ifdef __linux__ FD_CLR( fd, list ); -#elif defined __APPLE__ +#elif defined(__APPLE__) || defined(__FreeBSD__) struct kevent ev; EV_SET( &ev, fd, EVFILT_READ, EV_DELETE, 0, 0, NULL ); kevent( list, &ev, 1, NULL, 0, NULL ); // FIXME: check? -@@ -188,7 +192,7 @@ const char* get_value_multi(const CSimpl +@@ -188,7 +192,7 @@ const char* get_value_multi(const CSimpleIni& ini, con } double timer() { -#if defined(__linux__) +#if defined(__linux__) || defined(__FreeBSD__) struct timespec ts; clock_gettime(CLOCK_MONOTONIC, &ts); return double(ts.tv_sec) + (ts.tv_nsec * 1e-9); -@@ -822,7 +826,7 @@ void read_child_output( Command* cmd, in +@@ -822,7 +826,7 @@ void read_child_output( Command* cmd, int pipe_idx, fd } } -#ifdef __APPLE__ +#if defined(__APPLE__) || defined(__FreeBSD__) void watch_conf_dir( int kq, int* confd_fd, std::string confdir ) { struct kevent ev; std::string original = confdir; -@@ -839,7 +843,7 @@ void watch_conf_dir( int kq, int* confd_ +@@ -839,7 +843,7 @@ void watch_conf_dir( int kq, int* confd_fd, std::strin std::string child = confdir; /* Find the nearest existing ancestor */ - while( (*confd_fd = open( confdir.c_str(), O_EVTONLY )) < 0 && errno == ENOENT ) { + while( (*confd_fd = open( confdir.c_str(), O_RDONLY )) < 0 && errno == ENOENT ) { child = confdir; confdir = parentDirectory(confdir); } -@@ -876,7 +880,7 @@ void watch_conf_file( int kq, int* conff +@@ -876,7 +880,7 @@ void watch_conf_file( int kq, int* conff_fd, const cha } /* Open and watch */ - *conff_fd = open( confpath, O_EVTONLY ); + *conff_fd = open( confpath, O_RDONLY ); if ( *conff_fd >= 0 ) { EV_SET( &ev, *conff_fd, EVFILT_VNODE, EV_ADD | EV_CLEAR, NOTE_WRITE | NOTE_ATTRIB, 0, NULL ); kevent( kq, &ev, 1, NULL, 0, NULL ); -@@ -983,7 +987,7 @@ std::unordered_map additional_watch_paths; @@ -1065,7 +1069,7 @@ int main(int argc, char** argv) { /* only linux needs this, but... */ int maxfd = 0; -#ifdef __linux__ +#if defined(__linux__) fd_set rfds; watched_fds = &rfds; @@ -1080,12 +1084,12 @@ int main(int argc, char** argv) { CSimpleIniA* ini = NULL; if (daemonize) { -#ifdef __APPLE__ +#if defined(__APPLE__) || defined(__FreeBSD__) #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wdeprecated-declarations" #endif if (daemon(0, 0)) { -#ifdef __APPLE__ +#if defined(__APPLE__) || defined(__FreeBSD__) #pragma GCC diagnostic pop #endif log_err("daemon", errno, "Unable to daemonize"); @@ -1138,12 +1142,12 @@ int main(int argc, char** argv) { snprintf(pid_buf, sizeof(pid_buf), "%d\n", getpid()); ssize_t ign = write(lockfile_fd, pid_buf, strlen(pid_buf)); -#ifdef __linux__ +#if defined(__linux__) /* attempt to do clean shutdown and remove lockfile when killed */ signal(SIGHUP, signal_handler); signal(SIGINT, signal_handler); signal(SIGTERM, signal_handler); -#elif defined(__APPLE__) +#elif defined(__APPLE__) || defined(__FreeBSD__) int kq = kqueue(); if ( kq < 0 ) { log_err( "kqueue", errno, "Unable to create kqueue" ); @@ -1174,7 +1178,7 @@ int main(int argc, char** argv) { #endif -#ifdef __linux__ +#if defined(__linux__) signal(SIGCHLD, child_handler); #endif @@ -1188,11 +1192,11 @@ int main(int argc, char** argv) { /* normal will be restored in our main loop in the call to pselect, but none blocks all signals while processing events */ sigprocmask(SIG_SETMASK, &full_mask, &normal_mask); -#elif defined(__APPLE__) +#elif defined(__APPLE__) || defined(__FreeBSD__) sigprocmask(0, NULL, &normal_mask); #endif -#ifdef __APPLE__ +#if defined(__APPLE__) || defined(__FreeBSD__) struct stat st_buf; struct timespec mtimespec; @@ -1251,7 +1255,7 @@ int main(int argc, char** argv) { load_conf(confpath.c_str(), uid, gid, &normal_mask, &rfds, &maxfd); reload_additional_watches = false; -#elif defined(__APPLE__) +#elif defined(__APPLE__) || defined(__FreeBSD__) load_conf( confpath.c_str(), uid, gid, &normal_mask, watched_fds, &maxfd ); watch_conf_file( kq, &conff_fd, confpath.c_str() ); watch_conf_dir( kq, &confd_fd, confdir ); @@ -1289,7 +1293,7 @@ int main(int argc, char** argv) { if(nfds == 0) { reload = true; } -#elif defined(__APPLE__) +#elif defined(__APPLE__) || defined(__FreeBSD__) int nev = 0; if(timeout < 0) { nev = kevent( kq, NULL, 0, &ev, 1, NULL ); Index: head/databases/foundationdb/files/patch-fdbrpc_AsyncFileCached.actor.cpp =================================================================== --- head/databases/foundationdb/files/patch-fdbrpc_AsyncFileCached.actor.cpp (revision 471192) +++ head/databases/foundationdb/files/patch-fdbrpc_AsyncFileCached.actor.cpp (revision 471193) @@ -1,20 +1,11 @@ ---- fdbrpc/AsyncFileCached.actor.cpp.orig 2018-04-19 02:55:50 UTC +--- fdbrpc/AsyncFileCached.actor.cpp.orig 2018-05-30 22:33:28 UTC +++ fdbrpc/AsyncFileCached.actor.cpp @@ -31,7 +31,7 @@ EvictablePage::~EvictablePage() { if (pageCache->pageSize == 4096) FastAllocator<4096>::release(data); else - aligned_free(data); + free(data); } if (index > -1) { pageCache->pages[index] = pageCache->pages.back(); -@@ -233,7 +233,7 @@ Future AsyncFileCached::quiesce() - AsyncFileCached::~AsyncFileCached() { - while ( !pages.empty() ) { - auto ok = pages.begin()->second->evict(); -- ASSERT( ok ); -+ ASSERT_ABORT( ok ); - } - openFiles.erase( filename ); - } Index: head/databases/foundationdb/files/patch-fdbrpc_IAsyncFile.actor.cpp =================================================================== --- head/databases/foundationdb/files/patch-fdbrpc_IAsyncFile.actor.cpp (revision 471192) +++ head/databases/foundationdb/files/patch-fdbrpc_IAsyncFile.actor.cpp (revision 471193) @@ -1,11 +1,11 @@ ---- fdbrpc/IAsyncFile.actor.cpp.orig 2018-04-25 15:06:34 UTC +--- fdbrpc/IAsyncFile.actor.cpp.orig 2018-05-11 01:30:59 UTC +++ fdbrpc/IAsyncFile.actor.cpp -@@ -42,7 +42,7 @@ ACTOR static Future zeroRangeHelpe +@@ -42,7 +42,7 @@ ACTOR static Future zeroRangeHelper( Reference int { @@ -122,8 +122,8 @@ std::string getDefaultConfigPath() { return _filepath + "\\foundationdb"; #elif defined(__linux__) return "/etc/foundationdb"; -#elif defined(__APPLE__) - return "/usr/local/etc/foundationdb"; +#elif defined(__APPLE__) || defined(__FreeBSD__) + return CONFDIR; #else #error Port me! #endif Index: head/databases/foundationdb/files/patch-fdbserver_fdbserver.actor.cpp =================================================================== --- head/databases/foundationdb/files/patch-fdbserver_fdbserver.actor.cpp (revision 471192) +++ head/databases/foundationdb/files/patch-fdbserver_fdbserver.actor.cpp (revision 471193) @@ -1,37 +1,37 @@ ---- fdbserver/fdbserver.actor.cpp.orig 2018-04-19 02:55:50 UTC +--- fdbserver/fdbserver.actor.cpp.orig 2018-05-11 01:30:59 UTC +++ fdbserver/fdbserver.actor.cpp -@@ -59,7 +59,7 @@ +@@ -60,7 +60,7 @@ #define BOOST_DATE_TIME_NO_LIB #include -#ifdef __linux__ +#if defined(__linux__) || defined(__FreeBSD__) #include #include #ifdef ALLOC_INSTRUMENTATION -@@ -72,6 +72,7 @@ +@@ -73,6 +73,7 @@ #endif #include "flow/SimpleOpt.h" +#include enum { OPT_CONNFILE, OPT_SEEDCONNFILE, OPT_SEEDCONNSTRING, OPT_ROLE, OPT_LISTEN, OPT_PUBLICADDR, OPT_DATAFOLDER, OPT_LOGFOLDER, OPT_PARENTPID, OPT_NEWCONSOLE, OPT_NOBOX, OPT_TESTFILE, OPT_RESTARTING, OPT_RANDOMSEED, OPT_KEY, OPT_MEMLIMIT, OPT_STORAGEMEMLIMIT, OPT_MACHINEID, OPT_DCID, OPT_MACHINE_CLASS, OPT_BUGGIFY, OPT_VERSION, OPT_CRASHONERROR, OPT_HELP, OPT_NETWORKIMPL, OPT_NOBUFSTDOUT, OPT_BUFSTDOUTERR, OPT_TRACECLOCK, OPT_NUMTESTERS, OPT_DEVHELP, OPT_ROLLSIZE, OPT_MAXLOGS, OPT_MAXLOGSSIZE, OPT_KNOB, OPT_TESTSERVERS, OPT_TEST_ON_SERVERS, OPT_METRICSCONNFILE, OPT_METRICSPREFIX, -@@ -350,7 +351,7 @@ public: +@@ -351,7 +352,7 @@ class WorldReadablePermissions { (public) throw platform_error(); } permission.set_permissions( &sa ); -#elif (defined(__linux__) || defined(__APPLE__)) +#elif (defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__)) // There is nothing to do here, since the default permissions are fine #else #error Port me! -@@ -360,7 +361,7 @@ public: +@@ -361,7 +362,7 @@ class WorldReadablePermissions { (public) virtual ~WorldReadablePermissions() { #ifdef _WIN32 LocalFree( sa.lpSecurityDescriptor ); -#elif (defined(__linux__) || defined(__APPLE__)) +#elif (defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__)) // There is nothing to do here, since the default permissions are fine #else #error Port me! Index: head/databases/foundationdb/files/patch-fdbserver_worker.actor.cpp =================================================================== --- head/databases/foundationdb/files/patch-fdbserver_worker.actor.cpp (revision 471192) +++ head/databases/foundationdb/files/patch-fdbserver_worker.actor.cpp (revision 471193) @@ -1,38 +1,38 @@ ---- fdbserver/worker.actor.cpp.orig 2018-04-26 12:45:22 UTC +--- fdbserver/worker.actor.cpp.orig 2018-05-11 01:30:59 UTC +++ fdbserver/worker.actor.cpp @@ -39,7 +39,7 @@ #include "fdbclient/ClientWorkerInterface.h" #include "flow/Profiler.h" -#ifdef __linux__ +#if defined(__linux__) || defined(__FreeBSD__) #ifdef USE_GPERFTOOLS #include "gperftools/profiler.h" #endif -@@ -267,7 +267,7 @@ ACTOR Future registrationClient( R +@@ -267,7 +267,7 @@ ACTOR Future registrationClient( Reference profiledThreads; @@ -279,7 +279,7 @@ int filter_in_thread(void *arg) { //Enables the calling thread to be profiled void registerThreadForProfiling() { -#if defined(__linux__) && defined(USE_GPERFTOOLS) +#if (defined(__linux__) || defined(__FreeBSD__)) && defined(USE_GPERFTOOLS) //Not sure if this is actually needed, but a call to backtrace was advised here: //http://groups.google.com/group/google-perftools/browse_thread/thread/0dfd74532e038eb8/2686d9f24ac4365f?pli=1 profiledThreads.insert(std::this_thread::get_id()); @@ -293,7 +293,7 @@ void registerThreadForProfiling() { void updateCpuProfiler(ProfilerRequest req) { switch (req.type) { case ProfilerRequest::Type::GPROF: -#if defined(__linux__) && defined(USE_GPERFTOOLS) && !defined(VALGRIND) +#if (defined(__linux__) || defined(__FreeBSD__)) && defined(USE_GPERFTOOLS) && !defined(VALGRIND) switch (req.action) { case ProfilerRequest::Action::ENABLE: { const char *path = (const char*)req.outputFile.begin(); Index: head/databases/foundationdb/files/patch-flow_Deque.h =================================================================== --- head/databases/foundationdb/files/patch-flow_Deque.h (revision 471192) +++ head/databases/foundationdb/files/patch-flow_Deque.h (revision 471193) @@ -1,23 +1,23 @@ ---- flow/Deque.h.orig 2018-04-22 14:36:29 UTC +--- flow/Deque.h.orig 2018-05-11 01:30:59 UTC +++ flow/Deque.h -@@ -166,7 +166,7 @@ private: +@@ -166,7 +166,7 @@ class Deque { (private) new (&newArr[i - begin]) T(std::move(arr[i&mask])); arr[i&mask].~T(); } - aligned_free(arr); + free(arr); arr = newArr; end -= begin; begin = 0; -@@ -177,8 +177,8 @@ private: +@@ -177,8 +177,8 @@ class Deque { (private) for (int i = begin; i != end; i++) arr[i&mask].~T(); if(arr) - aligned_free(arr); + free(arr); } }; -#endif \ No newline at end of file +#endif Index: head/databases/foundationdb/files/patch-flow_Net2.actor.cpp =================================================================== --- head/databases/foundationdb/files/patch-flow_Net2.actor.cpp (revision 471192) +++ head/databases/foundationdb/files/patch-flow_Net2.actor.cpp (revision 471193) @@ -1,21 +1,21 @@ ---- flow/Net2.actor.cpp.orig 2018-04-19 02:55:50 UTC +--- flow/Net2.actor.cpp.orig 2018-05-11 01:30:59 UTC +++ flow/Net2.actor.cpp -@@ -56,7 +56,7 @@ uint64_t compatibleProtocolVersionMask = +@@ -56,7 +56,7 @@ uint64_t compatibleProtocolVersionMask = 0xfffffffffff uint64_t minValidProtocolVersion = 0x0FDB00A200060001LL; -#if defined(__linux__) +#if defined(__linux__) || defined(__FreeBSD__) #include volatile double net2liveness = 0; -@@ -403,8 +403,7 @@ private: +@@ -403,8 +403,7 @@ class Connection : public IConnection, ReferenceCounte void init() { // Socket settings that have to be set after connect or accept succeeds - boost::asio::socket_base::non_blocking_io nbio(true); - socket.io_control(nbio); + socket.non_blocking(true); socket.set_option(boost::asio::ip::tcp::no_delay(true)); } Index: head/databases/foundationdb/files/patch-flow_Platform.cpp =================================================================== --- head/databases/foundationdb/files/patch-flow_Platform.cpp (revision 471192) +++ head/databases/foundationdb/files/patch-flow_Platform.cpp (revision 471193) @@ -1,304 +1,305 @@ ---- flow/Platform.cpp.orig 2018-04-19 02:55:50 UTC +--- flow/Platform.cpp.orig 2018-05-11 01:30:59 UTC +++ flow/Platform.cpp @@ -71,6 +71,7 @@ #include #include +#include #include #include #include -@@ -119,6 +120,12 @@ +@@ -119,7 +120,13 @@ #include #endif +#ifdef __FreeBSD__ +#include +#include +#include +#include -+#endif #endif ++#endif std::string removeWhitespace(const std::string &t) + { @@ -198,7 +205,7 @@ double getProcessorTimeThread() { throw platform_error(); } return FiletimeAsInt64(ftKernel) / double(1e7) + FiletimeAsInt64(ftUser) / double(1e7); -#elif defined(__linux__) +#elif defined(__linux__) || defined(__FreeBSD__) return getProcessorTimeGeneric(RUSAGE_THREAD); #elif defined(__APPLE__) /* No RUSAGE_THREAD so we use the lower level interface */ @@ -266,6 +273,14 @@ uint64_t getResidentMemoryUsage() { throw platform_error(); } return info.resident_size; +#elif defined(__FreeBSD__) + struct rusage rusage; + + if (getrusage(RUSAGE_SELF | RUSAGE_THREAD, &rusage) == 0) { + return rusage.ru_maxrss; + } + + return 0; #else #warning getMemoryUsage unimplemented on this platform return 0; @@ -304,7 +319,7 @@ uint64_t getMemoryUsage() { } return info.virtual_size; #else - #warning getMemoryUsage unimplemented on this platform + //#warning getMemoryUsage unimplemented on this platform 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; +#elif defined(__FreeBSD__) + size_t len; + int pagesize = getpagesize(), free_pages; + u_long total; + + len = sizeof(total); + if (sysctlbyname("hw.physmem", &total, &len, NULL, 0) == -1) + total = 0; + + total = total / 1024; + + len = sizeof(free_pages); + if((sysctlbyname("vm.stats.vm.v_free_count", &free_pages, &len, NULL, 0) == -1) || !len) + free_pages = 0; + + memInfo.total = total; + memInfo.available = (pagesize / 1024) * free_pages; + memInfo.committed = memInfo.total - memInfo.available; #else #warning getMachineRAMInfo unimplemented on this platform #endif -@@ -435,7 +468,7 @@ void getMachineRAMInfo(MachineRAMInfo& m +@@ -435,7 +468,7 @@ void getMachineRAMInfo(MachineRAMInfo& memInfo) { void getDiskBytes(std::string const& directory, int64_t& free, int64_t& total) { INJECT_FAULT( platform_error, "getDiskBytes" ); #if defined(__unixish__) -#ifdef __linux__ +#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 +@@ -477,7 +510,7 @@ void getDiskBytes(std::string const& directory, int64_ #endif } -#ifdef __unixish__ +#if defined(__linux__) || defined(__APPLE__) 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) { #endif +#ifdef __FreeBSD__ +void getNetworkTraffic(uint32_t ip, uint64_t& bytesSent, uint64_t& bytesReceived, + uint64_t& outSegs, uint64_t& retransSegs) { + bytesReceived = 0; + bytesSent = 0; + outSegs = 0; + retransSegs = 0; +} + +void getMachineLoad(uint64_t& idleTime, uint64_t& totalTime) { + idleTime = 0; + totalTime = 0; +} + +void getDiskStatistics(std::string const& directory, uint64_t& currentIOs, uint64_t& busyTicks, uint64_t& reads, uint64_t& writes, uint64_t& writeSectors, uint64_t& readSectors) { + currentIOs = 0; + busyTicks = 0; + writes = 0; + reads = 0; + writeSectors = 0; + readSectors = 0; +} +#endif + #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 { return offset + count * secondsPerCount; } }; -#elif defined(__linux__) +#elif defined(__linux__) || defined(__FreeBSD__) #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() { GetSystemTimeAsFileTime(&fileTime); static_assert( sizeof(fileTime) == sizeof(uint64_t), "FILETIME size wrong" ); return (*(uint64_t*)&fileTime - FILETIME_C_EPOCH) * 100e-9; -#elif defined(__linux__) +#elif defined(__linux__) || defined(__FreeBSD__) 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() { GetSystemTimeAsFileTime(&fileTime); static_assert( sizeof(fileTime) == sizeof(uint64_t), "FILETIME size wrong" ); return (*(uint64_t*)&fileTime - FILETIME_C_EPOCH); -#elif defined(__linux__) +#elif defined(__linux__) || defined(__FreeBSD__) 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 +@@ -1481,7 +1538,7 @@ static void *allocateInternal(size_t length, bool larg flags |= MAP_HUGETLB; return mmap(NULL, length, PROT_READ|PROT_WRITE, flags, -1, 0); -#elif defined(__APPLE__) +#elif defined(__APPLE__) || defined(__FreeBSD__) 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) { CPU_ZERO(&set); CPU_SET(proc, &set); sched_setaffinity(0, sizeof(cpu_set_t), &set); +#elif defined(__FreeBSD__) + cpuset_t set; + CPU_ZERO(&set); + CPU_SET(proc, &set); + cpuset_setaffinity(CPU_LEVEL_WHICH, CPU_WHICH_PID, -1, sizeof(set), &set); #endif } -@@ -1615,7 +1677,7 @@ void renameFile( std::string const& from +@@ -1615,7 +1677,7 @@ void renameFile( std::string const& fromPath, std::str //renamedFile(); return; } -#elif (defined(__linux__) || defined(__APPLE__)) +#elif (defined(__linux__) || defined(__APPLE__)) || defined(__FreeBSD__) 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& +@@ -1733,7 +1795,7 @@ bool createDirectory( std::string const& directory ) { } TraceEvent(SevError, "CreateDirectory").detail("Directory", directory).GetLastError(); throw platform_error(); -#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& +@@ -1774,7 +1836,7 @@ std::string abspath( std::string const& filename ) { if (*x == '/') *x = CANONICAL_PATH_SEPARATOR; return nameBuffer; -#elif (defined(__linux__) || defined(__APPLE__)) +#elif (defined(__linux__) || defined(__APPLE__)) || defined(__FreeBSD__) char result[PATH_MAX]; auto r = realpath( filename.c_str(), result ); if (!r) { @@ -1839,7 +1901,7 @@ std::string getUserHomeDirectory() { #ifdef _WIN32 #define FILE_ATTRIBUTE_DATA DWORD -#elif (defined(__linux__) || defined(__APPLE__)) +#elif (defined(__linux__) || defined(__APPLE__)) || defined(__FreeBSD__) #define FILE_ATTRIBUTE_DATA mode_t #else #error Port me! @@ -1848,7 +1910,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); -#elif (defined(__linux__) || defined(__APPLE__)) +#elif (defined(__linux__) || defined(__APPLE__)) || defined(__FreeBSD__) return S_ISREG(fileAttributes) && StringRef(name).endsWith(extension); #else #error Port me! -@@ -1858,7 +1920,7 @@ bool acceptFile( FILE_ATTRIBUTE_DATA fil +@@ -1858,7 +1920,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; -#elif (defined(__linux__) || defined(__APPLE__)) +#elif (defined(__linux__) || defined(__APPLE__)) || defined(__FreeBSD__) return S_ISDIR(fileAttributes); #else #error Port me! -@@ -1894,7 +1956,7 @@ std::vector findFiles( std: +@@ -1894,7 +1956,7 @@ std::vector findFiles( std::string const& } FindClose(h); } -#elif (defined(__linux__) || defined(__APPLE__)) +#elif (defined(__linux__) || defined(__APPLE__)) || defined(__FreeBSD__) DIR *dip; if ((dip = opendir(directory.c_str())) != NULL) { -@@ -1958,7 +2020,7 @@ void findFilesRecursively(std::string pa +@@ -1958,7 +2020,7 @@ void findFilesRecursively(std::string path, std::vecto void threadSleep( double seconds ) { #ifdef _WIN32 Sleep( (DWORD)(seconds * 1e3) ); -#elif (defined(__linux__) || defined(__APPLE__)) +#elif (defined(__linux__) || defined(__APPLE__)) || defined(__FreeBSD__) struct timespec req, rem; req.tv_sec = seconds; -@@ -1996,7 +2058,7 @@ void makeTemporary( const char* filename +@@ -1996,7 +2058,7 @@ void makeTemporary( const char* filename ) { THREAD_HANDLE startThread(void (*func) (void *), void *arg) { return (void *)_beginthread(func, 0, arg); } -#elif (defined(__linux__) || defined(__APPLE__)) +#elif (defined(__linux__) || defined(__APPLE__)) || defined(__FreeBSD__) 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) +@@ -2009,7 +2071,7 @@ THREAD_HANDLE startThread(void *(*func) (void *), void void waitThread(THREAD_HANDLE thread) { #ifdef _WIN32 WaitForSingleObject(thread, INFINITE); -#elif (defined(__linux__) || defined(__APPLE__)) +#elif (defined(__linux__) || defined(__APPLE__)) || defined(__FreeBSD__) pthread_join(thread, NULL); #else #error Port me! -@@ -2038,7 +2100,7 @@ int64_t fileSize(std::string const& file +@@ -2038,7 +2100,7 @@ int64_t fileSize(std::string const& filename) { return 0; else return file_status.st_size; -#elif (defined(__linux__) || defined(__APPLE__)) +#elif (defined(__linux__) || defined(__APPLE__)) || defined(__FreeBSD__) struct stat file_status; if(stat(filename.c_str(), &file_status) != 0) return 0; -@@ -2181,6 +2243,8 @@ std::string getDefaultPluginPath( const +@@ -2181,6 +2243,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 ); +#elif defined(__FreeBSD__) + return format( "/usr/local/lib/foundationdb/plugins/%s.so", plugin_name ); #else #error Port me! #endif @@ -2430,7 +2494,7 @@ void* getImageOffset() { return NULL; } #endif bool isLibraryLoaded(const char* lib_path) { -#if !defined(__linux__) && !defined(__APPLE__) && !defined(_WIN32) +#if !defined(__linux__) && !defined(__APPLE__) && !defined(_WIN32) && !defined(__FreeBSD__) #error Port me! #endif -@@ -2446,7 +2510,7 @@ bool isLibraryLoaded(const char* lib_pat +@@ -2446,7 +2510,7 @@ bool isLibraryLoaded(const char* lib_path) { } void* loadLibrary(const char* lib_path) { -#if !defined(__linux__) && !defined(__APPLE__) && !defined(_WIN32) +#if !defined(__linux__) && !defined(__APPLE__) && !defined(_WIN32) && !defined(__FreeBSD__) #error Port me! #endif Index: head/databases/foundationdb/files/patch-flow_Platform.h =================================================================== --- head/databases/foundationdb/files/patch-flow_Platform.h (revision 471192) +++ head/databases/foundationdb/files/patch-flow_Platform.h (revision 471193) @@ -1,20 +1,20 @@ ---- flow/Platform.h.orig 2018-04-22 14:30:05 UTC +--- flow/Platform.h.orig 2018-05-11 01:30:59 UTC +++ flow/Platform.h @@ -22,7 +22,7 @@ #define FLOW_PLATFORM_H #pragma once -#if (defined(__linux__) || defined(__APPLE__)) +#if (defined(__linux__) || defined(__APPLE__)) || defined(__FreeBSD__) #define __unixish__ 1 #endif -@@ -183,6 +183,8 @@ THREAD_HANDLE startThread(void *(func) ( +@@ -182,6 +182,8 @@ THREAD_HANDLE startThread(void *(func) (void *), void + #if defined(_WIN32) #define DYNAMIC_LIB_EXT ".dll" #elif defined(__linux) - #define DYNAMIC_LIB_EXT ".so" -+#elif defined(__FreeBSD__) +#define DYNAMIC_LIB_EXT ".so" ++#elif defined(__FreeBSD__) + #define DYNAMIC_LIB_EXT ".so" #elif defined(__APPLE__) #define DYNAMIC_LIB_EXT ".dylib" - #else Index: head/databases/foundationdb/files/patch-flow_ThreadPrimitives.cpp =================================================================== --- head/databases/foundationdb/files/patch-flow_ThreadPrimitives.cpp (revision 471192) +++ head/databases/foundationdb/files/patch-flow_ThreadPrimitives.cpp (revision 471193) @@ -1,38 +1,38 @@ ---- flow/ThreadPrimitives.cpp.orig 2018-04-24 15:27:55 UTC +--- flow/ThreadPrimitives.cpp.orig 2018-05-11 01:30:59 UTC +++ flow/ThreadPrimitives.cpp -@@ -37,7 +37,7 @@ extern std::string format( const char *f +@@ -37,7 +37,7 @@ extern std::string format( const char *form, ... ); Event::Event() { #ifdef _WIN32 ev = CreateEvent(NULL, FALSE, FALSE, NULL); -#elif defined(__linux__) +#elif defined(__linux__) || defined(__FreeBSD__) int result = sem_init(&sem, 0, 0); if (result) criticalError(FDB_EXIT_INIT_SEMAPHORE, "UnableToInitializeSemaphore", format("Could not initialize semaphore - %s", strerror(errno)).c_str()); @@ -54,7 +54,7 @@ Event::Event() { Event::~Event() { #ifdef _WIN32 CloseHandle(ev); -#elif defined(__linux__) +#elif defined(__linux__) || defined(__FreeBSD__) sem_destroy(&sem); #elif defined(__APPLE__) semaphore_destroy(self, sem); @@ -66,7 +66,7 @@ Event::~Event() { void Event::set() { #ifdef _WIN32 SetEvent(ev); -#elif defined(__linux__) +#elif defined(__linux__) || defined(__FreeBSD__) sem_post(&sem); #elif defined(__APPLE__) semaphore_signal(sem); @@ -78,7 +78,7 @@ void Event::set() { void Event::block() { #ifdef _WIN32 WaitForSingleObject(ev, INFINITE); -#elif defined(__linux__) +#elif defined(__linux__) || defined(__FreeBSD__) int ret; do { ret = sem_wait(&sem); Index: head/databases/foundationdb/files/patch-flow_ThreadPrimitives.h =================================================================== --- head/databases/foundationdb/files/patch-flow_ThreadPrimitives.h (revision 471192) +++ head/databases/foundationdb/files/patch-flow_ThreadPrimitives.h (revision 471193) @@ -1,34 +1,34 @@ ---- flow/ThreadPrimitives.h.orig 2018-04-22 14:33:39 UTC +--- flow/ThreadPrimitives.h.orig 2018-05-11 01:30:59 UTC +++ flow/ThreadPrimitives.h @@ -25,7 +25,7 @@ #include "Error.h" #include "Trace.h" -#ifdef __linux__ +#if defined(__linux__) || defined(__FreeBSD__) #include #endif -@@ -63,11 +63,11 @@ public: +@@ -63,11 +63,11 @@ class ThreadSpinLock { (public) #endif } void leave() { -#if defined(__linux__) +#if defined(__linux__) || defined(__FreeBSD__) __sync_synchronize(); #endif isLocked = 0; -#if defined(__linux__) +#if defined(__linux__) || defined(__FreeBSD__) __sync_synchronize(); #endif #if VALGRIND -@@ -117,6 +117,8 @@ private: +@@ -116,6 +116,8 @@ class Event { (private) + #ifdef _WIN32 void* ev; #elif defined(__linux__) - sem_t sem; -+#elif defined(__FreeBSD__) + sem_t sem; ++#elif defined(__FreeBSD__) + sem_t sem; #elif defined(__APPLE__) mach_port_t self; - semaphore_t sem;