[lttng-dev] Bug#751337: [PATCH] tests: test_ctf_writer: replace HOST_NAME_MAX

Jon Bernard jbernard at tuxion.com
Tue Aug 5 16:14:12 EDT 2014


* Sebastian Andrzej Siewior <sebastian at breakpoint.cc> wrote:
> This patch replaces HOST_NAME_MAX by xgethostname() which is a wrapper
> around malloc() + gethostname() to get a large enough buffer to fit the
> hostname.
> xgethostname.c was stolen from coreutils and slightly changed so it
> works without xreallocte().
> 
> This should fix Debian #751337 where the package does not build KFreeBSD
> due to missing HOST_NAME_MAX.

This may also work as well:

    diff --git a/configure.ac b/configure.ac
    index 80eba33..248044e 100644
    --- a/configure.ac
    +++ b/configure.ac
    @@ -50,6 +50,17 @@ AC_C_INLINE
     AC_TYPE_PID_T
     AC_TYPE_SIZE_T

    +# FreeBSD does not define HOST_NAME_MAX
    +AC_CHECK_DECL(HOST_NAME_MAX,,
    +       [
    +        AC_CHECK_DECL(_POSIX_HOST_NAME_MAX,
    +                      AC_DEFINE(HOST_NAME_MAX, _POSIX_HOST_NAME_MAX, []),
    +                      AC_DEFINE(HOST_NAME_MAX, 256, [Define to 256 if neither have HOST_NAME_MAX nor _POSIX_HOST_NAME_MAX]),
    +                      [[#include <limits.h>]])
    +       ],
    +       [[#include <limits.h>]]
    +)
    +
     # Checks for library functions.
     AC_FUNC_MALLOC
     AC_FUNC_MMAP

-- 
Jon



More information about the lttng-dev mailing list