mirror of
git://sourceware.org/git/glibc.git
synced 2025-02-23 13:09:58 +08:00
Update.
* resolv/inet_addr.c (inet_aton): Optimize switch statement away.
This commit is contained in:
parent
61fab08af7
commit
8a40ed6807
@ -1,5 +1,7 @@
|
|||||||
1999-04-29 Ulrich Drepper <drepper@cygnus.com>
|
1999-04-29 Ulrich Drepper <drepper@cygnus.com>
|
||||||
|
|
||||||
|
* resolv/inet_addr.c (inet_aton): Optimize switch statement away.
|
||||||
|
|
||||||
* resolv/inet_pton.c (inet_pton4): Little optimizations.
|
* resolv/inet_pton.c (inet_pton4): Little optimizations.
|
||||||
(inet_pton6): Likewise.
|
(inet_pton6): Likewise.
|
||||||
|
|
||||||
|
12
FAQ.in
12
FAQ.in
@ -1314,6 +1314,18 @@ interface. For compilation with the old API, <db_185.h> has to be included
|
|||||||
(and not <db.h>) and you can link with either `-ldb1' or `-ldb' for either
|
(and not <db.h>) and you can link with either `-ldb1' or `-ldb' for either
|
||||||
of the db formats.
|
of the db formats.
|
||||||
|
|
||||||
|
?? Autoconf's AC_CHECK_FUNC macro reports that a function exists, but
|
||||||
|
when I try to use it, it always returns -1 and sets errno to ENOSYS.
|
||||||
|
|
||||||
|
{ZW} You are using a 2.0 Linux kernel, and the function you are trying to
|
||||||
|
use is only implemented in 2.1/2.2. Libc considers this to be a function
|
||||||
|
which exists, because if you upgrade to a 2.2 kernel, it will work. One
|
||||||
|
such function is sigaltstack.
|
||||||
|
|
||||||
|
Your program should check at runtime whether the function works, and
|
||||||
|
implement a fallback. Note that Autoconf cannot detect unimplemented
|
||||||
|
functions in other systems' C libraries, so you need to do this anyway.
|
||||||
|
|
||||||
|
|
||||||
? Miscellaneous
|
? Miscellaneous
|
||||||
|
|
||||||
|
@ -99,6 +99,7 @@ inet_aton(cp, addr)
|
|||||||
const char *cp;
|
const char *cp;
|
||||||
struct in_addr *addr;
|
struct in_addr *addr;
|
||||||
{
|
{
|
||||||
|
static const u_int32_t max[4] = { 0xffffffff, 0xffffff, 0xffff, 0xff };
|
||||||
register u_int32_t val; /* changed from u_long --david */
|
register u_int32_t val; /* changed from u_long --david */
|
||||||
#ifndef _LIBC
|
#ifndef _LIBC
|
||||||
register int base;
|
register int base;
|
||||||
@ -113,6 +114,8 @@ inet_aton(cp, addr)
|
|||||||
__set_errno (0);
|
__set_errno (0);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
memset (parts, '\0', sizeof (parts));
|
||||||
|
|
||||||
c = *cp;
|
c = *cp;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
/*
|
/*
|
||||||
@ -178,33 +181,14 @@ inet_aton(cp, addr)
|
|||||||
* the number of parts specified.
|
* the number of parts specified.
|
||||||
*/
|
*/
|
||||||
n = pp - parts + 1;
|
n = pp - parts + 1;
|
||||||
switch (n) {
|
|
||||||
|
|
||||||
case 0:
|
if (n == 0 /* initial nondigit */
|
||||||
goto ret_0; /* initial nondigit */
|
|| parts[0] > 0xff || parts[1] > 0xff || parts[2] > 0xff
|
||||||
|
|| val > max[n - 1])
|
||||||
|
goto ret_0;
|
||||||
|
|
||||||
case 1: /* a -- 32 bits */
|
val |= (parts[0] << 24) | (parts[1] << 16) | (parts[2] << 8);
|
||||||
break;
|
|
||||||
|
|
||||||
case 2: /* a.b -- 8.24 bits */
|
|
||||||
if (parts[0] > 0xff || val > 0xffffff)
|
|
||||||
goto ret_0;
|
|
||||||
val |= parts[0] << 24;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 3: /* a.b.c -- 8.8.16 bits */
|
|
||||||
if (parts[0] > 0xff || parts[1] > 0xff || val > 0xffff)
|
|
||||||
goto ret_0;
|
|
||||||
val |= (parts[0] << 24) | (parts[1] << 16);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 4: /* a.b.c.d -- 8.8.8.8 bits */
|
|
||||||
if (parts[0] > 0xff || parts[1] > 0xff || parts[2] > 0xff
|
|
||||||
|| val > 0xff)
|
|
||||||
goto ret_0;
|
|
||||||
val |= (parts[0] << 24) | (parts[1] << 16) | (parts[2] << 8);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (addr)
|
if (addr)
|
||||||
addr->s_addr = htonl(val);
|
addr->s_addr = htonl(val);
|
||||||
|
|
||||||
|
@ -24,6 +24,7 @@ static char rcsid[] = "$Id$";
|
|||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
#include <arpa/nameser.h>
|
#include <arpa/nameser.h>
|
||||||
|
#include <ctype.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <conf/portability.h>
|
#include <conf/portability.h>
|
||||||
|
Loading…
Reference in New Issue
Block a user