2 /* { dg-options "-Os" } */
4 /* Based on gethostbyname_r,
5 * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
7 * Licensed under the LGPL v2.1, see the file COPYING.LIB
9 * Extraction / wrapping as test by
10 * Joern Rennecke <joern.rennecke@embecosm.com>
11 * Copyright (C) 2013 Free Software Foundation, Inc.
14 typedef unsigned size_t;
16 typedef unsigned uint32_t;
17 struct resolv_answer
{
23 const unsigned char *rdata
;
38 int *__attribute__ ((noinline
,weak
)) nop (void * p
) { return p
; };
39 void __attribute__ ((noinline
,weak
)) seta (struct resolv_answer
* p
)
43 struct hostent
*result_buf
,
46 struct hostent
**result
,
53 struct resolv_answer a
;
56 *result
= ((void *)0);
60 if ((ssize_t
)buflen
<= 5)
64 addr_list
= (char **)buf
;
66 /* This got turned into branch with conditional move in delay slot. */
67 if ((ssize_t
)buflen
< 256)
73 result_buf
->h_aliases
= alias
;
74 result_buf
->h_addrtype
= 2;
75 result_buf
->h_length
= 4;
76 result_buf
->h_addr_list
= addr_list
;
88 int need_bytes
= sizeof(addr_list
[0]) * (a
.add_count
+ 1 + 1);
90 int ips_len
= a
.add_count
* a
.rdlength
;
92 buflen
-= (need_bytes
+ ips_len
);
93 if ((ssize_t
)buflen
< 0) {
98 result_buf
->h_addrtype
= 2;
105 /* For cse, the 1 was is loaded into a call-saved register;
106 the load was hoisted into a delay slot before the conditional load,
107 clobbering result_buf, which (conditionally) lived in the same
108 call-saved register, because mark_referenced_resources considered the
109 destination of the COND_EXEC only clobbered, but not used. */
122 struct hostent buf
, *res
;
125 ghostbyname_r (&buf
, &c
, 1024, &res
, &i
);
126 ghostbyname_r (&buf
, 0, 1024, &res
, &i
);