Fixes for compiling under cygwin

Signed-off-by: Yucong Sun <sunyucong@gmail.com>