Re: [cc65] gettimeofday()

From: Ullrich von Bassewitz <>
Date: 2012-01-18 21:25:57

On Wed, Jan 18, 2012 at 09:01:22PM +0200, Karri Kaksonen wrote:
> In some variants of C I have seen a function that can track time
> down to microseconds called
>     gettimeofday - get the date and time

gettimeofday is actually POSIX. However, using it has some problems: The POSIX
function takes a time zone and returns time&date - something not possible for
most supported platforms, because of a missing RTC and missing time zone
support. In addition to that, the data types used are slow on the 6502.

So why not add something to the library that has less overhead and is more
tailored to the actual purpose, which is measuring times in games and

For example

    struct currenttime {
        unsigned    sec;
        unsigned    msec;

    struct currenttime getcurrenttime (void);
    /* Return the current time in a struct currenttime. The time is based
     * on some unknown point in the past. Resolution depends on the features
     * of the actual hardware.

(we may as well pass a struct pointer to the function).

Since the function has a name that isn't used in some sort of standard, we can
freely decide on the semantics. Please don't get me wrong, I'm definitely a
friend of standards. But in the given case, there's just too much in the
standard we cannot implement anyway.



Ullrich von Bassewitz                        
To unsubscribe from the list send mail to with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Wed Jan 18 21:26:05 2012

This archive was generated by hypermail 2.1.8 : 2012-01-18 21:26:08 CET