2003-12-26 Guilhem Lavaux <guilhem@kaffe.org>
[official-gcc.git] / gcc / testsuite / gcc.c-torture / execute / 20011008-3.c
blob6d2a18f64a7b1c37ba540fd5ed78133821527ac0
1 extern void exit (int);
2 extern void abort (void);
4 typedef unsigned int u_int32_t;
5 typedef unsigned char u_int8_t;
6 typedef int int32_t;
8 typedef enum {
9 TXNLIST_DELETE,
10 TXNLIST_LSN,
11 TXNLIST_TXNID,
12 TXNLIST_PGNO
13 } db_txnlist_type;
15 struct __db_lsn; typedef struct __db_lsn DB_LSN;
16 struct __db_lsn {
17 u_int32_t file;
18 u_int32_t offset;
20 struct __db_txnlist; typedef struct __db_txnlist DB_TXNLIST;
22 struct __db_txnlist {
23 db_txnlist_type type;
24 struct { struct __db_txnlist *le_next; struct __db_txnlist **le_prev; } links;
25 union {
26 struct {
27 u_int32_t txnid;
28 int32_t generation;
29 int32_t aborted;
30 } t;
31 struct {
34 u_int32_t flags;
35 int32_t fileid;
36 u_int32_t count;
37 char *fname;
38 } d;
39 struct {
40 int32_t ntxns;
41 int32_t maxn;
42 DB_LSN *lsn_array;
43 } l;
44 struct {
45 int32_t nentries;
46 int32_t maxentry;
47 char *fname;
48 int32_t fileid;
49 void *pgno_array;
50 u_int8_t uid[20];
51 } p;
52 } u;
55 int log_compare (const DB_LSN *a, const DB_LSN *b)
57 return 1;
61 int
62 __db_txnlist_lsnadd(int val, DB_TXNLIST *elp, DB_LSN *lsnp, u_int32_t flags)
64 int i;
66 for (i = 0; i < (!(flags & (0x1)) ? 1 : elp->u.l.ntxns); i++)
68 int __j;
69 DB_LSN __tmp;
70 val++;
71 for (__j = 0; __j < elp->u.l.ntxns - 1; __j++)
72 if (log_compare(&elp->u.l.lsn_array[__j], &elp->u.l.lsn_array[__j + 1]) < 0)
74 __tmp = elp->u.l.lsn_array[__j];
75 elp->u.l.lsn_array[__j] = elp->u.l.lsn_array[__j + 1];
76 elp->u.l.lsn_array[__j + 1] = __tmp;
80 *lsnp = elp->u.l.lsn_array[0];
81 return val;
84 #ifndef STACK_SIZE
85 #define VLEN 1235
86 #else
87 #define VLEN (STACK_SIZE/10)
88 #endif
90 int main (void)
92 DB_TXNLIST el;
93 DB_LSN lsn, lsn_a[VLEN];
95 el.u.l.ntxns = VLEN-1;
96 el.u.l.lsn_array = lsn_a;
98 if (__db_txnlist_lsnadd (0, &el, &lsn, 0) != 1)
99 abort ();
101 if (__db_txnlist_lsnadd (0, &el, &lsn, 1) != VLEN-1)
102 abort ();
104 exit (0);