cygwin patch by (Felix Buenemann <atmosfear at users dot sourceforge dot net>)