#include "libavutil/error.h"
#include "os_support.h"
+#if HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+
#if HAVE_WINSOCK2_H
#include <winsock2.h>
#include <ws2tcpip.h>
-#ifdef EPROTONOSUPPORT
-# undef EPROTONOSUPPORT
-#endif
+#ifndef EPROTONOSUPPORT
#define EPROTONOSUPPORT WSAEPROTONOSUPPORT
-#ifdef ETIMEDOUT
-# undef ETIMEDOUT
#endif
+#ifndef ETIMEDOUT
#define ETIMEDOUT WSAETIMEDOUT
-#ifdef ECONNREFUSED
-# undef ECONNREFUSED
#endif
+#ifndef ECONNREFUSED
#define ECONNREFUSED WSAECONNREFUSED
-#ifdef EINPROGRESS
-# undef EINPROGRESS
#endif
+#ifndef EINPROGRESS
#define EINPROGRESS WSAEINPROGRESS
+#endif
+
#define getsockopt(a, b, c, d, e) getsockopt(a, b, c, (char*) d, e)
#define setsockopt(a, b, c, d, e) setsockopt(a, b, c, (const char*) d, e)