[CALUG] gettimeofday()

Jason Dixon jason at dixongroup.net
Sun Mar 29 01:35:46 EDT 2009


On Sat, Mar 28, 2009 at 08:47:26PM -0700, Jason C. Miller wrote:
> I did some digging on Google but, to be frank, I have no idea what to look
> for.  All of the relevant buzzwords come up with completely unrelated
> results.  That's where I'm hoping someone on here might be able to help.
> 
> I wrote a simple application that uses gettimeofday().  The code is below...
> 
> #include <stdio.h>
> #include <sys/time.h>
> int main()
>   {
>     struct timeval TV;
>     struct timezone TZ;
>     printf("%s\n", (gettimeofday( &TV, &TZ ))?"FAILURE":"SUCCESS" );
>   } /* end main() */
> 
> Here's the wierdness.  Gettimeofday() is a system call.  The internet, man
> page, and common knowledge all support that premise.  I have two linux
> machines at home that I'm running this test program on.  The gettimeofday()
> call shows up in the ltrace (understandably) of both machines, however, it
> shows up in the strace of only one of them.
> 
> The machine that does NOT show it as a system call is running FC9
> (2.6.27.7-53.fc9.x86_64 #1 SMP).
> 
> The machine that DOES show it as a system call is FC10
> (2.6.27.19-170.2.35.fc10.i686 #1 SMP).
> 
> The only major difference I see is that one is a 64-bit kernel and the other
> is 32-bit.
> 
> Any ideas?

The ubuntu man pages claim that TZ is obsolete and should be passed as
NULL.  This is the same as OpenBSD, and works for me.  In that case I'm
not sure how it worked for you at all, but hopefully it steers you in
the right direction.

-- 
Jason Dixon
DixonGroup Consulting
http://www.dixongroup.net/




More information about the CALUG mailing list