struct / union in initializer, RFE #901.
[sdcc.git] / sdcc / support / regression / tests / bug3401973.c
blob8e388bd470bd5eea2ace46cc823321ea8760585b
1 /*
2 * /cygdrive/c/Sandbox/sdcc/sdcc/trunk/sdcc/bin/sdcc.exe -mr2k --nostdlib --nostdinc --fverbose-asm -I../include -c buggy_dequeue.c
4 */
5 #include <testfwk.h>
7 typedef unsigned char u8;
8 typedef unsigned short u16;
10 #define TCB_STATE_RUN 0
11 #define NR_TASKS 16
13 #if !defined(__SDCC_pdk14) && !defined(__SDCC_pdk15) && !defined(__SDCC_pic14) // Not enough RAM
14 __xdata struct tcb {
15 u8 state;
16 u8 thread_id;
17 int *wait;
19 u16 timer;
20 u8 timeout;
22 const int *port;
23 } task_table[NR_TASKS];
27 u8 delaying_task_head;
28 #define NULL_IDX 0xff
30 u16 delay_tick_cnts[NR_TASKS];
31 u8 delay_next [NR_TASKS];
34 void buggy_dequeue( void ) {
35 u8 next_head;
37 /* wake the task up */
38 task_table[ delaying_task_head ].state = TCB_STATE_RUN;
40 next_head = delay_next[delaying_task_head];
41 delay_next[delaying_task_head] = NULL_IDX;
43 delaying_task_head = next_head;
45 #endif
47 void testBug(void)
49 #if !defined(__SDCC_pdk14) && !defined(__SDCC_pdk15) && !defined(__SDCC_pic14) // Not enough RAM
50 delay_tick_cnts[ 0] = 0x7FFF;
51 delay_tick_cnts[ 7] = 0x0020;
52 delay_tick_cnts[ 8] = 0x0290;
53 delay_tick_cnts[10] = 0x1590;
55 delay_next[ 7] = 10;
56 delay_next[10] = 8;
57 delay_next[ 8] = NULL_IDX;
59 delaying_task_head = 7;
61 buggy_dequeue( );
63 ASSERT( delaying_task_head == 10 );
64 ASSERT( delay_next[ 7] == NULL_IDX );
65 ASSERT( delay_next[10] == 8 );
66 ASSERT( delay_next[ 8] == NULL_IDX );
67 #endif