MinGW: Second step of porting to MinGW
This commit is contained in:
74
configure.ac
74
configure.ac
@@ -19,7 +19,7 @@ case $host in
|
|||||||
AC_CHECK_LIB([socket], [main], , [AC_MSG_ERROR([Can not find required library])])
|
AC_CHECK_LIB([socket], [main], , [AC_MSG_ERROR([Can not find required library])])
|
||||||
AC_CHECK_LIB([nsl], [main], , [AC_MSG_ERROR([Can not find required library])])
|
AC_CHECK_LIB([nsl], [main], , [AC_MSG_ERROR([Can not find required library])])
|
||||||
;;
|
;;
|
||||||
*mingw*)
|
*mingw*|*msys*)
|
||||||
target_os_is_win32=true
|
target_os_is_win32=true
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
@@ -84,6 +84,40 @@ AM_CONDITIONAL([HAVE_LIBGCRYPT], [test $ac_cv_lib_gcrypt_gcry_control = yes])
|
|||||||
# For MinGW.
|
# For MinGW.
|
||||||
AC_CHECK_LIB([ws2_32], [gethostbyname])
|
AC_CHECK_LIB([ws2_32], [gethostbyname])
|
||||||
|
|
||||||
|
AC_CHECK_HEADERS([sys/select.h])
|
||||||
|
AC_CHECK_HEADERS([winsock.h winsock2.h ws2tcpip.h],,,[#include <windows.h>])
|
||||||
|
|
||||||
|
#
|
||||||
|
# Check for the type of the fifth argument of select() since MinGW uses
|
||||||
|
# struct __ms_timeval.
|
||||||
|
#
|
||||||
|
|
||||||
|
ac_save_CFLAGS=$CFLAGS
|
||||||
|
CFLAGS="$CFLAGS -Werror"
|
||||||
|
AC_MSG_CHECKING([for the type of the fifth argument of select()])
|
||||||
|
arg_type=void
|
||||||
|
for t in "struct timeval" "struct __ms_timeval"; do
|
||||||
|
AC_COMPILE_IFELSE(
|
||||||
|
[AC_LANG_PROGRAM([
|
||||||
|
#if defined(HAVE_WINSOCK2_H) && defined(HAVE_WS2TCPIP_H)
|
||||||
|
#include <winsock2.h>
|
||||||
|
#include <ws2tcpip.h>
|
||||||
|
#else
|
||||||
|
#ifdef HAVE_SYS_SELECT_H
|
||||||
|
#include <sys/select.h>
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#include <stddef.h>
|
||||||
|
], [return select(0, NULL, NULL, NULL, ($t *)NULL)])],
|
||||||
|
[arg_type=$t; break])
|
||||||
|
done
|
||||||
|
AC_MSG_RESULT(${arg_type})
|
||||||
|
AC_DEFINE_UNQUOTED([SELECT_TIMEVAL_TYPE], [${arg_type}],
|
||||||
|
[Type of the fifth argument of select()])
|
||||||
|
CFLAGS=$ac_save_CFLAGS
|
||||||
|
|
||||||
|
AC_CHECK_FUNCS([tzset])
|
||||||
|
|
||||||
AC_CACHE_CHECK([for sin_len in sock],libiscsi_cv_HAVE_SOCK_SIN_LEN,[
|
AC_CACHE_CHECK([for sin_len in sock],libiscsi_cv_HAVE_SOCK_SIN_LEN,[
|
||||||
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
|
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
@@ -104,30 +138,15 @@ if test x"$libiscsi_cv_NEED_SYS_FILIO_H" = x"yes"; then
|
|||||||
AC_DEFINE(NEED_SYS_FILIO_H,1,[Whether we need sys/filio.h])
|
AC_DEFINE(NEED_SYS_FILIO_H,1,[Whether we need sys/filio.h])
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# check for sys/socket.h
|
AC_CHECK_HEADERS(dnl
|
||||||
dnl Check for sys/socket.h
|
[arpa/inet.h] dnl
|
||||||
AC_CHECK_HEADERS([sys/socket.h])
|
[netinet/in.h] dnl
|
||||||
|
[netinet/tcp.h] dnl
|
||||||
# check for netinet/tcp.h
|
[poll.h] dnl
|
||||||
dnl Check for netinet/tcp.h
|
[sys/socket.h] dnl
|
||||||
AC_CHECK_HEADERS([netinet/tcp.h])
|
[sys/time.h] dnl
|
||||||
|
[sys/uio.h] dnl
|
||||||
# check for netinet/in.h
|
)
|
||||||
dnl Check for netinet/in.h
|
|
||||||
AC_CHECK_HEADERS([netinet/in.h])
|
|
||||||
|
|
||||||
# check for arpa/inet.h
|
|
||||||
dnl Check for arpa/inet.h
|
|
||||||
AC_CHECK_HEADERS([arpa/inet.h])
|
|
||||||
|
|
||||||
# check for sys/uio.h
|
|
||||||
dnl Check for sys/uio.h
|
|
||||||
AC_CHECK_HEADERS([sys/uio.h])
|
|
||||||
|
|
||||||
# check for poll.h
|
|
||||||
dnl Check for poll.h
|
|
||||||
AC_CHECK_HEADERS([poll.h])
|
|
||||||
|
|
||||||
|
|
||||||
AC_CACHE_CHECK([for sockaddr_in6 support],libiscsi_cv_HAVE_SOCKADDR_IN6,[
|
AC_CACHE_CHECK([for sockaddr_in6 support],libiscsi_cv_HAVE_SOCKADDR_IN6,[
|
||||||
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
|
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
|
||||||
@@ -179,6 +198,11 @@ if ! test "$ac_cv_have_cunit" = yes ; then
|
|||||||
fi
|
fi
|
||||||
AM_CONDITIONAL(ISCSITEST, [test "$ac_cv_have_cunit" = yes -a "$enable_shared" = "yes"])
|
AM_CONDITIONAL(ISCSITEST, [test "$ac_cv_have_cunit" = yes -a "$enable_shared" = "yes"])
|
||||||
|
|
||||||
|
AC_CHECK_MEMBER([struct timezone.tz_dsttime],
|
||||||
|
[AC_DEFINE([HAVE_TIMEZONE_TZ_DSTTIME], [1],
|
||||||
|
[Define this macro if struct timezone has tz_dsttime])], [],
|
||||||
|
[#include <sys/time.h>])
|
||||||
|
|
||||||
AC_CHECK_MEMBER([struct CU_SuiteInfo.pSetUpFunc],
|
AC_CHECK_MEMBER([struct CU_SuiteInfo.pSetUpFunc],
|
||||||
[AC_DEFINE([HAVE_CU_SUITEINFO_PSETUPFUNC], 1,
|
[AC_DEFINE([HAVE_CU_SUITEINFO_PSETUPFUNC], 1,
|
||||||
[Define to 1 if struct CU_SuiteInfo has a member called pSetUpFunc])],
|
[Define to 1 if struct CU_SuiteInfo has a member called pSetUpFunc])],
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
AM_CPPFLAGS=-I. -I${srcdir}/../include
|
AM_CPPFLAGS=-I. -I${srcdir}/../include -I${srcdir}/../win32
|
||||||
AM_CFLAGS=$(WARN_CFLAGS)
|
AM_CFLAGS=$(WARN_CFLAGS)
|
||||||
AM_LDFLAGS=-no-undefined
|
AM_LDFLAGS=-no-undefined
|
||||||
LIBS=../lib/libiscsi.la
|
LIBS=../lib/libiscsi.la
|
||||||
|
|||||||
@@ -15,12 +15,17 @@
|
|||||||
along with this program; if not, see <http://www.gnu.org/licenses/>.
|
along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#ifdef HAVE_POLL_H
|
||||||
#include <poll.h>
|
#include <poll.h>
|
||||||
|
#else
|
||||||
|
#include "win32_compat.h"
|
||||||
|
#endif
|
||||||
#include <getopt.h>
|
#include <getopt.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
|
|||||||
@@ -37,7 +37,9 @@
|
|||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
#include <winsock2.h>
|
#include <winsock2.h>
|
||||||
#include "win32/win32_compat.h"
|
#include "win32/win32_compat.h"
|
||||||
|
#ifdef _MSC_VER
|
||||||
#pragma comment(lib, "ws2_32.lib")
|
#pragma comment(lib, "ws2_32.lib")
|
||||||
|
#endif
|
||||||
WSADATA wsaData;
|
WSADATA wsaData;
|
||||||
#else
|
#else
|
||||||
#include <poll.h>
|
#include <poll.h>
|
||||||
|
|||||||
@@ -37,6 +37,14 @@ lib_LTLIBRARIES = libiscsi.la
|
|||||||
libiscsi_la_SOURCES =
|
libiscsi_la_SOURCES =
|
||||||
libiscsi_la_LIBADD = libiscsipriv.la
|
libiscsi_la_LIBADD = libiscsipriv.la
|
||||||
|
|
||||||
|
libiscsi.syms: libiscsi.syms.in
|
||||||
|
cat <$< >$@
|
||||||
|
if TARGET_OS_IS_WIN32
|
||||||
|
echo win32_poll >>$@
|
||||||
|
endif
|
||||||
|
|
||||||
|
EXTRA_libiscsi_la_DEPENDENCIES = libiscsi.syms
|
||||||
|
|
||||||
SOCURRENT=9
|
SOCURRENT=9
|
||||||
SOREVISON=0
|
SOREVISON=0
|
||||||
SOAGE=0
|
SOAGE=0
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
AM_CPPFLAGS = -I${srcdir}/../include
|
AM_CPPFLAGS = -I${srcdir}/../include -I${srcdir}/../win32
|
||||||
AM_CFLAGS = $(WARN_CFLAGS)
|
AM_CFLAGS = $(WARN_CFLAGS)
|
||||||
AM_LDFLAGS = -no-undefined
|
AM_LDFLAGS = -no-undefined
|
||||||
LIBS = ../lib/libiscsi.la
|
LIBS = ../lib/libiscsi.la
|
||||||
|
|||||||
@@ -20,6 +20,8 @@
|
|||||||
|
|
||||||
#ifdef HAVE_POLL_H
|
#ifdef HAVE_POLL_H
|
||||||
#include <poll.h>
|
#include <poll.h>
|
||||||
|
#else
|
||||||
|
#include "win32_compat.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_UNISTD_H
|
#ifdef HAVE_UNISTD_H
|
||||||
|
|||||||
@@ -20,6 +20,8 @@
|
|||||||
|
|
||||||
#ifdef HAVE_POLL_H
|
#ifdef HAVE_POLL_H
|
||||||
#include <poll.h>
|
#include <poll.h>
|
||||||
|
#else
|
||||||
|
#include "win32_compat.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_UNISTD_H
|
#ifdef HAVE_UNISTD_H
|
||||||
|
|||||||
@@ -20,6 +20,8 @@
|
|||||||
|
|
||||||
#ifdef HAVE_POLL_H
|
#ifdef HAVE_POLL_H
|
||||||
#include <poll.h>
|
#include <poll.h>
|
||||||
|
#else
|
||||||
|
#include "win32_compat.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_UNISTD_H
|
#ifdef HAVE_UNISTD_H
|
||||||
|
|||||||
@@ -20,6 +20,8 @@
|
|||||||
|
|
||||||
#ifdef HAVE_POLL_H
|
#ifdef HAVE_POLL_H
|
||||||
#include <poll.h>
|
#include <poll.h>
|
||||||
|
#else
|
||||||
|
#include "win32_compat.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_UNISTD_H
|
#ifdef HAVE_UNISTD_H
|
||||||
|
|||||||
@@ -20,6 +20,8 @@
|
|||||||
|
|
||||||
#ifdef HAVE_POLL_H
|
#ifdef HAVE_POLL_H
|
||||||
#include <poll.h>
|
#include <poll.h>
|
||||||
|
#else
|
||||||
|
#include "win32_compat.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_UNISTD_H
|
#ifdef HAVE_UNISTD_H
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
AM_CPPFLAGS = -I${srcdir}/../include
|
AM_CPPFLAGS = -I${srcdir}/../include -I${srcdir}/../win32
|
||||||
AM_CFLAGS = $(WARN_CFLAGS)
|
AM_CFLAGS = $(WARN_CFLAGS)
|
||||||
AM_LDFLAGS = -no-undefined
|
AM_LDFLAGS = -no-undefined
|
||||||
LIBS = ../lib/libiscsi.la
|
LIBS = ../lib/libiscsi.la
|
||||||
|
|
||||||
bin_PROGRAMS = iscsi-inq iscsi-ls iscsi-perf iscsi-readcapacity16 \
|
bin_PROGRAMS = iscsi-inq iscsi-ls iscsi-swp
|
||||||
iscsi-swp
|
if !TARGET_OS_IS_WIN32
|
||||||
|
bin_PROGRAMS += iscsi-perf iscsi-readcapacity16
|
||||||
|
endif
|
||||||
|
|||||||
@@ -21,7 +21,9 @@
|
|||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
#include <winsock2.h>
|
#include <winsock2.h>
|
||||||
#include "win32_compat.h"
|
#include "win32_compat.h"
|
||||||
|
#ifdef _MSC_VER
|
||||||
#pragma comment(lib, "ws2_32.lib")
|
#pragma comment(lib, "ws2_32.lib")
|
||||||
|
#endif
|
||||||
WSADATA wsaData;
|
WSADATA wsaData;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -21,10 +21,14 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|||||||
THE SOFTWARE.
|
THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
#include "win32_compat.h"
|
#include "win32_compat.h"
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include < time.h >
|
#include <time.h>
|
||||||
|
#ifdef HAVE_SYS_TIME_H
|
||||||
|
#include <sys/time.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#undef poll
|
#undef poll
|
||||||
#undef socket
|
#undef socket
|
||||||
@@ -46,15 +50,13 @@ int win32_inet_pton(int af, const char *src, void *dst)
|
|||||||
struct sockaddr_in sa;
|
struct sockaddr_in sa;
|
||||||
int len = sizeof(SOCKADDR);
|
int len = sizeof(SOCKADDR);
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
int strLen = strlen(src) + 1;
|
|
||||||
#ifdef UNICODE
|
#ifdef UNICODE
|
||||||
|
int strLen = strlen(src) + 1;
|
||||||
wchar_t *srcNonConst = (wchar_t *)malloc(strLen * sizeof(wchar_t));
|
wchar_t *srcNonConst = (wchar_t *)malloc(strLen * sizeof(wchar_t));
|
||||||
memset(srcNonConst, 0, strLen);
|
memset(srcNonConst, 0, strLen);
|
||||||
MultiByteToWideChar(CP_ACP, 0, src, -1, srcNonConst, strLen);
|
MultiByteToWideChar(CP_ACP, 0, src, -1, srcNonConst, strLen);
|
||||||
#else
|
#else
|
||||||
char *srcNonConst = (char *)malloc(strLen);
|
char *srcNonConst = strdup(src);
|
||||||
memset(srcNonConst, 0, strLen);
|
|
||||||
strncpy(srcNonConst, src, strLen);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (WSAStringToAddress(srcNonConst, af, NULL, (LPSOCKADDR)&sa, &len) ==
|
if (WSAStringToAddress(srcNonConst, af, NULL, (LPSOCKADDR)&sa, &len) ==
|
||||||
@@ -72,7 +74,7 @@ int win32_inet_pton(int af, const char *src, void *dst)
|
|||||||
|
|
||||||
int win32_poll(struct pollfd *fds, unsigned int nfds, int timo)
|
int win32_poll(struct pollfd *fds, unsigned int nfds, int timo)
|
||||||
{
|
{
|
||||||
struct timeval timeout, *toptr;
|
SELECT_TIMEVAL_TYPE timeout, *toptr;
|
||||||
fd_set ifds, ofds, efds, *ip, *op;
|
fd_set ifds, ofds, efds, *ip, *op;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
int rc;
|
int rc;
|
||||||
@@ -142,10 +144,12 @@ int win32_poll(struct pollfd *fds, unsigned int nfds, int timo)
|
|||||||
#define DELTA_EPOCH_IN_MICROSECS 11644473600000000ULL
|
#define DELTA_EPOCH_IN_MICROSECS 11644473600000000ULL
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef HAVE_TIMEZONE_TZ_DSTTIME
|
||||||
struct timezone {
|
struct timezone {
|
||||||
int tz_minuteswest; /* minutes W of Greenwich */
|
int tz_minuteswest; /* minutes W of Greenwich */
|
||||||
int tz_dsttime; /* type of dst correction */
|
int tz_dsttime; /* type of dst correction */
|
||||||
};
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
int win32_gettimeofday(struct timeval *tv, struct timezone *tz)
|
int win32_gettimeofday(struct timeval *tv, struct timezone *tz)
|
||||||
{
|
{
|
||||||
@@ -169,7 +173,11 @@ int win32_gettimeofday(struct timeval *tv, struct timezone *tz)
|
|||||||
|
|
||||||
if (NULL != tz) {
|
if (NULL != tz) {
|
||||||
if (!tzflag) {
|
if (!tzflag) {
|
||||||
|
#ifdef HAVE_TZSET
|
||||||
|
tzset();
|
||||||
|
#else
|
||||||
_tzset();
|
_tzset();
|
||||||
|
#endif
|
||||||
tzflag++;
|
tzflag++;
|
||||||
}
|
}
|
||||||
tz->tz_minuteswest = _timezone / 60;
|
tz->tz_minuteswest = _timezone / 60;
|
||||||
|
|||||||
@@ -25,9 +25,6 @@ THE SOFTWARE.
|
|||||||
#ifndef win32_COMPAT_H_
|
#ifndef win32_COMPAT_H_
|
||||||
#define win32_COMPAT_H_
|
#define win32_COMPAT_H_
|
||||||
|
|
||||||
#ifdef _WIN32
|
|
||||||
#define NO_IPv6 1
|
|
||||||
|
|
||||||
#include <winsock2.h>
|
#include <winsock2.h>
|
||||||
#include <ws2tcpip.h>
|
#include <ws2tcpip.h>
|
||||||
#include <ws2ipdef.h>
|
#include <ws2ipdef.h>
|
||||||
@@ -98,7 +95,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);
|
ssize_t win32_readv(int fd, const struct iovec *iov, int iovcnt);
|
||||||
int win32_dup2(int oldfd, int newfd);
|
int win32_dup2(int oldfd, int newfd);
|
||||||
|
|
||||||
#define inline
|
#define inline __inline__
|
||||||
|
|
||||||
#endif // _WIN32
|
|
||||||
#endif // win32_COMPAT_H_
|
#endif // win32_COMPAT_H_
|
||||||
|
|||||||
Reference in New Issue
Block a user