This is the mail archive of the
gcc-prs@gcc.gnu.org
mailing list for the GCC project.
Re: c/8221: return value of a function is forgotten
- From: Andrew Pinski <pinskia at physics dot uc dot edu>
- To: nobody at gcc dot gnu dot org
- Cc: gcc-prs at gcc dot gnu dot org,
- Date: 14 Oct 2002 09:16:02 -0000
- Subject: Re: c/8221: return value of a function is forgotten
- Reply-to: Andrew Pinski <pinskia at physics dot uc dot edu>
The following reply was made to PR c/8221; it has been noted by GNATS.
From: Andrew Pinski <pinskia@physics.uc.edu>
To: c.kaliszyk@zodiac.mimuw.edu.pl
Cc: gcc-gnats@gcc.gnu.org, cek@wp.pl
Subject: Re: c/8221: return value of a function is forgotten
Date: Mon, 14 Oct 2002 02:12:23 -0700
On Monday, Oct 14, 2002, at 01:44 US/Pacific,
c.kaliszyk@zodiac.mimuw.edu.pl wrote:
> I call "gcc -O2" on this:
> --cut--
> inline int getcputime(void) {
> int i;
> __asm__(
> "rdtsc
> movl %%eax, %0"
> : :"g" (i) :"ax", "dx");
> return i;
> }
>
> int main(void) {
> int x =3D getcputime();
> int y =3D getcputime();
> printf ("Time measure resolution: %i\n", y - x);
> return 0;
> }
I think you constraints are wrong, this works for me:
inline int getcputime(void) {
int i;
__asm__ volatile(
"rdtsc\n\
movl %%eax, %0"
: "=g" (i) : :"eax", "edx");
return i;
}
int main(void) {
int x = getcputime();
int y = getcputime();
printf ("Time measure resolution: %i\n", y - x);
return 0;
}
read
http://gcc.gnu.org/onlinedocs/gcc-3.2/gcc/Extended-Asm.html
for information, this helped me get the correct result.
Thanks,
Andrew Pinski
PS I think this bug is user error so can someone close it.