OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [gcc.c-torture/] [execute/] [20071030-1.c] - Blame information for rev 801

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 688 jeremybenn
/* PR target/11044 */
2
/* Originator: Tim McGrath <misty-@charter.net> */
3
/* Testcase contributed by Eric Botcazou <ebotcazou@libertysurf.fr> */
4
 
5
/* Testcase copied from gcc.target/i386/loop-3.c */
6
 
7
extern void *memset (void *, int, __SIZE_TYPE__);
8
extern void abort (void);
9
 
10
typedef struct
11
{
12
        unsigned char colormod;
13
} entity_state_t;
14
 
15
typedef struct
16
{
17
        int num_entities;
18
        entity_state_t *entities;
19
} packet_entities_t;
20
 
21
typedef struct
22
{
23
        double senttime;
24
        float ping_time;
25
        packet_entities_t entities;
26
} client_frame_t;
27
 
28
typedef enum
29
{
30
        cs_free,
31
        cs_server,
32
        cs_zombie,
33
        cs_connected,
34
        cs_spawned
35
} sv_client_state_t;
36
 
37
typedef struct client_s
38
{
39
        sv_client_state_t state;
40
        int ping;
41
        client_frame_t frames[64];
42
} client_t;
43
 
44
int CalcPing (client_t *cl)
45
{
46
        float ping;
47
        int count, i;
48
        register client_frame_t *frame;
49
 
50
        if (cl->state == cs_server)
51
                return cl->ping;
52
        ping = 0;
53
        count = 0;
54
        for (frame = cl->frames, i = 0; i < 64; i++, frame++) {
55
                if (frame->ping_time > 0) {
56
                        ping += frame->ping_time;
57
                        count++;
58
                }
59
        }
60
        if (!count)
61
                return 9999;
62
        ping /= count;
63
 
64
        return ping * 1000;
65
}
66
 
67
int main(void)
68
{
69
   client_t cl;
70
 
71
   memset(&cl, 0, sizeof(cl));
72
 
73
   cl.frames[0].ping_time = 1.0f;
74
 
75
   if (CalcPing(&cl) != 1000)
76
     abort();
77
 
78
   return 0;
79
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.