From d8c4b19351f1146ddc8ba787b583a40c56110886 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Fri, 24 Aug 2012 02:15:57 +0900 Subject: [PATCH] Fix error with w64-mingw32 cross compiler. Add --enable-example option. --- configure.ac | 22 +++++++++++++++++++++- lib/spdylay_gzip.c | 2 ++ lib/spdylay_net.h | 4 ++++ lib/spdylay_session.c | 8 ++++---- 4 files changed, 31 insertions(+), 5 deletions(-) diff --git a/configure.ac b/configure.ac index 48ba9723..60afe04c 100644 --- a/configure.ac +++ b/configure.ac @@ -45,6 +45,11 @@ AC_ARG_ENABLE([maintainer-mode], [Turn on compile time warnings])], [maintainer_mode=$withval], [maintainer_mode=no]) +AC_ARG_ENABLE([examples], + [AS_HELP_STRING([--enable-examples], + [Build example programs])], + [request_examples=$withval], [request_examples=yes]) + dnl Checks for programs AC_PROG_CC AC_PROG_CXX @@ -124,7 +129,12 @@ fi AM_CONDITIONAL([HAVE_LIBXML2], [ test "x${have_libxml2}" = "xyes" ]) # The example programs depend on OpenSSL -enable_examples=$have_openssl +enable_examples=no +if test "x${request_examples}" = "xyes" && + test "x${have_openssl}" = "xyes"; then + enable_examples=yes +fi + AM_CONDITIONAL([ENABLE_EXAMPLES], [ test "x${enable_examples}" = "xyes" ]) # Checks for header files. @@ -140,6 +150,9 @@ AC_CHECK_HEADERS([ \ unistd.h \ ]) +# For ntohl, ntohs in Windows +AC_CHECK_HEADERS([winsock2.h]) + # Checks for typedefs, structures, and compiler characteristics. AC_TYPE_SIZE_T AC_TYPE_SSIZE_T @@ -188,6 +201,13 @@ if test "x$kevent_udata_intptr_t" = "xyes"; then fi AC_LANG_POP() +dnl Windows library for winsock2 +case "${host}" in + *mingw*) + LIBS="$LIBS -lws2_32" + ;; +esac + if test "x$maintainer_mode" != "xno"; then CFLAGS="$CFLAGS -Wall -Wextra -Werror" CFLAGS="$CFLAGS -Wmissing-prototypes -Wstrict-prototypes" diff --git a/lib/spdylay_gzip.c b/lib/spdylay_gzip.c index ab88f66c..f066769f 100644 --- a/lib/spdylay_gzip.c +++ b/lib/spdylay_gzip.c @@ -80,5 +80,7 @@ int spdylay_gzip_inflate(spdylay_gzip *inflater, return SPDYLAY_ERR_GZIP; default: assert(0); + /* We need this for some compilers */ + return 0; } } diff --git a/lib/spdylay_net.h b/lib/spdylay_net.h index 2a080dc6..45a14916 100644 --- a/lib/spdylay_net.h +++ b/lib/spdylay_net.h @@ -37,4 +37,8 @@ # include #endif /* HAVE_NETINET_IN_H */ +#ifdef HAVE_WINSOCK2_H +# include +#endif /* HAVE_WINSOCK2_H */ + #endif /* SPDYLAY_NET_H */ diff --git a/lib/spdylay_session.c b/lib/spdylay_session.c index 2cd21eff..295f9d91 100644 --- a/lib/spdylay_session.c +++ b/lib/spdylay_session.c @@ -2784,16 +2784,16 @@ ssize_t spdylay_session_pack_data(spdylay_session *session, spdylay_data *frame) { ssize_t framelen = datamax+8, r; - int eof; + int eof_flags; uint8_t flags; r = spdylay_reserve_buffer(buf_ptr, buflen_ptr, framelen); if(r != 0) { return r; } - eof = 0; + eof_flags = 0; r = frame->data_prd.read_callback (session, frame->stream_id, (*buf_ptr)+8, datamax, - &eof, &frame->data_prd.source, session->user_data); + &eof_flags, &frame->data_prd.source, session->user_data); if(r == SPDYLAY_ERR_DEFERRED || r == SPDYLAY_ERR_TEMPORAL_CALLBACK_FAILURE) { return r; } else if(r < 0 || datamax < (size_t)r) { @@ -2804,7 +2804,7 @@ ssize_t spdylay_session_pack_data(spdylay_session *session, spdylay_put_uint32be(&(*buf_ptr)[0], frame->stream_id); spdylay_put_uint32be(&(*buf_ptr)[4], r); flags = 0; - if(eof) { + if(eof_flags) { frame->eof = 1; if(frame->flags & SPDYLAY_DATA_FLAG_FIN) { flags |= SPDYLAY_DATA_FLAG_FIN;