Hi Garrett, On Aug 20, 2007, at 11:07 AM, Garrett D'Amore wrote:
> Is there some reason that gethrtime() isn't sufficient? gethrtime() is a great alternative if I cannot find this answer. I was just trying to avoid an extra function call or even a system call (for my understanding gethrtime() should not do any context-switch...) > Second, why do you care about sparcv8? Do you need to link to 32-bit > programs? Or do you *really* need sparcv8? (There are ways to use > Solaris sparcv8plus instructions in a sparcv8 linked program, btw. > But > simpler to just link sparcv8plus if you need 32-bit support on a > sparcv9 > processor.) I don't really have to support sparcv8 architectures. I doubt any of our existing customer runs our product on that architecture. Our product is a library and customers need 32-bit and 64-bit version, so in our build process we compile our sources first to produce 32-bit code (we invoke gcc without any -m options), then 64-bit code (we use -m64). I tried to run a small example using -mv8plus, unfortunately I suspect there's a bug in gcc we're using (3.4.2) and gcc doesn't accept -mv8plus (although the man page list it in the supported architectures). So, in conclusion I cannot find a way to generate 32- bit code with gcc that is able to compile this line: asm ("rd %%tick, %0" : "=r" (tickreg)); I guess gethrtime() is the way to go at this point for Sparc/Sol 32 bit. Thanks a lot, Fabrizio > > -- Garrett > > Fabrizio Bertocci wrote: >> 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 >> > _______________________________________________ opensolaris-code mailing list opensolaris-code@opensolaris.org http://mail.opensolaris.org/mailman/listinfo/opensolaris-code