2008-05-30 Vladimir Makarov <vmakarov@redhat.com>
[official-gcc.git] / gcc / testsuite / gcc.target / i386 / pr36064.c
blob7964f280cffb31a34813040f48534de7169e3869
1 /* { dg-do compile } */
2 /* { dg-require-effective-target ilp32 } */
3 /* { dg-options "-O1 -march=core2" } */
5 typedef long long ogg_int64_t;
7 typedef struct vorbis_info
9 long rate;
10 } vorbis_info;
12 typedef struct OggVorbis_File
14 int seekable;
15 int links;
16 ogg_int64_t *pcmlengths;
17 vorbis_info *vi;
18 int ready_state;
19 } OggVorbis_File;
21 extern double ov_time_total (OggVorbis_File * vf, int i);
22 extern int ov_pcm_seek_page (OggVorbis_File * vf, ogg_int64_t pos);
24 int
25 ov_time_seek_page (OggVorbis_File * vf, double seconds)
27 int link = -1;
28 ogg_int64_t pcm_total = 0;
29 double time_total = 0.;
31 if (vf->ready_state < 2)
32 return (-131);
33 if (!vf->seekable)
34 return (-138);
35 if (seconds < 0)
36 return (-131);
38 for (link = 0; link < vf->links; link++)
40 double addsec = ov_time_total (vf, link);
41 if (seconds < time_total + addsec)
42 break;
43 time_total += addsec;
44 pcm_total += vf->pcmlengths[link * 2 + 1];
47 if (link == vf->links)
48 return (-131);
51 ogg_int64_t target =
52 pcm_total + (seconds - time_total) * vf->vi[link].rate;
53 return (ov_pcm_seek_page (vf, target));