Skip to content

Modifications to support non-Linux OSes (tested on FreeBSD 14) #32

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jul 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ jobs:
- clearlinux:latest
- gentoo/stage3:musl-hardened
- gentoo/stage3:hardened
- freebsd
config:
- cmake_args: "-DENABLE_API=ON -DCMAKE_C_COMPILER=gcc"
- cmake_args: "-DENABLE_API=ON -DCMAKE_C_COMPILER=clang"
Expand Down Expand Up @@ -52,6 +53,7 @@ jobs:
${{ matrix.os }}/pkg-cache/

- name: Build inside Docker
if: "!startsWith(matrix.os, 'freebsd')"
id: docker-build
run: |
PKG_CACHE_DIR=/pkg-cache
Expand Down Expand Up @@ -167,3 +169,22 @@ jobs:
with:
path: pkg-cache
key: ${{ matrix.os }}/pkg-cache/${{ matrix.config.cmake_args }}/${{ github.sha }}

- name: Build inside FreeBSD VM
if: startsWith(matrix.os, 'freebsd')
uses: vmactions/freebsd-vm@v1
with:
prepare: |
PACKAGES="git cmake pkgconf curl jansson libsodium libmicrohttpd argp-standalone libepoll-shim"
if echo "${{ matrix.config.cmake_args }}" | grep -q "CMAKE_C_COMPILER=gcc"; then
PACKAGES="$PACKAGES gcc"
fi
pkg install -y $PACKAGES

run: |
git config --global --add safe.directory ${{ github.workspace }}
mkdir -p build
cd build
cmake ${{ github.workspace }} -DCMAKE_C_FLAGS='-Wall -Werror' ${{ matrix.config.cmake_args }}
make
./datum_gateway --help
15 changes: 15 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,24 @@ set(ARGP_LIBS "")
check_function_exists(argp_parse HAVE_ARGP_PARSE)
if(NOT HAVE_ARGP_PARSE)
check_library_exists(argp argp_parse "" ARGP)
if(NOT ARGP AND CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
# Workaround bug where CMake doesn't check the standard install location on FreeBSD
unset(ARGP CACHE)
check_library_exists(argp argp_parse "/usr/local/lib" ARGP)
endif()
if(ARGP)
list(APPEND ARGP_LIBS "argp")
endif()
endif()

check_function_exists(epoll_wait HAVE_EPOLL_WAIT)
if(HAVE_EPOLL_WAIT)
set(EPOLL_SHIM_INCLUDE_DIRS "")
set(EPOLL_SHIM_LIBRARIES "")
else()
pkg_check_modules(EPOLL_SHIM REQUIRED epoll-shim)
endif()

cmake_pop_check_state()

add_custom_target(generate_git_version
Expand All @@ -101,6 +114,7 @@ add_custom_command(
target_include_directories(datum_gateway
PRIVATE
$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}>
${EPOLL_SHIM_INCLUDE_DIRS}
${CURL_INCLUDE_DIRS}
${JANSSON_INCLUDE_DIRS}
${SODIUM_INCLUDE_DIRS}
Expand All @@ -116,6 +130,7 @@ target_link_libraries(datum_gateway
${POW_LIBS}
Threads::Threads
${ARGP_LIBS}
${EPOLL_SHIM_LIBRARIES}
${CURL_LIBRARIES} ${CURL_LDFLAGS} ${CURL_LDFLAGS_OTHER}
${JANSSON_LIBRARIES} ${JANSSON_LDFLAGS} ${JANSSON_LDFLAGS_OTHER}
${SODIUM_LIBRARIES} ${SODIUM_LDFLAGS} ${SODIUM_LDFLAGS_OTHER}
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,10 @@ For Clear Linux:

sudo swupd bundle-add c-basic cmake pkgconf devpkg-curl devpkg-jansson devpkg-libsodium devpkg-libmicrohttpd psmisc

For FreeBSD:

sudo pkg install cmake pkgconf curl jansson libsodium libmicrohttpd argp-standalone libepoll-shim

Compile DATUM by running:

cmake . && make
Expand Down
3 changes: 2 additions & 1 deletion src/datum_protocol.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
#include <sys/time.h>
#include <pthread.h>
#include <netinet/tcp.h>
#include <netinet/in.h>
#include <inttypes.h>

#include "datum_utils.h"
Expand Down Expand Up @@ -1629,7 +1630,7 @@ void *datum_protocol_client(void *args) {
server_out_buf = 0;
}
} else {
if (!(errno == EAGAIN || errno == EWOULDBLOCK)) {
if (!(errno == EAGAIN || errno == EWOULDBLOCK || errno == ENOTCONN)) {
pthread_mutex_unlock(&datum_protocol_send_buffer_lock);
break;
}
Expand Down