struct / union in initializer, RFE #901.
[sdcc.git] / sdcc / support / regression / tests / gcc-torture-execute-20011008-3.c
blobb51267b64355b898839c33d8f58d015b0537ebaf
1 /*
2 20011008-1.c from the execute part of the gcc torture tests.
3 */
5 #include <testfwk.h>
7 #ifdef __SDCC
8 #pragma std_c99
9 #pragma disable_warning 85
10 #endif
12 // Hmm, this test uses identifiers tarting in __, which are reserved for the implementation. We probably should rename them. Philipp
14 #include <stdint.h>
16 #if !defined(__SDCC_pdk14) // Lack of memory
17 typedef uint32_t u_int32_t;
18 typedef uint8_t u_int8_t;
20 typedef enum {
21 TXNLIST_DELETE,
22 TXNLIST_LSN,
23 TXNLIST_TXNID,
24 TXNLIST_PGNO
25 } db_txnlist_type;
27 struct __db_lsn; typedef struct __db_lsn DB_LSN;
28 struct __db_lsn {
29 u_int32_t file;
30 u_int32_t offset;
32 struct __db_txnlist; typedef struct __db_txnlist DB_TXNLIST;
34 struct __db_txnlist {
35 db_txnlist_type type;
36 struct { struct __db_txnlist *le_next; struct __db_txnlist **le_prev; } links;
37 union {
38 struct {
39 u_int32_t txnid;
40 int32_t generation;
41 int32_t aborted;
42 } t;
43 struct {
46 u_int32_t flags;
47 int32_t fileid;
48 u_int32_t count;
49 char *fname;
50 } d;
51 struct {
52 int32_t ntxns;
53 int32_t maxn;
54 DB_LSN *lsn_array;
55 } l;
56 struct {
57 int32_t nentries;
58 int32_t maxentry;
59 char *fname;
60 int32_t fileid;
61 void *pgno_array;
62 u_int8_t uid[20];
63 } p;
64 } u;
67 int log_compare (const DB_LSN *a, const DB_LSN *b)
69 return 1;
72 int
73 __db_txnlist_lsnadd(int val, DB_TXNLIST *elp, DB_LSN *lsnp, u_int32_t flags)
75 int i;
77 for (i = 0; i < (!(flags & (0x1)) ? 1 : elp->u.l.ntxns); i++)
79 int __j;
80 DB_LSN __tmp;
81 val++;
82 for (__j = 0; __j < elp->u.l.ntxns - 1; __j++)
83 if (log_compare(&elp->u.l.lsn_array[__j], &elp->u.l.lsn_array[__j + 1]) < 0)
85 __tmp = elp->u.l.lsn_array[__j];
86 elp->u.l.lsn_array[__j] = elp->u.l.lsn_array[__j + 1];
87 elp->u.l.lsn_array[__j + 1] = __tmp;
91 *lsnp = elp->u.l.lsn_array[0];
92 return val;
94 #endif
96 #define VLEN 5 // NOTE: reduced from 1235 to 5 for use with SDCC
98 void
99 testTortureExecute (void)
101 #if !(defined(__SDCC_mcs51) && defined(__SDCC_MODEL_SMALL)) && !defined(__SDCC_pdk14) // Lack of memory
102 DB_TXNLIST el;
103 DB_LSN lsn, lsn_a[VLEN];
105 el.u.l.ntxns = VLEN-1;
106 el.u.l.lsn_array = lsn_a;
108 if (__db_txnlist_lsnadd (0, &el, &lsn, 0) != 1)
109 ASSERT (0);
111 if (__db_txnlist_lsnadd (0, &el, &lsn, 1) != VLEN-1)
112 ASSERT (0);
114 return;
115 #endif