summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.target/s390/pr24624.c
blob: bc2070c4b799cf3fae99491ae4ea9e12bc3d0cc6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/* This used to ICE due to a backend problem on s390.  */

/* { dg-do compile } */
/* { dg-options "-O1 -mpacked-stack" } */

typedef unsigned int __u32;
typedef struct
{
  volatile int counter;
} __attribute__ ((aligned (4))) atomic_t;
static __inline__ __attribute__ ((always_inline))
     void atomic_inc (volatile atomic_t * v)
{
  (
    {
    typeof (v->counter) old_val, new_val;
  __asm__ __volatile__ (
	"   l     %0,0(%3)\n" 
	"0: lr    %1,%0\n" 
	"   ar    %1,%4\n" 
	"   cs    %0,%1,0(%3)\n" 
	"   jl    0b": 
	"=&d" (old_val), "=&d" (new_val), "=m" (((atomic_t *) (v))->counter): 
	"a" (v), "d" (1), "m" (((atomic_t *) (v))->counter):
	"cc", "memory");
    });
}
extern unsigned long volatile __attribute__ ((section (".data"))) jiffies;
struct inet_peer
{
  unsigned long dtime;
  atomic_t refcnt;
};
static volatile int peer_total;
int inet_peer_threshold = 65536 + 128;
int inet_peer_minttl = 120 * 100;
int inet_peer_maxttl = 10 * 60 * 100;
static int
cleanup_once (unsigned long ttl)
{
  struct inet_peer *p;
  if (p != ((void *) 0))
    {
      if (((
	     {
	     1;}
	   ) && ((long) (jiffies) - (long) (p->dtime + ttl) < 0)))
	{
	  return -1;
	}
      atomic_inc (&p->refcnt);
    }
}
struct inet_peer *
inet_getpeer (__u32 daddr, int create)
{
  int i;
  int ttl;
  if (peer_total >= inet_peer_threshold)
    ttl = inet_peer_minttl;
  else
    ttl =
      inet_peer_maxttl - (inet_peer_maxttl -
			  inet_peer_minttl) / 100 * peer_total /
      inet_peer_threshold * 100;
  for (i = 0; i < 30 && !cleanup_once (ttl); i++);
}