svn commit: r468809 - in head/databases: . foundationdb foundationdb/files

Vanilla I. Shu vanilla at FreeBSD.org
Wed May 2 01:27:16 UTC 2018


Author: vanilla
Date: Wed May  2 01:27:12 2018
New Revision: 468809
URL: https://svnweb.freebsd.org/changeset/ports/468809

Log:
  Add foundationdb, yet another distributed database from apple.

Added:
  head/databases/foundationdb/
  head/databases/foundationdb/Makefile   (contents, props changed)
  head/databases/foundationdb/distinfo   (contents, props changed)
  head/databases/foundationdb/files/
  head/databases/foundationdb/files/foundationdb.in   (contents, props changed)
  head/databases/foundationdb/files/patch-FDBLibTLS_local.mk   (contents, props changed)
  head/databases/foundationdb/files/patch-Makefile   (contents, props changed)
  head/databases/foundationdb/files/patch-build_link-wrapper.sh   (contents, props changed)
  head/databases/foundationdb/files/patch-fdbbackup_local.mk   (contents, props changed)
  head/databases/foundationdb/files/patch-fdbcli_local.mk   (contents, props changed)
  head/databases/foundationdb/files/patch-fdbclient_MultiVersionAssignmentVars.h   (contents, props changed)
  head/databases/foundationdb/files/patch-fdbclient_NativeAPI.actor.cpp   (contents, props changed)
  head/databases/foundationdb/files/patch-fdbclient_local.mk   (contents, props changed)
  head/databases/foundationdb/files/patch-fdbmonitor_fdbmonitor.cpp   (contents, props changed)
  head/databases/foundationdb/files/patch-fdbmonitor_local.mk   (contents, props changed)
  head/databases/foundationdb/files/patch-fdbrpc_AsyncFileCached.actor.cpp   (contents, props changed)
  head/databases/foundationdb/files/patch-fdbrpc_AsyncFileCached.actor.h   (contents, props changed)
  head/databases/foundationdb/files/patch-fdbrpc_IAsyncFile.actor.cpp   (contents, props changed)
  head/databases/foundationdb/files/patch-fdbrpc_Platform.cpp   (contents, props changed)
  head/databases/foundationdb/files/patch-fdbrpc_local.mk   (contents, props changed)
  head/databases/foundationdb/files/patch-fdbserver_TLogServer.actor.cpp   (contents, props changed)
  head/databases/foundationdb/files/patch-fdbserver_VFSAsync.cpp   (contents, props changed)
  head/databases/foundationdb/files/patch-fdbserver_fdbserver.actor.cpp   (contents, props changed)
  head/databases/foundationdb/files/patch-fdbserver_local.mk   (contents, props changed)
  head/databases/foundationdb/files/patch-fdbserver_worker.actor.cpp   (contents, props changed)
  head/databases/foundationdb/files/patch-flow_Deque.h   (contents, props changed)
  head/databases/foundationdb/files/patch-flow_FastAlloc.cpp   (contents, props changed)
  head/databases/foundationdb/files/patch-flow_IThreadPool.cpp   (contents, props changed)
  head/databases/foundationdb/files/patch-flow_Net2.actor.cpp   (contents, props changed)
  head/databases/foundationdb/files/patch-flow_Platform.cpp   (contents, props changed)
  head/databases/foundationdb/files/patch-flow_Platform.h   (contents, props changed)
  head/databases/foundationdb/files/patch-flow_ThreadPrimitives.cpp   (contents, props changed)
  head/databases/foundationdb/files/patch-flow_ThreadPrimitives.h   (contents, props changed)
  head/databases/foundationdb/files/patch-flow_libs_system_src_error__code.cpp   (contents, props changed)
  head/databases/foundationdb/files/patch-flow_local.mk   (contents, props changed)
  head/databases/foundationdb/files/patch-foundationdb.conf   (contents, props changed)
  head/databases/foundationdb/pkg-descr   (contents, props changed)
  head/databases/foundationdb/pkg-plist   (contents, props changed)
Modified:
  head/databases/Makefile

Modified: head/databases/Makefile
==============================================================================
--- head/databases/Makefile	Wed May  2 01:24:27 2018	(r468808)
+++ head/databases/Makefile	Wed May  2 01:27:12 2018	(r468809)
@@ -76,6 +76,7 @@
     SUBDIR += firebird25-server
     SUBDIR += flamerobin
     SUBDIR += fortytwo-bdb
+    SUBDIR += foundationdb
     SUBDIR += fpc-dblib
     SUBDIR += fpc-fpindexer
     SUBDIR += fpc-gdbm

Added: head/databases/foundationdb/Makefile
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/databases/foundationdb/Makefile	Wed May  2 01:27:12 2018	(r468809)
@@ -0,0 +1,55 @@
+# Created by: vanilla@
+# $FreeBSD$
+
+PORTNAME=	foundationdb
+PORTVERSION=	5.1.7
+CATEGORIES=	databases
+
+MAINTAINER=	vanilla at 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=		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
+MAKE_ENV+=	PYTHON=${PYTHON_CMD}
+
+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 <bsd.port.mk>

Added: head/databases/foundationdb/distinfo
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/databases/foundationdb/distinfo	Wed May  2 01:27:12 2018	(r468809)
@@ -0,0 +1,3 @@
+TIMESTAMP = 1524403792
+SHA256 (apple-foundationdb-5.1.7_GH0.tar.gz) = 6dd8b391527fc8070c9714117e0ed2ced50d993b20d64f3f2981bf9ef8734870
+SIZE (apple-foundationdb-5.1.7_GH0.tar.gz) = 3982458

Added: head/databases/foundationdb/files/foundationdb.in
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/databases/foundationdb/files/foundationdb.in	Wed May  2 01:27:12 2018	(r468809)
@@ -0,0 +1,33 @@
+#!/bin/sh
+#
+# $FreeBSD$
+#
+
+# PROVIDE: founationdb
+# REQUIRE: LOGIN
+# BEFORE:  securelevel
+# KEYWORD: shutdown
+
+# Add the following line to /etc/rc.conf to enable `foundationdb':
+#
+#foundationdb_enable="YES"
+#
+# Define config file here to run with different config file:
+#
+#foundationdb_config="xxxxx"
+#
+
+. /etc/rc.subr
+
+name="foundationdb"
+rcvar="${name}_enable"
+trafficserver_enable=${trafficserver_enable:-"NO"}
+command=/usr/local/sbin/fdbmonitor
+pidfile="/var/run/fdbmonitor.pid"
+
+load_rc_config "$name"
+: ${foundationdb_enable="NO"}
+: ${foundationdb_config="%%PREFIX%%/etc/foundationdb/foundationdb.conf"}
+
+command_args="--conffile ${foundationdb_config} --lockfile ${pidfile} --daemonize"
+run_rc_command $1

Added: head/databases/foundationdb/files/patch-FDBLibTLS_local.mk
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/databases/foundationdb/files/patch-FDBLibTLS_local.mk	Wed May  2 01:27:12 2018	(r468809)
@@ -0,0 +1,12 @@
+--- FDBLibTLS/local.mk.orig	2018-04-19 02:55:50 UTC
++++ FDBLibTLS/local.mk
+@@ -1,6 +1,6 @@
+-FDBLibTLS_CFLAGS := -fPIC -I/usr/local/include -I$(BOOSTDIR)
+-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_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

Added: head/databases/foundationdb/files/patch-Makefile
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/databases/foundationdb/files/patch-Makefile	Wed May  2 01:27:12 2018	(r468809)
@@ -0,0 +1,77 @@
+--- Makefile.orig	2018-04-19 02:55:50 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
+ 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

Added: head/databases/foundationdb/files/patch-build_link-wrapper.sh
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/databases/foundationdb/files/patch-build_link-wrapper.sh	Wed May  2 01:27:12 2018	(r468809)
@@ -0,0 +1,34 @@
+--- build/link-wrapper.sh.orig	2018-04-25 15:16:53 UTC
++++ build/link-wrapper.sh
+@@ -8,6 +8,9 @@ case $1 in
+ 
+ 	if [ "$1" = "DynamicLibrary" ]; then
+ 	    OPTIONS="-shared"
++	    if [ "$PLATFORM" = "freebsd" ]; then
++		OPTIONS="$OPTIONS -Wl,-z,noexecstack -Wl,-soname,$( basename $3 )"
++	    fi
+ 	    if [ "$PLATFORM" = "linux" ]; then
+ 		OPTIONS="$OPTIONS -Wl,-z,noexecstack -Wl,-soname,$( basename $3 )"
+ 	    fi
+@@ -43,6 +46,11 @@ case $1 in
+ 	    case $1 in
+ 		Application)
+ 		    case $PLATFORM in
++			freebsd)
++			    objcopy --only-keep-debug $3 $3.debug
++			    if [ -z "${NOSTRIP}" ]; then strip --strip-debug --strip-unneeded $3; fi
++			    objcopy --add-gnu-debuglink=$3.debug $3
++			    ;;
+ 			linux)
+ 			    objcopy --only-keep-debug $3 $3.debug
+ 			    if [ -z "${NOSTRIP}" ]; then strip --strip-debug --strip-unneeded $3; fi
+@@ -62,6 +70,9 @@ case $1 in
+ 		DynamicLibrary)
+ 		    cp $3 $3-debug
+ 		    case $PLATFORM in
++			freebsd)
++			    if [ -z "${NOSTRIP}" ]; then strip --strip-all $3; fi
++			    ;;
+ 			linux)
+ 			    if [ -z "${NOSTRIP}" ]; then strip --strip-all $3; fi
+ 			    ;;

Added: head/databases/foundationdb/files/patch-fdbbackup_local.mk
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/databases/foundationdb/files/patch-fdbbackup_local.mk	Wed May  2 01:27:12 2018	(r468809)
@@ -0,0 +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
+ endif
+ 
+ fdbbackup_GENERATED_SOURCES += versions.h

Added: head/databases/foundationdb/files/patch-fdbcli_local.mk
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/databases/foundationdb/files/patch-fdbcli_local.mk	Wed May  2 01:27:12 2018	(r468809)
@@ -0,0 +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
+ endif
+ 
+ test_fdbcli_status: fdbcli

Added: head/databases/foundationdb/files/patch-fdbclient_MultiVersionAssignmentVars.h
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/databases/foundationdb/files/patch-fdbclient_MultiVersionAssignmentVars.h	Wed May  2 01:27:12 2018	(r468809)
@@ -0,0 +1,11 @@
+--- 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);
+ 		}
+ 	}

Added: head/databases/foundationdb/files/patch-fdbclient_NativeAPI.actor.cpp
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/databases/foundationdb/files/patch-fdbclient_NativeAPI.actor.cpp	Wed May  2 01:27:12 2018	(r468809)
@@ -0,0 +1,20 @@
+--- 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<LocationInfo>() );
+ }
+ 

Added: head/databases/foundationdb/files/patch-fdbclient_local.mk
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/databases/foundationdb/files/patch-fdbclient_local.mk	Wed May  2 01:27:12 2018	(r468809)
@@ -0,0 +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_GENERATED_SOURCES += fdbclient/FDBOptions.g.h
+ 
+ fdbclient/FDBOptions.g.cpp: fdbclient/FDBOptions.g.h

Added: head/databases/foundationdb/files/patch-fdbmonitor_fdbmonitor.cpp
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/databases/foundationdb/files/patch-fdbmonitor_fdbmonitor.cpp	Wed May  2 01:27:12 2018	(r468809)
@@ -0,0 +1,165 @@
+--- fdbmonitor/fdbmonitor.cpp.orig	2018-04-19 02:55:50 UTC
++++ fdbmonitor/fdbmonitor.cpp
+@@ -35,6 +35,10 @@
+ #include <linux/limits.h>
+ #endif
+ 
++#ifdef __FreeBSD__
++#include <sys/event.h>
++#endif
++
+ #ifdef __APPLE__
+ #include <sys/event.h>
+ #include <mach/mach.h>
+@@ -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
+ 	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
+ 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
+ }
+ 
+ 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
+ 	}
+ }
+ 
+-#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_
+ 		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
+ 	}
+ 
+ 	/* 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<int, std::unordered_s
+ 
+ int main(int argc, char** argv) {
+ 	std::string lockfile = "/var/run/fdbmonitor.pid";
+-	std::string _confpath = "/etc/foundationdb/foundationdb.conf";
++	std::string _confpath = std::string(PREFIX) + "/etc/foundationdb/foundationdb.conf";
+ 
+ 	std::vector<const char *> 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 );

Added: head/databases/foundationdb/files/patch-fdbmonitor_local.mk
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/databases/foundationdb/files/patch-fdbmonitor_local.mk	Wed May  2 01:27:12 2018	(r468809)
@@ -0,0 +1,11 @@
+--- fdbmonitor/local.mk.orig	2018-04-26 01:54:14 UTC
++++ fdbmonitor/local.mk
+@@ -27,6 +27,8 @@ ifeq ($(PLATFORM),linux)
+   fdbmonitor_LDFLAGS := -static-libstdc++ -static-libgcc -lrt
+ else ifeq ($(PLATFORM),osx)
+   fdbmonitor_LDFLAGS := -lc++
++else ifeq ($(PLATFORM),freebsd)
++  fdbmonitor_LDFLAGS := -lc++ -lm
+ endif
+ 
+ bin/fdbmonitor.debug: bin/fdbmonitor

Added: head/databases/foundationdb/files/patch-fdbrpc_AsyncFileCached.actor.cpp
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/databases/foundationdb/files/patch-fdbrpc_AsyncFileCached.actor.cpp	Wed May  2 01:27:12 2018	(r468809)
@@ -0,0 +1,20 @@
+--- fdbrpc/AsyncFileCached.actor.cpp.orig	2018-04-19 02:55:50 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<Void> AsyncFileCached::quiesce() 
+ AsyncFileCached::~AsyncFileCached() {
+ 	while ( !pages.empty() ) {
+ 		auto ok = pages.begin()->second->evict();
+-		ASSERT( ok );
++		ASSERT_ABORT( ok );
+ 	}
+ 	openFiles.erase( filename );
+ }

Added: head/databases/foundationdb/files/patch-fdbrpc_AsyncFileCached.actor.h
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/databases/foundationdb/files/patch-fdbrpc_AsyncFileCached.actor.h	Wed May  2 01:27:12 2018	(r468809)
@@ -0,0 +1,11 @@
+--- 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() {

Added: head/databases/foundationdb/files/patch-fdbrpc_IAsyncFile.actor.cpp
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/databases/foundationdb/files/patch-fdbrpc_IAsyncFile.actor.cpp	Wed May  2 01:27:12 2018	(r468809)
@@ -0,0 +1,11 @@
+--- fdbrpc/IAsyncFile.actor.cpp.orig	2018-04-25 15:06:34 UTC
++++ fdbrpc/IAsyncFile.actor.cpp
+@@ -42,7 +42,7 @@ ACTOR static Future<Void> zeroRangeHelpe
+ 		Void _ = wait( yield() );
+ 	}
+ 
+-	aligned_free(zeros);
++	free(zeros);
+ 	return Void();
+ }
+ 

Added: head/databases/foundationdb/files/patch-fdbrpc_Platform.cpp
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/databases/foundationdb/files/patch-fdbrpc_Platform.cpp	Wed May  2 01:27:12 2018	(r468809)
@@ -0,0 +1,22 @@
+--- fdbrpc/Platform.cpp.orig	2018-04-19 02:55:50 UTC
++++ fdbrpc/Platform.cpp
+@@ -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

Added: head/databases/foundationdb/files/patch-fdbrpc_local.mk
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/databases/foundationdb/files/patch-fdbrpc_local.mk	Wed May  2 01:27:12 2018	(r468809)
@@ -0,0 +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
+ 
+ ifeq ($(PLATFORM),osx)
+   fdbrpc_CFLAGS += -fasynchronous-unwind-tables -fno-omit-frame-pointer

Added: head/databases/foundationdb/files/patch-fdbserver_TLogServer.actor.cpp
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/databases/foundationdb/files/patch-fdbserver_TLogServer.actor.cpp	Wed May  2 01:27:12 2018	(r468809)
@@ -0,0 +1,11 @@
+--- 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) {

Added: head/databases/foundationdb/files/patch-fdbserver_VFSAsync.cpp
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/databases/foundationdb/files/patch-fdbserver_VFSAsync.cpp	Wed May  2 01:27:12 2018	(r468809)
@@ -0,0 +1,11 @@
+--- 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();
+ 			}
+ 		}

Added: head/databases/foundationdb/files/patch-fdbserver_fdbserver.actor.cpp
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/databases/foundationdb/files/patch-fdbserver_fdbserver.actor.cpp	Wed May  2 01:27:12 2018	(r468809)
@@ -0,0 +1,37 @@
+--- fdbserver/fdbserver.actor.cpp.orig	2018-04-19 02:55:50 UTC
++++ fdbserver/fdbserver.actor.cpp
+@@ -59,7 +59,7 @@
+ #define BOOST_DATE_TIME_NO_LIB
+ #include <boost/interprocess/managed_shared_memory.hpp>
+ 
+-#ifdef  __linux__
++#if defined(__linux__) || defined(__FreeBSD__)
+ #include <execinfo.h>
+ #include <signal.h>
+ #ifdef ALLOC_INSTRUMENTATION
+@@ -72,6 +72,7 @@
+ #endif
+ 
+ #include "flow/SimpleOpt.h"
++#include <fstream>
+ 
+ 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:
+ 			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:
+ 	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!

Added: head/databases/foundationdb/files/patch-fdbserver_local.mk
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/databases/foundationdb/files/patch-fdbserver_local.mk	Wed May  2 01:27:12 2018	(r468809)
@@ -0,0 +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
+ endif
+ 
+ ifeq ($(WORKLOADS),false)

Added: head/databases/foundationdb/files/patch-fdbserver_worker.actor.cpp
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/databases/foundationdb/files/patch-fdbserver_worker.actor.cpp	Wed May  2 01:27:12 2018	(r468809)
@@ -0,0 +1,38 @@
+--- fdbserver/worker.actor.cpp.orig	2018-04-26 12:45:22 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<Void> 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<std::thread::id> 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();

Added: head/databases/foundationdb/files/patch-flow_Deque.h
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/databases/foundationdb/files/patch-flow_Deque.h	Wed May  2 01:27:12 2018	(r468809)
@@ -0,0 +1,23 @@
+--- flow/Deque.h.orig	2018-04-22 14:36:29 UTC
++++ flow/Deque.h
+@@ -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 @@ 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

Added: head/databases/foundationdb/files/patch-flow_FastAlloc.cpp
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/databases/foundationdb/files/patch-flow_FastAlloc.cpp	Wed May  2 01:27:12 2018	(r468809)
@@ -0,0 +1,12 @@
+--- flow/FastAlloc.cpp.orig	2018-04-22 14:45:22 UTC
++++ flow/FastAlloc.cpp
+@@ -51,6 +51,9 @@
+ #elif defined(__APPLE__)
+ #pragma message "init_priority is not supported on this platform; will this be a problem?"
+ #define INIT_SEG
++#elif defined(__FreeBSD__)
++#pragma message "init_priority is not supported on this platform; will this be a problem?"
++#define INIT_SEG
+ #else
+ #error Where am I?
+ #endif

Added: head/databases/foundationdb/files/patch-flow_IThreadPool.cpp
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/databases/foundationdb/files/patch-flow_IThreadPool.cpp	Wed May  2 01:27:12 2018	(r468809)
@@ -0,0 +1,11 @@
+--- 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();

Added: head/databases/foundationdb/files/patch-flow_Net2.actor.cpp
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/databases/foundationdb/files/patch-flow_Net2.actor.cpp	Wed May  2 01:27:12 2018	(r468809)
@@ -0,0 +1,21 @@
+--- flow/Net2.actor.cpp.orig	2018-04-19 02:55:50 UTC
++++ flow/Net2.actor.cpp
+@@ -56,7 +56,7 @@ uint64_t compatibleProtocolVersionMask =
+ uint64_t minValidProtocolVersion       = 0x0FDB00A200060001LL;
+ 
+ 
+-#if defined(__linux__)
++#if defined(__linux__) || defined(__FreeBSD__)
+ #include <execinfo.h>
+ 
+ volatile double net2liveness = 0;
+@@ -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));
+ 	}
+ 

Added: head/databases/foundationdb/files/patch-flow_Platform.cpp
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/databases/foundationdb/files/patch-flow_Platform.cpp	Wed May  2 01:27:12 2018	(r468809)
@@ -0,0 +1,304 @@
+--- flow/Platform.cpp.orig	2018-04-19 02:55:50 UTC
++++ flow/Platform.cpp
+@@ -71,6 +71,7 @@
+ 
+ #include <dirent.h>
+ #include <sys/time.h>
++#include <sys/user.h>
+ #include <sys/mman.h>
+ #include <unistd.h>
+ #include <ftw.h>
+@@ -119,6 +120,12 @@
+ #include <IOKit/IOBSD.h>
+ #endif
+ 
++#ifdef __FreeBSD__
++#include <sys/param.h>
++#include <sys/sysctl.h>
++#include <sys/cpuset.h>
++#include <sys/resource.h>
++#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
+ 	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
+ 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
+ #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
+ 		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
+ 		//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();

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***


More information about the svn-ports-all mailing list