Port to MinGW
Compile-tested only. Signed-off-by: Bart Van Assche <bvanassche@acm.org>
This commit is contained in:
@@ -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 <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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 <errno.h>
|
||||
#include <stdio.h>
|
||||
@@ -209,5 +204,3 @@ int win32_dup2(int oldfd, int newfd)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -30,7 +30,7 @@ THE SOFTWARE.
|
||||
|
||||
#include <winsock2.h>
|
||||
#include <ws2tcpip.h>
|
||||
#include <Ws2ipdef.h>
|
||||
#include <ws2ipdef.h>
|
||||
#include <basetsd.h>
|
||||
#include <io.h>
|
||||
#include <malloc.h>
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user