Bruno Haible <br...@clisp.org> writes: >> It seems clear that FreeBSD isn't POSIX compliant here since >> HOST_NAME_MAX needs to be provided, as far as I can tell. > > So, FreeBSD is POSIX compliant. See [1]: HOST_NAME_MAX is inside a section > that begins with: > "A definition of one of the symbolic constants in the following list > shall be omitted from <limits.h> on specific implementations where the > corresponding value is equal to or greater than the stated minimum, but > is unspecified. > This indetermination might depend on the amount of available memory space > on a specific instance of a specific implementation. The actual value > supported by a specific instance shall be provided by the sysconf() > function."
Hmm, I didn't notice that. Then I'm less sure that it makes sense for gnulib's limit.h to define HOST_NAME_MAX -- programs written against POSIX should not assume that symbol exists. The rationale for adding the symbol was to make the self-test test-gethostname.c build. It uses HOST_NAME_MAX, which is my fault. The proper fix appears to use sysconf if it is available, and otherwise fall back on HOST_NAME_MAX, and otherwise just fail. What do you think? Do sysconf work under mingw? Gnulib could provide a replacement if not. >> I guess looking into FreeBSD libc would answer this. > > [2] simply makes a system call. In the kernel, it's really an access of > an array of size MAXHOSTNAMELEN [3][4]. Thanks, so at least adding it wouldn't hurt, but it doesn't seem like The Right Thing anyway. /Simon > [1] http://www.opengroup.org/onlinepubs/9699919799/basedefs/limits.h.html > [2] http://www.freebsd.org/cgi/cvsweb.cgi/src/lib/libc/gen/gethostname.c > [3] http://www.freebsd.org/cgi/cvsweb.cgi/src/sys/kern/kern_mib.c > [4] http://www.freebsd.org/cgi/cvsweb.cgi/src/sys/sys/jail.h