Index: head/databases/foundationdb/Makefile =================================================================== --- head/databases/foundationdb/Makefile (revision 477159) +++ head/databases/foundationdb/Makefile (revision 477160) @@ -1,60 +1,57 @@ # Created by: vanilla@ # $FreeBSD$ PORTNAME= foundationdb -PORTVERSION= 5.2.5 -#DISTVERSIONPREFIX= release- -PORTREVISION= 1 +PORTVERSION= 5.2.8 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 -BROKEN= fails to build with boost 1.68, see bug 229697 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/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 477159) +++ head/databases/foundationdb/distinfo (revision 477160) @@ -1,3 +1,3 @@ -TIMESTAMP = 1529928229 -SHA256 (apple-foundationdb-5.2.5_GH0.tar.gz) = 25056568dfe283456f5b6b6ff822db133ecafc78319a29b6243c536f357d13b5 -SIZE (apple-foundationdb-5.2.5_GH0.tar.gz) = 4495658 +TIMESTAMP = 1534256583 +SHA256 (apple-foundationdb-5.2.8_GH0.tar.gz) = c276c91a8bfc6f6aaeceeec26f4b3d5a79d806c7a4e66a9138e3299a232eede1 +SIZE (apple-foundationdb-5.2.8_GH0.tar.gz) = 4499309 Index: head/databases/foundationdb/files/patch-Makefile =================================================================== --- head/databases/foundationdb/files/patch-Makefile (revision 477159) +++ head/databases/foundationdb/files/patch-Makefile (revision 477160) @@ -1,77 +1,77 @@ ---- Makefile.orig 2018-05-11 01:30:59 UTC +--- Makefile.orig 2018-08-01 01:25:10 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:=/generated.mk) +@@ -101,7 +112,7 @@ CPP_MK_GENERATED := $(CPP_PROJECTS:=/gen 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 (revision 477159) +++ head/databases/foundationdb/files/patch-build_csprojtom4.py (revision 477160) @@ -1,55 +1,55 @@ ---- build/csprojtom4.py.orig 2018-05-31 02:58:48 UTC +--- build/csprojtom4.py.orig 2018-08-14 14:24:41 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('\\', +@@ -55,5 +55,5 @@ sources = [node.getAttribute("Include"). 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)) Index: head/databases/foundationdb/files/patch-build_vcxprojtom4.py =================================================================== --- head/databases/foundationdb/files/patch-build_vcxprojtom4.py (revision 477159) +++ head/databases/foundationdb/files/patch-build_vcxprojtom4.py (revision 477160) @@ -1,56 +1,56 @@ ---- build/vcxprojtom4.py.orig 2018-05-31 02:52:54 UTC +--- build/vcxprojtom4.py.orig 2018-08-14 14:24:41 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('\\', +@@ -70,4 +70,4 @@ sources = [node.getAttribute("Include"). 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))) Index: head/databases/foundationdb/files/patch-fdbbackup_local.mk =================================================================== --- head/databases/foundationdb/files/patch-fdbbackup_local.mk (revision 477159) +++ head/databases/foundationdb/files/patch-fdbbackup_local.mk (revision 477160) @@ -1,11 +1,11 @@ --- fdbbackup/local.mk.orig 2018-04-19 02:55:50 UTC +++ fdbbackup/local.mk @@ -34,6 +34,8 @@ ifeq ($(PLATFORM),linux) # fdbbackup_STATIC_LIBS += -ltcmalloc -lunwind -lprofiler else ifeq ($(PLATFORM),osx) fdbbackup_LDFLAGS += -lc++ +else ifeq ($(PLATFORM),freebsd) -+ fdbbackup_LDFLAGS += -lc++ -lm -lexecinfo -lpthread -leio ++ fdbbackup_LDFLAGS += -lc++ -lm -lexecinfo -lpthread -leio -lboost_system endif fdbbackup_GENERATED_SOURCES += versions.h Index: head/databases/foundationdb/files/patch-fdbcli_local.mk =================================================================== --- head/databases/foundationdb/files/patch-fdbcli_local.mk (revision 477159) +++ head/databases/foundationdb/files/patch-fdbcli_local.mk (revision 477160) @@ -1,20 +1,20 @@ --- fdbcli/local.mk.orig 2018-04-19 02:55:50 UTC +++ fdbcli/local.mk @@ -22,7 +22,7 @@ fdbcli_CFLAGS := $(fdbclient_CFLAGS) fdbcli_LDFLAGS := $(fdbrpc_LDFLAGS) -fdbcli_LIBS := lib/libfdbclient.a lib/libfdbrpc.a lib/libflow.a -ldl +fdbcli_LIBS := lib/libfdbclient.a lib/libfdbrpc.a lib/libflow.a fdbcli_STATIC_LIBS := fdbcli_GENERATED_SOURCES += versions.h @@ -32,6 +32,8 @@ ifeq ($(PLATFORM),linux) fdbcli_LIBS += -lpthread -lrt else ifeq ($(PLATFORM),osx) fdbcli_LDFLAGS += -lc++ +else ifeq ($(PLATFORM),freebsd) -+ fdbcli_LDFLAGS += -lc++ -lm -lpthread -leio -lexecinfo ++ fdbcli_LDFLAGS += -lc++ -lm -lpthread -leio -lexecinfo -lboost_system endif test_fdbcli_status: fdbcli Index: head/databases/foundationdb/files/patch-fdbclient_local.mk =================================================================== --- head/databases/foundationdb/files/patch-fdbclient_local.mk (revision 477159) +++ head/databases/foundationdb/files/patch-fdbclient_local.mk (revision 477160) @@ -1,11 +1,11 @@ --- fdbclient/local.mk.orig 2018-04-26 06:55:09 UTC +++ fdbclient/local.mk @@ -21,7 +21,7 @@ # -*- mode: makefile; -*- fdbclient_CFLAGS := $(fdbrpc_CFLAGS) - -+fdbclient_LIBS := -lm -lc++ -lpthread -lexecinfo -leio ++fdbclient_LIBS := -lm -lc++ -lpthread -lexecinfo -leio -lboost_system fdbclient_GENERATED_SOURCES += fdbclient/FDBOptions.g.h fdbclient/FDBOptions.g.cpp: fdbclient/FDBOptions.g.h Index: head/databases/foundationdb/files/patch-fdbmonitor_fdbmonitor.cpp =================================================================== --- head/databases/foundationdb/files/patch-fdbmonitor_fdbmonitor.cpp (revision 477159) +++ head/databases/foundationdb/files/patch-fdbmonitor_fdbmonitor.cpp (revision 477160) @@ -1,165 +1,165 @@ ---- fdbmonitor/fdbmonitor.cpp.orig 2018-05-11 01:30:59 UTC +--- fdbmonitor/fdbmonitor.cpp.orig 2018-08-01 01:25:10 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, int* maxfd, +@@ -83,7 +87,7 @@ void monitor_fd( fdb_fd_set list, int fd 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, int* maxfd, +@@ -94,7 +98,7 @@ void monitor_fd( fdb_fd_set list, int fd 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 CSimpleIni& ini, con +@@ -188,7 +192,7 @@ const char* get_value_multi(const CSimpl } 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, int pipe_idx, fd +@@ -822,7 +826,7 @@ void read_child_output( Command* cmd, in } } -#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_fd, std::strin +@@ -839,7 +843,7 @@ void watch_conf_dir( int kq, int* confd_ 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_fd, const cha +@@ -876,7 +880,7 @@ void watch_conf_file( int kq, int* conff } /* 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_IAsyncFile.actor.cpp =================================================================== --- head/databases/foundationdb/files/patch-fdbrpc_IAsyncFile.actor.cpp (revision 477159) +++ head/databases/foundationdb/files/patch-fdbrpc_IAsyncFile.actor.cpp (revision 477160) @@ -1,11 +1,11 @@ ---- fdbrpc/IAsyncFile.actor.cpp.orig 2018-05-11 01:30:59 UTC +--- fdbrpc/IAsyncFile.actor.cpp.orig 2018-08-01 01:25:10 UTC +++ fdbrpc/IAsyncFile.actor.cpp -@@ -42,7 +42,7 @@ ACTOR static Future zeroRangeHelper( Reference zeroRangeHelpe Void _ = wait( yield() ); } - aligned_free(zeros); + free(zeros); return Void(); } Index: head/databases/foundationdb/files/patch-fdbrpc_Platform.cpp =================================================================== --- head/databases/foundationdb/files/patch-fdbrpc_Platform.cpp (revision 477159) +++ head/databases/foundationdb/files/patch-fdbrpc_Platform.cpp (revision 477160) @@ -1,22 +1,22 @@ ---- fdbrpc/Platform.cpp.orig 2018-05-11 01:30:59 UTC +--- fdbrpc/Platform.cpp.orig 2018-08-01 01:25:10 UTC +++ fdbrpc/Platform.cpp -@@ -87,7 +87,7 @@ int eraseDirectoryRecursive(std::string const& dir) { +@@ -87,7 +87,7 @@ int eraseDirectoryRecursive(std::string __eraseDirectoryRecurseiveCount = 0; #ifdef _WIN32 system( ("rd /s /q \"" + dir + "\"").c_str() ); -#elif defined(__linux__) || defined(__APPLE__) +#elif defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__) int error = nftw(dir.c_str(), [](const char *fpath, const struct stat *sb, int typeflag, struct FTW *ftwbuf) -> 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-fdbrpc_local.mk =================================================================== --- head/databases/foundationdb/files/patch-fdbrpc_local.mk (revision 477159) +++ head/databases/foundationdb/files/patch-fdbrpc_local.mk (revision 477160) @@ -1,17 +1,17 @@ --- fdbrpc/local.mk.orig 2018-04-19 02:55:50 UTC +++ fdbrpc/local.mk @@ -20,10 +20,11 @@ # -*- mode: makefile; -*- -fdbrpc_BUILD_SOURCES += fdbrpc/libeio/eio.c +#fdbrpc_BUILD_SOURCES += fdbrpc/libeio/eio.c -fdbrpc_CFLAGS := -I$(BOOSTDIR) -I. -Ifdbrpc -Ifdbrpc/libeio -DUSE_UCONTEXT -fdbrpc_LDFLAGS := +fdbrpc_CFLAGS := -I$(BOOSTDIR)/include -I. -Ifdbrpc -Ifdbrpc/libeio -DUSE_UCONTEXT +fdbrpc_LDFLAGS := -L$(BOOSTDIR)/lib -+fdbrpc_LIBS := -lm -lc++ -lpthread -leio ++fdbrpc_LIBS := -lm -lc++ -lpthread -leio -lboost_system ifeq ($(PLATFORM),osx) fdbrpc_CFLAGS += -fasynchronous-unwind-tables -fno-omit-frame-pointer Index: head/databases/foundationdb/files/patch-fdbserver_fdbserver.actor.cpp =================================================================== --- head/databases/foundationdb/files/patch-fdbserver_fdbserver.actor.cpp (revision 477159) +++ head/databases/foundationdb/files/patch-fdbserver_fdbserver.actor.cpp (revision 477160) @@ -1,37 +1,37 @@ ---- fdbserver/fdbserver.actor.cpp.orig 2018-05-11 01:30:59 UTC +--- fdbserver/fdbserver.actor.cpp.orig 2018-08-01 01:25:10 UTC +++ fdbserver/fdbserver.actor.cpp @@ -60,7 +60,7 @@ #define BOOST_DATE_TIME_NO_LIB #include -#ifdef __linux__ +#if defined(__linux__) || defined(__FreeBSD__) #include #include #ifdef ALLOC_INSTRUMENTATION @@ -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, -@@ -351,7 +352,7 @@ class WorldReadablePermissions { (public) +@@ -351,7 +352,7 @@ 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! -@@ -361,7 +362,7 @@ class WorldReadablePermissions { (public) +@@ -361,7 +362,7 @@ 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_local.mk =================================================================== --- head/databases/foundationdb/files/patch-fdbserver_local.mk (revision 477159) +++ head/databases/foundationdb/files/patch-fdbserver_local.mk (revision 477160) @@ -1,11 +1,11 @@ --- fdbserver/local.mk.orig 2018-04-19 02:55:50 UTC +++ fdbserver/local.mk @@ -34,6 +34,8 @@ ifeq ($(PLATFORM),linux) # fdbserver_STATIC_LIBS += -ltcmalloc -lunwind -lprofiler else ifeq ($(PLATFORM),osx) fdbserver_LDFLAGS += -lc++ +else ifeq ($(PLATFORM),freebsd) -+ fdbserver_LDFLAGS += -lc++ -lm -lpthread -lexecinfo -leio ++ fdbserver_LDFLAGS += -lc++ -lm -lpthread -lexecinfo -leio -lboost_system endif ifeq ($(WORKLOADS),false) Index: head/databases/foundationdb/files/patch-fdbserver_worker.actor.cpp =================================================================== --- head/databases/foundationdb/files/patch-fdbserver_worker.actor.cpp (revision 477159) +++ head/databases/foundationdb/files/patch-fdbserver_worker.actor.cpp (revision 477160) @@ -1,38 +1,38 @@ ---- fdbserver/worker.actor.cpp.orig 2018-05-11 01:30:59 UTC +--- fdbserver/worker.actor.cpp.orig 2018-08-01 01:25:10 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( Reference registrationClient( R } } -#if defined(__linux__) && defined(USE_GPERFTOOLS) +#if (defined(__linux__) || defined(__FreeBSD__)) && defined(USE_GPERFTOOLS) //A set of threads that should be profiled std::set 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 477159) +++ head/databases/foundationdb/files/patch-flow_Deque.h (revision 477160) @@ -1,23 +1,23 @@ ---- flow/Deque.h.orig 2018-05-11 01:30:59 UTC +--- flow/Deque.h.orig 2018-08-01 01:25:10 UTC +++ flow/Deque.h -@@ -166,7 +166,7 @@ class Deque { (private) +@@ -166,7 +166,7 @@ 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 @@ class Deque { (private) +@@ -177,8 +177,8 @@ 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 477159) +++ head/databases/foundationdb/files/patch-flow_Net2.actor.cpp (revision 477160) @@ -1,21 +1,21 @@ ---- flow/Net2.actor.cpp.orig 2018-05-11 01:30:59 UTC +--- flow/Net2.actor.cpp.orig 2018-08-01 01:25:10 UTC +++ flow/Net2.actor.cpp -@@ -56,7 +56,7 @@ uint64_t compatibleProtocolVersionMask = 0xfffffffffff +@@ -56,7 +56,7 @@ uint64_t compatibleProtocolVersionMask = uint64_t minValidProtocolVersion = 0x0FDB00A200060001LL; -#if defined(__linux__) +#if defined(__linux__) || defined(__FreeBSD__) #include volatile double net2liveness = 0; -@@ -403,8 +403,7 @@ class Connection : public IConnection, ReferenceCounte +@@ -403,8 +403,7 @@ private: 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 477159) +++ head/databases/foundationdb/files/patch-flow_Platform.cpp (revision 477160) @@ -1,305 +1,304 @@ ---- flow/Platform.cpp.orig 2018-05-11 01:30:59 UTC +--- flow/Platform.cpp.orig 2018-08-01 01:25:10 UTC +++ flow/Platform.cpp @@ -71,6 +71,7 @@ #include #include +#include #include #include #include -@@ -119,7 +120,13 @@ +@@ -119,6 +120,12 @@ #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& memInfo) { +@@ -427,6 +442,24 @@ void getMachineRAMInfo(MachineRAMInfo& m 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& memInfo) { +@@ -435,7 +468,7 @@ void getMachineRAMInfo(MachineRAMInfo& m 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& directory, int64_ +@@ -477,7 +510,7 @@ void getDiskBytes(std::string const& dir #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 length, bool larg +@@ -1481,7 +1538,7 @@ static void *allocateInternal(size_t len 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& fromPath, std::str +@@ -1615,7 +1677,7 @@ void renameFile( std::string const& from //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& directory ) { +@@ -1733,7 +1795,7 @@ bool createDirectory( std::string const& } 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& filename ) { +@@ -1774,7 +1836,7 @@ std::string abspath( std::string const& 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 fileAttributes, s +@@ -1858,7 +1920,7 @@ bool acceptFile( FILE_ATTRIBUTE_DATA fil 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::string const& +@@ -1894,7 +1956,7 @@ std::vector findFiles( std: } 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 path, std::vecto +@@ -1958,7 +2020,7 @@ void findFilesRecursively(std::string pa 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) (void *), void +@@ -2009,7 +2071,7 @@ THREAD_HANDLE startThread(void *(*func) 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& filename) { +@@ -2038,7 +2100,7 @@ int64_t fileSize(std::string const& file 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 char* plugin_n +@@ -2181,6 +2243,8 @@ std::string getDefaultPluginPath( const 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_path) { +@@ -2446,7 +2510,7 @@ bool isLibraryLoaded(const char* lib_pat } 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 477159) +++ head/databases/foundationdb/files/patch-flow_Platform.h (revision 477160) @@ -1,20 +1,20 @@ ---- flow/Platform.h.orig 2018-05-11 01:30:59 UTC +--- flow/Platform.h.orig 2018-08-01 01:25:10 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 -@@ -182,6 +182,8 @@ THREAD_HANDLE startThread(void *(func) (void *), void - #if defined(_WIN32) +@@ -183,6 +183,8 @@ THREAD_HANDLE startThread(void *(func) ( #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 477159) +++ head/databases/foundationdb/files/patch-flow_ThreadPrimitives.cpp (revision 477160) @@ -1,38 +1,38 @@ ---- flow/ThreadPrimitives.cpp.orig 2018-05-11 01:30:59 UTC +--- flow/ThreadPrimitives.cpp.orig 2018-08-01 01:25:10 UTC +++ flow/ThreadPrimitives.cpp -@@ -37,7 +37,7 @@ extern std::string format( const char *form, ... ); +@@ -37,7 +37,7 @@ extern std::string format( const char *f 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 477159) +++ head/databases/foundationdb/files/patch-flow_ThreadPrimitives.h (revision 477160) @@ -1,34 +1,34 @@ ---- flow/ThreadPrimitives.h.orig 2018-05-11 01:30:59 UTC +--- flow/ThreadPrimitives.h.orig 2018-08-01 01:25:10 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 @@ class ThreadSpinLock { (public) +@@ -63,11 +63,11 @@ 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 -@@ -116,6 +116,8 @@ class Event { (private) - #ifdef _WIN32 +@@ -117,6 +117,8 @@ private: 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; Index: head/databases/foundationdb/files/patch-flow_libs_system_src_error__code.cpp =================================================================== --- head/databases/foundationdb/files/patch-flow_libs_system_src_error__code.cpp (revision 477159) +++ head/databases/foundationdb/files/patch-flow_libs_system_src_error__code.cpp (revision 477160) @@ -1,60 +1,81 @@ ---- flow/libs/system/src/error_code.cpp.orig 2018-04-19 02:55:50 UTC +--- flow/libs/system/src/error_code.cpp.orig 2018-08-01 01:25:10 UTC +++ flow/libs/system/src/error_code.cpp -@@ -48,7 +48,7 @@ namespace +@@ -15,6 +15,7 @@ + // the library is being built (possibly exporting rather than importing code) + #define BOOST_SYSTEM_SOURCE + ++#include + #include + #include + #include +@@ -37,6 +38,7 @@ using namespace boost::system::errc; + + //----------------------------------------------------------------------------// + ++#if BOOST_VERSION < 106800 + namespace + { + #if defined(__PGI) +@@ -48,7 +50,7 @@ namespace { public: generic_error_category(){} - const char * name() const; + const char * name() const BOOST_SYSTEM_NOEXCEPT; std::string message( int ev ) const; }; -@@ -56,14 +56,14 @@ namespace +@@ -56,14 +58,14 @@ namespace { public: system_error_category(){} - const char * name() const; + const char * name() const BOOST_SYSTEM_NOEXCEPT; std::string message( int ev ) const; - error_condition default_error_condition( int ev ) const; + error_condition default_error_condition( int ev ) const BOOST_SYSTEM_NOEXCEPT; }; // generic_error_category implementation ---------------------------------// - const char * generic_error_category::name() const + const char * generic_error_category::name() const BOOST_SYSTEM_NOEXCEPT { return "generic"; } -@@ -154,12 +154,12 @@ namespace +@@ -154,12 +156,12 @@ namespace } // system_error_category implementation --------------------------------// - const char * system_error_category::name() const + const char * system_error_category::name() const BOOST_SYSTEM_NOEXCEPT { return "system"; } - error_condition system_error_category::default_error_condition( int ev ) const + error_condition system_error_category::default_error_condition( int ev ) const BOOST_SYSTEM_NOEXCEPT { switch ( ev ) { -@@ -414,13 +414,13 @@ namespace boost +@@ -414,13 +416,13 @@ namespace boost // address for comparison purposes # endif - BOOST_SYSTEM_DECL const error_category & system_category() + BOOST_SYSTEM_DECL const error_category & system_category() BOOST_SYSTEM_NOEXCEPT { static const system_error_category system_category_const; return system_category_const; } - BOOST_SYSTEM_DECL const error_category & generic_category() + BOOST_SYSTEM_DECL const error_category & generic_category() BOOST_SYSTEM_NOEXCEPT { static const generic_error_category generic_category_const; return generic_category_const; +@@ -428,3 +430,4 @@ namespace boost + + } // namespace system + } // namespace boost ++#endif Index: head/databases/foundationdb/files/patch-flow_local.mk =================================================================== --- head/databases/foundationdb/files/patch-flow_local.mk (revision 477159) +++ head/databases/foundationdb/files/patch-flow_local.mk (revision 477160) @@ -1,14 +1,14 @@ --- flow/local.mk.orig 2018-04-19 02:55:50 UTC +++ flow/local.mk @@ -20,8 +20,9 @@ # -*- mode: makefile; -*- -flow_CFLAGS := -I$(BOOSTDIR) -I. -Iflow -DUSE_UCONTEXT -flow_LDFLAGS := +flow_CFLAGS := -I$(BOOSTDIR)/include -I. -Iflow -DUSE_UCONTEXT +flow_LDFLAGS := -L$(BOOSTDIR)/lib -+flow_LIBS := -lm -lc++ -lpthread -leio -lexecinfo ++flow_LIBS := -lm -lc++ -lpthread -leio -lexecinfo -lboost_system ifeq ($(PLATFORM),osx) flow_CFLAGS += -fasynchronous-unwind-tables -fno-omit-frame-pointer