aboutsummaryrefslogtreecommitdiff
path: root/databases/foundationdb
diff options
context:
space:
mode:
authorDave Cottlehuber <dch@FreeBSD.org>2020-05-31 22:13:32 +0000
committerDave Cottlehuber <dch@FreeBSD.org>2020-05-31 22:13:32 +0000
commit595818230970081ef0aea4c111d8688fa15de3c5 (patch)
tree8f2ca1a001d292e0b08a3bd3d851fe752a5f154f /databases/foundationdb
parent42a8d22675f596626976940ea7b2221e03913764 (diff)
downloadports-595818230970081ef0aea4c111d8688fa15de3c5.tar.gz
ports-595818230970081ef0aea4c111d8688fa15de3c5.zip
databases/foundationdb: update to 6.3.0
- use new CMake build framework - build compatible C libraries by default - partial TLS support - drop upstreamed patches Sponsored by: SkunkWerks, GmbH
Notes
Notes: svn path=/head/; revision=537449
Diffstat (limited to 'databases/foundationdb')
-rw-r--r--databases/foundationdb/Makefile79
-rw-r--r--databases/foundationdb/distinfo6
-rw-r--r--databases/foundationdb/files/foundationdb.conf.in47
-rw-r--r--databases/foundationdb/files/foundationdb.in2
-rw-r--r--databases/foundationdb/files/patch-FDBLibTLS_local.mk10
-rw-r--r--databases/foundationdb/files/patch-Makefile68
-rw-r--r--databases/foundationdb/files/patch-build_link-wrapper.sh34
-rw-r--r--databases/foundationdb/files/patch-fdbbackup_local.mk11
-rw-r--r--databases/foundationdb/files/patch-fdbcli_local.mk15
-rw-r--r--databases/foundationdb/files/patch-fdbclient_local.mk11
-rw-r--r--databases/foundationdb/files/patch-fdbmonitor_fdbmonitor.cpp165
-rw-r--r--databases/foundationdb/files/patch-fdbmonitor_local.mk11
-rw-r--r--databases/foundationdb/files/patch-fdbrpc_AsyncFileCached.actor.cpp20
-rw-r--r--databases/foundationdb/files/patch-fdbrpc_IAsyncFile.actor.cpp11
-rw-r--r--databases/foundationdb/files/patch-fdbrpc_Platform.cpp22
-rw-r--r--databases/foundationdb/files/patch-fdbrpc_local.mk17
-rw-r--r--databases/foundationdb/files/patch-fdbserver_fdbserver.actor.cpp29
-rw-r--r--databases/foundationdb/files/patch-fdbserver_local.mk11
-rw-r--r--databases/foundationdb/files/patch-fdbserver_worker.actor.cpp38
-rw-r--r--databases/foundationdb/files/patch-flow_Deque.h20
-rw-r--r--databases/foundationdb/files/patch-flow_FastAlloc.cpp12
-rw-r--r--databases/foundationdb/files/patch-flow_Net2.actor.cpp33
-rw-r--r--databases/foundationdb/files/patch-flow_Platform.cpp306
-rw-r--r--databases/foundationdb/files/patch-flow_Platform.h20
-rw-r--r--databases/foundationdb/files/patch-flow_ThreadPrimitives.cpp38
-rw-r--r--databases/foundationdb/files/patch-flow_ThreadPrimitives.h34
-rw-r--r--databases/foundationdb/files/patch-flow_local.mk14
-rw-r--r--databases/foundationdb/files/patch-foundationdb.conf40
-rw-r--r--databases/foundationdb/pkg-descr15
-rw-r--r--databases/foundationdb/pkg-plist27
30 files changed, 134 insertions, 1032 deletions
diff --git a/databases/foundationdb/Makefile b/databases/foundationdb/Makefile
index f82ad1775360..380d1846b709 100644
--- a/databases/foundationdb/Makefile
+++ b/databases/foundationdb/Makefile
@@ -1,9 +1,7 @@
-# Created by: vanilla@
# $FreeBSD$
PORTNAME= foundationdb
-DISTVERSION= 6.1.8
-PORTREVISION= 6
+DISTVERSION= 6.3.0
CATEGORIES= databases
MAINTAINER= dch@FreeBSD.org
@@ -19,45 +17,64 @@ BUILD_DEPENDS= bash:shells/bash
LIB_DEPENDS= libboost_system.so:devel/boost-libs \
libeio.so:devel/libeio
-USES= compiler:c++14-lang gmake mono:build python:build shebangfix
+USES= compiler:c++17-lang cmake mono:build python:build shebangfix ssl
USE_GITHUB= yes
GH_ACCOUNT= apple
+GH_PROJECT= foundationdb
+USE_LDCONFIG= yes
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} TLS_DISABLED=yes
-CXXFLAGS+= -Wno-varargs -DTLS_DISABLED
-CFLAGS+= -Wno-implicit-int-float-conversion
-
-USERS= ${PORTNAME}
-GROUPS= ${PORTNAME}
+
+SHEBANG_FILES= bindings/c/generate_asm.py
+
+CMAKE_ARGS= -DOPENSSL_ROOT_DIR=${OPENSSLLIB}
+CMAKE_OFF= USE_DTRACE DISABLE_TLS
+
+USERS= foundationdb
+GROUPS= foundationdb
DBDIR?= /var/db/foundationdb
LOGDIR?= /var/log/foundationdb
-PLIST_SUB+= DB_USER=${USERS} \
+SUB_FDB= DB_USER=${USERS} \
DB_GROUP=${GROUPS} \
DB_DIR=${DBDIR} \
LOG_DIR=${LOGDIR}
+SUB_FILES+= foundationdb.conf
+SUB_LIST+= ${SUB_FDB}
+PLIST_SUB+= ${SUB_FDB}
post-patch:
- @${REINPLACE_CMD} -e 's|%%PREFIX%%|${PREFIX}|g' ${WRKSRC}/foundationdb.conf
- @${REINPLACE_CMD} -e 's|%%PREFIX%%|${PREFIX}|g' ${WRKSRC}/flow/Platform.cpp
-
+ ${REINPLACE_CMD} 's/OPENSSL_USE_STATIC_LIBS TRUE/OPENSSL_USE_STATIC_LIBS FALSE/' \
+ ${WRKSRC}/cmake/FDBComponents.cmake
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_DATA} ${WRKSRC}/lib/libfdbclient.a ${STAGEDIR}/${PREFIX}/lib
- ${INSTALL_DATA} ${WRKSRC}/lib/libfdbrpc.a ${STAGEDIR}/${PREFIX}/lib
- ${INSTALL_DATA} ${WRKSRC}/lib/libflow.a ${STAGEDIR}/${PREFIX}/lib
- @${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
- ${INSTALL_PROGRAM} ${WRKSRC}/bin/fdbmonitor ${STAGEDIR}${PREFIX}/sbin
- ${INSTALL_PROGRAM} ${WRKSRC}/bin/fdbserver ${STAGEDIR}${PREFIX}/sbin
- @${MKDIR} ${STAGEDIR}${DBDIR}
- @${MKDIR} ${STAGEDIR}${LOGDIR}
+ # commands on first line, dev tools on next two
+.for f in fdbbackup fdbcli fdbmonitor fdbserver \
+ actor_flamegraph fdb_c_performance_test fdb_c_ryw_benchmark \
+ fdb_c_txn_size_test fdb_flow_tester fdbconvert fdbdecode mako tutorial
+ ${INSTALL_PROGRAM} ${WRKDIR}/.build/bin/${f} ${STAGEDIR}${PREFIX}/bin/
+.endfor
+ # confirm with upstream if these are actually needed
+.for s in backup_agent dr_agent fastrestore_agent fdbr fdbrestore
+ ${RLN} ${STAGEDIR}${PREFIX}/bin/fdbbackup ${STAGEDIR}${PREFIX}/bin/${s}
+.endfor
+ # exposed libraries - confirm with upstream
+.for l in libfdb_c.so libfdb_flow.a libfdb_sqlite.a libfdbclient.a \
+ libfdbrpc.a libflow.a libthirdparty.a
+ ${STRIP_CMD} ${WRKDIR}/.build/lib/${l}
+ ${INSTALL_DATA} ${WRKDIR}/.build/lib/${l} ${STAGEDIR}/${PREFIX}/lib/
+.endfor
+ # exposed headers - confirm with upstream
+ ${MKDIR} ${STAGEDIR}${PREFIX}/include/foundationdb
+ ${INSTALL_DATA} ${WRKSRC}/bindings/c/foundationdb/fdb_c.h \
+ ${STAGEDIR}/${PREFIX}/include/foundationdb/
+ ${INSTALL_DATA} ${WRKSRC}/fdbclient/vexillographer/fdb.options \
+ ${STAGEDIR}/${PREFIX}/include/foundationdb/
+ ${INSTALL_DATA} ${WRKDIR}/.build/bindings/c/foundationdb/fdb_c_options.g.h \
+ ${STAGEDIR}/${PREFIX}/include/foundationdb/
+ # runtime related
+ ${MKDIR} ${STAGEDIR}${DBDIR} \
+ ${STAGEDIR}${LOGDIR} \
+ ${STAGEDIR}${PREFIX}/etc/foundationdb
+ ${INSTALL_DATA} ${WRKDIR}/foundationdb.conf \
+ ${STAGEDIR}${PREFIX}/etc/foundationdb/foundationdb.conf.sample
.include <bsd.port.mk>
diff --git a/databases/foundationdb/distinfo b/databases/foundationdb/distinfo
index 308386cbb967..7c2cd4c4e892 100644
--- a/databases/foundationdb/distinfo
+++ b/databases/foundationdb/distinfo
@@ -1,3 +1,3 @@
-TIMESTAMP = 1558679857
-SHA256 (apple-foundationdb-6.1.8_GH0.tar.gz) = 831a2d205b4e44cceac7acde46a1856c073fd2036066031ab77f9a6f52cd1b78
-SIZE (apple-foundationdb-6.1.8_GH0.tar.gz) = 4879159
+TIMESTAMP = 1590876916
+SHA256 (apple-foundationdb-6.3.0_GH0.tar.gz) = 307f99014fe0bb8fbb05399c303f5a7a5007ceee207810857a7b5e6a7df7c8e8
+SIZE (apple-foundationdb-6.3.0_GH0.tar.gz) = 5440880
diff --git a/databases/foundationdb/files/foundationdb.conf.in b/databases/foundationdb/files/foundationdb.conf.in
new file mode 100644
index 000000000000..5b47e46f2185
--- /dev/null
+++ b/databases/foundationdb/files/foundationdb.conf.in
@@ -0,0 +1,47 @@
+## foundationdb.conf
+##
+## Configuration file for FoundationDB server processes
+## Full documentation is available at
+## https://apple.github.io/foundationdb/configuration.html#the-configuration-file
+
+[fdbmonitor]
+user = %%DB_USER%%
+group = %%DB_GROUP%%
+
+[general]
+restart_delay = 60
+## by default, restart_backoff = restart_delay_reset_interval = restart_delay
+# initial_restart_delay = 0
+# restart_backoff = 60
+# restart_delay_reset_interval = 60
+cluster_file = %%PREFIX%%/etc/foundationdb/fdb.cluster
+# delete_envvars =
+# kill_on_configuration_change = true
+
+## Default parameters for individual fdbserver processes
+[fdbserver]
+command = %%PREFIX%%/bin/fdbserver
+public_address = auto:$ID
+listen_address = public
+datadir = %%DB_DIR%%/data/$ID
+logdir = %%LOG_DIR%%
+# logsize = 10MiB
+# maxlogssize = 100MiB
+# machine_id =
+# datacenter_id =
+# class =
+# memory = 8GiB
+# storage_memory = 1GiB
+# cache_memory = 2GiB
+# metrics_cluster =
+# metrics_prefix =
+
+## An individual fdbserver process with id 4500
+## Parameters set here override defaults from the [fdbserver] section
+[fdbserver.4500]
+
+[backup_agent]
+command = %%PREFIX%%/bin/backup_agent
+logdir = %%LOG_DIR%%
+
+[backup_agent.1]
diff --git a/databases/foundationdb/files/foundationdb.in b/databases/foundationdb/files/foundationdb.in
index e2423a651d6b..beaa49ccb767 100644
--- a/databases/foundationdb/files/foundationdb.in
+++ b/databases/foundationdb/files/foundationdb.in
@@ -22,7 +22,7 @@
name="foundationdb"
rcvar="${name}_enable"
foundationdb_enable=${foundationdb_enable:-"NO"}
-command=/usr/local/sbin/fdbmonitor
+command=%%PREFIX%%/bin/fdbmonitor
pidfile="/var/run/fdbmonitor.pid"
load_rc_config "$name"
diff --git a/databases/foundationdb/files/patch-FDBLibTLS_local.mk b/databases/foundationdb/files/patch-FDBLibTLS_local.mk
deleted file mode 100644
index 7b122708c430..000000000000
--- a/databases/foundationdb/files/patch-FDBLibTLS_local.mk
+++ /dev/null
@@ -1,10 +0,0 @@
---- FDBLibTLS/local.mk.orig 2019-04-09 00:11:05 UTC
-+++ FDBLibTLS/local.mk
-@@ -23,6 +23,6 @@
- FDBLibTLS_BUILD_SOURCES +=
-
-
--FDBLibTLS_CFLAGS := -fPIC -I/usr/local/include -I$(BOOSTDIR) -I. -DUSE_UCONTEXT
-+FDBLibTLS_CFLAGS := -fPIC -I$(BOOSTDIR)/include -I. -DUSE_UCONTEXT
-
- lib/libFDBLibTLS.a: bin/coverage.FDBLibTLS.xml
diff --git a/databases/foundationdb/files/patch-Makefile b/databases/foundationdb/files/patch-Makefile
deleted file mode 100644
index 12c39d7ea2bf..000000000000
--- a/databases/foundationdb/files/patch-Makefile
+++ /dev/null
@@ -1,68 +0,0 @@
---- Makefile.orig 2019-04-09 00:11:05 UTC
-+++ Makefile
-@@ -11,6 +11,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
-@@ -50,6 +52,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
-
-@@ -120,7 +131,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
-+CPP_PROJECTS := flow fdbrpc fdbclient fdbbackup fdbserver fdbcli bindings/c fdbmonitor bindings/flow/tester bindings/flow
- ifndef TLS_DISABLED
- CPP_PROJECTS += FDBLibTLS
- endif
-@@ -132,7 +143,7 @@ CPP_MK_GENERATED := $(CPP_PROJECTS:=/generated.mk)
- MK_GENERATED := $(CS_MK_GENERATED) $(CPP_MK_GENERATED)
-
- # build/valgrind.mk needs to be included before any _MK_GENERATED (which in turn includes local.mk)
--MK_INCLUDE := build/scver.mk build/valgrind.mk $(CS_MK_GENERATED) $(CPP_MK_GENERATED) $(OTHER_PROJECTS:=/include.mk) build/packages.mk
-+MK_INCLUDE := $(CS_MK_GENERATED) $(CPP_MK_GENERATED)
-
- ALL_MAKEFILES := Makefile $(MK_INCLUDE) $(patsubst %/generated.mk,%/local.mk,$(MK_GENERATED))
-
-@@ -142,7 +153,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
-@@ -164,11 +175,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
diff --git a/databases/foundationdb/files/patch-build_link-wrapper.sh b/databases/foundationdb/files/patch-build_link-wrapper.sh
deleted file mode 100644
index 86cff25ad461..000000000000
--- a/databases/foundationdb/files/patch-build_link-wrapper.sh
+++ /dev/null
@@ -1,34 +0,0 @@
---- 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
- ;;
diff --git a/databases/foundationdb/files/patch-fdbbackup_local.mk b/databases/foundationdb/files/patch-fdbbackup_local.mk
deleted file mode 100644
index f6a883b4e3a6..000000000000
--- a/databases/foundationdb/files/patch-fdbbackup_local.mk
+++ /dev/null
@@ -1,11 +0,0 @@
---- fdbbackup/local.mk.orig 2019-04-09 00:11:05 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 -lboost_system
- endif
-
- fdbbackup_GENERATED_SOURCES += versions.h
diff --git a/databases/foundationdb/files/patch-fdbcli_local.mk b/databases/foundationdb/files/patch-fdbcli_local.mk
deleted file mode 100644
index 05de37f0bbc8..000000000000
--- a/databases/foundationdb/files/patch-fdbcli_local.mk
+++ /dev/null
@@ -1,15 +0,0 @@
---- fdbcli/local.mk.orig 2019-04-09 00:11:05 UTC
-+++ fdbcli/local.mk
-@@ -31,9 +31,11 @@ ifeq ($(PLATFORM),linux)
- fdbcli_LDFLAGS += -static-libstdc++ -static-libgcc -lpthread -lrt -ldl
- else ifeq ($(PLATFORM),osx)
- fdbcli_LDFLAGS += -lc++
-+else ifeq ($(PLATFORM),freebsd)
-+ fdbcli_LDFLAGS += -lc++ -lm -lpthread -leio -lexecinfo -lboost_system
- endif
-
- test_fdbcli_status: fdbcli
-- python scripts/test_status.py
-+ $(PYTHON) scripts/test_status.py
-
- bin/fdbcli.debug: bin/fdbcli
diff --git a/databases/foundationdb/files/patch-fdbclient_local.mk b/databases/foundationdb/files/patch-fdbclient_local.mk
deleted file mode 100644
index 55c24423a09b..000000000000
--- a/databases/foundationdb/files/patch-fdbclient_local.mk
+++ /dev/null
@@ -1,11 +0,0 @@
---- 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 -lboost_system
- fdbclient_GENERATED_SOURCES += fdbclient/FDBOptions.g.h
-
- fdbclient/FDBOptions.g.cpp: fdbclient/FDBOptions.g.h
diff --git a/databases/foundationdb/files/patch-fdbmonitor_fdbmonitor.cpp b/databases/foundationdb/files/patch-fdbmonitor_fdbmonitor.cpp
deleted file mode 100644
index 69cc268496c4..000000000000
--- a/databases/foundationdb/files/patch-fdbmonitor_fdbmonitor.cpp
+++ /dev/null
@@ -1,165 +0,0 @@
---- fdbmonitor/fdbmonitor.cpp.orig 2019-04-09 00:11:05 UTC
-+++ fdbmonitor/fdbmonitor.cpp
-@@ -37,6 +37,10 @@
- #include <linux/limits.h>
- #endif
-
-+#ifdef __FreeBSD__
-+#include <sys/event.h>
-+#endif
-+
- #ifdef __APPLE__
- #include <sys/event.h>
- #include <mach/mach.h>
-@@ -77,7 +81,7 @@
-
- #ifdef __linux__
- typedef fd_set* fdb_fd_set;
--#elif defined __APPLE__
-+#elif defined(__APPLE__) || defined(__FreeBSD__)
- typedef int fdb_fd_set;
- #endif
-
-@@ -88,7 +92,7 @@ void monitor_fd( fdb_fd_set list, int fd, int* maxfd,
- FD_SET( fd, list );
- if ( fd > *maxfd )
- *maxfd = fd;
--#elif defined __APPLE__
-+#elif defined(__APPLE__) || defined(__FreeBSD__)
- /* ignore maxfd */
- struct kevent ev;
- EV_SET( &ev, fd, EVFILT_READ, EV_ADD, 0, 0, cmd );
-@@ -99,7 +103,7 @@ void monitor_fd( fdb_fd_set list, int fd, int* maxfd,
- void unmonitor_fd( fdb_fd_set list, int fd ) {
- #ifdef __linux__
- FD_CLR( fd, list );
--#elif defined __APPLE__
-+#elif defined(__APPLE__) || defined(__FreeBSD__)
- struct kevent ev;
- EV_SET( &ev, fd, EVFILT_READ, EV_DELETE, 0, 0, NULL );
- kevent( list, &ev, 1, NULL, 0, NULL ); // FIXME: check?
-@@ -193,7 +197,7 @@ const char* get_value_multi(const CSimpleIni& ini, con
- }
-
- double timer() {
--#if defined(__linux__)
-+#if defined(__linux__) || defined(__FreeBSD__)
- struct timespec ts;
- clock_gettime(CLOCK_MONOTONIC, &ts);
- return double(ts.tv_sec) + (ts.tv_nsec * 1e-9);
-@@ -912,7 +916,7 @@ void read_child_output( Command* cmd, int pipe_idx, fd
- }
- }
-
--#ifdef __APPLE__
-+#if defined(__APPLE__) || defined(__FreeBSD__)
- void watch_conf_dir( int kq, int* confd_fd, std::string confdir ) {
- struct kevent ev;
- std::string original = confdir;
-@@ -929,7 +933,7 @@ void watch_conf_dir( int kq, int* confd_fd, std::strin
- std::string child = confdir;
-
- /* Find the nearest existing ancestor */
-- while( (*confd_fd = open( confdir.c_str(), O_EVTONLY )) < 0 && errno == ENOENT ) {
-+ while( (*confd_fd = open( confdir.c_str(), O_RDONLY )) < 0 && errno == ENOENT ) {
- child = confdir;
- confdir = parentDirectory(confdir, false);
- }
-@@ -966,7 +970,7 @@ void watch_conf_file( int kq, int* conff_fd, const cha
- }
-
- /* Open and watch */
-- *conff_fd = open( confpath, O_EVTONLY );
-+ *conff_fd = open( confpath, O_RDONLY );
- if ( *conff_fd >= 0 ) {
- EV_SET( &ev, *conff_fd, EVFILT_VNODE, EV_ADD | EV_CLEAR, NOTE_WRITE | NOTE_ATTRIB, 0, NULL );
- kevent( kq, &ev, 1, NULL, 0, NULL );
-@@ -1170,7 +1174,7 @@ int main(int argc, char** argv) {
- // testPathOps(); return -1;
-
- 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;
-
-@@ -1252,7 +1256,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;
-
-@@ -1267,12 +1271,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");
-@@ -1325,12 +1329,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" );
-@@ -1361,7 +1365,7 @@ int main(int argc, char** argv) {
-
- #endif
-
--#ifdef __linux__
-+#if defined(__linux__)
- signal(SIGCHLD, child_handler);
- #endif
-
-@@ -1375,11 +1379,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;
-
-@@ -1438,7 +1442,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 );
-@@ -1476,7 +1480,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 );
diff --git a/databases/foundationdb/files/patch-fdbmonitor_local.mk b/databases/foundationdb/files/patch-fdbmonitor_local.mk
deleted file mode 100644
index 0bb6b1cad9d2..000000000000
--- a/databases/foundationdb/files/patch-fdbmonitor_local.mk
+++ /dev/null
@@ -1,11 +0,0 @@
---- 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
diff --git a/databases/foundationdb/files/patch-fdbrpc_AsyncFileCached.actor.cpp b/databases/foundationdb/files/patch-fdbrpc_AsyncFileCached.actor.cpp
deleted file mode 100644
index 2b553e174bb3..000000000000
--- a/databases/foundationdb/files/patch-fdbrpc_AsyncFileCached.actor.cpp
+++ /dev/null
@@ -1,20 +0,0 @@
---- fdbrpc/AsyncFileCached.actor.cpp.orig 2019-04-09 00:11:05 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();
-@@ -155,7 +155,7 @@ void AsyncFileCached::releaseZeroCopy( void* data, int
- if (length == 4096)
- FastAllocator<4096>::release(data);
- else
-- aligned_free(data);
-+ free(data);
- }
- }
- else {
diff --git a/databases/foundationdb/files/patch-fdbrpc_IAsyncFile.actor.cpp b/databases/foundationdb/files/patch-fdbrpc_IAsyncFile.actor.cpp
deleted file mode 100644
index c7eb47031e31..000000000000
--- a/databases/foundationdb/files/patch-fdbrpc_IAsyncFile.actor.cpp
+++ /dev/null
@@ -1,11 +0,0 @@
---- fdbrpc/IAsyncFile.actor.cpp.orig 2019-04-09 00:11:05 UTC
-+++ fdbrpc/IAsyncFile.actor.cpp
-@@ -43,7 +43,7 @@ ACTOR static Future<Void> zeroRangeHelper( Reference<I
- wait( yield() );
- }
-
-- aligned_free(zeros);
-+ free(zeros);
- return Void();
- }
-
diff --git a/databases/foundationdb/files/patch-fdbrpc_Platform.cpp b/databases/foundationdb/files/patch-fdbrpc_Platform.cpp
deleted file mode 100644
index 10600ee024c6..000000000000
--- a/databases/foundationdb/files/patch-fdbrpc_Platform.cpp
+++ /dev/null
@@ -1,22 +0,0 @@
---- fdbrpc/Platform.cpp.orig 2019-01-09 22:28:32 UTC
-+++ fdbrpc/Platform.cpp
-@@ -87,7 +87,7 @@ int eraseDirectoryRecursive(std::string const& dir) {
- __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 {
-@@ -123,8 +123,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
diff --git a/databases/foundationdb/files/patch-fdbrpc_local.mk b/databases/foundationdb/files/patch-fdbrpc_local.mk
deleted file mode 100644
index ac7edf336142..000000000000
--- a/databases/foundationdb/files/patch-fdbrpc_local.mk
+++ /dev/null
@@ -1,17 +0,0 @@
---- fdbrpc/local.mk.orig 2019-04-09 00:11:05 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/libeio -DUSE_UCONTEXT
--fdbrpc_LDFLAGS :=
-+fdbrpc_CFLAGS := -I$(BOOSTDIR)/include -I. -DUSE_UCONTEXT
-+fdbrpc_LDFLAGS := -L$(BOOSTDIR)/lib
-+fdbrpc_LIBS := -lm -lc++ -lpthread -leio -lboost_system
-
- ifeq ($(PLATFORM),osx)
- fdbrpc_CFLAGS += -fasynchronous-unwind-tables -fno-omit-frame-pointer
diff --git a/databases/foundationdb/files/patch-fdbserver_fdbserver.actor.cpp b/databases/foundationdb/files/patch-fdbserver_fdbserver.actor.cpp
deleted file mode 100644
index 079821f11340..000000000000
--- a/databases/foundationdb/files/patch-fdbserver_fdbserver.actor.cpp
+++ /dev/null
@@ -1,29 +0,0 @@
---- fdbserver/fdbserver.actor.cpp.orig 2019-04-09 00:11:05 UTC
-+++ fdbserver/fdbserver.actor.cpp
-@@ -60,7 +60,7 @@
- #include "versions.h"
- #endif
-
--#ifdef __linux__
-+#if defined(__linux__) || defined(__FreeBSD__)
- #include <execinfo.h>
- #include <signal.h>
- #ifdef ALLOC_INSTRUMENTATION
-@@ -288,7 +288,7 @@ class WorldReadablePermissions { (public)
- throw platform_error();
- }
- permission.set_permissions( &sa );
--#elif (defined(__linux__) || defined(__APPLE__))
-+#elif (defined(__linux__) || defined(__APPLE__)) || defined(__FreeBSD__)
- // There is nothing to do here, since the default permissions are fine
- #else
- #error Port me!
-@@ -298,7 +298,7 @@ class WorldReadablePermissions { (public)
- virtual ~WorldReadablePermissions() {
- #ifdef _WIN32
- LocalFree( sa.lpSecurityDescriptor );
--#elif (defined(__linux__) || defined(__APPLE__))
-+#elif (defined(__linux__) || defined(__APPLE__)) || defined(__FreeBSD__)
- // There is nothing to do here, since the default permissions are fine
- #else
- #error Port me!
diff --git a/databases/foundationdb/files/patch-fdbserver_local.mk b/databases/foundationdb/files/patch-fdbserver_local.mk
deleted file mode 100644
index e8e377ff7de4..000000000000
--- a/databases/foundationdb/files/patch-fdbserver_local.mk
+++ /dev/null
@@ -1,11 +0,0 @@
---- fdbserver/local.mk.orig 2019-04-09 00:11:05 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 -lboost_system
- endif
-
- ifeq ($(WORKLOADS),false)
diff --git a/databases/foundationdb/files/patch-fdbserver_worker.actor.cpp b/databases/foundationdb/files/patch-fdbserver_worker.actor.cpp
deleted file mode 100644
index aa1d330917de..000000000000
--- a/databases/foundationdb/files/patch-fdbserver_worker.actor.cpp
+++ /dev/null
@@ -1,38 +0,0 @@
---- fdbserver/worker.actor.cpp.orig 2019-04-09 00:11:05 UTC
-+++ fdbserver/worker.actor.cpp
-@@ -41,7 +41,7 @@
- #include "fdbclient/ClientWorkerInterface.h"
- #include "flow/Profiler.h"
-
--#ifdef __linux__
-+#if defined(__linux__) || defined(__FreeBSD__)
- #ifdef USE_GPERFTOOLS
- #include "gperftools/profiler.h"
- #endif
-@@ -373,7 +373,7 @@ ACTOR Future<Void> registrationClient(
- }
- }
-
--#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;
-
-@@ -385,7 +385,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());
-@@ -399,7 +399,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();
diff --git a/databases/foundationdb/files/patch-flow_Deque.h b/databases/foundationdb/files/patch-flow_Deque.h
deleted file mode 100644
index d8c44c2229d4..000000000000
--- a/databases/foundationdb/files/patch-flow_Deque.h
+++ /dev/null
@@ -1,20 +0,0 @@
---- flow/Deque.h.orig 2019-04-09 00:11:05 UTC
-+++ flow/Deque.h
-@@ -168,7 +168,7 @@ class Deque { (private)
- new (&newArr[i - begin]) T(std::move(arr[i&mask]));
- arr[i&mask].~T();
- }
-- aligned_free(arr);
-+ free(arr);
- arr = newArr;
- end -= begin;
- begin = 0;
-@@ -179,7 +179,7 @@ class Deque { (private)
- for (int i = begin; i != end; i++)
- arr[i&mask].~T();
- if(arr)
-- aligned_free(arr);
-+ free(arr);
- }
- };
-
diff --git a/databases/foundationdb/files/patch-flow_FastAlloc.cpp b/databases/foundationdb/files/patch-flow_FastAlloc.cpp
deleted file mode 100644
index 098ec8621d09..000000000000
--- a/databases/foundationdb/files/patch-flow_FastAlloc.cpp
+++ /dev/null
@@ -1,12 +0,0 @@
---- flow/FastAlloc.cpp.orig 2019-04-09 00:11:05 UTC
-+++ flow/FastAlloc.cpp
-@@ -53,6 +53,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
diff --git a/databases/foundationdb/files/patch-flow_Net2.actor.cpp b/databases/foundationdb/files/patch-flow_Net2.actor.cpp
deleted file mode 100644
index 7c087a89c581..000000000000
--- a/databases/foundationdb/files/patch-flow_Net2.actor.cpp
+++ /dev/null
@@ -1,33 +0,0 @@
---- flow/Net2.actor.cpp.orig 2019-04-09 00:11:05 UTC
-+++ flow/Net2.actor.cpp
-@@ -62,7 +62,7 @@ const uint64_t minValidProtocolVersion = 0x0FDB0
- // This assert is intended to help prevent incrementing the leftmost digits accidentally. It will probably need to change when we reach version 10.
- static_assert(currentProtocolVersion < 0x0FDB00B100000000LL, "Unexpected protocol version");
-
--#if defined(__linux__)
-+#if defined(__linux__) || defined(__FreeBSD__)
- #include <execinfo.h>
-
- volatile double net2liveness = 0;
-@@ -437,6 +437,12 @@ class Connection : public IConnection, ReferenceCounte
- }
- };
-
-+#if BOOST_VERSION >= 107000
-+#define GET_IO_SERVICE(s) ((boost::asio::io_context&)(s).get_executor().context())
-+#else
-+#define GET_IO_SERVICE(s) ((s).get_io_service())
-+#endif
-+
- class Listener : public IListener, ReferenceCounted<Listener> {
- NetworkAddress listenAddress;
- tcp::acceptor acceptor;
-@@ -459,7 +465,7 @@ class Listener : public IListener, ReferenceCounted<Li
-
- private:
- ACTOR static Future<Reference<IConnection>> doAccept( Listener* self ) {
-- state Reference<Connection> conn( new Connection( self->acceptor.get_io_service() ) );
-+ state Reference<Connection> conn( new Connection( GET_IO_SERVICE(self->acceptor) ) );
- state tcp::acceptor::endpoint_type peer_endpoint;
- try {
- BindPromise p("N2_AcceptError", UID());
diff --git a/databases/foundationdb/files/patch-flow_Platform.cpp b/databases/foundationdb/files/patch-flow_Platform.cpp
deleted file mode 100644
index 4603a351860c..000000000000
--- a/databases/foundationdb/files/patch-flow_Platform.cpp
+++ /dev/null
@@ -1,306 +0,0 @@
---- flow/Platform.cpp.orig 2019-04-09 00:11:05 UTC
-+++ flow/Platform.cpp
-@@ -72,6 +72,7 @@
-
- #include <dirent.h>
- #include <sys/time.h>
-+#include <sys/user.h>
- #include <sys/mman.h>
- #include <unistd.h>
- #include <ftw.h>
-@@ -122,7 +123,13 @@
- #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)
- {
-@@ -201,7 +208,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 */
-@@ -269,6 +276,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;
-@@ -307,7 +322,7 @@ uint64_t getMemoryUsage() {
- }
- return info.virtual_size;
- #else
-- #warning getMemoryUsage unimplemented on this platform
-+ //#warning getMemoryUsage unimplemented on this platform
- return 0;
- #endif
- }
-@@ -430,6 +445,24 @@ void getMachineRAMInfo(MachineRAMInfo& memInfo) {
- memInfo.total = pagesize * (vm_stat.free_count + vm_stat.active_count + vm_stat.inactive_count + vm_stat.wire_count);
- memInfo.available = pagesize * vm_stat.free_count;
- memInfo.committed = memInfo.total - memInfo.available;
-+#elif defined(__FreeBSD__)
-+ size_t len;
-+ int pagesize = getpagesize(), free_pages;
-+ u_long total;
-+
-+ len = sizeof(total);
-+ if (sysctlbyname("hw.physmem", &total, &len, NULL, 0) == -1)
-+ total = 0;
-+
-+ total = total / 1024;
-+
-+ len = sizeof(free_pages);
-+ if((sysctlbyname("vm.stats.vm.v_free_count", &free_pages, &len, NULL, 0) == -1) || !len)
-+ free_pages = 0;
-+
-+ memInfo.total = total;
-+ memInfo.available = (pagesize / 1024) * free_pages;
-+ memInfo.committed = memInfo.total - memInfo.available;
- #else
- #warning getMachineRAMInfo unimplemented on this platform
- #endif
-@@ -454,7 +487,7 @@ Error systemErrorCodeToError() {
- 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)) {
- Error e = systemErrorCodeToError();
-@@ -753,6 +786,30 @@ dev_t getDeviceId(std::string path) {
-
- #endif
-
-+#ifdef __FreeBSD__
-+void getNetworkTraffic(const IPAddress &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, bool logDetails) {
-+ 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(const IPAddress& ip, uint64_t& bytesSent, uint64_t& bytesReceived, uint64_t& outSegs,
- uint64_t& retransSegs) {
-@@ -1277,7 +1334,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.
-@@ -1342,7 +1399,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);
-@@ -1362,7 +1419,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;
-@@ -1412,7 +1469,7 @@ void setMemoryQuota( size_t limit ) {
- }
- if (!AssignProcessToJobObject( job, GetCurrentProcess() ))
- TraceEvent(SevWarn, "FailedToSetMemoryLimit").GetLastError();
--#elif defined(__linux__)
-+#elif defined(__linux__) || defined(__FreeBSD__)
- struct rlimit rlim;
- if (getrlimit(RLIMIT_AS, &rlim)) {
- TraceEvent(SevError, "GetMemoryLimit").GetLastError();
-@@ -1515,7 +1572,8 @@ static void *allocateInternal(size_t length, bool larg
- flags |= MAP_HUGETLB;
-
- return mmap(NULL, length, PROT_READ|PROT_WRITE, flags, -1, 0);
--#elif defined(__APPLE__)
-+#elif defined(__APPLE__) || defined(__FreeBSD__)
-+
- int flags = MAP_PRIVATE|MAP_ANON;
-
- return mmap(NULL, length, PROT_READ|PROT_WRITE, flags, -1, 0);
-@@ -1589,6 +1647,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
- }
-
-@@ -1649,7 +1712,7 @@ void renameFile( std::string const& fromPath, std::str
- //renamedFile();
- return;
- }
--#elif (defined(__linux__) || defined(__APPLE__))
-+#elif (defined(__linux__) || defined(__APPLE__)) || defined(__FreeBSD__)
- if (!rename( fromPath.c_str(), toPath.c_str() )) {
- //FIXME: We cannot inject faults after renaming the file, because we could end up with two asyncFileNonDurable open for the same file
- //renamedFile();
-@@ -1807,7 +1870,7 @@ bool createDirectory( std::string const& directory ) {
- Error e = systemErrorCodeToError();
- TraceEvent(SevError, "CreateDirectory").detail("Directory", directory).GetLastError().error(e);
- throw e;
--#elif (defined(__linux__) || defined(__APPLE__))
-+#elif (defined(__linux__) || defined(__APPLE__)) || defined(__FreeBSD__)
- size_t sep = 0;
- do {
- sep = directory.find_first_of('/', sep + 1);
-@@ -1959,7 +2022,7 @@ std::string abspath( std::string const& path, bool res
- if (*x == '/')
- *x = CANONICAL_PATH_SEPARATOR;
- return nameBuffer;
--#elif (defined(__linux__) || defined(__APPLE__))
-+#elif (defined(__linux__) || defined(__APPLE__)) || defined(__FreeBSD__)
-
- char result[PATH_MAX];
- // Must resolve links, so first try realpath on the whole thing
-@@ -2023,7 +2086,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!
-@@ -2032,7 +2095,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!
-@@ -2042,7 +2105,7 @@ bool acceptFile( FILE_ATTRIBUTE_DATA fileAttributes, s
- bool acceptDirectory( FILE_ATTRIBUTE_DATA fileAttributes, std::string name, std::string extension ) {
- #ifdef _WIN32
- return (fileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0;
--#elif (defined(__linux__) || defined(__APPLE__))
-+#elif (defined(__linux__) || defined(__APPLE__)) || defined(__FreeBSD__)
- return S_ISDIR(fileAttributes);
- #else
- #error Port me!
-@@ -2078,7 +2141,7 @@ std::vector<std::string> findFiles( std::string const&
- }
- FindClose(h);
- }
--#elif (defined(__linux__) || defined(__APPLE__))
-+#elif (defined(__linux__) || defined(__APPLE__)) || defined(__FreeBSD__)
- DIR *dip;
-
- if ((dip = opendir(directory.c_str())) != NULL) {
-@@ -2142,7 +2205,7 @@ void findFilesRecursively(std::string path, std::vecto
- void threadSleep( double seconds ) {
- #ifdef _WIN32
- Sleep( (DWORD)(seconds * 1e3) );
--#elif (defined(__linux__) || defined(__APPLE__))
-+#elif (defined(__linux__) || defined(__APPLE__)) || defined(__FreeBSD__)
- struct timespec req, rem;
-
- req.tv_sec = seconds;
-@@ -2180,7 +2243,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);
-@@ -2193,7 +2256,7 @@ THREAD_HANDLE startThread(void *(*func) (void *), void
- void waitThread(THREAD_HANDLE thread) {
- #ifdef _WIN32
- WaitForSingleObject(thread, INFINITE);
--#elif (defined(__linux__) || defined(__APPLE__))
-+#elif (defined(__linux__) || defined(__APPLE__)) || defined(__FreeBSD__)
- pthread_join(thread, NULL);
- #else
- #error Port me!
-@@ -2235,7 +2298,7 @@ int64_t fileSize(std::string const& filename) {
- return 0;
- else
- return file_status.st_size;
--#elif (defined(__linux__) || defined(__APPLE__))
-+#elif (defined(__linux__) || defined(__APPLE__)) || defined(__FreeBSD__)
- struct stat file_status;
- if(stat(filename.c_str(), &file_status) != 0)
- return 0;
-@@ -2378,6 +2441,8 @@ std::string getDefaultPluginPath( const char* plugin_n
- return format( "/usr/lib/foundationdb/plugins/%s.so", plugin_name );
- #elif defined(__APPLE__)
- return format( "/usr/local/foundationdb/plugins/%s.dylib", plugin_name );
-+#elif defined(__FreeBSD__)
-+ return format( "/usr/local/lib/foundationdb/plugins/%s.so", plugin_name );
- #else
- #error Port me!
- #endif
-@@ -2629,7 +2694,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
-
-@@ -2645,7 +2710,7 @@ bool isLibraryLoaded(const char* lib_path) {
- }
-
- void* loadLibrary(const char* lib_path) {
--#if !defined(__linux__) && !defined(__APPLE__) && !defined(_WIN32)
-+#if !defined(__linux__) && !defined(__APPLE__) && !defined(_WIN32) && !defined(__FreeBSD__)
- #error Port me!
- #endif
-
diff --git a/databases/foundationdb/files/patch-flow_Platform.h b/databases/foundationdb/files/patch-flow_Platform.h
deleted file mode 100644
index ee36e47b6445..000000000000
--- a/databases/foundationdb/files/patch-flow_Platform.h
+++ /dev/null
@@ -1,20 +0,0 @@
---- flow/Platform.h.orig 2019-04-09 00:11:05 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
-
-@@ -188,6 +188,8 @@ THREAD_HANDLE startThread(void *(func) (void *), void
- #if defined(_WIN32)
- #define DYNAMIC_LIB_EXT ".dll"
- #elif defined(__linux)
-+#define DYNAMIC_LIB_EXT ".so"
-+#elif defined(__FreeBSD__)
- #define DYNAMIC_LIB_EXT ".so"
- #elif defined(__APPLE__)
- #define DYNAMIC_LIB_EXT ".dylib"
diff --git a/databases/foundationdb/files/patch-flow_ThreadPrimitives.cpp b/databases/foundationdb/files/patch-flow_ThreadPrimitives.cpp
deleted file mode 100644
index c005abb58b4d..000000000000
--- a/databases/foundationdb/files/patch-flow_ThreadPrimitives.cpp
+++ /dev/null
@@ -1,38 +0,0 @@
---- flow/ThreadPrimitives.cpp.orig 2019-01-09 22:28:32 UTC
-+++ flow/ThreadPrimitives.cpp
-@@ -37,7 +37,7 @@ extern std::string format( const char *form, ... );
- Event::Event() {
- #ifdef _WIN32
- ev = CreateEvent(NULL, FALSE, FALSE, NULL);
--#elif defined(__linux__)
-+#elif defined(__linux__) || defined(__FreeBSD__)
- int result = sem_init(&sem, 0, 0);
- if (result)
- criticalError(FDB_EXIT_INIT_SEMAPHORE, "UnableToInitializeSemaphore", format("Could not initialize semaphore - %s", strerror(errno)).c_str());
-@@ -54,7 +54,7 @@ Event::Event() {
- Event::~Event() {
- #ifdef _WIN32
- CloseHandle(ev);
--#elif defined(__linux__)
-+#elif defined(__linux__) || defined(__FreeBSD__)
- sem_destroy(&sem);
- #elif defined(__APPLE__)
- semaphore_destroy(self, sem);
-@@ -66,7 +66,7 @@ Event::~Event() {
- void Event::set() {
- #ifdef _WIN32
- SetEvent(ev);
--#elif defined(__linux__)
-+#elif defined(__linux__) || defined(__FreeBSD__)
- sem_post(&sem);
- #elif defined(__APPLE__)
- semaphore_signal(sem);
-@@ -78,7 +78,7 @@ void Event::set() {
- void Event::block() {
- #ifdef _WIN32
- WaitForSingleObject(ev, INFINITE);
--#elif defined(__linux__)
-+#elif defined(__linux__) || defined(__FreeBSD__)
- int ret;
- do {
- ret = sem_wait(&sem);
diff --git a/databases/foundationdb/files/patch-flow_ThreadPrimitives.h b/databases/foundationdb/files/patch-flow_ThreadPrimitives.h
deleted file mode 100644
index d8e6af437b9c..000000000000
--- a/databases/foundationdb/files/patch-flow_ThreadPrimitives.h
+++ /dev/null
@@ -1,34 +0,0 @@
---- flow/ThreadPrimitives.h.orig 2019-04-09 00:11:05 UTC
-+++ flow/ThreadPrimitives.h
-@@ -25,7 +25,7 @@
- #include "flow/Error.h"
- #include "flow/Trace.h"
-
--#ifdef __linux__
-+#if defined(__linux__) || defined(__FreeBSD__)
- #include <semaphore.h>
- #endif
-
-@@ -63,11 +63,11 @@ class ThreadSpinLock { (public)
- #endif
- }
- void leave() {
--#if defined(__linux__)
-+#if defined(__linux__) || defined(__FreeBSD__)
- __sync_synchronize();
- #endif
- isLocked = 0;
--#if defined(__linux__)
-+#if defined(__linux__) || defined(__FreeBSD__)
- __sync_synchronize();
- #endif
- #if VALGRIND
-@@ -116,6 +116,8 @@ class Event { (private)
- #ifdef _WIN32
- void* ev;
- #elif defined(__linux__)
-+ sem_t sem;
-+#elif defined(__FreeBSD__)
- sem_t sem;
- #elif defined(__APPLE__)
- mach_port_t self;
diff --git a/databases/foundationdb/files/patch-flow_local.mk b/databases/foundationdb/files/patch-flow_local.mk
deleted file mode 100644
index e9c1b147da27..000000000000
--- a/databases/foundationdb/files/patch-flow_local.mk
+++ /dev/null
@@ -1,14 +0,0 @@
---- flow/local.mk.orig 2019-04-09 00:11:05 UTC
-+++ flow/local.mk
-@@ -20,8 +20,9 @@
-
- # -*- mode: makefile; -*-
-
--flow_CFLAGS := -I$(BOOSTDIR) -I. -DUSE_UCONTEXT
--flow_LDFLAGS :=
-+flow_CFLAGS := -I$(BOOSTDIR)/include -I. -DUSE_UCONTEXT
-+flow_LDFLAGS := -L$(BOOSTDIR)/lib
-+flow_LIBS := -lm -lc++ -lpthread -leio -lexecinfo -lboost_system
-
- ifeq ($(PLATFORM),osx)
- flow_CFLAGS += -fasynchronous-unwind-tables -fno-omit-frame-pointer
diff --git a/databases/foundationdb/files/patch-foundationdb.conf b/databases/foundationdb/files/patch-foundationdb.conf
deleted file mode 100644
index 52ca649fa7bf..000000000000
--- a/databases/foundationdb/files/patch-foundationdb.conf
+++ /dev/null
@@ -1,40 +0,0 @@
---- foundationdb.conf.orig 2018-04-27 06:33:40 UTC
-+++ foundationdb.conf
-@@ -0,0 +1,37 @@
-+## foundationdb.conf
-+##
-+## Configuration file for FoundationDB server processes
-+## Full documentation is available at
-+## https://foundationdb.com/documentation/configuration.html#foundationdb-conf
-+
-+[fdbmonitor]
-+user = foundationdb
-+group = foundationdb
-+
-+[general]
-+restart_delay = 60
-+cluster_file = /usr/local/etc/foundationdb/fdb.cluster
-+
-+## Default parameters for individual fdbserver processes
-+[fdbserver]
-+command = /usr/local/sbin/fdbserver
-+public_address = auto:$ID
-+listen_address = public
-+datadir = /var/db/foundationdb/data/$ID
-+logdir = /var/log/foundationdb
-+logsize = 10MiB
-+maxlogssize = 100MiB
-+# machine_id =
-+# datacenter_id =
-+# class =
-+# memory = 8GiB
-+# storage_memory = 1GiB
-+
-+## An individual fdbserver process with id 4500
-+## Parameters set here override defaults from the [fdbserver] section
-+[fdbserver.4500]
-+
-+[backup_agent]
-+command = /usr/local/lib/foundationdb/backup_agent/backup_agent
-+
-+[backup_agent.1]
diff --git a/databases/foundationdb/pkg-descr b/databases/foundationdb/pkg-descr
index 8634c2838630..9c9b5e714097 100644
--- a/databases/foundationdb/pkg-descr
+++ b/databases/foundationdb/pkg-descr
@@ -1,3 +1,16 @@
-A distributed, transactional key-value store.
+A massively distributed, transactional key-value store, extensible by
+design, with unparalleled reliability and performance.
+
+FoundationDB is multi-model, meaning you can store many types of data in a
+single database. All data is safely stored, distributed, and replicated
+in the Key-Value Store component. It is easy to install, grow, and
+manage, with a distributed architecture that gracefully scales out, and
+handles faults while acting like a single ACID database. FoundationDB
+provides amazing performance on commodity hardware, allowing you to
+support very heavy loads at low cost. It has been running in production
+for years and been hardened with lessons learned in some of the world's
+largest database deployments. Backing FoundationDB up is an unmatched
+testing system based on a deterministic simulation engine that ensures
+optimal reliability of operations.
WWW: https://www.foundationdb.org/
diff --git a/databases/foundationdb/pkg-plist b/databases/foundationdb/pkg-plist
index c4178a42161c..21278e3b27a2 100644
--- a/databases/foundationdb/pkg-plist
+++ b/databases/foundationdb/pkg-plist
@@ -1,12 +1,27 @@
+@dir(%%DB_USER%%,%%DB_GROUP%%,) %%DB_DIR%%
+@dir(%%DB_USER%%,%%DB_GROUP%%,) %%LOG_DIR%%
+@sample etc/foundationdb/foundationdb.conf.sample
+bin/actor_flamegraph
+bin/backup_agent
+bin/dr_agent
+bin/fdb_c_performance_test
+bin/fdb_c_ryw_benchmark
+bin/fdb_c_txn_size_test
+bin/fdb_flow_tester
bin/fdbbackup
bin/fdbcli
+bin/fdbmonitor
+bin/fdbr
bin/fdbrestore
-@sample etc/foundationdb/foundationdb.conf.sample
-lib/foundationdb/backup_agent/backup_agent
+bin/fdbserver
+bin/mako
+include/foundationdb/fdb.options
+include/foundationdb/fdb_c.h
+include/foundationdb/fdb_c_options.g.h
+lib/libfdb_c.so
+lib/libfdb_flow.a
+lib/libfdb_sqlite.a
lib/libfdbclient.a
lib/libfdbrpc.a
lib/libflow.a
-sbin/fdbmonitor
-sbin/fdbserver
-@dir(%%DB_USER%%,%%DB_GROUP%%,) %%DB_DIR%%
-@dir(%%DB_USER%%,%%DB_GROUP%%,) %%LOG_DIR%%
+lib/libthirdparty.a