struct / union in initializer, RFE #901.
[sdcc.git] / sdcc / support / regression / tests / gcc-torture-execute-20071030-1.c
blobcc2062720580bb600240a888896a8b9e156ff8e5
1 /*
2 20071030-1.c from the execute part of the gcc torture suite.
3 */
5 #include <testfwk.h>
7 #ifdef __SDCC
8 #pragma std_c99
9 #pragma disable_warning 93
10 #endif
12 #include <string.h>
14 /* PR target/11044 */
15 /* Originator: Tim McGrath <misty-@charter.net> */
16 /* Testcase contributed by Eric Botcazou <ebotcazou@libertysurf.fr> */
18 /* Testcase copied from gcc.target/i386/loop-3.c */
20 #if !defined(__SDCC_pdk14) && !defined(__SDCC_pdk15) // Lack of memory
21 typedef struct
23 unsigned char colormod;
24 } entity_state_t;
26 typedef struct
28 int num_entities;
29 entity_state_t *entities;
30 } packet_entities_t;
32 typedef struct
34 double senttime;
35 float ping_time;
36 packet_entities_t entities;
37 } client_frame_t;
39 typedef enum
41 cs_free,
42 cs_server,
43 cs_zombie,
44 cs_connected,
45 cs_spawned
46 } sv_client_state_t;
48 typedef struct client_s
50 sv_client_state_t state;
51 int ping;
52 client_frame_t frames[64];
53 } client_t;
55 int CalcPing (client_t *cl)
57 float ping;
58 int count, i;
59 register client_frame_t *frame;
61 if (cl->state == cs_server)
62 return cl->ping;
63 ping = 0;
64 count = 0;
65 for (frame = cl->frames, i = 0; i < 64; i++, frame++) {
66 if (frame->ping_time > 0) {
67 ping += frame->ping_time;
68 count++;
71 if (!count)
72 return 9999;
73 ping /= count;
75 return ping * 1000;
77 #endif
79 void testTortureExecute(void)
81 #if !defined(__SDCC_mcs51) && !defined(__SDCC_pdk14) && !defined(__SDCC_pdk15) && !( (defined (__SDCC_mos6502) || defined(__SDCC_mos65c02 )) && defined(__SDCC_STACK_AUTO) )// Lack of memory
82 client_t cl;
84 memset(&cl, 0, sizeof(cl));
86 cl.frames[0].ping_time = 1.0f;
88 if (CalcPing(&cl) != 1000)
89 ASSERT (0);
91 return;
92 #endif