Merge from mainline.
[official-gcc.git] / gcc / testsuite / gcc.dg / pr24624.c
blobfbfab0a674291f28dd484f332736e2ad2f2ed7b6
1 /* This used to ICE due to a backend problem on s390. */
3 /* { dg-do compile { target s390*-*-* } } */
4 /* { dg-options "-O1 -mpacked-stack" } */
6 typedef unsigned int __u32;
7 typedef struct
9 volatile int counter;
10 } __attribute__ ((aligned (4))) atomic_t;
11 static __inline__ __attribute__ ((always_inline))
12 void atomic_inc (volatile atomic_t * v)
16 typeof (v->counter) old_val, new_val;
17 __asm__ __volatile__ (
18 " l %0,0(%3)\n"
19 "0: lr %1,%0\n"
20 " ar %1,%4\n"
21 " cs %0,%1,0(%3)\n"
22 " jl 0b":
23 "=&d" (old_val), "=&d" (new_val), "=m" (((atomic_t *) (v))->counter):
24 "a" (v), "d" (1), "m" (((atomic_t *) (v))->counter):
25 "cc", "memory");
26 });
28 extern unsigned long volatile __attribute__ ((section (".data"))) jiffies;
29 struct inet_peer
31 unsigned long dtime;
32 atomic_t refcnt;
34 static volatile int peer_total;
35 int inet_peer_threshold = 65536 + 128;
36 int inet_peer_minttl = 120 * 100;
37 int inet_peer_maxttl = 10 * 60 * 100;
38 static int
39 cleanup_once (unsigned long ttl)
41 struct inet_peer *p;
42 if (p != ((void *) 0))
44 if (((
46 1;}
47 ) && ((long) (jiffies) - (long) (p->dtime + ttl) < 0)))
49 return -1;
51 atomic_inc (&p->refcnt);
54 struct inet_peer *
55 inet_getpeer (__u32 daddr, int create)
57 int i;
58 int ttl;
59 if (peer_total >= inet_peer_threshold)
60 ttl = inet_peer_minttl;
61 else
62 ttl =
63 inet_peer_maxttl - (inet_peer_maxttl -
64 inet_peer_minttl) / 100 * peer_total /
65 inet_peer_threshold * 100;
66 for (i = 0; i < 30 && !cleanup_once (ttl); i++);