| 1 |
/* { dg-do compile { target ia32 } } */ |
| 2 |
/* { dg-require-effective-target fpic } */ |
| 3 |
/* { dg-options "-O2 -march=tigerlake -fPIC" } */ |
| 4 |
/* { dg-final { scan-assembler-not {(?n)kmovd.*@gotntpoff} } } */ |
| 5 |
|
| 6 |
typedef unsigned short uint16_t; |
| 7 |
typedef int int32_t; |
| 8 |
typedef unsigned int uint32_t; |
| 9 |
typedef unsigned char uint8_t; |
| 10 |
|
| 11 |
typedef uint32_t in_addr_t; |
| 12 |
struct in_addr { in_addr_t s_addr; }; |
| 13 |
|
| 14 |
extern __thread const uint16_t * __libc_tsd_CTYPE_B __attribute__ ((tls_model ("initial-exec"))); |
| 15 |
extern __thread int __libc_errno __attribute__ ((tls_model ("initial-exec"))); |
| 16 |
|
| 17 |
extern unsigned long strtoul (const char*, char**, int); |
| 18 |
extern uint32_t __bswap_32 (in_addr_t); |
| 19 |
int |
| 20 |
inet_aton_end (const char *cp, struct in_addr *addr, const char **endp) |
| 21 |
{ |
| 22 |
static const in_addr_t max[4] = { 0xffffffff, 0xffffff, 0xffff, 0xff }; |
| 23 |
in_addr_t val; |
| 24 |
char c; |
| 25 |
union iaddr |
| 26 |
{ |
| 27 |
uint8_t bytes[4]; |
| 28 |
uint32_t word; |
| 29 |
} res; |
| 30 |
uint8_t *pp = res.bytes; |
| 31 |
int digit; |
| 32 |
|
| 33 |
int saved_errno = __libc_errno; |
| 34 |
__libc_errno = 0; |
| 35 |
res.word = 0; |
| 36 |
c = *cp; |
| 37 |
|
| 38 |
for (;;) |
| 39 |
{ |
| 40 |
if (c < '0' || c > '9') |
| 41 |
goto ret_0; |
| 42 |
{ |
| 43 |
char *endp; |
| 44 |
unsigned long ul = strtoul (cp, &endp, 0); |
| 45 |
if (ul == 0x7fffffffL && __libc_errno == 34) |
| 46 |
goto ret_0; |
| 47 |
if (ul > 0xfffffffful) |
| 48 |
goto ret_0; |
| 49 |
val = ul; |
| 50 |
digit = cp != endp; |
| 51 |
cp = endp; |
| 52 |
} |
| 53 |
c = *cp; |
| 54 |
if (c == '.') |
| 55 |
{ |
| 56 |
if (pp > res.bytes + 2 || val > 0xff) |
| 57 |
goto ret_0; |
| 58 |
*pp++ = val; |
| 59 |
c = *++cp; |
| 60 |
} |
| 61 |
else |
| 62 |
break; |
| 63 |
} |
| 64 |
|
| 65 |
if (!(__libc_tsd_CTYPE_B[(int)c] & 8192)) |
| 66 |
goto ret_0; |
| 67 |
|
| 68 |
if (!digit) |
| 69 |
goto ret_0; |
| 70 |
|
| 71 |
if (val > max[pp - res.bytes]) |
| 72 |
goto ret_0; |
| 73 |
|
| 74 |
if (addr != 0) |
| 75 |
addr->s_addr = res.word | __bswap_32 (val); |
| 76 |
*endp = cp; |
| 77 |
|
| 78 |
__libc_errno = saved_errno; |
| 79 |
return 1; |
| 80 |
|
| 81 |
ret_0: |
| 82 |
__libc_errno = saved_errno; |
| 83 |
return 0; |
| 84 |
} |