diff --git a/configure.ac b/configure.ac index 756b189..383faca 100644 --- a/configure.ac +++ b/configure.ac @@ -77,6 +77,9 @@ AC_CONFIG_HEADER(config.h) AC_CHECK_LIB([gcrypt], [gcry_control]) AM_CONDITIONAL([HAVE_LIBGCRYPT], [test $ac_cv_lib_gcrypt_gcry_control = yes]) +# For MinGW. +AC_CHECK_LIB([ws2_32], [gethostbyname]) + AC_CACHE_CHECK([for sin_len in sock],libiscsi_cv_HAVE_SOCK_SIN_LEN,[ AC_TRY_COMPILE([#include #include diff --git a/lib/init.c b/lib/init.c index ea8b84a..031299a 100644 --- a/lib/init.c +++ b/lib/init.c @@ -293,7 +293,8 @@ iscsi_create_context(const char *initiator_name) while (iscsi->smalloc_size < required) { iscsi->smalloc_size <<= 1; } - ISCSI_LOG(iscsi,5,"small allocation size is %zu byte", iscsi->smalloc_size); + ISCSI_LOG(iscsi, 5, "small allocation size is %u byte", + (uint32_t)iscsi->smalloc_size); ca = getenv("LIBISCSI_CACHE_ALLOCATIONS"); if (!ca || atoi(ca) != 0) { diff --git a/lib/socket.c b/lib/socket.c index 5d3952b..05a3e7d 100644 --- a/lib/socket.c +++ b/lib/socket.c @@ -630,7 +630,8 @@ iscsi_read_from_socket(struct iscsi_context *iscsi) * no need to limit the read to what is available in the socket */ count = hdr_size - in->hdr_pos; - count = recv(iscsi->fd, &in->hdr[in->hdr_pos], count, 0); + count = recv(iscsi->fd, (void *)&in->hdr[in->hdr_pos], + count, 0); if (count == 0) { /* remote side has closed the socket. */ return -1; @@ -681,7 +682,7 @@ iscsi_read_from_socket(struct iscsi_context *iscsi) } buf = &in->data[in->data_pos]; } - count = recv(iscsi->fd, buf, count, 0); + count = recv(iscsi->fd, (void *)buf, count, 0); } if (count == 0) { /* remote side has closed the socket. */ @@ -805,7 +806,8 @@ iscsi_write_to_socket(struct iscsi_context *iscsi) /* Write header and any immediate data */ if (pdu->outdata_written < pdu->outdata.size) { count = send(iscsi->fd, - pdu->outdata.data + pdu->outdata_written, + (void *)(pdu->outdata.data + + pdu->outdata_written), pdu->outdata.size - pdu->outdata_written, socket_flags); if (count == -1) { diff --git a/win32/win32_compat.c b/win32/win32_compat.c index 45bd80d..40bc4ce 100644 --- a/win32/win32_compat.c +++ b/win32/win32_compat.c @@ -21,11 +21,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#ifndef _WIN32 - -static int dummy ATTRIBUTE((unused)); - -#else #include "win32_compat.h" #include #include @@ -209,5 +204,3 @@ int win32_dup2(int oldfd, int newfd) { return 0; } - -#endif diff --git a/win32/win32_compat.h b/win32/win32_compat.h index 5f9a841..6176636 100644 --- a/win32/win32_compat.h +++ b/win32/win32_compat.h @@ -30,7 +30,7 @@ THE SOFTWARE. #include #include -#include +#include #include #include #include @@ -58,10 +58,12 @@ struct pollfd { }; #endif +#ifdef _MSC_VER typedef int ssize_t; typedef int uid_t; typedef int gid_t; typedef int socklen_t; +#endif /* Wrapper macros to call misc. functions win32 is missing */ #define close closesocket @@ -74,12 +76,21 @@ typedef int socklen_t; #define poll(x, y, z) win32_poll(x, y, z) #define inet_pton(x,y,z) win32_inet_pton(x,y,z) #define sleep(x) Sleep(x * 1000) +#ifdef _MSC_VER #define getpid GetCurrentProcessId +#endif #if defined(_MSC_VER) && _MSC_VER < 1900 #define snprintf(a, b, c, ...) _snprintf_s(a, b, b, c, ## __VA_ARGS__) #endif +struct timezone; + +struct iovec { + void *iov_base; + size_t iov_len; +}; + int win32_inet_pton(int af, const char * src, void * dst); int win32_poll(struct pollfd *fds, unsigned int nfsd, int timeout); int win32_gettimeofday(struct timeval *tv, struct timezone *tz); @@ -87,11 +98,6 @@ ssize_t win32_writev(int fd, const struct iovec *iov, int iovcnt); ssize_t win32_readv(int fd, const struct iovec *iov, int iovcnt); int win32_dup2(int oldfd, int newfd); -struct iovec { - void *iov_base; - size_t iov_len; -}; - #define inline #endif // _WIN32