Ah, then what needs doing is to rewrite the function as a test to see if a certain amount of time has passed...
int after(unsigned long start, unsigned long interval)
{
unsigned long finish;
unsigned long now = millis();
if ( interval == 0) return;
finish = start + interval;
if ( finish < start) { // we need to roll over
if ( now < start && now >= finish) return 1;
} else { // we can't roll over
if ( now >= finish || now < start) return 1;
}
return 0;
}
Then you can use it in your code like this...
void blah() {
time0 = millis();
while (Serial.read() != 3) {
if ( after( time0, 3000) return;
You could of course do this...
extern volatile unsigned long timer0_overflow_count;
...
timer0_overflow_count = 0;
...
... but you never know what code you would break in various libraries and internal functions that are using that counter and don't expect it to be reset, not to mention that as an undocumented API it could change at any moment.