diff --git a/rak/timer.h b/rak/timer.h index 67bdc1c7..e25ad2e6 100644 --- a/rak/timer.h +++ b/rak/timer.h @@ -49,6 +49,9 @@ class timer { timer(int64_t usec = 0) : m_time(usec) {} timer(timeval tv) : m_time((int64_t)(uint32_t)tv.tv_sec * 1000000 + (int64_t)(uint32_t)tv.tv_usec % 1000000) {} + bool is_zero() const { return m_time == 0; } + bool is_not_zero() const { return m_time != 0; } + int32_t seconds() const { return m_time / 1000000; } int32_t seconds_ceiling() const { return (m_time + 1000000 - 1) / 1000000; } int64_t usec() const { return m_time; } diff --git a/scripts/checks.m4 b/scripts/checks.m4 index 646e5406..598f39b3 100644 --- a/scripts/checks.m4 +++ b/scripts/checks.m4 @@ -21,9 +21,9 @@ AC_DEFUN([TORRENT_CHECK_XFS], [ AC_DEFUN([TORRENT_WITHOUT_XFS], [ AC_ARG_WITH(xfs, - [ --without-xfs Do not check for XFS filesystem support], + AC_HELP_STRING([--without-xfs], [do not check for XFS filesystem support]), [ - if test "$withval" = "yes"; then + if test "$withval" = "yes"; then TORRENT_CHECK_XFS fi ], [ @@ -34,7 +34,7 @@ AC_DEFUN([TORRENT_WITHOUT_XFS], [ AC_DEFUN([TORRENT_WITH_XFS], [ AC_ARG_WITH(xfs, - [ --with-xfs Check for XFS filesystem support], + AC_HELP_STRING([--with-xfs], [check for XFS filesystem support]), [ if test "$withval" = "yes"; then TORRENT_CHECK_XFS @@ -63,7 +63,7 @@ AC_DEFUN([TORRENT_CHECK_EPOLL], [ AC_DEFUN([TORRENT_WITHOUT_EPOLL], [ AC_ARG_WITH(epoll, - [ --without-epoll Do not check for epoll support.], + AC_HELP_STRING([--without-epoll], [do not check for epoll support]), [ if test "$withval" = "yes"; then TORRENT_CHECK_EPOLL @@ -133,7 +133,7 @@ AC_DEFUN([TORRENT_CHECK_KQUEUE_SOCKET_ONLY], [ AC_DEFUN([TORRENT_WITH_KQUEUE], [ AC_ARG_WITH(kqueue, - [ --with-kqueue enable kqueue. [[default=no]]], + AC_HELP_STRING([--with-kqueue], [enable kqueue [[default=no]]]), [ if test "$withval" = "yes"; then TORRENT_CHECK_KQUEUE @@ -145,7 +145,7 @@ AC_DEFUN([TORRENT_WITH_KQUEUE], [ AC_DEFUN([TORRENT_WITHOUT_KQUEUE], [ AC_ARG_WITH(kqueue, - [ --without-kqueue Do not check for kqueue support.], + AC_HELP_STRING([--without-kqueue], [do not check for kqueue support]), [ if test "$withval" = "yes"; then TORRENT_CHECK_KQUEUE @@ -160,8 +160,7 @@ AC_DEFUN([TORRENT_WITHOUT_KQUEUE], [ AC_DEFUN([TORRENT_WITHOUT_VARIABLE_FDSET], [ AC_ARG_WITH(variable-fdset, - - [ --without-variable-fdset do not use non-portable variable sized fd_set's.], + AC_HELP_STRING([--without-variable-fdset], [do not use non-portable variable sized fd_set's]), [ if test "$withval" = "yes"; then AC_DEFINE(USE_VARIABLE_FDSET, 1, defined when we allow the use of fd_set's of any size) @@ -205,7 +204,7 @@ AC_DEFUN([TORRENT_CHECK_POSIX_FALLOCATE], [ AC_DEFUN([TORRENT_WITH_POSIX_FALLOCATE], [ AC_ARG_WITH(posix-fallocate, - [ --with-posix-fallocate Check for and use posix_fallocate to allocate files.], + AC_HELP_STRING([--with-posix-fallocate], [check for and use posix_fallocate to allocate files]), [ if test "$withval" = "yes"; then TORRENT_CHECK_POSIX_FALLOCATE @@ -299,7 +298,7 @@ AC_DEFUN([TORRENT_DISABLED_STATFS], [ AC_DEFUN([TORRENT_WITHOUT_STATVFS], [ AC_ARG_WITH(statvfs, - [ --without-statvfs Don't try to use statvfs to find free diskspace.], + AC_HELP_STRING([--without-statvfs], [don't try to use statvfs to find free diskspace]), [ if test "$withval" = "yes"; then TORRENT_CHECK_STATVFS @@ -314,7 +313,7 @@ AC_DEFUN([TORRENT_WITHOUT_STATVFS], [ AC_DEFUN([TORRENT_WITHOUT_STATFS], [ AC_ARG_WITH(statfs, - [ --without-statfs Don't try to use statfs to find free diskspace.], + AC_HELP_STRING([--without-statfs], [don't try to use statfs to find free diskspace]), [ if test "$have_stat_vfs" = "no"; then if test "$withval" = "yes"; then @@ -336,7 +335,7 @@ AC_DEFUN([TORRENT_WITHOUT_STATFS], [ AC_DEFUN([TORRENT_WITH_ADDRESS_SPACE], [ AC_ARG_WITH(address-space, - AC_HELP_STRING([--with-address-space=MB], [Change the default address space size, default 1024 MB.]), + AC_HELP_STRING([--with-address-space=MB], [change the default address space size [[default=1024mb]]]), [ if test ! -z $withval -a "$withval" != "yes" -a "$withval" != "no"; then AC_DEFINE_UNQUOTED(DEFAULT_ADDRESS_SPACE_SIZE, [$withval]) @@ -402,7 +401,7 @@ AC_DEFUN([TORRENT_CHECK_CXX11], [ AC_DEFUN([TORRENT_WITH_FASTCGI], [ AC_ARG_WITH(fastcgi, - [ --with-fastcgi=PATH Enable FastCGI RPC support. (DO NOT USE)], + AC_HELP_STRING([--with-fastcgi=PATH], [enable FastCGI RPC support (DO NOT USE)]), [ AC_MSG_CHECKING([for FastCGI (DO NOT USE)]) @@ -451,7 +450,7 @@ AC_DEFUN([TORRENT_WITH_XMLRPC_C], [ AC_MSG_CHECKING(for XMLRPC-C) AC_ARG_WITH(xmlrpc-c, - [ --with-xmlrpc-c=PATH Enable XMLRPC-C support.], + AC_HELP_STRING([--with-xmlrpc-c=PATH], [enable XMLRPC-C support]), [ if test "$withval" = "no"; then AC_MSG_RESULT(no) @@ -508,3 +507,33 @@ AC_DEFUN([TORRENT_WITH_INOTIFY], [ AC_LANG_POP(C++) ]) + +AC_DEFUN([TORRENT_CHECK_PTHREAD_SETNAME_NP], [ + AC_CHECK_HEADERS(pthread.h) + + AC_MSG_CHECKING(for pthread_setname_np type) + + AC_TRY_LINK([ + #include + #include + ],[ + pthread_t t; + pthread_setname_np(t, "foo"); + ],[ + AC_DEFINE(HAS_PTHREAD_SETNAME_NP_GENERIC, 1, The function to set pthread name has a pthread_t argumet.) + AC_MSG_RESULT(generic) + ],[ + AC_TRY_LINK([ + #include + #include + ],[ + pthread_t t; + pthread_setname_np("foo"); + ],[ + AC_DEFINE(HAS_PTHREAD_SETNAME_NP_DARWIN, 1, The function to set pthread name has no pthread argument.) + AC_MSG_RESULT(darwin) + ],[ + AC_MSG_RESULT(no) + ]) + ]) +]) diff --git a/scripts/common.m4 b/scripts/common.m4 index af2dc7bc..51276242 100644 --- a/scripts/common.m4 +++ b/scripts/common.m4 @@ -13,7 +13,7 @@ AC_DEFUN([TORRENT_CHECK_CXXFLAGS], [ AC_DEFUN([TORRENT_ENABLE_DEBUG], [ AC_ARG_ENABLE(debug, - [ --enable-debug enable debug information [[default=yes]]], + AC_HELP_STRING([--enable-debug], [enable debug information [[default=yes]]]), [ if test "$enableval" = "yes"; then CXXFLAGS="$CXXFLAGS -g -DDEBUG" @@ -28,7 +28,7 @@ AC_DEFUN([TORRENT_ENABLE_DEBUG], [ AC_DEFUN([TORRENT_ENABLE_WERROR], [ AC_ARG_ENABLE(werror, - [ --enable-werror enable the -Werror and -Wall flag [[default=no]]], + AC_HELP_STRING([--enable-werror], [enable the -Werror and -Wall flag [[default=no]]]), [ if test "$enableval" = "yes"; then CXXFLAGS="$CXXFLAGS -Werror -Wall" @@ -39,7 +39,7 @@ AC_DEFUN([TORRENT_ENABLE_WERROR], [ AC_DEFUN([TORRENT_ENABLE_EXTRA_DEBUG], [ AC_ARG_ENABLE(extra-debug, - [ --enable-extra-debug enable extra debugging checks. [[default=no]]], + AC_HELP_STRING([--enable-extra-debug], [enable extra debugging checks [[default=no]]]), [ if test "$enableval" = "yes"; then AC_DEFINE(USE_EXTRA_DEBUG, 1, Enable extra debugging checks.) @@ -50,7 +50,7 @@ AC_DEFUN([TORRENT_ENABLE_EXTRA_DEBUG], [ AC_DEFUN([TORRENT_WITH_SYSROOT], [ AC_ARG_WITH(sysroot, - [ --with-sysroot=PATH compile and link with a specific sysroot.], + AC_HELP_STRING([--with-sysroot=PATH], [compile and link with a specific sysroot]), [ AC_MSG_CHECKING(for sysroot) @@ -72,7 +72,7 @@ AC_DEFUN([TORRENT_WITH_SYSROOT], [ AC_DEFUN([TORRENT_ENABLE_ARCH], [ AC_ARG_ENABLE(arch, - [ --enable-arch=ARCH comma seprated list of architectures to compile for.], + AC_HELP_STRING([--enable-arch=ARCH], [comma seprated list of architectures to compile for]), [ AC_MSG_CHECKING(for target architectures) @@ -152,7 +152,7 @@ AC_DEFUN([TORRENT_MINCORE_SIGNEDNESS], [ AC_DEFUN([TORRENT_MINCORE], [ AC_ARG_ENABLE(mincore, - [ --disable-mincore disable mincore check [[default=enable]]], + AC_HELP_STRING([--disable-mincore], [disable mincore check [[default=enable]]]), [ if test "$enableval" = "yes"; then TORRENT_MINCORE_SIGNEDNESS() @@ -259,7 +259,7 @@ AC_DEFUN([TORRENT_CHECK_ALIGNED], [ AC_DEFUN([TORRENT_ENABLE_ALIGNED], [ AC_ARG_ENABLE(aligned, - [ --enable-aligned enable alignment safe code [[default=check]]], + AC_HELP_STRING([--enable-aligned], [enable alignment safe code [[default=check]]]), [ if test "$enableval" = "yes"; then AC_DEFINE(USE_ALIGNED, 1, Require byte alignment) @@ -270,9 +270,28 @@ AC_DEFUN([TORRENT_ENABLE_ALIGNED], [ ]) +AC_DEFUN([TORRENT_DISABLE_INSTRUMENTATION], [ + AC_MSG_CHECKING([if instrumentation should be included]) + + AC_ARG_ENABLE(instrumentation, + AC_HELP_STRING([--disable-instrumentation], [disable instrumentation [[default=enabled]]]), + [ + if test "$enableval" = "yes"; then + AC_DEFINE(LT_INSTRUMENTATION, 1, enable instrumentation) + AC_MSG_RESULT(yes) + else + AC_MSG_RESULT(no) + fi + ],[ + AC_DEFINE(LT_INSTRUMENTATION, 1, enable instrumentation) + AC_MSG_RESULT(yes) + ]) +]) + + AC_DEFUN([TORRENT_ENABLE_INTERRUPT_SOCKET], [ AC_ARG_ENABLE(interrupt-socket, - [ --enable-interrupt-socket enable interrupt socket [[default=off]]], + AC_HELP_STRING([--enable-interrupt-socket], [enable interrupt socket [[default=no]]]), [ if test "$enableval" = "yes"; then AC_DEFINE(USE_INTERRUPT_SOCKET, 1, Use interrupt socket instead of pthread_kill) @@ -284,7 +303,7 @@ AC_DEFUN([TORRENT_ENABLE_INTERRUPT_SOCKET], [ AC_DEFUN([TORRENT_DISABLE_IPV6], [ AC_ARG_ENABLE(ipv6, - [ --enable-ipv6 enable ipv6 [[default=no]]], + AC_HELP_STRING([--enable-ipv6], [enable ipv6 [[default=no]]]), [ if test "$enableval" = "yes"; then AC_DEFINE(RAK_USE_INET6, 1, enable ipv6 stuff) @@ -294,7 +313,7 @@ AC_DEFUN([TORRENT_DISABLE_IPV6], [ AC_DEFUN([TORRENT_ENABLE_TR1], [ AC_ARG_ENABLE(std_tr1, - [ --disable-std_tr1 disable check for support for TR1 [[default=enable]]], + AC_HELP_STRING([--disable-std_tr1], [disable check for support for TR1 [[default=enable]]]), [ if test "$enableval" = "yes"; then TORRENT_CHECK_TR1() @@ -309,7 +328,7 @@ AC_DEFUN([TORRENT_ENABLE_TR1], [ AC_DEFUN([TORRENT_ENABLE_CXX11], [ AC_ARG_ENABLE(std_c++11, - [ --disable-std_c++11 disable check for support for C++11 [[default=enable]]], + AC_HELP_STRING([--disable-std_c++11], [disable check for support for C++11 [[default=enable]]]), [ if test "$enableval" = "yes"; then TORRENT_CHECK_CXX11()