Hi everyone,
I have two questions for the Solaris experts here, both related to  
finding the right way to read the real-time clock from my application  
(running in user's space).

Bottom line is that I need to have a 'rdtsc()' function available on  
Sparc. Currently my
'rdtsc()' function works on Intel/AMD platforms and simply executes the
processor's 'rdtsc' instruction to return a 64-bit integer with the
number of clock tick since power up.

The IA32 version of rdtsc() is:

inline unsigned long long HiresTimer::rdtsc() {
     unsigned long long x;
     asm volatile(
             "rdtsc \n\t"
             : "=A" (x));
     return x;
}


The IA64 version is:

inline unsigned long long HiresTimer::rdtsc() {
     unsigned long high, low;
     asm volatile(
             "rdtsc \n\t"
             : "=a" (low),
               "=d" (high));
     return ((unsigned long long)high << 32) | (low);
}

The above code works perfectly on Solaris 10 on x86 with gcc (3.4.x  
and 4.1.x).

For the Solaris on Sparc, I was able to get this to work on a sparcv9  
system:

inline unsigned long long HiresTimer::rdtsc() {
     unsigned long long tickreg;
     asm ("rd %%tick, %0" : "=r" (tickreg));
     return tickreg;
}

(still with gcc).

Question #1: Is there a way I can do the same thing on a Sparcv8 system?
Does sparcv8 has the 'tick' register at all or the 'tick' register  
was introduced only on newer architectures?

Problem #2: How can I do a similar thing with Sun's CC compiler? The  
'asm' sections are valid only for gcc and I'm not very familiar with  
Sun's CC.

Thank you in advance for any help you can give me.

Fabrizio Bertocci


_______________________________________________
opensolaris-code mailing list
opensolaris-code@opensolaris.org
http://mail.opensolaris.org/mailman/listinfo/opensolaris-code

Reply via email to