From 13e139375e3c4b8ab988252129d974e0d6df5737 Mon Sep 17 00:00:00 2001 From: atl Upstream Date: Thu, 11 Jul 2024 12:02:17 -0400 Subject: [PATCH 1/3] atl 2024-07-11 (957697f5) Code extracted from: https://github.com/GTkorvo/atl.git at commit 957697f586fff4c11921b16abd21ddd19a183e08 (master). Upstream Shortlog ----------------- --- atom.c | 1 + 1 file changed, 1 insertion(+) diff --git a/atom.c b/atom.c index 7417164309..b67652955c 100644 --- a/atom.c +++ b/atom.c @@ -494,6 +494,7 @@ static void nt_socket_init_func(){} static char *in_use_values[] = { +"CM_CMANAGER_ID", "CM_BW_MEASURED_COF", "CM_BW_MEASURED_VALUE", "CM_BW_MEASURE_INTERVAL", From ecaeeae0300776cb322a2c85252ad538b5f75845 Mon Sep 17 00:00:00 2001 From: EVPath Upstream Date: Thu, 11 Jul 2024 14:25:28 -0400 Subject: [PATCH 2/3] EVPath 2024-07-11 (47663b71) Code extracted from: https://github.com/GTkorvo/EVPath.git at commit 47663b710b9a1f0439dc1af628070b68ad2c7d9c (master). Upstream Shortlog ----------------- --- CMakeLists.txt | 10 +- cm.c | 27 +- cm_control.c | 4 +- cm_internal.h | 44 ++- cm_threadio.c | 2 +- cm_util.c | 54 ++- cmenet.c | 2 +- cmepoll.c | 128 ++---- cmib.c | 71 +--- cmmulticast.c | 2 +- cmselect.c | 28 +- cmsockets.c | 26 +- cmudp.c | 2 +- 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 + ev_dfg.c | 5 +- ev_internal.h | 2 +- evp.c | 10 +- gen_interface.pl | 692 +++++++++++++++++---------------- mtests/cmconn.c | 6 +- mtests/cmping.c | 1 + mtests/cmtest.c | 1 + mtests/support.c | 39 +- response.c | 2 +- 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 +- 35 files changed, 695 insertions(+), 610 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 003f31325f..384160c512 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -376,7 +376,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 +447,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 +485,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 +548,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 +571,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 diff --git a/cm.c b/cm.c index e1bb4fdc9e..b24a401c37 100644 --- a/cm.c +++ b/cm.c @@ -60,6 +60,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 +233,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 +259,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 +576,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 +754,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 +775,9 @@ INT_CManager_create_control(char *control_module) cm->transports = NULL; cm->initialized = 0; cm->reference_count = 1; + long seed = getpid() + time(NULL); + srand48(seed); + cm->CManager_ID = (int)lrand48(); char *tmp; if ((tmp = getenv("CMControlModule"))) { @@ -1053,7 +1059,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 +1496,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 +1697,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 +2098,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 +3862,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; 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_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_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/cmenet.c b/cmenet.c index eeac56f3e5..b33989de52 100644 --- a/cmenet.c +++ b/cmenet.c @@ -1414,7 +1414,7 @@ int err; * NT Sux. */ -int +static int pipe(filedes) SOCKET filedes[2]; { diff --git a/cmepoll.c b/cmepoll.c index b28fca2790..84d95470c9 100644 --- a/cmepoll.c +++ b/cmepoll.c @@ -114,10 +114,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 +154,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 +179,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 +202,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 +216,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 +460,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 +519,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 +589,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 +636,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 +682,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 +720,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 +730,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 +761,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 +769,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 +784,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 +845,8 @@ int err; * NT Sux. */ -int -pipe(filedes) -int filedes[2]; +static int +pipe(int filedes[2]) { int length; @@ -990,9 +934,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 +957,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 +965,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 +980,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 +995,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 +1010,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 +1018,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 +1032,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 +1045,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..1a956cedb1 100644 --- a/cmib.c +++ b/cmib.c @@ -369,9 +369,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 +391,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 +943,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 +1101,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 +1134,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 +1399,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 +1429,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 +1477,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 +1523,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 +1686,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 +1879,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 +1899,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..3d0e1f0897 100644 --- a/cmmulticast.c +++ b/cmmulticast.c @@ -449,7 +449,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..866cd9c925 100644 --- a/cmselect.c +++ b/cmselect.c @@ -109,7 +109,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 +153,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 +179,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 +221,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 +260,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 +268,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 +321,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 +440,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 +496,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 +652,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 +699,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 +751,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 +879,7 @@ int err; * NT Sux. */ -int +static int pipe(SOCKET *filedes) { diff --git a/cmsockets.c b/cmsockets.c index a4bfb79688..3cc819a9d4 100644 --- a/cmsockets.c +++ b/cmsockets.c @@ -457,7 +457,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 @@ -880,6 +879,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 } @@ -910,7 +929,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 +1155,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..4c6815f2ad 100644 --- a/cmudp.c +++ b/cmudp.c @@ -646,7 +646,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/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/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 #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/response.c b/response.c index fae5c44294..fad8f71cac 100644 --- a/response.c +++ b/response.c @@ -1974,7 +1974,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; From 2505eb4db56c4c1eb6fb8d6f962a51f275f7d6c1 Mon Sep 17 00:00:00 2001 From: EVPath Upstream Date: Thu, 11 Jul 2024 16:30:15 -0400 Subject: [PATCH 3/3] EVPath 2024-07-11 (39325269) Code extracted from: https://github.com/GTkorvo/EVPath.git at commit 39325269e73f886d235bf3f5da80a48ff974ac4b (master). Upstream Shortlog ----------------- --- cm.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cm.c b/cm.c index b24a401c37..b787b72f7f 100644 --- a/cm.c +++ b/cm.c @@ -20,6 +20,8 @@ #define FD_SETSIZE 1024 #include #define __ANSI_CPP__ +#define lrand48() rand() +#define srand48(x) srand((unsigned int)(x)) #else #include #include @@ -775,7 +777,7 @@ INT_CManager_create_control(char *control_module) cm->transports = NULL; cm->initialized = 0; cm->reference_count = 1; - long seed = getpid() + time(NULL); + uint64_t seed = getpid() + time(NULL); srand48(seed); cm->CManager_ID = (int)lrand48();