Merge branch 'win32-fixes'

This patchset fixes win32 builds after some previous patches (referenced
in particular commits), and also removes some quirks for win32.

* win32-fixes:
  test: do not return void
  log/win32: fix exporting extern variable
  log-internal: missing extern "C"
  log: remove USE_GLOBAL_FOR_DEBUG_LOGGING
  cmake: Export missing symbols for win32
  cmake: eliminate EVENT_BUILDING_REGRESS_TEST, since we link with shared libs
  test: windows doesn't have WNOWAIT
  cmake: clean not used #defines from event-config.h
  cmake: add <pthread.h> only for non-win32

(cherry picked from commit d84f0205453941235b0e04729098d4329c189bba)
This commit is contained in:
Azat Khuzhin 2017-03-14 13:31:02 +03:00 committed by Azat Khuzhin
parent cc554d87ce
commit ebd12e6de7
No known key found for this signature in database
GPG Key ID: B86086848EF8686D
12 changed files with 100 additions and 96 deletions

View File

@ -476,7 +476,9 @@ else()
endif()
if (NOT EVENT__DISABLE_THREAD_SUPPORT)
list(APPEND CMAKE_EXTRA_INCLUDE_FILES pthread.h)
if (NOT WIN32)
list(APPEND CMAKE_EXTRA_INCLUDE_FILES pthread.h)
endif()
CHECK_TYPE_SIZE(pthread_t EVENT__SIZEOF_PTHREAD_T)
endif()
@ -497,7 +499,6 @@ CHECK_TYPE_SIZE("void *" EVENT__SIZEOF_VOID_P)
# - ellzey
#CHECK_FILE_OFFSET_BITS()
#set(EVENT___FILE_OFFSET_BITS _FILE_OFFSET_BITS)
# Verify kqueue works with pipes.
if (EVENT__HAVE_KQUEUE)
@ -982,19 +983,11 @@ if (NOT EVENT__DISABLE_TESTS)
add_executable(regress ${SRC_REGRESS})
# While building the test suite we don't want the visibility
# header trying to "dllimport" the symbols on windows (it
# generates a ton of warnings due to different link
# attributes for all of the symbols)
set_target_properties(regress
PROPERTIES COMPILE_DEFINITIONS
"EVENT_BUILDING_REGRESS_TEST=1")
target_link_libraries(regress
${LIB_APPS}
${LIB_PLATFORM}
event_core_shared
event_extra_static)
event_extra_shared)
if (NOT EVENT__DISABLE_OPENSSL)
target_link_libraries(regress event_openssl_shared)
endif()

View File

@ -336,9 +336,6 @@
/* 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

View File

@ -480,22 +480,6 @@
#endif
#ifdef __THESE_ARE_NOT_CONFIG_H_THINGS_THEY_ARE_DASH_D_THINGS__
/* Number of bits in a file offset, on hosts where this is settable. */
/* Ellzey is not satisfied */
#define EVENT___FILE_OFFSET_BITS @EVENT___FILE_OFFSET_BITS@
/* Define for large files, on AIX-style hosts. */
#define @_LARGE_FILES@
#endif
#ifdef _WhAT_DOES_THIS_EVEN_DO_
/* Define to empty if `const' does not conform to ANSI C. */
/* lolwut? - ellzey */
#undef EVENT__const
#endif
/* 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

View File

@ -185,14 +185,23 @@ EVLOCK_TRY_LOCK_(void *lock)
#elif ! defined(EVENT__DISABLE_THREAD_SUPPORT)
unsigned long evthreadimpl_get_id_(void);
EVENT2_EXPORT_SYMBOL
int evthreadimpl_is_lock_debugging_enabled_(void);
EVENT2_EXPORT_SYMBOL
void *evthreadimpl_lock_alloc_(unsigned locktype);
EVENT2_EXPORT_SYMBOL
void evthreadimpl_lock_free_(void *lock, unsigned locktype);
EVENT2_EXPORT_SYMBOL
int evthreadimpl_lock_lock_(unsigned mode, void *lock);
EVENT2_EXPORT_SYMBOL
int evthreadimpl_lock_unlock_(unsigned mode, void *lock);
EVENT2_EXPORT_SYMBOL
void *evthreadimpl_cond_alloc_(unsigned condtype);
EVENT2_EXPORT_SYMBOL
void evthreadimpl_cond_free_(void *cond);
EVENT2_EXPORT_SYMBOL
int evthreadimpl_cond_signal_(void *cond, int broadcast);
EVENT2_EXPORT_SYMBOL
int evthreadimpl_cond_wait_(void *cond, void *lock, const struct timeval *tv);
int evthreadimpl_locking_enabled_(void);

View File

@ -34,6 +34,7 @@
defined(event_core_shared_EXPORTS) || \
defined(event_pthreads_shared_EXPORTS) || \
defined(event_openssl_shared_EXPORTS)
# if defined (__SUNPRO_C) && (__SUNPRO_C >= 0x550)
# define EVENT2_EXPORT_SYMBOL __global
# elif defined __GNUC__
@ -43,12 +44,21 @@
# else
# define EVENT2_EXPORT_SYMBOL /* unknown compiler */
# endif
#else
# if defined(_MSC_VER) && !defined(EVENT_BUILDING_REGRESS_TEST)
#else /* event_*_EXPORTS */
# if defined(_MSC_VER)
# define EVENT2_EXPORT_SYMBOL extern __declspec(dllimport)
# else
# define EVENT2_EXPORT_SYMBOL
# endif
#endif /* event_*_EXPORTS */
#if defined(_MSC_VER)
# define EVENT2_EXPORT_SYMBOL_DECL __declspec(dllimport)
#else
# define EVENT2_EXPORT_SYMBOL_DECL extern
#endif
#endif /* EVENT2_VISIBILITY_H_INCLUDED_ */

View File

@ -92,6 +92,7 @@ struct event_iocp_port {
HANDLE *shutdownSemaphore;
};
EVENT2_EXPORT_SYMBOL
const struct win32_extension_fns *event_get_win32_extension_fns_(void);
#else
/* Dummy definition so we can test-compile more things on unix. */
@ -106,12 +107,14 @@ struct event_overlapped {
@param cb The callback that should be invoked once the IO operation has
finished.
*/
EVENT2_EXPORT_SYMBOL
void event_overlapped_init_(struct event_overlapped *, iocp_callback cb);
/** Allocate and return a new evbuffer that supports overlapped IO on a given
socket. The socket must be associated with an IO completion port using
event_iocp_port_associate_.
*/
EVENT2_EXPORT_SYMBOL
struct evbuffer *evbuffer_overlapped_new_(evutil_socket_t fd);
/** XXXX Document (nickm) */
@ -131,6 +134,7 @@ void evbuffer_overlapped_set_fd_(struct evbuffer *buf, evutil_socket_t fd);
@param ol Overlapped object with associated completion callback.
@return 0 on success, -1 on error.
*/
EVENT2_EXPORT_SYMBOL
int evbuffer_launch_read_(struct evbuffer *buf, size_t n, struct event_overlapped *ol);
/** Start writing data from the start of an evbuffer.
@ -145,21 +149,26 @@ int evbuffer_launch_read_(struct evbuffer *buf, size_t n, struct event_overlappe
@param ol Overlapped object with associated completion callback.
@return 0 on success, -1 on error.
*/
EVENT2_EXPORT_SYMBOL
int evbuffer_launch_write_(struct evbuffer *buf, ev_ssize_t n, struct event_overlapped *ol);
/** XXX document */
EVENT2_EXPORT_SYMBOL
void evbuffer_commit_read_(struct evbuffer *, ev_ssize_t);
EVENT2_EXPORT_SYMBOL
void evbuffer_commit_write_(struct evbuffer *, ev_ssize_t);
/** Create an IOCP, and launch its worker threads. Internal use only.
This interface is unstable, and will change.
*/
EVENT2_EXPORT_SYMBOL
struct event_iocp_port *event_iocp_port_launch_(int n_cpus);
/** Associate a file descriptor with an iocp, such that overlapped IO on the
fd will happen on one of the iocp's worker threads.
*/
EVENT2_EXPORT_SYMBOL
int event_iocp_port_associate_(struct event_iocp_port *port, evutil_socket_t fd,
ev_uintptr_t key);
@ -169,15 +178,18 @@ int event_iocp_port_associate_(struct event_iocp_port *port, evutil_socket_t fd,
0. Otherwise, return -1. If you get a -1 return value, it is safe to call
this function again.
*/
EVENT2_EXPORT_SYMBOL
int event_iocp_shutdown_(struct event_iocp_port *port, long waitMsec);
/* FIXME document. */
EVENT2_EXPORT_SYMBOL
int event_iocp_activate_overlapped_(struct event_iocp_port *port,
struct event_overlapped *o,
ev_uintptr_t key, ev_uint32_t n_bytes);
struct event_base;
/* FIXME document. */
EVENT2_EXPORT_SYMBOL
struct event_iocp_port *event_base_get_iocp_(struct event_base *base);
/* FIXME document. */
@ -186,6 +198,7 @@ int event_base_start_iocp_(struct event_base *base, int n_cpus);
void event_base_stop_iocp_(struct event_base *base);
/* FIXME document. */
EVENT2_EXPORT_SYMBOL
struct bufferevent *bufferevent_async_new_(struct event_base *base,
evutil_socket_t fd, int options);

View File

@ -29,6 +29,10 @@
#include "event2/util.h"
#ifdef __cplusplus
extern "C" {
#endif
#ifdef __GNUC__
#define EV_CHECK_FMT(a,b) __attribute__((format(printf, a, b)))
#define EV_NORETURN __attribute__((noreturn))
@ -39,21 +43,15 @@
#define EVENT_ERR_ABORT_ ((int)0xdeaddead)
#define USE_GLOBAL_FOR_DEBUG_LOGGING
#if !defined(EVENT__DISABLE_DEBUG_MODE) || defined(USE_DEBUG)
#define EVENT_DEBUG_LOGGING_ENABLED
#endif
#ifdef EVENT_DEBUG_LOGGING_ENABLED
#ifdef USE_GLOBAL_FOR_DEBUG_LOGGING
EVENT2_EXPORT_SYMBOL
extern ev_uint32_t event_debug_logging_mask_;
EVENT2_EXPORT_SYMBOL_DECL
ev_uint32_t event_debug_logging_mask_;
#define event_debug_get_logging_mask_() (event_debug_logging_mask_)
#else
ev_uint32_t event_debug_get_logging_mask_(void);
#endif
#else
#define event_debug_get_logging_mask_() (0)
#endif
@ -90,4 +88,8 @@ void event_logv_(int severity, const char *errstr, const char *fmt, va_list ap)
#undef EV_CHECK_FMT
#ifdef __cplusplus
}
#endif
#endif /* LOG_INTERNAL_H_INCLUDED_ */

10
log.c
View File

@ -69,16 +69,8 @@ static event_fatal_cb fatal_fn = NULL;
#define DEFAULT_MASK 0
#endif
#ifdef USE_GLOBAL_FOR_DEBUG_LOGGING
EVENT2_EXPORT_SYMBOL
ev_uint32_t event_debug_logging_mask_ = DEFAULT_MASK;
#else
static ev_uint32_t event_debug_logging_mask_ = DEFAULT_MASK;
ev_uint32_t
event_debug_get_logging_mask_(void)
{
return event_debug_logging_mask_;
}
#endif
#endif /* EVENT_DEBUG_LOGGING_ENABLED */
void

View File

@ -848,11 +848,34 @@ simple_child_read_cb(evutil_socket_t fd, short event, void *arg)
called++;
}
#define TEST_FORK_EXIT_SUCCESS 76
static void fork_wait_check(int pid)
{
int status;
TT_BLATHER(("Before waitpid"));
#ifdef WNOWAIT
if ((waitpid(pid, &status, WNOWAIT) == -1 && errno == EINVAL) &&
#else
if (
#endif
waitpid(pid, &status, 0) == -1) {
perror("waitpid");
exit(1);
}
TT_BLATHER(("After waitpid"));
if (WEXITSTATUS(status) != TEST_FORK_EXIT_SUCCESS) {
fprintf(stdout, "FAILED (exit): %d\n", WEXITSTATUS(status));
exit(1);
}
}
static void
test_fork(void)
{
char c;
int status;
struct event ev, sig_ev, usr_ev, existing_ev;
pid_t pid;
@ -917,7 +940,7 @@ test_fork(void)
/* we do not send an EOF; simple_read_cb requires an EOF
* to set test_ok. we just verify that the callback was
* called. */
exit(test_ok != 0 || called != 2 ? -2 : 76);
exit(test_ok != 0 || called != 2 ? -2 : TEST_FORK_EXIT_SUCCESS);
}
/** wait until client read first message */
@ -928,18 +951,7 @@ test_fork(void)
tt_fail_perror("write");
}
TT_BLATHER(("Before waitpid"));
if ((waitpid(pid, &status, WNOWAIT) == -1 && errno == EINVAL) &&
waitpid(pid, &status, 0) == -1) {
perror("waitpid");
exit(1);
}
TT_BLATHER(("After waitpid"));
if (WEXITSTATUS(status) != 76) {
fprintf(stdout, "FAILED (exit): %d\n", WEXITSTATUS(status));
exit(1);
}
fork_wait_check(pid);
/* test that the current event loop still works */
if (write(pair[0], TEST1, strlen(TEST1)+1) < 0) {

View File

@ -612,16 +612,8 @@ end:
if (dns)
evdns_base_free(dns, 0);
}
static void
dns_search_test(void *arg)
{
return dns_search_test_impl(arg, 0);
}
static void
dns_search_lower_test(void *arg)
{
return dns_search_test_impl(arg, 1);
}
static void dns_search_test(void *arg) { dns_search_test_impl(arg, 0); }
static void dns_search_lower_test(void *arg) { dns_search_test_impl(arg, 1); }
static int request_count = 0;
static struct evdns_request *current_req = NULL;

View File

@ -545,8 +545,7 @@ http_basic_test_impl(void *arg, int ssl)
if (bev)
bufferevent_free(bev);
}
static void http_basic_test(void *arg)
{ return http_basic_test_impl(arg, 0); }
static void http_basic_test(void *arg) { http_basic_test_impl(arg, 0); }
static void
@ -3327,7 +3326,7 @@ http_chunk_out_test_impl(void *arg, int ssl)
evhttp_free(http);
}
static void http_chunk_out_test(void *arg)
{ return http_chunk_out_test_impl(arg, 0); }
{ http_chunk_out_test_impl(arg, 0); }
static void
http_stream_out_test_impl(void *arg, int ssl)
@ -3373,7 +3372,7 @@ http_stream_out_test_impl(void *arg, int ssl)
evhttp_free(http);
}
static void http_stream_out_test(void *arg)
{ return http_stream_out_test_impl(arg, 0); }
{ http_stream_out_test_impl(arg, 0); }
static void
http_stream_in_chunk(struct evhttp_request *req, void *arg)
@ -3569,7 +3568,7 @@ http_connection_fail_test_impl(void *arg, int ssl)
;
}
static void http_connection_fail_test(void *arg)
{ return http_connection_fail_test_impl(arg, 0); }
{ http_connection_fail_test_impl(arg, 0); }
static void
http_connection_retry_done(struct evhttp_request *req, void *arg)
@ -3641,7 +3640,7 @@ http_simple_test_impl(void *arg, int ssl, int dirty)
evhttp_free(http);
}
static void http_simple_test(void *arg)
{ return http_simple_test_impl(arg, 0, 0); }
{ http_simple_test_impl(arg, 0, 0); }
static void
http_connection_retry_test_basic(void *arg, const char *addr, struct evdns_base *dns_base, int ssl)
@ -3798,16 +3797,16 @@ http_connection_retry_conn_address_test_impl(void *arg, int ssl)
/** dnsserver will be cleaned in http_connection_retry_test_basic() */
}
static void http_connection_retry_conn_address_test(void *arg)
{ return http_connection_retry_conn_address_test_impl(arg, 0); }
{ http_connection_retry_conn_address_test_impl(arg, 0); }
static void
http_connection_retry_test_impl(void *arg, int ssl)
{
return http_connection_retry_test_basic(arg, "127.0.0.1", NULL, ssl);
http_connection_retry_test_basic(arg, "127.0.0.1", NULL, ssl);
}
static void
http_connection_retry_test(void *arg)
{ return http_connection_retry_test_impl(arg, 0); }
{ http_connection_retry_test_impl(arg, 0); }
static void
http_primitives(void *ptr)
@ -4474,7 +4473,7 @@ http_write_during_read_test_impl(void *arg, int ssl)
evhttp_free(http);
}
static void http_write_during_read_test(void *arg)
{ return http_write_during_read_test_impl(arg, 0); }
{ http_write_during_read_test_impl(arg, 0); }
static void
http_request_own_test(void *arg)
@ -4526,35 +4525,35 @@ http_request_own_test(void *arg)
#ifdef EVENT__HAVE_OPENSSL
static void https_basic_test(void *arg)
{ return http_basic_test_impl(arg, 1); }
{ http_basic_test_impl(arg, 1); }
static void https_filter_basic_test(void *arg)
{ return http_basic_test_impl(arg, 1 | HTTP_SSL_FILTER); }
{ http_basic_test_impl(arg, 1 | HTTP_SSL_FILTER); }
static void https_incomplete_test(void *arg)
{ http_incomplete_test_(arg, 0, 1); }
static void https_incomplete_timeout_test(void *arg)
{ http_incomplete_test_(arg, 1, 1); }
static void https_simple_test(void *arg)
{ return http_simple_test_impl(arg, 1, 0); }
{ http_simple_test_impl(arg, 1, 0); }
static void https_simple_dirty_test(void *arg)
{ return http_simple_test_impl(arg, 1, 1); }
{ http_simple_test_impl(arg, 1, 1); }
static void https_connection_retry_conn_address_test(void *arg)
{ return http_connection_retry_conn_address_test_impl(arg, 1); }
{ http_connection_retry_conn_address_test_impl(arg, 1); }
static void https_connection_retry_test(void *arg)
{ return http_connection_retry_test_impl(arg, 1); }
{ http_connection_retry_test_impl(arg, 1); }
static void https_chunk_out_test(void *arg)
{ return http_chunk_out_test_impl(arg, 1); }
{ http_chunk_out_test_impl(arg, 1); }
static void https_filter_chunk_out_test(void *arg)
{ return http_chunk_out_test_impl(arg, 1 | HTTP_SSL_FILTER); }
{ http_chunk_out_test_impl(arg, 1 | HTTP_SSL_FILTER); }
static void https_stream_out_test(void *arg)
{ return http_stream_out_test_impl(arg, 1); }
{ http_stream_out_test_impl(arg, 1); }
static void https_connection_fail_test(void *arg)
{ return http_connection_fail_test_impl(arg, 1); }
{ http_connection_fail_test_impl(arg, 1); }
static void https_write_during_read_test(void *arg)
{ return http_write_during_read_test_impl(arg, 1); }
{ http_write_during_read_test_impl(arg, 1); }
static void https_connection_test(void *arg)
{ return http_connection_test_(arg, 0, "127.0.0.1", NULL, 0, AF_UNSPEC, 1); }
{ http_connection_test_(arg, 0, "127.0.0.1", NULL, 0, AF_UNSPEC, 1); }
static void https_persist_connection_test(void *arg)
{ return http_connection_test_(arg, 1, "127.0.0.1", NULL, 0, AF_UNSPEC, 1); }
{ http_connection_test_(arg, 1, "127.0.0.1", NULL, 0, AF_UNSPEC, 1); }
#endif
struct testcase_t http_testcases[] = {

View File

@ -437,6 +437,7 @@ void evutil_free_secure_rng_globals_(void);
void evutil_free_globals_(void);
#ifdef _WIN32
EVENT2_EXPORT_SYMBOL
HMODULE evutil_load_windows_system_library_(const TCHAR *library_name);
#endif