mbedmicro/mbed — pull request #649 by rgrover (2014-11-04 15:41:50+00:00)
Title: Potential fix for #646

Here's the program I used to unit-test my solution.

```C
#include
#include

using namespace std;

void test(uint64_t headTimestamp, uint32_t currentTimestmap)
{
cout << "head: " << headTimestamp << " current: " << currentTimestmap << " ";

int64_t check = (int)(headTimestamp - currentTimestmap);
cout << "check: " << check << " ";
if (check < 0) {
cout << "elapsed" << endl;
} else {
cout << "NOT elapsed" << endl;
}
}

int main()
{
uint64_t headTimestamp;
// uint64_t headTimestamp = 0xffffffff - 1;
// test(headTimestamp, 0xffffffff);

// headTimestamp = 0xffffffff;
// test(headTimestamp, 0xffffffff);
// headTimestamp = 0xffffffff + 2;
// test(headTimestamp, 0xffffffff);
// test(headTimestamp, 0x0);
// test(headTimestamp, 0x1);
// test(headTimestamp, 0x2);

headTimestamp = 0x100000000ULL * 32 + 1;
test(headTimestamp, 0xffffffff-1000);
test(headTimestamp, 0xffffffff);
test(headTimestamp, 0x0);
test(headTimestamp, 0x1);
test(headTimestamp, 0x2);
}
```