1 /* { dg-add-options stack_size } */
2 
3 extern void exit (int);
4 extern void abort (void);
5 
6 typedef unsigned int u_int32_t;
7 typedef unsigned char u_int8_t;
8 typedef int int32_t;
9 
10 typedef enum {
11         TXNLIST_DELETE,
12         TXNLIST_LSN,
13         TXNLIST_TXNID,
14         TXNLIST_PGNO
15 } db_txnlist_type;
16 
17 struct __db_lsn; typedef struct __db_lsn DB_LSN;
18 struct __db_lsn {
19         u_int32_t file;
20         u_int32_t offset;
21 };
22 struct __db_txnlist; typedef struct __db_txnlist DB_TXNLIST;
23 
24 struct __db_txnlist {
25         db_txnlist_type type;
26         struct { struct __db_txnlist *le_next; struct __db_txnlist **le_prev; } links;
27         union {
28                 struct {
29                         u_int32_t txnid;
30                         int32_t generation;
31                         int32_t aborted;
32                 } t;
33                 struct {
34 
35 
36                         u_int32_t flags;
37                         int32_t fileid;
38                         u_int32_t count;
39                         char *fname;
40                 } d;
41                 struct {
42                         int32_t ntxns;
43                         int32_t maxn;
44                         DB_LSN *lsn_array;
45                 } l;
46                 struct {
47                         int32_t nentries;
48                         int32_t maxentry;
49                         char *fname;
50                         int32_t fileid;
51                         void *pgno_array;
52                         u_int8_t uid[20];
53                 } p;
54         } u;
55 };
56 
log_compare(const DB_LSN * a,const DB_LSN * b)57 int log_compare (const DB_LSN *a, const DB_LSN *b)
58 {
59   return 1;
60 }
61 
62 
63 int
__db_txnlist_lsnadd(int val,DB_TXNLIST * elp,DB_LSN * lsnp,u_int32_t flags)64 __db_txnlist_lsnadd(int val, DB_TXNLIST *elp, DB_LSN *lsnp, u_int32_t flags)
65 {
66    int i;
67 
68    for (i = 0; i < (!(flags & (0x1)) ? 1 : elp->u.l.ntxns); i++)
69      {
70 	int __j;
71 	DB_LSN __tmp;
72 	val++;
73 	for (__j = 0; __j < elp->u.l.ntxns - 1; __j++)
74 	  if (log_compare(&elp->u.l.lsn_array[__j], &elp->u.l.lsn_array[__j + 1]) < 0)
75 	  {
76 	     __tmp = elp->u.l.lsn_array[__j];
77 	     elp->u.l.lsn_array[__j] = elp->u.l.lsn_array[__j + 1];
78 	     elp->u.l.lsn_array[__j + 1] = __tmp;
79 	  }
80      }
81 
82    *lsnp = elp->u.l.lsn_array[0];
83    return val;
84 }
85 
86 #if defined (STACK_SIZE) && STACK_SIZE < 12350
87 #define VLEN (STACK_SIZE/10)
88 #else
89 #define VLEN 1235
90 #endif
91 
main(void)92 int main (void)
93 {
94   DB_TXNLIST el;
95   DB_LSN lsn, lsn_a[VLEN];
96 
97   el.u.l.ntxns = VLEN-1;
98   el.u.l.lsn_array = lsn_a;
99 
100   if (__db_txnlist_lsnadd (0, &el, &lsn, 0) != 1)
101     abort ();
102 
103   if (__db_txnlist_lsnadd (0, &el, &lsn, 1) != VLEN-1)
104     abort ();
105 
106   exit (0);
107 }
108