Skip to content
Merged
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
58 changes: 54 additions & 4 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ try_compile_source()
# LDFLAGS, LDFLAGS_EXTRA - any predetermined flags
try_link_object()
{
eval $CXX $LDFLAGS $LDFLAGS_EXTRA ${3:-} '"$configtmpdir"/"$1"' \
-o '"$configtmpdir"/"$2"' > /dev/null 2>&1
eval $CXX '"$configtmpdir"/"$1"' -o '"$configtmpdir"/"$2"' $LDFLAGS \
$LDFLAGS_EXTRA ${3:-} > /dev/null 2>&1
}

# Test if the compiler accepts an argument (for compilation only); if so add it to named variable.
Expand Down Expand Up @@ -235,6 +235,37 @@ int main()
_EOF
}

write_librt_check()
{
cat << _EOF > "$configtmpdir"/librt-check.cc
#include <dasynq.h>

using rearm = dasynq::rearm;
using loop_t = dasynq::event_loop_n;

class my_timer : public loop_t::timer_impl<my_timer>
{
public:
rearm timer_expiry(loop_t &, int expiry_count)
{
return rearm::REARM;
}
};

int main()
{
loop_t l1;
my_timer t1;

t1.add_timer(l1);
t1.arm_timer_rel(l1, {1,0});
l1.run();
Comment on lines +260 to +262

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For completeness this really should arm the timer also (arm_timer_rel(l1, {1,0}); or similar).


return 0;
}
_EOF
}

# Quote a string to preserve its original form after shell evaluation (except that an empty
# string remains as an empty string).
quote_for_shell()
Expand Down Expand Up @@ -636,8 +667,27 @@ if [ "$AUTO_LDFLAGS" = true ] && [ "$AUTO_CXXFLAGS" = true ]; then
HAS_LTO="false"
fi
fi
if [ "$AUTO_LDFLAGS_BASE" = true ] && [ "$PLATFORM" = FreeBSD ]; then
check_link_argument LDFLAGS_BASE -lrt
if [ "$AUTO_LDFLAGS_BASE" = true ]; then
info "Checking whether linking with librt is required..."
write_librt_check
# CPPFLAGS is included in the following check, because it uses the Dasynq library that can be
# configured by compile-time macros, which can influence the result of this check. For example,
# a user under Linux may specify "-DDASYNQ_HAVE_EPOLL=0" to disable the epoll backend, which
# currently also causes Dasynq to use POSIX timers.
if ! try_compile_source librt-check.cc librt-check.o "$CPPFLAGS -Idasynq/include"; then
sub_info_error "Couldn't compile the test source for the librt check."
fi
if ! try_link_object librt-check.o librt-check; then
if try_link_object librt-check.o librt-check -lrt; then
sub_info "Yes."
LDFLAGS_BASE="$LDFLAGS_BASE -lrt"
LDFLAGS_BASE="${LDFLAGS_BASE# }"
else
sub_info_error "Couldn't link the test object for the librt check."
fi
else
sub_info "No."
fi
fi
if [ "$SUPPORT_CAPABILITIES" != 0 ]; then
if [ "$AUTO_LDFLAGS_LIBCAP" = true ]; then
Expand Down
Loading