Don't redefine timeval in MinGW environments

In MinGW, time.h defines timeval, so we do this to avoid redefinition errors.

Fixes #1856