This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: Purpose of _LIBC in resolv/ ?
- From: Adhemerval Zanella <azanella at linux dot vnet dot ibm dot com>
- To: libc-alpha at sourceware dot org
- Date: Wed, 04 Jun 2014 15:44:33 -0300
- Subject: Re: Purpose of _LIBC in resolv/ ?
- Authentication-results: sourceware.org; auth=none
- References: <538D7D3E dot 1000203 at redhat dot com>
Hi,
>From resolv/README I would say to keep the code as close as possible to libbind (the
same way we keep some for gnulib). I am not following libbind development, from looks
like from http://wiki.netbsd.org/individual-software-releases/netresolv/ NetBSD has taken
ownership and there is not recent release since 2009.
I am not sure if anyone has taken care to keep glibc in sync with libbind, but doing a
quick check using inet_addr.c against libbind-6.0 I wouldn't say so. In such cases
I think we need to either decide to keep in sync with libbind (and thus re-testing
and review all the changes that has not landed in glibc) or just remove the _LIBC
defines (which for instance are not complete, since they do not guard the _alias macros).
I am personally in favor of second option.
On 03-06-2014 04:46, Petr Spacek wrote:
> Hello list,
>
> Could somebody explain to me what is the purpose of #ifdef _LIBC in resolv/ ?
>
> 1) Why resolver should behave differently when it is compiled into libc and into application?
>
> 2) It seems that code in resolv/ directory cannot be compiled without _LIBC at least from 2008-12-03 (commit 6f5c3117). I hope I read the code correctly:
>
> int
> __res_vinit(res_state statp, int preinit) {
> FILE *fp;
> char *cp, **pp;
> int n;
> char buf[BUFSIZ];
> int nserv = 0; /* number of nameserver records read from file */
> #ifdef _LIBC
> int nservall = 0; /* number of NS records read, nserv IPv4 only */
> #endif
> // snip
> #ifdef _LIBC
> if (MATCH(buf, "nameserver") && nservall < MAXNS) {
> #else
> if (MATCH(buf, "nameserver") && nserv < MAXNS) {
> #endif
> struct in_addr a;
>
> cp = buf + sizeof("nameserver") - 1;
> while (*cp == ' ' || *cp == '\t')
> cp++;
> if ((*cp != '\0') && (*cp != '\n')
> && __inet_aton(cp, &a)) {
> // the problem is that nservall is not declared without _LIBC
> statp->nsaddr_list[nservall].sin_addr = a;
> statp->nsaddr_list[nservall].sin_family = AF_INET;
> statp->nsaddr_list[nservall].sin_port =
> htons(NAMESERVER_PORT);
> nserv++;
> #ifdef _LIBC
> nservall++;
> } else {
> // snip
>
>
> I'm going to write a patch for DNSSEC support. Can I remove this _LIBC magic as the first step, before I dive into DNSSEC?
>
> Please explain me the purpose of this if it has to stay there.
>
> Thank you for your time!
>