From 3d10541474ac371b82dc05250735817cef2a8025 Mon Sep 17 00:00:00 2001 From: Joakim Soderberg Date: Mon, 9 Dec 2013 16:58:16 +0100 Subject: [PATCH 01/38] Fix non-C89 variable declaration. Microsofts C compiler does not support the C99 standard, so variables has to be declared at the start of a scope. --- evdns.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/evdns.c b/evdns.c index 28ea0f6c..ca274a94 100644 --- a/evdns.c +++ b/evdns.c @@ -4047,8 +4047,8 @@ evdns_base_free(struct evdns_base *base, int fail_requests) void evdns_base_clear_host_addresses(struct evdns_base *base) { - EVDNS_LOCK(base); struct hosts_entry *victim; + EVDNS_LOCK(base); while ((victim = TAILQ_FIRST(&base->hostsdb))) { TAILQ_REMOVE(&base->hostsdb, victim, next); mm_free(victim); From e415196a7da61ba32decf508ae4076d7ae5faf20 Mon Sep 17 00:00:00 2001 From: Joakim Soderberg Date: Mon, 9 Dec 2013 18:05:32 +0100 Subject: [PATCH 02/38] Initial CMake commit. --- CMakeLists.txt | 650 +++++++++++++++++++++++++++ WIN32-Code/event2/event-config.h | 363 --------------- WIN32-Code/getopt.c | 153 +++++++ WIN32-Code/getopt.h | 33 ++ WIN32-Code/getopt_long.c | 237 ++++++++++ cmake/CheckFileOffsetBits.c | 14 + cmake/CheckFileOffsetBits.cmake | 43 ++ cmake/CheckFunctionExistsEx.c | 30 ++ cmake/CheckFunctionExistsEx.cmake | 69 +++ cmake/CheckPrototypeDefinition.c.in | 29 ++ cmake/CheckPrototypeDefinition.cmake | 86 ++++ event-config.h.cmake | 500 +++++++++++++++++++++ test/bench_cascade.c | 11 +- 13 files changed, 1850 insertions(+), 368 deletions(-) create mode 100644 CMakeLists.txt delete mode 100644 WIN32-Code/event2/event-config.h create mode 100644 WIN32-Code/getopt.c create mode 100644 WIN32-Code/getopt.h create mode 100644 WIN32-Code/getopt_long.c create mode 100644 cmake/CheckFileOffsetBits.c create mode 100644 cmake/CheckFileOffsetBits.cmake create mode 100644 cmake/CheckFunctionExistsEx.c create mode 100644 cmake/CheckFunctionExistsEx.cmake create mode 100644 cmake/CheckPrototypeDefinition.c.in create mode 100644 cmake/CheckPrototypeDefinition.cmake create mode 100644 event-config.h.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 00000000..2629cea9 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,650 @@ +# +# Libevent CMake project +# +# Based on initial work by: +# Alexey Ozeritsky +# +# Additional changes: +# Brodie Thiesfield +# Joakim Soderberg +# +# Build example: +# +# cd libevent +# md build +# cd build +# cmake -G "Visual Studio 10" .. +# start libevent.sln +# +cmake_minimum_required(VERSION 2.6.0 FATAL_ERROR) + +# get rid of the extra default configurations +set(CMAKE_CONFIGURATION_TYPES "Debug;Release" CACHE STRING "Limited configurations" FORCE) + +project(libevent) + +set(EVENT_NUMERIC_VERSION 0x02010401) +set(EVENT_VERSION "2.1.4-beta") +set(EVENT_PACKAGE_VERSION "") + +option(EVENT__DISABLE_DEBUG_MODE "Define if libevent should build without support for a debug mode" 0) +option(EVENT__DISABLE_MM_REPLACEMENT "Define if libevent should not allow replacing the mm functions" 0) +option(EVENT__DISABLE_THREAD_SUPPORT "Define if libevent should not be compiled with thread support" 0) +option(EVENT__DISABLE_OPENSSL "Define if libevent should build without support for OpenSSL encrpytion" 0) +option(EVENT__DISABLE_BENCHMARK "Defines if libevent should build without the benchmark exectuables" 0) +option(EVENT__DISABLE_TESTS "If tests should be compiled or not" 0) + +# Put the libaries and binaries that get built into directories at the +# top of the build tree rather than in hard-to-find leaf directories. +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin) +set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib) +set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib) + +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake/") +include(CheckFunctionExistsEx) +include(CheckFileOffsetBits) +include(CheckFunctionExists) +include(CheckIncludeFile) +include(CheckIncludeFiles) +include(CheckTypeSize) +include(CheckVariableExists) +include(CheckSymbolExists) +include(CheckStructHasMember) +include(CheckCSourceCompiles) +include(CheckPrototypeDefinition) + +include(FindZLIB) # -> HAVE_LIBZ +include(FindThreads) # -> HAVE_PTHREAD +include(FindPythonInterp) + +# Winsock. +if(WIN32) + set(CMAKE_EXTRA_INCLUDE_FILES winsock2.h ws2tcpip.h) + set(CMAKE_REQUIRED_LIBRARIES ws2_32.lib) + set(CMAKE_REQUIRED_DEFINITIONS -FIwinsock2.h -FIws2tcpip.h) +endif() + +# Check if _GNU_SOURCE is available. +CHECK_SYMBOL_EXISTS(__GNU_LIBRARY__ "features.h" _GNU_SOURCE) + +if (_GNU_SOURCE) + add_definitions(-D_GNU_SOURCE) +endif() + +CHECK_INCLUDE_FILE(sys/types.h EVENT__HAVE_SYS_TYPES_H) +if(EVENT__HAVE_SYS_TYPES_H) + list(APPEND CMAKE_EXTRA_INCLUDE_FILES sys/types.h) +endif() + +CHECK_INCLUDE_FILE(sys/socket.h EVENT__HAVE_SYS_SOCKET_H) +if(EVENT__HAVE_SYS_SOCKET_H) + list(APPEND CMAKE_EXTRA_INCLUDE_FILES sys/socket.h) +endif() + +CHECK_INCLUDE_FILE(netinet/in.h EVENT__HAVE_NETINET_IN_H) +if(EVENT__HAVE_NETINET_IN_H) + list(APPEND CMAKE_EXTRA_INCLUDE_FILES netinet/in.h) +endif() + +CHECK_INCLUDE_FILE(netinet/in6.h EVENT__HAVE_NETINET_IN6_H) +if(EVENT__HAVE_NETINET_IN6_H) + list(APPEND CMAKE_EXTRA_INCLUDE_FILES netinet/in6.h) +endif() + +CHECK_INCLUDE_FILE(unistd.h EVENT__HAVE_UNISTD_H) +CHECK_INCLUDE_FILE(netdb.h EVENT__HAVE_NETDB_H) +CHECK_INCLUDE_FILE(dlfcn.h EVENT__HAVE_DLFCN_H) +CHECK_INCLUDE_FILE(arpa/inet.h EVENT__HAVE_ARPA_INET_H) +CHECK_INCLUDE_FILE(fcntl.h EVENT__HAVE_FCNTL_H) +if(EVENT__HAVE_FCNTL_H) + list(APPEND CMAKE_EXTRA_INCLUDE_FILES fcntl.h) +endif() +CHECK_INCLUDE_FILE(inttypes.h EVENT__HAVE_INTTYPES_H) +CHECK_INCLUDE_FILE(memory.h EVENT__HAVE_MEMORY_H) +CHECK_INCLUDE_FILE(poll.h EVENT__HAVE_POLL_H) +CHECK_INCLUDE_FILE(port.h EVENT__HAVE_PORT_H) +if(EVENT__HAVE_PORT_H) + list(APPEND CMAKE_EXTRA_INCLUDE_FILES port.h) +endif() +CHECK_INCLUDE_FILE(signal.h EVENT__HAVE_SIGNAL_H) +CHECK_INCLUDE_FILE(stdarg.h EVENT__HAVE_STDARG_H) +CHECK_INCLUDE_FILE(stddef.h EVENT__HAVE_STDDEF_H) +CHECK_INCLUDE_FILE(stdint.h EVENT__HAVE_STDINT_H) +CHECK_INCLUDE_FILE(stdlib.h EVENT__HAVE_STDLIB_H) +CHECK_INCLUDE_FILE(strings.h EVENT__HAVE_STRINGS_H) +CHECK_INCLUDE_FILE(string.h EVENT__HAVE_STRING_H) +CHECK_INCLUDE_FILE(sys/devpoll.h EVENT__HAVE_SYS_DEVPOLL_H) +CHECK_INCLUDE_FILE(sys/epoll.h EVENT__HAVE_SYS_EPOLL_H) +CHECK_INCLUDE_FILE(sys/eventfd.h EVENT__HAVE_SYS_EVENTFD_H) +CHECK_INCLUDE_FILE(sys/event.h EVENT__HAVE_SYS_EVENT_H) +CHECK_INCLUDE_FILE(sys/ioctl.h EVENT__HAVE_SYS_IOCTL_H) +CHECK_INCLUDE_FILE(sys/mman.h EVENT__HAVE_SYS_MMAN_H) +CHECK_INCLUDE_FILE(sys/param.h EVENT__HAVE_SYS_PARAM_H) +CHECK_INCLUDE_FILE(sys/queue.h EVENT__HAVE_SYS_QUEUE_H) +CHECK_INCLUDE_FILE(sys/select.h EVENT__HAVE_SYS_SELECT_H) +CHECK_INCLUDE_FILE(sys/sendfile.h EVENT__HAVE_SYS_SENDFILE_H) +CHECK_INCLUDE_FILE(sys/stat.h EVENT__HAVE_SYS_STAT_H) +CHECK_INCLUDE_FILE(sys/time.h EVENT__HAVE_SYS_TIME_H) +if(EVENT__HAVE_SYS_TIME_H) + list(APPEND CMAKE_EXTRA_INCLUDE_FILES sys/time.h) +endif() +CHECK_INCLUDE_FILE(sys/uio.h EVENT__HAVE_SYS_UIO_H) +CHECK_INCLUDE_FILES("sys/types.h;ifaddrs.h" EVENT__HAVE_IFADDRS_H) +CHECK_INCLUDE_FILE(mach/mach_time.h EVENT__HAVE_MACH_MACH_TIME_H) +CHECK_INCLUDE_FILE(netdb.h EVENT__HAVE_NETDB_H) +CHECK_INCLUDE_FILE(netinet/tcp.h EVENT__HAVE_NETINET_TCP_H) +CHECK_INCLUDE_FILE(sys/wait.h EVENT__HAVE_SYS_WAIT_H) +CHECK_INCLUDE_FILE(sys/resource.h EVENT__HAVE_SYS_RESOURCE_H) +CHECK_INCLUDE_FILE(sys/sysctl.h EVENT__HAVE_SYS_SYSCTL_H) +CHECK_INCLUDE_FILE(sys/timerfd.h EVENT__HAVE_SYS_TIMERFD_H) + + +CHECK_FUNCTION_EXISTS_EX(epoll_create EVENT__HAVE_EPOLL) +CHECK_FUNCTION_EXISTS_EX(epoll_ctl EVENT__HAVE_EPOLL_CTL) +CHECK_FUNCTION_EXISTS_EX(eventfd EVENT__HAVE_EVENTFD) +CHECK_FUNCTION_EXISTS_EX(clock_gettime EVENT__HAVE_CLOCK_GETTIME) +CHECK_FUNCTION_EXISTS_EX(fcntl EVENT__HAVE_FCNTL) +CHECK_FUNCTION_EXISTS_EX(getaddrinfo EVENT__HAVE_GETADDRINFO) +CHECK_FUNCTION_EXISTS_EX(getnameinfo EVENT__HAVE_GETNAMEINFO) +CHECK_FUNCTION_EXISTS_EX(gettimeofday EVENT__HAVE_GETTIMEOFDAY) +CHECK_FUNCTION_EXISTS_EX(getprotobynumber EVENT__HAVE_GETPROTOBYNUMBER) +CHECK_FUNCTION_EXISTS_EX(getservbyname EVENT__HAVE_GETSERVBYNAME) +CHECK_FUNCTION_EXISTS_EX(inet_aton EVENT__HAVE_INET_ATON) +CHECK_FUNCTION_EXISTS_EX(inet_ntop EVENT__HAVE_INET_NTOP) +CHECK_FUNCTION_EXISTS_EX(inet_pton EVENT__HAVE_INET_PTON) +CHECK_FUNCTION_EXISTS_EX(kqueue EVENT__HAVE_KQUEUE) +CHECK_FUNCTION_EXISTS_EX(mmap EVENT__HAVE_MMAP) +CHECK_FUNCTION_EXISTS_EX(pipe EVENT__HAVE_PIPE) +CHECK_FUNCTION_EXISTS_EX(pipe2 EVENT__HAVE_PIPE2) +CHECK_FUNCTION_EXISTS_EX(poll EVENT__HAVE_POLL) +CHECK_FUNCTION_EXISTS_EX(port_create EVENT__HAVE_PORT_CREATE) +CHECK_FUNCTION_EXISTS_EX(sendfile EVENT__HAVE_SENDFILE) +CHECK_FUNCTION_EXISTS_EX(sigaction EVENT__HAVE_SIGACTION) +CHECK_FUNCTION_EXISTS_EX(signal EVENT__HAVE_SIGNAL) +CHECK_FUNCTION_EXISTS_EX(splice EVENT__HAVE_SPLICE) +CHECK_FUNCTION_EXISTS_EX(strlcpy EVENT__HAVE_STRLCPY) +CHECK_FUNCTION_EXISTS_EX(strsep EVENT__HAVE_STRSEP) +CHECK_FUNCTION_EXISTS_EX(strtok_r EVENT__HAVE_STRTOK_R) +CHECK_FUNCTION_EXISTS_EX(strtoll EVENT__HAVE_STRTOLL) +CHECK_FUNCTION_EXISTS_EX(vasprintf EVENT__HAVE_VASPRINTF) +CHECK_FUNCTION_EXISTS_EX(sysctl EVENT__HAVE_SYSCTL) +CHECK_FUNCTION_EXISTS_EX(accept4 EVENT__HAVE_ACCEPT4) +CHECK_FUNCTION_EXISTS_EX(arc4random EVENT__HAVE_ARC4RANDOM) +CHECK_FUNCTION_EXISTS_EX(arc4random_buf EVENT__HAVE_ARC4RANDOM_BUF) +CHECK_FUNCTION_EXISTS_EX(epoll_create1 EVENT__HAVE_EPOLL_CREATE1) +CHECK_FUNCTION_EXISTS_EX(getegid EVENT__HAVE_GETEGID) +CHECK_FUNCTION_EXISTS_EX(geteuid EVENT__HAVE_GETEUID) +CHECK_FUNCTION_EXISTS_EX(getifaddrs EVENT__HAVE_GETIFADDRS) +CHECK_FUNCTION_EXISTS_EX(issetugid EVENT__HAVE_ISSETUGID) +CHECK_FUNCTION_EXISTS_EX(mach_absolute_time EVENT__HAVE_MACH_ABSOLUTE_TIME) +CHECK_FUNCTION_EXISTS_EX(nanosleep EVENT__HAVE_NANOSLEEP) +CHECK_FUNCTION_EXISTS_EX(usleep EVENT__HAVE_USLEEP) +CHECK_FUNCTION_EXISTS_EX(timeradd EVENT__HAVE_TIMERADD) +CHECK_FUNCTION_EXISTS_EX(timerclear EVENT__HAVE_TIMERCLEAR) +CHECK_FUNCTION_EXISTS_EX(timercmp EVENT__HAVE_TIMERCMP) +CHECK_FUNCTION_EXISTS_EX(timerfd_create HAVE_TIMERFD_CREATE) +CHECK_FUNCTION_EXISTS_EX(timerisset EVENT__HAVE_TIMERISSET) +CHECK_FUNCTION_EXISTS_EX(putenv EVENT__HAVE_PUTENV) +CHECK_FUNCTION_EXISTS_EX(setenv EVENT__HAVE_SETENV) +CHECK_FUNCTION_EXISTS_EX(setrlimit EVENT__HAVE_SETRLIMIT) +CHECK_FUNCTION_EXISTS_EX(umask EVENT__HAVE_UMASK) +CHECK_FUNCTION_EXISTS_EX(unsetenv EVENT__HAVE_UNSETENV) + +# Get the gethostbyname_r prototype. +CHECK_FUNCTION_EXISTS_EX(gethostbyname_r EVENT__HAVE_GETHOSTBYNAME_R) + +if(EVENT__HAVE_GETHOSTBYNAME_R) + CHECK_PROTOTYPE_DEFINITION(gethostbyname_r + "int gethostbyname_r(const char *name, struct hostent *hp, struct hostent_data *hdata)" + "0" + "netdb.h" + EVENT__HAVE_GETHOSTBYNAME_R_3_ARG) + + CHECK_PROTOTYPE_DEFINITION(gethostbyname_r + "struct hostent *gethostbyname_r(const char *name, struct hostent *hp, char *buf, size_t buflen, int *herr)" + "NULL" + "netdb.h" + EVENT__HAVE_GETHOSTBYNAME_R_5_ARG) + + CHECK_PROTOTYPE_DEFINITION(gethostbyname_r + "int gethostbyname_r(const char *name, struct hostent *hp, char *buf, size_t buflen, struct hostent **result, int *herr)" + "0" + "netdb.h" + EVENT__HAVE_GETHOSTBYNAME_R_6_ARG) +endif() + +if(HAVE_PORT_H AND HAVE_PORT_CREATE) + set(EVENT__HAVE_EVENT_PORTS 1) +endif() + +if(NOT WIN32) + CHECK_FUNCTION_EXISTS_EX(select EVENT__HAVE_SELECT) +endif() + +CHECK_TYPE_SIZE("uint8_t" EVENT__HAVE_UINT8_T) +CHECK_TYPE_SIZE("uint16_t" EVENT__HAVE_UINT16_T) +CHECK_TYPE_SIZE("uint32_t" EVENT__HAVE_UINT32_T) +CHECK_TYPE_SIZE("uint64_t" EVENT__HAVE_UINT64_T) +CHECK_TYPE_SIZE("short" EVENT__SIZEOF_SHORT BUILTIN_TYPES_ONLY) +CHECK_TYPE_SIZE("int" EVENT__SIZEOF_INT BUILTIN_TYPES_ONLY) +CHECK_TYPE_SIZE("unsigned" EVENT__SIZEOF_UNSIGNED BUILTIN_TYPES_ONLY) +CHECK_TYPE_SIZE("unsigned int" EVENT__SIZEOF_UNSIGNED_INT BUILTIN_TYPES_ONLY) +CHECK_TYPE_SIZE("long" EVENT__SIZEOF_LONG BUILTIN_TYPES_ONLY) +CHECK_TYPE_SIZE("long long" EVENT__SIZEOF_LONG_LONG BUILTIN_TYPES_ONLY) + +if(WIN32) + # These aren't available until Windows Vista. + # But you can still link them. They just won't be found when running the exe. + set(EVENT__HAVE_INET_NTOP 0) + set(EVENT__HAVE_INET_PTON 0) +endif() + +# Check for different inline keyword versions. +foreach(KEYWORD "inline" "__inline__" "__inline") + set(CMAKE_REQUIRED_DEFINITIONS "-DKEYWORD=${KEYWORD}") + CHECK_C_SOURCE_COMPILES( + " + #include + KEYWORD void a() {} + int main(int argc, char **argv) { a(); return 0; } + " HAVE_${KEYWORD}) +endforeach() + +if (NOT HAVE_inline) + if (HAVE___inline__) + set(EVENT__inline __inline__) + elseif(HAVE___inline) + set(EVENT__inline __inline) + endif() +endif() +set(CMAKE_REQUIRED_DEFINITIONS "") + +# Check for different function name macros. +foreach(KEYWORD "__func__" "__FUNCTION__") + set(CMAKE_REQUIRED_DEFINITIONS "-DKEYWORD=${KEYWORD}") + CHECK_C_SOURCE_COMPILES( + " + #include + int main(int argc, char **argv) { const char *cp = KEYWORD; return 0; } + " HAVE_${KEYWORD}) +endforeach() +set(CMAKE_REQUIRED_DEFINITIONS "") + +if (NOT HAVE___func__) + if (HAVE___FUNCTION__) + set(EVENT____func__ __FUNCTION__) + else() + # Substitute for __func__ + set(EVENT____func__ __FILE__) + endif() +endif() + +CHECK_SYMBOL_EXISTS(TAILQ_FOREACH sys/queue.h EVENT__HAVE_TAILQFOREACH) +CHECK_SYMBOL_EXISTS(CTL_KERN sys/sysctl.h EVENT__HAVE_DECL_CTL_KERN) +CHECK_SYMBOL_EXISTS(KERN_ARND sys/sysctl.h EVENT__HAVE_DECL_KERN_ARND) +CHECK_SYMBOL_EXISTS(KERN_RANDOM sys/sysctl.h EVENT__HAVE_DECL_KERN_RANDOM) +CHECK_SYMBOL_EXISTS(RANDOM_UUID sys/sysctl.h EVENT__HAVE_DECL_RANDOM_UUID) +CHECK_SYMBOL_EXISTS(F_SETFD fcntl.h EVENT__HAVE_SETFD) + +CHECK_TYPE_SIZE(fd_mask EVENT__HAVE_FD_MASK) + +CHECK_TYPE_SIZE(size_t EVENT__SIZEOF_SIZE_T) +if(NOT EVENT__SIZEOF_SIZE_T) + set(EVENT__size_t unsigned) + set(EVENT__SIZEOF_SIZE_T ${EVENT__SIZEOF_UNSIGNED}) +endif() + +CHECK_TYPE_SIZE("off_t" EVENT__SIZEOF_OFF_T) + +CHECK_TYPE_SIZE(ssize_t EVENT__SIZEOF_SSIZE_T) +CHECK_TYPE_SIZE(SSIZE_T EVENT__SIZEOF_UPPERCASE_SSIZE_T) +if(NOT EVENT__SIZEOF_SSIZE_T) + if(EVENT__SIZEOF_UPPERCASE_SSIZE_T) + set(EVENT__ssize_t SSIZE_T) + set(EVENT__SIZEOF_SSIZE_T ${EVENT__SIZEOF_UPPERCASE_SSIZE_T}) + else() + set(EVENT__ssize_t int) + set(EVENT__SIZEOF_SSIZE_T ${EVENT__SIZEOF_INT}) + endif() +endif() + +CHECK_TYPE_SIZE(socklen_t EVENT__SIZEOF_SOCKLEN_T) +if(NOT EVENT__SIZEOF_SOCKLEN_T) + set(EVENT__socklen_t "unsigned int") + set(EVENT__SIZEOF_SOCKLEN_T ${EVENT__SIZEOF_UNSIGNED_INT}) +endif() + +CHECK_TYPE_SIZE(pid_t EVENT__SIZEOF_PID_T) +if(NOT EVENT__SIZEOF_PID_T) + set(EVENT__pid_t int) + set(EVENT__SIZEOF_PID_T ${EVENT__SIZEOF_INT}) +endif() + +CHECK_TYPE_SIZE(pthread_t EVENT__SIZEOF_PTHREAD_T) + +if(EVENT__HAVE_CLOCK_GETTIME) + set(EVENT__DNS_USE_CPU_CLOCK_FOR_ID 1) +endif() + +CHECK_TYPE_SIZE("uintptr_t" EVENT__HAVE_UINTPTR_T) +CHECK_TYPE_SIZE("void *" EVENT__SIZEOF_VOID_P) + +# Tests file offset bits. +# TODO: Add AIX test for if -D_LARGE_FILES is needed. +CHECK_FILE_OFFSET_BITS() +set(EVENT___FILE_OFFSET_BITS _FILE_OFFSET_BITS) + +# TODO: Check EVENT__HAVE_WORKING_KQUEUE (Define if kqueue works correctly with pipes) + +CHECK_SYMBOL_EXISTS(_MINIX "stdio.h" EVENT___MINIX) +CHECK_SYMBOL_EXISTS(_POSIX_1_SOURCE "stdio.h" EVENT___POSIX_1_SOURCE) +CHECK_SYMBOL_EXISTS(_POSIX_SOURCE "stdio.h" EVENT___POSIX_SOURCE) + +if(EVENT__HAVE_NETDB_H) + list(APPEND CMAKE_EXTRA_INCLUDE_FILES netdb.h) + CHECK_TYPE_SIZE("struct addrinfo" EVENT__HAVE_STRUCT_ADDRINFO) +elseif(WIN32) + list(APPEND CMAKE_EXTRA_INCLUDE_FILES ws2tcpip.h) + CHECK_TYPE_SIZE("struct addrinfo" EVENT__HAVE_STRUCT_ADDRINFO) +endif() + +# Check for sockaddr structure sizes. +set(SOCKADDR_HEADERS) + +if (WIN32) + set(CMAKE_REQUIRED_DEFINITIONS "-DWIN32_LEAN_AND_MEAN") + if (_MSC_VER LESS 1300) + set(SOCKADDR_HEADERS winsock.h) + else() + set(SOCKADDR_HEADERS winsock2.h ws2tcpip.h) + endif() +else() + if (EVENT__HAVE_NETINET_IN_H) + set(SOCKADDR_HEADERS ${SOCKADDR_HEADERS} netinet/in.h) + endif() + + if (EVENT__HAVE_NETINET_IN6_H) + set(SOCKADDR_HEADERS ${SOCKADDR_HEADERS} netinet/in6.h) + endif() + + if (EVENT__HAVE_SYS_SOCKET_H) + set(SOCKADDR_HEADERS ${SOCKADDR_HEADERS} sys/socket.h) + endif() + + if (EVENT__HAVE_NETDB_H) + set(SOCKADDR_HEADERS ${SOCKADDR_HEADERS} netdb.h) + endif() +endif() + +CHECK_TYPE_SIZE("struct in6_addr" EVENT__HAVE_STRUCT_IN6_ADDR) +if(EVENT__HAVE_STRUCT_IN6_ADDR) + CHECK_STRUCT_HAS_MEMBER("struct in6_addr" s6_addr16 "${SOCKADDR_HEADERS}" EVENT__HAVE_STRUCT_IN6_ADDR_S6_ADDR16) + CHECK_STRUCT_HAS_MEMBER("struct in6_addr" s6_addr32 "${SOCKADDR_HEADERS}" EVENT__HAVE_STRUCT_IN6_ADDR_S6_ADDR32) +endif() + +CHECK_TYPE_SIZE("sa_family_t" EVENT__HAVE_SA_FAMILY_T) +CHECK_TYPE_SIZE("struct sockaddr_in6" EVENT__HAVE_STRUCT_SOCKADDR_IN6) +if(EVENT__HAVE_STRUCT_SOCKADDR_IN6) + CHECK_STRUCT_HAS_MEMBER("struct sockaddr_in6" sin6_len "${SOCKADDR_HEADERS}" EVENT__HAVE_STRUCT_SOCKADDR_IN6_SIN6_LEN) + CHECK_STRUCT_HAS_MEMBER("struct sockaddr_in6" sin_len "${SOCKADDR_HEADERS}" EVENT__HAVE_STRUCT_SOCKADDR_IN_SIN_LEN) +endif() + +CHECK_TYPE_SIZE("struct sockaddr_storage" EVENT__HAVE_STRUCT_SOCKADDR_STORAGE) +if(EVENT__HAVE_STRUCT_SOCKADDR_STORAGE) + CHECK_STRUCT_HAS_MEMBER("struct sockaddr_storage" ss_family "${SOCKADDR_HEADERS}" EVENT__HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY) + CHECK_STRUCT_HAS_MEMBER("struct sockaddr_storage" __ss_family "${SOCKADDR_HEADERS}" EVENT__HAVE_STRUCT_SOCKADDR_STORAGE___SS_FAMILY) +endif() + +# Group the source files. +set(HDR_PRIVATE + bufferevent-internal.h + changelist-internal.h + defer-internal.h + evbuffer-internal.h + include/evdns.h + event-internal.h + include/event.h + include/evhttp.h + evmap-internal.h + evrpc-internal.h + include/evrpc.h + evsignal-internal.h + evthread-internal.h + include/evutil.h + ht-internal.h + http-internal.h + iocp-internal.h + ipv6-internal.h + log-internal.h + minheap-internal.h + mm-internal.h + ratelim-internal.h + strlcpy-internal.h + util-internal.h + evconfig-private.h + compat/sys/queue.h + ) + +set(HDR_PUBLIC + include/event2/buffer.h + include/event2/bufferevent.h + include/event2/bufferevent_compat.h + include/event2/bufferevent_ssl.h + include/event2/bufferevent_struct.h + include/event2/buffer_compat.h + include/event2/dns.h + include/event2/dns_compat.h + include/event2/dns_struct.h + include/event2/event.h + include/event2/event_compat.h + include/event2/event_struct.h + include/event2/http.h + include/event2/http_compat.h + include/event2/http_struct.h + include/event2/listener.h + include/event2/rpc.h + include/event2/rpc_compat.h + include/event2/rpc_struct.h + include/event2/tag.h + include/event2/tag_compat.h + include/event2/thread.h + include/event2/util.h + ) + +set(SRC_CORE + buffer.c + bufferevent.c + bufferevent_filter.c + bufferevent_pair.c + bufferevent_ratelim.c + bufferevent_sock.c + event.c + evmap.c + evthread.c + evutil.c + evutil_rand.c + evutil_time.c + listener.c + log.c + signal.c + strlcpy.c + ) + +if(EVENT__HAVE_SELECT) + list(APPEND SRC_CORE select.c) +endif() + +if(EVENT__HAVE_POLL) + list(APPEND SRC_CORE poll.c) +endif() + +if(EVENT__HAVE_KQUEUE) + list(APPEND SRC_CORE kqueue.c) +endif() + +if(EVENT__HAVE_DEVPOLL) + list(APPEND SRC_CORE devpoll.c) +endif() + +if(EVENT__HAVE_EPOLL) + list(APPEND SRC_CORE epoll_sub.c epoll.c) +endif() + +if(EVENT__HAVE_EVENT_PORTS) + list(APPEND SRC_CORE evport.c) +endif() + +if (NOT EVENT__DISABLE_OPENSSL) + find_package(OpenSSL REQUIRED) + message("OpenSSL include: ${OPENSSL_INCLUDE_DIR}") + message("OpenSSL lib: ${OPENSSL_LIBRARIES}") + list(APPEND LIB_REGRESS ${OPENSSL_LIBRARIES}) +endif() + +if(CMAKE_USE_PTHREADS_INIT) + set(EVENT__HAVE_PTHREADS 1) + list(APPEND SRC_CORE evthread_pthread.c) + list(APPEND SRC_REGRESS test/regress_thread.c) + list(APPEND LIB_REGRESS ${CMAKE_THREAD_LIBS_INIT}) +endif() + +if(ZLIB_LIBRARY) + set(EVENT__HAVE_ZLIB 1) + set(EVENT__HAVE_ZLIB_H) + include_directories(${ZLIB_INCLUDE_DIRS}) + list(APPEND SRC_REGRESS test/regress_zlib.c) + list(APPEND LIB_REGRESS ${ZLIB_LIBRARIES}) +endif() + +set(SRC_EXTRA + event_tagging.c + http.c + evdns.c + evrpc.c + ) + +add_definitions(-DHAVE_CONFIG_H) +include_directories(./ ./compat ./include) + +if(WIN32) + list(APPEND SRC_CORE + buffer_iocp.c + bufferevent_async.c + event_iocp.c + evthread_win32.c + win32select.c + WIN32-Code/getopt.c + WIN32-Code/getopt_long.c + ) + list(APPEND SRC_REGRESS test/regress_iocp.c) + list(APPEND SRC_REGRESS test/regress_thread.c) + set(EVENT__DNS_USE_FTIME_FOR_ID 1) + add_definitions(-D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE) + set(LIB_PLATFORM ws2_32) + include_directories(./WIN32-Code) +endif() + +source_group("Headers Private" FILES ${HDR_PRIVATE}) +source_group("Headers Public" FILES ${HDR_PUBLIC}) +source_group("Source Core" FILES ${SRC_CORE}) +source_group("Source Extra" FILES ${SRC_EXTRA}) + +configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/event-config.h.cmake + ${CMAKE_CURRENT_SOURCE_DIR}/include/event2/event-config.h) + +add_library(event_core STATIC + ${HDR_PRIVATE} + ${HDR_PUBLIC} + ${SRC_CORE} + ) + +add_library(event_extras STATIC + ${SRC_EXTRA} + ) + +add_library(event STATIC + ${HDR_PRIVATE} + ${HDR_PUBLIC} + ${SRC_CORE} + ${SRC_EXTRA} + ) + +# TODO: Make these into tests instead? +#add_executable(event-test sample/event-test.c) +#target_link_libraries(event-test event ${LIB_PLATFORM}) + +add_executable(time-test sample/time-test.c) +target_link_libraries(time-test event ${LIB_PLATFORM}) + +add_executable(signal-test sample/signal-test.c) +target_link_libraries(signal-test event ${LIB_PLATFORM}) + +#add_executable(test-init test/test-init.c) +#target_link_libraries(test-init event ${LIB_PLATFORM}) + +#add_executable(test-eof test/test-eof.c) +#target_link_libraries(test-eof event ${LIB_PLATFORM}) + +#add_executable(test-weof test/test-weof.c) +#target_link_libraries(test-weof event ${LIB_PLATFORM}) + +#add_executable(time-test test/time-test.c) +#target_link_libraries(time-test event ${LIB_PLATFORM}) + +if (NOT EVENT__DISABLE_BENCHMARK) + add_executable(bench_cascade test/bench_cascade.c) + target_link_libraries(bench_cascade event ${LIB_PLATFORM}) + + add_executable(bench_http test/bench_http.c) + target_link_libraries(bench_http event ${LIB_PLATFORM}) +endif() + +if (NOT EVENT__DISABLE_TESTS) + if (PYTHONINTERP_FOUND) + message("Generating regress tests...") + add_definitions(-DTINYTEST_LOCAL) + add_custom_command( + OUTPUT + ${CMAKE_CURRENT_SOURCE_DIR}/test/regress.gen.c + ${CMAKE_CURRENT_SOURCE_DIR}/test/regress.gen.h + DEPENDS + event_rpcgen.py + test/regress.rpc + COMMAND ${PYTHON_EXECUTABLE} ../event_rpcgen.py regress.rpc + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/test + ) + + list(APPEND SRC_REGRESS + test/regress.c + test/regress_buffer.c + test/regress_http.c + test/regress_dns.c + test/regress_testutils.c + test/regress_testutils.h + test/regress_rpc.c + test/regress_et.c + test/regress_bufferevent.c + test/regress_listener.c + test/regress_util.c + test/tinytest.c + test/regress_main.c + test/regress_minheap.c + test/regress.gen.c + test/regress.gen.h + test/regress_finalize.c + ) + + add_executable(regress ${SRC_REGRESS}) + target_link_libraries(regress event ${LIB_REGRESS} ${LIB_PLATFORM}) + else() + message(WARNING "Python not found, cannot generate regress tests!") + endif() + + # Tests. + enable_testing() + + add_test(regress "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${EXECUTABLE_OUTPUT_PATH}/regress") + + include(CTest) +endif() diff --git a/WIN32-Code/event2/event-config.h b/WIN32-Code/event2/event-config.h deleted file mode 100644 index 43b5c3fb..00000000 --- a/WIN32-Code/event2/event-config.h +++ /dev/null @@ -1,363 +0,0 @@ -/* event2/event-config.h - * - * This file was generated by autoconf when libevent was built, and post- - * processed by Libevent so that its macros would have a uniform prefix. - * - * DO NOT EDIT THIS FILE. - * - * Do not rely on macros in this file existing in later versions. - */ -#ifndef EVENT_CONFIG_H__ -#define EVENT_CONFIG_H__ -/* config.h. Generated by configure. */ -/* config.h.in. Generated from configure.in by autoheader. */ - -/* Define if libevent should not allow replacing the mm functions */ -/* #undef EVENT__DISABLE_MM_REPLACEMENT */ - -/* Define if libevent should not be compiled with thread support */ -/* #undef EVENT__DISABLE_THREAD_SUPPORT */ - -/* Define if clock_gettime is available in libc */ -/* #undef _EVENT_DNS_USE_CPU_CLOCK_FOR_ID */ - -/* Define is no secure id variant is available */ -/* #define _EVENT_DNS_USE_GETTIMEOFDAY_FOR_ID 1 */ -#define EVENT_DNS_USE_FTIME_FOR_ID_ 1 - -/* Define to 1 if you have the header file. */ -/* #undef EVENT__HAVE_ARPA_INET_H */ - -/* Define to 1 if you have the `clock_gettime' function. */ -/* #undef EVENT__HAVE_CLOCK_GETTIME */ - -/* Define if /dev/poll is available */ -/* #undef EVENT__HAVE_DEVPOLL */ - -/* Define to 1 if you have the header file. */ -/* #undef EVENT__HAVE_DLFCN_H */ - -/* Define if your system supports the epoll system calls */ -/* #undef EVENT__HAVE_EPOLL */ - -/* Define to 1 if you have the `epoll_ctl' function. */ -/* #undef EVENT__HAVE_EPOLL_CTL */ - -/* Define to 1 if you have the `eventfd' function. */ -/* #undef EVENT__HAVE_EVENTFD */ - -/* Define if your system supports event ports */ -/* #undef EVENT__HAVE_EVENT_PORTS */ - -/* Define to 1 if you have the `fcntl' function. */ -/* #undef EVENT__HAVE_FCNTL */ - -/* Define to 1 if you have the header file. */ -#define EVENT__HAVE_FCNTL_H 1 - -/* Define to 1 if you have the `getaddrinfo' function. */ -#define EVENT__HAVE_GETADDRINFO 1 - -/* Define to 1 if you have the `getnameinfo' function. */ -#define EVENT__HAVE_GETNAMEINFO 1 - -/* Define to 1 if you have the `getprotobynumber' function. */ -#define EVENT__HAVE_GETPROTOBYNUMBER 1 - -/* Define to 1 if you have the `getservbyname' function. */ -#define EVENT__HAVE_GETSERVBYNAME 1 - -/* Define to 1 if you have the `gettimeofday' function. */ -/* #define EVENT__HAVE_GETTIMEOFDAY 1 */ - -/* Define to 1 if you have the `inet_aton' function. */ -/* #undef EVENT__HAVE_INET_ATON */ - -/* Define to 1 if you have the `inet_ntop' function. */ -/* #undef EVENT__HAVE_INET_NTOP */ - -/* Define to 1 if you have the `inet_pton' function. */ -/* #undef EVENT__HAVE_INET_PTON */ - -/* Define to 1 if you have the header file. */ -/* #define EVENT__HAVE_INTTYPES_H 1 */ - -/* Define to 1 if you have the `kqueue' function. */ -/* #undef EVENT__HAVE_KQUEUE */ - -/* Define if the system has zlib */ -/* #undef EVENT__HAVE_LIBZ */ - -/* Define to 1 if you have the header file. */ -#define EVENT__HAVE_MEMORY_H 1 - -/* Define to 1 if you have the `mmap' function. */ -/* #undef EVENT__HAVE_MMAP */ - -/* Define to 1 if you have the header file. */ -/* #undef EVENT__HAVE_NETINET_IN6_H */ - -/* Define to 1 if you have the header file. */ -/* #undef EVENT__HAVE_NETINET_IN_H */ - -/* Define to 1 if you have the `pipe' function. */ -/* #undef EVENT__HAVE_PIPE */ - -/* Define to 1 if you have the `poll' function. */ -/* #undef EVENT__HAVE_POLL */ - -/* Define to 1 if you have the header file. */ -/* #undef EVENT__HAVE_POLL_H */ - -/* Define to 1 if you have the `port_create' function. */ -/* #undef EVENT__HAVE_PORT_CREATE */ - -/* Define to 1 if you have the header file. */ -/* #undef EVENT__HAVE_PORT_H */ - -/* Define if you have POSIX threads libraries and header files. */ -/* #undef EVENT__HAVE_PTHREAD */ - -/* Define if we have pthreads on this system */ -/* #undef EVENT__HAVE_PTHREADS */ - -/* Define to 1 if the system has the type `sa_family_t'. */ -/* #undef EVENT__HAVE_SA_FAMILY_T */ - -/* Define to 1 if you have the `select' function. */ -/* #undef EVENT__HAVE_SELECT */ - -/* Define to 1 if you have the `sendfile' function. */ -/* #undef EVENT__HAVE_SENDFILE */ - -/* Define if F_SETFD is defined in */ -/* #undef EVENT__HAVE_SETFD */ - -/* Define to 1 if you have the `sigaction' function. */ -/* #undef EVENT__HAVE_SIGACTION */ - -/* Define to 1 if you have the `signal' function. */ -#define EVENT__HAVE_SIGNAL 1 - -/* Define to 1 if you have the `splice' function. */ -/* #undef EVENT__HAVE_SPLICE */ - -/* Define to 1 if you have the header file. */ -#define EVENT__HAVE_STDARG_H 1 - -/* Define to 1 if you have the header file. */ -#define EVENT__HAVE_STDDEF_H 1 - -/* Define to 1 if you have the header file. */ -/* #define EVENT__HAVE_STDINT_H 1 */ - -/* Define to 1 if you have the header file. */ -#define EVENT__HAVE_STDLIB_H 1 - -/* Define to 1 if you have the header file. */ -#define EVENT__HAVE_STRINGS_H 1 - -/* Define to 1 if you have the header file. */ -#define EVENT__HAVE_STRING_H 1 - -/* Define to 1 if you have the `strlcpy' function. */ -/* #undef EVENT__HAVE_STRLCPY */ - -/* Define to 1 if you have the `strsep' function. */ -/* #undef EVENT__HAVE_STRSEP */ - -/* Define to 1 if you have the `strtok_r' function. */ -/* #undef EVENT__HAVE_STRTOK_R */ - -/* Define to 1 if you have the `strtoll' function. */ -/* #define EVENT__HAVE_STRTOLL 1 */ - -#define EVENT__HAVE_STRUCT_ADDRINFO 1 - -/* Define to 1 if the system has the type `struct in6_addr'. */ -#define EVENT__HAVE_STRUCT_IN6_ADDR 1 - -/* Define to 1 if `s6_addr16' is member of `struct in6_addr'. */ -#define EVENT__HAVE_STRUCT_IN6_ADDR_S6_ADDR16 1 - -/* Define to 1 if `s6_addr32' is member of `struct in6_addr'. */ -#define EVENT__HAVE_STRUCT_IN6_ADDR_S6_ADDR32 1 - -/* Define to 1 if the system has the type `struct sockaddr_in6'. */ -#define EVENT__HAVE_STRUCT_SOCKADDR_IN6 1 - -/* Define to 1 if `sin6_len' is member of `struct sockaddr_in6'. */ -/* #undef EVENT__HAVE_STRUCT_SOCKADDR_IN6_SIN6_LEN */ - -/* Define to 1 if `sin_len' is member of `struct sockaddr_in'. */ -/* #undef EVENT__HAVE_STRUCT_SOCKADDR_IN_SIN_LEN */ - -/* Define to 1 if the system has the type `struct sockaddr_storage'. */ -#define EVENT__HAVE_STRUCT_SOCKADDR_STORAGE 1 - -/* Define to 1 if you have the header file. */ -/* #undef EVENT__HAVE_SYS_DEVPOLL_H */ - -/* Define to 1 if you have the header file. */ -/* #undef EVENT__HAVE_SYS_EPOLL_H */ - -/* Define to 1 if you have the header file. */ -/* #undef EVENT__HAVE_SYS_EVENTFD_H */ - -/* Define to 1 if you have the header file. */ -/* #undef EVENT__HAVE_SYS_EVENT_H */ - -/* Define to 1 if you have the header file. */ -/* #undef EVENT__HAVE_SYS_IOCTL_H */ - -/* Define to 1 if you have the header file. */ -/* #undef EVENT__HAVE_SYS_MMAN_H */ - -/* Define to 1 if you have the header file. */ -/* #define EVENT__HAVE_SYS_PARAM_H 1 */ - -/* Define to 1 if you have the header file. */ -/* #undef EVENT__HAVE_SYS_QUEUE_H */ - -/* Define to 1 if you have the header file. */ -/* #undef EVENT__HAVE_SYS_SELECT_H */ - -/* Define to 1 if you have the header file. */ -/* #undef EVENT__HAVE_SYS_SENDFILE_H */ - -/* Define to 1 if you have the header file. */ -/* #undef EVENT__HAVE_SYS_SOCKET_H */ - -/* Define to 1 if you have the header file. */ -#define EVENT__HAVE_SYS_STAT_H 1 - -/* Define to 1 if you have the header file. */ -/* #define EVENT__HAVE_SYS_TIME_H 1 */ - -/* Define to 1 if you have the header file. */ -#define EVENT__HAVE_SYS_TYPES_H 1 - -/* Define to 1 if you have the header file. */ -/* #undef EVENT__HAVE_SYS_UIO_H */ - -/* Define if TAILQ_FOREACH is defined in */ -/* #undef EVENT__HAVE_TAILQFOREACH */ - -/* Define if timeradd is defined in */ -/* #undef EVENT__HAVE_TIMERADD */ - -/* Define if timerclear is defined in */ -#define EVENT__HAVE_TIMERCLEAR 1 - -/* Define if timercmp is defined in */ -#define EVENT__HAVE_TIMERCMP 1 - -/* Define if timerisset is defined in */ -#define EVENT__HAVE_TIMERISSET 1 - -/* Define to 1 if the system has the type `uint16_t'. */ -/* #define EVENT__HAVE_UINT16_T 1 */ - -/* Define to 1 if the system has the type `uint32_t'. */ -/* #define EVENT__HAVE_UINT32_T 1 */ - -/* Define to 1 if the system has the type `uint64_t'. */ -/* #define EVENT__HAVE_UINT64_T 1 */ - -/* Define to 1 if the system has the type `uint8_t'. */ -/* #define EVENT__HAVE_UINT8_T 1 */ - -/* Define to 1 if you have the header file. */ -/* #define EVENT__HAVE_UNISTD_H 1 */ - -/* Define to 1 if you have the `vasprintf' function. */ -/* #undef EVENT__HAVE_VASPRINTF */ - -/* Define if kqueue works correctly with pipes */ -/* #undef EVENT__HAVE_WORKING_KQUEUE */ - -/* Numeric representation of the version */ -#define EVENT__NUMERIC_VERSION 0x02010301 - -/* Name of package */ -#define EVENT__PACKAGE "libevent" - -/* Define to the address where bug reports for this package should be sent. */ -#define EVENT__PACKAGE_BUGREPORT "" - -/* Define to the full name of this package. */ -#define EVENT__PACKAGE_NAME "" - -/* Define to the full name and version of this package. */ -#define EVENT__PACKAGE_STRING "" - -/* Define to the one symbol short name of this package. */ -#define EVENT__PACKAGE_TARNAME "" - -/* Define to the version of this package. */ -#define EVENT__PACKAGE_VERSION "" - -/* Define to necessary symbol if this constant uses a non-standard name on - your system. */ -/* #undef EVENT__PTHREAD_CREATE_JOINABLE */ - -/* The size of a `int', as computed by sizeof. */ -#define EVENT__SIZEOF_INT 4 - -/* The size of a `long', as computed by sizeof. */ -#define EVENT__SIZEOF_LONG 4 - -/* The size of a `long long', as computed by sizeof. */ -#define EVENT__SIZEOF_LONG_LONG 8 - -/* The size of a `short', as computed by sizeof. */ -#define EVENT__SIZEOF_SHORT 2 - -/* The size of `size_t', as computed by sizeof. */ -#ifdef _WIN64 -#define EVENT__SIZEOF_SIZE_T 8 -#else -#define EVENT__SIZEOF_SIZE_T 4 -#endif - -/* The size of `void *', as computed by sizeof. */ -#ifdef _WIN64 -#define EVENT__SIZEOF_VOID_P 8 -#else -#define EVENT__SIZEOF_VOID_P 4 -#endif - -/* Define to 1 if you have the ANSI C header files. */ -#define EVENT__STDC_HEADERS 1 - -/* Define to 1 if you can safely include both and . */ -#define EVENT__TIME_WITH_SYS_TIME 1 - -/* Version number of package */ -#define EVENT__VERSION "2.1.3-alpha-dev" - -/* Define to appropriate substitue if compiler doesnt have __func__ */ -#define EVENT____func__ __FUNCTION__ - -/* Define to empty if `const' does not conform to ANSI C. */ -/* #undef EVENT__const */ - -/* Define to `__inline__' or `__inline' if that's what the C compiler - calls it, or to nothing if 'inline' is not supported under any name. */ -#ifndef _EVENT___cplusplus -#define EVENT__inline __inline -#endif - -/* Define to `int' if does not define. */ -/* #undef EVENT__pid_t */ - -/* Define to `unsigned' if does not define. */ -/* #undef EVENT__size_t */ - -/* Define to unsigned int if you dont have it */ -#define EVENT__socklen_t unsigned int - -/* Define to `int' if does not define. */ -#define EVENT__ssize_t SSIZE_T - -#endif diff --git a/WIN32-Code/getopt.c b/WIN32-Code/getopt.c new file mode 100644 index 00000000..3bb21f6f --- /dev/null +++ b/WIN32-Code/getopt.c @@ -0,0 +1,153 @@ +/* $NetBSD: getopt.c,v 1.16 1999/12/02 13:15:56 kleink Exp $ */ + +/* + * Copyright (c) 1987, 1993, 1994 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#if 0 +static char sccsid[] = "@(#)getopt.c 8.3 (Berkeley) 4/27/95"; +#endif + +#include +#include +#include +#include + +#define __P(x) x +#define _DIAGASSERT(x) assert(x) + +#ifdef __weak_alias +__weak_alias(getopt,_getopt); +#endif + + +int opterr = 1, /* if error message should be printed */ + optind = 1, /* index into parent argv vector */ + optopt, /* character checked for validity */ + optreset; /* reset getopt */ +char *optarg; /* argument associated with option */ + +static char * _progname __P((char *)); +int getopt_internal __P((int, char * const *, const char *)); + +static char * +_progname(nargv0) + char * nargv0; +{ + char * tmp; + + _DIAGASSERT(nargv0 != NULL); + + tmp = strrchr(nargv0, '/'); + if (tmp) + tmp++; + else + tmp = nargv0; + return(tmp); +} + +#define BADCH (int)'?' +#define BADARG (int)':' +#define EMSG "" + +/* + * getopt -- + * Parse argc/argv argument vector. + */ +int +getopt(nargc, nargv, ostr) + int nargc; + char * const nargv[]; + const char *ostr; +{ + static char *__progname = 0; + static char *place = EMSG; /* option letter processing */ + char *oli; /* option letter list index */ + __progname = __progname?__progname:_progname(*nargv); + + _DIAGASSERT(nargv != NULL); + _DIAGASSERT(ostr != NULL); + + if (optreset || !*place) { /* update scanning pointer */ + optreset = 0; + if (optind >= nargc || *(place = nargv[optind]) != '-') { + place = EMSG; + return (-1); + } + if (place[1] && *++place == '-' /* found "--" */ + && place[1] == '\0') { + ++optind; + place = EMSG; + return (-1); + } + } /* option letter okay? */ + if ((optopt = (int)*place++) == (int)':' || + !(oli = strchr(ostr, optopt))) { + /* + * if the user didn't specify '-' as an option, + * assume it means -1. + */ + if (optopt == (int)'-') + return (-1); + if (!*place) + ++optind; + if (opterr && *ostr != ':') + (void)fprintf(stderr, + "%s: illegal option -- %c\n", __progname, optopt); + return (BADCH); + } + if (*++oli != ':') { /* don't need argument */ + optarg = NULL; + if (!*place) + ++optind; + } + else { /* need an argument */ + if (*place) /* no white space */ + optarg = place; + else if (nargc <= ++optind) { /* no arg */ + place = EMSG; + if (*ostr == ':') + return (BADARG); + if (opterr) + (void)fprintf(stderr, + "%s: option requires an argument -- %c\n", + __progname, optopt); + return (BADCH); + } + else /* white space */ + optarg = nargv[optind]; + place = EMSG; + ++optind; + } + return (optopt); /* dump back option letter */ +} + diff --git a/WIN32-Code/getopt.h b/WIN32-Code/getopt.h new file mode 100644 index 00000000..7137f037 --- /dev/null +++ b/WIN32-Code/getopt.h @@ -0,0 +1,33 @@ +#ifndef __GETOPT_H__ +#define __GETOPT_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +extern int opterr; /* if error message should be printed */ +extern int optind; /* index into parent argv vector */ +extern int optopt; /* character checked for validity */ +extern int optreset; /* reset getopt */ +extern char *optarg; /* argument associated with option */ + +struct option +{ + const char *name; + int has_arg; + int *flag; + int val; +}; + +#define no_argument 0 +#define required_argument 1 +#define optional_argument 2 + +int getopt(int, char**, char*); +int getopt_long(int, char**, char*, struct option*, int*); + +#ifdef __cplusplus +} +#endif + +#endif /* __GETOPT_H__ */ diff --git a/WIN32-Code/getopt_long.c b/WIN32-Code/getopt_long.c new file mode 100644 index 00000000..5bcf4006 --- /dev/null +++ b/WIN32-Code/getopt_long.c @@ -0,0 +1,237 @@ + +/* + * Copyright (c) 1987, 1993, 1994, 1996 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ +#include +#include +#include +#include +#include +#include "getopt.h" + +extern int opterr; /* if error message should be printed */ +extern int optind; /* index into parent argv vector */ +extern int optopt; /* character checked for validity */ +extern int optreset; /* reset getopt */ +extern char *optarg; /* argument associated with option */ + +#define __P(x) x +#define _DIAGASSERT(x) assert(x) + +static char * __progname __P((char *)); +int getopt_internal __P((int, char * const *, const char *)); + +static char * +__progname(nargv0) + char * nargv0; +{ + char * tmp; + + _DIAGASSERT(nargv0 != NULL); + + tmp = strrchr(nargv0, '/'); + if (tmp) + tmp++; + else + tmp = nargv0; + return(tmp); +} + +#define BADCH (int)'?' +#define BADARG (int)':' +#define EMSG "" + +/* + * getopt -- + * Parse argc/argv argument vector. + */ +int +getopt_internal(nargc, nargv, ostr) + int nargc; + char * const *nargv; + const char *ostr; +{ + static char *place = EMSG; /* option letter processing */ + char *oli; /* option letter list index */ + + _DIAGASSERT(nargv != NULL); + _DIAGASSERT(ostr != NULL); + + if (optreset || !*place) { /* update scanning pointer */ + optreset = 0; + if (optind >= nargc || *(place = nargv[optind]) != '-') { + place = EMSG; + return (-1); + } + if (place[1] && *++place == '-') { /* found "--" */ + /* ++optind; */ + place = EMSG; + return (-2); + } + } /* option letter okay? */ + if ((optopt = (int)*place++) == (int)':' || + !(oli = strchr(ostr, optopt))) { + /* + * if the user didn't specify '-' as an option, + * assume it means -1. + */ + if (optopt == (int)'-') + return (-1); + if (!*place) + ++optind; + if (opterr && *ostr != ':') + (void)fprintf(stderr, + "%s: illegal option -- %c\n", __progname(nargv[0]), optopt); + return (BADCH); + } + if (*++oli != ':') { /* don't need argument */ + optarg = NULL; + if (!*place) + ++optind; + } else { /* need an argument */ + if (*place) /* no white space */ + optarg = place; + else if (nargc <= ++optind) { /* no arg */ + place = EMSG; + if ((opterr) && (*ostr != ':')) + (void)fprintf(stderr, + "%s: option requires an argument -- %c\n", + __progname(nargv[0]), optopt); + return (BADARG); + } else /* white space */ + optarg = nargv[optind]; + place = EMSG; + ++optind; + } + return (optopt); /* dump back option letter */ +} + +#if 0 +/* + * getopt -- + * Parse argc/argv argument vector. + */ +int +getopt2(nargc, nargv, ostr) + int nargc; + char * const *nargv; + const char *ostr; +{ + int retval; + + if ((retval = getopt_internal(nargc, nargv, ostr)) == -2) { + retval = -1; + ++optind; + } + return(retval); +} +#endif + +/* + * getopt_long -- + * Parse argc/argv argument vector. + */ +int +getopt_long(nargc, nargv, options, long_options, index) + int nargc; + char ** nargv; + char * options; + struct option * long_options; + int * index; +{ + int retval; + + _DIAGASSERT(nargv != NULL); + _DIAGASSERT(options != NULL); + _DIAGASSERT(long_options != NULL); + /* index may be NULL */ + + if ((retval = getopt_internal(nargc, nargv, options)) == -2) { + char *current_argv = nargv[optind++] + 2, *has_equal; + int i, current_argv_len, match = -1; + + if (*current_argv == '\0') { + return(-1); + } + if ((has_equal = strchr(current_argv, '=')) != NULL) { + current_argv_len = has_equal - current_argv; + has_equal++; + } else + current_argv_len = strlen(current_argv); + + for (i = 0; long_options[i].name; i++) { + if (strncmp(current_argv, long_options[i].name, current_argv_len)) + continue; + + if (strlen(long_options[i].name) == (unsigned)current_argv_len) { + match = i; + break; + } + if (match == -1) + match = i; + } + if (match != -1) { + if (long_options[match].has_arg == required_argument || + long_options[match].has_arg == optional_argument) { + if (has_equal) + optarg = has_equal; + else + optarg = nargv[optind++]; + } + if ((long_options[match].has_arg == required_argument) + && (optarg == NULL)) { + /* + * Missing argument, leading : + * indicates no error should be generated + */ + if ((opterr) && (*options != ':')) + (void)fprintf(stderr, + "%s: option requires an argument -- %s\n", + __progname(nargv[0]), current_argv); + return (BADARG); + } + } else { /* No matching argument */ + if ((opterr) && (*options != ':')) + (void)fprintf(stderr, + "%s: illegal option -- %s\n", __progname(nargv[0]), current_argv); + return (BADCH); + } + if (long_options[match].flag) { + *long_options[match].flag = long_options[match].val; + retval = 0; + } else + retval = long_options[match].val; + if (index) + *index = match; + } + return(retval); +} diff --git a/cmake/CheckFileOffsetBits.c b/cmake/CheckFileOffsetBits.c new file mode 100644 index 00000000..d948fecf --- /dev/null +++ b/cmake/CheckFileOffsetBits.c @@ -0,0 +1,14 @@ +#include + +#define KB ((off_t)1024) +#define MB ((off_t)1024 * KB) +#define GB ((off_t)1024 * MB) +#define TB ((off_t)1024 * GB) +int t2[(((64 * GB -1) % 671088649) == 268434537) + && (((TB - (64 * GB -1) + 255) % 1792151290) == 305159546)? 1: -1]; + +int main() +{ + ; + return 0; +} diff --git a/cmake/CheckFileOffsetBits.cmake b/cmake/CheckFileOffsetBits.cmake new file mode 100644 index 00000000..12534401 --- /dev/null +++ b/cmake/CheckFileOffsetBits.cmake @@ -0,0 +1,43 @@ +# - Check if _FILE_OFFSET_BITS macro needed for large files +# CHECK_FILE_OFFSET_BITS () +# +# The following variables may be set before calling this macro to +# modify the way the check is run: +# +# CMAKE_REQUIRED_FLAGS = string of compile command line flags +# CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar) +# CMAKE_REQUIRED_INCLUDES = list of include directories +# Copyright (c) 2009, Michihiro NAKAJIMA +# +# Redistribution and use is allowed according to the terms of the BSD license. +# For details see the accompanying COPYING-CMAKE-SCRIPTS file. + +#INCLUDE(CheckCSourceCompiles) + +GET_FILENAME_COMPONENT(_selfdir_CheckFileOffsetBits + "${CMAKE_CURRENT_LIST_FILE}" PATH) + +MACRO (CHECK_FILE_OFFSET_BITS) + IF(NOT DEFINED _FILE_OFFSET_BITS) + MESSAGE(STATUS "Cheking _FILE_OFFSET_BITS for large files") + TRY_COMPILE(__WITHOUT_FILE_OFFSET_BITS_64 + ${CMAKE_CURRENT_BINARY_DIR} + ${_selfdir_CheckFileOffsetBits}/CheckFileOffsetBits.c + COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS}) + IF(NOT __WITHOUT_FILE_OFFSET_BITS_64) + TRY_COMPILE(__WITH_FILE_OFFSET_BITS_64 + ${CMAKE_CURRENT_BINARY_DIR} + ${_selfdir_CheckFileOffsetBits}/CheckFileOffsetBits.c + COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} -D_FILE_OFFSET_BITS=64) + ENDIF(NOT __WITHOUT_FILE_OFFSET_BITS_64) + + IF(NOT __WITHOUT_FILE_OFFSET_BITS_64 AND __WITH_FILE_OFFSET_BITS_64) + SET(_FILE_OFFSET_BITS 64 CACHE INTERNAL "_FILE_OFFSET_BITS macro needed for large files") + MESSAGE(STATUS "Cheking _FILE_OFFSET_BITS for large files - needed") + ELSE(NOT __WITHOUT_FILE_OFFSET_BITS_64 AND __WITH_FILE_OFFSET_BITS_64) + SET(_FILE_OFFSET_BITS "" CACHE INTERNAL "_FILE_OFFSET_BITS macro needed for large files") + MESSAGE(STATUS "Cheking _FILE_OFFSET_BITS for large files - not needed") + ENDIF(NOT __WITHOUT_FILE_OFFSET_BITS_64 AND __WITH_FILE_OFFSET_BITS_64) + ENDIF(NOT DEFINED _FILE_OFFSET_BITS) + +ENDMACRO (CHECK_FILE_OFFSET_BITS) diff --git a/cmake/CheckFunctionExistsEx.c b/cmake/CheckFunctionExistsEx.c new file mode 100644 index 00000000..e3e9cb0f --- /dev/null +++ b/cmake/CheckFunctionExistsEx.c @@ -0,0 +1,30 @@ +#ifdef CHECK_FUNCTION_EXISTS + +#ifndef WIN32 +char CHECK_FUNCTION_EXISTS(); +#endif + +#ifdef __CLASSIC_C__ +int main(){ + int ac; + char*av[]; +#else +int main(int ac, char*av[]){ +#endif +#ifdef WIN32 + void * p = &CHECK_FUNCTION_EXISTS; +#else + CHECK_FUNCTION_EXISTS(); +#endif + if(ac > 1000) + { + return *av[0]; + } + return 0; +} + +#else /* CHECK_FUNCTION_EXISTS */ + +# error "CHECK_FUNCTION_EXISTS has to specify the function" + +#endif /* CHECK_FUNCTION_EXISTS */ diff --git a/cmake/CheckFunctionExistsEx.cmake b/cmake/CheckFunctionExistsEx.cmake new file mode 100644 index 00000000..f513f4e1 --- /dev/null +++ b/cmake/CheckFunctionExistsEx.cmake @@ -0,0 +1,69 @@ +# - Check if a C function can be linked +# CHECK_FUNCTION_EXISTS( ) +# +# Check that the is provided by libraries on the system and +# store the result in a . This does not verify that any +# system header file declares the function, only that it can be found +# at link time (considure using CheckSymbolExists). +# +# The following variables may be set before calling this macro to +# modify the way the check is run: +# +# CMAKE_REQUIRED_FLAGS = string of compile command line flags +# CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar) +# CMAKE_REQUIRED_INCLUDES = list of include directories +# CMAKE_REQUIRED_LIBRARIES = list of libraries to link + +#============================================================================= +# Copyright 2002-2011 Kitware, Inc. +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of CMake, substitute the full +# License text for the above reference.) + +MACRO(CHECK_FUNCTION_EXISTS_EX FUNCTION VARIABLE) + IF("${VARIABLE}" MATCHES "^${VARIABLE}$") + SET(MACRO_CHECK_FUNCTION_DEFINITIONS + "-DCHECK_FUNCTION_EXISTS=${FUNCTION} ${CMAKE_REQUIRED_FLAGS}") + MESSAGE(STATUS "Looking for ${FUNCTION}") + IF(CMAKE_REQUIRED_LIBRARIES) + SET(CHECK_FUNCTION_EXISTS_ADD_LIBRARIES + "-DLINK_LIBRARIES:STRING=${CMAKE_REQUIRED_LIBRARIES}") + ELSE(CMAKE_REQUIRED_LIBRARIES) + SET(CHECK_FUNCTION_EXISTS_ADD_LIBRARIES) + ENDIF(CMAKE_REQUIRED_LIBRARIES) + IF(CMAKE_REQUIRED_INCLUDES) + SET(CHECK_FUNCTION_EXISTS_ADD_INCLUDES + "-DINCLUDE_DIRECTORIES:STRING=${CMAKE_REQUIRED_INCLUDES}") + ELSE(CMAKE_REQUIRED_INCLUDES) + SET(CHECK_FUNCTION_EXISTS_ADD_INCLUDES) + ENDIF(CMAKE_REQUIRED_INCLUDES) + TRY_COMPILE(${VARIABLE} + ${CMAKE_BINARY_DIR} + ${PROJECT_SOURCE_DIR}/cmake/CheckFunctionExistsEx.c + COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} + CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_FUNCTION_DEFINITIONS} + "${CHECK_FUNCTION_EXISTS_ADD_LIBRARIES}" + "${CHECK_FUNCTION_EXISTS_ADD_INCLUDES}" + OUTPUT_VARIABLE OUTPUT) + IF(${VARIABLE}) + SET(${VARIABLE} 1 CACHE INTERNAL "Have function ${FUNCTION}") + MESSAGE(STATUS "Looking for ${FUNCTION} - found") + FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log + "Determining if the function ${FUNCTION} exists passed with the following output:\n" + "${OUTPUT}\n\n") + ELSE(${VARIABLE}) + MESSAGE(STATUS "Looking for ${FUNCTION} - not found") + SET(${VARIABLE} "" CACHE INTERNAL "Have function ${FUNCTION}") + FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log + "Determining if the function ${FUNCTION} exists failed with the following output:\n" + "${OUTPUT}\n\n") + ENDIF(${VARIABLE}) + ENDIF("${VARIABLE}" MATCHES "^${VARIABLE}$") +ENDMACRO(CHECK_FUNCTION_EXISTS_EX) diff --git a/cmake/CheckPrototypeDefinition.c.in b/cmake/CheckPrototypeDefinition.c.in new file mode 100644 index 00000000..a97344ac --- /dev/null +++ b/cmake/CheckPrototypeDefinition.c.in @@ -0,0 +1,29 @@ +@CHECK_PROTOTYPE_DEFINITION_HEADER@ + +static void cmakeRequireSymbol(int dummy, ...) { + (void) dummy; +} + +static void checkSymbol(void) { +#ifndef @CHECK_PROTOTYPE_DEFINITION_SYMBOL@ + cmakeRequireSymbol(0, &@CHECK_PROTOTYPE_DEFINITION_SYMBOL@); +#endif +} + +@CHECK_PROTOTYPE_DEFINITION_PROTO@ { + return @CHECK_PROTOTYPE_DEFINITION_RETURN@; +} + +#ifdef __CLASSIC_C__ +int main() { + int ac; + char*av[]; +#else +int main(int ac, char *av[]) { +#endif + checkSymbol(); + if (ac > 1000) { + return *av[0]; + } + return 0; +} diff --git a/cmake/CheckPrototypeDefinition.cmake b/cmake/CheckPrototypeDefinition.cmake new file mode 100644 index 00000000..3a53f668 --- /dev/null +++ b/cmake/CheckPrototypeDefinition.cmake @@ -0,0 +1,86 @@ +# - Check if the protoype we expect is correct. +# check_prototype_definition(FUNCTION PROTOTYPE RETURN HEADER VARIABLE) +# +# FUNCTION - The name of the function (used to check if prototype exists) +# PROTOTYPE- The prototype to check. +# RETURN - The return value of the function. +# HEADER - The header files required. +# VARIABLE - The variable to store the result. +# +# Example: +# +# check_prototype_definition(getpwent_r +# "struct passwd *getpwent_r(struct passwd *src, char *buf, int buflen)" +# "NULL" +# "unistd.h;pwd.h" +# SOLARIS_GETPWENT_R) +# +# The following variables may be set before calling this macro to +# modify the way the check is run: +# +# CMAKE_REQUIRED_FLAGS = string of compile command line flags +# CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar) +# CMAKE_REQUIRED_INCLUDES = list of include directories +# CMAKE_REQUIRED_LIBRARIES = list of libraries to link + + +function(CHECK_PROTOTYPE_DEFINITION _FUNCTION _PROTOTYPE _RETURN _HEADER _VARIABLE) + + if ("${_VARIABLE}" MATCHES "^${_VARIABLE}$") + set(CHECK_PROTOTYPE_DEFINITION_CONTENT "/* */\n") + + set(CHECK_PROTOTYPE_DEFINITION_FLAGS ${CMAKE_REQUIRED_FLAGS}) + if (CMAKE_REQUIRED_LIBRARIES) + set(CHECK_PROTOTYPE_DEFINITION_LIBS + "-DLINK_LIBRARIES:STRING=${CMAKE_REQUIRED_LIBRARIES}") + else(CMAKE_REQUIRED_LIBRARIES) + set(CHECK_PROTOTYPE_DEFINITION_LIBS) + endif(CMAKE_REQUIRED_LIBRARIES) + if (CMAKE_REQUIRED_INCLUDES) + set(CMAKE_SYMBOL_EXISTS_INCLUDES + "-DINCLUDE_DIRECTORIES:STRING=${CMAKE_REQUIRED_INCLUDES}") + else(CMAKE_REQUIRED_INCLUDES) + set(CMAKE_SYMBOL_EXISTS_INCLUDES) + endif(CMAKE_REQUIRED_INCLUDES) + + foreach(_FILE ${_HEADER}) + set(CHECK_PROTOTYPE_DEFINITION_HEADER + "${CHECK_PROTOTYPE_DEFINITION_HEADER}#include <${_FILE}>\n") + endforeach(_FILE) + + set(CHECK_PROTOTYPE_DEFINITION_SYMBOL ${_FUNCTION}) + set(CHECK_PROTOTYPE_DEFINITION_PROTO ${_PROTOTYPE}) + set(CHECK_PROTOTYPE_DEFINITION_RETURN ${_RETURN}) + + #configure_file("${CMAKE_ROOT}/Modules/CheckPrototypeDefinition.c.in" + # "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckPrototypeDefinition.c" @ONLY) + configure_file("${CMAKE_MODULE_PATH}/CheckPrototypeDefinition.c.in" + "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckPrototypeDefinition.c" @ONLY) + + file(READ ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckPrototypeDefinition.c _SOURCE) + + try_compile(${_VARIABLE} + ${CMAKE_BINARY_DIR} + ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckPrototypeDefinition.c + COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} + CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${CHECK_PROTOTYPE_DEFINITION_FLAGS} + "${CHECK_PROTOTYPE_DEFINITION_LIBS}" + "${CMAKE_SYMBOL_EXISTS_INCLUDES}" + OUTPUT_VARIABLE OUTPUT) + + if (${_VARIABLE}) + set(${_VARIABLE} 1 CACHE INTERNAL "Have correct prototype for ${_FUNCTION}") + message(STATUS "Checking prototype ${_FUNCTION} for ${_VARIABLE} - True") + file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log + "Determining if the prototype ${_FUNCTION} exists for ${_VARIABLE} passed with the following output:\n" + "${OUTPUT}\n\n") + else (${_VARIABLE}) + message(STATUS "Checking prototype ${_FUNCTION} for ${_VARIABLE} - False") + set(${_VARIABLE} 0 CACHE INTERNAL "Have correct prototype for ${_FUNCTION}") + file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log + "Determining if the prototype ${_FUNCTION} exists for ${_VARIABLE} failed with the following output:\n" + "${OUTPUT}\n\n${_SOURCE}\n\n") + endif (${_VARIABLE}) + endif("${_VARIABLE}" MATCHES "^${_VARIABLE}$") + +endfunction(CHECK_PROTOTYPE_DEFINITION) diff --git a/event-config.h.cmake b/event-config.h.cmake new file mode 100644 index 00000000..577b7448 --- /dev/null +++ b/event-config.h.cmake @@ -0,0 +1,500 @@ +/* event-config.h + * + * This file was generated by cmake when the makefiles were generated. + * + * DO NOT EDIT THIS FILE. + * + * Do not rely on macros in this file existing in later versions. + */ +#ifndef EVENT2_EVENT_CONFIG_H_INCLUDED_ +#define EVENT2_EVENT_CONFIG_H_INCLUDED_ + +/* Numeric representation of the version */ +#define EVENT__NUMERIC_VERSION @EVENT_NUMERIC_VERSION@ + +#define EVENT__PACKAGE_VERSION @EVENT_PACKAGE_VERSION@ + +/* Version number of package */ +#define EVENT__VERSION "@EVENT_VERSION@" + +/* Name of package */ +#define EVENT__PACKAGE "libevent" + +/* Define to the address where bug reports for this package should be sent. */ +#define EVENT__PACKAGE_BUGREPORT "" + +/* Define to the full name of this package. */ +#define EVENT__PACKAGE_NAME "" + +/* Define to the full name and version of this package. */ +#define EVENT__PACKAGE_STRING "" + +/* Define to the one symbol short name of this package. */ +#define EVENT__PACKAGE_TARNAME "" + +/* Define if libevent should build without support for a debug mode */ +#cmakedefine EVENT__DISABLE_DEBUG_MODE 0 + +/* Define if libevent should not allow replacing the mm functions */ +#cmakedefine EVENT__DISABLE_MM_REPLACEMENT 0 + +/* Define if libevent should not be compiled with thread support */ +#cmakedefine EVENT__DISABLE_THREAD_SUPPORT 0 + +/* Define to 1 if you have the `accept4' function. */ +#cmakedefine EVENT__HAVE_ACCEPT4 1 + +/* Define to 1 if you have the `arc4random' function. */ +#cmakedefine EVENT__HAVE_ARC4RANDOM 1 + +/* Define to 1 if you have the `arc4random_buf' function. */ +#cmakedefine EVENT__HAVE_ARC4RANDOM_BUF 1 + +/* Define if clock_gettime is available in libc */ +#cmakedefine EVENT__DNS_USE_CPU_CLOCK_FOR_ID 1 + +/* Define is no secure id variant is available */ +#cmakedefine EVENT__DNS_USE_GETTIMEOFDAY_FOR_ID 1 +#cmakedefine EVENT__DNS_USE_FTIME_FOR_ID 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine EVENT__HAVE_ARPA_INET_H 1 + +/* Define to 1 if you have the `clock_gettime' function. */ +#cmakedefine EVENT__HAVE_CLOCK_GETTIME 1 + +/* Define to 1 if you have the declaration of `CTL_KERN'. */ +#cmakedefine EVENT__HAVE_DECL_CTL_KERN 1 + +/* Define to 1 if you have the declaration of `KERN_ARND'. */ +#cmakedefine EVENT__HAVE_DECL_KERN_ARND 0 + +/* Define to 1 if you have the declaration of `KERN_RANDOM'. */ +#cmakedefine EVENT__HAVE_DECL_KERN_RANDOM 1 + +/* Define if /dev/poll is available */ +#cmakedefine EVENT__HAVE_DEVPOLL 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine EVENT__HAVE_NETDB_H 1 + +/* Define to 1 if fd_mask type is defined */ +#cmakedefine EVENT__HAVE_FD_MASK 1 + +/* Define to 1 if the header file defines TAILQ_FOREACH. */ +#cmakedefine EVENT__HAVE_TAILQFOREACH 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine EVENT__HAVE_DLFCN_H 1 + +/* Define if your system supports the epoll system calls */ +#cmakedefine EVENT__HAVE_EPOLL 1 + +/* Define to 1 if you have the `epoll_create1' function. */ +#cmakedefine EVENT__HAVE_EPOLL_CREATE1 1 + +/* Define to 1 if you have the `epoll_ctl' function. */ +#cmakedefine EVENT__HAVE_EPOLL_CTL 1 + +/* Define to 1 if you have the `eventfd' function. */ +#cmakedefine EVENT__HAVE_EVENTFD 1 + +/* Define if your system supports event ports */ +#cmakedefine EVENT__HAVE_EVENT_PORTS 1 + +/* Define to 1 if you have the `fcntl' function. */ +#cmakedefine EVENT__HAVE_FCNTL 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine EVENT__HAVE_FCNTL_H 1 + +/* Define to 1 if you have the `getaddrinfo' function. */ +#cmakedefine EVENT__HAVE_GETADDRINFO 1 + +/* Define to 1 if you have the `getegid' function. */ +#cmakedefine EVENT__HAVE_GETEGID 1 + +/* Define to 1 if you have the `geteuid' function. */ +#cmakedefine EVENT__HAVE_GETEUID 1 + +/* TODO: Check for different gethostname argument counts. CheckPrototypeDefinition.cmake can be used. */ +/* Define this if you have any gethostbyname_r() */ +#cmakedefine EVENT__HAVE_GETHOSTBYNAME_R 1 + +/* Define this if gethostbyname_r takes 3 arguments */ +#cmakedefine EVENT__HAVE_GETHOSTBYNAME_R_3_ARG 1 + +/* Define this if gethostbyname_r takes 5 arguments */ +#cmakedefine EVENT__HAVE_GETHOSTBYNAME_R_5_ARG 1 + +/* Define this if gethostbyname_r takes 6 arguments */ +#cmakedefine EVENT__HAVE_GETHOSTBYNAME_R_6_ARG 1 + +/* Define to 1 if you have the `getifaddrs' function. */ +#cmakedefine EVENT__HAVE_GETIFADDRS 1 + +/* Define to 1 if you have the `getnameinfo' function. */ +#cmakedefine EVENT__HAVE_GETNAMEINFO 1 + +/* Define to 1 if you have the `getprotobynumber' function. */ +#cmakedefine EVENT__HAVE_GETPROTOBYNUMBER 1 + +/* Define to 1 if you have the `getservbyname' function. */ +#cmakedefine EVENT__HAVE_GETSERVBYNAME 1 + +/* Define to 1 if you have the `gettimeofday' function. */ +#cmakedefine EVENT__HAVE_GETTIMEOFDAY 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine EVENT__HAVE_IFADDRS_H 1 + +/* Define to 1 if you have the `inet_aton' function. */ +#cmakedefine EVENT__HAVE_INET_ATON 1 + +/* Define to 1 if you have the `inet_ntop' function. */ +#cmakedefine EVENT__HAVE_INET_NTOP 1 + +/* Define to 1 if you have the `inet_pton' function. */ +#cmakedefine EVENT__HAVE_INET_PTON 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine EVENT__HAVE_INTTYPES_H 1 + +/* Define to 1 if you have the `issetugid' function. */ +#cmakedefine EVENT__HAVE_ISSETUGID 1 + +/* Define to 1 if you have the `kqueue' function. */ +#cmakedefine EVENT__HAVE_KQUEUE 1 + +/* Define if the system has zlib */ +#cmakedefine EVENT__HAVE_LIBZ 1 + +/* Define to 1 if you have the `mach_absolute_time' function. */ +#cmakedefine EVENT__HAVE_MACH_ABSOLUTE_TIME 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine EVENT__HAVE_MACH_MACH_TIME_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine EVENT__HAVE_MEMORY_H 1 + +/* Define to 1 if you have the `mmap' function. */ +#cmakedefine EVENT__HAVE_MMAP 1 + +/* Define to 1 if you have the `nanosleep' function. */ +#cmakedefine EVENT__HAVE_NANOSLEEP 1 + +/* Define to 1 if you have the `usleep' function. */ +#cmakedefine EVENT__HAVE_USLEEP 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine EVENT__HAVE_NETDB_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine EVENT__HAVE_NETINET_IN6_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine EVENT__HAVE_NETINET_IN_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine EVENT__HAVE_NETINET_TCP_H 1 + +/* Define if the system has openssl */ +#cmakedefine EVENT__HAVE_OPENSSL 1 + +/* Defines if the system has zlib */ +#cmakedefine EVENT__HAVE_ZLIB 1 + +/* Define to 1 if you have the `pipe' function. */ +#cmakedefine EVENT__HAVE_PIPE 1 + +/* Define to 1 if you have the `pipe2' function. */ +#cmakedefine EVENT__HAVE_PIPE2 1 + +/* Define to 1 if you have the `poll' function. */ +#cmakedefine EVENT__HAVE_POLL 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine EVENT__HAVE_POLL_H 1 + +/* Define to 1 if you have the `port_create' function. */ +#cmakedefine EVENT__HAVE_PORT_CREATE 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine EVENT__HAVE_PORT_H 1 + +/* Define if you have POSIX threads libraries and header files. */ +#cmakedefine EVENT__HAVE_PTHREAD 1 + +/* Define if we have pthreads on this system */ +#cmakedefine EVENT__HAVE_PTHREADS 1 + +/* Define to 1 if you have the `putenv' function. */ +#cmakedefine EVENT__HAVE_PUTENV 1 + +/* Define to 1 if the system has the type `sa_family_t'. */ +#cmakedefine EVENT__HAVE_SA_FAMILY_T 1 + +/* Define to 1 if you have the `select' function. */ +#cmakedefine EVENT__HAVE_SELECT 1 + +/* Define to 1 if you have the `setenv' function. */ +#cmakedefine EVENT__HAVE_SETENV 1 + +/* Define if F_SETFD is defined in */ +#cmakedefine EVENT__HAVE_SETFD 1 + +/* Define to 1 if you have the `setrlimit' function. */ +#cmakedefine EVENT__HAVE_SETRLIMIT 1 + +/* Define to 1 if you have the `sendfile' function. */ +#cmakedefine EVENT__HAVE_SENDFILE 1 + +/* Define if F_SETFD is defined in */ +#cmakedefine EVENT__HAVE_SETFD 1 + +/* Define to 1 if you have the `sigaction' function. */ +#cmakedefine EVENT__HAVE_SIGACTION 1 + +/* Define to 1 if you have the `signal' function. */ +#cmakedefine EVENT__HAVE_SIGNAL 1 + +/* Define to 1 if you have the `splice' function. */ +#cmakedefine EVENT__HAVE_SPLICE 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine EVENT__HAVE_STDARG_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine EVENT__HAVE_STDDEF_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine EVENT__HAVE_STDINT_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine EVENT__HAVE_STDLIB_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine EVENT__HAVE_STRINGS_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine EVENT__HAVE_STRING_H 1 + +/* Define to 1 if you have the `strlcpy' function. */ +#cmakedefine EVENT__HAVE_STRLCPY 1 + +/* Define to 1 if you have the `strsep' function. */ +#cmakedefine EVENT__HAVE_STRSEP 1 + +/* Define to 1 if you have the `strtok_r' function. */ +#cmakedefine EVENT__HAVE_STRTOK_R 1 + +/* Define to 1 if you have the `strtoll' function. */ +#cmakedefine EVENT__HAVE_STRTOLL 1 + +/* Define to 1 if the system has the type `struct addrinfo'. */ +#cmakedefine EVENT__HAVE_STRUCT_ADDRINFO 1 + +/* Define to 1 if the system has the type `struct in6_addr'. */ +#cmakedefine EVENT__HAVE_STRUCT_IN6_ADDR 1 + +/* Define to 1 if `s6_addr16' is member of `struct in6_addr'. */ +#cmakedefine EVENT__HAVE_STRUCT_IN6_ADDR_S6_ADDR16 1 + +/* Define to 1 if `s6_addr32' is member of `struct in6_addr'. */ +#cmakedefine EVENT__HAVE_STRUCT_IN6_ADDR_S6_ADDR32 1 + +/* Define to 1 if the system has the type `struct sockaddr_in6'. */ +#cmakedefine EVENT__HAVE_STRUCT_SOCKADDR_IN6 1 + +/* Define to 1 if `sin6_len' is member of `struct sockaddr_in6'. */ +#cmakedefine EVENT__HAVE_STRUCT_SOCKADDR_IN6_SIN6_LEN 1 + +/* Define to 1 if `sin_len' is member of `struct sockaddr_in'. */ +#cmakedefine EVENT__HAVE_STRUCT_SOCKADDR_IN_SIN_LEN 1 + +/* Define to 1 if the system has the type `struct sockaddr_storage'. */ +#cmakedefine EVENT__HAVE_STRUCT_SOCKADDR_STORAGE 1 + +/* Define to 1 if `ss_family' is a member of `struct sockaddr_storage'. */ +#cmakedefine EVENT__HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY 1 + +/* Define to 1 if `__ss_family' is a member of `struct sockaddr_storage'. */ +#cmakedefine EVENT__HAVE_STRUCT_SOCKADDR_STORAGE___SS_FAMILY 1 + +/* Define to 1 if you have the `sysctl' function. */ +#cmakedefine EVENT__HAVE_SYSCTL 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine EVENT__HAVE_SYS_DEVPOLL_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine EVENT__HAVE_SYS_EPOLL_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine EVENT__HAVE_SYS_EVENTFD_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine EVENT__HAVE_SYS_EVENT_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine EVENT__HAVE_SYS_IOCTL_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine EVENT__HAVE_SYS_MMAN_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine EVENT__HAVE_SYS_PARAM_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine EVENT__HAVE_SYS_QUEUE_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine EVENT__HAVE_SYS_RESOURCE_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine EVENT__HAVE_SYS_SELECT_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine EVENT__HAVE_SYS_SENDFILE_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine EVENT__HAVE_SYS_SOCKET_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine EVENT__HAVE_SYS_STAT_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine EVENT__HAVE_SYS_SYSCTL_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine EVENT__HAVE_SYS_TIMERFD_H */ + +/* Define to 1 if you have the header file. */ +#cmakedefine EVENT__HAVE_SYS_TIME_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine EVENT__HAVE_SYS_TYPES_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine EVENT__HAVE_SYS_UIO_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine EVENT__HAVE_SYS_WAIT_H 1 + +/* Define if TAILQ_FOREACH is defined in */ +#cmakedefine EVENT__HAVE_TAILQFOREACH 1 + +/* Define if timeradd is defined in */ +#cmakedefine EVENT__HAVE_TIMERADD 1 + +/* Define if timerclear is defined in */ +#cmakedefine EVENT__HAVE_TIMERCLEAR 1 + +/* Define if timercmp is defined in */ +#cmakedefine EVENT__HAVE_TIMERCMP 1 + +/* Define to 1 if you have the `timerfd_create' function. */ +#cmakedefine EVENT__HAVE_TIMERFD_CREATE 1 + +/* Define if timerisset is defined in */ +#cmakedefine EVENT__HAVE_TIMERISSET 1 + +/* Define to 1 if the system has the type `uint8_t'. */ +#cmakedefine EVENT__HAVE_UINT8_T 1 + +/* Define to 1 if the system has the type `uint16_t'. */ +#cmakedefine EVENT__HAVE_UINT16_T 1 + +/* Define to 1 if the system has the type `uint32_t'. */ +#cmakedefine EVENT__HAVE_UINT32_T 1 + +/* Define to 1 if the system has the type `uint64_t'. */ +#cmakedefine EVENT__HAVE_UINT64_T 1 + +/* Define to 1 if the system has the type `uintptr_t'. */ +#cmakedefine EVENT__HAVE_UINTPTR_T 1 + +/* Define to 1 if you have the `umask' function. */ +#cmakedefine EVENT__HAVE_UMASK 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine EVENT__HAVE_UNISTD_H 1 + +/* Define to 1 if you have the `unsetenv' function. */ +#cmakedefine EVENT__HAVE_UNSETENV 1 + +/* Define to 1 if you have the `vasprintf' function. */ +#cmakedefine EVENT__HAVE_VASPRINTF 1 + +/* Define if kqueue works correctly with pipes */ +#cmakedefine EVENT__HAVE_WORKING_KQUEUE 1 + +/* Define to necessary symbol if this constant uses a non-standard name on + your system. */ +#cmakedefine EVENT__PTHREAD_CREATE_JOINABLE ${EVENT__PTHREAD_CREATE_JOINABLE} + +/* The size of `pthread_t', as computed by sizeof. */ +#cmakedefine EVENT__SIZEOF_PTHREAD_T ${EVENT__SIZEOF_PTHREAD_T} + +/* The size of a `int', as computed by sizeof. */ +#cmakedefine EVENT__SIZEOF_INT ${EVENT__SIZEOF_INT} + +/* The size of a `long', as computed by sizeof. */ +#cmakedefine EVENT__SIZEOF_LONG ${EVENT__SIZEOF_LONG} + +/* The size of a `long long', as computed by sizeof. */ +#cmakedefine EVENT__SIZEOF_LONG_LONG ${EVENT__SIZEOF_LONG_LONG} + +/* The size of `off_t', as computed by sizeof. */ +#cmakedefine EVENT__SIZEOF_OFF_T ${EVENT__SIZEOF_OFF_T} + +/* The size of a `short', as computed by sizeof. */ +#cmakedefine EVENT__SIZEOF_SHORT ${EVENT__SIZEOF_SHORT} + +/* The size of `size_t', as computed by sizeof. */ +#cmakedefine EVENT__SIZEOF_SIZE_T ${EVENT__SIZEOF_SIZE_T} + +/* Define to 1 if you have the ANSI C header files. */ +#cmakedefine EVENT__STDC_HEADERS ${EVENT__STDC_HEADERS} + +/* Define to 1 if you can safely include both and . */ +#cmakedefine EVENT__TIME_WITH_SYS_TIME ${EVENT__TIME_WITH_SYS_TIME} + +/* The size of `socklen_t', as computed by sizeof. */ +#cmakedefine EVENT__SIZEOF_SOCKLEN_T ${EVENT__SIZEOF_SOCKLEN_T} + +/* The size of 'void *', as computer by sizeof */ +#cmakedefine EVENT__SIZEOF_VOID_P ${EVENT__SIZEOF_VOID_P} + +/* Define to appropriate substitute if compiler doesnt have __func__ */ +#cmakedefine EVENT____func__ ${EVENT____func__} + +/* Number of bits in a file offset, on hosts where this is settable. */ +#cmakedefine EVENT___FILE_OFFSET_BITS ${EVENT___FILE_OFFSET_BITS} + +/* Define for large files, on AIX-style hosts. */ +/* #undef _LARGE_FILES */ + +/* Define to empty if `const' does not conform to ANSI C. */ +/* #undef EVENT__const */ + +/* Define to `__inline__' or `__inline' if that's what the C compiler + calls it, or to nothing if 'inline' is not supported under any name. */ +#ifndef __cplusplus +#cmakedefine EVENT__inline ${EVENT__inline} +#endif + +/* Define to `int' if does not define. */ +#cmakedefine EVENT__pid_t ${EVENT__pid_t} + +/* Define to `unsigned' if does not define. */ +#cmakedefine EVENT__size_t ${EVENT__size_t} + +/* Define to unsigned int if you dont have it */ +#cmakedefine EVENT__socklen_t ${EVENT__socklen_t} + +/* Define to `int' if does not define. */ +#cmakedefine EVENT__ssize_t ${EVENT__ssize_t} + +#endif diff --git a/test/bench_cascade.c b/test/bench_cascade.c index 831b0bcb..b44c8ab1 100644 --- a/test/bench_cascade.c +++ b/test/bench_cascade.c @@ -36,6 +36,7 @@ #define WIN32_LEAN_AND_MEAN #include #else +#define closesocket(x) close(x) #include #include #endif @@ -48,7 +49,7 @@ #include #endif #include - +#include #include #include @@ -84,8 +85,8 @@ run_once(int num_pipes) evutil_socket_t *cp; static struct timeval ts, te, tv_timeout; - events = calloc(num_pipes, sizeof(struct event)); - pipes = calloc(num_pipes * 2, sizeof(evutil_socket_t)); + events = (struct event *)calloc(num_pipes, sizeof(struct event)); + pipes = (evutil_socket_t *)calloc(num_pipes * 2, sizeof(evutil_socket_t)); if (events == NULL || pipes == NULL) { perror("malloc"); @@ -126,8 +127,8 @@ run_once(int num_pipes) for (cp = pipes, i = 0; i < num_pipes; i++, cp += 2) { event_del(&events[i]); - close(cp[0]); - close(cp[1]); + closesocket(cp[0]); + closesocket(cp[1]); } free(pipes); From e9fc014c86a6e70582b6f5a9e1db70ebf5530ae7 Mon Sep 17 00:00:00 2001 From: Joakim Soderberg Date: Thu, 12 Dec 2013 16:33:20 +0100 Subject: [PATCH 03/38] Add all tests and benchmarks to CMake project. Also fixed some minor issues with what's built. --- CMakeLists.txt | 163 +++++++++++++++++++++++++++++++------------------ test/bench.c | 4 ++ 2 files changed, 108 insertions(+), 59 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2629cea9..3348c382 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -54,8 +54,6 @@ include(CheckCSourceCompiles) include(CheckPrototypeDefinition) include(FindZLIB) # -> HAVE_LIBZ -include(FindThreads) # -> HAVE_PTHREAD -include(FindPythonInterp) # Winsock. if(WIN32) @@ -429,7 +427,6 @@ set(HDR_PUBLIC include/event2/buffer.h include/event2/bufferevent.h include/event2/bufferevent_compat.h - include/event2/bufferevent_ssl.h include/event2/bufferevent_struct.h include/event2/buffer_compat.h include/event2/dns.h @@ -496,23 +493,33 @@ endif() if (NOT EVENT__DISABLE_OPENSSL) find_package(OpenSSL REQUIRED) + set(EVENT__HAVE_OPENSSL 1) message("OpenSSL include: ${OPENSSL_INCLUDE_DIR}") message("OpenSSL lib: ${OPENSSL_LIBRARIES}") + include_directories(${OPENSSL_INCLUDE_DIR}) + list(APPEND SRC_CORE bufferevent_openssl.c) + list(APPEND HDR_PUBLIC include/event2/bufferevent_ssl.h) list(APPEND LIB_REGRESS ${OPENSSL_LIBRARIES}) endif() -if(CMAKE_USE_PTHREADS_INIT) - set(EVENT__HAVE_PTHREADS 1) - list(APPEND SRC_CORE evthread_pthread.c) - list(APPEND SRC_REGRESS test/regress_thread.c) - list(APPEND LIB_REGRESS ${CMAKE_THREAD_LIBS_INIT}) +if (NOT EVENT__DISABLE_THREAD_SUPPORT) + if (WIN32) + list(APPEND SRC_CORE evthread_win32.c) + else() + find_package(Threads REQUIRED) + if (NOT CMAKE_USE_PTHREADS_INIT) + message(FATAL_ERROR "Failed to find Pthreads, set EVENT__DISABLE_THREAD_SUPPORT to turn off thread support") + endif() + set(EVENT__HAVE_PTHREADS 1) + list(APPEND SRC_CORE evthread_pthread.c) + list(APPEND LIB_REGRESS ${CMAKE_THREAD_LIBS_INIT}) + endif() endif() -if(ZLIB_LIBRARY) +if (ZLIB_LIBRARY) set(EVENT__HAVE_ZLIB 1) set(EVENT__HAVE_ZLIB_H) include_directories(${ZLIB_INCLUDE_DIRS}) - list(APPEND SRC_REGRESS test/regress_zlib.c) list(APPEND LIB_REGRESS ${ZLIB_LIBRARIES}) endif() @@ -533,11 +540,12 @@ if(WIN32) event_iocp.c evthread_win32.c win32select.c - WIN32-Code/getopt.c - WIN32-Code/getopt_long.c + WIN32-Code/getopt.c + WIN32-Code/getopt_long.c ) - list(APPEND SRC_REGRESS test/regress_iocp.c) - list(APPEND SRC_REGRESS test/regress_thread.c) + + list(APPEND HDR_PRIVATE WIN32-Code/getopt.h) + set(EVENT__DNS_USE_FTIME_FOR_ID 1) add_definitions(-D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE) set(LIB_PLATFORM ws2_32) @@ -553,6 +561,7 @@ configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/event-config.h.cmake ${CMAKE_CURRENT_SOURCE_DIR}/include/event2/event-config.h) +# TODO: Add dynamic versions of the libraries as well. add_library(event_core STATIC ${HDR_PRIVATE} ${HDR_PUBLIC} @@ -562,7 +571,7 @@ add_library(event_core STATIC add_library(event_extras STATIC ${SRC_EXTRA} ) - + add_library(event STATIC ${HDR_PRIVATE} ${HDR_PUBLIC} @@ -570,37 +579,57 @@ add_library(event STATIC ${SRC_EXTRA} ) -# TODO: Make these into tests instead? -#add_executable(event-test sample/event-test.c) -#target_link_libraries(event-test event ${LIB_PLATFORM}) - -add_executable(time-test sample/time-test.c) -target_link_libraries(time-test event ${LIB_PLATFORM}) - -add_executable(signal-test sample/signal-test.c) -target_link_libraries(signal-test event ${LIB_PLATFORM}) - -#add_executable(test-init test/test-init.c) -#target_link_libraries(test-init event ${LIB_PLATFORM}) - -#add_executable(test-eof test/test-eof.c) -#target_link_libraries(test-eof event ${LIB_PLATFORM}) - -#add_executable(test-weof test/test-weof.c) -#target_link_libraries(test-weof event ${LIB_PLATFORM}) - -#add_executable(time-test test/time-test.c) -#target_link_libraries(time-test event ${LIB_PLATFORM}) +if (NOT EVENT__DISABLE_SAMPLES) + # TODO: Add samples. +endif() if (NOT EVENT__DISABLE_BENCHMARK) - add_executable(bench_cascade test/bench_cascade.c) - target_link_libraries(bench_cascade event ${LIB_PLATFORM}) - - add_executable(bench_http test/bench_http.c) - target_link_libraries(bench_http event ${LIB_PLATFORM}) + foreach (BENCHMARK bench bench_cascade bench_http bench_httpclient) + add_executable(${BENCHMARK} test/${BENCHMARK}.c) + target_link_libraries(${BENCHMARK} event ${LIB_PLATFORM}) + endforeach() endif() if (NOT EVENT__DISABLE_TESTS) + + # (We require python to generate the regress tests) + find_package(PythonInterp 2) # TODO: Require 2.4+ here... + + # + # Test programs. + # + set(TESTPROGS test-changelist + test-eof + test-fdleak + test-init + test-time + test-weof) + + # Create test program executables. + foreach (TESTPROG ${TESTPROGS} test-dumpevents test-ratelim) + add_executable(${TESTPROG} test/${TESTPROG}.c) + target_link_libraries(${TESTPROG} event ${LIB_PLATFORM}) + endforeach() + + foreach (TESTPROG ${TESTPROGS}) + add_test(${TESTPROG} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${TESTPROG}) + endforeach() + + # Dump events test. + if (PYTHONINTERP_FOUND) + add_custom_command( + OUTPUT + ${CMAKE_CURRENT_BINARY_DIR}/test/eventdump + DEPENDS + test-dumpevents + COMMAND test-dumpevents + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/test + ) + endif() + + # + # Regress tests. + # if (PYTHONINTERP_FOUND) message("Generating regress tests...") add_definitions(-DTINYTEST_LOCAL) @@ -616,35 +645,51 @@ if (NOT EVENT__DISABLE_TESTS) ) list(APPEND SRC_REGRESS - test/regress.c - test/regress_buffer.c - test/regress_http.c - test/regress_dns.c - test/regress_testutils.c - test/regress_testutils.h - test/regress_rpc.c - test/regress_et.c - test/regress_bufferevent.c - test/regress_listener.c - test/regress_util.c - test/tinytest.c - test/regress_main.c - test/regress_minheap.c + test/regress.c test/regress.gen.c test/regress.gen.h + test/regress_buffer.c + test/regress_bufferevent.c + test/regress_dns.c + test/regress_et.c test/regress_finalize.c + test/regress_http.c + test/regress_listener.c + test/regress_main.c + test/regress_minheap.c + test/regress_rpc.c + test/regress_testutils.c + test/regress_testutils.h + test/regress_util.c + test/tinytest.c ) - + + if (WIN32) + list(APPEND SRC_REGRESS test/regress_iocp.c) + list(APPEND SRC_REGRESS test/regress_thread.c) + endif() + + if (CMAKE_USE_PTHREADS_INIT) + list(APPEND SRC_REGRESS test/regress_thread.c) + endif() + + if (ZLIB_LIBRARY) + list(APPEND SRC_REGRESS test/regress_zlib.c) + endif() + + if (OPENSSL_LIBRARIES) + list(APPEND SRC_REGRESS test/regress_ssl.c) + endif() + add_executable(regress ${SRC_REGRESS}) target_link_libraries(regress event ${LIB_REGRESS} ${LIB_PLATFORM}) + + add_test(regress ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/regress) else() message(WARNING "Python not found, cannot generate regress tests!") endif() - # Tests. enable_testing() - add_test(regress "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${EXECUTABLE_OUTPUT_PATH}/regress") - include(CTest) endif() diff --git a/test/bench.c b/test/bench.c index b3e40a55..bdae7b1a 100644 --- a/test/bench.c +++ b/test/bench.c @@ -57,6 +57,10 @@ #endif #include +#ifdef WIN32 +#include +#endif + #include #include From 99c1dc3233a3fdd70c641011eecb3eb23b0817bb Mon Sep 17 00:00:00 2001 From: Joakim Soderberg Date: Thu, 12 Dec 2013 18:21:11 +0100 Subject: [PATCH 04/38] More work on adding tests to CMake project --- CMakeLists.txt | 123 ++++++++++++++++++++++++++----------- test/regress_bufferevent.c | 2 +- 2 files changed, 88 insertions(+), 37 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3348c382..63367a74 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -33,6 +33,7 @@ option(EVENT__DISABLE_THREAD_SUPPORT "Define if libevent should not be compiled option(EVENT__DISABLE_OPENSSL "Define if libevent should build without support for OpenSSL encrpytion" 0) option(EVENT__DISABLE_BENCHMARK "Defines if libevent should build without the benchmark exectuables" 0) option(EVENT__DISABLE_TESTS "If tests should be compiled or not" 0) +option(EVENT__DISABLE_REGRESS "Disable the regress tests" 0) # Put the libaries and binaries that get built into directories at the # top of the build tree rather than in hard-to-find leaf directories. @@ -596,41 +597,9 @@ if (NOT EVENT__DISABLE_TESTS) find_package(PythonInterp 2) # TODO: Require 2.4+ here... # - # Test programs. + # Generate Regress tests. # - set(TESTPROGS test-changelist - test-eof - test-fdleak - test-init - test-time - test-weof) - - # Create test program executables. - foreach (TESTPROG ${TESTPROGS} test-dumpevents test-ratelim) - add_executable(${TESTPROG} test/${TESTPROG}.c) - target_link_libraries(${TESTPROG} event ${LIB_PLATFORM}) - endforeach() - - foreach (TESTPROG ${TESTPROGS}) - add_test(${TESTPROG} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${TESTPROG}) - endforeach() - - # Dump events test. - if (PYTHONINTERP_FOUND) - add_custom_command( - OUTPUT - ${CMAKE_CURRENT_BINARY_DIR}/test/eventdump - DEPENDS - test-dumpevents - COMMAND test-dumpevents - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/test - ) - endif() - - # - # Regress tests. - # - if (PYTHONINTERP_FOUND) + if (NOT EVENT__DISABLE_REGRESS AND PYTHONINTERP_FOUND) message("Generating regress tests...") add_definitions(-DTINYTEST_LOCAL) add_custom_command( @@ -683,12 +652,94 @@ if (NOT EVENT__DISABLE_TESTS) add_executable(regress ${SRC_REGRESS}) target_link_libraries(regress event ${LIB_REGRESS} ${LIB_PLATFORM}) - - add_test(regress ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/regress) else() message(WARNING "Python not found, cannot generate regress tests!") endif() + # + # Test programs. + # + set(TESTPROGS test-changelist + test-eof + test-fdleak + test-init + test-time + test-weof) + + # Create test program executables. + foreach (TESTPROG ${TESTPROGS} test-dumpevents test-ratelim) + add_executable(${TESTPROG} test/${TESTPROG}.c) + target_link_libraries(${TESTPROG} event ${LIB_PLATFORM}) + endforeach() + + # + # We run all tests with the different backends turned on one at a time. + # + + # Default environment variables turns off all event systems, + # then we enable each one, one at a time when creating the tests. + set(BACKENDS EVPORT KQUEUE EPOLL DEVPOLL POLL SELECT WIN32) + set(DEFAULT_TEST_ENV_VARS "") + foreach(BACKEND ${BACKENDS}) + list(APPEND DEFAULT_TEST_ENV_VARS "EVENT_NO${BACKEND}") + endforeach() + + # Macro that creates the ctest test for a backend. + macro(add_backend_test BACKEND_TEST_NAME ENV_VARS) + foreach (TESTPROG ${TESTPROGS}) + add_test(${TESTPROG}_${BACKEND_TEST_NAME} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${TESTPROG}) + set_tests_properties(${TESTPROG}_${BACKEND_TEST_NAME} PROPERTIES ENVIRONMENT "${ENV_VARS}") + endforeach() + + # Dump events test. + if (PYTHONINTERP_FOUND) + add_test(test-dumpevents_${BACKEND_TEST_NAME} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/test-dumpevents | ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test/check-dumpevents.py) + set_tests_properties(test-dumpevents_${BACKEND_TEST_NAME} PROPERTIES ENVIRONMENT "${ENV_VARS}") + else() + message(WARNING "test-dumpevents will be run without output check since python was not found!") + add_test(test-dumpevents_${BACKEND_TEST_NAME}_no_check ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/test-dumpevents) + set_tests_properties(test-dumpevents_${BACKEND_TEST_NAME}_no_check PROPERTIES ENVIRONMENT "${ENV_VARS}") + endif() + + # Regress tests. + if (NOT EVENT__DISABLE_REGRESS AND PYTHONINTERP_FOUND) + add_test(regress_${BACKEND_TEST_NAME} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/regress) + set_tests_properties(regress_${BACKEND_TEST_NAME} PROPERTIES ENVIRONMENT "${ENV_VARS}") + endif() + endmacro() + + # Add the tests for each backend. + foreach(BACKEND ${BACKENDS}) + # Enable this backend only. + set(BACKEND_ENV_VARS ${DEFAULT_TEST_ENV_VARS}) + list(REMOVE_ITEM BACKEND_ENV_VARS EVENT_NO${BACKEND}) + + # Epoll has some extra settings. + if (${BACKEND} STREQUAL "EPOLL") + add_backend_test(timerfd_${BACKEND} "${BACKEND_ENV_VARS};EVENT_PRECISE_TIMER=1") + add_backend_test(changelist_${BACKEND} "${BACKEND_ENV_VARS};EVENT_EPOLL_USE_CHANGELIST=yes") + add_backend_test(timerfd_changelist_${BACKEND} "${BACKEND_ENV_VARS};EVENT_EPOLL_USE_CHANGELIST=yes;EVENT_PRECISE_TIMER=1") + else() + add_backend_test(${BACKEND} ${BACKEND_ENV_VARS}) + endif() + endforeach() + + # + # Rate limiter tests. + # + + # Group limits, no connection limit. + add_test(test-ratelim_group_lim ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/test-ratelim -g 30000 -n 30 -t 100 --check-grouplimit 1000 --check-stddev 100) + + # Connection limit, no group limit. + add_test(test-ratelim_con_lim ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/test-ratelim -c 1000 -n 30 -t 100 --check-connlimit 50 --check-stddev 50) + + # Connection limit and group limit. + add_test(test-ratelim_group_con_lim ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/test-ratelim -c 1000 -g 30000 -n 30 -t 100 --check-grouplimit 1000 --check-connlimit 50 --check-stddev 50) + + # Connection limit and group limit with independent drain. + add_test(test-ratelim_group_con_lim_drain ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/test-ratelim -c 1000 -g 35000 -n 30 -t 100 -G 500 --check-grouplimit 1000 --check-connlimit 50 --check-stddev 50) + enable_testing() include(CTest) diff --git a/test/regress_bufferevent.c b/test/regress_bufferevent.c index 1be16216..dad26b62 100644 --- a/test/regress_bufferevent.c +++ b/test/regress_bufferevent.c @@ -599,7 +599,7 @@ close_socket_cb(evutil_socket_t fd, short what, void *arg) static void test_bufferevent_connect_fail(void *arg) { - struct basic_test_data *data = arg; + struct basic_test_data *data = (struct basic_test_data *)arg; struct bufferevent *bev=NULL; struct sockaddr_in localhost; struct sockaddr *sa = (struct sockaddr*)&localhost; From ce14defeb6de5c7f8677074f90238e67feeab20b Mon Sep 17 00:00:00 2001 From: Joakim Soderberg Date: Fri, 13 Dec 2013 11:34:22 +0100 Subject: [PATCH 05/38] Generate a dummy evconfig-private.h so things build properly. Windows used to have an empty file for this before. --- CMakeLists.txt | 12 ++++++++++-- WIN32-Code/evconfig-private.h | 6 ------ evconfig-private.h.cmake | 35 +++++++++++++++++++++++++++++++++++ 3 files changed, 45 insertions(+), 8 deletions(-) delete mode 100644 WIN32-Code/evconfig-private.h create mode 100644 evconfig-private.h.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 63367a74..3e822356 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -558,9 +558,17 @@ source_group("Headers Public" FILES ${HDR_PUBLIC}) source_group("Source Core" FILES ${SRC_CORE}) source_group("Source Extra" FILES ${SRC_EXTRA}) +# Generate the configure headers. +# (Place them in the build dir so we don't polute the source tree with generated files). +include_directories(${CMAKE_CURRENT_BINARY_DIR}/include) + configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/event-config.h.cmake - ${CMAKE_CURRENT_SOURCE_DIR}/include/event2/event-config.h) + ${CMAKE_CURRENT_BINARY_DIR}/include/event2/event-config.h) + +configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/evconfig-private.h.cmake + ${CMAKE_CURRENT_BINARY_DIR}/include/evconfig-private.h) # TODO: Add dynamic versions of the libraries as well. add_library(event_core STATIC @@ -681,7 +689,7 @@ if (NOT EVENT__DISABLE_TESTS) set(BACKENDS EVPORT KQUEUE EPOLL DEVPOLL POLL SELECT WIN32) set(DEFAULT_TEST_ENV_VARS "") foreach(BACKEND ${BACKENDS}) - list(APPEND DEFAULT_TEST_ENV_VARS "EVENT_NO${BACKEND}") + list(APPEND DEFAULT_TEST_ENV_VARS "EVENT_NO${BACKEND}=1") endforeach() # Macro that creates the ctest test for a backend. diff --git a/WIN32-Code/evconfig-private.h b/WIN32-Code/evconfig-private.h deleted file mode 100644 index 88e20627..00000000 --- a/WIN32-Code/evconfig-private.h +++ /dev/null @@ -1,6 +0,0 @@ -#if !defined(EVENT_EVCONFIG__PRIVATE_H_) && !defined(__MINGW32__) -#define EVENT_EVCONFIG__PRIVATE_H_ - -/* Nothing to see here. Move along. */ - -#endif diff --git a/evconfig-private.h.cmake b/evconfig-private.h.cmake new file mode 100644 index 00000000..32f04794 --- /dev/null +++ b/evconfig-private.h.cmake @@ -0,0 +1,35 @@ + +#ifndef EVCONFIG_PRIVATE_H_INCLUDED_ +#define EVCONFIG_PRIVATE_H_INCLUDED_ + +/* Enable extensions on AIX 3, Interix. */ +#cmakedefine _ALL_SOURCE + +/* Enable GNU extensions on systems that have them. */ +#cmakedefine _GNU_SOURCE 1 + +/* Enable threading extensions on Solaris. */ +#cmakedefine _POSIX_PTHREAD_SEMANTICS 1 + +/* Enable extensions on HP NonStop. */ +#cmakedefine _TANDEM_SOURCE 1 + +/* Enable general extensions on Solaris. */ +#cmakedefine __EXTENSIONS__ + +/* Number of bits in a file offset, on hosts where this is settable. */ +#cmakedefine _FILE_OFFSET_BITS 1 +/* Define for large files, on AIX-style hosts. */ +#cmakedefine _LARGE_FILES 1 + +/* Define to 1 if on MINIX. */ +#cmakedefine _MINIX 1 + +/* Define to 2 if the system does not provide POSIX.1 features except with + this defined. */ +#cmakedefine _POSIX_1_SOURCE 1 + +/* Define to 1 if you need to in order for `stat' and other things to work. */ +#cmakedefine _POSIX_SOURCE 1 + +#endif From 58fcd42880d7ad095f682430b1615c6af9ae64bf Mon Sep 17 00:00:00 2001 From: Joakim Soderberg Date: Fri, 13 Dec 2013 12:39:50 +0000 Subject: [PATCH 06/38] Link libm on unix platforms. --- CMakeLists.txt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3e822356..25491349 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -550,7 +550,11 @@ if(WIN32) set(EVENT__DNS_USE_FTIME_FOR_ID 1) add_definitions(-D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE) set(LIB_PLATFORM ws2_32) - include_directories(./WIN32-Code) + include_directories(./WIN32-Code) +endif() + +if (UNIX) + list(APPEND LIB_PLATFORM m) endif() source_group("Headers Private" FILES ${HDR_PRIVATE}) From 19222e5247f78b699c9d4061fc2118d772305724 Mon Sep 17 00:00:00 2001 From: Joakim Soderberg Date: Fri, 13 Dec 2013 17:00:23 +0100 Subject: [PATCH 07/38] Added some GCC specific options. - Added sample applications. - Fixed the https-client to work on Windows kind of (No cert validation). --- CMakeLists.txt | 79 ++++++++++++++++++++++++++++++++++++------- sample/https-client.c | 27 +++++++++++++++ 2 files changed, 93 insertions(+), 13 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 25491349..a9977426 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,13 +27,16 @@ set(EVENT_NUMERIC_VERSION 0x02010401) set(EVENT_VERSION "2.1.4-beta") set(EVENT_PACKAGE_VERSION "") -option(EVENT__DISABLE_DEBUG_MODE "Define if libevent should build without support for a debug mode" 0) -option(EVENT__DISABLE_MM_REPLACEMENT "Define if libevent should not allow replacing the mm functions" 0) -option(EVENT__DISABLE_THREAD_SUPPORT "Define if libevent should not be compiled with thread support" 0) -option(EVENT__DISABLE_OPENSSL "Define if libevent should build without support for OpenSSL encrpytion" 0) -option(EVENT__DISABLE_BENCHMARK "Defines if libevent should build without the benchmark exectuables" 0) -option(EVENT__DISABLE_TESTS "If tests should be compiled or not" 0) -option(EVENT__DISABLE_REGRESS "Disable the regress tests" 0) +option(EVENT__DISABLE_DEBUG_MODE "Define if libevent should build without support for a debug mode" OFF) +option(EVENT__ENABLE_VERBOSE_DEBUG "Enables verbose debugging" OFF) +option(EVENT__DISABLE_MM_REPLACEMENT "Define if libevent should not allow replacing the mm functions" OFF) +option(EVENT__DISABLE_THREAD_SUPPORT "Define if libevent should not be compiled with thread support" OFF) +option(EVENT__DISABLE_OPENSSL "Define if libevent should build without support for OpenSSL encrpytion" OFF) +option(EVENT__DISABLE_BENCHMARK "Defines if libevent should build without the benchmark exectuables" OFF) +option(EVENT__DISABLE_TESTS "If tests should be compiled or not" OFF) +option(EVENT__DISABLE_REGRESS "Disable the regress tests" OFF) +# TODO: Add --enable-verbose-debug, verbose debug logging +# TODO: Add --disable-largefile omit support for large files # Put the libaries and binaries that get built into directories at the # top of the build tree rather than in hard-to-find leaf directories. @@ -56,6 +59,35 @@ include(CheckPrototypeDefinition) include(FindZLIB) # -> HAVE_LIBZ +if (CMAKE_COMPILER_IS_GNUCC) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall") + + option(EVENT__DISABLE_GCC_WARNINGS "Disable verbose warnings with GCC" OFF) + if (EVENT__DISABLE_GCC_WARNINGS) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -w") + endif() + + option(EVENT__ENABLE_GCC_HARDENING "Enable compiler security checks" OFF) + if (EVENT__ENABLE_GCC_HARDENING) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_FORTIFY_SOURCE=2 -fstack-protector-all -fwrapv -fPIE -Wstack-protector --param ssp-buffer-size=1") + endif() + + option(EVENT__ENABLE_GCC_FUNCTION_SECTIONS "Enable gcc function sections" OFF) + if (EVENT__ENABLE_GCC_FUNCTION_SECTIONS) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -ffunction-sections") + # TODO: Add --gc-sections support. We need some checks for NetBSD to ensure this works. + endif() + + # We need to test for at least gcc 2.95 here, because older versions don't + # have -fno-strict-aliasing + execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpversion + OUTPUT_VARIABLE GCC_VERSION) + if (GCC_VERSION VERSION_GREATER 2.95) + message(STATUS "GCC Version >= 2.95 enabling no-strict-aliasing") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-strict-aliasing") + endif() +endif() + # Winsock. if(WIN32) set(CMAKE_EXTRA_INCLUDE_FILES winsock2.h ws2tcpip.h) @@ -500,7 +532,7 @@ if (NOT EVENT__DISABLE_OPENSSL) include_directories(${OPENSSL_INCLUDE_DIR}) list(APPEND SRC_CORE bufferevent_openssl.c) list(APPEND HDR_PUBLIC include/event2/bufferevent_ssl.h) - list(APPEND LIB_REGRESS ${OPENSSL_LIBRARIES}) + list(APPEND LIB_APPS ${OPENSSL_LIBRARIES}) endif() if (NOT EVENT__DISABLE_THREAD_SUPPORT) @@ -513,7 +545,7 @@ if (NOT EVENT__DISABLE_THREAD_SUPPORT) endif() set(EVENT__HAVE_PTHREADS 1) list(APPEND SRC_CORE evthread_pthread.c) - list(APPEND LIB_REGRESS ${CMAKE_THREAD_LIBS_INIT}) + list(APPEND LIB_APPS ${CMAKE_THREAD_LIBS_INIT}) endif() endif() @@ -521,7 +553,7 @@ if (ZLIB_LIBRARY) set(EVENT__HAVE_ZLIB 1) set(EVENT__HAVE_ZLIB_H) include_directories(${ZLIB_INCLUDE_DIRS}) - list(APPEND LIB_REGRESS ${ZLIB_LIBRARIES}) + list(APPEND LIB_APPS ${ZLIB_LIBRARIES}) endif() set(SRC_EXTRA @@ -593,7 +625,28 @@ add_library(event STATIC ) if (NOT EVENT__DISABLE_SAMPLES) - # TODO: Add samples. + set(SAMPLES + dns-example + event-read-fifo + hello-world + le-proxy + signal-test + http-server + time-test) + + if (OPENSSL_LIBRARIES) + # Special sample with more than one file. + add_executable(https-client + sample/https-client.c + sample/openssl_hostname_validation.c + sample/hostcheck.c) + target_link_libraries(https-client event ${LIB_APPS} ${LIB_PLATFORM}) + endif() + + foreach(SAMPLE ${SAMPLES}) + add_executable(${SAMPLE} sample/${SAMPLE}.c) + target_link_libraries(${SAMPLE} event ${LIB_APPS} ${LIB_PLATFORM}) + endforeach() endif() if (NOT EVENT__DISABLE_BENCHMARK) @@ -663,7 +716,7 @@ if (NOT EVENT__DISABLE_TESTS) endif() add_executable(regress ${SRC_REGRESS}) - target_link_libraries(regress event ${LIB_REGRESS} ${LIB_PLATFORM}) + target_link_libraries(regress event ${LIB_APPS} ${LIB_PLATFORM}) else() message(WARNING "Python not found, cannot generate regress tests!") endif() @@ -724,7 +777,7 @@ if (NOT EVENT__DISABLE_TESTS) foreach(BACKEND ${BACKENDS}) # Enable this backend only. set(BACKEND_ENV_VARS ${DEFAULT_TEST_ENV_VARS}) - list(REMOVE_ITEM BACKEND_ENV_VARS EVENT_NO${BACKEND}) + list(REMOVE_ITEM BACKEND_ENV_VARS EVENT_NO${BACKEND}=1) # Epoll has some extra settings. if (${BACKEND} STREQUAL "EPOLL") diff --git a/sample/https-client.c b/sample/https-client.c index b32e4304..831576f3 100644 --- a/sample/https-client.c +++ b/sample/https-client.c @@ -19,6 +19,9 @@ #ifdef WIN32 #include #include + +#define snprintf _snprintf +#define strcasecmp _stricmp #else #include #include @@ -188,6 +191,22 @@ main(int argc, char **argv) if (argc != 2) syntax(); +#ifdef WIN32 + { + WORD wVersionRequested; + WSADATA wsaData; + int err; + + wVersionRequested = MAKEWORD(2, 2); + + err = WSAStartup(wVersionRequested, &wsaData); + if (err != 0) { + printf("WSAStartup failed with error: %d\n", err); + return 1; + } + } +#endif + url = argv[1]; http_uri = evhttp_uri_parse(url); if (http_uri == NULL) { @@ -241,6 +260,9 @@ main(int argc, char **argv) if (!ssl_ctx) die_openssl("SSL_CTX_new"); + #ifndef WIN32 + /* TODO: Add certificate loading on Windows as well */ + /* Attempt to use the system's trusted root certificates. * (This path is only valid for Debian-based systems.) */ if (1 != SSL_CTX_load_verify_locations(ssl_ctx, @@ -271,6 +293,7 @@ main(int argc, char **argv) * "wrapping" OpenSSL's routine, not replacing it. */ SSL_CTX_set_cert_verify_callback (ssl_ctx, cert_verify_callback, (void *) host); + #endif // not WIN32 // Create event base base = event_base_new(); @@ -331,5 +354,9 @@ main(int argc, char **argv) evhttp_connection_free(evcon); event_base_free(base); +#ifdef WIN32 + WSACleanup(); +#endif + return 0; } From dbf2b5171ac9d5d1ae17f66153f8db6991cea3d7 Mon Sep 17 00:00:00 2001 From: Joakim Soderberg Date: Mon, 16 Dec 2013 11:26:29 +0100 Subject: [PATCH 08/38] Use evutil_closesocket instead. --- test/bench_cascade.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/test/bench_cascade.c b/test/bench_cascade.c index b44c8ab1..5bb155b1 100644 --- a/test/bench_cascade.c +++ b/test/bench_cascade.c @@ -36,7 +36,6 @@ #define WIN32_LEAN_AND_MEAN #include #else -#define closesocket(x) close(x) #include #include #endif @@ -127,8 +126,8 @@ run_once(int num_pipes) for (cp = pipes, i = 0; i < num_pipes; i++, cp += 2) { event_del(&events[i]); - closesocket(cp[0]); - closesocket(cp[1]); + evutil_closesocket(cp[0]); + evutil_closesocket(cp[1]); } free(pipes); From c259d53c822d639c838a91aa0d98ef1a61db26c9 Mon Sep 17 00:00:00 2001 From: Joakim Soderberg Date: Mon, 16 Dec 2013 11:27:13 +0100 Subject: [PATCH 09/38] Add copyright and licensing files for CMake modules. --- cmake/COPYING-CMAKE-SCRIPTS | 22 ++++++++++++++ cmake/Copyright.txt | 57 +++++++++++++++++++++++++++++++++++++ 2 files changed, 79 insertions(+) create mode 100644 cmake/COPYING-CMAKE-SCRIPTS create mode 100644 cmake/Copyright.txt diff --git a/cmake/COPYING-CMAKE-SCRIPTS b/cmake/COPYING-CMAKE-SCRIPTS new file mode 100644 index 00000000..ab3c4d25 --- /dev/null +++ b/cmake/COPYING-CMAKE-SCRIPTS @@ -0,0 +1,22 @@ +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + +1. Redistributions of source code must retain the copyright + notice, this list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. +3. The name of the author may not be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file diff --git a/cmake/Copyright.txt b/cmake/Copyright.txt new file mode 100644 index 00000000..813124f0 --- /dev/null +++ b/cmake/Copyright.txt @@ -0,0 +1,57 @@ +CMake - Cross Platform Makefile Generator +Copyright 2000-2013 Kitware, Inc. +Copyright 2000-2011 Insight Software Consortium +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + +* Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + +* Neither the names of Kitware, Inc., the Insight Software Consortium, + nor the names of their contributors may be used to endorse or promote + products derived from this software without specific prior written + permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +------------------------------------------------------------------------------ + +The above copyright and license notice applies to distributions of +CMake in source and binary form. Some source files contain additional +notices of original copyright by their contributors; see each source +for details. Third-party software packages supplied with CMake under +compatible licenses provide their own copyright notices documented in +corresponding subdirectories. + +------------------------------------------------------------------------------ + +CMake was initially developed by Kitware with the following sponsorship: + + * National Library of Medicine at the National Institutes of Health + as part of the Insight Segmentation and Registration Toolkit (ITK). + + * US National Labs (Los Alamos, Livermore, Sandia) ASC Parallel + Visualization Initiative. + + * National Alliance for Medical Image Computing (NAMIC) is funded by the + National Institutes of Health through the NIH Roadmap for Medical Research, + Grant U54 EB005149. + + * Kitware, Inc. \ No newline at end of file From 9bbce0b63cceb2df9725b30abcf64ee8794cc73e Mon Sep 17 00:00:00 2001 From: Joakim Soderberg Date: Mon, 16 Dec 2013 11:34:14 +0100 Subject: [PATCH 10/38] Only include WIN32 getopt where it is used. getopt is only used in the benchmark tests, don't include it in the core lib... --- CMakeLists.txt | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a9977426..a3ced8a9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -572,9 +572,7 @@ if(WIN32) bufferevent_async.c event_iocp.c evthread_win32.c - win32select.c - WIN32-Code/getopt.c - WIN32-Code/getopt_long.c + win32select.c ) list(APPEND HDR_PRIVATE WIN32-Code/getopt.h) @@ -651,7 +649,13 @@ endif() if (NOT EVENT__DISABLE_BENCHMARK) foreach (BENCHMARK bench bench_cascade bench_http bench_httpclient) - add_executable(${BENCHMARK} test/${BENCHMARK}.c) + set(BENCH_SRC test/${BENCHMARK}.c) + + if (WIN32) + list(APPEND BENCH_SRC WIN32-Code/getopt.c WIN32-Code/getopt_long.c) + endif() + + add_executable(${BENCHMARK} ${BENCH_SRC}) target_link_libraries(${BENCHMARK} event ${LIB_PLATFORM}) endforeach() endif() From 78da644f3d88a4770d10e5a55c1fda17085b716b Mon Sep 17 00:00:00 2001 From: Joakim Soderberg Date: Mon, 16 Dec 2013 11:35:31 +0100 Subject: [PATCH 11/38] Fix bench_cascade program on Windows. --- test/bench_cascade.c | 9 +++++++++ test/bench_http.c | 4 ++++ 2 files changed, 13 insertions(+) diff --git a/test/bench_cascade.c b/test/bench_cascade.c index 5bb155b1..d14af82b 100644 --- a/test/bench_cascade.c +++ b/test/bench_cascade.c @@ -146,6 +146,11 @@ main(int argc, char **argv) struct timeval *tv; int num_pipes = 100; +#ifdef WIN32 + WSADATA WSAData; + WSAStartup(0x101, &WSAData); +#endif + while ((c = getopt(argc, argv, "n:")) != -1) { switch (c) { case 'n': @@ -175,5 +180,9 @@ main(int argc, char **argv) tv->tv_sec * 1000000L + tv->tv_usec); } +#ifdef WIN32 + WSACleanup(); +#endif + exit(0); } diff --git a/test/bench_http.c b/test/bench_http.c index 09f521b5..c031f70f 100644 --- a/test/bench_http.c +++ b/test/bench_http.c @@ -184,6 +184,10 @@ main(int argc, char **argv) } event_base_dispatch(base); +#ifdef WIN32 + WSACleanup(); +#endif + /* NOTREACHED */ return (0); } From 8f2af50f385d1bf93af48d59960440e8ca48bf3a Mon Sep 17 00:00:00 2001 From: Joakim Soderberg Date: Mon, 16 Dec 2013 13:45:45 +0100 Subject: [PATCH 12/38] Don't segfault on no found event backend. --- test/test-changelist.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/test-changelist.c b/test/test-changelist.c index 206eb601..6e2466d5 100644 --- a/test/test-changelist.c +++ b/test/test-changelist.c @@ -183,7 +183,8 @@ main(int argc, char **argv) return (1); /* Initalize the event library */ - base = event_base_new(); + if (!(base = event_base_new())) + return (1); /* Initalize a timeout to terminate the test */ timeout = evtimer_new(base,timeout_cb,&timeout); From 7ea4159d2924f7f1beb24e9d506cb88791b4ce36 Mon Sep 17 00:00:00 2001 From: Joakim Soderberg Date: Mon, 16 Dec 2013 16:37:51 +0100 Subject: [PATCH 13/38] Only test the event backends available on the system. Fix how the CMake project adds the tests using the different backends. At first we tried to do it exactly as it's done in test/test.sh. However, test.sh uses a special program test-init to decide if a given backend is available or not before running the actual tests. Doing it this way will not be possible using CMake. Since then we would have to have the test-init executable compiled at the time we run CMake, to know what tests we should add. (And since CMake generates the make/project files that compiles the executables, there's a catch 22). Instead of deciding what tests to run this way, we simply use the result of the CMake system introspection (that figures out what backends are available) to decide what backend tests to add. --- CMakeLists.txt | 61 +++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 50 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a3ced8a9..21528b35 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -745,35 +745,74 @@ if (NOT EVENT__DISABLE_TESTS) # We run all tests with the different backends turned on one at a time. # + # Add event backends based on system introspection result. + set(BACKENDS "") + + if (EVENT__HAVE_EPOLL) + list(APPEND BACKENDS EPOLL) + endif() + + if (EVENT__HAVE_SELECT) + list(APPEND BACKENDS SELECT) + endif() + + if (EVENT__HAVE_POLL) + list(APPEND BACKENDS POLL) + endif() + + if (EVENT__HAVE_KQUEUE) + list(APPEND BACKENDS KQUEUE) + endif() + + if (EVENT__HAVE_EVENT_PORTS) + list(APPEND BACKENDS EVPORT) + endif() + + if (EVENT__HAVE_DEVPOLL) + list(APPEND BACKENDS DEVPOLL) + endif() + + if (WIN32) + list(APPEND BACKENDS WIN32) + endif() + + message("Available event backends: ${BACKENDS}") + # Default environment variables turns off all event systems, # then we enable each one, one at a time when creating the tests. - set(BACKENDS EVPORT KQUEUE EPOLL DEVPOLL POLL SELECT WIN32) - set(DEFAULT_TEST_ENV_VARS "") + set(DEFAULT_TEST_ENV_VARS "EVENT_SHOW_METHOD=1;") foreach(BACKEND ${BACKENDS}) list(APPEND DEFAULT_TEST_ENV_VARS "EVENT_NO${BACKEND}=1") endforeach() # Macro that creates the ctest test for a backend. macro(add_backend_test BACKEND_TEST_NAME ENV_VARS) + set(TEST_NAMES "") + foreach (TESTPROG ${TESTPROGS}) - add_test(${TESTPROG}_${BACKEND_TEST_NAME} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${TESTPROG}) - set_tests_properties(${TESTPROG}_${BACKEND_TEST_NAME} PROPERTIES ENVIRONMENT "${ENV_VARS}") + set(TEST_NAME ${TESTPROG}_${BACKEND_TEST_NAME}) + add_test(${TEST_NAME} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${TESTPROG}) + list(APPEND TEST_NAMES ${TEST_NAME}) + set_tests_properties(${TEST_NAME} PROPERTIES ENVIRONMENT "${ENV_VARS}") endforeach() # Dump events test. if (PYTHONINTERP_FOUND) - add_test(test-dumpevents_${BACKEND_TEST_NAME} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/test-dumpevents | ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test/check-dumpevents.py) - set_tests_properties(test-dumpevents_${BACKEND_TEST_NAME} PROPERTIES ENVIRONMENT "${ENV_VARS}") + set(TEST_NAME test-dumpevents_${BACKEND_TEST_NAME}) + add_test(${TEST_NAME} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/test-dumpevents | ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test/check-dumpevents.py) + set_tests_properties(${TEST_NAME} PROPERTIES ENVIRONMENT "${ENV_VARS}") else() message(WARNING "test-dumpevents will be run without output check since python was not found!") - add_test(test-dumpevents_${BACKEND_TEST_NAME}_no_check ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/test-dumpevents) - set_tests_properties(test-dumpevents_${BACKEND_TEST_NAME}_no_check PROPERTIES ENVIRONMENT "${ENV_VARS}") + set(TEST_NAME test-dumpevents_${BACKEND_TEST_NAME}_no_check) + add_test(${TEST_NAME} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/test-dumpevents) + set_tests_properties(${TEST_NAME} PROPERTIES ENVIRONMENT "${ENV_VARS}") endif() # Regress tests. if (NOT EVENT__DISABLE_REGRESS AND PYTHONINTERP_FOUND) - add_test(regress_${BACKEND_TEST_NAME} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/regress) - set_tests_properties(regress_${BACKEND_TEST_NAME} PROPERTIES ENVIRONMENT "${ENV_VARS}") + set(TEST_NAME regress_${BACKEND_TEST_NAME}) + add_test(${TEST_NAME} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/regress) + set_tests_properties(${TEST_NAME} PROPERTIES ENVIRONMENT "${ENV_VARS}") endif() endmacro() @@ -789,7 +828,7 @@ if (NOT EVENT__DISABLE_TESTS) add_backend_test(changelist_${BACKEND} "${BACKEND_ENV_VARS};EVENT_EPOLL_USE_CHANGELIST=yes") add_backend_test(timerfd_changelist_${BACKEND} "${BACKEND_ENV_VARS};EVENT_EPOLL_USE_CHANGELIST=yes;EVENT_PRECISE_TIMER=1") else() - add_backend_test(${BACKEND} ${BACKEND_ENV_VARS}) + add_backend_test(${BACKEND} "${BACKEND_ENV_VARS}") endif() endforeach() From e053c4f029982778bcdee1b220c335419872ac25 Mon Sep 17 00:00:00 2001 From: Joakim Soderberg Date: Mon, 16 Dec 2013 16:44:13 +0000 Subject: [PATCH 14/38] Added a "make verify" target. This is more than for cosmetic purposes to match how it's done with autoconf. Due to the fact that we use environment variables to turn off certain backends during the tests, simply running "ctest" or "make test" can result in failed tests. This is because if you do "EVENT_NOEPOLL=yes && export EVENT_NOEPOLL" and then run the tests, when running the epoll tests, the EPOLL backend will be turned off. There is no way of unsetting an environment variable for a test in CMake, you can only set them. And since libevent simply checks if the environment variable is set (it doesn't check the actual value of it), this won't work. So to remedy this, we create the "make verify" target that first unsets all the EVENT_NO* environment variables, and then runs ctest. Also bumped the required CMake version from 2.6 to 2.8, since the set_test_properties(bla PROPERTIES ENVIRONMENT "SOME_VAR") requires 2.8 Added some explicit dependencies for the test programs to libevent, so they don't just fail if you try to run the tests without first doing "make" --- CMakeLists.txt | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 21528b35..e513e83a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,7 +16,7 @@ # cmake -G "Visual Studio 10" .. # start libevent.sln # -cmake_minimum_required(VERSION 2.6.0 FATAL_ERROR) +cmake_minimum_required(VERSION 2.8.0 FATAL_ERROR) # get rid of the extra default configurations set(CMAKE_CONFIGURATION_TYPES "Debug;Release" CACHE STRING "Limited configurations" FORCE) @@ -639,11 +639,13 @@ if (NOT EVENT__DISABLE_SAMPLES) sample/openssl_hostname_validation.c sample/hostcheck.c) target_link_libraries(https-client event ${LIB_APPS} ${LIB_PLATFORM}) + add_dependencies(https-client event) endif() foreach(SAMPLE ${SAMPLES}) add_executable(${SAMPLE} sample/${SAMPLE}.c) target_link_libraries(${SAMPLE} event ${LIB_APPS} ${LIB_PLATFORM}) + add_dependencies(${SAMPLE} event) endforeach() endif() @@ -657,6 +659,7 @@ if (NOT EVENT__DISABLE_BENCHMARK) add_executable(${BENCHMARK} ${BENCH_SRC}) target_link_libraries(${BENCHMARK} event ${LIB_PLATFORM}) + add_dependencies(${BENCHMARK} event) endforeach() endif() @@ -721,6 +724,7 @@ if (NOT EVENT__DISABLE_TESTS) add_executable(regress ${SRC_REGRESS}) target_link_libraries(regress event ${LIB_APPS} ${LIB_PLATFORM}) + add_dependencies(regress event) else() message(WARNING "Python not found, cannot generate regress tests!") endif() @@ -739,6 +743,7 @@ if (NOT EVENT__DISABLE_TESTS) foreach (TESTPROG ${TESTPROGS} test-dumpevents test-ratelim) add_executable(${TESTPROG} test/${TESTPROG}.c) target_link_libraries(${TESTPROG} event ${LIB_PLATFORM}) + add_dependencies(${TESTPROG} event) endforeach() # @@ -782,7 +787,8 @@ if (NOT EVENT__DISABLE_TESTS) # then we enable each one, one at a time when creating the tests. set(DEFAULT_TEST_ENV_VARS "EVENT_SHOW_METHOD=1;") foreach(BACKEND ${BACKENDS}) - list(APPEND DEFAULT_TEST_ENV_VARS "EVENT_NO${BACKEND}=1") + set(BACKEND_ENV_VAR "EVENT_NO${BACKEND}=1") + list(APPEND DEFAULT_TEST_ENV_VARS "${BACKEND_ENV_VAR}") endforeach() # Macro that creates the ctest test for a backend. @@ -790,7 +796,7 @@ if (NOT EVENT__DISABLE_TESTS) set(TEST_NAMES "") foreach (TESTPROG ${TESTPROGS}) - set(TEST_NAME ${TESTPROG}_${BACKEND_TEST_NAME}) + set(TEST_NAME ${TESTPROG}__${BACKEND_TEST_NAME}) add_test(${TEST_NAME} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${TESTPROG}) list(APPEND TEST_NAMES ${TEST_NAME}) set_tests_properties(${TEST_NAME} PROPERTIES ENVIRONMENT "${ENV_VARS}") @@ -798,19 +804,19 @@ if (NOT EVENT__DISABLE_TESTS) # Dump events test. if (PYTHONINTERP_FOUND) - set(TEST_NAME test-dumpevents_${BACKEND_TEST_NAME}) + set(TEST_NAME test-dumpevents__${BACKEND_TEST_NAME}) add_test(${TEST_NAME} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/test-dumpevents | ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test/check-dumpevents.py) set_tests_properties(${TEST_NAME} PROPERTIES ENVIRONMENT "${ENV_VARS}") else() message(WARNING "test-dumpevents will be run without output check since python was not found!") - set(TEST_NAME test-dumpevents_${BACKEND_TEST_NAME}_no_check) + set(TEST_NAME test-dumpevents__${BACKEND_TEST_NAME}_no_check) add_test(${TEST_NAME} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/test-dumpevents) set_tests_properties(${TEST_NAME} PROPERTIES ENVIRONMENT "${ENV_VARS}") endif() # Regress tests. if (NOT EVENT__DISABLE_REGRESS AND PYTHONINTERP_FOUND) - set(TEST_NAME regress_${BACKEND_TEST_NAME}) + set(TEST_NAME regress__${BACKEND_TEST_NAME}) add_test(${TEST_NAME} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/regress) set_tests_properties(${TEST_NAME} PROPERTIES ENVIRONMENT "${ENV_VARS}") endif() @@ -848,6 +854,16 @@ if (NOT EVENT__DISABLE_TESTS) # Connection limit and group limit with independent drain. add_test(test-ratelim_group_con_lim_drain ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/test-ratelim -c 1000 -g 35000 -n 30 -t 100 -G 500 --check-grouplimit 1000 --check-connlimit 50 --check-stddev 50) + # Add a "make verify" target, same as for autoconf. + # (Important! This will unset all EVENT_NO* environment variables. + # If they are set in the shell the tests are running using simply "ctest" or "make test" will fail) + add_custom_target(verify COMMAND unset EVENT_NOEPOLL && unset EVENT_NOPOLL && unset EVENT_NOSELECT && unset EVENT_NOWIN32 && unset EVENT_NOEVPORT && unset EVENT_NOKQUEUE && unset EVENT_NODEVPOLL && ${CMAKE_CTEST_COMMAND} + DEPENDS event ${TESTPROGS}) + + if (NOT EVENT__DISABLE_REGRESS) + add_dependencies(verify regress) + endif() + enable_testing() include(CTest) From 67e5d749836a3aea6ec5317c11f0a385ae4d9b85 Mon Sep 17 00:00:00 2001 From: Joakim Soderberg Date: Mon, 16 Dec 2013 18:10:32 +0100 Subject: [PATCH 15/38] Fix the make "verify" target on Windows. Windows does not have the "unset" command, but this doesn't matter since the problem that requires us to use unset doesn't happen on Windows. Also did some minor cosmetic changes, and dependcy changes. --- CMakeLists.txt | 56 ++++++++++++++++++++++++++++---------------------- 1 file changed, 32 insertions(+), 24 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e513e83a..5fb31b13 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -157,7 +157,7 @@ CHECK_INCLUDE_FILE(sys/sendfile.h EVENT__HAVE_SYS_SENDFILE_H) CHECK_INCLUDE_FILE(sys/stat.h EVENT__HAVE_SYS_STAT_H) CHECK_INCLUDE_FILE(sys/time.h EVENT__HAVE_SYS_TIME_H) if(EVENT__HAVE_SYS_TIME_H) - list(APPEND CMAKE_EXTRA_INCLUDE_FILES sys/time.h) + list(APPEND CMAKE_EXTRA_INCLUDE_FILES sys/time.h) endif() CHECK_INCLUDE_FILE(sys/uio.h EVENT__HAVE_SYS_UIO_H) CHECK_INCLUDE_FILES("sys/types.h;ifaddrs.h" EVENT__HAVE_IFADDRS_H) @@ -249,7 +249,7 @@ if(HAVE_PORT_H AND HAVE_PORT_CREATE) endif() if(NOT WIN32) - CHECK_FUNCTION_EXISTS_EX(select EVENT__HAVE_SELECT) + CHECK_FUNCTION_EXISTS_EX(select EVENT__HAVE_SELECT) endif() CHECK_TYPE_SIZE("uint8_t" EVENT__HAVE_UINT8_T) @@ -264,10 +264,10 @@ CHECK_TYPE_SIZE("long" EVENT__SIZEOF_LONG BUILTIN_TYPES_ONLY) CHECK_TYPE_SIZE("long long" EVENT__SIZEOF_LONG_LONG BUILTIN_TYPES_ONLY) if(WIN32) - # These aren't available until Windows Vista. - # But you can still link them. They just won't be found when running the exe. - set(EVENT__HAVE_INET_NTOP 0) - set(EVENT__HAVE_INET_PTON 0) + # These aren't available until Windows Vista. + # But you can still link them. They just won't be found when running the exe. + set(EVENT__HAVE_INET_NTOP 0) + set(EVENT__HAVE_INET_PTON 0) endif() # Check for different inline keyword versions. @@ -372,11 +372,11 @@ CHECK_SYMBOL_EXISTS(_POSIX_1_SOURCE "stdio.h" EVENT___POSIX_1_SOURCE) CHECK_SYMBOL_EXISTS(_POSIX_SOURCE "stdio.h" EVENT___POSIX_SOURCE) if(EVENT__HAVE_NETDB_H) - list(APPEND CMAKE_EXTRA_INCLUDE_FILES netdb.h) - CHECK_TYPE_SIZE("struct addrinfo" EVENT__HAVE_STRUCT_ADDRINFO) + list(APPEND CMAKE_EXTRA_INCLUDE_FILES netdb.h) + CHECK_TYPE_SIZE("struct addrinfo" EVENT__HAVE_STRUCT_ADDRINFO) elseif(WIN32) - list(APPEND CMAKE_EXTRA_INCLUDE_FILES ws2tcpip.h) - CHECK_TYPE_SIZE("struct addrinfo" EVENT__HAVE_STRUCT_ADDRINFO) + list(APPEND CMAKE_EXTRA_INCLUDE_FILES ws2tcpip.h) + CHECK_TYPE_SIZE("struct addrinfo" EVENT__HAVE_STRUCT_ADDRINFO) endif() # Check for sockaddr structure sizes. @@ -409,21 +409,21 @@ endif() CHECK_TYPE_SIZE("struct in6_addr" EVENT__HAVE_STRUCT_IN6_ADDR) if(EVENT__HAVE_STRUCT_IN6_ADDR) - CHECK_STRUCT_HAS_MEMBER("struct in6_addr" s6_addr16 "${SOCKADDR_HEADERS}" EVENT__HAVE_STRUCT_IN6_ADDR_S6_ADDR16) - CHECK_STRUCT_HAS_MEMBER("struct in6_addr" s6_addr32 "${SOCKADDR_HEADERS}" EVENT__HAVE_STRUCT_IN6_ADDR_S6_ADDR32) + CHECK_STRUCT_HAS_MEMBER("struct in6_addr" s6_addr16 "${SOCKADDR_HEADERS}" EVENT__HAVE_STRUCT_IN6_ADDR_S6_ADDR16) + CHECK_STRUCT_HAS_MEMBER("struct in6_addr" s6_addr32 "${SOCKADDR_HEADERS}" EVENT__HAVE_STRUCT_IN6_ADDR_S6_ADDR32) endif() CHECK_TYPE_SIZE("sa_family_t" EVENT__HAVE_SA_FAMILY_T) CHECK_TYPE_SIZE("struct sockaddr_in6" EVENT__HAVE_STRUCT_SOCKADDR_IN6) if(EVENT__HAVE_STRUCT_SOCKADDR_IN6) - CHECK_STRUCT_HAS_MEMBER("struct sockaddr_in6" sin6_len "${SOCKADDR_HEADERS}" EVENT__HAVE_STRUCT_SOCKADDR_IN6_SIN6_LEN) - CHECK_STRUCT_HAS_MEMBER("struct sockaddr_in6" sin_len "${SOCKADDR_HEADERS}" EVENT__HAVE_STRUCT_SOCKADDR_IN_SIN_LEN) + CHECK_STRUCT_HAS_MEMBER("struct sockaddr_in6" sin6_len "${SOCKADDR_HEADERS}" EVENT__HAVE_STRUCT_SOCKADDR_IN6_SIN6_LEN) + CHECK_STRUCT_HAS_MEMBER("struct sockaddr_in6" sin_len "${SOCKADDR_HEADERS}" EVENT__HAVE_STRUCT_SOCKADDR_IN_SIN_LEN) endif() CHECK_TYPE_SIZE("struct sockaddr_storage" EVENT__HAVE_STRUCT_SOCKADDR_STORAGE) if(EVENT__HAVE_STRUCT_SOCKADDR_STORAGE) - CHECK_STRUCT_HAS_MEMBER("struct sockaddr_storage" ss_family "${SOCKADDR_HEADERS}" EVENT__HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY) - CHECK_STRUCT_HAS_MEMBER("struct sockaddr_storage" __ss_family "${SOCKADDR_HEADERS}" EVENT__HAVE_STRUCT_SOCKADDR_STORAGE___SS_FAMILY) + CHECK_STRUCT_HAS_MEMBER("struct sockaddr_storage" ss_family "${SOCKADDR_HEADERS}" EVENT__HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY) + CHECK_STRUCT_HAS_MEMBER("struct sockaddr_storage" __ss_family "${SOCKADDR_HEADERS}" EVENT__HAVE_STRUCT_SOCKADDR_STORAGE___SS_FAMILY) endif() # Group the source files. @@ -493,7 +493,7 @@ set(SRC_CORE evthread.c evutil.c evutil_rand.c - evutil_time.c + evutil_time.c listener.c log.c signal.c @@ -739,8 +739,10 @@ if (NOT EVENT__DISABLE_TESTS) test-time test-weof) + set(ALL_TESTPROGS ${TESTPROGS} test-dumpevents test-ratelim) + # Create test program executables. - foreach (TESTPROG ${TESTPROGS} test-dumpevents test-ratelim) + foreach (TESTPROG ${ALL_TESTPROGS}) add_executable(${TESTPROG} test/${TESTPROG}.c) target_link_libraries(${TESTPROG} event ${LIB_PLATFORM}) add_dependencies(${TESTPROG} event) @@ -843,22 +845,28 @@ if (NOT EVENT__DISABLE_TESTS) # # Group limits, no connection limit. - add_test(test-ratelim_group_lim ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/test-ratelim -g 30000 -n 30 -t 100 --check-grouplimit 1000 --check-stddev 100) + add_test(test-ratelim__group_lim ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/test-ratelim -g 30000 -n 30 -t 100 --check-grouplimit 1000 --check-stddev 100) # Connection limit, no group limit. - add_test(test-ratelim_con_lim ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/test-ratelim -c 1000 -n 30 -t 100 --check-connlimit 50 --check-stddev 50) + add_test(test-ratelim__con_lim ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/test-ratelim -c 1000 -n 30 -t 100 --check-connlimit 50 --check-stddev 50) # Connection limit and group limit. - add_test(test-ratelim_group_con_lim ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/test-ratelim -c 1000 -g 30000 -n 30 -t 100 --check-grouplimit 1000 --check-connlimit 50 --check-stddev 50) + add_test(test-ratelim__group_con_lim ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/test-ratelim -c 1000 -g 30000 -n 30 -t 100 --check-grouplimit 1000 --check-connlimit 50 --check-stddev 50) # Connection limit and group limit with independent drain. - add_test(test-ratelim_group_con_lim_drain ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/test-ratelim -c 1000 -g 35000 -n 30 -t 100 -G 500 --check-grouplimit 1000 --check-connlimit 50 --check-stddev 50) + add_test(test-ratelim__group_con_lim_drain ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/test-ratelim -c 1000 -g 35000 -n 30 -t 100 -G 500 --check-grouplimit 1000 --check-connlimit 50 --check-stddev 50) # Add a "make verify" target, same as for autoconf. # (Important! This will unset all EVENT_NO* environment variables. # If they are set in the shell the tests are running using simply "ctest" or "make test" will fail) - add_custom_target(verify COMMAND unset EVENT_NOEPOLL && unset EVENT_NOPOLL && unset EVENT_NOSELECT && unset EVENT_NOWIN32 && unset EVENT_NOEVPORT && unset EVENT_NOKQUEUE && unset EVENT_NODEVPOLL && ${CMAKE_CTEST_COMMAND} - DEPENDS event ${TESTPROGS}) + if (WIN32) + # Windows doesn't have "unset", and the above does not happen anyway. + add_custom_target(verify COMMAND ${CMAKE_CTEST_COMMAND} + DEPENDS event ${ALL_TESTPROGS}) + else() + add_custom_target(verify COMMAND unset EVENT_NOEPOLL && unset EVENT_NOPOLL && unset EVENT_NOSELECT && unset EVENT_NOWIN32 && unset EVENT_NOEVPORT && unset EVENT_NOKQUEUE && unset EVENT_NODEVPOLL && ${CMAKE_CTEST_COMMAND} + DEPENDS event ${ALL_TESTPROGS}) + endif() if (NOT EVENT__DISABLE_REGRESS) add_dependencies(verify regress) From 69c3516be62bf2ce7e31dcf0af2d40ac4f172f7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20S=C3=B6derberg?= Date: Tue, 17 Dec 2013 13:28:23 +0100 Subject: [PATCH 16/38] Get rid of deprecation warnings for OpenSSL on OSX 10.7+ --- CMakeLists.txt | 5 +++++ bufferevent_openssl.c | 3 +++ sample/https-client.c | 3 +++ sample/le-proxy.c | 3 +++ sample/openssl_hostname_validation.c | 2 ++ test/regress_ssl.c | 3 +++ 6 files changed, 19 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5fb31b13..178d9ba2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -88,6 +88,11 @@ if (CMAKE_COMPILER_IS_GNUCC) endif() endif() +if (APPLE) + # Get rid of deprecated warnings for OpenSSL on OSX 10.7 and greater. + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-error=deprecated-declarations") +endif() + # Winsock. if(WIN32) set(CMAKE_EXTRA_INCLUDE_FILES winsock2.h ws2tcpip.h) diff --git a/bufferevent_openssl.c b/bufferevent_openssl.c index 1ce124f9..89fc7eaa 100644 --- a/bufferevent_openssl.c +++ b/bufferevent_openssl.c @@ -24,6 +24,9 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +// Get rid of OSX 10.7 and greater deprecation warnings. +#pragma clang diagnostic ignored "-Wdeprecated-declarations" + #include "event2/event-config.h" #include "evconfig-private.h" diff --git a/sample/https-client.c b/sample/https-client.c index 831576f3..165c5e69 100644 --- a/sample/https-client.c +++ b/sample/https-client.c @@ -10,6 +10,9 @@ Loosely based on le-proxy.c. */ +// Get rid of OSX 10.7 and greater deprecation warnings. +#pragma clang diagnostic ignored "-Wdeprecated-declarations" + #include #include #include diff --git a/sample/le-proxy.c b/sample/le-proxy.c index afacd33f..a348bdb6 100644 --- a/sample/le-proxy.c +++ b/sample/le-proxy.c @@ -5,6 +5,9 @@ XXX It's a little ugly and should probably be cleaned up. */ +// Get rid of OSX 10.7 and greater deprecation warnings. +#pragma clang diagnostic ignored "-Wdeprecated-declarations" + #include #include #include diff --git a/sample/openssl_hostname_validation.c b/sample/openssl_hostname_validation.c index f2cd8564..1c95373d 100644 --- a/sample/openssl_hostname_validation.c +++ b/sample/openssl_hostname_validation.c @@ -34,6 +34,8 @@ SOFTWARE. * */ +// Get rid of OSX 10.7 and greater deprecation warnings. +#pragma clang diagnostic ignored "-Wdeprecated-declarations" #include #include diff --git a/test/regress_ssl.c b/test/regress_ssl.c index acf2bd67..60fe9639 100644 --- a/test/regress_ssl.c +++ b/test/regress_ssl.c @@ -24,6 +24,9 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +// Get rid of OSX 10.7 and greater deprecation warnings. +#pragma clang diagnostic ignored "-Wdeprecated-declarations" + #ifdef _WIN32 #include #include From a831f2f7decbbb89518790c023b4cf019f8ce6a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20S=C3=B6derberg?= Date: Tue, 17 Dec 2013 13:29:04 +0100 Subject: [PATCH 17/38] Fix kqueue support. --- CMakeLists.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 178d9ba2..00cac54e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -371,6 +371,9 @@ CHECK_FILE_OFFSET_BITS() set(EVENT___FILE_OFFSET_BITS _FILE_OFFSET_BITS) # TODO: Check EVENT__HAVE_WORKING_KQUEUE (Define if kqueue works correctly with pipes) +if (EVENT__HAVE_KQUEUE) + set(EVENT__HAVE_WORKING_KQUEUE 1) +endif() CHECK_SYMBOL_EXISTS(_MINIX "stdio.h" EVENT___MINIX) CHECK_SYMBOL_EXISTS(_POSIX_1_SOURCE "stdio.h" EVENT___POSIX_1_SOURCE) From 2799b359d3fa0c8d57ec4095e09ee701c5771e05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20S=C3=B6derberg?= Date: Tue, 17 Dec 2013 14:01:21 +0100 Subject: [PATCH 18/38] Added a test for testing if kqueue works with pipes. --- CMakeLists.txt | 11 +++++-- cmake/CheckWorkingKqueue.cmake | 52 ++++++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+), 2 deletions(-) create mode 100644 cmake/CheckWorkingKqueue.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 00cac54e..ea26e833 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -35,6 +35,7 @@ option(EVENT__DISABLE_OPENSSL "Define if libevent should build without support f option(EVENT__DISABLE_BENCHMARK "Defines if libevent should build without the benchmark exectuables" OFF) option(EVENT__DISABLE_TESTS "If tests should be compiled or not" OFF) option(EVENT__DISABLE_REGRESS "Disable the regress tests" OFF) +option(EVENT__FORCE_KQUEUE_CHECK "When crosscompiling forces running a test program that verifies that Kqueue works with pipes. Note that this requires you to manually run the test program on the the cross compilation target to verify that it works. See cmake documentation for try_run for more details" OFF) # TODO: Add --enable-verbose-debug, verbose debug logging # TODO: Add --disable-largefile omit support for large files @@ -370,9 +371,15 @@ CHECK_TYPE_SIZE("void *" EVENT__SIZEOF_VOID_P) CHECK_FILE_OFFSET_BITS() set(EVENT___FILE_OFFSET_BITS _FILE_OFFSET_BITS) -# TODO: Check EVENT__HAVE_WORKING_KQUEUE (Define if kqueue works correctly with pipes) +# Verify kqueue works with pipes. if (EVENT__HAVE_KQUEUE) - set(EVENT__HAVE_WORKING_KQUEUE 1) + if (CMAKE_CROSSCOMPILING AND NOT EVENT__FORCE_KQUEUE_CHECK) + message(WARNING "Cannot check if kqueue works with pipes when crosscompiling, use EVENT__FORCE_KQUEUE_CHECK to be sure (this requires manually running a test program on the cross compilation target)") + set(EVENT__HAVE_WORKING_KQUEUE 1) + else() + message("Checking if kqueue works with pipes...") + include(CheckWorkingKqueue) + endif() endif() CHECK_SYMBOL_EXISTS(_MINIX "stdio.h" EVENT___MINIX) diff --git a/cmake/CheckWorkingKqueue.cmake b/cmake/CheckWorkingKqueue.cmake new file mode 100644 index 00000000..47bf4e83 --- /dev/null +++ b/cmake/CheckWorkingKqueue.cmake @@ -0,0 +1,52 @@ +include(CheckCSourceRuns) + +check_c_source_runs( +" +#include +#include +#include +#include +#include +#include + +int +main(int argc, char **argv) +{ + int kq; + int n; + int fd[2]; + struct kevent ev; + struct timespec ts; + char buf[8000]; + + if (pipe(fd) == -1) + exit(1); + if (fcntl(fd[1], F_SETFL, O_NONBLOCK) == -1) + exit(1); + + while ((n = write(fd[1], buf, sizeof(buf))) == sizeof(buf)) + ; + + if ((kq = kqueue()) == -1) + exit(1); + + memset(&ev, 0, sizeof(ev)); + ev.ident = fd[1]; + ev.filter = EVFILT_WRITE; + ev.flags = EV_ADD | EV_ENABLE; + n = kevent(kq, &ev, 1, NULL, 0, NULL); + if (n == -1) + exit(1); + + read(fd[0], buf, sizeof(buf)); + + ts.tv_sec = 0; + ts.tv_nsec = 0; + n = kevent(kq, NULL, 0, &ev, 1, &ts); + if (n == -1 || n == 0) + exit(1); + + exit(0); +} + +" EVENT__HAVE_WORKING_KQUEUE) \ No newline at end of file From 86df3edaa00dcb63945ce0ac52e0b01f2108da19 Mon Sep 17 00:00:00 2001 From: Joakim Soderberg Date: Tue, 17 Dec 2013 14:07:14 +0100 Subject: [PATCH 19/38] Change the BSD license from 4 to 3-clause. This makes it GPL compatible. Changing the license from 4 to 3-clause BSD license is OK according to a Berkley announcement on July 22, 1999 by William Hoskins, the director of the fofice of technology licensing for Berkley: ftp://ftp.cs.berkeley.edu/pub/4bsd/README.Impt.License.Change --- WIN32-Code/getopt.c | 34 +++++++++++++++------------------- WIN32-Code/getopt_long.c | 32 ++++++++++++++------------------ 2 files changed, 29 insertions(+), 37 deletions(-) diff --git a/WIN32-Code/getopt.c b/WIN32-Code/getopt.c index 3bb21f6f..0fcba5d9 100644 --- a/WIN32-Code/getopt.c +++ b/WIN32-Code/getopt.c @@ -1,7 +1,7 @@ /* $NetBSD: getopt.c,v 1.16 1999/12/02 13:15:56 kleink Exp $ */ /* - * Copyright (c) 1987, 1993, 1994 + * Copyright (c) 1987, 1993, 1994, 1995 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -12,25 +12,21 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. + * 3. Neither the names of the copyright holders nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS + * IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. */ #if 0 diff --git a/WIN32-Code/getopt_long.c b/WIN32-Code/getopt_long.c index 5bcf4006..8bbc2053 100644 --- a/WIN32-Code/getopt_long.c +++ b/WIN32-Code/getopt_long.c @@ -11,25 +11,21 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. + * 3. Neither the names of the copyright holders nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS + * IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. */ #include #include From 968e97bd4bab7d2232d031c121fb98c7068c7d6d Mon Sep 17 00:00:00 2001 From: Joakim Soderberg Date: Tue, 17 Dec 2013 14:31:22 +0100 Subject: [PATCH 20/38] Minimum required python version is 2.4. Got rid of TODO... The version you specify to find_package is the minimum version, so exactly what we want. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ea26e833..38ffb6ca 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -681,7 +681,7 @@ endif() if (NOT EVENT__DISABLE_TESTS) # (We require python to generate the regress tests) - find_package(PythonInterp 2) # TODO: Require 2.4+ here... + find_package(PythonInterp 2.4) # # Generate Regress tests. From 0ef1d04e446ac051d4a2957c29710f6e90709605 Mon Sep 17 00:00:00 2001 From: Joakim Soderberg Date: Tue, 17 Dec 2013 14:32:07 +0100 Subject: [PATCH 21/38] Get rid of unknown pragma warnings. --- bufferevent_openssl.c | 2 ++ sample/https-client.c | 2 ++ sample/le-proxy.c | 2 ++ sample/openssl_hostname_validation.c | 2 ++ test/regress_ssl.c | 2 ++ 5 files changed, 10 insertions(+) diff --git a/bufferevent_openssl.c b/bufferevent_openssl.c index 89fc7eaa..f44b8e5f 100644 --- a/bufferevent_openssl.c +++ b/bufferevent_openssl.c @@ -25,7 +25,9 @@ */ // Get rid of OSX 10.7 and greater deprecation warnings. +#ifdef __clang__ #pragma clang diagnostic ignored "-Wdeprecated-declarations" +#endif #include "event2/event-config.h" #include "evconfig-private.h" diff --git a/sample/https-client.c b/sample/https-client.c index 165c5e69..b40f92b9 100644 --- a/sample/https-client.c +++ b/sample/https-client.c @@ -11,7 +11,9 @@ */ // Get rid of OSX 10.7 and greater deprecation warnings. +#ifdef __clang__ #pragma clang diagnostic ignored "-Wdeprecated-declarations" +#endif #include #include diff --git a/sample/le-proxy.c b/sample/le-proxy.c index a348bdb6..0c918d7a 100644 --- a/sample/le-proxy.c +++ b/sample/le-proxy.c @@ -6,7 +6,9 @@ */ // Get rid of OSX 10.7 and greater deprecation warnings. +#ifdef __clang__ #pragma clang diagnostic ignored "-Wdeprecated-declarations" +#endif #include #include diff --git a/sample/openssl_hostname_validation.c b/sample/openssl_hostname_validation.c index 1c95373d..6ab94f51 100644 --- a/sample/openssl_hostname_validation.c +++ b/sample/openssl_hostname_validation.c @@ -35,7 +35,9 @@ SOFTWARE. */ // Get rid of OSX 10.7 and greater deprecation warnings. +#ifdef __clang__ #pragma clang diagnostic ignored "-Wdeprecated-declarations" +#endif #include #include diff --git a/test/regress_ssl.c b/test/regress_ssl.c index 60fe9639..e72b8dbf 100644 --- a/test/regress_ssl.c +++ b/test/regress_ssl.c @@ -25,7 +25,9 @@ */ // Get rid of OSX 10.7 and greater deprecation warnings. +#ifdef __clang__ #pragma clang diagnostic ignored "-Wdeprecated-declarations" +#endif #ifdef _WIN32 #include From f2483f8b3d781f052d2d38902c314a54645d21a4 Mon Sep 17 00:00:00 2001 From: Joakim Soderberg Date: Tue, 17 Dec 2013 15:17:29 +0000 Subject: [PATCH 22/38] Add a "make verify_coverage" target generation coverage info. Use lcov/gcov to gather coverage info for the tests (Only works with gcc/clang and make). cmake -DEVENT__COVERAGE=1 -DCMAKE_BUILD_TYPE=Debug .. make make verify_coverage Current coverage (run on debian): Line coverage 79.1 % 10231 / 12939 Function coverage 86.1 % 933 / 1083 --- CMakeLists.txt | 27 +++++++ cmake/CodeCoverage.cmake | 162 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 189 insertions(+) create mode 100644 cmake/CodeCoverage.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 38ffb6ca..aa35da6f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -36,6 +36,7 @@ option(EVENT__DISABLE_BENCHMARK "Defines if libevent should build without the be option(EVENT__DISABLE_TESTS "If tests should be compiled or not" OFF) option(EVENT__DISABLE_REGRESS "Disable the regress tests" OFF) option(EVENT__FORCE_KQUEUE_CHECK "When crosscompiling forces running a test program that verifies that Kqueue works with pipes. Note that this requires you to manually run the test program on the the cross compilation target to verify that it works. See cmake documentation for try_run for more details" OFF) +option(EVENT__COVERAGE "Enable running gcov to get a test coverage report (only works with GCC/CLang). Make sure to enable -DCMAKE_BUILD_TYPE=Debug as well." OFF) # TODO: Add --enable-verbose-debug, verbose debug logging # TODO: Add --disable-largefile omit support for large files @@ -60,6 +61,22 @@ include(CheckPrototypeDefinition) include(FindZLIB) # -> HAVE_LIBZ +# Setup compiler flags for coverage. +if (EVENT__COVERAGE) + if(NOT CMAKE_COMPILER_IS_GNUCXX) + if (NOT "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") + message(FATAL_ERROR "Compiler is not GNU gcc! Aborting... You can set this on the command line using CC=/usr/bin/gcc CXX=/usr/bin/g++ cmake ..") + endif() + endif() + + if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug") + message(FATAL_ERROR "Code coverage results with an optimised (non-Debug) build may be misleading! Add -DCMAKE_BUILD_TYPE=Debug") + endif() + + message("Setting coverage compiler flags") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -O0 -fprofile-arcs -ftest-coverage") +endif() + if (CMAKE_COMPILER_IS_GNUCC) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall") @@ -887,6 +904,16 @@ if (NOT EVENT__DISABLE_TESTS) add_dependencies(verify regress) endif() + if (EVENT__COVERAGE) + include(CodeCoverage) + + setup_target_for_coverage( + verify_coverage # Coverage target name "make verify_coverage" + make # Test runner. + coverage # Output directory. + verify) # Arguments passed to test runner. "make verify" + endif() + enable_testing() include(CTest) diff --git a/cmake/CodeCoverage.cmake b/cmake/CodeCoverage.cmake new file mode 100644 index 00000000..2afefa1d --- /dev/null +++ b/cmake/CodeCoverage.cmake @@ -0,0 +1,162 @@ +# +# Boost Software License - Version 1.0 - August 17th, 2003 +# +# Permission is hereby granted, free of charge, to any person or organization +# obtaining a copy of the software and accompanying documentation covered by +# this license (the "Software") to use, reproduce, display, distribute, +# execute, and transmit the Software, and to prepare derivative works of the +# Software, and to permit third-parties to whom the Software is furnished to +# do so, all subject to the following: +# +# The copyright notices in the Software and this entire statement, including +# the above license grant, this restriction and the following disclaimer, +# must be included in all copies of the Software, in whole or in part, and +# all derivative works of the Software, unless such copies or derivative +# works are solely in the form of machine-executable object code generated by +# a source language processor. +# +# 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, TITLE AND NON-INFRINGEMENT. IN NO EVENT +# SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE +# FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, +# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +# DEALINGS IN THE SOFTWARE. +# +# 2012-01-31, Lars Bilke +# - Enable Code Coverage +# +# 2013-09-17, Joakim Söderberg +# - Added support for Clang. +# - Some additional usage instructions. +# +# USAGE: +# 1. Copy this file into your cmake modules path. +# +# 2. Add the following line to your CMakeLists.txt: +# INCLUDE(CodeCoverage) +# +# 3. Set compiler flags to turn off optimization and enable coverage: +# SET(CMAKE_CXX_FLAGS "-g -O0 -fprofile-arcs -ftest-coverage") +# SET(CMAKE_C_FLAGS "-g -O0 -fprofile-arcs -ftest-coverage") +# +# 3. Use the function SETUP_TARGET_FOR_COVERAGE to create a custom make target +# which runs your test executable and produces a lcov code coverage report: +# Example: +# SETUP_TARGET_FOR_COVERAGE( +# my_coverage_target # Name for custom target. +# test_driver # Name of the test driver executable that runs the tests. +# # NOTE! This should always have a ZERO as exit code +# # otherwise the coverage generation will not complete. +# coverage # Name of output directory. +# ) +# +# 4. Build a Debug build: +# cmake -DCMAKE_BUILD_TYPE=Debug .. +# make +# make my_coverage_target +# +# + +# Check prereqs +FIND_PROGRAM( GCOV_PATH gcov ) +FIND_PROGRAM( LCOV_PATH lcov ) +FIND_PROGRAM( GENHTML_PATH genhtml ) +FIND_PROGRAM( GCOVR_PATH gcovr PATHS ${CMAKE_SOURCE_DIR}/tests) + +IF(NOT GCOV_PATH) + MESSAGE(FATAL_ERROR "gcov not found! Aborting...") +ENDIF() # NOT GCOV_PATH + +IF(NOT CMAKE_COMPILER_IS_GNUCXX) + # Clang version 3.0.0 and greater now supports gcov as well. + MESSAGE(WARNING "Compiler is not GNU gcc! Clang Version 3.0.0 and greater supports gcov as well, but older versions don't.") + + IF(NOT "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") + MESSAGE(FATAL_ERROR "Compiler is not GNU gcc! Aborting...") + ENDIF() +ENDIF() # NOT CMAKE_COMPILER_IS_GNUCXX + +IF ( NOT CMAKE_BUILD_TYPE STREQUAL "Debug" ) + MESSAGE( WARNING "Code coverage results with an optimized (non-Debug) build may be misleading" ) +ENDIF() # NOT CMAKE_BUILD_TYPE STREQUAL "Debug" + + +# Param _targetname The name of new the custom make target +# Param _testrunner The name of the target which runs the tests. +# MUST return ZERO always, even on errors. +# If not, no coverage report will be created! +# Param _outputname lcov output is generated as _outputname.info +# HTML report is generated in _outputname/index.html +# Optional fourth parameter is passed as arguments to _testrunner +# Pass them in list form, e.g.: "-j;2" for -j 2 +FUNCTION(SETUP_TARGET_FOR_COVERAGE _targetname _testrunner _outputname) + + IF(NOT LCOV_PATH) + MESSAGE(FATAL_ERROR "lcov not found! Aborting...") + ENDIF() # NOT LCOV_PATH + + IF(NOT GENHTML_PATH) + MESSAGE(FATAL_ERROR "genhtml not found! Aborting...") + ENDIF() # NOT GENHTML_PATH + + # Setup target + ADD_CUSTOM_TARGET(${_targetname} + + # Cleanup lcov + ${LCOV_PATH} --directory . --zerocounters + + # Run tests + COMMAND ${_testrunner} ${ARGV3} + + # Capturing lcov counters and generating report + COMMAND ${LCOV_PATH} --directory . --capture --output-file ${_outputname}.info + COMMAND ${LCOV_PATH} --remove ${_outputname}.info 'tests/*' '/usr/*' --output-file ${_outputname}.info.cleaned + COMMAND ${GENHTML_PATH} -o ${_outputname} ${_outputname}.info.cleaned + COMMAND ${CMAKE_COMMAND} -E remove ${_outputname}.info ${_outputname}.info.cleaned + + WORKING_DIRECTORY ${CMAKE_BINARY_DIR} + COMMENT "Resetting code coverage counters to zero.\nProcessing code coverage counters and generating report." + ) + + # Show info where to find the report + ADD_CUSTOM_COMMAND(TARGET ${_targetname} POST_BUILD + COMMAND ; + COMMENT "Open ./${_outputname}/index.html in your browser to view the coverage report." + ) + +ENDFUNCTION() # SETUP_TARGET_FOR_COVERAGE + +# Param _targetname The name of new the custom make target +# Param _testrunner The name of the target which runs the tests +# Param _outputname cobertura output is generated as _outputname.xml +# Optional fourth parameter is passed as arguments to _testrunner +# Pass them in list form, e.g.: "-j;2" for -j 2 +FUNCTION(SETUP_TARGET_FOR_COVERAGE_COBERTURA _targetname _testrunner _outputname) + + IF(NOT PYTHON_EXECUTABLE) + MESSAGE(FATAL_ERROR "Python not found! Aborting...") + ENDIF() # NOT PYTHON_EXECUTABLE + + IF(NOT GCOVR_PATH) + MESSAGE(FATAL_ERROR "gcovr not found! Aborting...") + ENDIF() # NOT GCOVR_PATH + + ADD_CUSTOM_TARGET(${_targetname} + + # Run tests + ${_testrunner} ${ARGV3} + + # Running gcovr + COMMAND ${GCOVR_PATH} -x -r ${CMAKE_SOURCE_DIR} -e '${CMAKE_SOURCE_DIR}/tests/' -o ${_outputname}.xml + WORKING_DIRECTORY ${CMAKE_BINARY_DIR} + COMMENT "Running gcovr to produce Cobertura code coverage report." + ) + + # Show info where to find the report + ADD_CUSTOM_COMMAND(TARGET ${_targetname} POST_BUILD + COMMAND ; + COMMENT "Cobertura code coverage report saved in ${_outputname}.xml." + ) + +ENDFUNCTION() # SETUP_TARGET_FOR_COVERAGE_COBERTURA From 4ac086abc41323a2de4393753368e0f6e4625268 Mon Sep 17 00:00:00 2001 From: Joakim Soderberg Date: Thu, 19 Dec 2013 10:54:52 +0100 Subject: [PATCH 23/38] Fix the "make verify" target on NetBSD --- CMakeLists.txt | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index aa35da6f..520c241f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,7 +21,7 @@ cmake_minimum_required(VERSION 2.8.0 FATAL_ERROR) # get rid of the extra default configurations set(CMAKE_CONFIGURATION_TYPES "Debug;Release" CACHE STRING "Limited configurations" FORCE) -project(libevent) +project(libevent C) set(EVENT_NUMERIC_VERSION 0x02010401) set(EVENT_VERSION "2.1.4-beta") @@ -896,7 +896,23 @@ if (NOT EVENT__DISABLE_TESTS) add_custom_target(verify COMMAND ${CMAKE_CTEST_COMMAND} DEPENDS event ${ALL_TESTPROGS}) else() - add_custom_target(verify COMMAND unset EVENT_NOEPOLL && unset EVENT_NOPOLL && unset EVENT_NOSELECT && unset EVENT_NOWIN32 && unset EVENT_NOEVPORT && unset EVENT_NOKQUEUE && unset EVENT_NODEVPOLL && ${CMAKE_CTEST_COMMAND} + # On some platforms doing exec(unset) as CMake does won't work, so make sure + # we run the unset command in a shell instead. + # First we write the script contents. + file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/tmp/verify_tests.sh + " + #!/bin/bash + unset EVENT_NOEPOLL; unset EVENT_NOPOLL; unset EVENT_NOSELECT; unset EVENT_NOWIN32; unset EVENT_NOEVPORT; unset EVENT_NOKQUEUE; unset EVENT_NODEVPOLL + ${CMAKE_CTEST_COMMAND} + ") + + # Then we copy the file (this allows us to set execute permission on it) + file(COPY ${CMAKE_CURRENT_BINARY_DIR}/tmp/verify_tests.sh + DESTINATION ${CMAKE_CURRENT_BINARY_DIR} + FILE_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) + + # Create the target that runs the script. + add_custom_target(verify COMMAND ${CMAKE_CURRENT_BINARY_DIR}/verify_tests.sh DEPENDS event ${ALL_TESTPROGS}) endif() From f7805939d161412e0c25cbddb71f9f329beb752b Mon Sep 17 00:00:00 2001 From: Joakim Soderberg Date: Thu, 19 Dec 2013 10:46:04 +0000 Subject: [PATCH 24/38] Only look for ZLib when it is used (if tests are included). Also make the project language C. --- CMakeLists.txt | 21 ++++++++++++--------- cmake/CodeCoverage.cmake | 4 ++-- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 520c241f..8cf39093 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -59,13 +59,11 @@ include(CheckStructHasMember) include(CheckCSourceCompiles) include(CheckPrototypeDefinition) -include(FindZLIB) # -> HAVE_LIBZ - # Setup compiler flags for coverage. if (EVENT__COVERAGE) - if(NOT CMAKE_COMPILER_IS_GNUCXX) + if(NOT CMAKE_COMPILER_IS_GNUCC) if (NOT "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") - message(FATAL_ERROR "Compiler is not GNU gcc! Aborting... You can set this on the command line using CC=/usr/bin/gcc CXX=/usr/bin/g++ cmake ..") + message(FATAL_ERROR "Trying to compile coverage support (--DEVENT__COVERAGE) but compiler is not GNU gcc! Aborting... You can set this on the command line using CC=/usr/bin/gcc CXX=/usr/bin/g++ cmake ..") endif() endif() @@ -581,11 +579,16 @@ if (NOT EVENT__DISABLE_THREAD_SUPPORT) endif() endif() -if (ZLIB_LIBRARY) - set(EVENT__HAVE_ZLIB 1) - set(EVENT__HAVE_ZLIB_H) - include_directories(${ZLIB_INCLUDE_DIRS}) - list(APPEND LIB_APPS ${ZLIB_LIBRARIES}) +if (NOT EVENT__DISABLE_TESTS) + # Zlib is only used for testing. + find_package(ZLIB) + + if (ZLIB_LIBRARY) + set(EVENT__HAVE_ZLIB 1) + set(EVENT__HAVE_ZLIB_H) + include_directories(${ZLIB_INCLUDE_DIRS}) + list(APPEND LIB_APPS ${ZLIB_LIBRARIES}) + endif() endif() set(SRC_EXTRA diff --git a/cmake/CodeCoverage.cmake b/cmake/CodeCoverage.cmake index 2afefa1d..969f2732 100644 --- a/cmake/CodeCoverage.cmake +++ b/cmake/CodeCoverage.cmake @@ -68,14 +68,14 @@ IF(NOT GCOV_PATH) MESSAGE(FATAL_ERROR "gcov not found! Aborting...") ENDIF() # NOT GCOV_PATH -IF(NOT CMAKE_COMPILER_IS_GNUCXX) +IF(NOT CMAKE_COMPILER_IS_GNUCC AND NOT CMAKE_COMPILER_IS_GNUCXX) # Clang version 3.0.0 and greater now supports gcov as well. MESSAGE(WARNING "Compiler is not GNU gcc! Clang Version 3.0.0 and greater supports gcov as well, but older versions don't.") IF(NOT "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") MESSAGE(FATAL_ERROR "Compiler is not GNU gcc! Aborting...") ENDIF() -ENDIF() # NOT CMAKE_COMPILER_IS_GNUCXX +ENDIF() # NOT CMAKE_COMPILER_IS_GNUCC IF ( NOT CMAKE_BUILD_TYPE STREQUAL "Debug" ) MESSAGE( WARNING "Code coverage results with an optimized (non-Debug) build may be misleading" ) From dd413bd19b918c9e586b4a2747a361b79a13e88f Mon Sep 17 00:00:00 2001 From: Joakim Soderberg Date: Thu, 19 Dec 2013 12:03:49 +0000 Subject: [PATCH 25/38] Added EVENT__ENABLE_GCC_WARNINGS, turns all warnings into errors. --- CMakeLists.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8cf39093..70b33f2f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -75,6 +75,7 @@ if (EVENT__COVERAGE) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -O0 -fprofile-arcs -ftest-coverage") endif() +# GCC specific options. if (CMAKE_COMPILER_IS_GNUCC) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall") @@ -94,6 +95,11 @@ if (CMAKE_COMPILER_IS_GNUCC) # TODO: Add --gc-sections support. We need some checks for NetBSD to ensure this works. endif() + option(EVENT__ENABLE_GCC_WARNINGS "Make all GCC warnings into errors" OFF) + if (EVENT__ENABLE_GCC_WARNINGS) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror") + endif() + # We need to test for at least gcc 2.95 here, because older versions don't # have -fno-strict-aliasing execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpversion From f3446ed5fbc5c31f5ae8bd872aca762e90ee61b3 Mon Sep 17 00:00:00 2001 From: Joakim Soderberg Date: Thu, 9 Jan 2014 13:44:38 +0100 Subject: [PATCH 26/38] Add CMake config and install targets. Make it easier for other projects to do find_package by creating config files both in the build and install tree. --- CMakeLists.txt | 98 +++++++++++++++++++++++++++- cmake/LibeventConfig.cmake.in | 17 +++++ cmake/LibeventConfigVersion.cmake.in | 11 ++++ 3 files changed, 124 insertions(+), 2 deletions(-) create mode 100644 cmake/LibeventConfig.cmake.in create mode 100644 cmake/LibeventConfigVersion.cmake.in diff --git a/CMakeLists.txt b/CMakeLists.txt index 70b33f2f..5e759a89 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,9 +23,12 @@ set(CMAKE_CONFIGURATION_TYPES "Debug;Release" CACHE STRING "Limited configuratio project(libevent C) +set(EVENT_VERSION_MAJOR 2) +set(EVENT_VERSION_MINOR 1) +set(EVENT_VERSION_PATCH 4) set(EVENT_NUMERIC_VERSION 0x02010401) -set(EVENT_VERSION "2.1.4-beta") -set(EVENT_PACKAGE_VERSION "") +set(EVENT_VERSION "${EVENT_VERSION_MAJOR}.${EVENT_VERSION_MINOR}.${EVENT_VERSION_PATCH}-beta") +set(EVENT_PACKAGE_VERSION "${EVENT_VERSION_MAJOR}.${EVENT_VERSION_MINOR}.${EVENT_VERSION_PATCH}") option(EVENT__DISABLE_DEBUG_MODE "Define if libevent should build without support for a debug mode" OFF) option(EVENT__ENABLE_VERBOSE_DEBUG "Enables verbose debugging" OFF) @@ -645,6 +648,10 @@ configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/evconfig-private.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/include/evconfig-private.h) +# +# Create the libraries. +# + # TODO: Add dynamic versions of the libraries as well. add_library(event_core STATIC ${HDR_PRIVATE} @@ -663,6 +670,10 @@ add_library(event STATIC ${SRC_EXTRA} ) +# +# Samples. +# + if (NOT EVENT__DISABLE_SAMPLES) set(SAMPLES dns-example @@ -943,3 +954,86 @@ if (NOT EVENT__DISABLE_TESTS) include(CTest) endif() + +# +# Installation preparation. +# + +# Allow the user to override installation directories. +set(EVENT_INSTALL_LIB_DIR lib CACHE PATH "Installation directory for libraries") +set(EVENT_INSTALL_BIN_DIR bin CACHE PATH "Installation directory for executables") +set(EVENT_INSTALL_INCLUDE_DIR include CACHE PATH "Installation directory for header files") + +if(WIN32 AND NOT CYGWIN) + set(DEF_INSTALL_CMAKE_DIR cmake) +else() + set(DEF_INSTALL_CMAKE_DIR lib/cmake/libevent) +endif() + +set(EVENT_INSTALL_CMAKE_DIR ${DEF_INSTALL_CMAKE_DIR} CACHE PATH "Installation directory for CMake files") + +# Make sure the paths are absolute. +foreach(p LIB BIN INCLUDE CMAKE) + set(var EVENT_INSTALL_${p}_DIR) + if(NOT IS_ABSOLUTE "${${var}}") + set(${var} "${CMAKE_INSTALL_PREFIX}/${${var}}") + endif() +endforeach() + +# Export targets (This is used for other CMake projects to easily find the libraries and include files). +export(TARGETS event event_extras event_core + FILE "${PROJECT_BINARY_DIR}/LibeventTargets.cmake") +export(PACKAGE libevent) + +# Generate the config file for the build-tree. +set(EVENT__INCLUDE_DIRS + "${PROJECT_SOURCE_DIR}/include" + "${PROJECT_BINARY_DIR}/include") +configure_file(${PROJECT_SOURCE_DIR}/cmake/LibeventConfig.cmake.in + ${PROJECT_BINARY_DIR}/LibeventConfig.cmake + @ONLY) + +# Generate the config file for the installation tree. +file(RELATIVE_PATH + REL_INCLUDE_DIR + "${EVENT_INSTALL_CMAKE_DIR}" + "${EVENT_INSTALL_INCLUDE_DIR}") # Calculate the relative directory from the Cmake dir. + +# Note the EVENT_CMAKE_DIR is defined in LibeventConfig.cmake.in, +# we escape it here so it's evaluated when it is included instead +# so that the include dirs are givenrelative to where the +# config file is located. +set(EVENT__INCLUDE_DIRS + "\${EVENT_CMAKE_DIR}/${REL_INCLUDE_DIR}") +configure_file(${PROJECT_SOURCE_DIR}/cmake/LibeventConfig.cmake.in + ${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/LibeventConfig.cmake + @ONLY) + +# Generate version info for both build-tree and install-tree. +configure_file(${PROJECT_SOURCE_DIR}/cmake/LibeventConfigVersion.cmake.in + ${PROJECT_BINARY_DIR}/LibeventConfigVersion.cmake + @ONLY) + +# Define the public headers. +set_target_properties(event event_core event_extras + PROPERTIES PUBLIC_HEADER ${HDR_PUBLIC}) + +# +# Install targets. +# +install(TARGETS event event_core event_extras + EXPORT LibeventTargets + LIBRARY DESTINATION "${EVENT_INSTALL_LIB_DIR}" COMPONENT lib + ARCHIVE DESTINATION "${EVENT_INSTALL_LIB_DIR}" COMPONENT lib + PUBLIC_HEADER DESTINATION "${EVENT_INSTALL_INCLUDE_DIR}/event2" COMPONENT dev) + +# Install the configs. +install(FILES + ${PROJECT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/LibeventConfig.cmake + ${PROJECT_BINARY_DIR}/Libevent + DESTINATION "${EVENT_INSTALL_CMAKE_DIR}" COMPONENT dev) + + +# Install exports for the install-tree. +install(EXPORT LibeventTargets + DESTINATION "${EVENT_INSTALL_CMAKE_DIR}" COMPONENT dev) diff --git a/cmake/LibeventConfig.cmake.in b/cmake/LibeventConfig.cmake.in new file mode 100644 index 00000000..d4199651 --- /dev/null +++ b/cmake/LibeventConfig.cmake.in @@ -0,0 +1,17 @@ +# - Config file for the Libevent package +# It defines the following variables +# LIBEVENT_INCLUDE_DIRS - include directories for FooBar +# LIBEVENT_LIBRARIES - libraries to link against + +# Get the path of the current file. +get_filename_component(LIBEVENT_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH) + +# Set the include directories. +set(LIBEVENT_INCLUDE_DIRS "@EVENT__INCLUDE_DIRS@") + +# Include the project Targets file, this contains definitions for IMPORTED targets. +include(${LIBEVENT_CMAKE_DIR}/LibeventTargets.cmake) + +# IMPORTED targets from LibeventTargets.cmake +set(LIBEVENT_LIBRARIES event event_core event_extras) + diff --git a/cmake/LibeventConfigVersion.cmake.in b/cmake/LibeventConfigVersion.cmake.in new file mode 100644 index 00000000..56371a8f --- /dev/null +++ b/cmake/LibeventConfigVersion.cmake.in @@ -0,0 +1,11 @@ +set(PACKAGE_VERSION "@EVENT_PACKAGE_VERSION@") + +# Check whether the requested PACKAGE_FIND_VERSION is compatible +if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}") + set(PACKAGE_VERSION_COMPATIBLE FALSE) +else() + set(PACKAGE_VERSION_COMPATIBLE TRUE) + if ("${PACKAGE_VERSION}" VERSION_EQUAL "${PACKAGE_FIND_VERSION}") + set(PACKAGE_VERSION_EXACT TRUE) + endif() +endif() From 4b754df949fddd6f0c6afb0f526d80ae7e48f87e Mon Sep 17 00:00:00 2001 From: Joakim Soderberg Date: Fri, 10 Jan 2014 17:58:42 +0100 Subject: [PATCH 27/38] Fix typo --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5e759a89..fbe2e2ba 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1030,7 +1030,7 @@ install(TARGETS event event_core event_extras # Install the configs. install(FILES ${PROJECT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/LibeventConfig.cmake - ${PROJECT_BINARY_DIR}/Libevent + ${PROJECT_BINARY_DIR}/LibeventConfigVersion.cmake DESTINATION "${EVENT_INSTALL_CMAKE_DIR}" COMPONENT dev) From 49ab36327177bf593e3b9e62caf058de0d27c385 Mon Sep 17 00:00:00 2001 From: Joakim Soderberg Date: Tue, 14 Jan 2014 13:01:31 +0000 Subject: [PATCH 28/38] Some work on making it possible to simply do add_subdirectory() on the project. --- CMakeLists.txt | 5 ++++- cmake/CheckPrototypeDefinition.cmake | 3 +-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index fbe2e2ba..f0c17483 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -989,6 +989,7 @@ export(PACKAGE libevent) set(EVENT__INCLUDE_DIRS "${PROJECT_SOURCE_DIR}/include" "${PROJECT_BINARY_DIR}/include") +set(LIBEVENT_INCLUDE_DIRS ${EVENT__INCLUDE_DIRS} CACHE PATH "Libevent include directories") configure_file(${PROJECT_SOURCE_DIR}/cmake/LibeventConfig.cmake.in ${PROJECT_BINARY_DIR}/LibeventConfig.cmake @ONLY) @@ -1004,7 +1005,7 @@ file(RELATIVE_PATH # so that the include dirs are givenrelative to where the # config file is located. set(EVENT__INCLUDE_DIRS - "\${EVENT_CMAKE_DIR}/${REL_INCLUDE_DIR}") + "\${EVENT_CMAKE_DIR}/${REL_INCLUDE_DIR}") configure_file(${PROJECT_SOURCE_DIR}/cmake/LibeventConfig.cmake.in ${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/LibeventConfig.cmake @ONLY) @@ -1037,3 +1038,5 @@ install(FILES # Install exports for the install-tree. install(EXPORT LibeventTargets DESTINATION "${EVENT_INSTALL_CMAKE_DIR}" COMPONENT dev) + +set(LIBEVENT_LIBRARIES event event_core event_extras CACHE STRING "Libevent libraries") diff --git a/cmake/CheckPrototypeDefinition.cmake b/cmake/CheckPrototypeDefinition.cmake index 3a53f668..5e6ba4bb 100644 --- a/cmake/CheckPrototypeDefinition.cmake +++ b/cmake/CheckPrototypeDefinition.cmake @@ -52,8 +52,7 @@ function(CHECK_PROTOTYPE_DEFINITION _FUNCTION _PROTOTYPE _RETURN _HEADER _VARIAB set(CHECK_PROTOTYPE_DEFINITION_PROTO ${_PROTOTYPE}) set(CHECK_PROTOTYPE_DEFINITION_RETURN ${_RETURN}) - #configure_file("${CMAKE_ROOT}/Modules/CheckPrototypeDefinition.c.in" - # "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckPrototypeDefinition.c" @ONLY) + # TODO: Fix this. If the Module path has more than one entry, the below will fail. configure_file("${CMAKE_MODULE_PATH}/CheckPrototypeDefinition.c.in" "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckPrototypeDefinition.c" @ONLY) From fd42e70d182fbffe58ffdc4db7d0fe2f3cc36d47 Mon Sep 17 00:00:00 2001 From: Joakim Soderberg Date: Tue, 14 Jan 2014 17:37:58 +0100 Subject: [PATCH 29/38] Set USE_DEBUG=1 on EVENT__ENABLE_VERBOSE_DEBUG --- CMakeLists.txt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f0c17483..bc7c38d3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -40,7 +40,6 @@ option(EVENT__DISABLE_TESTS "If tests should be compiled or not" OFF) option(EVENT__DISABLE_REGRESS "Disable the regress tests" OFF) option(EVENT__FORCE_KQUEUE_CHECK "When crosscompiling forces running a test program that verifies that Kqueue works with pipes. Note that this requires you to manually run the test program on the the cross compilation target to verify that it works. See cmake documentation for try_run for more details" OFF) option(EVENT__COVERAGE "Enable running gcov to get a test coverage report (only works with GCC/CLang). Make sure to enable -DCMAKE_BUILD_TYPE=Debug as well." OFF) -# TODO: Add --enable-verbose-debug, verbose debug logging # TODO: Add --disable-largefile omit support for large files # Put the libaries and binaries that get built into directories at the @@ -62,6 +61,10 @@ include(CheckStructHasMember) include(CheckCSourceCompiles) include(CheckPrototypeDefinition) +if (EVENT__ENABLE_VERBOSE_DEBUG) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DUSE_DEBUG=1") +endif() + # Setup compiler flags for coverage. if (EVENT__COVERAGE) if(NOT CMAKE_COMPILER_IS_GNUCC) From 24d646666b3d85ff65fbdd5c1a29e3dc5c6f6e09 Mon Sep 17 00:00:00 2001 From: Joakim Soderberg Date: Tue, 14 Jan 2014 17:53:47 +0100 Subject: [PATCH 30/38] Fix so that old nmake project still builds. --- Makefile.nmake | 2 +- test/Makefile.nmake | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile.nmake b/Makefile.nmake index 39efbc91..f27cd619 100644 --- a/Makefile.nmake +++ b/Makefile.nmake @@ -20,7 +20,7 @@ SSL_CFLAGS= !ENDIF # Needed for correctness -CFLAGS=/IWIN32-Code /Iinclude /Icompat /DHAVE_CONFIG_H /I. $(SSL_CFLAGS) +CFLAGS=/IWIN32-Code /IWIN32-Code/nmake /Iinclude /Icompat /DHAVE_CONFIG_H /I. $(SSL_CFLAGS) # For optimization and warnings CFLAGS=$(CFLAGS) /Ox /W3 /wd4996 /nologo diff --git a/test/Makefile.nmake b/test/Makefile.nmake index 92244ad7..17aa2fb2 100644 --- a/test/Makefile.nmake +++ b/test/Makefile.nmake @@ -10,7 +10,7 @@ SSL_OBJS= SSL_LIBS= !ENDIF -CFLAGS=/I.. /I../WIN32-Code /I../include /I../compat /DHAVE_CONFIG_H /DTINYTEST_LOCAL $(SSL_CFLAGS) +CFLAGS=/I.. /I../WIN32-Code /I../WIN32-Code/nmake /I../include /I../compat /DHAVE_CONFIG_H /DTINYTEST_LOCAL $(SSL_CFLAGS) CFLAGS=$(CFLAGS) /Ox /W3 /wd4996 /nologo From d2bc39afd0a45ec44e5a3a30ffba0f3f3473b1a1 Mon Sep 17 00:00:00 2001 From: Joakim Soderberg Date: Tue, 14 Jan 2014 18:24:43 +0100 Subject: [PATCH 31/38] Rename README to README.md and use markdown to format. --- README => README.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename README => README.md (100%) diff --git a/README b/README.md similarity index 100% rename from README rename to README.md From 604b8cc4d1fdb40426803d9faba062fd08fcf87d Mon Sep 17 00:00:00 2001 From: Joakim Soderberg Date: Tue, 14 Jan 2014 18:25:07 +0100 Subject: [PATCH 32/38] Update README with CMake build instructions. --- README.md | 81 ++++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 72 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 3dfa10a3..bc6d72bc 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,36 @@ -0. BUILDING AND INSTALLATION (Briefly) +# 0. BUILDING AND INSTALLATION (Briefly) +## Autoconf + +``` $ ./configure $ make $ make verify # (optional) $ sudo make install +``` -1. BUILDING AND INSTALLATION (In Depth) +## CMake (Windows) + + + +``` +$ md build && cd build +$ cmake -G "Visual Studio 10" .. # Or whatever generator you want to use cmake --help for a list. +$ start libevent.sln +``` + +## CMake (Unix) + +``` +$ mkdir build && cd build +$ cmake .. # Default to Unix Makefiles. +$ make +$ make verify # (optional) +``` + +# 1. BUILDING AND INSTALLATION (In Depth) + +## Autoconf To build libevent, type @@ -17,11 +42,15 @@ $ ./configure && make You can run the regression tests by running +``` $ make verify +``` Install as root via -# make install +``` +$ make install +``` Before reporting any problems, please run the regression tests. @@ -44,20 +73,54 @@ The configure script also supports the following flags: --disable-openssl Disable support for OpenSSL encryption. --disable-thread-support Don't support multithreaded environments. -2. USEFUL LINKS: +## CMake (Windows) + +First of all install . + +To build libevent using Microsoft Visual studio open the "Visual Studio Command prompt" and type: + +``` +$ cd +$ cmake -G "Visual Studio 10" .. # Or whatever generator you want to use cmake --help for a list. +$ start libevent.sln +``` + +Then build the entire solution via the Build menu. + +the "NMake Makefiles" CMake generator can be used to build entirely via the command line. + +To get a list of settings available for the project you can type: + +``` +$ cmake -LH .. +``` + +CMake also provides a GUI that lets you specify the source directory and output (binary) directory +that the build should be placed in. + +### OpenSSL support + +To build Libevent with OpenSSL support you will need to have OpenSSL binaries available when building, +these can be found here: + +# 2. USEFUL LINKS: For the latest released version of Libevent, see the official website at http://libevent.org/ . There's a pretty good work-in-progress manual up at - http://www.wangafu.net/~nickm/libevent-book/ . + . For the latest development versions of Libevent, access our Git repository via - "git clone git://levent.git.sourceforge.net/gitroot/levent/libevent" -You can browse the git repository online at -http://levent.git.sourceforge.net/git/gitweb-index.cgi . +``` +$ git clone git://levent.git.sourceforge.net/gitroot/levent/libevent +``` + +You can browse the git repository online at: + . + To report bugs, request features, or submit patches to Libevent, use the Sourceforge trackers at @@ -66,7 +129,7 @@ https://sourceforge.net/tracker/?group_id=50884 . There's also a libevent-users mailing list for talking about Libevent use and development: http://archives.seul.org/libevent/users/ -3. ACKNOWLEDGMENTS +# 3. ACKNOWLEDGMENTS The following people have helped with suggestions, ideas, code or fixing bugs: From 8d4cb35dda3ea20af3e541d307d7e293e3f82eba Mon Sep 17 00:00:00 2001 From: JoakimSoderberg Date: Tue, 14 Jan 2014 18:41:58 +0100 Subject: [PATCH 33/38] Clean up the README some. --- README.md | 379 +++++++++++++++++++++++++++--------------------------- 1 file changed, 193 insertions(+), 186 deletions(-) diff --git a/README.md b/README.md index bc6d72bc..795ad885 100644 --- a/README.md +++ b/README.md @@ -2,31 +2,27 @@ ## Autoconf -``` -$ ./configure -$ make -$ make verify # (optional) -$ sudo make install -``` + $ ./configure + $ make + $ make verify # (optional) + $ sudo make install ## CMake (Windows) - +Install CMake: -``` -$ md build && cd build -$ cmake -G "Visual Studio 10" .. # Or whatever generator you want to use cmake --help for a list. -$ start libevent.sln -``` + + $ md build && cd build + $ cmake -G "Visual Studio 10" .. # Or whatever generator you want to use cmake --help for a list. + $ start libevent.sln ## CMake (Unix) -``` -$ mkdir build && cd build -$ cmake .. # Default to Unix Makefiles. -$ make -$ make verify # (optional) -``` + $ mkdir build && cd build + $ cmake .. # Default to Unix Makefiles. + $ make + $ make verify # (optional) + # 1. BUILDING AND INSTALLATION (In Depth) @@ -34,29 +30,26 @@ $ make verify # (optional) To build libevent, type -$ ./configure && make + $ ./configure && make - (If you got libevent from the git repository, you will - first need to run the included "autogen.sh" script in order to - generate the configure script.) + + (If you got libevent from the git repository, you will + first need to run the included "autogen.sh" script in order to + generate the configure script.) You can run the regression tests by running -``` -$ make verify -``` + $ make verify Install as root via -``` -$ make install -``` + $ make install Before reporting any problems, please run the regression tests. To enable the low-level tracing build the library as: - CFLAGS=-DUSE_DEBUG ./configure [...] + $ CFLAGS=-DUSE_DEBUG ./configure [...] Standard configure flags should work. In particular, see: @@ -81,13 +74,19 @@ To build libevent using Microsoft Visual studio open the "Visual Studio Command ``` $ cd +$ mkdir build && cd build $ cmake -G "Visual Studio 10" .. # Or whatever generator you want to use cmake --help for a list. $ start libevent.sln ``` -Then build the entire solution via the Build menu. +In the above, the ".." refers to the dir containing the Libevent source code. +You can build multiple versions (with different compile time settings) from the same source tree +by creating other build directories. -the "NMake Makefiles" CMake generator can be used to build entirely via the command line. +It is highly recommended to build "out of source" when using +CMake instead of "in source" like the normal behaviour of autoconf for this reason. + +The "NMake Makefiles" CMake generator can be used to build entirely via the command line. To get a list of settings available for the project you can type: @@ -95,8 +94,10 @@ To get a list of settings available for the project you can type: $ cmake -LH .. ``` +### GUI + CMake also provides a GUI that lets you specify the source directory and output (binary) directory -that the build should be placed in. +that the build should be placed in. ### OpenSSL support @@ -106,7 +107,7 @@ these can be found here: # 2. USEFUL LINKS: For the latest released version of Libevent, see the official website at -http://libevent.org/ . + . There's a pretty good work-in-progress manual up at . @@ -119,170 +120,176 @@ $ git clone git://levent.git.sourceforge.net/gitroot/levent/libevent ``` You can browse the git repository online at: - . + + + To report bugs, request features, or submit patches to Libevent, use the Sourceforge trackers at -https://sourceforge.net/tracker/?group_id=50884 . + + There's also a libevent-users mailing list for talking about Libevent -use and development: http://archives.seul.org/libevent/users/ +use and development: + + # 3. ACKNOWLEDGMENTS The following people have helped with suggestions, ideas, code or fixing bugs: - Samy Al Bahra - Jacob Appelbaum - Arno Bakker - Weston Andros Adamson - William Ahern - Ivan Andropov - Sergey Avseyev - Avi Bab - Joachim Bauch - Gilad Benjamini - Stas Bekman - Denis Bilenko - Julien Blache - Kevin Bowling - Tomash Brechko - Kelly Brock - Ralph Castain - Adrian Chadd - Lawnstein Chan - Shuo Chen - Ka-Hing Cheung - Andrew Cox - Paul Croome - George Danchev - Andrew Danforth - Ed Day - Christopher Davis - Mike Davis - Antony Dovgal - Mihai Draghicioiu - Alexander Drozdov - Mark Ellzey - Shie Erlich - Leonid Evdokimov - Juan Pablo Fernandez - Christophe Fillot - Mike Frysinger - Remi Gacogne - Artem Germanov - Alexander von Gernler - Artur Grabowski - Diwaker Gupta - Sebastian Hahn - Dave Hart - Greg Hazel - Nicholas Heath - Michael Herf - Sebastian Hahn - Savg He - Mark Heily - Maxime Henrion - Michael Herf - Greg Hewgill - Andrew Hochhaus - Aaron Hopkins - Tani Hosokawa - Jamie Iles - Xiuqiang Jiang - Claudio Jeker - Evan Jones - George Kadianakis - Phua Keat - Azat Khuzhin - Alexander Klauer - Kevin Ko - Brian Koehmstedt - Marko Kreen - Valery Kyholodov - Ross Lagerwall - Scott Lamb - Christopher Layne - Adam Langley - Graham Leggett - Volker Lendecke - Philip Lewis - Zhou Li - David Libenzi - Yan Lin - Moshe Litvin - Simon Liu - Mitchell Livingston - Hagne Mahre - Lubomir Marinov - Abilio Marques - Abel Mathew - Nick Mathewson - James Mansion - Nicholas Marriott - Andrey Matveev - Caitlin Mercer - Dagobert Michelsen - Andrea Montefusco - Mansour Moufid - Mina Naguib - Felix Nawothnig - Trond Norbye - Linus Nordberg - Richard Nyberg - Jon Oberheide - Phil Oleson - Dave Pacheco - Derrick Pallas - Tassilo von Parseval - Catalin Patulea - Patrick Pelletier - Simon Perreault - Dan Petro - Pierre Phaneuf - Amarin Phaosawasdi - Ryan Phillips - Dimitre Piskyulev - Pavel Plesov - Jon Poland - Roman Puls - Nate R - Robert Ransom - Bert JW Regeer - Nate Rosenblum - Peter Rosin - Maseeb Abdul Qadir - Wang Qin - Alex S - Gyepi Sam - Hanna Schroeter - Ralf Schmitt - Mike Smellie - Kevin Springborn - Nir Soffer - Harlan Stenn - Steve Snyder - Dug Song - Dongsheng Song - Hannes Sowa - Ferenc Szalai - Brodie Thiesfield - Jason Toffaletti - Gisle Vanem - Bas Verhoeven - Constantine Verutin - Colin Watt - Zack Weinberg - Jardel Weyrich - Jay R. Wren - Zack Weinberg - Alejo - Alex - Taral - propanbutan - mmadia - yangacer + * Samy Al Bahra + * Jacob Appelbaum + * Arno Bakker + * Weston Andros Adamson + * William Ahern + * Ivan Andropov + * Sergey Avseyev + * Avi Bab + * Joachim Bauch + * Gilad Benjamini + * Stas Bekman + * Denis Bilenko + * Julien Blache + * Kevin Bowling + * Tomash Brechko + * Kelly Brock + * Ralph Castain + * Adrian Chadd + * Lawnstein Chan + * Shuo Chen + * Ka-Hing Cheung + * Andrew Cox + * Paul Croome + * George Danchev + * Andrew Danforth + * Ed Day + * Christopher Davis + * Mike Davis + * Antony Dovgal + * Mihai Draghicioiu + * Alexander Drozdov + * Mark Ellzey + * Shie Erlich + * Leonid Evdokimov + * Juan Pablo Fernandez + * Christophe Fillot + * Mike Frysinger + * Remi Gacogne + * Artem Germanov + * Alexander von Gernler + * Artur Grabowski + * Diwaker Gupta + * Sebastian Hahn + * Dave Hart + * Greg Hazel + * Nicholas Heath + * Michael Herf + * Sebastian Hahn + * Savg He + * Mark Heily + * Maxime Henrion + * Michael Herf + * Greg Hewgill + * Andrew Hochhaus + * Aaron Hopkins + * Tani Hosokawa + * Jamie Iles + * Xiuqiang Jiang + * Claudio Jeker + * Evan Jones + * George Kadianakis + * Phua Keat + * Azat Khuzhin + * Alexander Klauer + * Kevin Ko + * Brian Koehmstedt + * Marko Kreen + * Valery Kyholodov + * Ross Lagerwall + * Scott Lamb + * Christopher Layne + * Adam Langley + * Graham Leggett + * Volker Lendecke + * Philip Lewis + * Zhou Li + * David Libenzi + * Yan Lin + * Moshe Litvin + * Simon Liu + * Mitchell Livingston + * Hagne Mahre + * Lubomir Marinov + * Abilio Marques + * Abel Mathew + * Nick Mathewson + * James Mansion + * Nicholas Marriott + * Andrey Matveev + * Caitlin Mercer + * Dagobert Michelsen + * Andrea Montefusco + * Mansour Moufid + * Mina Naguib + * Felix Nawothnig + * Trond Norbye + * Linus Nordberg + * Richard Nyberg + * Jon Oberheide + * Phil Oleson + * Dave Pacheco + * Derrick Pallas + * Tassilo von Parseval + * Catalin Patulea + * Patrick Pelletier + * Simon Perreault + * Dan Petro + * Pierre Phaneuf + * Amarin Phaosawasdi + * Ryan Phillips + * Dimitre Piskyulev + * Pavel Plesov + * Jon Poland + * Roman Puls + * Nate R + * Robert Ransom + * Bert JW Regeer + * Nate Rosenblum + * Peter Rosin + * Maseeb Abdul Qadir + * Wang Qin + * Alex S + * Gyepi Sam + * Hanna Schroeter + * Ralf Schmitt + * Mike Smellie + * Kevin Springborn + * Nir Soffer + * Harlan Stenn + * Steve Snyder + * Dug Song + * Dongsheng Song + * Hannes Sowa + * Joakim Soderberg + * Ferenc Szalai + * Brodie Thiesfield + * Jason Toffaletti + * Gisle Vanem + * Bas Verhoeven + * Constantine Verutin + * Colin Watt + * Zack Weinberg + * Jardel Weyrich + * Jay R. Wren + * Zack Weinberg + * Alejo + * Alex + * Taral + * propanbutan + * mmadia + * yangacer If we have forgotten your name, please contact us. From 8697b99cd472e7f0c5a496b93d4c19e34e1bfd6e Mon Sep 17 00:00:00 2001 From: Joakim Soderberg Date: Tue, 14 Jan 2014 18:45:11 +0100 Subject: [PATCH 34/38] Forgotten headers for old nmake project compatability. --- WIN32-Code/nmake/evconfig-private.h | 6 + WIN32-Code/nmake/event2/event-config.h | 363 +++++++++++++++++++++++++ 2 files changed, 369 insertions(+) create mode 100644 WIN32-Code/nmake/evconfig-private.h create mode 100644 WIN32-Code/nmake/event2/event-config.h diff --git a/WIN32-Code/nmake/evconfig-private.h b/WIN32-Code/nmake/evconfig-private.h new file mode 100644 index 00000000..88e20627 --- /dev/null +++ b/WIN32-Code/nmake/evconfig-private.h @@ -0,0 +1,6 @@ +#if !defined(EVENT_EVCONFIG__PRIVATE_H_) && !defined(__MINGW32__) +#define EVENT_EVCONFIG__PRIVATE_H_ + +/* Nothing to see here. Move along. */ + +#endif diff --git a/WIN32-Code/nmake/event2/event-config.h b/WIN32-Code/nmake/event2/event-config.h new file mode 100644 index 00000000..43b5c3fb --- /dev/null +++ b/WIN32-Code/nmake/event2/event-config.h @@ -0,0 +1,363 @@ +/* event2/event-config.h + * + * This file was generated by autoconf when libevent was built, and post- + * processed by Libevent so that its macros would have a uniform prefix. + * + * DO NOT EDIT THIS FILE. + * + * Do not rely on macros in this file existing in later versions. + */ +#ifndef EVENT_CONFIG_H__ +#define EVENT_CONFIG_H__ +/* config.h. Generated by configure. */ +/* config.h.in. Generated from configure.in by autoheader. */ + +/* Define if libevent should not allow replacing the mm functions */ +/* #undef EVENT__DISABLE_MM_REPLACEMENT */ + +/* Define if libevent should not be compiled with thread support */ +/* #undef EVENT__DISABLE_THREAD_SUPPORT */ + +/* Define if clock_gettime is available in libc */ +/* #undef _EVENT_DNS_USE_CPU_CLOCK_FOR_ID */ + +/* Define is no secure id variant is available */ +/* #define _EVENT_DNS_USE_GETTIMEOFDAY_FOR_ID 1 */ +#define EVENT_DNS_USE_FTIME_FOR_ID_ 1 + +/* Define to 1 if you have the header file. */ +/* #undef EVENT__HAVE_ARPA_INET_H */ + +/* Define to 1 if you have the `clock_gettime' function. */ +/* #undef EVENT__HAVE_CLOCK_GETTIME */ + +/* Define if /dev/poll is available */ +/* #undef EVENT__HAVE_DEVPOLL */ + +/* Define to 1 if you have the header file. */ +/* #undef EVENT__HAVE_DLFCN_H */ + +/* Define if your system supports the epoll system calls */ +/* #undef EVENT__HAVE_EPOLL */ + +/* Define to 1 if you have the `epoll_ctl' function. */ +/* #undef EVENT__HAVE_EPOLL_CTL */ + +/* Define to 1 if you have the `eventfd' function. */ +/* #undef EVENT__HAVE_EVENTFD */ + +/* Define if your system supports event ports */ +/* #undef EVENT__HAVE_EVENT_PORTS */ + +/* Define to 1 if you have the `fcntl' function. */ +/* #undef EVENT__HAVE_FCNTL */ + +/* Define to 1 if you have the header file. */ +#define EVENT__HAVE_FCNTL_H 1 + +/* Define to 1 if you have the `getaddrinfo' function. */ +#define EVENT__HAVE_GETADDRINFO 1 + +/* Define to 1 if you have the `getnameinfo' function. */ +#define EVENT__HAVE_GETNAMEINFO 1 + +/* Define to 1 if you have the `getprotobynumber' function. */ +#define EVENT__HAVE_GETPROTOBYNUMBER 1 + +/* Define to 1 if you have the `getservbyname' function. */ +#define EVENT__HAVE_GETSERVBYNAME 1 + +/* Define to 1 if you have the `gettimeofday' function. */ +/* #define EVENT__HAVE_GETTIMEOFDAY 1 */ + +/* Define to 1 if you have the `inet_aton' function. */ +/* #undef EVENT__HAVE_INET_ATON */ + +/* Define to 1 if you have the `inet_ntop' function. */ +/* #undef EVENT__HAVE_INET_NTOP */ + +/* Define to 1 if you have the `inet_pton' function. */ +/* #undef EVENT__HAVE_INET_PTON */ + +/* Define to 1 if you have the header file. */ +/* #define EVENT__HAVE_INTTYPES_H 1 */ + +/* Define to 1 if you have the `kqueue' function. */ +/* #undef EVENT__HAVE_KQUEUE */ + +/* Define if the system has zlib */ +/* #undef EVENT__HAVE_LIBZ */ + +/* Define to 1 if you have the header file. */ +#define EVENT__HAVE_MEMORY_H 1 + +/* Define to 1 if you have the `mmap' function. */ +/* #undef EVENT__HAVE_MMAP */ + +/* Define to 1 if you have the header file. */ +/* #undef EVENT__HAVE_NETINET_IN6_H */ + +/* Define to 1 if you have the header file. */ +/* #undef EVENT__HAVE_NETINET_IN_H */ + +/* Define to 1 if you have the `pipe' function. */ +/* #undef EVENT__HAVE_PIPE */ + +/* Define to 1 if you have the `poll' function. */ +/* #undef EVENT__HAVE_POLL */ + +/* Define to 1 if you have the header file. */ +/* #undef EVENT__HAVE_POLL_H */ + +/* Define to 1 if you have the `port_create' function. */ +/* #undef EVENT__HAVE_PORT_CREATE */ + +/* Define to 1 if you have the header file. */ +/* #undef EVENT__HAVE_PORT_H */ + +/* Define if you have POSIX threads libraries and header files. */ +/* #undef EVENT__HAVE_PTHREAD */ + +/* Define if we have pthreads on this system */ +/* #undef EVENT__HAVE_PTHREADS */ + +/* Define to 1 if the system has the type `sa_family_t'. */ +/* #undef EVENT__HAVE_SA_FAMILY_T */ + +/* Define to 1 if you have the `select' function. */ +/* #undef EVENT__HAVE_SELECT */ + +/* Define to 1 if you have the `sendfile' function. */ +/* #undef EVENT__HAVE_SENDFILE */ + +/* Define if F_SETFD is defined in */ +/* #undef EVENT__HAVE_SETFD */ + +/* Define to 1 if you have the `sigaction' function. */ +/* #undef EVENT__HAVE_SIGACTION */ + +/* Define to 1 if you have the `signal' function. */ +#define EVENT__HAVE_SIGNAL 1 + +/* Define to 1 if you have the `splice' function. */ +/* #undef EVENT__HAVE_SPLICE */ + +/* Define to 1 if you have the header file. */ +#define EVENT__HAVE_STDARG_H 1 + +/* Define to 1 if you have the header file. */ +#define EVENT__HAVE_STDDEF_H 1 + +/* Define to 1 if you have the header file. */ +/* #define EVENT__HAVE_STDINT_H 1 */ + +/* Define to 1 if you have the header file. */ +#define EVENT__HAVE_STDLIB_H 1 + +/* Define to 1 if you have the header file. */ +#define EVENT__HAVE_STRINGS_H 1 + +/* Define to 1 if you have the header file. */ +#define EVENT__HAVE_STRING_H 1 + +/* Define to 1 if you have the `strlcpy' function. */ +/* #undef EVENT__HAVE_STRLCPY */ + +/* Define to 1 if you have the `strsep' function. */ +/* #undef EVENT__HAVE_STRSEP */ + +/* Define to 1 if you have the `strtok_r' function. */ +/* #undef EVENT__HAVE_STRTOK_R */ + +/* Define to 1 if you have the `strtoll' function. */ +/* #define EVENT__HAVE_STRTOLL 1 */ + +#define EVENT__HAVE_STRUCT_ADDRINFO 1 + +/* Define to 1 if the system has the type `struct in6_addr'. */ +#define EVENT__HAVE_STRUCT_IN6_ADDR 1 + +/* Define to 1 if `s6_addr16' is member of `struct in6_addr'. */ +#define EVENT__HAVE_STRUCT_IN6_ADDR_S6_ADDR16 1 + +/* Define to 1 if `s6_addr32' is member of `struct in6_addr'. */ +#define EVENT__HAVE_STRUCT_IN6_ADDR_S6_ADDR32 1 + +/* Define to 1 if the system has the type `struct sockaddr_in6'. */ +#define EVENT__HAVE_STRUCT_SOCKADDR_IN6 1 + +/* Define to 1 if `sin6_len' is member of `struct sockaddr_in6'. */ +/* #undef EVENT__HAVE_STRUCT_SOCKADDR_IN6_SIN6_LEN */ + +/* Define to 1 if `sin_len' is member of `struct sockaddr_in'. */ +/* #undef EVENT__HAVE_STRUCT_SOCKADDR_IN_SIN_LEN */ + +/* Define to 1 if the system has the type `struct sockaddr_storage'. */ +#define EVENT__HAVE_STRUCT_SOCKADDR_STORAGE 1 + +/* Define to 1 if you have the header file. */ +/* #undef EVENT__HAVE_SYS_DEVPOLL_H */ + +/* Define to 1 if you have the header file. */ +/* #undef EVENT__HAVE_SYS_EPOLL_H */ + +/* Define to 1 if you have the header file. */ +/* #undef EVENT__HAVE_SYS_EVENTFD_H */ + +/* Define to 1 if you have the header file. */ +/* #undef EVENT__HAVE_SYS_EVENT_H */ + +/* Define to 1 if you have the header file. */ +/* #undef EVENT__HAVE_SYS_IOCTL_H */ + +/* Define to 1 if you have the header file. */ +/* #undef EVENT__HAVE_SYS_MMAN_H */ + +/* Define to 1 if you have the header file. */ +/* #define EVENT__HAVE_SYS_PARAM_H 1 */ + +/* Define to 1 if you have the header file. */ +/* #undef EVENT__HAVE_SYS_QUEUE_H */ + +/* Define to 1 if you have the header file. */ +/* #undef EVENT__HAVE_SYS_SELECT_H */ + +/* Define to 1 if you have the header file. */ +/* #undef EVENT__HAVE_SYS_SENDFILE_H */ + +/* Define to 1 if you have the header file. */ +/* #undef EVENT__HAVE_SYS_SOCKET_H */ + +/* Define to 1 if you have the header file. */ +#define EVENT__HAVE_SYS_STAT_H 1 + +/* Define to 1 if you have the header file. */ +/* #define EVENT__HAVE_SYS_TIME_H 1 */ + +/* Define to 1 if you have the header file. */ +#define EVENT__HAVE_SYS_TYPES_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef EVENT__HAVE_SYS_UIO_H */ + +/* Define if TAILQ_FOREACH is defined in */ +/* #undef EVENT__HAVE_TAILQFOREACH */ + +/* Define if timeradd is defined in */ +/* #undef EVENT__HAVE_TIMERADD */ + +/* Define if timerclear is defined in */ +#define EVENT__HAVE_TIMERCLEAR 1 + +/* Define if timercmp is defined in */ +#define EVENT__HAVE_TIMERCMP 1 + +/* Define if timerisset is defined in */ +#define EVENT__HAVE_TIMERISSET 1 + +/* Define to 1 if the system has the type `uint16_t'. */ +/* #define EVENT__HAVE_UINT16_T 1 */ + +/* Define to 1 if the system has the type `uint32_t'. */ +/* #define EVENT__HAVE_UINT32_T 1 */ + +/* Define to 1 if the system has the type `uint64_t'. */ +/* #define EVENT__HAVE_UINT64_T 1 */ + +/* Define to 1 if the system has the type `uint8_t'. */ +/* #define EVENT__HAVE_UINT8_T 1 */ + +/* Define to 1 if you have the header file. */ +/* #define EVENT__HAVE_UNISTD_H 1 */ + +/* Define to 1 if you have the `vasprintf' function. */ +/* #undef EVENT__HAVE_VASPRINTF */ + +/* Define if kqueue works correctly with pipes */ +/* #undef EVENT__HAVE_WORKING_KQUEUE */ + +/* Numeric representation of the version */ +#define EVENT__NUMERIC_VERSION 0x02010301 + +/* Name of package */ +#define EVENT__PACKAGE "libevent" + +/* Define to the address where bug reports for this package should be sent. */ +#define EVENT__PACKAGE_BUGREPORT "" + +/* Define to the full name of this package. */ +#define EVENT__PACKAGE_NAME "" + +/* Define to the full name and version of this package. */ +#define EVENT__PACKAGE_STRING "" + +/* Define to the one symbol short name of this package. */ +#define EVENT__PACKAGE_TARNAME "" + +/* Define to the version of this package. */ +#define EVENT__PACKAGE_VERSION "" + +/* Define to necessary symbol if this constant uses a non-standard name on + your system. */ +/* #undef EVENT__PTHREAD_CREATE_JOINABLE */ + +/* The size of a `int', as computed by sizeof. */ +#define EVENT__SIZEOF_INT 4 + +/* The size of a `long', as computed by sizeof. */ +#define EVENT__SIZEOF_LONG 4 + +/* The size of a `long long', as computed by sizeof. */ +#define EVENT__SIZEOF_LONG_LONG 8 + +/* The size of a `short', as computed by sizeof. */ +#define EVENT__SIZEOF_SHORT 2 + +/* The size of `size_t', as computed by sizeof. */ +#ifdef _WIN64 +#define EVENT__SIZEOF_SIZE_T 8 +#else +#define EVENT__SIZEOF_SIZE_T 4 +#endif + +/* The size of `void *', as computed by sizeof. */ +#ifdef _WIN64 +#define EVENT__SIZEOF_VOID_P 8 +#else +#define EVENT__SIZEOF_VOID_P 4 +#endif + +/* Define to 1 if you have the ANSI C header files. */ +#define EVENT__STDC_HEADERS 1 + +/* Define to 1 if you can safely include both and . */ +#define EVENT__TIME_WITH_SYS_TIME 1 + +/* Version number of package */ +#define EVENT__VERSION "2.1.3-alpha-dev" + +/* Define to appropriate substitue if compiler doesnt have __func__ */ +#define EVENT____func__ __FUNCTION__ + +/* Define to empty if `const' does not conform to ANSI C. */ +/* #undef EVENT__const */ + +/* Define to `__inline__' or `__inline' if that's what the C compiler + calls it, or to nothing if 'inline' is not supported under any name. */ +#ifndef _EVENT___cplusplus +#define EVENT__inline __inline +#endif + +/* Define to `int' if does not define. */ +/* #undef EVENT__pid_t */ + +/* Define to `unsigned' if does not define. */ +/* #undef EVENT__size_t */ + +/* Define to unsigned int if you dont have it */ +#define EVENT__socklen_t unsigned int + +/* Define to `int' if does not define. */ +#define EVENT__ssize_t SSIZE_T + +#endif From 20244671cd3c66ce81ae85dcb9a3f1312c78a25e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20So=CC=88derberg?= Date: Tue, 21 Jan 2014 11:19:02 +0100 Subject: [PATCH 35/38] Fix include bug. On systems where a previous version of Libevent is installed we don't want the system version of the headers to be included before the ones in the build tree. This happened on my OSX system where I had an ancient version of Libevent installed. It would then load the incorrect event-config.h and fail because the system introspection macros weren't set properly. --- CMakeLists.txt | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index bc7c38d3..35636186 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -611,7 +611,12 @@ set(SRC_EXTRA ) add_definitions(-DHAVE_CONFIG_H) -include_directories(./ ./compat ./include) + +# We use BEFORE here so we don't accidentally look in system directories +# first for some previous versions of the headers that are installed. +include_directories(BEFORE ${PROJECT_SOURCE_DIR} + ${PROJECT_SOURCE_DIR}/compat + ${PROJECT_SOURCE_DIR}/include) if(WIN32) list(APPEND SRC_CORE @@ -641,7 +646,7 @@ source_group("Source Extra" FILES ${SRC_EXTRA}) # Generate the configure headers. # (Place them in the build dir so we don't polute the source tree with generated files). -include_directories(${CMAKE_CURRENT_BINARY_DIR}/include) +include_directories(BEFORE ${CMAKE_CURRENT_BINARY_DIR}/include) configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/event-config.h.cmake From 4e1439588f742959e0afe871c7473a78bc540cf1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20So=CC=88derberg?= Date: Tue, 21 Jan 2014 11:30:27 +0100 Subject: [PATCH 36/38] Change all uses of WIN32 to _WIN32 --- cmake/CheckFunctionExistsEx.c | 4 ++-- evutil.c | 2 +- sample/dns-example.c | 2 +- sample/https-client.c | 12 ++++++------ test/bench.c | 2 +- test/bench_cascade.c | 4 ++-- test/bench_http.c | 2 +- 7 files changed, 14 insertions(+), 14 deletions(-) diff --git a/cmake/CheckFunctionExistsEx.c b/cmake/CheckFunctionExistsEx.c index e3e9cb0f..5ee3e591 100644 --- a/cmake/CheckFunctionExistsEx.c +++ b/cmake/CheckFunctionExistsEx.c @@ -1,6 +1,6 @@ #ifdef CHECK_FUNCTION_EXISTS -#ifndef WIN32 +#ifndef _WIN32 char CHECK_FUNCTION_EXISTS(); #endif @@ -11,7 +11,7 @@ int main(){ #else int main(int ac, char*av[]){ #endif -#ifdef WIN32 +#ifdef _WIN32 void * p = &CHECK_FUNCTION_EXISTS; #else CHECK_FUNCTION_EXISTS(); diff --git a/evutil.c b/evutil.c index e49d744f..c28caded 100644 --- a/evutil.c +++ b/evutil.c @@ -1794,7 +1794,7 @@ evutil_vsnprintf(char *buf, size_t buflen, const char *format, va_list ap) int r; if (!buflen) return 0; -#if defined(_MSC_VER) || defined(WIN32) +#if defined(_MSC_VER) || defined(_WIN32) r = _vsnprintf(buf, buflen, format, ap); if (r < 0) r = _vscprintf(format, ap); diff --git a/sample/dns-example.c b/sample/dns-example.c index c4fb64a5..15e48ce4 100644 --- a/sample/dns-example.c +++ b/sample/dns-example.c @@ -171,7 +171,7 @@ main(int c, char **v) { ++idx; } -#ifdef WIN32 +#ifdef _WIN32 { WSADATA WSAData; WSAStartup(0x101, &WSAData); diff --git a/sample/https-client.c b/sample/https-client.c index b40f92b9..6a9d1baf 100644 --- a/sample/https-client.c +++ b/sample/https-client.c @@ -21,7 +21,7 @@ #include #include -#ifdef WIN32 +#ifdef _WIN32 #include #include @@ -196,7 +196,7 @@ main(int argc, char **argv) if (argc != 2) syntax(); -#ifdef WIN32 +#ifdef _WIN32 { WORD wVersionRequested; WSADATA wsaData; @@ -210,7 +210,7 @@ main(int argc, char **argv) return 1; } } -#endif +#endif // _WIN32 url = argv[1]; http_uri = evhttp_uri_parse(url); @@ -265,7 +265,7 @@ main(int argc, char **argv) if (!ssl_ctx) die_openssl("SSL_CTX_new"); - #ifndef WIN32 + #ifndef _WIN32 /* TODO: Add certificate loading on Windows as well */ /* Attempt to use the system's trusted root certificates. @@ -298,7 +298,7 @@ main(int argc, char **argv) * "wrapping" OpenSSL's routine, not replacing it. */ SSL_CTX_set_cert_verify_callback (ssl_ctx, cert_verify_callback, (void *) host); - #endif // not WIN32 + #endif // not _WIN32 // Create event base base = event_base_new(); @@ -359,7 +359,7 @@ main(int argc, char **argv) evhttp_connection_free(evcon); event_base_free(base); -#ifdef WIN32 +#ifdef _WIN32 WSACleanup(); #endif diff --git a/test/bench.c b/test/bench.c index bdae7b1a..3700505f 100644 --- a/test/bench.c +++ b/test/bench.c @@ -57,7 +57,7 @@ #endif #include -#ifdef WIN32 +#ifdef _WIN32 #include #endif diff --git a/test/bench_cascade.c b/test/bench_cascade.c index d14af82b..2d85cc1f 100644 --- a/test/bench_cascade.c +++ b/test/bench_cascade.c @@ -146,7 +146,7 @@ main(int argc, char **argv) struct timeval *tv; int num_pipes = 100; -#ifdef WIN32 +#ifdef _WIN32 WSADATA WSAData; WSAStartup(0x101, &WSAData); #endif @@ -180,7 +180,7 @@ main(int argc, char **argv) tv->tv_sec * 1000000L + tv->tv_usec); } -#ifdef WIN32 +#ifdef _WIN32 WSACleanup(); #endif diff --git a/test/bench_http.c b/test/bench_http.c index c031f70f..255aae57 100644 --- a/test/bench_http.c +++ b/test/bench_http.c @@ -184,7 +184,7 @@ main(int argc, char **argv) } event_base_dispatch(base); -#ifdef WIN32 +#ifdef _WIN32 WSACleanup(); #endif From 8b40a5b08f1cc9a84a74d89e262bf4463a4e8051 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20So=CC=88derberg?= Date: Tue, 21 Jan 2014 11:35:21 +0100 Subject: [PATCH 37/38] Check if we're on OSX before disabling deprecation in le-proxy --- sample/le-proxy.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sample/le-proxy.c b/sample/le-proxy.c index 0c918d7a..30e0a5f6 100644 --- a/sample/le-proxy.c +++ b/sample/le-proxy.c @@ -6,7 +6,7 @@ */ // Get rid of OSX 10.7 and greater deprecation warnings. -#ifdef __clang__ +#if defined(__APPLE__) && defined(__clang__) #pragma clang diagnostic ignored "-Wdeprecated-declarations" #endif From ae1bd829d5e79f8e54ee03c4e6a911b36c072f89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20So=CC=88derberg?= Date: Tue, 21 Jan 2014 19:19:30 +0100 Subject: [PATCH 38/38] Fix broken autotools build. The move of the static *config.h files to a sub directory for WIN32 broke the autotools build. Use the proper subpath for that as well... --- Makefile.am | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile.am b/Makefile.am index 576a0acd..3ca6a151 100644 --- a/Makefile.am +++ b/Makefile.am @@ -146,7 +146,7 @@ if BUILD_WIN32 SYS_LIBS = -lws2_32 -lshell32 -ladvapi32 SYS_SRC = win32select.c evthread_win32.c buffer_iocp.c event_iocp.c \ bufferevent_async.c -SYS_INCLUDES = -IWIN32-Code +SYS_INCLUDES = -IWIN32-Code -IWIN32-Code/nmake else @@ -247,8 +247,8 @@ libevent_openssl_la_CPPFLAGS = $(AM_CPPFLAGS) $(OPENSSL_INCS) endif noinst_HEADERS += \ - WIN32-Code/evconfig-private.h \ - WIN32-Code/event2/event-config.h \ + WIN32-Code/nmake/evconfig-private.h \ + WIN32-Code/nmake/event2/event-config.h \ WIN32-Code/tree.h \ bufferevent-internal.h \ changelist-internal.h \