From 35455db82da9e701c7cf20d7b2c955511bec9987 Mon Sep 17 00:00:00 2001 From: ffs Upstream Date: Mon, 5 Aug 2024 14:38:22 -0500 Subject: [PATCH 1/3] ffs 2024-08-05 (58aece47) Code extracted from: https://github.com/GTkorvo/ffs.git at commit 58aece47a424eeb5f78769264ee0ee0e50be0456 (master). Upstream Shortlog ----------------- --- CMakeLists.txt | 2 +- fm/fm_formats.c | 2 +- version.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 09a8f77436..1bd4039bd9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,7 +7,7 @@ if(POLICY CMP0074) cmake_policy(SET CMP0074 NEW) endif() -project(FFS VERSION 3.1.2) +project(FFS VERSION 3.1.3) # Some boilerplate to setup nice output directories include(GNUInstallDirs) diff --git a/fm/fm_formats.c b/fm/fm_formats.c index b8263772f1..632c7efe40 100755 --- a/fm/fm_formats.c +++ b/fm/fm_formats.c @@ -3170,7 +3170,7 @@ extern int unix_timeout_read_func(void *conn, void *buffer, int length, int *errno_p, char **result_p); -#ifdef _MSC_VER +#ifdef _WIN32 #define srand48(x) srand((int)(x)) #define drand48() ((double)rand()/RAND_MAX) #define sleep(sec) Sleep(1000 * sec) diff --git a/version.c b/version.c index 9405d3c817..aa5a5417f6 100755 --- a/version.c +++ b/version.c @@ -1,6 +1,6 @@ #include -static char *FFS_version = "FFS Version 3.1.2 - Sun Aug 4 18:47:12 EDT 2024\n"; +static char *FFS_version = "FFS Version 3.1.3 - Mon Aug 5 14:59:11 EDT 2024\n"; void FFSprint_version() From d01efcdf5f1f181352ca80c69af7f816462bddab Mon Sep 17 00:00:00 2001 From: EVPath Upstream Date: Mon, 5 Aug 2024 14:53:29 -0500 Subject: [PATCH 2/3] EVPath 2024-08-05 (8e5fe233) Code extracted from: https://github.com/GTkorvo/EVPath.git at commit 8e5fe2331212a0fe220f20d73aeb8d5b80af69f9 (master). Upstream Shortlog ----------------- --- .indent.pro | 2 +- CMakeLists.txt | 35 +- chr_time.c | 2 +- cm.c | 33 +- cm_control.c | 4 +- cm_evol.c | 2 + cm_internal.h | 44 ++- cm_pbio.c | 2 + cm_perf.c | 2 + cm_schedule.h | 4 +- cm_threadio.c | 2 +- cm_util.c | 54 ++- cmdemo.c | 25 +- cmenet.c | 11 +- cmepoll.c | 130 ++----- cmib.c | 73 +--- cmmulticast.c | 10 +- cmselect.c | 30 +- cmsockets.c | 32 +- cmudp.c | 10 +- config.h.cmake | 6 + dfg_tests/auto_tree_test.c | 7 + dfg_tests/fail_chain_test.c | 7 + dfg_tests/self_reconfig_test.c | 7 + dfg_tests/tree_test.c | 7 + dlloader.c | 6 +- ev_dfg.c | 5 +- ev_internal.h | 2 +- evp.c | 10 +- gen_interface.pl | 692 +++++++++++++++++---------------- ip_config.c | 26 +- metrics.c | 4 +- mtests/cmconn.c | 6 +- mtests/cmping.c | 1 + mtests/cmtest.c | 1 + mtests/support.c | 39 +- qual_hostname.c | 2 + response.c | 6 +- rtests/evtest.c | 1 + rtests/extract_test.c | 1 + rtests/remote_terminal_test.c | 1 + tests/auto_test.c | 8 +- tests/block_test.c | 24 +- tests/bulktest.c | 31 +- tests/evtest.c | 9 +- tests/extract_test.c | 2 +- tests/support.c | 42 +- thin_server.c | 2 + version.c | 2 +- 49 files changed, 809 insertions(+), 655 deletions(-) diff --git a/.indent.pro b/.indent.pro index 7105acfffa..542b994d9c 100644 --- a/.indent.pro +++ b/.indent.pro @@ -1,4 +1,4 @@ -nbad -bap -nbc -br -c33 -cd33 -ncdb -ce -ci4 -brs --cli0 -cp33 -d0 -di1 -fc1 -fca -i4 -ip0 -l75 -lp +-cli0 -cp33 -d0 -di1 -fc1 -fca -i4 -ip0 -l120 -lp -npcs -psl -sc -nsob -nss -ts8 -TIOFile -TIOFormat -TIOConversionPtr -TIOFieldList -TIORecordType -TIOFieldPtr diff --git a/CMakeLists.txt b/CMakeLists.txt index 003f31325f..2aafc704e3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,7 +4,7 @@ cmake_minimum_required(VERSION 3.5) # GTKorvo set(CMAKE_DIRECTORY_LABELS EVPath) -project(EVPath VERSION 4.5.0 LANGUAGES C CXX) +project(EVPath VERSION 4.5.2 LANGUAGES C CXX) # Enable _ROOT variables for dependency searching # CMake v3.12 @@ -297,10 +297,13 @@ if(EVPATH_TRANSPORT_MODULES) add_library(cmselect MODULE cmselect.c) add_library(cmsockets MODULE cmsockets.c ip_config.c) - add_library(cmudp MODULE cmudp.c) - add_library(cmmulticast MODULE cmmulticast.c) - - foreach(M cmselect cmsockets cmudp cmmulticast) + list (APPEND tgts cmselect cmsockets) + if(NOT WIN32) + add_library(cmudp MODULE cmudp.c) + add_library(cmmulticast MODULE cmmulticast.c) + list (APPEND tgts cmudp cmmulticast) + endif() + foreach(M ${tgts}) set_target_properties(${M} PROPERTIES OUTPUT_NAME ${EVPATH_LIBRARY_PREFIX}${M} LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/${EVPATH_INSTALL_MODULE_DIR} @@ -310,10 +313,12 @@ if(EVPATH_TRANSPORT_MODULES) target_link_libraries(cmselect PRIVATE evpath_headers atl::atl) target_link_libraries(cmsockets PRIVATE evpath_headers atl::atl) - target_link_libraries(cmudp PRIVATE evpath_headers atl::atl) - target_link_libraries(cmmulticast PRIVATE evpath_headers atl::atl) - - list(APPEND EVPATH_TRANSPORT_TARGETS cmselect cmsockets cmudp cmmulticast) + list(APPEND EVPATH_TRANSPORT_TARGETS cmselect cmsockets) + if(NOT WIN32) + target_link_libraries(cmudp PRIVATE evpath_headers atl::atl) + target_link_libraries(cmmulticast PRIVATE evpath_headers atl::atl) + list (APPEND EVPATH_TRANSPORT_TARGETS cmudp cmmulticast) + endif() if (HAVE_SYS_EPOLL_H) add_library(cmepoll MODULE cmepoll.c) @@ -376,7 +381,7 @@ if (MSVC) set(EVPATH_USE_ZPL_ENET FALSE) endif() if(NOT (DEFINED EVPATH_USE_ZPL_ENET)) - option(EVPATH_USE_ZPL_ENET "Build the enet transport" "ON") + option(EVPATH_USE_ZPL_ENET "Build the zplenet transport" "OFF") endif() if(EVPATH_USE_ZPL_ENET) set(RUN_ZPL_ENET_TESTS TRUE) @@ -447,7 +452,7 @@ else() option(EVPATH_USE_LIBFABRIC "Build the libfabric transport" ${LIBFABRIC_FOUND}) endif() -if(LIBFABRIC_FOUND) +if(LIBFABRIC_FOUND AND NOT EVPATH_NO_RDMA) if(EVPATH_TRANSPORT_MODULES) add_library(cmfabric MODULE cmfabric.c ip_config.c) set_target_properties(cmfabric PROPERTIES @@ -485,7 +490,7 @@ else() option(EVPATH_USE_IBVERBS "Build the libfabric transport" ${IBVERBS_FOUND}) endif() set(HAVE_IBVERBS ${IBVERBS_FOUND}) -if(IBVERBS_FOUND) +if(IBVERBS_FOUND AND NOT EVPATH_NO_RDMA) if(BUILD_TESTING) if(NOT CMAKE_CROSSCOMPILING) message(STATUS "Check MEMLOCK rlimit for IB tests") @@ -548,7 +553,7 @@ if(IBVERBS_FOUND) find_package(NNTI) option(EVPATH_USE_NNTI "Build the nnti transport" ${NNTI_FOUND}) endif() - if(NNTI_FOUND) + if(NNTI_FOUND AND NOT EVPATH_NO_RDMA) if(CercsArch STREQUAL "ppc64") set(RUN_NNTI_TESTS FALSE) endif() @@ -571,7 +576,7 @@ if(IBVERBS_FOUND) endif() endif() else() - set(EVPATH_USE_NNTI FALSE "Build the nnti transport" FORCE) + set(EVPATH_USE_NNTI FALSE CACHE INTERNAL "Build the nnti transport" FORCE) endif() # Install extra find module dependencies @@ -604,6 +609,8 @@ CHECK_INCLUDE_FILE(hostlib.h HAVE_HOSTLIB_H) CHECK_INCLUDE_FILE(malloc.h HAVE_MALLOC_H) CHECK_INCLUDE_FILE(memory.h HAVE_MEMORY_H) CHECK_INCLUDE_FILE(netdb.h HAVE_NETDB_H) +CHECK_INCLUDE_FILE(netinet/in.h HAVE_NETINET_IN_H) +CHECK_INCLUDE_FILE(arpa/inet.h HAVE_ARPA_INET_H) CHECK_INCLUDE_FILE(sockLib.h HAVE_SOCKLIB_H) CHECK_INCLUDE_FILE(stdarg.h STDC_HEADERS) CHECK_INCLUDE_FILE(stdint.h HAVE_STDINT_H) diff --git a/chr_time.c b/chr_time.c index 0cbd146b6d..55db08ec5f 100644 --- a/chr_time.c +++ b/chr_time.c @@ -5,7 +5,7 @@ #ifdef HAVE_SYS_TIME_H #include #endif -#ifdef _MSC_VER +#ifdef _WIN32 #include #include #include diff --git a/cm.c b/cm.c index e1bb4fdc9e..12179f2df4 100644 --- a/cm.c +++ b/cm.c @@ -17,9 +17,13 @@ #include #include #ifdef HAVE_WINDOWS_H +#ifndef FD_SETSIZE #define FD_SETSIZE 1024 +#endif #include #define __ANSI_CPP__ +#define lrand48() rand() +#define srand48(x) srand((unsigned int)(x)) #else #include #include @@ -60,6 +64,7 @@ extern void libcmselect_LTX_select_stop(CMtrans_services svc,void *client_data); static void CMinitialize (CManager cm); static atom_t CM_TRANSPORT = -1; +static atom_t CM_CMANAGER_ID = -1; static atom_t CM_NETWORK_POSTFIX = -1; static atom_t CM_CONN_BLOCKING = -1; atom_t CM_REBWM_RLEN = -1; @@ -232,7 +237,7 @@ static thr_thread_t thr_fork(void*(*func)(void*), void *arg) { thr_thread_t new_thread = 0; - int err = thr_thread_create(&new_thread, NULL, (void*(*)(void*))func, arg); + int err = thr_thread_create(&new_thread, NULL, (void*)func, arg); if (err != 0) { return (thr_thread_t) (intptr_t)NULL; } else { @@ -258,7 +263,7 @@ INT_CMfork_comm_thread(CManager cm) if (server_thread == (thr_thread_t)(intptr_t) NULL) { return 0; } - cm->control_list->server_thread = server_thread; + cm->control_list->server_thread = thr_get_thread_id(server_thread); cm->control_list->has_thread = 1; cm->reference_count++; CMtrace_out(cm, CMFreeVerbose, "Forked - CManager %p ref count now %d\n", @@ -575,6 +580,7 @@ CMinternal_listen(CManager cm, attr_list listen_info, int try_others) attrs = (*trans_list)->listen(cm, &CMstatic_trans_svcs, *trans_list, listen_info); + add_attr(attrs, CM_CMANAGER_ID, Attr_Int4, (intptr_t)cm->CManager_ID); if (iface) { add_string_attr(attrs, CM_IP_INTERFACE, strdup(iface)); } @@ -752,6 +758,7 @@ INT_CManager_create_control(char *control_module) if (atom_init == 0) { CM_TRANSPORT = attr_atom_from_string("CM_TRANSPORT"); + CM_CMANAGER_ID = attr_atom_from_string("CM_CMANAGER_ID"); CM_NETWORK_POSTFIX = attr_atom_from_string("CM_NETWORK_POSTFIX"); CM_CONN_BLOCKING = attr_atom_from_string("CM_CONN_BLOCKING"); CM_REBWM_RLEN = attr_atom_from_string("CM_REG_BW_RUN_LEN"); @@ -772,6 +779,9 @@ INT_CManager_create_control(char *control_module) cm->transports = NULL; cm->initialized = 0; cm->reference_count = 1; + uint64_t seed = getpid() + time(NULL); + srand48(seed); + cm->CManager_ID = (int)lrand48(); char *tmp; if ((tmp = getenv("CMControlModule"))) { @@ -1053,7 +1063,7 @@ CManager_free(CManager cm) new_list->select_data = NULL; new_list->add_select = NULL; new_list->remove_select = NULL; - new_list->server_thread = (thr_thread_t)(intptr_t) NULL; + new_list->server_thread = (thr_thread_id)0; new_list->network_blocking_function.func = NULL; new_list->network_polling_function.func = NULL; new_list->polling_function_list = NULL; @@ -1490,7 +1500,7 @@ INT_CMget_ip_config_diagnostics(CManager cm) msg[0] = 0x434d4800; /* CMH\0 */ msg[1] = (CURRENT_HANDSHAKE_VERSION << 24) + sizeof(msg); msg[2] = cm->FFSserver_identifier; - msg[3] = 5; /* not implemented yet */ + msg[3] = cm->CManager_ID; msg[4] = 0; /* not implemented yet */ if (conn->remote_format_server_ID != 0) { /* set high bit if we already have his ID */ @@ -1691,12 +1701,16 @@ timeout_conn(CManager cm, void *client_data) fprintf(cm->CMTrace_file, "In CMinternal_get_conn, attrs "); if (attrs) fdump_attr_list(cm->CMTrace_file, attrs); else fprintf(cm->CMTrace_file, "\n"); } + int target_cm_id = -1; + (void) get_int_attr(attrs, CM_CMANAGER_ID, &target_cm_id); for (i=0; iconnection_count; i++) { CMConnection tmp = cm->connections[i]; if (tmp->closed || tmp->failed) continue; - if (tmp->trans->connection_eq(cm, &CMstatic_trans_svcs, - tmp->trans, attrs, - tmp->transport_data)) { + + if ((tmp->remote_CManager_ID == target_cm_id) || + tmp->trans->connection_eq(cm, &CMstatic_trans_svcs, + tmp->trans, attrs, + tmp->transport_data)) { CMtrace_out(tmp->cm, CMFreeVerbose, "internal_get_conn found conn=%p ref count will be %d\n", tmp, tmp->conn_ref_count +1); @@ -2088,6 +2102,7 @@ timeout_conn(CManager cm, void *client_data) if (cm_preread_hook) { do_read = cm_preread_hook(buffer_full_point - buffer_data_end, tmp_message_buffer); } + CMtrace_out(cm, CMLowLevelVerbose, "P5\n"); if (do_read) { if (trans->read_to_buffer_func) { /* @@ -3851,7 +3866,7 @@ CM_init_select(CMControlList cl, CManager cm) } CMtrace_out(cm, CMLowLevelVerbose, "CM - Forked comm thread %p\n", (void*)(intptr_t)server_thread); - cm->control_list->server_thread = server_thread; + cm->control_list->server_thread = thr_get_thread_id(server_thread); cm->control_list->cl_reference_count++; cm->control_list->free_reference_count++; cl->has_thread = 1; @@ -3968,7 +3983,7 @@ int offset_compare(const void* lhsv, const void* rhsv) return lhs->offset.tv_usec - rhs->offset.tv_usec; } -#ifdef _MSC_VER +#ifdef _WIN32 static inline void timeradd(struct timeval *a, struct timeval *b, struct timeval *res) { diff --git a/cm_control.c b/cm_control.c index 4344aedf6c..63862ea49a 100644 --- a/cm_control.c +++ b/cm_control.c @@ -242,7 +242,7 @@ INT_CMCondition_wait(CManager cm, int condition) (void*)(intptr_t)cl->server_thread); } if (!cl->has_thread) { - if ((cl->server_thread == (thr_thread_t) (intptr_t) NULL) || (cl->server_thread == thr_thread_self())) { + if ((cl->server_thread == (thr_thread_id) 0) || (cl->server_thread == thr_thread_self())) { cl->cond_polling = 1; while (!(cond->signaled || cond->failed)) { if (cm_control_debug_flag) { @@ -255,7 +255,7 @@ INT_CMCondition_wait(CManager cm, int condition) fprintf(cm->CMTrace_file, "CMLowLevel after Polling for CMcondition %d\n", condition); } /* the poll and handle will set cl->server_thread, restore it */ - cl->server_thread = (thr_thread_t) (intptr_t)NULL; + cl->server_thread = (thr_thread_id) (intptr_t)NULL; if (cm_control_debug_flag) { fprintf(cm->CMTrace_file, "CMLowLevel In condition wait, reset server thread = %lx\n", (long)cl->server_thread); diff --git a/cm_evol.c b/cm_evol.c index dc62cddc39..8a46ae661c 100644 --- a/cm_evol.c +++ b/cm_evol.c @@ -11,7 +11,9 @@ #endif #include #ifdef HAVE_WINDOWS_H +#ifndef FD_SETSIZE #define FD_SETSIZE 1024 +#endif #include #define __ANSI_CPP__ #else diff --git a/cm_internal.h b/cm_internal.h index 173a1ce366..0837a2ed95 100644 --- a/cm_internal.h +++ b/cm_internal.h @@ -15,6 +15,8 @@ #include #define thr_mutex_t pthread_mutex_t #define thr_thread_t pthread_t +#define thr_thread_id thr_thread_t +#define thr_get_thread_id(t) (t) #define thr_condition_t pthread_cond_t #define thr_thread_self() pthread_self() #define thr_thread_exit(status) pthread_exit(status); @@ -34,24 +36,35 @@ #else //#include #include -#define thr_mutex_t HANDLE -#define thr_thread_t DWORD -#define thr_condition_t HANDLE -#define thr_thread_create(w,x,y,z) 0 +extern int win_thread_create(HANDLE* w, void* x, void* y, void* z); +extern void win_mutex_init(SRWLOCK *m); +extern void win_mutex_lock(SRWLOCK* m); +extern void win_mutex_unlock(SRWLOCK* m); +extern void win_mutex_free(SRWLOCK* m); +extern void win_condition_init(CONDITION_VARIABLE *c); +extern void win_condition_wait(CONDITION_VARIABLE *c, SRWLOCK *m); +extern void win_condition_signal(CONDITION_VARIABLE *c); +extern void win_condition_free(CONDITION_VARIABLE *c); +#define thr_mutex_t SRWLOCK +#define thr_thread_t HANDLE +#define thr_thread_id DWORD +#define thr_condition_t CONDITION_VARIABLE +#define thr_thread_create(w,x,y,z) win_thread_create(w,x,y,z) #define thr_thread_self() GetCurrentThreadId() -#define thr_thread_exit(status) +#define thr_thread_exit(status) ExitThread((DWORD)(intptr_t)status) +#define thr_get_thread_id(t) GetThreadId(t) #define thr_thread_detach(thread) #define thr_thread_yield() #define thr_thread_join(t, s) (void)s -#define thr_mutex_init(m) -#define thr_mutex_lock(m) -#define thr_mutex_unlock(m) -#define thr_mutex_free(m) -#define thr_condition_init(c) -#define thr_condition_wait(c, m) -#define thr_condition_signal(c) -#define thr_condition_broadcast(c) -#define thr_condition_free(c) +#define thr_mutex_init(m) win_mutex_init(&m) +#define thr_mutex_lock(m) win_mutex_lock(&m) +#define thr_mutex_unlock(m) win_mutex_unlock(&m) +#define thr_mutex_free(m) win_mutex_free(&m) +#define thr_condition_init(c) win_condition_init(&c) +#define thr_condition_wait(c, m) win_condition_wait(&c, &m) +#define thr_condition_signal(c) win_condition_signal(&c) +#define thr_condition_broadcast(c) error +#define thr_condition_free(c) win_condition_free(&c) #endif #include @@ -138,6 +151,7 @@ typedef struct _CManager { int initialized; int reference_count; char *control_module_choice; /* this is static, doesn't need to be free'd */ + int CManager_ID; CMControlList control_list; /* the control list for this DE */ @@ -240,7 +254,7 @@ typedef struct _CMControlList { int closed; int has_thread; int cond_polling; - thr_thread_t server_thread; + thr_thread_id server_thread; } CMControlList_s; struct queued_data_rec { diff --git a/cm_pbio.c b/cm_pbio.c index 84aedbc777..1dd42f9688 100644 --- a/cm_pbio.c +++ b/cm_pbio.c @@ -8,7 +8,9 @@ #endif #include #ifdef HAVE_WINDOWS_H +#ifndef FD_SETSIZE #define FD_SETSIZE 1024 +#endif #include #else #include diff --git a/cm_perf.c b/cm_perf.c index 30bce15e4b..0f3770b2bf 100644 --- a/cm_perf.c +++ b/cm_perf.c @@ -12,7 +12,9 @@ #endif #include #ifdef HAVE_WINDOWS_H +#ifndef FD_SETSIZE #define FD_SETSIZE 1024 +#endif #include #define __ANSI_CPP__ #else diff --git a/cm_schedule.h b/cm_schedule.h index 8b2132b373..9dff2ad785 100644 --- a/cm_schedule.h +++ b/cm_schedule.h @@ -7,8 +7,10 @@ extern "C" { #endif -#ifdef _MSC_VER +#ifdef __WIN32 +#ifndef FD_SETSIZE #define FD_SETSIZE 1024 +#endif #include #endif typedef struct _avail_period { diff --git a/cm_threadio.c b/cm_threadio.c index 08441bbd12..ba64380d44 100644 --- a/cm_threadio.c +++ b/cm_threadio.c @@ -46,7 +46,7 @@ static thr_thread_t thr_fork(void*(*func)(void*), void *arg) { thr_thread_t new_thread = 0; - int err = thr_thread_create(&new_thread, NULL, (void*(*)(void*))func, arg); + int err = thr_thread_create(&new_thread, 0, (void*)func, arg); if (err != 0) { return (thr_thread_t) (intptr_t) NULL; } else { diff --git a/cm_util.c b/cm_util.c index d6509555db..082f1f0e31 100644 --- a/cm_util.c +++ b/cm_util.c @@ -1,5 +1,4 @@ #include "config.h" -#ifndef MODULE #include #ifdef HAVE_UNISTD_H @@ -12,11 +11,7 @@ #include #endif #include -#else -#include "kernel/kcm.h" -#include "kernel/cm_kernel.h" -#include "kernel/library.h" -#endif + #include "atl.h" #include "evpath.h" #include "chr_time.h" @@ -297,3 +292,50 @@ INT_CMfree(void *ptr) free(ptr); } +#ifdef _MSC_VER +#include +#include +#include +int +win_thread_create(HANDLE *threadp, void *attr, void *startfunc, void *arg) +{ + HANDLE h = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)startfunc, arg, 0, attr); + (*threadp) = h; + return 0; +} +void win_mutex_init(SRWLOCK *m) +{ + InitializeSRWLock(m); +} + + +void win_mutex_lock(SRWLOCK *m) +{ + AcquireSRWLockExclusive(m); +} +void win_mutex_unlock(SRWLOCK *m) +{ + ReleaseSRWLockExclusive(m); +} +void win_mutex_free(SRWLOCK *m) +{ + // nothing necessary +} +extern void win_condition_init(CONDITION_VARIABLE *c) +{ + InitializeConditionVariable(c); +} +extern void win_condition_wait(CONDITION_VARIABLE *c, SRWLOCK* m) +{ + SleepConditionVariableSRW(c, m, INFINITE, 0); +} + +extern void win_condition_signal(CONDITION_VARIABLE *c) +{ + WakeConditionVariable(c); +} +extern void win_condition_free(CONDITION_VARIABLE *c) +{ + // nothing necessary +} +#endif diff --git a/cmdemo.c b/cmdemo.c index bc9cc90db7..b4ee139b7f 100644 --- a/cmdemo.c +++ b/cmdemo.c @@ -25,14 +25,12 @@ typedef struct _nested_rec { complex item; } nested, *nested_ptr; -static IOField nested_field_list[] = -{ +static IOField nested_field_list[] = { {"item", "complex", sizeof(complex), IOOffset(nested_ptr, item)}, {NULL, NULL, 0, 0} }; -static IOField complex_field_list[] = -{ +static IOField complex_field_list[] = { {"r", "double", sizeof(double), IOOffset(complex_ptr, r)}, {"i", "double", sizeof(double), IOOffset(complex_ptr, i)}, {NULL, NULL, 0, 0} @@ -48,8 +46,7 @@ typedef struct _simple_rec { int scan_sum; } simple_rec, *simple_rec_ptr; -static IOField simple_field_list[] = -{ +static IOField simple_field_list[] = { {"integer_field", "integer", sizeof(int), IOOffset(simple_rec_ptr, integer_field)}, {"short_field", "integer", @@ -67,15 +64,14 @@ static IOField simple_field_list[] = {NULL, NULL, 0, 0} }; -static CMFormatRec simple_format_list[] = -{ +static CMFormatRec simple_format_list[] = { {"complex", complex_field_list}, {"nested", nested_field_list}, {NULL, NULL} }; static -void + void generate_record(event) simple_rec_ptr event; { @@ -103,7 +99,7 @@ simple_rec_ptr event; int quiet = -1; static -void + void simple_handler(cm, conn, vevent, client_data, attrs) CManager cm; CMConnection conn; @@ -123,8 +119,7 @@ attr_list attrs; sum = sum % 100; scan_sum = event->scan_sum; if (sum != scan_sum) { - printf("Received record checksum does not match. expected %d, got %d\n", - (int) sum, (int) scan_sum); + printf("Received record checksum does not match. expected %d, got %d\n", (int) sum, (int) scan_sum); } if ((quiet <= 0) || (sum != scan_sum)) { printf("In the handler, event data is :\n"); @@ -168,8 +163,7 @@ char **argv; CMlisten_specific(cm, listen_list); contact_list = CMget_contact_list(cm); printf("Contact list \"%s\"\n", attr_list_to_string(contact_list)); - format = CMregister_format(cm, "simple", simple_field_list, - simple_format_list); + format = CMregister_format(cm, "simple", simple_field_list, simple_format_list); CMregister_handler(format, simple_handler, NULL); CMsleep(cm, 120); } else { @@ -186,8 +180,7 @@ char **argv; exit(1); } } - format = CMregister_format(cm, "simple", simple_field_list, - simple_format_list); + format = CMregister_format(cm, "simple", simple_field_list, simple_format_list); generate_record(&data); attrs = create_attr_list(); #define CMDEMO_TEST_ATOM ATL_CHAR_CONS('C','\115','\104','t') diff --git a/cmenet.c b/cmenet.c index eeac56f3e5..71d2eba533 100644 --- a/cmenet.c +++ b/cmenet.c @@ -6,7 +6,9 @@ #undef NDEBUG #ifdef HAVE_WINDOWS_H +#ifndef FD_SETSIZE #define FD_SETSIZE 1024 +#endif #include #include #include @@ -39,8 +41,12 @@ #ifdef HAVE_STREAMS_UN_H #include #endif +#ifdef HAVE_NETINET_IN_H #include +#endif +#ifdef HAVE_ARPA_INET_H #include +#endif #ifdef HAVE_NETDB_H #include #endif @@ -189,9 +195,6 @@ extern void ZPLENETdummy() { // for warning suppression #define INTERFACE_NAME(NAME) libcmenet_LTX_ ## NAME #include #endif -#ifndef _MSC_VER -#include -#endif #include #ifdef HAVE_SYS_TIME_H #include @@ -1414,7 +1417,7 @@ int err; * NT Sux. */ -int +static int pipe(filedes) SOCKET filedes[2]; { diff --git a/cmepoll.c b/cmepoll.c index b28fca2790..7b2513eb96 100644 --- a/cmepoll.c +++ b/cmepoll.c @@ -3,7 +3,9 @@ #include #ifdef HAVE_WINDOWS_H +#ifndef FD_SETSIZE #define FD_SETSIZE 1024 +#endif #include #include #include @@ -114,10 +116,7 @@ static char*WSAerror_str(int err); #endif static void -init_select_data(svc, sdp, cm) -CMtrans_services svc; -select_data_ptr *sdp; -CManager cm; +init_select_data(CMtrans_services svc, select_data_ptr *sdp, CManager cm) { select_data_ptr sd = malloc(sizeof(struct select_data)); *sdp = sd; @@ -157,9 +156,7 @@ typedef struct _periodic_task { } task_handle_s; static void -free_epoll_data(svc, sdp) -CMtrans_services svc; -select_data_ptr *sdp; +free_epoll_data(CMtrans_services svc, select_data_ptr *sdp) { periodic_task_handle tasks; select_data_ptr sd = *sdp; @@ -184,10 +181,7 @@ select_data_ptr *sdp; ((tvp)->tv_usec cmp (uvp)->tv_usec)))) static void -set_soonest_timeout(timeout, task_list, now) -struct timeval *timeout; -periodic_task_handle task_list; -struct timeval now; +set_soonest_timeout(struct timeval *timeout, periodic_task_handle task_list, struct timeval now) { struct timeval this_delay; if (task_list == NULL) return; @@ -210,10 +204,7 @@ struct timeval now; } static void -increment_time(time, increment_sec, increment_usec) -struct timeval *time; -int increment_sec; -int increment_usec; +increment_time(struct timeval *time, int increment_sec, int increment_usec) { time->tv_usec += increment_usec; time->tv_sec += increment_sec; @@ -227,11 +218,7 @@ static void shutdown_wake_mechanism(select_data_ptr sd); static void -socket_select(svc, sd, timeout_sec, timeout_usec) -CMtrans_services svc; -select_data_ptr sd; -int timeout_sec; -int timeout_usec; +socket_select(CMtrans_services svc, select_data_ptr sd, int timeout_sec, int timeout_usec) { int i, res; int fd; @@ -475,13 +462,7 @@ int timeout_usec; } extern void -libcmepoll_LTX_add_select(svc, sdp, fd, func, arg1, arg2) -CMtrans_services svc; -select_data_ptr *sdp; -int fd; -select_list_func func; -void *arg1; -void *arg2; +libcmepoll_LTX_add_select(CMtrans_services svc, select_data_ptr *sdp, int fd, select_list_func func, void *arg1, void *arg2) { select_data_ptr sd = *((select_data_ptr *)sdp); struct epoll_event ep_event; @@ -540,13 +521,7 @@ void *arg2; } extern void -libcmepoll_LTX_write_select(svc, sdp, fd, func, arg1, arg2) -CMtrans_services svc; -select_data_ptr *sdp; -int fd; -select_list_func func; -void *arg1; -void *arg2; +libcmepoll_LTX_write_select(CMtrans_services svc, select_data_ptr *sdp, int fd, select_list_func func, void *arg1, void *arg2) { select_data_ptr sd = *((select_data_ptr *)sdp); struct epoll_event ep_event; @@ -616,15 +591,7 @@ void *arg2; } extern periodic_task_handle -libcmepoll_LTX_add_periodic(svc, sdp, interval_sec, interval_usec, - func, arg1, arg2) -CMtrans_services svc; -select_data_ptr *sdp; -int interval_sec; -int interval_usec; -select_list_func func; -void *arg1; -void *arg2; +libcmepoll_LTX_add_periodic(CMtrans_services svc, select_data_ptr *sdp, int interval_sec, int interval_usec, select_list_func func, void *arg1, void *arg2) { select_data_ptr sd = *((select_data_ptr *)sdp); periodic_task_handle handle = malloc(sizeof(struct _periodic_task)); @@ -671,15 +638,7 @@ void *arg2; extern periodic_task_handle -libcmepoll_LTX_add_delayed_task(svc, sdp, delay_sec, delay_usec, - func, arg1, arg2) -CMtrans_services svc; -select_data_ptr *sdp; -int delay_sec; -int delay_usec; -select_list_func func; -void *arg1; -void *arg2; +libcmepoll_LTX_add_delayed_task(CMtrans_services svc, select_data_ptr *sdp, int delay_sec, int delay_usec, select_list_func func, void *arg1, void *arg2) { select_data_ptr sd = *((select_data_ptr *)sdp); periodic_task_handle handle = malloc(sizeof(struct _periodic_task)); @@ -725,9 +684,7 @@ void *arg2; } static int -remove_periodic_task(sd, handle) -select_data_ptr sd; -periodic_task_handle handle; +remove_periodic_task(select_data_ptr sd, periodic_task_handle handle) { periodic_task_handle list, last = NULL; list = sd->periodic_task_list; @@ -765,10 +722,7 @@ periodic_task_handle handle; extern void -libcmepoll_LTX_remove_periodic(svc, sdp, handle) -CMtrans_services svc; -select_data_ptr *sdp; -periodic_task_handle handle; +libcmepoll_LTX_remove_periodic(CMtrans_services svc, select_data_ptr *sdp, periodic_task_handle handle) { select_data_ptr sd = *((select_data_ptr *)sdp); if (sd == NULL) return; @@ -778,10 +732,7 @@ periodic_task_handle handle; } extern void -libcmepoll_LTX_remove_select(svc, sdp, fd) -CMtrans_services svc; -select_data_ptr *sdp; -int fd; +libcmepoll_LTX_remove_select(CMtrans_services svc, select_data_ptr *sdp, int fd) { select_data_ptr sd = *((select_data_ptr *)sdp); @@ -812,8 +763,7 @@ int fd; } static void -shutdown_wake_mechanism(sd) -select_data_ptr sd; +shutdown_wake_mechanism(select_data_ptr sd) { if (sd->wake_read_fd == -1) return; close(sd->wake_read_fd); @@ -821,9 +771,7 @@ select_data_ptr sd; sd->wake_read_fd = sd->wake_write_fd = -1; } -static void read_wake_fd(fd_as_ptr, junk) -void *fd_as_ptr; -void *junk; +static void read_wake_fd(void *fd_as_ptr, void *junk) { char buffer; int fd = (int) (long)fd_as_ptr; @@ -838,8 +786,7 @@ void *junk; #ifdef HAVE_WINDOWS_H static char* -WSAerror_str(err) -int err; +WSAerror_str(int err) { switch(err) { case WSAEINTR: return "WSAEINTR"; @@ -900,9 +847,8 @@ int err; * NT Sux. */ -int -pipe(filedes) -int filedes[2]; +static int +pipe(int filedes[2]) { int length; @@ -990,9 +936,7 @@ int filedes[2]; #endif static void -setup_wake_mechanism(svc, sdp) -CMtrans_services svc; -select_data_ptr *sdp; +setup_wake_mechanism(CMtrans_services svc, select_data_ptr *sdp) { int filedes[2]; @@ -1015,9 +959,7 @@ select_data_ptr *sdp; } extern void -libcmepoll_LTX_wake_function(svc, sdp) -CMtrans_services svc; -select_data_ptr *sdp; +libcmepoll_LTX_wake_function(CMtrans_services svc, select_data_ptr *sdp) { if (*sdp != NULL) { wake_server_thread(*sdp); @@ -1025,8 +967,7 @@ select_data_ptr *sdp; } static void -wake_server_thread(sd) -select_data_ptr sd; +wake_server_thread(select_data_ptr sd) { static char buffer = 'W'; /* doesn't matter what we write */ if (sd->wake_write_fd != -1) { @@ -1041,9 +982,7 @@ select_data_ptr sd; } extern void -libcmepoll_LTX_blocking_function(svc, client_data) -CMtrans_services svc; -void *client_data; +libcmepoll_LTX_blocking_function(CMtrans_services svc, void *client_data) { select_data_ptr sd = *((select_data_ptr *)client_data); if (sd == NULL) { @@ -1058,9 +997,7 @@ void *client_data; } extern void -libcmepoll_LTX_polling_function(svc, client_data) -CMtrans_services svc; -void *client_data; +libcmepoll_LTX_polling_function(CMtrans_services svc, void *client_data) { select_data_ptr sd = *((select_data_ptr *)client_data); if (sd == NULL) { @@ -1075,10 +1012,7 @@ void *client_data; } extern void -libcmepoll_LTX_select_initialize(svc, cm, client_data) -CMtrans_services svc; -CManager cm; -void *client_data; +libcmepoll_LTX_select_initialize(CMtrans_services svc, CManager cm, void *client_data) { if (*((select_data_ptr *)client_data) == NULL) { init_select_data(svc, (select_data_ptr*)client_data, cm); @@ -1086,10 +1020,7 @@ void *client_data; } extern void -libcmepoll_LTX_select_shutdown(svc, cm, client_data) -CMtrans_services svc; -CManager cm; -void *client_data; +libcmepoll_LTX_select_shutdown(CMtrans_services svc, CManager cm, void *client_data) { select_data_ptr *sdp = client_data; select_data_ptr sd = *sdp; @@ -1103,10 +1034,7 @@ void *client_data; } extern void -libcmepoll_LTX_select_free(svc, cm, client_data) -CMtrans_services svc; -CManager cm; -void *client_data; +libcmepoll_LTX_select_free(CMtrans_services svc, CManager cm, void *client_data) { select_data_ptr *sdp = client_data; select_data_ptr sd = *sdp; @@ -1119,9 +1047,7 @@ void *client_data; } extern void -libcmepoll_LTX_select_stop(svc, client_data) -CMtrans_services svc; -void *client_data; +libcmepoll_LTX_select_stop(CMtrans_services svc, void *client_data) { if (*((select_data_ptr *)client_data) != NULL) { (*((select_data_ptr*)client_data))->closed = 1; diff --git a/cmib.c b/cmib.c index 6cfd7c828f..4d81a1d5ba 100644 --- a/cmib.c +++ b/cmib.c @@ -3,7 +3,9 @@ #include #ifdef HAVE_WINDOWS_H +#ifndef FD_SETSIZE #define FD_SETSIZE 1024 +#endif #include #include #define getpid() _getpid() @@ -369,9 +371,7 @@ static inline uint16_t get_local_lid(struct ibv_context *context, int port) } static int -check_host(hostname, sin_addr) - char *hostname; -void *sin_addr; +check_host(char *hostname,void *sin_addr) { struct hostent *host_addr; host_addr = gethostbyname(hostname); @@ -393,8 +393,7 @@ void *sin_addr; } static ib_conn_data_ptr -create_ib_conn_data(svc) - CMtrans_services svc; +create_ib_conn_data(CMtrans_services svc) { ib_conn_data_ptr ib_conn_data = svc->malloc_func(sizeof(struct ib_connection_data)); memset(ib_conn_data, 0, sizeof(struct ib_connection_data)); @@ -946,9 +945,7 @@ CMIB_data_available(transport_entry trans, CMConnection conn) * Accept socket connection */ static void -ib_accept_conn(void_trans, void_conn_sock) - void *void_trans; -void *void_conn_sock; +ib_accept_conn(void *void_trans, void *void_conn_sock) { transport_entry trans = (transport_entry) void_trans; int conn_sock = (int) (long) void_conn_sock; @@ -1106,9 +1103,7 @@ void *void_conn_sock; } extern void -libcmib_LTX_shutdown_conn(svc, scd) - CMtrans_services svc; -ib_conn_data_ptr scd; +libcmib_LTX_shutdown_conn(CMtrans_services svc, ib_conn_data_ptr scd) { svc->trace_out(scd->sd->cm, "CMIB shutdown_conn, removing select %d\n", scd->fd); @@ -1141,14 +1136,7 @@ is_private_10(int IP) } static int -initiate_conn(cm, svc, trans, attrs, ib_conn_data, conn_attr_list, no_more_redirect) - CManager cm; -CMtrans_services svc; -transport_entry trans; -attr_list attrs; -ib_conn_data_ptr ib_conn_data; -attr_list conn_attr_list; -int no_more_redirect; +initiate_conn(CManager cm, CMtrans_services svc, transport_entry trans, attr_list attrs, ib_conn_data_ptr ib_conn_data, attr_list conn_attr_list, int no_more_redirect) { int sock; @@ -1413,11 +1401,7 @@ int no_more_redirect; * (name_str stores the machine name). */ extern CMConnection -libcmib_LTX_initiate_conn(cm, svc, trans, attrs) - CManager cm; -CMtrans_services svc; -transport_entry trans; -attr_list attrs; +libcmib_LTX_initiate_conn(CManager cm, CMtrans_services svc, transport_entry trans, attr_list attrs) { ib_conn_data_ptr ib_conn_data = create_ib_conn_data(svc); attr_list conn_attr_list = create_attr_list(); @@ -1447,11 +1431,7 @@ attr_list attrs; * same as ours and if the IP_PORT matches the one we are listening on. */ extern int -libcmib_LTX_self_check(cm, svc, trans, attrs) - CManager cm; -CMtrans_services svc; -transport_entry trans; -attr_list attrs; +libcmib_LTX_self_check(CManager cm, CMtrans_services svc, transport_entry trans, attr_list attrs) { ib_client_data_ptr sd = trans->trans_data; @@ -1499,12 +1479,9 @@ attr_list attrs; } extern int -libcmib_LTX_connection_eq(cm, svc, trans, attrs, scd) - CManager cm; -CMtrans_services svc; -transport_entry trans; -attr_list attrs; -ib_conn_data_ptr scd; +libcmib_LTX_connection_eq(CManager cm, CMtrans_services svc, + transport_entry trans, attr_list attrs, + ib_conn_data_ptr scd) { int int_port_num; @@ -1548,11 +1525,8 @@ ib_conn_data_ptr scd; * Create an IP socket for connection from other CMs */ extern attr_list -libcmib_LTX_non_blocking_listen(cm, svc, trans, listen_info) - CManager cm; -CMtrans_services svc; -transport_entry trans; -attr_list listen_info; +libcmib_LTX_non_blocking_listen(CManager cm, CMtrans_services svc, + transport_entry trans, attr_list listen_info) { ib_client_data_ptr sd = trans->trans_data; unsigned int length; @@ -1714,11 +1688,8 @@ struct iovec { #endif extern void -libcmib_LTX_set_write_notify(trans, svc, scd, enable) - transport_entry trans; -CMtrans_services svc; -ib_conn_data_ptr scd; -int enable; +libcmib_LTX_set_write_notify(transport_entry trans, CMtrans_services svc, + ib_conn_data_ptr scd, int enable) { if (enable != 0) { svc->fd_write_select(trans->cm, scd->fd, (select_list_func) trans->write_possible, @@ -1910,12 +1881,8 @@ libcmib_LTX_writev_complete_notify_func(CMtrans_services svc, } extern int -libcmib_LTX_writev_func(svc, scd, iovs, iovcnt, attrs) -CMtrans_services svc; -ib_conn_data_ptr scd; -void *iovs; -int iovcnt; -attr_list attrs; +libcmib_LTX_writev_func(CMtrans_services svc, ib_conn_data_ptr scd, + void *iovs, int iovcnt, attr_list attrs) { return libcmib_LTX_writev_complete_notify_func(svc, scd, iovs, iovcnt, attrs, NULL, NULL); @@ -1934,9 +1901,7 @@ free_ib_data(CManager cm, void *sdv) } extern void * -libcmib_LTX_initialize(cm, svc) - CManager cm; -CMtrans_services svc; +libcmib_LTX_initialize(CManager cm, CMtrans_services svc) { static int atom_init = 0; diff --git a/cmmulticast.c b/cmmulticast.c index 03acd641e7..e17e5a0373 100644 --- a/cmmulticast.c +++ b/cmmulticast.c @@ -3,12 +3,12 @@ #include #ifdef HAVE_WINDOWS_H +#ifndef FD_SETSIZE #define FD_SETSIZE 1024 +#endif #include #include #include -#define getpid() _getpid() -#define close(x) closesocket(x) #else #ifdef HAVE_SYS_TIME_H #include @@ -60,6 +60,10 @@ #ifdef HAVE_MEMORY_H #include #endif +#ifdef _WIN32 +#define getpid() _getpid() +#define close(x) closesocket(x) +#endif #include #include "evpath.h" @@ -449,7 +453,7 @@ libcmmulticast_LTX_writev_func(CMtrans_services svc, mcast_conn_data_ptr mcd, st } #ifdef HAVE_WINDOWS_H -int socket_global_init = 0; +static int socket_global_init = 0; /* Winsock init stuff, ask for ver 1.1 */ static WORD wVersionRequested = MAKEWORD(1, 1); static WSADATA wsaData; diff --git a/cmselect.c b/cmselect.c index baf9409df6..2b9403809d 100644 --- a/cmselect.c +++ b/cmselect.c @@ -3,7 +3,9 @@ #include #ifdef HAVE_WINDOWS_H +#ifndef FD_SETSIZE #define FD_SETSIZE 1024 +#endif #include #include #include @@ -109,7 +111,7 @@ typedef struct func_list_item { } FunctionListElement; typedef struct select_data { - thr_thread_t server_thread; + thr_thread_id server_thread; void *fdset; /* bitmap of the fds for read select */ void *write_set; /* bitmap of the fds for write select */ @@ -153,7 +155,7 @@ init_select_data(CMtrans_services svc, select_data_ptr *sdp, CManager cm) EVPATH_FD_ZERO((fd_set *) sd->fdset); sd->write_set = svc->malloc_func(sizeof(fd_set)); EVPATH_FD_ZERO((fd_set *) sd->write_set); - sd->server_thread = (thr_thread_t)(intptr_t) NULL; + sd->server_thread = (thr_thread_id)(intptr_t) NULL; sd->closed = 0; sd->sel_item_max = 0; sd->select_items = (FunctionListElement *) svc->malloc_func(sizeof(FunctionListElement)); @@ -179,7 +181,7 @@ init_select_data(CMtrans_services svc, select_data_ptr *sdp, CManager cm) typedef struct _periodic_task { int period_sec; int period_usec; - thr_thread_t executing; + thr_thread_id executing; struct timeval next_time; select_list_func func; void *arg1; @@ -221,7 +223,7 @@ set_soonest_timeout(struct timeval *timeout, periodic_task_handle task_list, str if (task_list == NULL) return; this_delay.tv_sec = task_list->next_time.tv_sec - now.tv_sec; this_delay.tv_usec = task_list->next_time.tv_usec - now.tv_usec; - if (task_list->executing == (thr_thread_t)-1) { + if (task_list->executing == (thr_thread_id)-1) { /* this task not executing already, see when it needs to run */ if (this_delay.tv_usec < 0) { this_delay.tv_sec--; @@ -260,7 +262,7 @@ socket_select(CMtrans_services svc, select_data_ptr sd, int timeout_sec, int tim int tmp_select_consistency_number = sd->select_consistency_number; if (sd->closed) { - sd->server_thread = (thr_thread_t)(intptr_t) NULL; + sd->server_thread = (thr_thread_id)(intptr_t) NULL; return; } @@ -268,7 +270,7 @@ socket_select(CMtrans_services svc, select_data_ptr sd, int timeout_sec, int tim /* assert CM is locked */ assert(CM_LOCKED(svc, sd->cm)); } - if (sd->server_thread == (thr_thread_t)(intptr_t) NULL) { + if (sd->server_thread == (thr_thread_id)(intptr_t) NULL) { /* no server thread set, must be this one */ sd->server_thread = thr_thread_self(); } @@ -321,7 +323,7 @@ socket_select(CMtrans_services svc, select_data_ptr sd, int timeout_sec, int tim ACQUIRE_CM_LOCK(svc, sd->cm); } if (sd->closed) { - sd->server_thread = (thr_thread_t)(intptr_t) NULL; + sd->server_thread = (thr_thread_id)(intptr_t) NULL; return; } #ifndef HAVE_WINDOWS_H @@ -440,7 +442,7 @@ socket_select(CMtrans_services svc, select_data_ptr sd, int timeout_sec, int tim if (res != 0) { for (i = 0; i <= sd->sel_item_max; i++) { if (sd->closed) { - sd->server_thread = (thr_thread_t)(intptr_t) NULL; + sd->server_thread = (thr_thread_id)(intptr_t) NULL; return; } if (FD_ISSET(i, &wr_set)) { @@ -496,14 +498,14 @@ socket_select(CMtrans_services svc, select_data_ptr sd, int timeout_sec, int tim increment_time(&this_periodic_task->next_time, this_periodic_task->period_sec, this_periodic_task->period_usec); - if (this_periodic_task->executing == (thr_thread_t)-1) { + if (this_periodic_task->executing == (thr_thread_id)-1) { this_periodic_task->executing = thr_thread_self(); DROP_CM_LOCK(svc, sd->cm); this_periodic_task->func(this_periodic_task->arg1, this_periodic_task->arg2); ACQUIRE_CM_LOCK(svc, sd->cm); next = this_periodic_task->next; - this_periodic_task->executing = (thr_thread_t) -1; + this_periodic_task->executing = (thr_thread_id) -1; if ((this_periodic_task->period_sec == 0) && (this_periodic_task->period_usec == 0)) { remove_periodic_task(sd, this_periodic_task); @@ -652,7 +654,7 @@ libcmselect_LTX_add_periodic(CMtrans_services svc, select_data_ptr *sdp, int int } handle->period_sec = interval_sec; handle->period_usec = interval_usec; - handle->executing = (thr_thread_t) -1; + handle->executing = (thr_thread_id) -1; #ifndef HAVE_WINDOWS_H gettimeofday(&handle->next_time, NULL); #else @@ -699,7 +701,7 @@ libcmselect_LTX_add_delayed_task(CMtrans_services svc, select_data_ptr *sdp, int } handle->period_sec = 0; handle->period_usec = 0; - handle->executing = (thr_thread_t) -1; + handle->executing = (thr_thread_id) -1; #ifndef HAVE_WINDOWS_H gettimeofday(&handle->next_time, NULL); #else @@ -751,7 +753,7 @@ remove_periodic_task(select_data_ptr sd, periodic_task_handle handle) if (handle->executing != thr_thread_self()) { /* someone besides us executing this ? */ int i = 0; - while (handle->executing != (thr_thread_t)-1) { + while (handle->executing != (thr_thread_id)-1) { /* wait until they're done */ thr_thread_yield(); i++; @@ -879,7 +881,7 @@ int err; * NT Sux. */ -int +static int pipe(SOCKET *filedes) { diff --git a/cmsockets.c b/cmsockets.c index a4bfb79688..dc5d59eb8c 100644 --- a/cmsockets.c +++ b/cmsockets.c @@ -3,7 +3,9 @@ #include #ifdef HAVE_WINDOWS_H +#ifndef FD_SETSIZE #define FD_SETSIZE 1024 +#endif #include #include #include @@ -457,7 +459,6 @@ initiate_conn(CManager cm, CMtrans_services svc, transport_entry trans, attr_lis int err = WSAGetLastError(); if (err != WSAEWOULDBLOCK || err != WSAEINPROGRESS) { #endif - printf("Errno was %d\n", errno); svc->trace_out(cm, "CMSocket connect FAILURE --> Connect() to IP %s failed", ip_str); close(sock); #ifdef WSAEWOULDBLOCK @@ -857,7 +858,7 @@ static void set_block_state(CMtrans_services svc, socket_conn_data_ptr scd, socket_block_state needed_block_state) { -#ifndef _MSC_VER +#ifndef _WIN32 int fdflags = fcntl(scd->fd, F_GETFL, 0); if (fdflags == -1) { perror("getflags\n"); @@ -880,6 +881,26 @@ set_block_state(CMtrans_services svc, socket_conn_data_ptr scd, scd->fd); } #else + if ((needed_block_state == Block) && (scd->block_state == Non_Block)) { + u_long mode = 0; // 0 to enable blocking socket + int ret = ioctlsocket(scd->fd, FIONBIO, &mode); + scd->block_state = Block; + if (ret != NO_ERROR) + printf("ioctlsocket failed with error: %ld\n", ret); + + svc->trace_out(scd->sd->cm, "CMSocket switch fd %d to blocking WIN properly", + scd->fd); + } else if ((needed_block_state == Non_Block) && + (scd->block_state == Block)) { + u_long mode = 1; // 1 to enable non-blocking socket + int ret = ioctlsocket(scd->fd, FIONBIO, &mode); + if (ret != NO_ERROR) + printf("ioctlsocket failed with error: %ld\n", ret); + + scd->block_state = Non_Block; + svc->trace_out(scd->sd->cm, "CMSocket switch fd %d to nonblocking WIN properly", + scd->fd); + } #endif } @@ -887,7 +908,7 @@ extern ssize_t libcmsockets_LTX_read_to_buffer_func(CMtrans_services svc, socket_conn_data_ptr scd, void *buffer, ssize_t requested_len, int non_blocking) { ssize_t left, iget; -#ifndef _MSC_VER +#ifndef _WIN32 // GSE int fdflags = fcntl(scd->fd, F_GETFL, 0); if (fdflags == -1) { @@ -910,7 +931,8 @@ libcmsockets_LTX_read_to_buffer_func(CMtrans_services svc, socket_conn_data_ptr iget = read(scd->fd, (char *) buffer, (int)requested_len); if ((iget == -1) || (iget == 0)) { int lerrno = errno; - if ((lerrno != EWOULDBLOCK) && + if ((lerrno != 0) && + (lerrno != EWOULDBLOCK) && (lerrno != EAGAIN) && (lerrno != EINTR)) { /* serious error */ @@ -1135,7 +1157,7 @@ libcmsockets_LTX_NBwritev_func(CMtrans_services svc, socket_conn_data_ptr scd, v return init_bytes - left; } -int socket_global_init = 0; +static int socket_global_init = 0; #ifdef HAVE_WINDOWS_H /* Winsock init stuff, ask for ver 2.2 */ diff --git a/cmudp.c b/cmudp.c index d865034dde..226bb1d0cc 100644 --- a/cmudp.c +++ b/cmudp.c @@ -3,10 +3,11 @@ #include #ifdef HAVE_WINDOWS_H +#ifndef FD_SETSIZE #define FD_SETSIZE 1024 +#endif #include #include -#define getpid() _getpid() #else #ifdef HAVE_SYS_TIME_H #include @@ -59,6 +60,9 @@ #include #endif +#ifdef _WIN32 +#define getpid() _getpid() +#endif #include #include "evpath.h" #include "cm_transport.h" @@ -627,7 +631,7 @@ libcmudp_LTX_writev_func(CMtrans_services svc, udp_conn_data_ptr ucd, struct iov fd = ucd->utd->socket_fd; svc->trace_out(ucd->utd->cm, "CMUdp writev of %d vectors on fd %d", iovcnt, fd); -#ifndef _MSC_VER +#ifndef _WIN32 struct sockaddr_in addr = ucd->dest_addr; struct msghdr msg; memset(&msg, 0, sizeof(msg)); @@ -646,7 +650,7 @@ libcmudp_LTX_writev_func(CMtrans_services svc, udp_conn_data_ptr ucd, struct iov } #ifdef HAVE_WINDOWS_H -int socket_global_init = 0; +static int socket_global_init = 0; /* Winsock init stuff, ask for ver 1.1 */ static WORD wVersionRequested = MAKEWORD(1, 1); static WSADATA wsaData; diff --git a/config.h.cmake b/config.h.cmake index 13943a10a8..b7ffa68fed 100644 --- a/config.h.cmake +++ b/config.h.cmake @@ -72,6 +72,12 @@ /* Define to 1 if you have the header file. */ #cmakedefine HAVE_NETDB_H +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_NETINET_IN_H + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_ARPA_INET_H + /* Define to 1 if you have the header file. */ #cmakedefine HAVE_STDARG_H diff --git a/dfg_tests/auto_tree_test.c b/dfg_tests/auto_tree_test.c index d4b1d781b6..97705efd4b 100644 --- a/dfg_tests/auto_tree_test.c +++ b/dfg_tests/auto_tree_test.c @@ -5,6 +5,7 @@ #ifdef HAVE_UNISTD_H #include #endif +#include #include #include "cod.h" @@ -71,6 +72,12 @@ be_test_master(int argc, char **argv) #ifdef HAVE_WINDOWS_H SetTimer(NULL, 5, 1000, (TIMERPROC) fail_and_die); #else + struct sigaction sigact; + sigact.sa_flags = 0; + sigact.sa_handler = fail_and_die; + sigemptyset(&sigact.sa_mask); + sigaddset(&sigact.sa_mask, SIGALRM); + sigaction(SIGALRM, &sigact, NULL); alarm(240); /* reset time limit to 4 minutes */ #endif if (argc == 1) { diff --git a/dfg_tests/fail_chain_test.c b/dfg_tests/fail_chain_test.c index a3673e6db4..e68cae7962 100755 --- a/dfg_tests/fail_chain_test.c +++ b/dfg_tests/fail_chain_test.c @@ -6,6 +6,7 @@ #ifdef HAVE_UNISTD_H #include #endif +#include #include "evpath.h" #include "ev_dfg.h" #include "test_support.h" @@ -140,6 +141,12 @@ be_test_master(int argc, char **argv) #ifdef HAVE_WINDOWS_H SetTimer(NULL, 5, 1000, (TIMERPROC) fail_and_die); #else + struct sigaction sigact; + sigact.sa_flags = 0; + sigact.sa_handler = fail_and_die; + sigemptyset(&sigact.sa_mask); + sigaddset(&sigact.sa_mask, SIGALRM); + sigaction(SIGALRM, &sigact, NULL); alarm(240); /* reset time limit to 4 minutes */ #endif if (argc == 1) { diff --git a/dfg_tests/self_reconfig_test.c b/dfg_tests/self_reconfig_test.c index 4970d8d050..6484c79c2f 100644 --- a/dfg_tests/self_reconfig_test.c +++ b/dfg_tests/self_reconfig_test.c @@ -6,6 +6,7 @@ #ifdef HAVE_UNISTD_H #include #endif +#include #include "evpath.h" #include "ev_dfg.h" #include "test_support.h" @@ -168,6 +169,12 @@ be_test_master(int argc, char **argv) #ifdef HAVE_WINDOWS_H SetTimer(NULL, 5, 1000, (TIMERPROC) fail_and_die); #else + struct sigaction sigact; + sigact.sa_flags = 0; + sigact.sa_handler = fail_and_die; + sigemptyset(&sigact.sa_mask); + sigaddset(&sigact.sa_mask, SIGALRM); + sigaction(SIGALRM, &sigact, NULL); alarm(240); /* reset time limit to 4 minutes */ #endif if (argc == 1) { diff --git a/dfg_tests/tree_test.c b/dfg_tests/tree_test.c index d157647986..5770de6eb4 100644 --- a/dfg_tests/tree_test.c +++ b/dfg_tests/tree_test.c @@ -6,6 +6,7 @@ #ifdef HAVE_UNISTD_H #include #endif +#include #include "ev_dfg.h" #include "test_support.h" @@ -56,6 +57,12 @@ be_test_master(int argc, char **argv) #ifdef HAVE_WINDOWS_H SetTimer(NULL, 5, 1000, (TIMERPROC) fail_and_die); #else + struct sigaction sigact; + sigact.sa_flags = 0; + sigact.sa_handler = fail_and_die; + sigemptyset(&sigact.sa_mask); + sigaddset(&sigact.sa_mask, SIGALRM); + sigaction(SIGALRM, &sigact, NULL); alarm(300); #endif if (argc == 1) { diff --git a/dlloader.c b/dlloader.c index 8cc58134d1..07ced47444 100644 --- a/dlloader.c +++ b/dlloader.c @@ -8,7 +8,7 @@ #include "dlloader.h" static char **search_list = NULL; -#ifdef _MSC_VER +#ifdef _WIN32 #include static struct { @@ -57,7 +57,11 @@ void* dlsym(void* handle, const char* name) return (void*)(intptr_t)fp; } +#ifndef DLFCN_EXPORT const char* dlerror(void) +#else +DLFCN_EXPORT char* dlerror(void) +#endif { static char errstr[88]; diff --git a/ev_dfg.c b/ev_dfg.c index 3493e0a431..3720d401f8 100644 --- a/ev_dfg.c +++ b/ev_dfg.c @@ -1583,13 +1583,14 @@ INT_EVdfg_create(EVmaster master) extern char *INT_EVmaster_get_contact_list(EVmaster master) { attr_list contact_list = NULL; - atom_t CM_TRANSPORT = attr_atom_from_string("CM_TRANSPORT"); - atom_t CM_ENET_CONN_TIMEOUT = attr_atom_from_string("CM_ENET_CONN_TIMEOUT"); CManager cm = master->cm; char *tmp = NULL; /* use enet transport if available */ #if defined(ENET_FOUND) || defined(ZPL_ENET_AVAILABLE) + atom_t CM_ENET_CONN_TIMEOUT = attr_atom_from_string("CM_ENET_CONN_TIMEOUT"); + atom_t CM_TRANSPORT = attr_atom_from_string("CM_TRANSPORT"); + (void) CM_TRANSPORT; attr_list listen_list = create_attr_list(); #if defined(ENET_FOUND) add_string_attr(listen_list, CM_TRANSPORT, strdup("enet")); diff --git a/ev_internal.h b/ev_internal.h index f787a372b9..62ed43696e 100644 --- a/ev_internal.h +++ b/ev_internal.h @@ -234,7 +234,7 @@ typedef struct _EVclient_sources { typedef struct _ev_handler_activation_rec { struct _ev_handler_activation_rec *prev; - thr_thread_t thread_id; + thr_thread_id thread_id; EVstone stone_id; struct _ev_handler_activation_rec *next; } ev_handler_activation_rec, *ev_handler_activation_ptr; diff --git a/evp.c b/evp.c index f72ddb0cf8..77a10ff357 100644 --- a/evp.c +++ b/evp.c @@ -1632,7 +1632,7 @@ pop_activation_record_from_stack(CManager cm, ev_handler_activation_ptr rec) { event_path_data evp = cm->evp; ev_handler_activation_ptr tmp; - thr_thread_t self = thr_thread_self(); + thr_thread_id self = thr_thread_self(); if (!evp->activation_stack) { printf("Activation stack inconsistency! No records!\n"); return; @@ -1663,7 +1663,7 @@ find_activation_record_from_stack(CManager cm) { event_path_data evp = cm->evp; ev_handler_activation_ptr tmp; - thr_thread_t self = thr_thread_self(); + thr_thread_id self = thr_thread_self(); tmp = evp->activation_stack; while(tmp) { if (tmp->thread_id == self) { @@ -3700,7 +3700,7 @@ INT_EVextract_stone_events(CManager cm, EVstone stone_id) stone_type stone; EVevent_list list = malloc(sizeof(list[0])); - list[0].length = -1; + list[0].length = (size_t)-1; stone = stone_struct(evp, stone_id); if (!stone) return NULL; list = extract_events_from_queue(cm, stone->queue, list); @@ -3764,7 +3764,7 @@ extract_events_from_queue(CManager cm, queue_ptr que, EVevent_list list) first = que->queue_head; last = que->queue_tail; - while (list[num_of_elements].length != -1) num_of_elements++; + while (list[num_of_elements].length != (size_t)-1) num_of_elements++; while(first != NULL && last != NULL) { list = (EVevent_list) realloc (list, (num_of_elements + 2) * sizeof(list[0])); current_entry = &list[num_of_elements]; @@ -3779,7 +3779,7 @@ extract_events_from_queue(CManager cm, queue_ptr que, EVevent_list list) num_of_elements++; first = first->next; } - list[num_of_elements].length = -1; + list[num_of_elements].length = (size_t)-1; return list; } diff --git a/gen_interface.pl b/gen_interface.pl index f76852ba75..d79335ea5d 100755 --- a/gen_interface.pl +++ b/gen_interface.pl @@ -10,26 +10,26 @@ sub gen_type print REVP " int condition_var;\n"; @args = split( ", ", $arg_str,2); foreach $arg (split (", ", $args[1])) { - $_ = $arg; - if (/^\s*(.*\W+)(\w+)$\s*/) { - $argtype = $1; - $argname = $2; - $argtype =~ s/\s+$//; - $argtype =~ s/(?!\w)\s+(?=\W)//; #remove unnecessary white space - $argtype =~ s/(?!\W)\s+(?=\w)//; #remove unnecessary white space - $iotype = $argtype; - $sizetype = $argtype; - switch:for ($argtype) { - /attr_list/ && do {$iotype = "string"; $argtype="char*"; last;}; - /char*/ && do {$iotype = "string"; $argtype="char*"; last;}; - /EVstone$/ && do {$iotype = "integer"; $argtype="EVstone"; last;}; - /EVstone\*/ && do {print REVP " int ${argname}_len;\n"; + $_ = $arg; + if (/^\s*(.*\W+)(\w+)$\s*/) { + $argtype = $1; + $argname = $2; + $argtype =~ s/\s+$//; + $argtype =~ s/(?!\w)\s+(?=\W)//; #remove unnecessary white space + $argtype =~ s/(?!\W)\s+(?=\w)//; #remove unnecessary white space + $iotype = $argtype; + $sizetype = $argtype; + switch:for ($argtype) { + /attr_list/ && do {$iotype = "string"; $argtype="char*"; last;}; + /char*/ && do {$iotype = "string"; $argtype="char*"; last;}; + /EVstone$/ && do {$iotype = "integer"; $argtype="EVstone"; last;}; + /EVstone\*/ && do {print REVP " int ${argname}_len;\n"; $iotype = "integer[${argname}_len]"; $argtype="int *"; last;}; - /EVSimpleHandlerFunc$/ && do {$iotype = "string"; $argtype="char*"; last;}; - /FMStructDescList/ && do {$iotype = "string"; $argtype="char*"; last;}; - } - } - print REVP " $argtype $argname;\n"; + /EVSimpleHandlerFunc$/ && do {$iotype = "string"; $argtype="char*"; last;}; + /FMStructDescList/ && do {$iotype = "string"; $argtype="char*"; last;}; + } + } + print REVP " $argtype $argname;\n"; } print REVP "} ${subr}_request;\n"; $ret_type = $return_type{$subr}; @@ -52,27 +52,27 @@ sub gen_field_list print REVP " {\"condition_var\", \"integer\", sizeof(int), FMOffset(${subr}_request*, condition_var)},\n"; @args = split( ", ", $arg_str,2); foreach $arg (split (", ", $args[1])) { - $_ = $arg; - if (/^\s*(.*\W+)(\w+)$\s*/) { - $argtype = $1; - $argname = $2; - $argtype =~ s/\s+$//; - $argtype =~ s/(?!\w)\s+(?=\W)//; #remove unnecessary white space - $argtype =~ s/(?!\W)\s+(?=\w)//; #remove unnecessary white space - $iotype = $argtype; - $sizetype = $argtype; - switch:for ($argtype) { - /attr_list/ && do {$iotype = "string"; $argtype="char*"; last;}; - /char*/ && do {$iotype = "string"; $argtype="char*"; last;}; - /void*/ && do {$iotype = "char[${argname}_len"; $argtype="void*"; last;}; - /int/ && do {$iotype = "integer"; $argtype="int"; last;}; - /EVstone/ && do {$iotype = "integer"; $argtype="EVstone"; last;}; - /EVaction/ && do {$iotype = "integer"; $argtype="EVaction"; last;}; - /EVSimpleHandlerFunc/ && do {$iotype = "string"; $argtype="EVSimpleHandlerFunc"; last;}; - /FMStructDescList/ && do {$iotype = "string"; $argtype="EVSimpleHandlerFunc"; last;}; - } - } - print REVP " {\"$argname\", \"$iotype\", sizeof($sizetype), FMOffset(${subr}_request*,$argname)},\n"; + $_ = $arg; + if (/^\s*(.*\W+)(\w+)$\s*/) { + $argtype = $1; + $argname = $2; + $argtype =~ s/\s+$//; + $argtype =~ s/(?!\w)\s+(?=\W)//; #remove unnecessary white space + $argtype =~ s/(?!\W)\s+(?=\w)//; #remove unnecessary white space + $iotype = $argtype; + $sizetype = $argtype; + switch:for ($argtype) { + /attr_list/ && do {$iotype = "string"; $argtype="char*"; last;}; + /char*/ && do {$iotype = "string"; $argtype="char*"; last;}; + /void*/ && do {$iotype = "char[${argname}_len"; $argtype="void*"; last;}; + /int/ && do {$iotype = "integer"; $argtype="int"; last;}; + /EVstone/ && do {$iotype = "integer"; $argtype="EVstone"; last;}; + /EVaction/ && do {$iotype = "integer"; $argtype="EVaction"; last;}; + /EVSimpleHandlerFunc/ && do {$iotype = "string"; $argtype="EVSimpleHandlerFunc"; last;}; + /FMStructDescList/ && do {$iotype = "string"; $argtype="EVSimpleHandlerFunc"; last;}; + } + } + print REVP " {\"$argname\", \"$iotype\", sizeof($sizetype), FMOffset(${subr}_request*,$argname)},\n"; } print REVP " {NULL, NULL, 0, 0}\n};\n"; print REVP "\nFMStructDescRec ${subr}_req_formats[] = {\n"; @@ -87,17 +87,17 @@ sub gen_stub { print REVP "\nextern $return_type{$subr}\n"; print REVPHI "\nextern $return_type{$subr}\n"; if ($#args > 0) { - print REVP "INT_R$subr(CMConnection conn, $args[1])\n"; - print REVPHI "INT_R$subr(CMConnection conn, $args[1]);\n"; + print REVP "INT_R$subr(CMConnection conn, $args[1])\n"; + print REVPHI "INT_R$subr(CMConnection conn, $args[1]);\n"; } else { - print REVP "INT_R$subr(CMConnection conn)\n"; - print REVPHI "INT_R$subr(CMConnection conn);\n"; + print REVP "INT_R$subr(CMConnection conn)\n"; + print REVPHI "INT_R$subr(CMConnection conn);\n"; } print REVP "{\n"; $_ = $return_type{$subr}; if (/^\s*void\s*$/) { - $return_type{$subr} = "void"; + $return_type{$subr} = "void"; } $retsubtype = $return_type{$subr}; switch: for ($ret_type) { @@ -115,33 +115,33 @@ sub gen_stub { print REVP " f = INT_CMlookup_format(conn->cm, ${subr}_req_formats);\n"; $free_list = ""; foreach $arg (split (", ", $args[1])) { - $_ = $arg; - if (/^\s*(.*\W+)(\w+)$\s*/) { - $argtype = $1; - $argname = $2; - $argtype =~ s/\s+$//; - $argtype =~ s/(?!\w)\s+(?=\W)//; #remove unnecessary white space - $argtype =~ s/(?!\W)\s+(?=\w)//; #remove unnecessary white space - $argright = $argname; - switch:for ($argtype) { - /attr_list/ && do {$argright = "attr_list_to_string($argname)"; $free_list .= " free(request.$argname);\n"; last;}; - /FMStructDescList/ && do {$argright = "get_format_name(conn->cm, $argname)"; last;}; - } - } - print REVP " request.$argname = $argright;\n"; + $_ = $arg; + if (/^\s*(.*\W+)(\w+)$\s*/) { + $argtype = $1; + $argname = $2; + $argtype =~ s/\s+$//; + $argtype =~ s/(?!\w)\s+(?=\W)//; #remove unnecessary white space + $argtype =~ s/(?!\W)\s+(?=\w)//; #remove unnecessary white space + $argright = $argname; + switch:for ($argtype) { + /attr_list/ && do {$argright = "attr_list_to_string($argname)"; $free_list .= " free(request.$argname);\n"; last;}; + /FMStructDescList/ && do {$argright = "get_format_name(conn->cm, $argname)"; last;}; + } + } + print REVP " request.$argname = $argright;\n"; } print REVP " request.condition_var = cond;\n"; print REVP " if (f == NULL) {\n"; print REVP " f = INT_CMregister_format(conn->cm, ${subr}_req_formats);\n"; print REVP " }\n"; if ($return_type{$subr} eq "void") { - print REVP " INT_CMCondition_set_client_data(conn->cm, cond, NULL);\n"; + print REVP " INT_CMCondition_set_client_data(conn->cm, cond, NULL);\n"; } else { - print REVP " INT_CMCondition_set_client_data(conn->cm, cond, &response);\n"; + print REVP " INT_CMCondition_set_client_data(conn->cm, cond, &response);\n"; } print REVP " INT_CMwrite(conn, f, &request);\n"; if ("$free_list" ne "") { - print REVP "$free_list"; + print REVP "$free_list"; } print REVP " INT_CMCondition_wait(conn->cm, cond);\n"; switch:for ($return_type{$subr}) { @@ -173,7 +173,7 @@ sub gen_wrapper { print REVP "{\n"; $_ = $return_type{$subr}; if (/^\s*void\s*$/) { - $return_type{$subr} = "void"; + $return_type{$subr} = "void"; } $retsubtype = $return_type{$subr}; switch: for ($ret_type) { @@ -190,21 +190,21 @@ sub gen_wrapper { print REVP " ret = INT_R${subr}(conn"; } foreach $arg (split (", ", $args[1])) { - $_ = $arg; - if (/^\s*(.*\W+)(\w+)$\s*/) { - $argtype = $1; - $argname = $2; - $argtype =~ s/\s+$//; - $argtype =~ s/(?!\w)\s+(?=\W)//; #remove unnecessary white space - $argtype =~ s/(?!\W)\s+(?=\w)//; #remove unnecessary white space - $argright = "$argname"; - switch:for ($argtype) { - /attr_list/ && do {$argright = "$argname"; last;}; - /EVSimpleHandlerFunc/ && do {$argright = "$argname"; last;}; - /FMStructDescList/ && do {$argright = "$argname"; last;}; - } - } - print REVP ", $argright"; + $_ = $arg; + if (/^\s*(.*\W+)(\w+)$\s*/) { + $argtype = $1; + $argname = $2; + $argtype =~ s/\s+$//; + $argtype =~ s/(?!\w)\s+(?=\W)//; #remove unnecessary white space + $argtype =~ s/(?!\W)\s+(?=\w)//; #remove unnecessary white space + $argright = "$argname"; + switch:for ($argtype) { + /attr_list/ && do {$argright = "$argname"; last;}; + /EVSimpleHandlerFunc/ && do {$argright = "$argname"; last;}; + /FMStructDescList/ && do {$argright = "$argname"; last;}; + } + } + print REVP ", $argright"; } print REVP ");\n"; print REVP " CManager_unlock(conn->cm);\n"; @@ -229,7 +229,7 @@ sub gen_handler { print REVP "{\n"; $_ = $return_type{$subr}; if (/^\s*void\s*$/) { - $return_type{$subr} = "void"; + $return_type{$subr} = "void"; } $retsubtype = $return_type{$subr}; switch: for ($ret_type) { @@ -248,43 +248,43 @@ sub gen_handler { print REVP " f = INT_CMregister_format(conn->cm, EV_${retsubtype}_response_formats);\n"; print REVP " }\n"; foreach $arg (split (", ", $args[1])) { - $_ = $arg; - if (/^\s*(.*\W+)(\w+)$\s*/) { - $argtype = $1; - $argname = $2; - $argtype =~ s/\s+$//; - $argtype =~ s/(?!\w)\s+(?=\W)//; #remove unnecessary white space - $argtype =~ s/(?!\W)\s+(?=\w)//; #remove unnecessary white space - $argright = $argname; - switch:for ($argtype) { - /attr_list/ && do {print REVP " attr_list $argname = attr_list_from_string(request->$argname);\n"; last;}; - /EVSimpleHandlerFunc/ && do {print REVP " EVSimpleHandlerFunc $argname = REVPlookup_handler(request->$argname);\n"; last;}; - /FMStructDescList/ && do {print REVP " FMStructDescList $argname = REVPlookup_format_structs(conn->cm, request->$argname);\n"; last;}; - } - } + $_ = $arg; + if (/^\s*(.*\W+)(\w+)$\s*/) { + $argtype = $1; + $argname = $2; + $argtype =~ s/\s+$//; + $argtype =~ s/(?!\w)\s+(?=\W)//; #remove unnecessary white space + $argtype =~ s/(?!\W)\s+(?=\w)//; #remove unnecessary white space + $argright = $argname; + switch:for ($argtype) { + /attr_list/ && do {print REVP " attr_list $argname = attr_list_from_string(request->$argname);\n"; last;}; + /EVSimpleHandlerFunc/ && do {print REVP " EVSimpleHandlerFunc $argname = REVPlookup_handler(request->$argname);\n"; last;}; + /FMStructDescList/ && do {print REVP " FMStructDescList $argname = REVPlookup_format_structs(conn->cm, request->$argname);\n"; last;}; + } + } } if ($return_type{$subr} eq "void") { - print REVP " $subr(cm"; + print REVP " $subr(cm"; } else { - print REVP " ret = $subr(cm"; + print REVP " ret = $subr(cm"; } $after = ""; foreach $arg (split (", ", $args[1])) { - $_ = $arg; - if (/^\s*(.*\W+)(\w+)$\s*/) { - $argtype = $1; - $argname = $2; - $argtype =~ s/\s+$//; - $argtype =~ s/(?!\w)\s+(?=\W)//; #remove unnecessary white space - $argtype =~ s/(?!\W)\s+(?=\w)//; #remove unnecessary white space - $argright = "request->$argname"; - switch:for ($argtype) { - /attr_list/ && do {$argright = "$argname"; $after .= "free_attr_list($argname);\n"; last;}; - /EVSimpleHandlerFunc/ && do {$argright = "$argname"; last;}; - /FMStructDescList/ && do {$argright = "$argname"; last;}; - } - } - print REVP ", $argright"; + $_ = $arg; + if (/^\s*(.*\W+)(\w+)$\s*/) { + $argtype = $1; + $argname = $2; + $argtype =~ s/\s+$//; + $argtype =~ s/(?!\w)\s+(?=\W)//; #remove unnecessary white space + $argtype =~ s/(?!\W)\s+(?=\w)//; #remove unnecessary white space + $argright = "request->$argname"; + switch:for ($argtype) { + /attr_list/ && do {$argright = "$argname"; $after .= "free_attr_list($argname);\n"; last;}; + /EVSimpleHandlerFunc/ && do {$argright = "$argname"; last;}; + /FMStructDescList/ && do {$argright = "$argname"; last;}; + } + } + print REVP ", $argright"; } if ($has_client_data == 1) {print REVP ", NULL";} print REVP ");\n"; @@ -311,7 +311,7 @@ sub strip_client_data { @args = split( ", ", $arguments{$subr}); $_ = pop(@args); if (!/.*client_data\W*$/) { - push(@args, $_); + push(@args, $_); } $arg_str = join(", ", @args); } @@ -321,10 +321,10 @@ sub mod_EVhandler { local(@args); @args = split( ", ", $arg_str); for( my $i=0; $i < scalar(@args); $i++) { - $_ = $args[$i]; - if (/\W*EVSimpleHandlerFunc.*$/) { - $args[$i] = "char *handler"; - } + $_ = $args[$i]; + if (/\W*EVSimpleHandlerFunc.*$/) { + $args[$i] = "char *handler"; + } } $arg_str = join(", ", @args); return $arg_str; @@ -332,23 +332,39 @@ sub mod_EVhandler { { local ($/, *INPUT); - + + $cat = "cat"; + if ($^O eq "MSWin32") { + $cat = "powershell.exe Get-Content"; + } $cat_args = ""; $has_ev_dfg = 0; $cm_only = 0; + $index = 0; foreach my $a(@ARGV) { - if ($a =~ "-CM_ONLY") { - $cm_only = 1; - next; - } - $a=~s/ /\\ /g; - $cat_args .= "$a "; - if ($a =~ /ev_dfg/) { - $has_evdfg = 1; - } + if ($a =~ "-CM_ONLY") { + $cm_only = 1; + next; + } + $a=~s/ /\\ /g; + + if ($^O eq "MSWin32") { + $sep = ","; + } else { + $sep = " "; + } + if ($index == 0) + { + $sep = ""; + } + $cat_args .= "$sep$a"; + if ($a =~ /ev_dfg/) { + $has_evdfg = 1; + } + $index++; } - unless (open(INPUT, "cat $cat_args |")) { - die "sudden flaming death, no file: $cat_args\n"; + unless (open(INPUT, "$cat $cat_args |")) { + die "sudden flaming death, no file: $cat_args\n"; } $_ = ; @@ -361,76 +377,76 @@ sub mod_EVhandler { LINE: for (@f) { if (/NOLOCK/) { - $nolock = 1; + $nolock = 1; } if (/REMOTE/) { - $remote = 1; + $remote = 1; } if (/^extern/) { - next LINE if (/\"C\"/); - $decl = ""; - if ($nolock == 1) {$decl = "NOLOCK";} - if ($remote == 1) {$decl = "REMOTE";} - $nolock = 0; - $remote = 0; - $pending = 1; + next LINE if (/\"C\"/); + $decl = ""; + if ($nolock == 1) {$decl = "NOLOCK";} + if ($remote == 1) {$decl = "REMOTE";} + $nolock = 0; + $remote = 0; + $pending = 1; } if (($pending) && /;/) { - $decl = $decl . " " . $_; - push (@DECLS, $decl); - $pending = 0; + $decl = $decl . " " . $_; + push (@DECLS, $decl); + $pending = 0; } if ($pending) { - $decl = $decl . " " . $_; + $decl = $decl . " " . $_; } } for (@DECLS) { $nolock = 0; $remote = 0; if (/NOLOCK/) { - s/NOLOCK//g; - $nolock = 1; + s/NOLOCK//g; + $nolock = 1; } if (/REMOTE/) { - s/REMOTE//g; - $remote = 1; + s/REMOTE//g; + $remote = 1; } if (/extern\W+(\w+\W+)(\w+)\W*\((.*)\)/) { - $return = $1; - $name = $2; - $_ = $3; - s/\)//g; - s/\s+/ /g; - $return =~ s/(?!\w)\s+(?=\W)//; #remove unnecessary white space - $return =~ s/(?!\W)\s+(?=\w)//; #remove unnecessary white space - $return =~ s/\s*$//; #remove unnecessary white space - $return =~ s/^\s*//; #remove unnecessary white space - $return_type{$name} = $return; - $args = $_; - $arguments{$name} = "$args"; + $return = $1; + $name = $2; + $_ = $3; + s/\)//g; + s/\s+/ /g; + $return =~ s/(?!\w)\s+(?=\W)//; #remove unnecessary white space + $return =~ s/(?!\W)\s+(?=\w)//; #remove unnecessary white space + $return =~ s/\s*$//; #remove unnecessary white space + $return =~ s/^\s*//; #remove unnecessary white space + $return_type{$name} = $return; + $args = $_; + $arguments{$name} = "$args"; } else { if (/extern\W+(\w+\W+\w+\W+)(\w+).*\((.*)\)/) { - $return = $1; - $name = $2; - $_ = $3; - s/\)//g; - s/\s+/ /g; - $return =~ s/(?!\w)\s+(?=\W)//; #remove unnecessary white space - $return =~ s/(?!\W)\s+(?=\w)//; #remove unnecessary white space - $return =~ s/\s*$//; #remove unnecessary white space - $return =~ s/^\s*//; #remove unnecessary white space - $return_type{$name} = $return; - $args = $_; - $arguments{$name} = "$args"; + $return = $1; + $name = $2; + $_ = $3; + s/\)//g; + s/\s+/ /g; + $return =~ s/(?!\w)\s+(?=\W)//; #remove unnecessary white space + $return =~ s/(?!\W)\s+(?=\w)//; #remove unnecessary white space + $return =~ s/\s*$//; #remove unnecessary white space + $return =~ s/^\s*//; #remove unnecessary white space + $return_type{$name} = $return; + $args = $_; + $arguments{$name} = "$args"; } else { - print "Failed to match function2 on $_\n" + print "Failed to match function2 on $_\n" } } if ($nolock == 1) { - $nolocking{$name} = 1; + $nolocking{$name} = 1; } if ($remote == 1) { - $remote_enabled{$name} = 1; + $remote_enabled{$name} = 1; } } @@ -459,121 +475,121 @@ sub mod_EVhandler { print INT "#include \"ev_dfg_internal.h\"\n"; } print INT<cm"; - } - if (/EVmaster\W/) { - $cmanager = $name. "->cm"; - } - if (/EVdfg_stone\W/) { - $evdfg_stone = $name; - } - } - - $_ = $return_type{$subr}; - if (/^\s*void\s*$/) { - $return_type{$subr} = "void"; - } - if ($return_type{$subr} ne "void") { - print INT "\t$return_type{$subr} ret;\n"; - } - if (!defined($nolocking{$subr})) { - if (defined($cmanager)) { - print INT "\tCManager_lock($cmanager);\n"; - } else { - if (defined($cmconnection)) { - print INT "\tCManager cm = $cmconnection->cm;\n"; - } elsif (defined($evsource)) { - print INT "\tCManager cm = $evsource->cm;\n"; - } elsif (defined($cmtaskhandle)) { - print INT "\tCManager cm = $cmtaskhandle->cm;\n"; - } elsif (defined($cmformat)) { - print INT "\tCManager cm = $cmformat->cm;\n"; - } elsif (defined($evdfg)) { - print INT "\tCManager cm = $evdfg->master->cm;\n"; - } elsif (defined($evdfg_stone)) { - print INT "\tCManager cm = $evdfg_stone->dfg->master->cm;\n"; - } else { -# print INT "\tCManager cm = duh;\n"; - } - print INT "\tCManager_lock(cm);\n"; - } - } - if ($return_type{$subr} eq "void") { - print INT "\t"; - } else { - print INT "\tret = "; - } - - print INT "INT_$subr("; - $first = 1; - foreach $arg (split ( ",", $arguments{$subr})) { - if ($first != 1) { - print INT ", "; - } else { - $first = 0; - } - $_ = $arg; - if (/\W+(\w+)\W*$/) { - print INT "$1"; - } - } - print INT ");\n"; - if ((!defined($nolocking{$subr})) && ($subr ne "CManager_close")) { - if (defined($cmanager)) { - print INT "\tCManager_unlock($cmanager);\n"; - } else { - print INT "\tCManager_unlock(cm);\n"; - } - } - print INT "\treturn ret;\n" unless ($return_type{$subr} eq "void"); - print INT "}\n"; + if ($cm_only && (($subr =~ /^EV/) || ($subr =~ /^create/))) { + next; + } + print INT "\nextern $return_type{$subr}\n"; + print INT "$subr ( $arguments{$subr} )\n"; + print INT "{\n"; + undef $cmanager; + undef $cmconnection; + undef $evsource; + undef $cmtaskhandle; + undef $cmformat; + undef $evdfg; + undef $evdfg_stone; + foreach $arg (split ( ",", $arguments{$subr})) { + $_ = $arg; + if (/\W+(\w+)\W*$/) { + $name = $1; + } + if (/CManager/) { + $cmanager = $name; + } + if (/CMConnection/) { + $cmconnection = $name; + } + if (/EVsource/) { + $evsource = $name; + } + if (/CMTaskHandle/) { + $cmtaskhandle = $name; + } + if (/CMFormat\W/) { + $cmformat = $name; + } + if (/EVdfg\W/) { + $evdfg = $name; + } + if (/EVclient\W/) { + $cmanager = $name. "->cm"; + } + if (/EVmaster\W/) { + $cmanager = $name. "->cm"; + } + if (/EVdfg_stone\W/) { + $evdfg_stone = $name; + } + } + + $_ = $return_type{$subr}; + if (/^\s*void\s*$/) { + $return_type{$subr} = "void"; + } + if ($return_type{$subr} ne "void") { + print INT "\t$return_type{$subr} ret;\n"; + } + if (!defined($nolocking{$subr})) { + if (defined($cmanager)) { + print INT "\tCManager_lock($cmanager);\n"; + } else { + if (defined($cmconnection)) { + print INT "\tCManager cm = $cmconnection->cm;\n"; + } elsif (defined($evsource)) { + print INT "\tCManager cm = $evsource->cm;\n"; + } elsif (defined($cmtaskhandle)) { + print INT "\tCManager cm = $cmtaskhandle->cm;\n"; + } elsif (defined($cmformat)) { + print INT "\tCManager cm = $cmformat->cm;\n"; + } elsif (defined($evdfg)) { + print INT "\tCManager cm = $evdfg->master->cm;\n"; + } elsif (defined($evdfg_stone)) { + print INT "\tCManager cm = $evdfg_stone->dfg->master->cm;\n"; + } else { +# print INT "\tCManager cm = duh;\n"; + } + print INT "\tCManager_lock(cm);\n"; + } + } + if ($return_type{$subr} eq "void") { + print INT "\t"; + } else { + print INT "\tret = "; + } + + print INT "INT_$subr("; + $first = 1; + foreach $arg (split ( ",", $arguments{$subr})) { + if ($first != 1) { + print INT ", "; + } else { + $first = 0; + } + $_ = $arg; + if (/\W+(\w+)\W*$/) { + print INT "$1"; + } + } + print INT ");\n"; + if ((!defined($nolocking{$subr})) && ($subr ne "CManager_close")) { + if (defined($cmanager)) { + print INT "\tCManager_unlock($cmanager);\n"; + } else { + print INT "\tCManager_unlock(cm);\n"; + } + } + print INT "\treturn ret;\n" unless ($return_type{$subr} eq "void"); + print INT "}\n"; } print "done\n"; print INT<evp->fmc, (char*)id); free(id); @@ -825,27 +841,27 @@ sub mod_EVhandler { EOF foreach $subr (sort (keys %return_type)) { - defined($remote_enabled{$subr}) || next; - - print REVPH "\nextern $return_type{$subr}\n"; - $no_client_data = strip_client_data($arguments{$subr}); - $no_handler = mod_EVhandler($no_client_data); - $_ = $arguments{$subr}; - $has_client_data = 0; - if (/.*client_data\W*$/) { - $has_client_data = 1; - } - @args = split( ", ", $no_handler, 2); - if ($#args > 0) { - print REVPH "R$subr(CMConnection conn, $args[1]);\n"; - } else { - print REVPH "R$subr(CMConnection conn);\n"; - } - gen_type(${subr}, $no_handler); - gen_field_list(${subr}, $no_handler); - gen_stub(${subr}, $no_handler); - gen_wrapper(${subr}, $no_handler, $has_client_data); - gen_handler(${subr}, $no_client_data, $has_client_data); + defined($remote_enabled{$subr}) || next; + + print REVPH "\nextern $return_type{$subr}\n"; + $no_client_data = strip_client_data($arguments{$subr}); + $no_handler = mod_EVhandler($no_client_data); + $_ = $arguments{$subr}; + $has_client_data = 0; + if (/.*client_data\W*$/) { + $has_client_data = 1; + } + @args = split( ", ", $no_handler, 2); + if ($#args > 0) { + print REVPH "R$subr(CMConnection conn, $args[1]);\n"; + } else { + print REVPH "R$subr(CMConnection conn);\n"; + } + gen_type(${subr}, $no_handler); + gen_field_list(${subr}, $no_handler); + gen_stub(${subr}, $no_handler); + gen_wrapper(${subr}, $no_handler, $has_client_data); + gen_handler(${subr}, $no_client_data, $has_client_data); } print REVP<condition_var); if (NULL != response_ptr) { - *response_ptr = data; + *response_ptr = data; } CMCondition_signal(cm, response->condition_var); } @@ -866,7 +882,7 @@ sub mod_EVhandler { EV_void_response *response = (EV_void_response*) data; void **response_ptr = CMCondition_get_client_data(cm, response->condition_var); if (NULL != response_ptr) { - memcpy(response_ptr, data, sizeof(EV_int_response)); + memcpy(response_ptr, data, sizeof(EV_int_response)); } CMCondition_signal(cm, response->condition_var); } @@ -877,8 +893,8 @@ sub mod_EVhandler { EV_string_response *response = (EV_string_response*) data; EV_string_response *stub_ptr = CMCondition_get_client_data(cm, response->condition_var); if (NULL != stub_ptr) { - memcpy(stub_ptr, data, sizeof(EV_string_response)); - stub_ptr->ret = strdup(response->ret); + memcpy(stub_ptr, data, sizeof(EV_string_response)); + stub_ptr->ret = strdup(response->ret); } CMCondition_signal(cm, response->condition_var); } @@ -889,8 +905,8 @@ sub mod_EVhandler { EV_EVevent_list_response *response = (EV_EVevent_list_response*) data; EV_EVevent_list_response *stub_ptr = CMCondition_get_client_data(cm, response->condition_var); if (NULL != stub_ptr) { - memcpy(stub_ptr, data, sizeof(EV_EVevent_list_response)); - stub_ptr->ret = copy_EVevent_list(response->ret); + memcpy(stub_ptr, data, sizeof(EV_EVevent_list_response)); + stub_ptr->ret = copy_EVevent_list(response->ret); } CMCondition_signal(cm, response->condition_var); } @@ -915,7 +931,7 @@ sub mod_EVhandler { EOF print REVPH< #endif #ifdef HAVE_WINDOWS_H +#ifndef FD_SETSIZE #define FD_SETSIZE 1024 +#endif #include #include #include @@ -334,7 +336,27 @@ get_qual_hostname(char *buf, int len, attr_list attrs, trace_func(trace_data, "CM - Tentative Qualified hostname %s", buf); if (memchr(buf, '.', strlen(buf)) == NULL) { /* useless hostname if it's not fully qualified */ - buf[0] = 0; + struct addrinfo hints, *info, *p; + int gai_result; + + char hostname[1024]; + hostname[1023] = '\0'; + gethostname(hostname, 1023); + + memset(&hints, 0, sizeof hints); + hints.ai_family = AF_UNSPEC; /*either IPV4 or IPV6*/ + hints.ai_socktype = SOCK_STREAM; + hints.ai_flags = AI_CANONNAME; + + if ((gai_result = getaddrinfo(hostname, NULL, &hints, &info)) != 0) { + fprintf(stderr, "getaddrinfo: %s\n", gai_strerror(gai_result)); + } + + for(p = info; p != NULL; p = p->ai_next) { + strcpy(buf, p->ai_canonname); + } + + freeaddrinfo(info); } if ((buf[0] != 0) && ((host = gethostbyname(buf)) == NULL)) { /* useless hostname if we can't translate it */ @@ -484,7 +506,7 @@ dump_output(int length_estimate, char *format, ...) #ifndef HOST_NAME_MAX #define HOST_NAME_MAX 255 #endif -#ifdef _MSC_VER +#ifdef _WIN32 static int inet_aton(const char* cp, struct in_addr* addr) { addr->s_addr = inet_addr(cp); diff --git a/metrics.c b/metrics.c index fdfc365f64..cf9c64380c 100644 --- a/metrics.c +++ b/metrics.c @@ -603,7 +603,7 @@ double dgettimeofday( void ) /**************OS FUNCTIONS**************/ char* os_type() { -#ifndef _MSC_VER +#ifndef _WIN32 static struct utsname output; static int first = 1; if (first) { @@ -617,7 +617,7 @@ char* os_type() { } char* os_release() { -#ifndef _MSC_VER +#ifndef _WIN32 static struct utsname output; static int first = 1; if (first) { diff --git a/mtests/cmconn.c b/mtests/cmconn.c index a2a3cafdd3..1513792c90 100644 --- a/mtests/cmconn.c +++ b/mtests/cmconn.c @@ -26,14 +26,14 @@ #include #endif #include "evpath.h" -#ifdef HAVE_SYS_WAIT_H -#include -#endif + #ifdef _MSC_VER #define drand48() (((double)rand())/((double)RAND_MAX)) #define lrand48() rand() #define srand48(x) #define kill(x,y) TerminateProcess(OpenProcess(0,0,(DWORD)x),y) +#else +#include #endif typedef struct _msg_rec { char *contact_list; diff --git a/mtests/cmping.c b/mtests/cmping.c index 067eb11f76..59a0783054 100644 --- a/mtests/cmping.c +++ b/mtests/cmping.c @@ -18,6 +18,7 @@ #define srand48(x) #define kill(x,y) TerminateProcess(OpenProcess(0,0,(DWORD)x),y) #else +#include #include #include #endif diff --git a/mtests/cmtest.c b/mtests/cmtest.c index 0396443fee..3b2ef85810 100644 --- a/mtests/cmtest.c +++ b/mtests/cmtest.c @@ -18,6 +18,7 @@ #define srand48(x) #define kill(x,y) TerminateProcess(OpenProcess(0, 0, (DWORD)x),y) #else +#include #include #include #endif diff --git a/mtests/support.c b/mtests/support.c index 01bb680382..5d9eb0b415 100644 --- a/mtests/support.c +++ b/mtests/support.c @@ -96,13 +96,40 @@ run_subprocess(char **args) { char **run_args = args; #ifdef HAVE_WINDOWS_H - intptr_t child; - child = _spawnv(_P_NOWAIT, "./evtest.exe", args); - if (child == -1) { - printf("failed for evtest\n"); - perror("spawnv"); + STARTUPINFO si; + PROCESS_INFORMATION pi; + char comm_line[8191]; + + ZeroMemory( &si, sizeof(si) ); + si.cb = sizeof(si); + ZeroMemory( &pi, sizeof(pi) ); + char module[MAX_PATH]; + GetModuleFileName(NULL, &module[0], MAX_PATH); + int i = 1; + strcpy(comm_line, module); + strcat(comm_line, " "); + while (args[i] != NULL) { + strcat(comm_line, args[i]); + strcat(comm_line, " "); + i++; + } - return child; + if (!CreateProcess(module, + comm_line, + NULL, // Process handle not inheritable + NULL, // Thread handle not inheritable + FALSE, // Set handle inheritance to FALSE + 0, // No creation flags + NULL, // Use parent's environment block + NULL, // Use parent's starting directory + &si, // Pointer to STARTUPINFO structure + &pi ) + ) + { + printf( "CreateProcess failed (%d).\n", GetLastError() ); + return 0; + } + return (intptr_t) pi.hProcess; #else pid_t child; if (quiet <=0) {printf("Forking subprocess\n");} diff --git a/qual_hostname.c b/qual_hostname.c index eed0e028f1..138dde1706 100644 --- a/qual_hostname.c +++ b/qual_hostname.c @@ -7,7 +7,9 @@ #include #endif #ifdef HAVE_WINDOWS_H +#ifndef FD_SETSIZE #define FD_SETSIZE 1024 +#endif #include #define __ANSI_CPP__ #else diff --git a/response.c b/response.c index fae5c44294..fb7eae9ae9 100644 --- a/response.c +++ b/response.c @@ -1700,7 +1700,7 @@ internal_cod_submit(cod_exec_context ec, int port, void *data, void *type_info) internal_cod_submit_general(ec, port, data, type_info, NULL, NULL); } -#ifdef _MSC_VER +#ifdef _WIN32 static long lrand48() { return rand(); @@ -1709,12 +1709,14 @@ static long lrand48() static double drand48() { return (double)(rand()) / (double)(RAND_MAX); } +#ifdef _MSVC static void sleep(int t) { Sleep(t * 1000); } #endif +#endif static void add_standard_routines(stone_type stone, cod_parse_context context) { @@ -1974,7 +1976,7 @@ extern sm_ref cod_build_param_node(const char *id, sm_ref typ, int param_num); extern void cod_add_decl_to_parse_context(const char *name, sm_ref item, cod_parse_context context); -extern FFS_DECLSPEC void +extern void cod_add_param(const char *id, const char *typ, int param_num, cod_parse_context context); diff --git a/rtests/evtest.c b/rtests/evtest.c index cf1a2ac732..615fc7f903 100644 --- a/rtests/evtest.c +++ b/rtests/evtest.c @@ -20,6 +20,7 @@ #define srand48(x) #define kill(x,y) TerminateProcess(OpenProcess(0,0,(DWORD)x),y) #else +#include #include #include #endif diff --git a/rtests/extract_test.c b/rtests/extract_test.c index ed2677329b..47fe155248 100644 --- a/rtests/extract_test.c +++ b/rtests/extract_test.c @@ -19,6 +19,7 @@ #define srand48(x) #define kill(x,y) TerminateProcess(OpenProcess(0, 0, (DWORD)x),y) #else +#include #include #include #endif diff --git a/rtests/remote_terminal_test.c b/rtests/remote_terminal_test.c index 999bb626b4..8896145d1c 100644 --- a/rtests/remote_terminal_test.c +++ b/rtests/remote_terminal_test.c @@ -19,6 +19,7 @@ #define srand48(x) #define kill(x,y) TerminateProcess(OpenProcess(0,0,(DWORD)x),y) #else +#include #include #include #endif diff --git a/tests/auto_test.c b/tests/auto_test.c index aeba229bf0..7d7046db26 100644 --- a/tests/auto_test.c +++ b/tests/auto_test.c @@ -345,11 +345,11 @@ do_regression_master_test() printf("Waiting for remote....\n"); } #ifdef HAVE_WINDOWS_H - if (_cwait(&exit_state, subproc_proc, 0) == -1) { - perror("cwait"); - } + WaitForSingleObject((HANDLE)subproc_proc, INFINITE ); + DWORD exitCode = 0; + GetExitCodeProcess((HANDLE)subproc_proc, &exitCode); + exit_state = exitCode; if (exit_state == 0) { - if (quiet <= 0) printf("Passed single remote subproc test\n"); } else { printf("Single remote subproc exit with status %d\n", diff --git a/tests/block_test.c b/tests/block_test.c index 4e64d7db0f..c5bb25e8a1 100644 --- a/tests/block_test.c +++ b/tests/block_test.c @@ -444,18 +444,6 @@ do_regression_master_test() printf("Waiting for remote....\n"); } while (!done) { -#ifdef HAVE_WINDOWS_H - if (_cwait(&exit_state, subproc_proc, 0) == -1) { - perror("cwait"); - } - if (exit_state == 0) { - if (quiet <= 0) - printf("Subproc exitted\n"); - } else { - printf("Single remote subproc exit with status %d\n", - exit_state); - } -#else int result, j; if (quiet <= 0) { printf(","); @@ -467,6 +455,18 @@ do_regression_master_test() } done++; /* CMsleep(cm, 50); done++;*/ +#ifdef HAVE_WINDOWS_H + WaitForSingleObject((HANDLE)subproc_proc, INFINITE ); + DWORD exitCode = 0; + GetExitCodeProcess((HANDLE)subproc_proc, &exitCode); + exit_state = exitCode; + if (exit_state == 0) { + printf("Passed single remote subproc test\n"); + } else { + printf("Single remote subproc exit with status %d\n", + exit_state); + } +#else result = waitpid(subproc_proc, &exit_state, WNOHANG); if (result == -1) { perror("waitpid"); diff --git a/tests/bulktest.c b/tests/bulktest.c index 9068ffd1f7..ada01bb033 100644 --- a/tests/bulktest.c +++ b/tests/bulktest.c @@ -263,7 +263,7 @@ main(int argc, char **argv) int regression_master = 1; int forked = 0; - argv0 = argv[0];\ + argv0 = argv[0]; while (argv[1] && (argv[1][0] == '-')) { if (strcmp(&argv[1][1], "size") == 0) { if (sscanf(argv[2], "%d", &size) != 1) { @@ -600,25 +600,28 @@ do_regression_master_test() printf("Waiting for remote....\n"); } while (!done) { -#ifdef HAVE_WINDOWS_H - if (_cwait(&exit_state, subproc_proc, 0) == -1) { - perror("cwait"); - } - if (exit_state == 0) { - if (quiet <= 0) - printf("Subproc exitted\n"); - } else { - printf("Single remote subproc exit with status %d\n", - exit_state); - } -#else - int result; if (quiet <= 0) { printf(","); fflush(stdout); } CMsleep(cm, 50); done++; +#ifdef HAVE_WINDOWS_H + DWORD result = WaitForSingleObject((HANDLE)subproc_proc, 1 ); + if (result != WAIT_TIMEOUT) { + DWORD exitCode = 0; + GetExitCodeProcess((HANDLE)subproc_proc, &exitCode); + exit_state = exitCode; + if (exit_state == 0) { + printf("Passed single remote subproc test\n"); + } else { + printf("Single remote subproc exit with status %d\n", + exit_state); + } + done++; + } +#else + int result; result = waitpid(subproc_proc, &exit_state, WNOHANG); if (result == -1) { perror("waitpid"); diff --git a/tests/evtest.c b/tests/evtest.c index b13102dbf8..1a2cdf22fb 100644 --- a/tests/evtest.c +++ b/tests/evtest.c @@ -18,6 +18,7 @@ #define srand48(x) #define kill(x,y) TerminateProcess(OpenProcess(0,0,(DWORD)x),y) #else +#include #include #include #endif @@ -369,11 +370,11 @@ do_regression_master_test() printf("Waiting for remote....\n"); } #ifdef HAVE_WINDOWS_H - if (_cwait(&exit_state, subproc_proc, 0) == -1) { - perror("cwait"); - } + WaitForSingleObject((HANDLE)subproc_proc, INFINITE ); + DWORD exitCode = 0; + GetExitCodeProcess((HANDLE)subproc_proc, &exitCode); + exit_state = exitCode; if (exit_state == 0) { - if (quiet <= 0) printf("Passed single remote subproc test\n"); } else { printf("Single remote subproc exit with status %d\n", diff --git a/tests/extract_test.c b/tests/extract_test.c index 5ef1816aed..90247c7abd 100644 --- a/tests/extract_test.c +++ b/tests/extract_test.c @@ -321,7 +321,7 @@ main(int argc, char **argv) EVdrain_stone(cm, term1); events = EVextract_stone_events(cm, term1); count = 0; - while (events && (events[count].length != -1)) { + while (events && (events[count].length != (size_t)-1)) { EVsubmit_encoded(cm, term0, events[count].buffer, events[count].length, attrs); count++; } diff --git a/tests/support.c b/tests/support.c index 5a13be452c..f1ced333e1 100644 --- a/tests/support.c +++ b/tests/support.c @@ -103,13 +103,42 @@ run_subprocess(char **args) { char **run_args = args; #ifdef HAVE_WINDOWS_H - intptr_t child; - child = _spawnv(_P_NOWAIT, "./evtest.exe", args); - if (child == -1) { - printf("failed for evtest\n"); - perror("spawnv"); + STARTUPINFO si; + PROCESS_INFORMATION pi; + char comm_line[8191]; + + ZeroMemory( &si, sizeof(si) ); + si.cb = sizeof(si); + ZeroMemory( &pi, sizeof(pi) ); + char module[MAX_PATH]; + GetModuleFileName(NULL, &module[0], MAX_PATH); + int i = 1; + strcpy(comm_line, module); + strcat(comm_line, " "); + while (args[i] != NULL) { + strcat(comm_line, args[i]); + strcat(comm_line, " "); + i++; + } - return child; + if (!CreateProcess(module, + comm_line, + NULL, // Process handle not inheritable + NULL, // Thread handle not inheritable + FALSE, // Set handle inheritance to FALSE + 0, // No creation flags + NULL, // Use parent's environment block + NULL, // Use parent's starting directory + &si, // Pointer to STARTUPINFO structure + &pi ) + ) + { + printf( "CreateProcess failed (%d).\n", GetLastError() ); + printf("Args were argv[0] = %s\n", args[0]); + printf("Args were argv[1] = %s, argv[2] = %s\n", args[1], args[2]); + return 0; + } + return (intptr_t) pi.hProcess; #else pid_t child; if (quiet <=0) {printf("Forking subprocess\n");} @@ -149,6 +178,7 @@ run_subprocess(char **args) while(run_args[i]) { printf("%s ", run_args[i++]); } + printf("\n"); } if (no_fork) { child = -1; diff --git a/thin_server.c b/thin_server.c index 6e2080bd90..9502cd35b5 100644 --- a/thin_server.c +++ b/thin_server.c @@ -3,7 +3,9 @@ #include #include #ifdef HAVE_WINSOCK2_H +#ifndef FD_SETSIZE #define FD_SETSIZE 1024 +#endif #include #include #define drand48() (((double)rand())/((double)RAND_MAX)) diff --git a/version.c b/version.c index eced0882d4..db921e39ed 100644 --- a/version.c +++ b/version.c @@ -2,7 +2,7 @@ #include #include "config.h" -static char *EVPath_version = "EVPath Version 4.2.4 -- Mon Dec 4 16:21:33 EST 2017\n"; +static char *EVPath_version = "EVPath Version 4.5.2 -- Mon Aug 5 15:33:46 EDT 2024\n"; #if defined (__INTEL_COMPILER) // Allow extern declarations with no prior decl From 833a20b7dc8f76729f4019f75f664fc51f715565 Mon Sep 17 00:00:00 2001 From: EVPath Upstream Date: Tue, 6 Aug 2024 14:54:43 -0400 Subject: [PATCH 3/3] EVPath 2024-08-06 (17be1a03) Code extracted from: https://github.com/GTkorvo/EVPath.git at commit 17be1a03434d889415100d2dfe4d3932aaf04498 (master). Upstream Shortlog ----------------- --- CMakeLists.txt | 2 +- cm_schedule.h | 2 +- response.c | 2 +- version.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2aafc704e3..79181d3d05 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,7 +4,7 @@ cmake_minimum_required(VERSION 3.5) # GTKorvo set(CMAKE_DIRECTORY_LABELS EVPath) -project(EVPath VERSION 4.5.2 LANGUAGES C CXX) +project(EVPath VERSION 4.5.3 LANGUAGES C CXX) # Enable _ROOT variables for dependency searching # CMake v3.12 diff --git a/cm_schedule.h b/cm_schedule.h index 9dff2ad785..766d80d24a 100644 --- a/cm_schedule.h +++ b/cm_schedule.h @@ -7,7 +7,7 @@ extern "C" { #endif -#ifdef __WIN32 +#ifdef _WIN32 #ifndef FD_SETSIZE #define FD_SETSIZE 1024 #endif diff --git a/response.c b/response.c index fb7eae9ae9..8373149d01 100644 --- a/response.c +++ b/response.c @@ -1709,7 +1709,7 @@ static long lrand48() static double drand48() { return (double)(rand()) / (double)(RAND_MAX); } -#ifdef _MSVC +#ifndef HAVE_UNISTD_H static void sleep(int t) { diff --git a/version.c b/version.c index db921e39ed..b31925a519 100644 --- a/version.c +++ b/version.c @@ -2,7 +2,7 @@ #include #include "config.h" -static char *EVPath_version = "EVPath Version 4.5.2 -- Mon Aug 5 15:33:46 EDT 2024\n"; +static char *EVPath_version = "EVPath Version 4.5.3 -- Tue Aug 6 13:53:13 EDT 2024\n"; #if defined (__INTEL_COMPILER) // Allow extern declarations with no prior decl