diff options
author | Vanilla I. Shu <vanilla@FreeBSD.org> | 2018-05-02 01:27:12 +0000 |
---|---|---|
committer | Vanilla I. Shu <vanilla@FreeBSD.org> | 2018-05-02 01:27:12 +0000 |
commit | 9bb490e4d1fc8cd87ea0db24f93bf555b1f308cf (patch) | |
tree | 1a246c06bef78a1f57c64201f25868dd6ca4627b /databases/foundationdb | |
parent | 5c1941f7ee9075c0be9e3bdc49f5a62b0568ddf7 (diff) | |
download | ports-9bb490e4d1fc8cd87ea0db24f93bf555b1f308cf.tar.gz ports-9bb490e4d1fc8cd87ea0db24f93bf555b1f308cf.zip |
Add foundationdb, yet another distributed database from apple.
Notes
Notes:
svn path=/head/; revision=468809
Diffstat (limited to 'databases/foundationdb')
36 files changed, 1241 insertions, 0 deletions
diff --git a/databases/foundationdb/Makefile b/databases/foundationdb/Makefile new file mode 100644 index 000000000000..78b67308b15d --- /dev/null +++ b/databases/foundationdb/Makefile @@ -0,0 +1,55 @@ +# Created by: vanilla@ +# $FreeBSD$ + +PORTNAME= foundationdb +PORTVERSION= 5.1.7 +CATEGORIES= databases + +MAINTAINER= vanilla@FreeBSD.org +COMMENT= Distributed, transactional key-value store + +LICENSE= APACHE20 +LICENSE_FILE= ${WRKSRC}/LICENSE + +ONLY_FOR_ARCHS= amd64 +ONLY_FOR_ARCHS_REASON= not yet ported to anything other than amd64 + +BUILD_DEPENDS= bash:shells/bash +LIB_DEPENDS= libboost_system.so:devel/boost-libs \ + libeio.so:devel/libeio + +USES= 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> diff --git a/databases/foundationdb/distinfo b/databases/foundationdb/distinfo new file mode 100644 index 000000000000..3bee059e3903 --- /dev/null +++ b/databases/foundationdb/distinfo @@ -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 diff --git a/databases/foundationdb/files/foundationdb.in b/databases/foundationdb/files/foundationdb.in new file mode 100644 index 000000000000..87d06b918452 --- /dev/null +++ b/databases/foundationdb/files/foundationdb.in @@ -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 diff --git a/databases/foundationdb/files/patch-FDBLibTLS_local.mk b/databases/foundationdb/files/patch-FDBLibTLS_local.mk new file mode 100644 index 000000000000..42fb54e0b800 --- /dev/null +++ b/databases/foundationdb/files/patch-FDBLibTLS_local.mk @@ -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 diff --git a/databases/foundationdb/files/patch-Makefile b/databases/foundationdb/files/patch-Makefile new file mode 100644 index 000000000000..4a5103c12c61 --- /dev/null +++ b/databases/foundationdb/files/patch-Makefile @@ -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 diff --git a/databases/foundationdb/files/patch-build_link-wrapper.sh b/databases/foundationdb/files/patch-build_link-wrapper.sh new file mode 100644 index 000000000000..86cff25ad461 --- /dev/null +++ b/databases/foundationdb/files/patch-build_link-wrapper.sh @@ -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 + ;; diff --git a/databases/foundationdb/files/patch-fdbbackup_local.mk b/databases/foundationdb/files/patch-fdbbackup_local.mk new file mode 100644 index 000000000000..c714f9f56ffc --- /dev/null +++ b/databases/foundationdb/files/patch-fdbbackup_local.mk @@ -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 diff --git a/databases/foundationdb/files/patch-fdbcli_local.mk b/databases/foundationdb/files/patch-fdbcli_local.mk new file mode 100644 index 000000000000..0d7fb5535686 --- /dev/null +++ b/databases/foundationdb/files/patch-fdbcli_local.mk @@ -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 diff --git a/databases/foundationdb/files/patch-fdbclient_MultiVersionAssignmentVars.h b/databases/foundationdb/files/patch-fdbclient_MultiVersionAssignmentVars.h new file mode 100644 index 000000000000..4fe344e93e7c --- /dev/null +++ b/databases/foundationdb/files/patch-fdbclient_MultiVersionAssignmentVars.h @@ -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); + } + } diff --git a/databases/foundationdb/files/patch-fdbclient_NativeAPI.actor.cpp b/databases/foundationdb/files/patch-fdbclient_NativeAPI.actor.cpp new file mode 100644 index 000000000000..ba3bbbbbac38 --- /dev/null +++ b/databases/foundationdb/files/patch-fdbclient_NativeAPI.actor.cpp @@ -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>() ); + } + diff --git a/databases/foundationdb/files/patch-fdbclient_local.mk b/databases/foundationdb/files/patch-fdbclient_local.mk new file mode 100644 index 000000000000..cc73fae7dfc4 --- /dev/null +++ b/databases/foundationdb/files/patch-fdbclient_local.mk @@ -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 diff --git a/databases/foundationdb/files/patch-fdbmonitor_fdbmonitor.cpp b/databases/foundationdb/files/patch-fdbmonitor_fdbmonitor.cpp new file mode 100644 index 000000000000..98bc4f51dc58 --- /dev/null +++ b/databases/foundationdb/files/patch-fdbmonitor_fdbmonitor.cpp @@ -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 ); diff --git a/databases/foundationdb/files/patch-fdbmonitor_local.mk b/databases/foundationdb/files/patch-fdbmonitor_local.mk new file mode 100644 index 000000000000..0bb6b1cad9d2 --- /dev/null +++ b/databases/foundationdb/files/patch-fdbmonitor_local.mk @@ -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 diff --git a/databases/foundationdb/files/patch-fdbrpc_AsyncFileCached.actor.cpp b/databases/foundationdb/files/patch-fdbrpc_AsyncFileCached.actor.cpp new file mode 100644 index 000000000000..39d3aa56d40a --- /dev/null +++ b/databases/foundationdb/files/patch-fdbrpc_AsyncFileCached.actor.cpp @@ -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 ); + } diff --git a/databases/foundationdb/files/patch-fdbrpc_AsyncFileCached.actor.h b/databases/foundationdb/files/patch-fdbrpc_AsyncFileCached.actor.h new file mode 100644 index 000000000000..ed2addfc30e1 --- /dev/null +++ b/databases/foundationdb/files/patch-fdbrpc_AsyncFileCached.actor.h @@ -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() { diff --git a/databases/foundationdb/files/patch-fdbrpc_IAsyncFile.actor.cpp b/databases/foundationdb/files/patch-fdbrpc_IAsyncFile.actor.cpp new file mode 100644 index 000000000000..53b8b854cda7 --- /dev/null +++ b/databases/foundationdb/files/patch-fdbrpc_IAsyncFile.actor.cpp @@ -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(); + } + diff --git a/databases/foundationdb/files/patch-fdbrpc_Platform.cpp b/databases/foundationdb/files/patch-fdbrpc_Platform.cpp new file mode 100644 index 000000000000..3edbd4ec3031 --- /dev/null +++ b/databases/foundationdb/files/patch-fdbrpc_Platform.cpp @@ -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 diff --git a/databases/foundationdb/files/patch-fdbrpc_local.mk b/databases/foundationdb/files/patch-fdbrpc_local.mk new file mode 100644 index 000000000000..4be61357141f --- /dev/null +++ b/databases/foundationdb/files/patch-fdbrpc_local.mk @@ -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 diff --git a/databases/foundationdb/files/patch-fdbserver_TLogServer.actor.cpp b/databases/foundationdb/files/patch-fdbserver_TLogServer.actor.cpp new file mode 100644 index 000000000000..73588fb017ef --- /dev/null +++ b/databases/foundationdb/files/patch-fdbserver_TLogServer.actor.cpp @@ -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) { diff --git a/databases/foundationdb/files/patch-fdbserver_VFSAsync.cpp b/databases/foundationdb/files/patch-fdbserver_VFSAsync.cpp new file mode 100644 index 000000000000..eac190b230a2 --- /dev/null +++ b/databases/foundationdb/files/patch-fdbserver_VFSAsync.cpp @@ -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(); + } + } diff --git a/databases/foundationdb/files/patch-fdbserver_fdbserver.actor.cpp b/databases/foundationdb/files/patch-fdbserver_fdbserver.actor.cpp new file mode 100644 index 000000000000..412a112cb3b0 --- /dev/null +++ b/databases/foundationdb/files/patch-fdbserver_fdbserver.actor.cpp @@ -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! diff --git a/databases/foundationdb/files/patch-fdbserver_local.mk b/databases/foundationdb/files/patch-fdbserver_local.mk new file mode 100644 index 000000000000..574f567ca4e6 --- /dev/null +++ b/databases/foundationdb/files/patch-fdbserver_local.mk @@ -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) diff --git a/databases/foundationdb/files/patch-fdbserver_worker.actor.cpp b/databases/foundationdb/files/patch-fdbserver_worker.actor.cpp new file mode 100644 index 000000000000..24a7fee686cf --- /dev/null +++ b/databases/foundationdb/files/patch-fdbserver_worker.actor.cpp @@ -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(); diff --git a/databases/foundationdb/files/patch-flow_Deque.h b/databases/foundationdb/files/patch-flow_Deque.h new file mode 100644 index 000000000000..3beb988d029d --- /dev/null +++ b/databases/foundationdb/files/patch-flow_Deque.h @@ -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 diff --git a/databases/foundationdb/files/patch-flow_FastAlloc.cpp b/databases/foundationdb/files/patch-flow_FastAlloc.cpp new file mode 100644 index 000000000000..7cffa1d152e0 --- /dev/null +++ b/databases/foundationdb/files/patch-flow_FastAlloc.cpp @@ -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 diff --git a/databases/foundationdb/files/patch-flow_IThreadPool.cpp b/databases/foundationdb/files/patch-flow_IThreadPool.cpp new file mode 100644 index 000000000000..94c31dd8e08c --- /dev/null +++ b/databases/foundationdb/files/patch-flow_IThreadPool.cpp @@ -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(); diff --git a/databases/foundationdb/files/patch-flow_Net2.actor.cpp b/databases/foundationdb/files/patch-flow_Net2.actor.cpp new file mode 100644 index 000000000000..e3b5f027ee8c --- /dev/null +++ b/databases/foundationdb/files/patch-flow_Net2.actor.cpp @@ -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)); + } + diff --git a/databases/foundationdb/files/patch-flow_Platform.cpp b/databases/foundationdb/files/patch-flow_Platform.cpp new file mode 100644 index 000000000000..e2d121b83c44 --- /dev/null +++ b/databases/foundationdb/files/patch-flow_Platform.cpp @@ -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(); +@@ -1733,7 +1795,7 @@ bool createDirectory( std::string const& + } + TraceEvent(SevError, "CreateDirectory").detail("Directory", directory).GetLastError(); + throw platform_error(); +-#elif (defined(__linux__) || defined(__APPLE__)) ++#elif (defined(__linux__) || defined(__APPLE__)) || defined(__FreeBSD__) + size_t sep = 0; + do { + sep = directory.find_first_of('/', sep + 1); +@@ -1774,7 +1836,7 @@ std::string abspath( std::string const& + if (*x == '/') + *x = CANONICAL_PATH_SEPARATOR; + return nameBuffer; +-#elif (defined(__linux__) || defined(__APPLE__)) ++#elif (defined(__linux__) || defined(__APPLE__)) || defined(__FreeBSD__) + char result[PATH_MAX]; + auto r = realpath( filename.c_str(), result ); + if (!r) { +@@ -1839,7 +1901,7 @@ std::string getUserHomeDirectory() { + + #ifdef _WIN32 + #define FILE_ATTRIBUTE_DATA DWORD +-#elif (defined(__linux__) || defined(__APPLE__)) ++#elif (defined(__linux__) || defined(__APPLE__)) || defined(__FreeBSD__) + #define FILE_ATTRIBUTE_DATA mode_t + #else + #error Port me! +@@ -1848,7 +1910,7 @@ std::string getUserHomeDirectory() { + bool acceptFile( FILE_ATTRIBUTE_DATA fileAttributes, std::string name, std::string extension ) { + #ifdef _WIN32 + return !(fileAttributes & FILE_ATTRIBUTE_DIRECTORY) && StringRef(name).endsWith(extension); +-#elif (defined(__linux__) || defined(__APPLE__)) ++#elif (defined(__linux__) || defined(__APPLE__)) || defined(__FreeBSD__) + return S_ISREG(fileAttributes) && StringRef(name).endsWith(extension); + #else + #error Port me! +@@ -1858,7 +1920,7 @@ bool acceptFile( FILE_ATTRIBUTE_DATA fil + bool acceptDirectory( FILE_ATTRIBUTE_DATA fileAttributes, std::string name, std::string extension ) { + #ifdef _WIN32 + return (fileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0; +-#elif (defined(__linux__) || defined(__APPLE__)) ++#elif (defined(__linux__) || defined(__APPLE__)) || defined(__FreeBSD__) + return S_ISDIR(fileAttributes); + #else + #error Port me! +@@ -1894,7 +1956,7 @@ std::vector<std::string> findFiles( std: + } + FindClose(h); + } +-#elif (defined(__linux__) || defined(__APPLE__)) ++#elif (defined(__linux__) || defined(__APPLE__)) || defined(__FreeBSD__) + DIR *dip; + + if ((dip = opendir(directory.c_str())) != NULL) { +@@ -1958,7 +2020,7 @@ void findFilesRecursively(std::string pa + void threadSleep( double seconds ) { + #ifdef _WIN32 + Sleep( (DWORD)(seconds * 1e3) ); +-#elif (defined(__linux__) || defined(__APPLE__)) ++#elif (defined(__linux__) || defined(__APPLE__)) || defined(__FreeBSD__) + struct timespec req, rem; + + req.tv_sec = seconds; +@@ -1996,7 +2058,7 @@ void makeTemporary( const char* filename + THREAD_HANDLE startThread(void (*func) (void *), void *arg) { + return (void *)_beginthread(func, 0, arg); + } +-#elif (defined(__linux__) || defined(__APPLE__)) ++#elif (defined(__linux__) || defined(__APPLE__)) || defined(__FreeBSD__) + THREAD_HANDLE startThread(void *(*func) (void *), void *arg) { + pthread_t t; + pthread_create(&t, NULL, func, arg); +@@ -2009,7 +2071,7 @@ THREAD_HANDLE startThread(void *(*func) + void waitThread(THREAD_HANDLE thread) { + #ifdef _WIN32 + WaitForSingleObject(thread, INFINITE); +-#elif (defined(__linux__) || defined(__APPLE__)) ++#elif (defined(__linux__) || defined(__APPLE__)) || defined(__FreeBSD__) + pthread_join(thread, NULL); + #else + #error Port me! +@@ -2038,7 +2100,7 @@ int64_t fileSize(std::string const& file + return 0; + else + return file_status.st_size; +-#elif (defined(__linux__) || defined(__APPLE__)) ++#elif (defined(__linux__) || defined(__APPLE__)) || defined(__FreeBSD__) + struct stat file_status; + if(stat(filename.c_str(), &file_status) != 0) + return 0; +@@ -2181,6 +2243,8 @@ std::string getDefaultPluginPath( const + return format( "/usr/lib/foundationdb/plugins/%s.so", plugin_name ); + #elif defined(__APPLE__) + return format( "/usr/local/foundationdb/plugins/%s.dylib", plugin_name ); ++#elif defined(__FreeBSD__) ++ return format( "/usr/local/lib/foundationdb/plugins/%s.so", plugin_name ); + #else + #error Port me! + #endif +@@ -2430,7 +2494,7 @@ void* getImageOffset() { return NULL; } + #endif + + bool isLibraryLoaded(const char* lib_path) { +-#if !defined(__linux__) && !defined(__APPLE__) && !defined(_WIN32) ++#if !defined(__linux__) && !defined(__APPLE__) && !defined(_WIN32) && !defined(__FreeBSD__) + #error Port me! + #endif + +@@ -2446,7 +2510,7 @@ bool isLibraryLoaded(const char* lib_pat + } + + 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 new file mode 100644 index 000000000000..f39a4f863ca8 --- /dev/null +++ b/databases/foundationdb/files/patch-flow_Platform.h @@ -0,0 +1,20 @@ +--- flow/Platform.h.orig 2018-04-22 14:30: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 + +@@ -183,6 +183,8 @@ THREAD_HANDLE startThread(void *(func) ( + #define DYNAMIC_LIB_EXT ".dll" + #elif defined(__linux) + #define DYNAMIC_LIB_EXT ".so" ++#elif defined(__FreeBSD__) ++#define DYNAMIC_LIB_EXT ".so" + #elif defined(__APPLE__) + #define DYNAMIC_LIB_EXT ".dylib" + #else diff --git a/databases/foundationdb/files/patch-flow_ThreadPrimitives.cpp b/databases/foundationdb/files/patch-flow_ThreadPrimitives.cpp new file mode 100644 index 000000000000..46c5b336f7a4 --- /dev/null +++ b/databases/foundationdb/files/patch-flow_ThreadPrimitives.cpp @@ -0,0 +1,38 @@ +--- flow/ThreadPrimitives.cpp.orig 2018-04-24 15:27:55 UTC ++++ flow/ThreadPrimitives.cpp +@@ -37,7 +37,7 @@ extern std::string format( const char *f + Event::Event() { + #ifdef _WIN32 + ev = CreateEvent(NULL, FALSE, FALSE, NULL); +-#elif defined(__linux__) ++#elif defined(__linux__) || defined(__FreeBSD__) + int result = sem_init(&sem, 0, 0); + if (result) + criticalError(FDB_EXIT_INIT_SEMAPHORE, "UnableToInitializeSemaphore", format("Could not initialize semaphore - %s", strerror(errno)).c_str()); +@@ -54,7 +54,7 @@ Event::Event() { + Event::~Event() { + #ifdef _WIN32 + CloseHandle(ev); +-#elif defined(__linux__) ++#elif defined(__linux__) || defined(__FreeBSD__) + sem_destroy(&sem); + #elif defined(__APPLE__) + semaphore_destroy(self, sem); +@@ -66,7 +66,7 @@ Event::~Event() { + void Event::set() { + #ifdef _WIN32 + SetEvent(ev); +-#elif defined(__linux__) ++#elif defined(__linux__) || defined(__FreeBSD__) + sem_post(&sem); + #elif defined(__APPLE__) + semaphore_signal(sem); +@@ -78,7 +78,7 @@ void Event::set() { + void Event::block() { + #ifdef _WIN32 + WaitForSingleObject(ev, INFINITE); +-#elif defined(__linux__) ++#elif defined(__linux__) || defined(__FreeBSD__) + int ret; + do { + ret = sem_wait(&sem); diff --git a/databases/foundationdb/files/patch-flow_ThreadPrimitives.h b/databases/foundationdb/files/patch-flow_ThreadPrimitives.h new file mode 100644 index 000000000000..137a336513d6 --- /dev/null +++ b/databases/foundationdb/files/patch-flow_ThreadPrimitives.h @@ -0,0 +1,34 @@ +--- flow/ThreadPrimitives.h.orig 2018-04-22 14:33:39 UTC ++++ flow/ThreadPrimitives.h +@@ -25,7 +25,7 @@ + #include "Error.h" + #include "Trace.h" + +-#ifdef __linux__ ++#if defined(__linux__) || defined(__FreeBSD__) + #include <semaphore.h> + #endif + +@@ -63,11 +63,11 @@ public: + #endif + } + void leave() { +-#if defined(__linux__) ++#if defined(__linux__) || defined(__FreeBSD__) + __sync_synchronize(); + #endif + isLocked = 0; +-#if defined(__linux__) ++#if defined(__linux__) || defined(__FreeBSD__) + __sync_synchronize(); + #endif + #if VALGRIND +@@ -117,6 +117,8 @@ private: + void* ev; + #elif defined(__linux__) + sem_t sem; ++#elif defined(__FreeBSD__) ++ sem_t sem; + #elif defined(__APPLE__) + mach_port_t self; + semaphore_t sem; diff --git a/databases/foundationdb/files/patch-flow_libs_system_src_error__code.cpp b/databases/foundationdb/files/patch-flow_libs_system_src_error__code.cpp new file mode 100644 index 000000000000..138a354463a6 --- /dev/null +++ b/databases/foundationdb/files/patch-flow_libs_system_src_error__code.cpp @@ -0,0 +1,60 @@ +--- flow/libs/system/src/error_code.cpp.orig 2018-04-19 02:55:50 UTC ++++ flow/libs/system/src/error_code.cpp +@@ -48,7 +48,7 @@ namespace + { + public: + generic_error_category(){} +- const char * name() const; ++ const char * name() const BOOST_SYSTEM_NOEXCEPT; + std::string message( int ev ) const; + }; + +@@ -56,14 +56,14 @@ namespace + { + public: + system_error_category(){} +- const char * name() const; ++ const char * name() const BOOST_SYSTEM_NOEXCEPT; + std::string message( int ev ) const; +- error_condition default_error_condition( int ev ) const; ++ error_condition default_error_condition( int ev ) const BOOST_SYSTEM_NOEXCEPT; + }; + + // generic_error_category implementation ---------------------------------// + +- const char * generic_error_category::name() const ++ const char * generic_error_category::name() const BOOST_SYSTEM_NOEXCEPT + { + return "generic"; + } +@@ -154,12 +154,12 @@ namespace + } + // system_error_category implementation --------------------------------// + +- const char * system_error_category::name() const ++ const char * system_error_category::name() const BOOST_SYSTEM_NOEXCEPT + { + return "system"; + } + +- error_condition system_error_category::default_error_condition( int ev ) const ++ error_condition system_error_category::default_error_condition( int ev ) const BOOST_SYSTEM_NOEXCEPT + { + switch ( ev ) + { +@@ -414,13 +414,13 @@ namespace boost + // address for comparison purposes + # endif + +- BOOST_SYSTEM_DECL const error_category & system_category() ++ BOOST_SYSTEM_DECL const error_category & system_category() BOOST_SYSTEM_NOEXCEPT + { + static const system_error_category system_category_const; + return system_category_const; + } + +- BOOST_SYSTEM_DECL const error_category & generic_category() ++ BOOST_SYSTEM_DECL const error_category & generic_category() BOOST_SYSTEM_NOEXCEPT + { + static const generic_error_category generic_category_const; + return generic_category_const; diff --git a/databases/foundationdb/files/patch-flow_local.mk b/databases/foundationdb/files/patch-flow_local.mk new file mode 100644 index 000000000000..dbb52205a25a --- /dev/null +++ b/databases/foundationdb/files/patch-flow_local.mk @@ -0,0 +1,14 @@ +--- flow/local.mk.orig 2018-04-19 02:55:50 UTC ++++ flow/local.mk +@@ -20,8 +20,9 @@ + + # -*- mode: makefile; -*- + +-flow_CFLAGS := -I$(BOOSTDIR) -I. -Iflow -DUSE_UCONTEXT +-flow_LDFLAGS := ++flow_CFLAGS := -I$(BOOSTDIR)/include -I. -Iflow -DUSE_UCONTEXT ++flow_LDFLAGS := -L$(BOOSTDIR)/lib ++flow_LIBS := -lm -lc++ -lpthread -leio -lexecinfo + + 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 new file mode 100644 index 000000000000..52ca649fa7bf --- /dev/null +++ b/databases/foundationdb/files/patch-foundationdb.conf @@ -0,0 +1,40 @@ +--- 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 new file mode 100644 index 000000000000..8634c2838630 --- /dev/null +++ b/databases/foundationdb/pkg-descr @@ -0,0 +1,3 @@ +A distributed, transactional key-value store. + +WWW: https://www.foundationdb.org/ diff --git a/databases/foundationdb/pkg-plist b/databases/foundationdb/pkg-plist new file mode 100644 index 000000000000..f9b40e7ab7da --- /dev/null +++ b/databases/foundationdb/pkg-plist @@ -0,0 +1,9 @@ +bin/fdbbackup +bin/fdbcli +bin/fdbrestore +@sample etc/foundationdb/foundationdb.conf.sample +lib/foundationdb/backup_agent/backup_agent +sbin/fdbmonitor +sbin/fdbserver +@dir(%%DB_USER%%,%%DB_GROUP%%,) %%DB_DIR%% +@dir(%%DB_USER%%,%%DB_GROUP%%,) %%LOG_DIR%% |