This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libfortran/15516] assembly snippets for nano second resolution wall clock time


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-05-18 14:02 -------
Confirmed, and here is the PPC32 one too (but I do not know how to get the timebase frequency):
Note (long needs to be really a 32bit value and I also wrote this from memory):

unsigned long long GetTimebase(void)
{
  unsigned long low;
  unsigned long high;
  unsinged long high1;
  do
  {
    asm volatile ("mftbu %0":"=r"(high));
    asm volatile ("mftb %0":"=r"(low));
    asm volatile ("mftbu %0":"=r"(high1));
  } while (high != high1);
  return ((unsigned long long)high)<<32ULL|(unsigned long long) low;
}

PPC64 (easier as mftb gives the full timebase register for 64bit processors):

unsigned long long GetTimebase(void)
{
  unsigned long long timebase;
  asm volatile ("mftb %0":"=r"(timebase));
  return timebase;
}

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1
   Last reconfirmed|0000-00-00 00:00:00         |2004-05-18 14:02:39
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15516


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]