Put you implementation of gettimeofday() in its own library, for instance libwindows_compat.a.
Then, EXPLICITLY list the C library on the link line, after everything else except the compat library, and place -lwindows_compat AFTER it:
Code:
$(LINK) -o myprogram $(MY_OBJS) $(MY_LIBS) -lc libwindows_compat.a
This causes the C library to be linked against BEFORE checking windows_compat. If some future version of the MinGW library includes a gettimeofday() function, it will be used, not the one in libwindows_compat.a