Fix compile error on netbsd

Include config.h from sources under examples.  Added kevent.udata type
check.
This commit is contained in:
Tatsuhiro Tsujikawa 2012-07-27 22:11:13 +09:00
parent 51c4f4f5b0
commit 05e6d527b1
18 changed files with 97 additions and 26 deletions

View File

@ -59,6 +59,10 @@ AM_CONDITIONAL([HAVE_STDCXX_11],
# Checks for libraries.
# Search for dlsym function, which is used in tests. Linux needs -ldl,
# but netbsd does not need it.
AC_SEARCH_LIBS([dlsym], [dl])
# zlib
PKG_CHECK_MODULES([ZLIB], [zlib >= 1.2.3])
LIBS="$ZLIB_LIBS $LIBS"
@ -163,6 +167,23 @@ AM_CONDITIONAL([HAVE_EPOLL], [ test "x${have_epoll}" = "xyes" ])
AC_CHECK_FUNCS([kqueue], [have_kqueue=yes])
AM_CONDITIONAL([HAVE_KQUEUE], [test "x${have_kqueue}" = "xyes"])
AC_MSG_CHECKING([whether struct kevent.udata is intptr_t])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
#include <sys/types.h>
#include <sys/event.h>
#include <sys/time.h>
]],
[[
struct kevent event;
event.udata = (intptr_t*)(&event);
]])],
[kevent_udata_intptr_t=yes], [kevent_udata_intptr_t=no])
AC_MSG_RESULT([$kevent_udata_intptr_t])
if test "x$kevent_udata_intptr_t" = "xyes"; then
AC_DEFINE([KEVENT_UDATA_INTPTR_T], [1],
[Define to 1 if struct kevent.udata is intptr_t])
fi
if test "x$maintainer_mode" != "xno"; then
CFLAGS="$CFLAGS -Wall -Wextra -Werror"
CFLAGS="$CFLAGS -Wmissing-prototypes -Wstrict-prototypes"

View File

@ -25,9 +25,7 @@
#ifndef EVENT_POLL_H
#define EVENT_POLL_H
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif // HAVE_CONFIG_H
#include "spdylay_config.h"
#ifdef HAVE_EPOLL
# include "EventPoll_epoll.h"

View File

@ -25,6 +25,8 @@
#ifndef EVENT_POLL_EVENT_H
#define EVENT_POLL_EVENT_H
#include "spdylay_config.h"
namespace spdylay {
enum EventPollEvent {

View File

@ -25,6 +25,8 @@
#ifndef EVENT_POLL_EPOLL_H
#define EVENT_POLL_EPOLL_H
#include "spdylay_config.h"
#include <cstdlib>
#include <sys/epoll.h>

View File

@ -29,6 +29,12 @@
#include <cerrno>
#include <cassert>
#ifdef KEVENT_UDATA_INTPTR_T
# define PTR_TO_UDATA(X) (reinterpret_cast<intptr_t>(X))
#else // !KEVENT_UDATA_INTPTR_T
# define PTR_TO_UDATA(X) (X)
#endif // !KEVENT_UDATA_INTPTR_T
namespace spdylay {
EventPoll::EventPoll(size_t max_events)
@ -46,7 +52,7 @@ EventPoll::~EventPoll()
}
delete [] evlist_;
}
int EventPoll::poll(int timeout)
{
timespec ts, *ts_ptr;
@ -74,7 +80,7 @@ int EventPoll::get_num_events()
void* EventPoll::get_user_data(size_t p)
{
return evlist_[p].udata;
return reinterpret_cast<void*>(evlist_[p].udata);
}
int EventPoll::get_events(size_t p)
@ -96,10 +102,10 @@ int update_event(int kq, int fd, int events, void *user_data)
struct kevent changelist[2];
EV_SET(&changelist[0], fd, EVFILT_READ,
EV_ADD | ((events & EP_POLLIN) ? EV_ENABLE : EV_DISABLE),
0, 0, user_data);
0, 0, PTR_TO_UDATA(user_data));
EV_SET(&changelist[1], fd, EVFILT_WRITE,
EV_ADD | ((events & EP_POLLOUT) ? EV_ENABLE : EV_DISABLE),
0, 0, user_data);
0, 0, PTR_TO_UDATA(user_data));
timespec ts = { 0, 0 };
return kevent(kq, changelist, 2, changelist, 0, &ts);
}

View File

@ -25,6 +25,8 @@
#ifndef EVENT_POLL_KQUEUE_H
#define EVENT_POLL_KQUEUE_H
#include "spdylay_config.h"
#include <cstdlib>
#include <sys/types.h>

View File

@ -25,9 +25,7 @@
#ifndef HTML_PARSER_H
#define HTML_PARSER_H
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif // HAVE_CONFIG_H
#include "spdylay_config.h"
#include <vector>
#include <string>

View File

@ -36,7 +36,7 @@ bin_PROGRAMS += shrpx
endif # HAVE_LIBEVENT_OPENSSL
HELPER_OBJECTS = uri.cc util.cc spdylay_ssl.cc
HELPER_HFILES = uri.h util.h spdylay_ssl.h
HELPER_HFILES = uri.h util.h spdylay_ssl.h spdylay_config.h
EVENT_OBJECTS =
EVENT_HFILES = EventPoll.h EventPollEvent.h

View File

@ -25,6 +25,8 @@
#ifndef SPDY_SERVER_H
#define SPDY_SERVER_H
#include "spdylay_config.h"
#include <stdint.h>
#include <sys/types.h>

View File

@ -569,9 +569,8 @@ int SpdyUpstream::rst_stream(Downstream *downstream, int status_code)
LOG(FATAL) << "spdylay_submit_rst_stream() failed: "
<< spdylay_strerror(rv);
DIE();
} else {
return 0;
}
return 0;
}
int SpdyUpstream::window_update(Downstream *downstream)
@ -584,9 +583,8 @@ int SpdyUpstream::window_update(Downstream *downstream)
LOG(FATAL) << "spdylay_submit_window_update() failed: "
<< spdylay_strerror(rv);
DIE();
} else {
return 0;
}
return 0;
}
namespace {
@ -626,7 +624,7 @@ int SpdyUpstream::error_reply(Downstream *downstream, int status_code)
return -1;
}
downstream->set_response_state(Downstream::MSG_COMPLETE);
spdylay_data_provider data_prd;
data_prd.source.ptr = downstream;
data_prd.read_callback = spdy_data_read_callback;
@ -645,9 +643,8 @@ int SpdyUpstream::error_reply(Downstream *downstream, int status_code)
LOG(FATAL) << "spdylay_submit_response() failed: "
<< spdylay_strerror(rv);
DIE();
} else {
return 0;
}
return 0;
}
bufferevent_data_cb SpdyUpstream::get_downstream_readcb()

View File

@ -22,6 +22,11 @@
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef SPDY_H
#define SPDY_H
#include "spdylay_config.h"
#include <signal.h>
#include <vector>
@ -172,7 +177,7 @@ void on_request_recv_callback
hd->submit_response(response_obj.get_status_string(), stream_id,
response_obj.get_headers(), &data_prd);
}
class spdy {
public:
spdy() : server_(0) {}
@ -197,7 +202,7 @@ public:
server_ = new SpdyServer(&config_);
return server_->listen() == 0;
}
int run()
{
return server_->run();
@ -232,3 +237,5 @@ int run(Server& server)
} // namespace reactor
} // namespace spdylay
#endif // SPDY_H

View File

@ -22,9 +22,7 @@
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif // HAVE_CONFIG_H
#include "spdylay_config.h"
#include <sys/types.h>
#include <sys/socket.h>

32
examples/spdylay_config.h Normal file
View File

@ -0,0 +1,32 @@
/*
* Spdylay - SPDY Library
*
* Copyright (c) 2012 Tatsuhiro Tsujikawa
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef SPDYLAY_CONFIG_H
#define SPDYLAY_CONFIG_H
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif // HAVE_CONFIG_H
#endif // SPDYLAY_CONFIG_H

View File

@ -25,6 +25,8 @@
#ifndef SPDYLAY_SSL_H
#define SPDYLAY_SSL_H
#include "spdylay_config.h"
#include <stdint.h>
#include <cstdlib>
#include <sys/time.h>

View File

@ -25,6 +25,8 @@
#ifndef URI_H
#define URI_H
#include "spdylay_config.h"
#include <stdint.h>
#include <string>

View File

@ -25,6 +25,8 @@
#ifndef UTIL_H
#define UTIL_H
#include "spdylay_config.h"
#include <vector>
#include <string>
#include <algorithm>

View File

@ -349,7 +349,7 @@ int spdylay_session_add_frame(spdylay_session *session,
void *abs_frame,
void *aux_data)
{
int r;
int r = 0;
spdylay_outbound_item *item;
item = malloc(sizeof(spdylay_outbound_item));
if(item == NULL) {
@ -929,7 +929,7 @@ int spdylay_session_prep_credential(spdylay_session *session,
static ssize_t spdylay_session_prep_frame(spdylay_session *session,
spdylay_outbound_item *item)
{
ssize_t framebuflen;
ssize_t framebuflen = 0;
if(item->frame_cat == SPDYLAY_CTRL) {
spdylay_frame *frame;
spdylay_frame_type frame_type;

View File

@ -46,7 +46,7 @@ main_LDFLAGS = -static @CUNIT_LIBS@
failmalloc_SOURCES = failmalloc.c failmalloc_test.c failmalloc_test.h \
malloc_wrapper.c malloc_wrapper.h \
spdylay_test_helper.c spdylay_test_helper.h
failmalloc_LDADD = $(main_LDADD) -ldl
failmalloc_LDADD = $(main_LDADD)
failmalloc_LDFLAGS = $(main_LDFLAGS)
AM_CFLAGS = -Wall -I${top_srcdir}/lib -I${top_srcdir}/lib/includes -I${top_builddir}/lib/includes \