From b2ba000668fa8ff71be70033329ca438645a3f27 Mon Sep 17 00:00:00 2001 From: EVPath Upstream Date: Sat, 7 Dec 2024 05:35:21 +1000 Subject: [PATCH] EVPath 2024-12-07 (5663b5a6) Code extracted from: https://github.com/GTkorvo/EVPath.git at commit 5663b5a6a84dd35bc65a9ce1789697b0f7b95b41 (master). Upstream Shortlog ----------------- --- .indent.pro | 2 +- CMakeLists.txt | 109 +- 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 | 694 ++++---- ip_config.c | 26 +- metrics.c | 4 +- mtests/cmconn.c | 6 +- mtests/cmping.c | 1 + mtests/cmtest.c | 1 + mtests/support.c | 39 +- pregen-source/cm_interface.c | 1590 ++++++++++++++++++ pregen-source/revp.c | 2756 ++++++++++++++++++++++++++++++++ pregen-source/revp_internal.h | 106 ++ pregen-source/revpath.h | 113 ++ 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 +- 53 files changed, 5413 insertions(+), 692 deletions(-) create mode 100644 pregen-source/cm_interface.c create mode 100644 pregen-source/revp.c create mode 100644 pregen-source/revp_internal.h create mode 100644 pregen-source/revpath.h 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..4de146303f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,28 +1,10 @@ -cmake_minimum_required(VERSION 3.5) +cmake_minimum_required(VERSION 3.14) # The directory label is used for CDash to treat EVPath as a subproject of # GTKorvo set(CMAKE_DIRECTORY_LABELS EVPath) -project(EVPath VERSION 4.5.0 LANGUAGES C CXX) - -# Enable _ROOT variables for dependency searching -# CMake v3.12 -if(POLICY CMP0074) - cmake_policy(SET CMP0074 NEW) -endif() - -# Enable imported targets as library dependencies for CHECK_INCLUDE_FILE -if(POLICY CMP0075) - cmake_policy(SET CMP0075 NEW) -endif() - -# Let option(...) setings work with non-cache variables. Useful for including -# EVPath as a third party dependency in another project. -# CMake v3.13 -if(POLICY CMP0077) - cmake_policy(SET CMP0077 NEW) -endif() +project(EVPath VERSION 4.5.4 LANGUAGES C CXX) # Some boilerplate to setup nice output directories include(GNUInstallDirs) @@ -87,7 +69,6 @@ if(WIN32) -D_SCL_SECURE_NO_DEPRECATE -D_WINSOCK_DEPRECATED_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE) - set (MSVC_PERL_FLAGS "-msvc-long") endif() endif() @@ -138,7 +119,7 @@ add_library(EVPath cm.c cm_control.c cm_formats.c cm_util.c cm_transport.c cm_lock.c cm_perf.c cm_pbio.c cm_interface.c version.c cm_threadio.c cm_evol.c evp.c response.c metrics.c - dlloader.c ip_config.c chr_time.c + dlloader.c ip_config.c chr_time.c revpath.h revp_internal.h revp.c evp_compat.c thin_server.c evp_threads.c ev_dfg.c) add_library(EVPath::EVPath ALIAS EVPath) add_library(evpath ALIAS EVPath) @@ -297,10 +278,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 +294,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 +362,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 +433,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 +471,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 +534,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 +557,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 @@ -580,21 +566,42 @@ install(DIRECTORY ${PROJECT_SOURCE_DIR}/cmake/ FILES_MATCHING PATTERN "Find*.cmake" PATTERN "CMake*.cmake" ) -add_custom_command( - OUTPUT "cm_interface.c" "revp.c" "revpath.h" - SOURCE - ${CMAKE_CURRENT_SOURCE_DIR}/evpath.h ${CMAKE_CURRENT_SOURCE_DIR}/ev_dfg.h - COMMAND perl - ${CMAKE_CURRENT_SOURCE_DIR}/gen_interface.pl - ${CMAKE_CURRENT_SOURCE_DIR}/evpath.h - ${CMAKE_CURRENT_SOURCE_DIR}/ev_dfg.h - ${CMAKE_CURRENT_SOURCE_DIR}/cm_schedule.h - DEPENDS - ${CMAKE_CURRENT_SOURCE_DIR}/gen_interface.pl - ${CMAKE_CURRENT_SOURCE_DIR}/evpath.h - ${CMAKE_CURRENT_SOURCE_DIR}/ev_dfg.h - ${CMAKE_CURRENT_SOURCE_DIR}/cm_schedule.h -) +find_package(Perl) + +if (PERL_FOUND) + add_custom_command( + OUTPUT "cm_interface.c" "revp.c" "revpath.h" "revp_internal.h" + COMMAND ${PERL_EXECUTABLE} + ${CMAKE_CURRENT_SOURCE_DIR}/gen_interface.pl + ${CMAKE_CURRENT_SOURCE_DIR}/evpath.h + ${CMAKE_CURRENT_SOURCE_DIR}/ev_dfg.h + ${CMAKE_CURRENT_SOURCE_DIR}/cm_schedule.h + DEPENDS + ${CMAKE_CURRENT_SOURCE_DIR}/gen_interface.pl + ${CMAKE_CURRENT_SOURCE_DIR}/evpath.h + ${CMAKE_CURRENT_SOURCE_DIR}/ev_dfg.h + ${CMAKE_CURRENT_SOURCE_DIR}/cm_schedule.h + ) +else() + add_custom_command(OUTPUT cm_interface.c + COMMAND ${CMAKE_COMMAND} -E copy + ${PROJECT_SOURCE_DIR}/pregen-source/cm_interface.c cm_interface.c + COMMENT "Copying pregen cm_interface.c to build area") + add_custom_command(OUTPUT revp.c + COMMAND ${CMAKE_COMMAND} -E copy + ${PROJECT_SOURCE_DIR}/pregen-source/revp.c revp.c + COMMENT "Copying pregen revp.c to build area") + add_custom_command(OUTPUT revpath.h + COMMAND ${CMAKE_COMMAND} -E copy + ${PROJECT_SOURCE_DIR}/pregen-source/revpath.h revpath.h + COMMENT "Copying pregen revpath.h to build area") + + add_custom_command(OUTPUT revp_internal.h + COMMAND ${CMAKE_COMMAND} -E copy + ${PROJECT_SOURCE_DIR}/pregen-source/revp_internal.h revp_internal.h + COMMENT "Copying pregen revp_internal.h to build area") + +endif() if(Threads_FOUND AND CMAKE_USE_PTHREADS_INIT) set(USE_PTHREADS TRUE) @@ -604,6 +611,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..766d80d24a 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..791ea96efa 100755 --- a/gen_interface.pl +++ b/gen_interface.pl @@ -1,4 +1,4 @@ -#! /usr/bin/env - perl +#!perl use File::Basename; my $dirname = dirname(__FILE__); @@ -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/pregen-source/cm_interface.c b/pregen-source/cm_interface.c new file mode 100644 index 0000000000..ce16c335bb --- /dev/null +++ b/pregen-source/cm_interface.c @@ -0,0 +1,1590 @@ +/* + * This file is automatically generated by gen_interface.pl from evpath.h. + * + * DO NOT EDIT + * + */ +#include "config.h" +#include "stdio.h" +#include "string.h" +#include "stdlib.h" +#include "ffs.h" +#ifdef HAVE_COD_H +#include "cod.h" +#endif +#include "atl.h" +#include "evpath.h" +#include "cm_internal.h" +#include "ev_dfg.h" +#include "ev_dfg_internal.h" +#ifdef __cplusplus +extern "C" { +#endif + +extern int +CMCondition_get ( CManager cm, CMConnection dep ) +{ + int ret; + CManager_lock(cm); + ret = INT_CMCondition_get(cm, dep); + CManager_unlock(cm); + return ret; +} + +extern void* +CMCondition_get_client_data ( CManager cm, int condition ) +{ + void* ret; + CManager_lock(cm); + ret = INT_CMCondition_get_client_data(cm, condition); + CManager_unlock(cm); + return ret; +} + +extern int +CMCondition_has_failed ( CManager cm, int condition ) +{ + int ret; + CManager_lock(cm); + ret = INT_CMCondition_has_failed(cm, condition); + CManager_unlock(cm); + return ret; +} + +extern int +CMCondition_has_signaled ( CManager cm, int condition ) +{ + int ret; + CManager_lock(cm); + ret = INT_CMCondition_has_signaled(cm, condition); + CManager_unlock(cm); + return ret; +} + +extern void +CMCondition_set_client_data ( CManager cm, int condition, void *client_data ) +{ + CManager_lock(cm); + INT_CMCondition_set_client_data(cm, condition, client_data); + CManager_unlock(cm); +} + +extern void +CMCondition_signal ( CManager cm, int condition ) +{ + CManager_lock(cm); + INT_CMCondition_signal(cm, condition); + CManager_unlock(cm); +} + +extern int +CMCondition_wait ( CManager cm, int condition ) +{ + int ret; + CManager_lock(cm); + ret = INT_CMCondition_wait(cm, condition); + CManager_unlock(cm); + return ret; +} + +extern void +CMConnection_add_reference ( CMConnection conn ) +{ + CManager cm = conn->cm; + CManager_lock(cm); + INT_CMConnection_add_reference(conn); + CManager_unlock(cm); +} + +extern void +CMConnection_close ( CMConnection conn ) +{ + CManager cm = conn->cm; + CManager_lock(cm); + INT_CMConnection_close(conn); + CManager_unlock(cm); +} + +extern void +CMConnection_dereference ( CMConnection conn ) +{ + CManager cm = conn->cm; + CManager_lock(cm); + INT_CMConnection_dereference(conn); + CManager_unlock(cm); +} + +extern attr_list +CMConnection_get_attrs ( CMConnection conn ) +{ + attr_list ret; + CManager cm = conn->cm; + CManager_lock(cm); + ret = INT_CMConnection_get_attrs(conn); + CManager_unlock(cm); + return ret; +} + +extern int +CMConnection_set_character ( CMConnection conn, attr_list attrs ) +{ + int ret; + CManager cm = conn->cm; + CManager_lock(cm); + ret = INT_CMConnection_set_character(conn, attrs); + CManager_unlock(cm); + return ret; +} + +extern int +CMConnection_write_would_block ( CMConnection conn ) +{ + int ret; + CManager cm = conn->cm; + CManager_lock(cm); + ret = INT_CMConnection_write_would_block(conn); + CManager_unlock(cm); + return ret; +} + +extern void +CMTrace_file_id ( int ID ) +{ + INT_CMTrace_file_id(ID); +} + +extern void +CM_fd_add_select ( CManager cm, SOCKET fd, select_func handler_func, void *param1, void *param2 ) +{ + CManager_lock(cm); + INT_CM_fd_add_select(cm, fd, handler_func, param1, param2); + CManager_unlock(cm); +} + +extern void +CM_insert_contact_info ( CManager cm, attr_list attrs ) +{ + CManager_lock(cm); + INT_CM_insert_contact_info(cm, attrs); + CManager_unlock(cm); +} + +extern CMTaskHandle +CMadd_delayed_task ( CManager cm, int secs, int usecs, CMPollFunc func, void *client_data ) +{ + CMTaskHandle ret; + CManager_lock(cm); + ret = INT_CMadd_delayed_task(cm, secs, usecs, func, client_data); + CManager_unlock(cm); + return ret; +} + +extern CMTaskHandle +CMadd_periodic ( CManager cm, long period, CMPollFunc func, void *client_data ) +{ + CMTaskHandle ret; + CManager_lock(cm); + ret = INT_CMadd_periodic(cm, period, func, client_data); + CManager_unlock(cm); + return ret; +} + +extern CMTaskHandle +CMadd_periodic_task ( CManager cm, int period_sec, int period_usec, CMPollFunc func, void *client_data ) +{ + CMTaskHandle ret; + CManager_lock(cm); + ret = INT_CMadd_periodic_task(cm, period_sec, period_usec, func, client_data); + CManager_unlock(cm); + return ret; +} + +extern void +CMadd_poll ( CManager cm, CMPollFunc func, void *client_data ) +{ + CManager_lock(cm); + INT_CMadd_poll(cm, func, client_data); + CManager_unlock(cm); +} + +extern void +CMadd_shutdown_task ( CManager cm, CMPollFunc func, void *client_data, int task_type ) +{ + CManager_lock(cm); + INT_CMadd_shutdown_task(cm, func, client_data, task_type); + CManager_unlock(cm); +} + +extern void +CMadd_stone_to_global_lookup ( CManager cm, int stone_num, int global_stone_num ) +{ + CManager_lock(cm); + INT_CMadd_stone_to_global_lookup(cm, stone_num, global_stone_num); + CManager_unlock(cm); +} + +extern void +CManager_close ( CManager cm ) +{ + CManager_lock(cm); + INT_CManager_close(cm); +} + +extern CManager +CManager_create ( ) +{ + CManager ret; + ret = INT_CManager_create(); + return ret; +} + +extern CManager +CManager_create_control ( char *control_module ) +{ + CManager ret; + ret = INT_CManager_create_control(control_module); + return ret; +} + +extern void +CMconn_register_close_handler ( CMConnection conn, CMCloseHandlerFunc func, void *client_data ) +{ + CManager cm = conn->cm; + CManager_lock(cm); + INT_CMconn_register_close_handler(conn, func, client_data); + CManager_unlock(cm); +} + +extern int +CMcontact_self_check ( CManager cm, attr_list attrs ) +{ + int ret; + CManager_lock(cm); + ret = INT_CMcontact_self_check(cm, attrs); + CManager_unlock(cm); + return ret; +} + +extern attr_list +CMderef_and_copy_list ( CManager cm, attr_list attrs ) +{ + attr_list ret; + CManager_lock(cm); + ret = INT_CMderef_and_copy_list(cm, attrs); + CManager_unlock(cm); + return ret; +} + +extern int +CMfork_comm_thread ( CManager cm ) +{ + int ret; + CManager_lock(cm); + ret = INT_CMfork_comm_thread(cm); + CManager_unlock(cm); + return ret; +} + +extern void +CMfree ( void *ptr ) +{ + INT_CMfree(ptr); +} + +extern FMContext +CMget_FMcontext ( CManager cm ) +{ + FMContext ret; + ret = INT_CMget_FMcontext(cm); + return ret; +} + +extern CMConnection +CMget_conn ( CManager cm, attr_list contact_list ) +{ + CMConnection ret; + CManager_lock(cm); + ret = INT_CMget_conn(cm, contact_list); + CManager_unlock(cm); + return ret; +} + +extern attr_list +CMget_contact_list ( CManager cm ) +{ + attr_list ret; + CManager_lock(cm); + ret = INT_CMget_contact_list(cm); + CManager_unlock(cm); + return ret; +} + +extern CMConnection +CMget_indexed_conn ( CManager cm, int i ) +{ + CMConnection ret; + CManager_lock(cm); + ret = INT_CMget_indexed_conn(cm, i); + CManager_unlock(cm); + return ret; +} + +extern char* +CMget_ip_config_diagnostics ( CManager cm ) +{ + char* ret; + ret = INT_CMget_ip_config_diagnostics(cm); + return ret; +} + +extern void +CMget_port_range ( CManager cm, int *high_bound, int *low_bound ) +{ + INT_CMget_port_range(cm, high_bound, low_bound); +} + +extern void +CMget_qual_hostname ( CManager cm, char *buf, int len ) +{ + INT_CMget_qual_hostname(cm, buf, len); +} + +extern int +CMget_self_ip_addr ( CManager cm ) +{ + int ret; + ret = INT_CMget_self_ip_addr(cm); + return ret; +} + +extern attr_list +CMget_specific_contact_list ( CManager cm, attr_list attrs ) +{ + attr_list ret; + CManager_lock(cm); + ret = INT_CMget_specific_contact_list(cm, attrs); + CManager_unlock(cm); + return ret; +} + +extern CMtrans_services +CMget_static_trans_services ( ) +{ + CMtrans_services ret; + ret = INT_CMget_static_trans_services(); + return ret; +} + +extern void* +CMget_transport_data ( CMConnection conn ) +{ + void* ret; + CManager cm = conn->cm; + CManager_lock(cm); + ret = INT_CMget_transport_data(conn); + CManager_unlock(cm); + return ret; +} + +extern CMConnection +CMinitiate_conn ( CManager cm, attr_list contact_list ) +{ + CMConnection ret; + CManager_lock(cm); + ret = INT_CMinitiate_conn(cm, contact_list); + CManager_unlock(cm); + return ret; +} + +extern void +CMinstall_perf_upcall ( CManager cm, CMperf_upcall upcall ) +{ + CManager_lock(cm); + INT_CMinstall_perf_upcall(cm, upcall); + CManager_unlock(cm); +} + +extern int +CMinstall_pull_schedule ( CManager cm, struct timeval *base_time, struct timeval *period, CMavail_period_ptr avail ) +{ + int ret; + CManager_lock(cm); + ret = INT_CMinstall_pull_schedule(cm, base_time, period, avail); + CManager_unlock(cm); + return ret; +} + +extern int +CMlisten ( CManager cm ) +{ + int ret; + CManager_lock(cm); + ret = INT_CMlisten(cm); + CManager_unlock(cm); + return ret; +} + +extern int +CMlisten_specific ( CManager cm, attr_list listen_info ) +{ + int ret; + CManager_lock(cm); + ret = INT_CMlisten_specific(cm, listen_info); + CManager_unlock(cm); + return ret; +} + +extern CMFormat +CMlookup_format ( CManager cm, FMStructDescList format_list ) +{ + CMFormat ret; + CManager_lock(cm); + ret = INT_CMlookup_format(cm, format_list); + CManager_unlock(cm); + return ret; +} + +extern void* +CMmalloc ( long size ) +{ + void* ret; + ret = INT_CMmalloc(size); + return ret; +} + +extern void +CMpoll_network ( CManager cm ) +{ + CManager_lock(cm); + INT_CMpoll_network(cm); + CManager_unlock(cm); +} + +extern double +CMprobe_bandwidth ( CMConnection conn, long size, attr_list attrs ) +{ + double ret; + CManager cm = conn->cm; + CManager_lock(cm); + ret = INT_CMprobe_bandwidth(conn, size, attrs); + CManager_unlock(cm); + return ret; +} + +extern long +CMprobe_latency ( CMConnection conn, long msg_size, attr_list attrs ) +{ + long ret; + CManager cm = conn->cm; + CManager_lock(cm); + ret = INT_CMprobe_latency(conn, msg_size, attrs); + CManager_unlock(cm); + return ret; +} + +extern void* +CMrealloc ( void *ptr, long size ) +{ + void* ret; + ret = INT_CMrealloc(ptr, size); + return ret; +} + +extern CMFormat +CMregister_format ( CManager cm, FMStructDescList format_list ) +{ + CMFormat ret; + CManager_lock(cm); + ret = INT_CMregister_format(cm, format_list); + CManager_unlock(cm); + return ret; +} + +extern void +CMregister_handler ( CMFormat format, CMHandlerFunc handler, void *client_data ) +{ + CManager cm = format->cm; + CManager_lock(cm); + INT_CMregister_handler(format, handler, client_data); + CManager_unlock(cm); +} + +extern void +CMregister_invalid_message_handler ( CManager cm, CMUnregCMHandler handler ) +{ + INT_CMregister_invalid_message_handler(cm, handler); +} + +extern void +CMregister_non_CM_message_handler ( int header, CMNonCMHandler handler ) +{ + INT_CMregister_non_CM_message_handler(header, handler); +} + +extern CMFormat +CMregister_simple_format ( CManager cm, char *format_name, FMFieldList field_list, int struct_size ) +{ + CMFormat ret; + CManager_lock(cm); + ret = INT_CMregister_simple_format(cm, format_name, field_list, struct_size); + CManager_unlock(cm); + return ret; +} + +extern void +CMregister_write_callback ( CMConnection conn, CMWriteCallbackFunc handler, void *client_data ) +{ + CManager cm = conn->cm; + CManager_lock(cm); + INT_CMregister_write_callback(conn, handler, client_data); + CManager_unlock(cm); +} + +extern double +CMregressive_probe_bandwidth ( CMConnection conn, long size, attr_list attrs ) +{ + double ret; + CManager cm = conn->cm; + CManager_lock(cm); + ret = INT_CMregressive_probe_bandwidth(conn, size, attrs); + CManager_unlock(cm); + return ret; +} + +extern void +CMremove_periodic ( CMTaskHandle handle ) +{ + CManager cm = handle->cm; + CManager_lock(cm); + INT_CMremove_periodic(handle); + CManager_unlock(cm); +} + +extern void +CMremove_task ( CMTaskHandle handle ) +{ + CManager cm = handle->cm; + CManager_lock(cm); + INT_CMremove_task(handle); + CManager_unlock(cm); +} + +extern void +CMreturn_buffer ( CManager cm, void *data ) +{ + CManager_lock(cm); + INT_CMreturn_buffer(cm, data); + CManager_unlock(cm); +} + +extern void +CMrun_network ( CManager cm ) +{ + CManager_lock(cm); + INT_CMrun_network(cm); + CManager_unlock(cm); +} + +extern void +CMsleep ( CManager cm, int secs ) +{ + CManager_lock(cm); + INT_CMsleep(cm, secs); + CManager_unlock(cm); +} + +extern void* +CMtake_buffer ( CManager cm, void *data ) +{ + void* ret; + CManager_lock(cm); + ret = INT_CMtake_buffer(cm, data); + CManager_unlock(cm); + return ret; +} + +extern attr_list +CMtest_transport ( CMConnection conn, attr_list how ) +{ + attr_list ret; + CManager cm = conn->cm; + CManager_lock(cm); + ret = INT_CMtest_transport(conn, how); + CManager_unlock(cm); + return ret; +} + +extern void +CMusleep ( CManager cm, int usecs ) +{ + CManager_lock(cm); + INT_CMusleep(cm, usecs); + CManager_unlock(cm); +} + +extern int +CMwrite ( CMConnection conn, CMFormat format, void *data ) +{ + int ret; + CManager cm = conn->cm; + CManager_lock(cm); + ret = INT_CMwrite(conn, format, data); + CManager_unlock(cm); + return ret; +} + +extern int +CMwrite_attr ( CMConnection conn, CMFormat format, void *data, attr_list attrs ) +{ + int ret; + CManager cm = conn->cm; + CManager_lock(cm); + ret = INT_CMwrite_attr(conn, format, data, attrs); + CManager_unlock(cm); + return ret; +} + +extern int +EVaction_add_split_target ( CManager cm, EVstone stone, EVaction action, EVstone target_stone ) +{ + int ret; + CManager_lock(cm); + ret = INT_EVaction_add_split_target(cm, stone, action, target_stone); + CManager_unlock(cm); + return ret; +} + +extern void +EVaction_remove_split_target ( CManager cm, EVstone stone, EVaction action, EVstone target_stone ) +{ + CManager_lock(cm); + INT_EVaction_remove_split_target(cm, stone, action, target_stone); + CManager_unlock(cm); +} + +extern int +EVaction_set_output ( CManager cm, EVstone stone, EVaction action, int output_index, EVstone target_stone ) +{ + int ret; + CManager_lock(cm); + ret = INT_EVaction_set_output(cm, stone, action, output_index, target_stone); + CManager_unlock(cm); + return ret; +} + +extern void +EVadd_dll_search_dir ( char *path_string ) +{ + INT_EVadd_dll_search_dir(path_string); +} + +extern void +EVadd_standard_routines ( CManager cm, char *extern_string, cod_extern_entry *externs ) +{ + CManager_lock(cm); + INT_EVadd_standard_routines(cm, extern_string, externs); + CManager_unlock(cm); +} + +extern void +EVadd_standard_structs ( CManager cm, FMStructDescList *lists ) +{ + CManager_lock(cm); + INT_EVadd_standard_structs(cm, lists); + CManager_unlock(cm); +} + +extern EVstone +EValloc_stone ( CManager cm ) +{ + EVstone ret; + CManager_lock(cm); + ret = INT_EValloc_stone(cm); + CManager_unlock(cm); + return ret; +} + +extern EVaction +EVassoc_bridge_action ( CManager cm, EVstone stone, attr_list contact_list, EVstone remote_stone ) +{ + EVaction ret; + CManager_lock(cm); + ret = INT_EVassoc_bridge_action(cm, stone, contact_list, remote_stone); + CManager_unlock(cm); + return ret; +} + +extern EVaction +EVassoc_congestion_action ( CManager cm, EVstone stone, char *action_spec, void* client_data ) +{ + EVaction ret; + CManager_lock(cm); + ret = INT_EVassoc_congestion_action(cm, stone, action_spec, client_data); + CManager_unlock(cm); + return ret; +} + +extern void +EVassoc_conversion_action ( CManager cm, int stone_id, int stage, FMFormat target_format, FMFormat incoming_format ) +{ + CManager_lock(cm); + INT_EVassoc_conversion_action(cm, stone_id, stage, target_format, incoming_format); + CManager_unlock(cm); +} + +extern EVaction +EVassoc_filter_action ( CManager cm, EVstone stone, FMStructDescList incoming_format_list, EVSimpleHandlerFunc handler, EVstone out_stone, void* client_data ) +{ + EVaction ret; + CManager_lock(cm); + ret = INT_EVassoc_filter_action(cm, stone, incoming_format_list, handler, out_stone, client_data); + CManager_unlock(cm); + return ret; +} + +extern EVaction +EVassoc_immediate_action ( CManager cm, EVstone stone, char *action_spec, void *client_data ) +{ + EVaction ret; + CManager_lock(cm); + ret = INT_EVassoc_immediate_action(cm, stone, action_spec, client_data); + CManager_unlock(cm); + return ret; +} + +extern EVaction +EVassoc_multi_action ( CManager cm, EVstone stone, char *action_spec, void *client_data ) +{ + EVaction ret; + CManager_lock(cm); + ret = INT_EVassoc_multi_action(cm, stone, action_spec, client_data); + CManager_unlock(cm); + return ret; +} + +extern EVaction +EVassoc_raw_terminal_action ( CManager cm, EVstone stone, EVRawHandlerFunc handler, void* client_data ) +{ + EVaction ret; + CManager_lock(cm); + ret = INT_EVassoc_raw_terminal_action(cm, stone, handler, client_data); + CManager_unlock(cm); + return ret; +} + +extern EVaction +EVassoc_split_action ( CManager cm, EVstone stone, EVstone *target_list ) +{ + EVaction ret; + CManager_lock(cm); + ret = INT_EVassoc_split_action(cm, stone, target_list); + CManager_unlock(cm); + return ret; +} + +extern EVaction +EVassoc_store_action ( CManager cm, EVstone stone_num, EVstone out_stone, int store_limit ) +{ + EVaction ret; + CManager_lock(cm); + ret = INT_EVassoc_store_action(cm, stone_num, out_stone, store_limit); + CManager_unlock(cm); + return ret; +} + +extern EVaction +EVassoc_terminal_action ( CManager cm, EVstone stone, FMStructDescList format_list, EVSimpleHandlerFunc handler, void* client_data ) +{ + EVaction ret; + CManager_lock(cm); + ret = INT_EVassoc_terminal_action(cm, stone, format_list, handler, client_data); + CManager_unlock(cm); + return ret; +} + +extern EVaction +EVassoc_thread_bridge_action ( CManager cm, EVstone stone, CManager target_cm, EVstone target_stone ) +{ + EVaction ret; + CManager_lock(target_cm); + ret = INT_EVassoc_thread_bridge_action(cm, stone, target_cm, target_stone); + CManager_unlock(target_cm); + return ret; +} + +extern void +EVclear_stored ( CManager cm, EVstone stone_num, EVaction action_num ) +{ + CManager_lock(cm); + INT_EVclear_stored(cm, stone_num, action_num); + CManager_unlock(cm); +} + +extern unsigned int +EVclient_active_sink_count ( EVclient client ) +{ + unsigned int ret; + CManager_lock(client->cm); + ret = INT_EVclient_active_sink_count(client); + CManager_unlock(client->cm); + return ret; +} + +extern EVclient +EVclient_assoc ( CManager cm, char *node_name, char *master_contact, EVclient_sources source_capabilities, EVclient_sinks sink_capabilities ) +{ + EVclient ret; + CManager_lock(cm); + ret = INT_EVclient_assoc(cm, node_name, master_contact, source_capabilities, sink_capabilities); + CManager_unlock(cm); + return ret; +} + +extern EVclient +EVclient_assoc_local ( CManager cm, char *node_name, EVmaster master, EVclient_sources source_capabilities, EVclient_sinks sink_capabilities ) +{ + EVclient ret; + CManager_lock(master->cm); + ret = INT_EVclient_assoc_local(cm, node_name, master, source_capabilities, sink_capabilities); + CManager_unlock(master->cm); + return ret; +} + +extern int +EVclient_force_shutdown ( EVclient client, int result ) +{ + int ret; + CManager_lock(client->cm); + ret = INT_EVclient_force_shutdown(client, result); + CManager_unlock(client->cm); + return ret; +} + +extern void +EVclient_ready_for_shutdown ( EVclient client ) +{ + CManager_lock(client->cm); + INT_EVclient_ready_for_shutdown(client); + CManager_unlock(client->cm); +} + +extern int +EVclient_ready_wait ( EVclient client ) +{ + int ret; + CManager_lock(client->cm); + ret = INT_EVclient_ready_wait(client); + CManager_unlock(client->cm); + return ret; +} + +extern EVclient_sinks +EVclient_register_raw_sink_handler ( CManager cm, char *name, EVRawHandlerFunc handler, void *client_data ) +{ + EVclient_sinks ret; + CManager_lock(cm); + ret = INT_EVclient_register_raw_sink_handler(cm, name, handler, client_data); + CManager_unlock(cm); + return ret; +} + +extern EVclient_sinks +EVclient_register_sink_handler ( CManager cm, char *name, FMStructDescList list, EVSimpleHandlerFunc handler, void* client_data ) +{ + EVclient_sinks ret; + CManager_lock(cm); + ret = INT_EVclient_register_sink_handler(cm, name, list, handler, client_data); + CManager_unlock(cm); + return ret; +} + +extern EVclient_sources +EVclient_register_source ( char *name, EVsource src ) +{ + EVclient_sources ret; + CManager cm = src->cm; + CManager_lock(cm); + ret = INT_EVclient_register_source(name, src); + CManager_unlock(cm); + return ret; +} + +extern int +EVclient_shutdown ( EVclient client, int result ) +{ + int ret; + CManager_lock(client->cm); + ret = INT_EVclient_shutdown(client, result); + CManager_unlock(client->cm); + return ret; +} + +extern int +EVclient_source_active ( EVsource src ) +{ + int ret; + CManager cm = src->cm; + CManager_lock(cm); + ret = INT_EVclient_source_active(src); + CManager_unlock(cm); + return ret; +} + +extern int +EVclient_test_for_shutdown ( EVclient client ) +{ + int ret; + CManager_lock(client->cm); + ret = INT_EVclient_test_for_shutdown(client); + CManager_unlock(client->cm); + return ret; +} + +extern int +EVclient_wait_for_shutdown ( EVclient client ) +{ + int ret; + CManager_lock(client->cm); + ret = INT_EVclient_wait_for_shutdown(client); + CManager_unlock(client->cm); + return ret; +} + +extern EVstone +EVcreate_auto_stone ( CManager cm, int period_sec, int period_usec, char *action_spec, EVstone out_stone ) +{ + EVstone ret; + CManager_lock(cm); + ret = INT_EVcreate_auto_stone(cm, period_sec, period_usec, action_spec, out_stone); + CManager_unlock(cm); + return ret; +} + +extern EVstone +EVcreate_bridge_action ( CManager cm, attr_list contact_list, EVstone remote_stone ) +{ + EVstone ret; + CManager_lock(cm); + ret = INT_EVcreate_bridge_action(cm, contact_list, remote_stone); + CManager_unlock(cm); + return ret; +} + +extern EVstone +EVcreate_immediate_action ( CManager cm, char *action_spec, EVstone *target_list ) +{ + EVstone ret; + CManager_lock(cm); + ret = INT_EVcreate_immediate_action(cm, action_spec, target_list); + CManager_unlock(cm); + return ret; +} + +extern EVstone +EVcreate_split_action ( CManager cm, EVstone *target_list ) +{ + EVstone ret; + CManager_lock(cm); + ret = INT_EVcreate_split_action(cm, target_list); + CManager_unlock(cm); + return ret; +} + +extern EVstone +EVcreate_stone_action ( CManager cm, char *action_spec ) +{ + EVstone ret; + CManager_lock(cm); + ret = INT_EVcreate_stone_action(cm, action_spec); + CManager_unlock(cm); + return ret; +} + +extern EVstone +EVcreate_store_action ( CManager cm, EVstone out_stone, int store_limit ) +{ + EVstone ret; + CManager_lock(cm); + ret = INT_EVcreate_store_action(cm, out_stone, store_limit); + CManager_unlock(cm); + return ret; +} + +extern EVsource +EVcreate_submit_handle ( CManager cm, EVstone stone, FMStructDescList data_format ) +{ + EVsource ret; + CManager_lock(cm); + ret = INT_EVcreate_submit_handle(cm, stone, data_format); + CManager_unlock(cm); + return ret; +} + +extern EVsource +EVcreate_submit_handle_free ( CManager cm, EVstone stone, FMStructDescList data_format, EVFreeFunction free_func, void *client_data ) +{ + EVsource ret; + CManager_lock(cm); + ret = INT_EVcreate_submit_handle_free(cm, stone, data_format, free_func, client_data); + CManager_unlock(cm); + return ret; +} + +extern EVstone +EVcreate_terminal_action ( CManager cm, FMStructDescList format_list, EVSimpleHandlerFunc handler, void* client_data ) +{ + EVstone ret; + CManager_lock(cm); + ret = INT_EVcreate_terminal_action(cm, format_list, handler, client_data); + CManager_unlock(cm); + return ret; +} + +extern EVstone +EVcreate_thread_bridge_action ( CManager cm, CManager target_cm, EVstone target_stone ) +{ + EVstone ret; + CManager_lock(target_cm); + ret = INT_EVcreate_thread_bridge_action(cm, target_cm, target_stone); + CManager_unlock(target_cm); + return ret; +} + +extern int +EVdestroy_stone ( CManager cm, EVstone stone_id ) +{ + int ret; + CManager_lock(cm); + ret = INT_EVdestroy_stone(cm, stone_id); + CManager_unlock(cm); + return ret; +} + +extern void +EVdfg_add_action ( EVdfg_stone stone, char *action_spec ) +{ + CManager cm = stone->dfg->master->cm; + CManager_lock(cm); + INT_EVdfg_add_action(stone, action_spec); + CManager_unlock(cm); +} + +extern void +EVdfg_add_sink_action ( EVdfg_stone stone, char *handler_name ) +{ + CManager cm = stone->dfg->master->cm; + CManager_lock(cm); + INT_EVdfg_add_sink_action(stone, handler_name); + CManager_unlock(cm); +} + +extern int +EVdfg_assign_node ( EVdfg_stone stone, char *node ) +{ + int ret; + CManager cm = stone->dfg->master->cm; + CManager_lock(cm); + ret = INT_EVdfg_assign_node(stone, node); + CManager_unlock(cm); + return ret; +} + +extern EVdfg +EVdfg_create ( EVmaster master ) +{ + EVdfg ret; + CManager_lock(master->cm); + ret = INT_EVdfg_create(master); + CManager_unlock(master->cm); + return ret; +} + +extern EVdfg_stone +EVdfg_create_sink_stone ( EVdfg dfg, char *handler_name ) +{ + EVdfg_stone ret; + CManager cm = dfg->master->cm; + CManager_lock(cm); + ret = INT_EVdfg_create_sink_stone(dfg, handler_name); + CManager_unlock(cm); + return ret; +} + +extern EVdfg_stone +EVdfg_create_source_stone ( EVdfg dfg, char *source_name ) +{ + EVdfg_stone ret; + CManager cm = dfg->master->cm; + CManager_lock(cm); + ret = INT_EVdfg_create_source_stone(dfg, source_name); + CManager_unlock(cm); + return ret; +} + +extern EVdfg_stone +EVdfg_create_stone ( EVdfg dfg, char *action_spec ) +{ + EVdfg_stone ret; + CManager cm = dfg->master->cm; + CManager_lock(cm); + ret = INT_EVdfg_create_stone(dfg, action_spec); + CManager_unlock(cm); + return ret; +} + +extern void +EVdfg_dump_graph ( EVdfg_state_type which, EVdfg dfg ) +{ + CManager cm = dfg->master->cm; + CManager_lock(cm); + INT_EVdfg_dump_graph(which, dfg); + CManager_unlock(cm); +} + +extern void +EVdfg_enable_auto_stone ( EVdfg_stone stone, int period_sec, int period_usec ) +{ + CManager cm = stone->dfg->master->cm; + CManager_lock(cm); + INT_EVdfg_enable_auto_stone(stone, period_sec, period_usec); + CManager_unlock(cm); +} + +extern attr_list +EVdfg_get_attr_list ( EVdfg_stone stone ) +{ + attr_list ret; + CManager cm = stone->dfg->master->cm; + CManager_lock(cm); + ret = INT_EVdfg_get_attr_list(stone); + CManager_unlock(cm); + return ret; +} + +extern void +EVdfg_link_dest ( EVdfg_stone source, EVdfg_stone destination ) +{ + CManager cm = destination->dfg->master->cm; + CManager_lock(cm); + INT_EVdfg_link_dest(source, destination); + CManager_unlock(cm); +} + +extern void +EVdfg_link_port ( EVdfg_stone source, int output_index, EVdfg_stone destination ) +{ + CManager cm = destination->dfg->master->cm; + CManager_lock(cm); + INT_EVdfg_link_port(source, output_index, destination); + CManager_unlock(cm); +} + +extern void +EVdfg_realize ( EVdfg dfg ) +{ + CManager cm = dfg->master->cm; + CManager_lock(cm); + INT_EVdfg_realize(dfg); + CManager_unlock(cm); +} + +extern void +EVdfg_set_attr_list ( EVdfg_stone stone, attr_list attrs ) +{ + CManager cm = stone->dfg->master->cm; + CManager_lock(cm); + INT_EVdfg_set_attr_list(stone, attrs); + CManager_unlock(cm); +} + +extern int +EVdfg_unlink_dest ( EVdfg_stone source, EVdfg_stone destination ) +{ + int ret; + CManager cm = destination->dfg->master->cm; + CManager_lock(cm); + ret = INT_EVdfg_unlink_dest(source, destination); + CManager_unlock(cm); + return ret; +} + +extern int +EVdfg_unlink_port ( EVdfg_stone source, int output_index ) +{ + int ret; + CManager cm = source->dfg->master->cm; + CManager_lock(cm); + ret = INT_EVdfg_unlink_port(source, output_index); + CManager_unlock(cm); + return ret; +} + +extern int +EVdrain_stone ( CManager cm, EVstone stone_id ) +{ + int ret; + CManager_lock(cm); + ret = INT_EVdrain_stone(cm, stone_id); + CManager_unlock(cm); + return ret; +} + +extern void +EVenable_auto_stone ( CManager cm, EVstone stone_num, int period_sec, int period_usec ) +{ + CManager_lock(cm); + INT_EVenable_auto_stone(cm, stone_num, period_sec, period_usec); + CManager_unlock(cm); +} + +extern EVstone +EVexecuting_stone ( CManager cm ) +{ + EVstone ret; + CManager_lock(cm); + ret = INT_EVexecuting_stone(cm); + CManager_unlock(cm); + return ret; +} + +extern attr_list +EVextract_attr_list ( CManager cm, EVstone stone_id ) +{ + attr_list ret; + CManager_lock(cm); + ret = INT_EVextract_attr_list(cm, stone_id); + CManager_unlock(cm); + return ret; +} + +extern EVevent_list +EVextract_stone_events ( CManager cm, EVstone stone_id ) +{ + EVevent_list ret; + CManager_lock(cm); + ret = INT_EVextract_stone_events(cm, stone_id); + CManager_unlock(cm); + return ret; +} + +extern void +EVfree_source ( EVsource source ) +{ + CManager cm = source->cm; + CManager_lock(cm); + INT_EVfree_source(source); + CManager_unlock(cm); +} + +extern void +EVfree_stone ( CManager cm, EVstone stone ) +{ + CManager_lock(cm); + INT_EVfree_stone(cm, stone); + CManager_unlock(cm); +} + +extern int +EVfreeze_stone ( CManager cm, EVstone stone_id ) +{ + int ret; + CManager_lock(cm); + ret = INT_EVfreeze_stone(cm, stone_id); + CManager_unlock(cm); + return ret; +} + +extern FMFormat +EVget_src_ref_format ( EVsource source ) +{ + FMFormat ret; + CManager cm = source->cm; + CManager_lock(cm); + ret = INT_EVget_src_ref_format(source); + CManager_unlock(cm); + return ret; +} + +extern int +EVmaster_assign_canonical_name ( EVmaster master, char *given_name, char *canonical_name ) +{ + int ret; + CManager_lock(master->cm); + ret = INT_EVmaster_assign_canonical_name(master, given_name, canonical_name); + CManager_unlock(master->cm); + return ret; +} + +extern EVmaster +EVmaster_create ( CManager cm ) +{ + EVmaster ret; + CManager_lock(cm); + ret = INT_EVmaster_create(cm); + CManager_unlock(cm); + return ret; +} + +extern char* +EVmaster_get_contact_list ( EVmaster master ) +{ + char* ret; + CManager_lock(master->cm); + ret = INT_EVmaster_get_contact_list(master); + CManager_unlock(master->cm); + return ret; +} + +extern void +EVmaster_node_fail_handler ( EVmaster master, EVmasterFailHandlerFunc func ) +{ + CManager_lock(master->cm); + INT_EVmaster_node_fail_handler(master, func); + CManager_unlock(master->cm); +} + +extern void +EVmaster_node_join_handler ( EVmaster master, EVmasterJoinHandlerFunc func ) +{ + CManager_lock(master->cm); + INT_EVmaster_node_join_handler(master, func); + CManager_unlock(master->cm); +} + +extern void +EVmaster_node_reconfig_handler ( EVmaster master, EVmasterReconfigHandlerFunc func ) +{ + CManager_lock(master->cm); + INT_EVmaster_node_reconfig_handler(master, func); + CManager_unlock(master->cm); +} + +extern void +EVmaster_register_node_list ( EVmaster master, char** list ) +{ + CManager_lock(master->cm); + INT_EVmaster_register_node_list(master, list); + CManager_unlock(master->cm); +} + +extern void +EVregister_close_handler ( CManager cm, EVStoneCloseHandlerFunc handler, void *client_data ) +{ + CManager_lock(cm); + INT_EVregister_close_handler(cm, handler, client_data); + CManager_unlock(cm); +} + +extern void +EVreturn_event_buffer ( CManager cm, void *event ) +{ + CManager_lock(cm); + INT_EVreturn_event_buffer(cm, event); + CManager_unlock(cm); +} + +extern void +EVsend_stored ( CManager cm, EVstone stone_num, EVaction action_num ) +{ + CManager_lock(cm); + INT_EVsend_stored(cm, stone_num, action_num); + CManager_unlock(cm); +} + +extern void +EVset_attr_list ( CManager cm, EVstone stone_id, attr_list list ) +{ + CManager_lock(cm); + INT_EVset_attr_list(cm, stone_id, list); + CManager_unlock(cm); +} + +extern void +EVset_store_limit ( CManager cm, EVstone stone_num, EVaction action_num, int store_limit ) +{ + CManager_lock(cm); + INT_EVset_store_limit(cm, stone_num, action_num, store_limit); + CManager_unlock(cm); +} + +extern void +EVstall_stone ( CManager cm, EVstone stone_id ) +{ + CManager_lock(cm); + INT_EVstall_stone(cm, stone_id); + CManager_unlock(cm); +} + +extern void +EVstone_add_split_target ( CManager cm, EVstone stone, EVstone target_stone ) +{ + CManager_lock(cm); + INT_EVstone_add_split_target(cm, stone, target_stone); + CManager_unlock(cm); +} + +extern void +EVstone_remove_split_target ( CManager cm, EVstone stone, EVstone target_stone ) +{ + CManager_lock(cm); + INT_EVstone_remove_split_target(cm, stone, target_stone); + CManager_unlock(cm); +} + +extern int +EVstone_set_output ( CManager cm, EVstone stone, int output_index, EVstone target_stone ) +{ + int ret; + CManager_lock(cm); + ret = INT_EVstone_set_output(cm, stone, output_index, target_stone); + CManager_unlock(cm); + return ret; +} + +extern int +EVstore_count ( CManager cm, EVstone stone_num, EVaction action_num ) +{ + int ret; + CManager_lock(cm); + ret = INT_EVstore_count(cm, stone_num, action_num); + CManager_unlock(cm); + return ret; +} + +extern int +EVstore_is_sending ( CManager cm, EVstone stone_num, EVaction action_num ) +{ + int ret; + CManager_lock(cm); + ret = INT_EVstore_is_sending(cm, stone_num, action_num); + CManager_unlock(cm); + return ret; +} + +extern void +EVstore_start_send ( CManager cm, EVstone stone_num, EVaction action_num ) +{ + CManager_lock(cm); + INT_EVstore_start_send(cm, stone_num, action_num); + CManager_unlock(cm); +} + +extern void +EVsubmit ( EVsource source, void *data, attr_list attrs ) +{ + CManager cm = source->cm; + CManager_lock(cm); + INT_EVsubmit(source, data, attrs); + CManager_unlock(cm); +} + +extern void +EVsubmit_encoded ( CManager cm, EVstone stone, void *data, size_t data_len, attr_list attrs ) +{ + CManager_lock(cm); + INT_EVsubmit_encoded(cm, stone, data, data_len, attrs); + CManager_unlock(cm); +} + +extern int +EVsubmit_encoded_or_wait ( CManager cm, EVstone stone, void *data, int data_len, attr_list attrs, EVSubmitCallbackFunc cb, void *user_data ) +{ + int ret; + CManager_lock(cm); + ret = INT_EVsubmit_encoded_or_wait(cm, stone, data, data_len, attrs, cb, user_data); + CManager_unlock(cm); + return ret; +} + +extern void +EVsubmit_general ( EVsource source, void *data, EVFreeFunction free_func, attr_list attrs ) +{ + CManager cm = source->cm; + CManager_lock(cm); + INT_EVsubmit_general(source, data, free_func, attrs); + CManager_unlock(cm); +} + +extern int +EVsubmit_or_wait ( EVsource source, void *data, attr_list attrs, EVSubmitCallbackFunc cb, void *user_data ) +{ + int ret; + CManager cm = source->cm; + CManager_lock(cm); + ret = INT_EVsubmit_or_wait(source, data, attrs, cb, user_data); + CManager_unlock(cm); + return ret; +} + +extern int +EVtake_event_buffer ( CManager cm, void *event ) +{ + int ret; + CManager_lock(cm); + ret = INT_EVtake_event_buffer(cm, event); + CManager_unlock(cm); + return ret; +} + +extern int +EVtransfer_events ( CManager cm, EVstone src_stone, EVstone dest_stone ) +{ + int ret; + CManager_lock(cm); + ret = INT_EVtransfer_events(cm, src_stone, dest_stone); + CManager_unlock(cm); + return ret; +} + +extern int +EVunfreeze_stone ( CManager cm, EVstone stone_id ) +{ + int ret; + CManager_lock(cm); + ret = INT_EVunfreeze_stone(cm, stone_id); + CManager_unlock(cm); + return ret; +} + +extern void +EVunstall_stone ( CManager cm, EVstone stone_id ) +{ + CManager_lock(cm); + INT_EVunstall_stone(cm, stone_id); + CManager_unlock(cm); +} + +extern char* +create_filter_action_spec ( FMStructDescList format_list, char *function ) +{ + char* ret; + ret = INT_create_filter_action_spec(format_list, function); + return ret; +} + +extern char* +create_multityped_action_spec ( FMStructDescList *input_format_lists, char *function ) +{ + char* ret; + ret = INT_create_multityped_action_spec(input_format_lists, function); + return ret; +} + +extern char* +create_router_action_spec ( FMStructDescList format_list, char *function ) +{ + char* ret; + ret = INT_create_router_action_spec(format_list, function); + return ret; +} + +extern char* +create_transform_action_spec ( FMStructDescList format_list, FMStructDescList out_format_list, char *function ) +{ + char* ret; + ret = INT_create_transform_action_spec(format_list, out_format_list, function); + return ret; +} +#ifdef __cplusplus +} +#endif diff --git a/pregen-source/revp.c b/pregen-source/revp.c new file mode 100644 index 0000000000..df4c7f92f5 --- /dev/null +++ b/pregen-source/revp.c @@ -0,0 +1,2756 @@ +/* + * This file is automatically generated by gen_interface.pl from evpath.h. + * + * DO NOT EDIT + * + */ +#include "config.h" +#include "ffs.h" +#include "atl.h" +#include "evpath.h" +#include "stdio.h" +#ifdef LT_LIBPREFIX +#include "ltdl.h" +#else +#ifdef _MSC_VER +#include +#define RTLD_GLOBAL 1 +#define RTLD_LAZY 2 +extern void* dlopen(const char* filename, int flags); +extern int dlclose(void* handle); +extern void* dlsym(void* handle, const char* name); +extern const char* dlerror(void); + +#else +#include +#endif + +#define lt_dlopen(x) dlopen(x, 0) +#define lt_dlsym(x, y) dlsym(x, y) +#define lt_dlhandle void* +#define lt_dlinit() 0 +#define lt_dlerror() "" +#endif +#include "stdio.h" +#include "string.h" +#include "stdlib.h" +#include "cm_internal.h" +#ifdef __cplusplus +extern "C" { +#endif +#if defined (__INTEL_COMPILER) +// Allow unused +# pragma warning (disable: 869) +#endif + +typedef struct _EV_void_response { + int condition_var; +} EV_void_response; + +FMField EV_void_response_flds[] = { + {"condition_var", "integer", sizeof(int), FMOffset(EV_void_response*, condition_var)}, + {NULL, NULL, 0, 0} +}; + +FMStructDescRec EV_void_response_formats[] = { + {"EV_void_response", EV_void_response_flds, sizeof(EV_void_response), NULL}, + {NULL, NULL, 0, NULL} +}; + +typedef struct _EV_int_response { + int condition_var; + int ret; +} EV_int_response; + +FMField EV_int_response_flds[] = { + {"condition_var", "integer", sizeof(int), FMOffset(EV_int_response*, condition_var)}, + {"ret", "integer", sizeof(EVstone), FMOffset(EV_int_response*,ret)}, + {NULL, NULL, 0, 0} +}; + +FMStructDescRec EV_int_response_formats[] = { + {"EV_int_response", EV_int_response_flds, sizeof(EV_int_response), NULL}, + {NULL, NULL, 0, NULL} +}; + +typedef struct _EV_string_response { + int condition_var; + char *ret; +} EV_string_response; + +FMField EV_string_response_flds[] = { + {"condition_var", "integer", sizeof(int), FMOffset(EV_string_response*, condition_var)}, + {"ret", "string", sizeof(char*), FMOffset(EV_string_response*,ret)}, + {NULL, NULL, 0, 0} +}; + +FMStructDescRec EV_string_response_formats[] = { + {"EV_string_response", EV_string_response_flds, sizeof(EV_string_response), NULL}, + {NULL, NULL, 0, NULL} +}; + +typedef struct _EV_EVevent_list_response { + int condition_var; + int ret_len; + EVevent_list ret; +} EV_EVevent_list_response; + +FMField EV_EVevent_list_response_flds[] = { + {"condition_var", "integer", sizeof(int), FMOffset(EV_EVevent_list_response*, condition_var)}, + {"ret_len", "integer", sizeof(int), FMOffset(EV_EVevent_list_response*,ret_len)}, + {"ret", "EVevent_list[ret_len]", sizeof(struct buf_entry), FMOffset(EV_EVevent_list_response*,ret)}, + {NULL, NULL, 0, 0} +}; + +FMField EVevent_list_flds[] = { + {"length", "integer", sizeof(int), FMOffset(EVevent_list,length)}, + {"event_buffer", "char[length]", sizeof(char), FMOffset(EVevent_list, buffer)}, + {NULL, NULL, 0, 0} +}; + +FMStructDescRec EV_EVevent_list_response_formats[] = { + {"EV_EVevent_response", EV_EVevent_list_response_flds, sizeof(EV_EVevent_list_response), NULL}, + {"EVevent_list", EVevent_list_flds, sizeof(struct buf_entry), NULL}, + {NULL, NULL, 0, NULL} +}; + +int +count_EVevent_list(EVevent_list list) +{ + int count = 0; + while (list && list[count].buffer != NULL) { + count++; + } + count++; + return count; +} + +EVevent_list +copy_EVevent_list(EVevent_list list) +{ + EVevent_list ret; + int i, size = count_EVevent_list(list); + ret = (EVevent_list) malloc(sizeof(ret[0]) * size); + for (i=0; i < size-1; i++) { + ret[i].length = list[i].length; + ret[i].buffer = malloc(list[i].length); + memcpy(ret[i].buffer, list[i].buffer, list[i].length); + } + ret[i].length = 0; + ret[i].buffer = NULL; + return ret; +} + +EVSimpleHandlerFunc +REVPlookup_handler(char *name) +{ + EVSimpleHandlerFunc f = NULL; + if (strncmp("0x", name, 2) == 0) { + /* hex constant */ + void *p; + sscanf(name, "0x%p", &p); + f = (EVSimpleHandlerFunc)p; + return f; + } +#if !NO_DYNAMIC_LINKING + static lt_dlhandle h = NULL; + static void *dh = NULL; + if (h == NULL) { + (void) lt_dlinit(); + h = lt_dlopen(NULL); + } + f = (EVSimpleHandlerFunc) lt_dlsym(h, name); + if (f == NULL) { + if (dh == NULL) { + dh = dlopen(NULL, 0); + } + printf("Querying dlopen()\n"); + f = (EVSimpleHandlerFunc)dlsym(dh, name); + } + if (f == NULL) { + if (dh == NULL) { + dh = dlopen(NULL, RTLD_GLOBAL|RTLD_LAZY); + } + f = (EVSimpleHandlerFunc)dlsym(dh, name); + } +#endif + if (f == NULL) { + printf("Dynamic symbol lookup for \"%s\" failed.\n\tEither the symbol is invalid, or symbol lookup is not enabled.\n", name); + printf("Make sure that the symbol is declared \"extern\" (not \"static\")\n"); + printf("Try linking the program with either \"-rdynamic\" (GCC) or \"-dlopen self\" (libtool)\n"); + } + return f; +} + +static char * +get_format_name(CManager cm, FMStructDescList structs) +{ + int id_len, i; + FMFormat format = EVregister_format_set(cm, structs); + char *tmp = get_server_ID_FMformat(format, &id_len); + char *str_tmp = malloc(id_len * 2 + 1); + for (i=0; i < id_len; i++) { + sprintf(&str_tmp[i*2], "%02x", ((unsigned char*)tmp)[i]); + } + return str_tmp; +} + +extern FMStructDescList +REVPlookup_format_structs(CManager cm, char *format_name) +{ + FMFormat format; + int slen = (int)strlen(format_name); + int i; + unsigned char *id = malloc(slen/2); + for (i=0; i < slen/2; i++) { + int x; + char tmp[3] = {0, 0, 0}; + tmp[0] = format_name[2*i]; + tmp[1] = format_name[2*i + 1]; + sscanf(tmp, "%x", &x); + id[i] = (unsigned char) x; + } + format = FMformat_from_ID(cm->evp->fmc, (char*)id); + free(id); + return format_list_of_FMFormat(format); +} + + +typedef struct _EVaction_add_split_target_request { + int condition_var; + EVstone stone; + EVaction action; + EVstone target_stone; +} EVaction_add_split_target_request; + +typedef struct _EVaction_add_split_target_response { + int condition_var; + int ret; +} EVaction_add_split_target_response; + +FMField EVaction_add_split_target_req_flds[] = { + {"condition_var", "integer", sizeof(int), FMOffset(EVaction_add_split_target_request*, condition_var)}, + {"stone", "integer", sizeof(EVstone), FMOffset(EVaction_add_split_target_request*,stone)}, + {"action", "integer", sizeof(EVaction), FMOffset(EVaction_add_split_target_request*,action)}, + {"target_stone", "integer", sizeof(EVstone), FMOffset(EVaction_add_split_target_request*,target_stone)}, + {NULL, NULL, 0, 0} +}; + +FMStructDescRec EVaction_add_split_target_req_formats[] = { + {"EV_EVaction_add_split_target_request", EVaction_add_split_target_req_flds, sizeof(EVaction_add_split_target_request), NULL}, + {NULL, NULL, 0, NULL} +}; + +extern int +INT_REVaction_add_split_target(CMConnection conn, EVstone stone, EVaction action, EVstone target_stone) +{ + int cond; + CMFormat f; + EV_int_response response; + EVaction_add_split_target_request request; + memset(&request, 0, sizeof(request)); + cond = INT_CMCondition_get(conn->cm, conn); + f = INT_CMlookup_format(conn->cm, EVaction_add_split_target_req_formats); + request.stone = stone; + request.action = action; + request.target_stone = target_stone; + request.condition_var = cond; + if (f == NULL) { + f = INT_CMregister_format(conn->cm, EVaction_add_split_target_req_formats); + } + INT_CMCondition_set_client_data(conn->cm, cond, &response); + INT_CMwrite(conn, f, &request); + INT_CMCondition_wait(conn->cm, cond); + return response.ret; +} + +extern int +REVaction_add_split_target(CMConnection conn, EVstone stone, EVaction action, EVstone target_stone) +{ + int ret; + CManager_lock(conn->cm); + ret = INT_REVaction_add_split_target(conn, stone, action, target_stone); + CManager_unlock(conn->cm); + return ret; +} + +static void +REVaction_add_split_target_handler(CManager cm, CMConnection conn, void *data,void *client_data,attr_list message_attrs) +{ + EV_int_response response; + EVaction_add_split_target_request *request = (EVaction_add_split_target_request *) data; + int ret; + CMFormat f = CMlookup_format(conn->cm, EV_int_response_formats); + (void) message_attrs; + (void) client_data; + if (f == NULL) { + f = INT_CMregister_format(conn->cm, EV_int_response_formats); + } + ret = EVaction_add_split_target(cm, request->stone, request->action, request->target_stone); + response.ret = ret;; + response.condition_var = request->condition_var; + CMwrite(conn, f, &response); +} + +typedef struct _EVaction_remove_split_target_request { + int condition_var; + EVstone stone; + EVaction action; + EVstone target_stone; +} EVaction_remove_split_target_request; + +typedef struct _EVaction_remove_split_target_response { + int condition_var; +} EVaction_remove_split_target_response; + +FMField EVaction_remove_split_target_req_flds[] = { + {"condition_var", "integer", sizeof(int), FMOffset(EVaction_remove_split_target_request*, condition_var)}, + {"stone", "integer", sizeof(EVstone), FMOffset(EVaction_remove_split_target_request*,stone)}, + {"action", "integer", sizeof(EVaction), FMOffset(EVaction_remove_split_target_request*,action)}, + {"target_stone", "integer", sizeof(EVstone), FMOffset(EVaction_remove_split_target_request*,target_stone)}, + {NULL, NULL, 0, 0} +}; + +FMStructDescRec EVaction_remove_split_target_req_formats[] = { + {"EV_EVaction_remove_split_target_request", EVaction_remove_split_target_req_flds, sizeof(EVaction_remove_split_target_request), NULL}, + {NULL, NULL, 0, NULL} +}; + +extern void +INT_REVaction_remove_split_target(CMConnection conn, EVstone stone, EVaction action, EVstone target_stone) +{ + int cond; + CMFormat f; + EVaction_remove_split_target_request request; + memset(&request, 0, sizeof(request)); + cond = INT_CMCondition_get(conn->cm, conn); + f = INT_CMlookup_format(conn->cm, EVaction_remove_split_target_req_formats); + request.stone = stone; + request.action = action; + request.target_stone = target_stone; + request.condition_var = cond; + if (f == NULL) { + f = INT_CMregister_format(conn->cm, EVaction_remove_split_target_req_formats); + } + INT_CMCondition_set_client_data(conn->cm, cond, NULL); + INT_CMwrite(conn, f, &request); + INT_CMCondition_wait(conn->cm, cond); +} + +extern void +REVaction_remove_split_target(CMConnection conn, EVstone stone, EVaction action, EVstone target_stone) +{ + CManager_lock(conn->cm); + INT_REVaction_remove_split_target(conn, stone, action, target_stone); + CManager_unlock(conn->cm); + return; +} + +static void +REVaction_remove_split_target_handler(CManager cm, CMConnection conn, void *data,void *client_data,attr_list message_attrs) +{ + EV_void_response response; + EVaction_remove_split_target_request *request = (EVaction_remove_split_target_request *) data; + CMFormat f = CMlookup_format(conn->cm, EV_void_response_formats); + (void) message_attrs; + (void) client_data; + if (f == NULL) { + f = INT_CMregister_format(conn->cm, EV_void_response_formats); + } + EVaction_remove_split_target(cm, request->stone, request->action, request->target_stone); + response.condition_var = request->condition_var; + CMwrite(conn, f, &response); +} + +typedef struct _EVaction_set_output_request { + int condition_var; + EVstone stone; + EVaction action; + int output_index; + EVstone target_stone; +} EVaction_set_output_request; + +typedef struct _EVaction_set_output_response { + int condition_var; + int ret; +} EVaction_set_output_response; + +FMField EVaction_set_output_req_flds[] = { + {"condition_var", "integer", sizeof(int), FMOffset(EVaction_set_output_request*, condition_var)}, + {"stone", "integer", sizeof(EVstone), FMOffset(EVaction_set_output_request*,stone)}, + {"action", "integer", sizeof(EVaction), FMOffset(EVaction_set_output_request*,action)}, + {"output_index", "integer", sizeof(int), FMOffset(EVaction_set_output_request*,output_index)}, + {"target_stone", "integer", sizeof(EVstone), FMOffset(EVaction_set_output_request*,target_stone)}, + {NULL, NULL, 0, 0} +}; + +FMStructDescRec EVaction_set_output_req_formats[] = { + {"EV_EVaction_set_output_request", EVaction_set_output_req_flds, sizeof(EVaction_set_output_request), NULL}, + {NULL, NULL, 0, NULL} +}; + +extern int +INT_REVaction_set_output(CMConnection conn, EVstone stone, EVaction action, int output_index, EVstone target_stone) +{ + int cond; + CMFormat f; + EV_int_response response; + EVaction_set_output_request request; + memset(&request, 0, sizeof(request)); + cond = INT_CMCondition_get(conn->cm, conn); + f = INT_CMlookup_format(conn->cm, EVaction_set_output_req_formats); + request.stone = stone; + request.action = action; + request.output_index = output_index; + request.target_stone = target_stone; + request.condition_var = cond; + if (f == NULL) { + f = INT_CMregister_format(conn->cm, EVaction_set_output_req_formats); + } + INT_CMCondition_set_client_data(conn->cm, cond, &response); + INT_CMwrite(conn, f, &request); + INT_CMCondition_wait(conn->cm, cond); + return response.ret; +} + +extern int +REVaction_set_output(CMConnection conn, EVstone stone, EVaction action, int output_index, EVstone target_stone) +{ + int ret; + CManager_lock(conn->cm); + ret = INT_REVaction_set_output(conn, stone, action, output_index, target_stone); + CManager_unlock(conn->cm); + return ret; +} + +static void +REVaction_set_output_handler(CManager cm, CMConnection conn, void *data,void *client_data,attr_list message_attrs) +{ + EV_int_response response; + EVaction_set_output_request *request = (EVaction_set_output_request *) data; + int ret; + CMFormat f = CMlookup_format(conn->cm, EV_int_response_formats); + (void) message_attrs; + (void) client_data; + if (f == NULL) { + f = INT_CMregister_format(conn->cm, EV_int_response_formats); + } + ret = EVaction_set_output(cm, request->stone, request->action, request->output_index, request->target_stone); + response.ret = ret;; + response.condition_var = request->condition_var; + CMwrite(conn, f, &response); +} + +typedef struct _EValloc_stone_request { + int condition_var; +} EValloc_stone_request; + +typedef struct _EValloc_stone_response { + int condition_var; + EVstone ret; +} EValloc_stone_response; + +FMField EValloc_stone_req_flds[] = { + {"condition_var", "integer", sizeof(int), FMOffset(EValloc_stone_request*, condition_var)}, + {NULL, NULL, 0, 0} +}; + +FMStructDescRec EValloc_stone_req_formats[] = { + {"EV_EValloc_stone_request", EValloc_stone_req_flds, sizeof(EValloc_stone_request), NULL}, + {NULL, NULL, 0, NULL} +}; + +extern EVstone +INT_REValloc_stone(CMConnection conn) +{ + int cond; + CMFormat f; + EV_int_response response; + EValloc_stone_request request; + memset(&request, 0, sizeof(request)); + cond = INT_CMCondition_get(conn->cm, conn); + f = INT_CMlookup_format(conn->cm, EValloc_stone_req_formats); + request.condition_var = cond; + if (f == NULL) { + f = INT_CMregister_format(conn->cm, EValloc_stone_req_formats); + } + INT_CMCondition_set_client_data(conn->cm, cond, &response); + INT_CMwrite(conn, f, &request); + INT_CMCondition_wait(conn->cm, cond); + return (EVstone) response.ret; +} + +extern EVstone +REValloc_stone(CMConnection conn) +{ + EVstone ret; + CManager_lock(conn->cm); + ret = INT_REValloc_stone(conn); + CManager_unlock(conn->cm); + return ret; +} + +static void +REValloc_stone_handler(CManager cm, CMConnection conn, void *data,void *client_data,attr_list message_attrs) +{ + EV_int_response response; + EValloc_stone_request *request = (EValloc_stone_request *) data; + EVstone ret; + CMFormat f = CMlookup_format(conn->cm, EV_int_response_formats); + (void) message_attrs; + (void) client_data; + if (f == NULL) { + f = INT_CMregister_format(conn->cm, EV_int_response_formats); + } + ret = EValloc_stone(cm); + response.ret = (int)ret; + response.condition_var = request->condition_var; + CMwrite(conn, f, &response); +} + +typedef struct _EVassoc_bridge_action_request { + int condition_var; + EVstone stone; + char* contact_list; + EVstone remote_stone; +} EVassoc_bridge_action_request; + +typedef struct _EVassoc_bridge_action_response { + int condition_var; + EVaction ret; +} EVassoc_bridge_action_response; + +FMField EVassoc_bridge_action_req_flds[] = { + {"condition_var", "integer", sizeof(int), FMOffset(EVassoc_bridge_action_request*, condition_var)}, + {"stone", "integer", sizeof(EVstone), FMOffset(EVassoc_bridge_action_request*,stone)}, + {"contact_list", "string", sizeof(attr_list), FMOffset(EVassoc_bridge_action_request*,contact_list)}, + {"remote_stone", "integer", sizeof(EVstone), FMOffset(EVassoc_bridge_action_request*,remote_stone)}, + {NULL, NULL, 0, 0} +}; + +FMStructDescRec EVassoc_bridge_action_req_formats[] = { + {"EV_EVassoc_bridge_action_request", EVassoc_bridge_action_req_flds, sizeof(EVassoc_bridge_action_request), NULL}, + {NULL, NULL, 0, NULL} +}; + +extern EVaction +INT_REVassoc_bridge_action(CMConnection conn, EVstone stone, attr_list contact_list, EVstone remote_stone) +{ + int cond; + CMFormat f; + EV_int_response response; + EVassoc_bridge_action_request request; + memset(&request, 0, sizeof(request)); + cond = INT_CMCondition_get(conn->cm, conn); + f = INT_CMlookup_format(conn->cm, EVassoc_bridge_action_req_formats); + request.stone = stone; + request.contact_list = attr_list_to_string(contact_list); + request.remote_stone = remote_stone; + request.condition_var = cond; + if (f == NULL) { + f = INT_CMregister_format(conn->cm, EVassoc_bridge_action_req_formats); + } + INT_CMCondition_set_client_data(conn->cm, cond, &response); + INT_CMwrite(conn, f, &request); + free(request.contact_list); + INT_CMCondition_wait(conn->cm, cond); + return (EVaction) response.ret; +} + +extern EVaction +REVassoc_bridge_action(CMConnection conn, EVstone stone, attr_list contact_list, EVstone remote_stone) +{ + EVaction ret; + CManager_lock(conn->cm); + ret = INT_REVassoc_bridge_action(conn, stone, contact_list, remote_stone); + CManager_unlock(conn->cm); + return ret; +} + +static void +REVassoc_bridge_action_handler(CManager cm, CMConnection conn, void *data,void *client_data,attr_list message_attrs) +{ + EV_int_response response; + EVassoc_bridge_action_request *request = (EVassoc_bridge_action_request *) data; + EVaction ret; + CMFormat f = CMlookup_format(conn->cm, EV_int_response_formats); + (void) message_attrs; + (void) client_data; + if (f == NULL) { + f = INT_CMregister_format(conn->cm, EV_int_response_formats); + } + attr_list contact_list = attr_list_from_string(request->contact_list); + ret = EVassoc_bridge_action(cm, request->stone, contact_list, request->remote_stone); +free_attr_list(contact_list); + response.ret = (int) ret; + response.condition_var = request->condition_var; + CMwrite(conn, f, &response); +} + +typedef struct _EVassoc_filter_action_request { + int condition_var; + EVstone stone; + char* incoming_format_list; + char* handler; + EVstone out_stone; +} EVassoc_filter_action_request; + +typedef struct _EVassoc_filter_action_response { + int condition_var; + EVaction ret; +} EVassoc_filter_action_response; + +FMField EVassoc_filter_action_req_flds[] = { + {"condition_var", "integer", sizeof(int), FMOffset(EVassoc_filter_action_request*, condition_var)}, + {"stone", "integer", sizeof(EVstone), FMOffset(EVassoc_filter_action_request*,stone)}, + {"incoming_format_list", "string", sizeof(FMStructDescList), FMOffset(EVassoc_filter_action_request*,incoming_format_list)}, + {"handler", "string", sizeof(char*), FMOffset(EVassoc_filter_action_request*,handler)}, + {"out_stone", "integer", sizeof(EVstone), FMOffset(EVassoc_filter_action_request*,out_stone)}, + {NULL, NULL, 0, 0} +}; + +FMStructDescRec EVassoc_filter_action_req_formats[] = { + {"EV_EVassoc_filter_action_request", EVassoc_filter_action_req_flds, sizeof(EVassoc_filter_action_request), NULL}, + {NULL, NULL, 0, NULL} +}; + +extern EVaction +INT_REVassoc_filter_action(CMConnection conn, EVstone stone, FMStructDescList incoming_format_list, char *handler, EVstone out_stone) +{ + int cond; + CMFormat f; + EV_int_response response; + EVassoc_filter_action_request request; + memset(&request, 0, sizeof(request)); + cond = INT_CMCondition_get(conn->cm, conn); + f = INT_CMlookup_format(conn->cm, EVassoc_filter_action_req_formats); + request.stone = stone; + request.incoming_format_list = get_format_name(conn->cm, incoming_format_list); + request.handler = handler; + request.out_stone = out_stone; + request.condition_var = cond; + if (f == NULL) { + f = INT_CMregister_format(conn->cm, EVassoc_filter_action_req_formats); + } + INT_CMCondition_set_client_data(conn->cm, cond, &response); + INT_CMwrite(conn, f, &request); + INT_CMCondition_wait(conn->cm, cond); + return (EVaction) response.ret; +} + +extern EVaction +REVassoc_filter_action(CMConnection conn, EVstone stone, FMStructDescList incoming_format_list, char *handler, EVstone out_stone) +{ + EVaction ret; + CManager_lock(conn->cm); + ret = INT_REVassoc_filter_action(conn, stone, incoming_format_list, handler, out_stone); + CManager_unlock(conn->cm); + return ret; +} + +static void +REVassoc_filter_action_handler(CManager cm, CMConnection conn, void *data,void *client_data,attr_list message_attrs) +{ + EV_int_response response; + EVassoc_filter_action_request *request = (EVassoc_filter_action_request *) data; + EVaction ret; + CMFormat f = CMlookup_format(conn->cm, EV_int_response_formats); + (void) message_attrs; + (void) client_data; + if (f == NULL) { + f = INT_CMregister_format(conn->cm, EV_int_response_formats); + } + FMStructDescList incoming_format_list = REVPlookup_format_structs(conn->cm, request->incoming_format_list); + EVSimpleHandlerFunc handler = REVPlookup_handler(request->handler); + ret = EVassoc_filter_action(cm, request->stone, incoming_format_list, handler, request->out_stone, NULL); + response.ret = (int) ret; + response.condition_var = request->condition_var; + CMwrite(conn, f, &response); +} + +typedef struct _EVassoc_immediate_action_request { + int condition_var; + EVstone stone; + char* action_spec; +} EVassoc_immediate_action_request; + +typedef struct _EVassoc_immediate_action_response { + int condition_var; + EVaction ret; +} EVassoc_immediate_action_response; + +FMField EVassoc_immediate_action_req_flds[] = { + {"condition_var", "integer", sizeof(int), FMOffset(EVassoc_immediate_action_request*, condition_var)}, + {"stone", "integer", sizeof(EVstone), FMOffset(EVassoc_immediate_action_request*,stone)}, + {"action_spec", "string", sizeof(char*), FMOffset(EVassoc_immediate_action_request*,action_spec)}, + {NULL, NULL, 0, 0} +}; + +FMStructDescRec EVassoc_immediate_action_req_formats[] = { + {"EV_EVassoc_immediate_action_request", EVassoc_immediate_action_req_flds, sizeof(EVassoc_immediate_action_request), NULL}, + {NULL, NULL, 0, NULL} +}; + +extern EVaction +INT_REVassoc_immediate_action(CMConnection conn, EVstone stone, char *action_spec) +{ + int cond; + CMFormat f; + EV_int_response response; + EVassoc_immediate_action_request request; + memset(&request, 0, sizeof(request)); + cond = INT_CMCondition_get(conn->cm, conn); + f = INT_CMlookup_format(conn->cm, EVassoc_immediate_action_req_formats); + request.stone = stone; + request.action_spec = action_spec; + request.condition_var = cond; + if (f == NULL) { + f = INT_CMregister_format(conn->cm, EVassoc_immediate_action_req_formats); + } + INT_CMCondition_set_client_data(conn->cm, cond, &response); + INT_CMwrite(conn, f, &request); + INT_CMCondition_wait(conn->cm, cond); + return (EVaction) response.ret; +} + +extern EVaction +REVassoc_immediate_action(CMConnection conn, EVstone stone, char *action_spec) +{ + EVaction ret; + CManager_lock(conn->cm); + ret = INT_REVassoc_immediate_action(conn, stone, action_spec); + CManager_unlock(conn->cm); + return ret; +} + +static void +REVassoc_immediate_action_handler(CManager cm, CMConnection conn, void *data,void *client_data,attr_list message_attrs) +{ + EV_int_response response; + EVassoc_immediate_action_request *request = (EVassoc_immediate_action_request *) data; + EVaction ret; + CMFormat f = CMlookup_format(conn->cm, EV_int_response_formats); + (void) message_attrs; + (void) client_data; + if (f == NULL) { + f = INT_CMregister_format(conn->cm, EV_int_response_formats); + } + ret = EVassoc_immediate_action(cm, request->stone, request->action_spec, NULL); + response.ret = (int) ret; + response.condition_var = request->condition_var; + CMwrite(conn, f, &response); +} + +typedef struct _EVassoc_multi_action_request { + int condition_var; + EVstone stone; + char* action_spec; +} EVassoc_multi_action_request; + +typedef struct _EVassoc_multi_action_response { + int condition_var; + EVaction ret; +} EVassoc_multi_action_response; + +FMField EVassoc_multi_action_req_flds[] = { + {"condition_var", "integer", sizeof(int), FMOffset(EVassoc_multi_action_request*, condition_var)}, + {"stone", "integer", sizeof(EVstone), FMOffset(EVassoc_multi_action_request*,stone)}, + {"action_spec", "string", sizeof(char*), FMOffset(EVassoc_multi_action_request*,action_spec)}, + {NULL, NULL, 0, 0} +}; + +FMStructDescRec EVassoc_multi_action_req_formats[] = { + {"EV_EVassoc_multi_action_request", EVassoc_multi_action_req_flds, sizeof(EVassoc_multi_action_request), NULL}, + {NULL, NULL, 0, NULL} +}; + +extern EVaction +INT_REVassoc_multi_action(CMConnection conn, EVstone stone, char *action_spec) +{ + int cond; + CMFormat f; + EV_int_response response; + EVassoc_multi_action_request request; + memset(&request, 0, sizeof(request)); + cond = INT_CMCondition_get(conn->cm, conn); + f = INT_CMlookup_format(conn->cm, EVassoc_multi_action_req_formats); + request.stone = stone; + request.action_spec = action_spec; + request.condition_var = cond; + if (f == NULL) { + f = INT_CMregister_format(conn->cm, EVassoc_multi_action_req_formats); + } + INT_CMCondition_set_client_data(conn->cm, cond, &response); + INT_CMwrite(conn, f, &request); + INT_CMCondition_wait(conn->cm, cond); + return (EVaction) response.ret; +} + +extern EVaction +REVassoc_multi_action(CMConnection conn, EVstone stone, char *action_spec) +{ + EVaction ret; + CManager_lock(conn->cm); + ret = INT_REVassoc_multi_action(conn, stone, action_spec); + CManager_unlock(conn->cm); + return ret; +} + +static void +REVassoc_multi_action_handler(CManager cm, CMConnection conn, void *data,void *client_data,attr_list message_attrs) +{ + EV_int_response response; + EVassoc_multi_action_request *request = (EVassoc_multi_action_request *) data; + EVaction ret; + CMFormat f = CMlookup_format(conn->cm, EV_int_response_formats); + (void) message_attrs; + (void) client_data; + if (f == NULL) { + f = INT_CMregister_format(conn->cm, EV_int_response_formats); + } + ret = EVassoc_multi_action(cm, request->stone, request->action_spec, NULL); + response.ret = (int) ret; + response.condition_var = request->condition_var; + CMwrite(conn, f, &response); +} + +typedef struct _EVassoc_split_action_request { + int condition_var; + EVstone stone; + int target_list_len; + int * target_list; +} EVassoc_split_action_request; + +typedef struct _EVassoc_split_action_response { + int condition_var; + EVaction ret; +} EVassoc_split_action_response; + +FMField EVassoc_split_action_req_flds[] = { + {"condition_var", "integer", sizeof(int), FMOffset(EVassoc_split_action_request*, condition_var)}, + {"stone", "integer", sizeof(EVstone), FMOffset(EVassoc_split_action_request*,stone)}, + {"target_list", "integer", sizeof(EVstone*), FMOffset(EVassoc_split_action_request*,target_list)}, + {NULL, NULL, 0, 0} +}; + +FMStructDescRec EVassoc_split_action_req_formats[] = { + {"EV_EVassoc_split_action_request", EVassoc_split_action_req_flds, sizeof(EVassoc_split_action_request), NULL}, + {NULL, NULL, 0, NULL} +}; + +extern EVaction +INT_REVassoc_split_action(CMConnection conn, EVstone stone, EVstone *target_list) +{ + int cond; + CMFormat f; + EV_int_response response; + EVassoc_split_action_request request; + memset(&request, 0, sizeof(request)); + cond = INT_CMCondition_get(conn->cm, conn); + f = INT_CMlookup_format(conn->cm, EVassoc_split_action_req_formats); + request.stone = stone; + request.target_list = target_list; + request.condition_var = cond; + if (f == NULL) { + f = INT_CMregister_format(conn->cm, EVassoc_split_action_req_formats); + } + INT_CMCondition_set_client_data(conn->cm, cond, &response); + INT_CMwrite(conn, f, &request); + INT_CMCondition_wait(conn->cm, cond); + return (EVaction) response.ret; +} + +extern EVaction +REVassoc_split_action(CMConnection conn, EVstone stone, EVstone *target_list) +{ + EVaction ret; + CManager_lock(conn->cm); + ret = INT_REVassoc_split_action(conn, stone, target_list); + CManager_unlock(conn->cm); + return ret; +} + +static void +REVassoc_split_action_handler(CManager cm, CMConnection conn, void *data,void *client_data,attr_list message_attrs) +{ + EV_int_response response; + EVassoc_split_action_request *request = (EVassoc_split_action_request *) data; + EVaction ret; + CMFormat f = CMlookup_format(conn->cm, EV_int_response_formats); + (void) message_attrs; + (void) client_data; + if (f == NULL) { + f = INT_CMregister_format(conn->cm, EV_int_response_formats); + } + ret = EVassoc_split_action(cm, request->stone, request->target_list); + response.ret = (int) ret; + response.condition_var = request->condition_var; + CMwrite(conn, f, &response); +} + +typedef struct _EVassoc_store_action_request { + int condition_var; + EVstone stone_num; + EVstone out_stone; + int store_limit; +} EVassoc_store_action_request; + +typedef struct _EVassoc_store_action_response { + int condition_var; + EVaction ret; +} EVassoc_store_action_response; + +FMField EVassoc_store_action_req_flds[] = { + {"condition_var", "integer", sizeof(int), FMOffset(EVassoc_store_action_request*, condition_var)}, + {"stone_num", "integer", sizeof(EVstone), FMOffset(EVassoc_store_action_request*,stone_num)}, + {"out_stone", "integer", sizeof(EVstone), FMOffset(EVassoc_store_action_request*,out_stone)}, + {"store_limit", "integer", sizeof(int), FMOffset(EVassoc_store_action_request*,store_limit)}, + {NULL, NULL, 0, 0} +}; + +FMStructDescRec EVassoc_store_action_req_formats[] = { + {"EV_EVassoc_store_action_request", EVassoc_store_action_req_flds, sizeof(EVassoc_store_action_request), NULL}, + {NULL, NULL, 0, NULL} +}; + +extern EVaction +INT_REVassoc_store_action(CMConnection conn, EVstone stone_num, EVstone out_stone, int store_limit) +{ + int cond; + CMFormat f; + EV_int_response response; + EVassoc_store_action_request request; + memset(&request, 0, sizeof(request)); + cond = INT_CMCondition_get(conn->cm, conn); + f = INT_CMlookup_format(conn->cm, EVassoc_store_action_req_formats); + request.stone_num = stone_num; + request.out_stone = out_stone; + request.store_limit = store_limit; + request.condition_var = cond; + if (f == NULL) { + f = INT_CMregister_format(conn->cm, EVassoc_store_action_req_formats); + } + INT_CMCondition_set_client_data(conn->cm, cond, &response); + INT_CMwrite(conn, f, &request); + INT_CMCondition_wait(conn->cm, cond); + return (EVaction) response.ret; +} + +extern EVaction +REVassoc_store_action(CMConnection conn, EVstone stone_num, EVstone out_stone, int store_limit) +{ + EVaction ret; + CManager_lock(conn->cm); + ret = INT_REVassoc_store_action(conn, stone_num, out_stone, store_limit); + CManager_unlock(conn->cm); + return ret; +} + +static void +REVassoc_store_action_handler(CManager cm, CMConnection conn, void *data,void *client_data,attr_list message_attrs) +{ + EV_int_response response; + EVassoc_store_action_request *request = (EVassoc_store_action_request *) data; + EVaction ret; + CMFormat f = CMlookup_format(conn->cm, EV_int_response_formats); + (void) message_attrs; + (void) client_data; + if (f == NULL) { + f = INT_CMregister_format(conn->cm, EV_int_response_formats); + } + ret = EVassoc_store_action(cm, request->stone_num, request->out_stone, request->store_limit); + response.ret = (int) ret; + response.condition_var = request->condition_var; + CMwrite(conn, f, &response); +} + +typedef struct _EVassoc_terminal_action_request { + int condition_var; + EVstone stone; + char* format_list; + char* handler; +} EVassoc_terminal_action_request; + +typedef struct _EVassoc_terminal_action_response { + int condition_var; + EVaction ret; +} EVassoc_terminal_action_response; + +FMField EVassoc_terminal_action_req_flds[] = { + {"condition_var", "integer", sizeof(int), FMOffset(EVassoc_terminal_action_request*, condition_var)}, + {"stone", "integer", sizeof(EVstone), FMOffset(EVassoc_terminal_action_request*,stone)}, + {"format_list", "string", sizeof(FMStructDescList), FMOffset(EVassoc_terminal_action_request*,format_list)}, + {"handler", "string", sizeof(char*), FMOffset(EVassoc_terminal_action_request*,handler)}, + {NULL, NULL, 0, 0} +}; + +FMStructDescRec EVassoc_terminal_action_req_formats[] = { + {"EV_EVassoc_terminal_action_request", EVassoc_terminal_action_req_flds, sizeof(EVassoc_terminal_action_request), NULL}, + {NULL, NULL, 0, NULL} +}; + +extern EVaction +INT_REVassoc_terminal_action(CMConnection conn, EVstone stone, FMStructDescList format_list, char *handler) +{ + int cond; + CMFormat f; + EV_int_response response; + EVassoc_terminal_action_request request; + memset(&request, 0, sizeof(request)); + cond = INT_CMCondition_get(conn->cm, conn); + f = INT_CMlookup_format(conn->cm, EVassoc_terminal_action_req_formats); + request.stone = stone; + request.format_list = get_format_name(conn->cm, format_list); + request.handler = handler; + request.condition_var = cond; + if (f == NULL) { + f = INT_CMregister_format(conn->cm, EVassoc_terminal_action_req_formats); + } + INT_CMCondition_set_client_data(conn->cm, cond, &response); + INT_CMwrite(conn, f, &request); + INT_CMCondition_wait(conn->cm, cond); + return (EVaction) response.ret; +} + +extern EVaction +REVassoc_terminal_action(CMConnection conn, EVstone stone, FMStructDescList format_list, char *handler) +{ + EVaction ret; + CManager_lock(conn->cm); + ret = INT_REVassoc_terminal_action(conn, stone, format_list, handler); + CManager_unlock(conn->cm); + return ret; +} + +static void +REVassoc_terminal_action_handler(CManager cm, CMConnection conn, void *data,void *client_data,attr_list message_attrs) +{ + EV_int_response response; + EVassoc_terminal_action_request *request = (EVassoc_terminal_action_request *) data; + EVaction ret; + CMFormat f = CMlookup_format(conn->cm, EV_int_response_formats); + (void) message_attrs; + (void) client_data; + if (f == NULL) { + f = INT_CMregister_format(conn->cm, EV_int_response_formats); + } + FMStructDescList format_list = REVPlookup_format_structs(conn->cm, request->format_list); + EVSimpleHandlerFunc handler = REVPlookup_handler(request->handler); + ret = EVassoc_terminal_action(cm, request->stone, format_list, handler, NULL); + response.ret = (int) ret; + response.condition_var = request->condition_var; + CMwrite(conn, f, &response); +} + +typedef struct _EVclear_stored_request { + int condition_var; + EVstone stone_num; + EVaction action_num; +} EVclear_stored_request; + +typedef struct _EVclear_stored_response { + int condition_var; +} EVclear_stored_response; + +FMField EVclear_stored_req_flds[] = { + {"condition_var", "integer", sizeof(int), FMOffset(EVclear_stored_request*, condition_var)}, + {"stone_num", "integer", sizeof(EVstone), FMOffset(EVclear_stored_request*,stone_num)}, + {"action_num", "integer", sizeof(EVaction), FMOffset(EVclear_stored_request*,action_num)}, + {NULL, NULL, 0, 0} +}; + +FMStructDescRec EVclear_stored_req_formats[] = { + {"EV_EVclear_stored_request", EVclear_stored_req_flds, sizeof(EVclear_stored_request), NULL}, + {NULL, NULL, 0, NULL} +}; + +extern void +INT_REVclear_stored(CMConnection conn, EVstone stone_num, EVaction action_num) +{ + int cond; + CMFormat f; + EVclear_stored_request request; + memset(&request, 0, sizeof(request)); + cond = INT_CMCondition_get(conn->cm, conn); + f = INT_CMlookup_format(conn->cm, EVclear_stored_req_formats); + request.stone_num = stone_num; + request.action_num = action_num; + request.condition_var = cond; + if (f == NULL) { + f = INT_CMregister_format(conn->cm, EVclear_stored_req_formats); + } + INT_CMCondition_set_client_data(conn->cm, cond, NULL); + INT_CMwrite(conn, f, &request); + INT_CMCondition_wait(conn->cm, cond); +} + +extern void +REVclear_stored(CMConnection conn, EVstone stone_num, EVaction action_num) +{ + CManager_lock(conn->cm); + INT_REVclear_stored(conn, stone_num, action_num); + CManager_unlock(conn->cm); + return; +} + +static void +REVclear_stored_handler(CManager cm, CMConnection conn, void *data,void *client_data,attr_list message_attrs) +{ + EV_void_response response; + EVclear_stored_request *request = (EVclear_stored_request *) data; + CMFormat f = CMlookup_format(conn->cm, EV_void_response_formats); + (void) message_attrs; + (void) client_data; + if (f == NULL) { + f = INT_CMregister_format(conn->cm, EV_void_response_formats); + } + EVclear_stored(cm, request->stone_num, request->action_num); + response.condition_var = request->condition_var; + CMwrite(conn, f, &response); +} + +typedef struct _EVcreate_auto_stone_request { + int condition_var; + int period_sec; + int period_usec; + char* action_spec; + EVstone out_stone; +} EVcreate_auto_stone_request; + +typedef struct _EVcreate_auto_stone_response { + int condition_var; + EVstone ret; +} EVcreate_auto_stone_response; + +FMField EVcreate_auto_stone_req_flds[] = { + {"condition_var", "integer", sizeof(int), FMOffset(EVcreate_auto_stone_request*, condition_var)}, + {"period_sec", "integer", sizeof(int), FMOffset(EVcreate_auto_stone_request*,period_sec)}, + {"period_usec", "integer", sizeof(int), FMOffset(EVcreate_auto_stone_request*,period_usec)}, + {"action_spec", "string", sizeof(char*), FMOffset(EVcreate_auto_stone_request*,action_spec)}, + {"out_stone", "integer", sizeof(EVstone), FMOffset(EVcreate_auto_stone_request*,out_stone)}, + {NULL, NULL, 0, 0} +}; + +FMStructDescRec EVcreate_auto_stone_req_formats[] = { + {"EV_EVcreate_auto_stone_request", EVcreate_auto_stone_req_flds, sizeof(EVcreate_auto_stone_request), NULL}, + {NULL, NULL, 0, NULL} +}; + +extern EVstone +INT_REVcreate_auto_stone(CMConnection conn, int period_sec, int period_usec, char *action_spec, EVstone out_stone) +{ + int cond; + CMFormat f; + EV_int_response response; + EVcreate_auto_stone_request request; + memset(&request, 0, sizeof(request)); + cond = INT_CMCondition_get(conn->cm, conn); + f = INT_CMlookup_format(conn->cm, EVcreate_auto_stone_req_formats); + request.period_sec = period_sec; + request.period_usec = period_usec; + request.action_spec = action_spec; + request.out_stone = out_stone; + request.condition_var = cond; + if (f == NULL) { + f = INT_CMregister_format(conn->cm, EVcreate_auto_stone_req_formats); + } + INT_CMCondition_set_client_data(conn->cm, cond, &response); + INT_CMwrite(conn, f, &request); + INT_CMCondition_wait(conn->cm, cond); + return (EVstone) response.ret; +} + +extern EVstone +REVcreate_auto_stone(CMConnection conn, int period_sec, int period_usec, char *action_spec, EVstone out_stone) +{ + EVstone ret; + CManager_lock(conn->cm); + ret = INT_REVcreate_auto_stone(conn, period_sec, period_usec, action_spec, out_stone); + CManager_unlock(conn->cm); + return ret; +} + +static void +REVcreate_auto_stone_handler(CManager cm, CMConnection conn, void *data,void *client_data,attr_list message_attrs) +{ + EV_int_response response; + EVcreate_auto_stone_request *request = (EVcreate_auto_stone_request *) data; + EVstone ret; + CMFormat f = CMlookup_format(conn->cm, EV_int_response_formats); + (void) message_attrs; + (void) client_data; + if (f == NULL) { + f = INT_CMregister_format(conn->cm, EV_int_response_formats); + } + ret = EVcreate_auto_stone(cm, request->period_sec, request->period_usec, request->action_spec, request->out_stone); + response.ret = (int)ret; + response.condition_var = request->condition_var; + CMwrite(conn, f, &response); +} + +typedef struct _EVcreate_bridge_action_request { + int condition_var; + char* contact_list; + EVstone remote_stone; +} EVcreate_bridge_action_request; + +typedef struct _EVcreate_bridge_action_response { + int condition_var; + EVstone ret; +} EVcreate_bridge_action_response; + +FMField EVcreate_bridge_action_req_flds[] = { + {"condition_var", "integer", sizeof(int), FMOffset(EVcreate_bridge_action_request*, condition_var)}, + {"contact_list", "string", sizeof(attr_list), FMOffset(EVcreate_bridge_action_request*,contact_list)}, + {"remote_stone", "integer", sizeof(EVstone), FMOffset(EVcreate_bridge_action_request*,remote_stone)}, + {NULL, NULL, 0, 0} +}; + +FMStructDescRec EVcreate_bridge_action_req_formats[] = { + {"EV_EVcreate_bridge_action_request", EVcreate_bridge_action_req_flds, sizeof(EVcreate_bridge_action_request), NULL}, + {NULL, NULL, 0, NULL} +}; + +extern EVstone +INT_REVcreate_bridge_action(CMConnection conn, attr_list contact_list, EVstone remote_stone) +{ + int cond; + CMFormat f; + EV_int_response response; + EVcreate_bridge_action_request request; + memset(&request, 0, sizeof(request)); + cond = INT_CMCondition_get(conn->cm, conn); + f = INT_CMlookup_format(conn->cm, EVcreate_bridge_action_req_formats); + request.contact_list = attr_list_to_string(contact_list); + request.remote_stone = remote_stone; + request.condition_var = cond; + if (f == NULL) { + f = INT_CMregister_format(conn->cm, EVcreate_bridge_action_req_formats); + } + INT_CMCondition_set_client_data(conn->cm, cond, &response); + INT_CMwrite(conn, f, &request); + free(request.contact_list); + INT_CMCondition_wait(conn->cm, cond); + return (EVstone) response.ret; +} + +extern EVstone +REVcreate_bridge_action(CMConnection conn, attr_list contact_list, EVstone remote_stone) +{ + EVstone ret; + CManager_lock(conn->cm); + ret = INT_REVcreate_bridge_action(conn, contact_list, remote_stone); + CManager_unlock(conn->cm); + return ret; +} + +static void +REVcreate_bridge_action_handler(CManager cm, CMConnection conn, void *data,void *client_data,attr_list message_attrs) +{ + EV_int_response response; + EVcreate_bridge_action_request *request = (EVcreate_bridge_action_request *) data; + EVstone ret; + CMFormat f = CMlookup_format(conn->cm, EV_int_response_formats); + (void) message_attrs; + (void) client_data; + if (f == NULL) { + f = INT_CMregister_format(conn->cm, EV_int_response_formats); + } + attr_list contact_list = attr_list_from_string(request->contact_list); + ret = EVcreate_bridge_action(cm, contact_list, request->remote_stone); +free_attr_list(contact_list); + response.ret = (int)ret; + response.condition_var = request->condition_var; + CMwrite(conn, f, &response); +} + +typedef struct _EVcreate_immediate_action_request { + int condition_var; + char* action_spec; + int target_list_len; + int * target_list; +} EVcreate_immediate_action_request; + +typedef struct _EVcreate_immediate_action_response { + int condition_var; + EVstone ret; +} EVcreate_immediate_action_response; + +FMField EVcreate_immediate_action_req_flds[] = { + {"condition_var", "integer", sizeof(int), FMOffset(EVcreate_immediate_action_request*, condition_var)}, + {"action_spec", "string", sizeof(char*), FMOffset(EVcreate_immediate_action_request*,action_spec)}, + {"target_list", "integer", sizeof(EVstone*), FMOffset(EVcreate_immediate_action_request*,target_list)}, + {NULL, NULL, 0, 0} +}; + +FMStructDescRec EVcreate_immediate_action_req_formats[] = { + {"EV_EVcreate_immediate_action_request", EVcreate_immediate_action_req_flds, sizeof(EVcreate_immediate_action_request), NULL}, + {NULL, NULL, 0, NULL} +}; + +extern EVstone +INT_REVcreate_immediate_action(CMConnection conn, char *action_spec, EVstone *target_list) +{ + int cond; + CMFormat f; + EV_int_response response; + EVcreate_immediate_action_request request; + memset(&request, 0, sizeof(request)); + cond = INT_CMCondition_get(conn->cm, conn); + f = INT_CMlookup_format(conn->cm, EVcreate_immediate_action_req_formats); + request.action_spec = action_spec; + request.target_list = target_list; + request.condition_var = cond; + if (f == NULL) { + f = INT_CMregister_format(conn->cm, EVcreate_immediate_action_req_formats); + } + INT_CMCondition_set_client_data(conn->cm, cond, &response); + INT_CMwrite(conn, f, &request); + INT_CMCondition_wait(conn->cm, cond); + return (EVstone) response.ret; +} + +extern EVstone +REVcreate_immediate_action(CMConnection conn, char *action_spec, EVstone *target_list) +{ + EVstone ret; + CManager_lock(conn->cm); + ret = INT_REVcreate_immediate_action(conn, action_spec, target_list); + CManager_unlock(conn->cm); + return ret; +} + +static void +REVcreate_immediate_action_handler(CManager cm, CMConnection conn, void *data,void *client_data,attr_list message_attrs) +{ + EV_int_response response; + EVcreate_immediate_action_request *request = (EVcreate_immediate_action_request *) data; + EVstone ret; + CMFormat f = CMlookup_format(conn->cm, EV_int_response_formats); + (void) message_attrs; + (void) client_data; + if (f == NULL) { + f = INT_CMregister_format(conn->cm, EV_int_response_formats); + } + ret = EVcreate_immediate_action(cm, request->action_spec, request->target_list); + response.ret = (int)ret; + response.condition_var = request->condition_var; + CMwrite(conn, f, &response); +} + +typedef struct _EVcreate_split_action_request { + int condition_var; + int target_list_len; + int * target_list; +} EVcreate_split_action_request; + +typedef struct _EVcreate_split_action_response { + int condition_var; + EVstone ret; +} EVcreate_split_action_response; + +FMField EVcreate_split_action_req_flds[] = { + {"condition_var", "integer", sizeof(int), FMOffset(EVcreate_split_action_request*, condition_var)}, + {"target_list", "integer", sizeof(EVstone*), FMOffset(EVcreate_split_action_request*,target_list)}, + {NULL, NULL, 0, 0} +}; + +FMStructDescRec EVcreate_split_action_req_formats[] = { + {"EV_EVcreate_split_action_request", EVcreate_split_action_req_flds, sizeof(EVcreate_split_action_request), NULL}, + {NULL, NULL, 0, NULL} +}; + +extern EVstone +INT_REVcreate_split_action(CMConnection conn, EVstone *target_list) +{ + int cond; + CMFormat f; + EV_int_response response; + EVcreate_split_action_request request; + memset(&request, 0, sizeof(request)); + cond = INT_CMCondition_get(conn->cm, conn); + f = INT_CMlookup_format(conn->cm, EVcreate_split_action_req_formats); + request.target_list = target_list; + request.condition_var = cond; + if (f == NULL) { + f = INT_CMregister_format(conn->cm, EVcreate_split_action_req_formats); + } + INT_CMCondition_set_client_data(conn->cm, cond, &response); + INT_CMwrite(conn, f, &request); + INT_CMCondition_wait(conn->cm, cond); + return (EVstone) response.ret; +} + +extern EVstone +REVcreate_split_action(CMConnection conn, EVstone *target_list) +{ + EVstone ret; + CManager_lock(conn->cm); + ret = INT_REVcreate_split_action(conn, target_list); + CManager_unlock(conn->cm); + return ret; +} + +static void +REVcreate_split_action_handler(CManager cm, CMConnection conn, void *data,void *client_data,attr_list message_attrs) +{ + EV_int_response response; + EVcreate_split_action_request *request = (EVcreate_split_action_request *) data; + EVstone ret; + CMFormat f = CMlookup_format(conn->cm, EV_int_response_formats); + (void) message_attrs; + (void) client_data; + if (f == NULL) { + f = INT_CMregister_format(conn->cm, EV_int_response_formats); + } + ret = EVcreate_split_action(cm, request->target_list); + response.ret = (int)ret; + response.condition_var = request->condition_var; + CMwrite(conn, f, &response); +} + +typedef struct _EVcreate_stone_action_request { + int condition_var; + char* action_spec; +} EVcreate_stone_action_request; + +typedef struct _EVcreate_stone_action_response { + int condition_var; + EVstone ret; +} EVcreate_stone_action_response; + +FMField EVcreate_stone_action_req_flds[] = { + {"condition_var", "integer", sizeof(int), FMOffset(EVcreate_stone_action_request*, condition_var)}, + {"action_spec", "string", sizeof(char*), FMOffset(EVcreate_stone_action_request*,action_spec)}, + {NULL, NULL, 0, 0} +}; + +FMStructDescRec EVcreate_stone_action_req_formats[] = { + {"EV_EVcreate_stone_action_request", EVcreate_stone_action_req_flds, sizeof(EVcreate_stone_action_request), NULL}, + {NULL, NULL, 0, NULL} +}; + +extern EVstone +INT_REVcreate_stone_action(CMConnection conn, char *action_spec) +{ + int cond; + CMFormat f; + EV_int_response response; + EVcreate_stone_action_request request; + memset(&request, 0, sizeof(request)); + cond = INT_CMCondition_get(conn->cm, conn); + f = INT_CMlookup_format(conn->cm, EVcreate_stone_action_req_formats); + request.action_spec = action_spec; + request.condition_var = cond; + if (f == NULL) { + f = INT_CMregister_format(conn->cm, EVcreate_stone_action_req_formats); + } + INT_CMCondition_set_client_data(conn->cm, cond, &response); + INT_CMwrite(conn, f, &request); + INT_CMCondition_wait(conn->cm, cond); + return (EVstone) response.ret; +} + +extern EVstone +REVcreate_stone_action(CMConnection conn, char *action_spec) +{ + EVstone ret; + CManager_lock(conn->cm); + ret = INT_REVcreate_stone_action(conn, action_spec); + CManager_unlock(conn->cm); + return ret; +} + +static void +REVcreate_stone_action_handler(CManager cm, CMConnection conn, void *data,void *client_data,attr_list message_attrs) +{ + EV_int_response response; + EVcreate_stone_action_request *request = (EVcreate_stone_action_request *) data; + EVstone ret; + CMFormat f = CMlookup_format(conn->cm, EV_int_response_formats); + (void) message_attrs; + (void) client_data; + if (f == NULL) { + f = INT_CMregister_format(conn->cm, EV_int_response_formats); + } + ret = EVcreate_stone_action(cm, request->action_spec); + response.ret = (int)ret; + response.condition_var = request->condition_var; + CMwrite(conn, f, &response); +} + +typedef struct _EVcreate_store_action_request { + int condition_var; + EVstone out_stone; + int store_limit; +} EVcreate_store_action_request; + +typedef struct _EVcreate_store_action_response { + int condition_var; + EVstone ret; +} EVcreate_store_action_response; + +FMField EVcreate_store_action_req_flds[] = { + {"condition_var", "integer", sizeof(int), FMOffset(EVcreate_store_action_request*, condition_var)}, + {"out_stone", "integer", sizeof(EVstone), FMOffset(EVcreate_store_action_request*,out_stone)}, + {"store_limit", "integer", sizeof(int), FMOffset(EVcreate_store_action_request*,store_limit)}, + {NULL, NULL, 0, 0} +}; + +FMStructDescRec EVcreate_store_action_req_formats[] = { + {"EV_EVcreate_store_action_request", EVcreate_store_action_req_flds, sizeof(EVcreate_store_action_request), NULL}, + {NULL, NULL, 0, NULL} +}; + +extern EVstone +INT_REVcreate_store_action(CMConnection conn, EVstone out_stone, int store_limit) +{ + int cond; + CMFormat f; + EV_int_response response; + EVcreate_store_action_request request; + memset(&request, 0, sizeof(request)); + cond = INT_CMCondition_get(conn->cm, conn); + f = INT_CMlookup_format(conn->cm, EVcreate_store_action_req_formats); + request.out_stone = out_stone; + request.store_limit = store_limit; + request.condition_var = cond; + if (f == NULL) { + f = INT_CMregister_format(conn->cm, EVcreate_store_action_req_formats); + } + INT_CMCondition_set_client_data(conn->cm, cond, &response); + INT_CMwrite(conn, f, &request); + INT_CMCondition_wait(conn->cm, cond); + return (EVstone) response.ret; +} + +extern EVstone +REVcreate_store_action(CMConnection conn, EVstone out_stone, int store_limit) +{ + EVstone ret; + CManager_lock(conn->cm); + ret = INT_REVcreate_store_action(conn, out_stone, store_limit); + CManager_unlock(conn->cm); + return ret; +} + +static void +REVcreate_store_action_handler(CManager cm, CMConnection conn, void *data,void *client_data,attr_list message_attrs) +{ + EV_int_response response; + EVcreate_store_action_request *request = (EVcreate_store_action_request *) data; + EVstone ret; + CMFormat f = CMlookup_format(conn->cm, EV_int_response_formats); + (void) message_attrs; + (void) client_data; + if (f == NULL) { + f = INT_CMregister_format(conn->cm, EV_int_response_formats); + } + ret = EVcreate_store_action(cm, request->out_stone, request->store_limit); + response.ret = (int)ret; + response.condition_var = request->condition_var; + CMwrite(conn, f, &response); +} + +typedef struct _EVcreate_terminal_action_request { + int condition_var; + char* format_list; + char* handler; +} EVcreate_terminal_action_request; + +typedef struct _EVcreate_terminal_action_response { + int condition_var; + EVstone ret; +} EVcreate_terminal_action_response; + +FMField EVcreate_terminal_action_req_flds[] = { + {"condition_var", "integer", sizeof(int), FMOffset(EVcreate_terminal_action_request*, condition_var)}, + {"format_list", "string", sizeof(FMStructDescList), FMOffset(EVcreate_terminal_action_request*,format_list)}, + {"handler", "string", sizeof(char*), FMOffset(EVcreate_terminal_action_request*,handler)}, + {NULL, NULL, 0, 0} +}; + +FMStructDescRec EVcreate_terminal_action_req_formats[] = { + {"EV_EVcreate_terminal_action_request", EVcreate_terminal_action_req_flds, sizeof(EVcreate_terminal_action_request), NULL}, + {NULL, NULL, 0, NULL} +}; + +extern EVstone +INT_REVcreate_terminal_action(CMConnection conn, FMStructDescList format_list, char *handler) +{ + int cond; + CMFormat f; + EV_int_response response; + EVcreate_terminal_action_request request; + memset(&request, 0, sizeof(request)); + cond = INT_CMCondition_get(conn->cm, conn); + f = INT_CMlookup_format(conn->cm, EVcreate_terminal_action_req_formats); + request.format_list = get_format_name(conn->cm, format_list); + request.handler = handler; + request.condition_var = cond; + if (f == NULL) { + f = INT_CMregister_format(conn->cm, EVcreate_terminal_action_req_formats); + } + INT_CMCondition_set_client_data(conn->cm, cond, &response); + INT_CMwrite(conn, f, &request); + INT_CMCondition_wait(conn->cm, cond); + return (EVstone) response.ret; +} + +extern EVstone +REVcreate_terminal_action(CMConnection conn, FMStructDescList format_list, char *handler) +{ + EVstone ret; + CManager_lock(conn->cm); + ret = INT_REVcreate_terminal_action(conn, format_list, handler); + CManager_unlock(conn->cm); + return ret; +} + +static void +REVcreate_terminal_action_handler(CManager cm, CMConnection conn, void *data,void *client_data,attr_list message_attrs) +{ + EV_int_response response; + EVcreate_terminal_action_request *request = (EVcreate_terminal_action_request *) data; + EVstone ret; + CMFormat f = CMlookup_format(conn->cm, EV_int_response_formats); + (void) message_attrs; + (void) client_data; + if (f == NULL) { + f = INT_CMregister_format(conn->cm, EV_int_response_formats); + } + FMStructDescList format_list = REVPlookup_format_structs(conn->cm, request->format_list); + EVSimpleHandlerFunc handler = REVPlookup_handler(request->handler); + ret = EVcreate_terminal_action(cm, format_list, handler, NULL); + response.ret = (int)ret; + response.condition_var = request->condition_var; + CMwrite(conn, f, &response); +} + +typedef struct _EVdestroy_stone_request { + int condition_var; + EVstone stone_id; +} EVdestroy_stone_request; + +typedef struct _EVdestroy_stone_response { + int condition_var; + int ret; +} EVdestroy_stone_response; + +FMField EVdestroy_stone_req_flds[] = { + {"condition_var", "integer", sizeof(int), FMOffset(EVdestroy_stone_request*, condition_var)}, + {"stone_id", "integer", sizeof(EVstone), FMOffset(EVdestroy_stone_request*,stone_id)}, + {NULL, NULL, 0, 0} +}; + +FMStructDescRec EVdestroy_stone_req_formats[] = { + {"EV_EVdestroy_stone_request", EVdestroy_stone_req_flds, sizeof(EVdestroy_stone_request), NULL}, + {NULL, NULL, 0, NULL} +}; + +extern int +INT_REVdestroy_stone(CMConnection conn, EVstone stone_id) +{ + int cond; + CMFormat f; + EV_int_response response; + EVdestroy_stone_request request; + memset(&request, 0, sizeof(request)); + cond = INT_CMCondition_get(conn->cm, conn); + f = INT_CMlookup_format(conn->cm, EVdestroy_stone_req_formats); + request.stone_id = stone_id; + request.condition_var = cond; + if (f == NULL) { + f = INT_CMregister_format(conn->cm, EVdestroy_stone_req_formats); + } + INT_CMCondition_set_client_data(conn->cm, cond, &response); + INT_CMwrite(conn, f, &request); + INT_CMCondition_wait(conn->cm, cond); + return response.ret; +} + +extern int +REVdestroy_stone(CMConnection conn, EVstone stone_id) +{ + int ret; + CManager_lock(conn->cm); + ret = INT_REVdestroy_stone(conn, stone_id); + CManager_unlock(conn->cm); + return ret; +} + +static void +REVdestroy_stone_handler(CManager cm, CMConnection conn, void *data,void *client_data,attr_list message_attrs) +{ + EV_int_response response; + EVdestroy_stone_request *request = (EVdestroy_stone_request *) data; + int ret; + CMFormat f = CMlookup_format(conn->cm, EV_int_response_formats); + (void) message_attrs; + (void) client_data; + if (f == NULL) { + f = INT_CMregister_format(conn->cm, EV_int_response_formats); + } + ret = EVdestroy_stone(cm, request->stone_id); + response.ret = ret;; + response.condition_var = request->condition_var; + CMwrite(conn, f, &response); +} + +typedef struct _EVdrain_stone_request { + int condition_var; + EVstone stone_id; +} EVdrain_stone_request; + +typedef struct _EVdrain_stone_response { + int condition_var; + int ret; +} EVdrain_stone_response; + +FMField EVdrain_stone_req_flds[] = { + {"condition_var", "integer", sizeof(int), FMOffset(EVdrain_stone_request*, condition_var)}, + {"stone_id", "integer", sizeof(EVstone), FMOffset(EVdrain_stone_request*,stone_id)}, + {NULL, NULL, 0, 0} +}; + +FMStructDescRec EVdrain_stone_req_formats[] = { + {"EV_EVdrain_stone_request", EVdrain_stone_req_flds, sizeof(EVdrain_stone_request), NULL}, + {NULL, NULL, 0, NULL} +}; + +extern int +INT_REVdrain_stone(CMConnection conn, EVstone stone_id) +{ + int cond; + CMFormat f; + EV_int_response response; + EVdrain_stone_request request; + memset(&request, 0, sizeof(request)); + cond = INT_CMCondition_get(conn->cm, conn); + f = INT_CMlookup_format(conn->cm, EVdrain_stone_req_formats); + request.stone_id = stone_id; + request.condition_var = cond; + if (f == NULL) { + f = INT_CMregister_format(conn->cm, EVdrain_stone_req_formats); + } + INT_CMCondition_set_client_data(conn->cm, cond, &response); + INT_CMwrite(conn, f, &request); + INT_CMCondition_wait(conn->cm, cond); + return response.ret; +} + +extern int +REVdrain_stone(CMConnection conn, EVstone stone_id) +{ + int ret; + CManager_lock(conn->cm); + ret = INT_REVdrain_stone(conn, stone_id); + CManager_unlock(conn->cm); + return ret; +} + +static void +REVdrain_stone_handler(CManager cm, CMConnection conn, void *data,void *client_data,attr_list message_attrs) +{ + EV_int_response response; + EVdrain_stone_request *request = (EVdrain_stone_request *) data; + int ret; + CMFormat f = CMlookup_format(conn->cm, EV_int_response_formats); + (void) message_attrs; + (void) client_data; + if (f == NULL) { + f = INT_CMregister_format(conn->cm, EV_int_response_formats); + } + ret = EVdrain_stone(cm, request->stone_id); + response.ret = ret;; + response.condition_var = request->condition_var; + CMwrite(conn, f, &response); +} + +typedef struct _EVenable_auto_stone_request { + int condition_var; + EVstone stone_num; + int period_sec; + int period_usec; +} EVenable_auto_stone_request; + +typedef struct _EVenable_auto_stone_response { + int condition_var; +} EVenable_auto_stone_response; + +FMField EVenable_auto_stone_req_flds[] = { + {"condition_var", "integer", sizeof(int), FMOffset(EVenable_auto_stone_request*, condition_var)}, + {"stone_num", "integer", sizeof(EVstone), FMOffset(EVenable_auto_stone_request*,stone_num)}, + {"period_sec", "integer", sizeof(int), FMOffset(EVenable_auto_stone_request*,period_sec)}, + {"period_usec", "integer", sizeof(int), FMOffset(EVenable_auto_stone_request*,period_usec)}, + {NULL, NULL, 0, 0} +}; + +FMStructDescRec EVenable_auto_stone_req_formats[] = { + {"EV_EVenable_auto_stone_request", EVenable_auto_stone_req_flds, sizeof(EVenable_auto_stone_request), NULL}, + {NULL, NULL, 0, NULL} +}; + +extern void +INT_REVenable_auto_stone(CMConnection conn, EVstone stone_num, int period_sec, int period_usec) +{ + int cond; + CMFormat f; + EVenable_auto_stone_request request; + memset(&request, 0, sizeof(request)); + cond = INT_CMCondition_get(conn->cm, conn); + f = INT_CMlookup_format(conn->cm, EVenable_auto_stone_req_formats); + request.stone_num = stone_num; + request.period_sec = period_sec; + request.period_usec = period_usec; + request.condition_var = cond; + if (f == NULL) { + f = INT_CMregister_format(conn->cm, EVenable_auto_stone_req_formats); + } + INT_CMCondition_set_client_data(conn->cm, cond, NULL); + INT_CMwrite(conn, f, &request); + INT_CMCondition_wait(conn->cm, cond); +} + +extern void +REVenable_auto_stone(CMConnection conn, EVstone stone_num, int period_sec, int period_usec) +{ + CManager_lock(conn->cm); + INT_REVenable_auto_stone(conn, stone_num, period_sec, period_usec); + CManager_unlock(conn->cm); + return; +} + +static void +REVenable_auto_stone_handler(CManager cm, CMConnection conn, void *data,void *client_data,attr_list message_attrs) +{ + EV_void_response response; + EVenable_auto_stone_request *request = (EVenable_auto_stone_request *) data; + CMFormat f = CMlookup_format(conn->cm, EV_void_response_formats); + (void) message_attrs; + (void) client_data; + if (f == NULL) { + f = INT_CMregister_format(conn->cm, EV_void_response_formats); + } + EVenable_auto_stone(cm, request->stone_num, request->period_sec, request->period_usec); + response.condition_var = request->condition_var; + CMwrite(conn, f, &response); +} + +typedef struct _EVextract_attr_list_request { + int condition_var; + EVstone stone_id; +} EVextract_attr_list_request; + +typedef struct _EVextract_attr_list_response { + int condition_var; + char* ret; +} EVextract_attr_list_response; + +FMField EVextract_attr_list_req_flds[] = { + {"condition_var", "integer", sizeof(int), FMOffset(EVextract_attr_list_request*, condition_var)}, + {"stone_id", "integer", sizeof(EVstone), FMOffset(EVextract_attr_list_request*,stone_id)}, + {NULL, NULL, 0, 0} +}; + +FMStructDescRec EVextract_attr_list_req_formats[] = { + {"EV_EVextract_attr_list_request", EVextract_attr_list_req_flds, sizeof(EVextract_attr_list_request), NULL}, + {NULL, NULL, 0, NULL} +}; + +extern attr_list +INT_REVextract_attr_list(CMConnection conn, EVstone stone_id) +{ + int cond; + CMFormat f; + EV_string_response response; + EVextract_attr_list_request request; + memset(&request, 0, sizeof(request)); + cond = INT_CMCondition_get(conn->cm, conn); + f = INT_CMlookup_format(conn->cm, EVextract_attr_list_req_formats); + request.stone_id = stone_id; + request.condition_var = cond; + if (f == NULL) { + f = INT_CMregister_format(conn->cm, EVextract_attr_list_req_formats); + } + INT_CMCondition_set_client_data(conn->cm, cond, &response); + INT_CMwrite(conn, f, &request); + INT_CMCondition_wait(conn->cm, cond); + return attr_list_from_string(response.ret); +} + +extern attr_list +REVextract_attr_list(CMConnection conn, EVstone stone_id) +{ + attr_list ret; + CManager_lock(conn->cm); + ret = INT_REVextract_attr_list(conn, stone_id); + CManager_unlock(conn->cm); + return ret; +} + +static void +REVextract_attr_list_handler(CManager cm, CMConnection conn, void *data,void *client_data,attr_list message_attrs) +{ + EV_string_response response; + EVextract_attr_list_request *request = (EVextract_attr_list_request *) data; + attr_list ret; + CMFormat f = CMlookup_format(conn->cm, EV_string_response_formats); + (void) message_attrs; + (void) client_data; + if (f == NULL) { + f = INT_CMregister_format(conn->cm, EV_string_response_formats); + } + ret = EVextract_attr_list(cm, request->stone_id); + response.ret = attr_list_to_string(ret); + response.condition_var = request->condition_var; + CMwrite(conn, f, &response); + free(response.ret); +} + +typedef struct _EVfree_stone_request { + int condition_var; + EVstone stone; +} EVfree_stone_request; + +typedef struct _EVfree_stone_response { + int condition_var; +} EVfree_stone_response; + +FMField EVfree_stone_req_flds[] = { + {"condition_var", "integer", sizeof(int), FMOffset(EVfree_stone_request*, condition_var)}, + {"stone", "integer", sizeof(EVstone), FMOffset(EVfree_stone_request*,stone)}, + {NULL, NULL, 0, 0} +}; + +FMStructDescRec EVfree_stone_req_formats[] = { + {"EV_EVfree_stone_request", EVfree_stone_req_flds, sizeof(EVfree_stone_request), NULL}, + {NULL, NULL, 0, NULL} +}; + +extern void +INT_REVfree_stone(CMConnection conn, EVstone stone) +{ + int cond; + CMFormat f; + EVfree_stone_request request; + memset(&request, 0, sizeof(request)); + cond = INT_CMCondition_get(conn->cm, conn); + f = INT_CMlookup_format(conn->cm, EVfree_stone_req_formats); + request.stone = stone; + request.condition_var = cond; + if (f == NULL) { + f = INT_CMregister_format(conn->cm, EVfree_stone_req_formats); + } + INT_CMCondition_set_client_data(conn->cm, cond, NULL); + INT_CMwrite(conn, f, &request); + INT_CMCondition_wait(conn->cm, cond); +} + +extern void +REVfree_stone(CMConnection conn, EVstone stone) +{ + CManager_lock(conn->cm); + INT_REVfree_stone(conn, stone); + CManager_unlock(conn->cm); + return; +} + +static void +REVfree_stone_handler(CManager cm, CMConnection conn, void *data,void *client_data,attr_list message_attrs) +{ + EV_void_response response; + EVfree_stone_request *request = (EVfree_stone_request *) data; + CMFormat f = CMlookup_format(conn->cm, EV_void_response_formats); + (void) message_attrs; + (void) client_data; + if (f == NULL) { + f = INT_CMregister_format(conn->cm, EV_void_response_formats); + } + EVfree_stone(cm, request->stone); + response.condition_var = request->condition_var; + CMwrite(conn, f, &response); +} + +typedef struct _EVfreeze_stone_request { + int condition_var; + EVstone stone_id; +} EVfreeze_stone_request; + +typedef struct _EVfreeze_stone_response { + int condition_var; + int ret; +} EVfreeze_stone_response; + +FMField EVfreeze_stone_req_flds[] = { + {"condition_var", "integer", sizeof(int), FMOffset(EVfreeze_stone_request*, condition_var)}, + {"stone_id", "integer", sizeof(EVstone), FMOffset(EVfreeze_stone_request*,stone_id)}, + {NULL, NULL, 0, 0} +}; + +FMStructDescRec EVfreeze_stone_req_formats[] = { + {"EV_EVfreeze_stone_request", EVfreeze_stone_req_flds, sizeof(EVfreeze_stone_request), NULL}, + {NULL, NULL, 0, NULL} +}; + +extern int +INT_REVfreeze_stone(CMConnection conn, EVstone stone_id) +{ + int cond; + CMFormat f; + EV_int_response response; + EVfreeze_stone_request request; + memset(&request, 0, sizeof(request)); + cond = INT_CMCondition_get(conn->cm, conn); + f = INT_CMlookup_format(conn->cm, EVfreeze_stone_req_formats); + request.stone_id = stone_id; + request.condition_var = cond; + if (f == NULL) { + f = INT_CMregister_format(conn->cm, EVfreeze_stone_req_formats); + } + INT_CMCondition_set_client_data(conn->cm, cond, &response); + INT_CMwrite(conn, f, &request); + INT_CMCondition_wait(conn->cm, cond); + return response.ret; +} + +extern int +REVfreeze_stone(CMConnection conn, EVstone stone_id) +{ + int ret; + CManager_lock(conn->cm); + ret = INT_REVfreeze_stone(conn, stone_id); + CManager_unlock(conn->cm); + return ret; +} + +static void +REVfreeze_stone_handler(CManager cm, CMConnection conn, void *data,void *client_data,attr_list message_attrs) +{ + EV_int_response response; + EVfreeze_stone_request *request = (EVfreeze_stone_request *) data; + int ret; + CMFormat f = CMlookup_format(conn->cm, EV_int_response_formats); + (void) message_attrs; + (void) client_data; + if (f == NULL) { + f = INT_CMregister_format(conn->cm, EV_int_response_formats); + } + ret = EVfreeze_stone(cm, request->stone_id); + response.ret = ret;; + response.condition_var = request->condition_var; + CMwrite(conn, f, &response); +} + +typedef struct _EVset_attr_list_request { + int condition_var; + EVstone stone_id; + char* list; +} EVset_attr_list_request; + +typedef struct _EVset_attr_list_response { + int condition_var; +} EVset_attr_list_response; + +FMField EVset_attr_list_req_flds[] = { + {"condition_var", "integer", sizeof(int), FMOffset(EVset_attr_list_request*, condition_var)}, + {"stone_id", "integer", sizeof(EVstone), FMOffset(EVset_attr_list_request*,stone_id)}, + {"list", "string", sizeof(attr_list), FMOffset(EVset_attr_list_request*,list)}, + {NULL, NULL, 0, 0} +}; + +FMStructDescRec EVset_attr_list_req_formats[] = { + {"EV_EVset_attr_list_request", EVset_attr_list_req_flds, sizeof(EVset_attr_list_request), NULL}, + {NULL, NULL, 0, NULL} +}; + +extern void +INT_REVset_attr_list(CMConnection conn, EVstone stone_id, attr_list list) +{ + int cond; + CMFormat f; + EVset_attr_list_request request; + memset(&request, 0, sizeof(request)); + cond = INT_CMCondition_get(conn->cm, conn); + f = INT_CMlookup_format(conn->cm, EVset_attr_list_req_formats); + request.stone_id = stone_id; + request.list = attr_list_to_string(list); + request.condition_var = cond; + if (f == NULL) { + f = INT_CMregister_format(conn->cm, EVset_attr_list_req_formats); + } + INT_CMCondition_set_client_data(conn->cm, cond, NULL); + INT_CMwrite(conn, f, &request); + free(request.list); + INT_CMCondition_wait(conn->cm, cond); +} + +extern void +REVset_attr_list(CMConnection conn, EVstone stone_id, attr_list list) +{ + CManager_lock(conn->cm); + INT_REVset_attr_list(conn, stone_id, list); + CManager_unlock(conn->cm); + return; +} + +static void +REVset_attr_list_handler(CManager cm, CMConnection conn, void *data,void *client_data,attr_list message_attrs) +{ + EV_void_response response; + EVset_attr_list_request *request = (EVset_attr_list_request *) data; + CMFormat f = CMlookup_format(conn->cm, EV_void_response_formats); + (void) message_attrs; + (void) client_data; + if (f == NULL) { + f = INT_CMregister_format(conn->cm, EV_void_response_formats); + } + attr_list list = attr_list_from_string(request->list); + EVset_attr_list(cm, request->stone_id, list); +free_attr_list(list); + response.condition_var = request->condition_var; + CMwrite(conn, f, &response); +} + +typedef struct _EVstall_stone_request { + int condition_var; + EVstone stone_id; +} EVstall_stone_request; + +typedef struct _EVstall_stone_response { + int condition_var; +} EVstall_stone_response; + +FMField EVstall_stone_req_flds[] = { + {"condition_var", "integer", sizeof(int), FMOffset(EVstall_stone_request*, condition_var)}, + {"stone_id", "integer", sizeof(EVstone), FMOffset(EVstall_stone_request*,stone_id)}, + {NULL, NULL, 0, 0} +}; + +FMStructDescRec EVstall_stone_req_formats[] = { + {"EV_EVstall_stone_request", EVstall_stone_req_flds, sizeof(EVstall_stone_request), NULL}, + {NULL, NULL, 0, NULL} +}; + +extern void +INT_REVstall_stone(CMConnection conn, EVstone stone_id) +{ + int cond; + CMFormat f; + EVstall_stone_request request; + memset(&request, 0, sizeof(request)); + cond = INT_CMCondition_get(conn->cm, conn); + f = INT_CMlookup_format(conn->cm, EVstall_stone_req_formats); + request.stone_id = stone_id; + request.condition_var = cond; + if (f == NULL) { + f = INT_CMregister_format(conn->cm, EVstall_stone_req_formats); + } + INT_CMCondition_set_client_data(conn->cm, cond, NULL); + INT_CMwrite(conn, f, &request); + INT_CMCondition_wait(conn->cm, cond); +} + +extern void +REVstall_stone(CMConnection conn, EVstone stone_id) +{ + CManager_lock(conn->cm); + INT_REVstall_stone(conn, stone_id); + CManager_unlock(conn->cm); + return; +} + +static void +REVstall_stone_handler(CManager cm, CMConnection conn, void *data,void *client_data,attr_list message_attrs) +{ + EV_void_response response; + EVstall_stone_request *request = (EVstall_stone_request *) data; + CMFormat f = CMlookup_format(conn->cm, EV_void_response_formats); + (void) message_attrs; + (void) client_data; + if (f == NULL) { + f = INT_CMregister_format(conn->cm, EV_void_response_formats); + } + EVstall_stone(cm, request->stone_id); + response.condition_var = request->condition_var; + CMwrite(conn, f, &response); +} + +typedef struct _EVstone_add_split_target_request { + int condition_var; + EVstone stone; + EVstone target_stone; +} EVstone_add_split_target_request; + +typedef struct _EVstone_add_split_target_response { + int condition_var; +} EVstone_add_split_target_response; + +FMField EVstone_add_split_target_req_flds[] = { + {"condition_var", "integer", sizeof(int), FMOffset(EVstone_add_split_target_request*, condition_var)}, + {"stone", "integer", sizeof(EVstone), FMOffset(EVstone_add_split_target_request*,stone)}, + {"target_stone", "integer", sizeof(EVstone), FMOffset(EVstone_add_split_target_request*,target_stone)}, + {NULL, NULL, 0, 0} +}; + +FMStructDescRec EVstone_add_split_target_req_formats[] = { + {"EV_EVstone_add_split_target_request", EVstone_add_split_target_req_flds, sizeof(EVstone_add_split_target_request), NULL}, + {NULL, NULL, 0, NULL} +}; + +extern void +INT_REVstone_add_split_target(CMConnection conn, EVstone stone, EVstone target_stone) +{ + int cond; + CMFormat f; + EVstone_add_split_target_request request; + memset(&request, 0, sizeof(request)); + cond = INT_CMCondition_get(conn->cm, conn); + f = INT_CMlookup_format(conn->cm, EVstone_add_split_target_req_formats); + request.stone = stone; + request.target_stone = target_stone; + request.condition_var = cond; + if (f == NULL) { + f = INT_CMregister_format(conn->cm, EVstone_add_split_target_req_formats); + } + INT_CMCondition_set_client_data(conn->cm, cond, NULL); + INT_CMwrite(conn, f, &request); + INT_CMCondition_wait(conn->cm, cond); +} + +extern void +REVstone_add_split_target(CMConnection conn, EVstone stone, EVstone target_stone) +{ + CManager_lock(conn->cm); + INT_REVstone_add_split_target(conn, stone, target_stone); + CManager_unlock(conn->cm); + return; +} + +static void +REVstone_add_split_target_handler(CManager cm, CMConnection conn, void *data,void *client_data,attr_list message_attrs) +{ + EV_void_response response; + EVstone_add_split_target_request *request = (EVstone_add_split_target_request *) data; + CMFormat f = CMlookup_format(conn->cm, EV_void_response_formats); + (void) message_attrs; + (void) client_data; + if (f == NULL) { + f = INT_CMregister_format(conn->cm, EV_void_response_formats); + } + EVstone_add_split_target(cm, request->stone, request->target_stone); + response.condition_var = request->condition_var; + CMwrite(conn, f, &response); +} + +typedef struct _EVstone_remove_split_target_request { + int condition_var; + EVstone stone; + EVstone target_stone; +} EVstone_remove_split_target_request; + +typedef struct _EVstone_remove_split_target_response { + int condition_var; +} EVstone_remove_split_target_response; + +FMField EVstone_remove_split_target_req_flds[] = { + {"condition_var", "integer", sizeof(int), FMOffset(EVstone_remove_split_target_request*, condition_var)}, + {"stone", "integer", sizeof(EVstone), FMOffset(EVstone_remove_split_target_request*,stone)}, + {"target_stone", "integer", sizeof(EVstone), FMOffset(EVstone_remove_split_target_request*,target_stone)}, + {NULL, NULL, 0, 0} +}; + +FMStructDescRec EVstone_remove_split_target_req_formats[] = { + {"EV_EVstone_remove_split_target_request", EVstone_remove_split_target_req_flds, sizeof(EVstone_remove_split_target_request), NULL}, + {NULL, NULL, 0, NULL} +}; + +extern void +INT_REVstone_remove_split_target(CMConnection conn, EVstone stone, EVstone target_stone) +{ + int cond; + CMFormat f; + EVstone_remove_split_target_request request; + memset(&request, 0, sizeof(request)); + cond = INT_CMCondition_get(conn->cm, conn); + f = INT_CMlookup_format(conn->cm, EVstone_remove_split_target_req_formats); + request.stone = stone; + request.target_stone = target_stone; + request.condition_var = cond; + if (f == NULL) { + f = INT_CMregister_format(conn->cm, EVstone_remove_split_target_req_formats); + } + INT_CMCondition_set_client_data(conn->cm, cond, NULL); + INT_CMwrite(conn, f, &request); + INT_CMCondition_wait(conn->cm, cond); +} + +extern void +REVstone_remove_split_target(CMConnection conn, EVstone stone, EVstone target_stone) +{ + CManager_lock(conn->cm); + INT_REVstone_remove_split_target(conn, stone, target_stone); + CManager_unlock(conn->cm); + return; +} + +static void +REVstone_remove_split_target_handler(CManager cm, CMConnection conn, void *data,void *client_data,attr_list message_attrs) +{ + EV_void_response response; + EVstone_remove_split_target_request *request = (EVstone_remove_split_target_request *) data; + CMFormat f = CMlookup_format(conn->cm, EV_void_response_formats); + (void) message_attrs; + (void) client_data; + if (f == NULL) { + f = INT_CMregister_format(conn->cm, EV_void_response_formats); + } + EVstone_remove_split_target(cm, request->stone, request->target_stone); + response.condition_var = request->condition_var; + CMwrite(conn, f, &response); +} + +typedef struct _EVstone_set_output_request { + int condition_var; + EVstone stone; + int output_index; + EVstone target_stone; +} EVstone_set_output_request; + +typedef struct _EVstone_set_output_response { + int condition_var; + int ret; +} EVstone_set_output_response; + +FMField EVstone_set_output_req_flds[] = { + {"condition_var", "integer", sizeof(int), FMOffset(EVstone_set_output_request*, condition_var)}, + {"stone", "integer", sizeof(EVstone), FMOffset(EVstone_set_output_request*,stone)}, + {"output_index", "integer", sizeof(int), FMOffset(EVstone_set_output_request*,output_index)}, + {"target_stone", "integer", sizeof(EVstone), FMOffset(EVstone_set_output_request*,target_stone)}, + {NULL, NULL, 0, 0} +}; + +FMStructDescRec EVstone_set_output_req_formats[] = { + {"EV_EVstone_set_output_request", EVstone_set_output_req_flds, sizeof(EVstone_set_output_request), NULL}, + {NULL, NULL, 0, NULL} +}; + +extern int +INT_REVstone_set_output(CMConnection conn, EVstone stone, int output_index, EVstone target_stone) +{ + int cond; + CMFormat f; + EV_int_response response; + EVstone_set_output_request request; + memset(&request, 0, sizeof(request)); + cond = INT_CMCondition_get(conn->cm, conn); + f = INT_CMlookup_format(conn->cm, EVstone_set_output_req_formats); + request.stone = stone; + request.output_index = output_index; + request.target_stone = target_stone; + request.condition_var = cond; + if (f == NULL) { + f = INT_CMregister_format(conn->cm, EVstone_set_output_req_formats); + } + INT_CMCondition_set_client_data(conn->cm, cond, &response); + INT_CMwrite(conn, f, &request); + INT_CMCondition_wait(conn->cm, cond); + return response.ret; +} + +extern int +REVstone_set_output(CMConnection conn, EVstone stone, int output_index, EVstone target_stone) +{ + int ret; + CManager_lock(conn->cm); + ret = INT_REVstone_set_output(conn, stone, output_index, target_stone); + CManager_unlock(conn->cm); + return ret; +} + +static void +REVstone_set_output_handler(CManager cm, CMConnection conn, void *data,void *client_data,attr_list message_attrs) +{ + EV_int_response response; + EVstone_set_output_request *request = (EVstone_set_output_request *) data; + int ret; + CMFormat f = CMlookup_format(conn->cm, EV_int_response_formats); + (void) message_attrs; + (void) client_data; + if (f == NULL) { + f = INT_CMregister_format(conn->cm, EV_int_response_formats); + } + ret = EVstone_set_output(cm, request->stone, request->output_index, request->target_stone); + response.ret = ret;; + response.condition_var = request->condition_var; + CMwrite(conn, f, &response); +} + +typedef struct _EVtransfer_events_request { + int condition_var; + EVstone src_stone; + EVstone dest_stone; +} EVtransfer_events_request; + +typedef struct _EVtransfer_events_response { + int condition_var; + int ret; +} EVtransfer_events_response; + +FMField EVtransfer_events_req_flds[] = { + {"condition_var", "integer", sizeof(int), FMOffset(EVtransfer_events_request*, condition_var)}, + {"src_stone", "integer", sizeof(EVstone), FMOffset(EVtransfer_events_request*,src_stone)}, + {"dest_stone", "integer", sizeof(EVstone), FMOffset(EVtransfer_events_request*,dest_stone)}, + {NULL, NULL, 0, 0} +}; + +FMStructDescRec EVtransfer_events_req_formats[] = { + {"EV_EVtransfer_events_request", EVtransfer_events_req_flds, sizeof(EVtransfer_events_request), NULL}, + {NULL, NULL, 0, NULL} +}; + +extern int +INT_REVtransfer_events(CMConnection conn, EVstone src_stone, EVstone dest_stone) +{ + int cond; + CMFormat f; + EV_int_response response; + EVtransfer_events_request request; + memset(&request, 0, sizeof(request)); + cond = INT_CMCondition_get(conn->cm, conn); + f = INT_CMlookup_format(conn->cm, EVtransfer_events_req_formats); + request.src_stone = src_stone; + request.dest_stone = dest_stone; + request.condition_var = cond; + if (f == NULL) { + f = INT_CMregister_format(conn->cm, EVtransfer_events_req_formats); + } + INT_CMCondition_set_client_data(conn->cm, cond, &response); + INT_CMwrite(conn, f, &request); + INT_CMCondition_wait(conn->cm, cond); + return response.ret; +} + +extern int +REVtransfer_events(CMConnection conn, EVstone src_stone, EVstone dest_stone) +{ + int ret; + CManager_lock(conn->cm); + ret = INT_REVtransfer_events(conn, src_stone, dest_stone); + CManager_unlock(conn->cm); + return ret; +} + +static void +REVtransfer_events_handler(CManager cm, CMConnection conn, void *data,void *client_data,attr_list message_attrs) +{ + EV_int_response response; + EVtransfer_events_request *request = (EVtransfer_events_request *) data; + int ret; + CMFormat f = CMlookup_format(conn->cm, EV_int_response_formats); + (void) message_attrs; + (void) client_data; + if (f == NULL) { + f = INT_CMregister_format(conn->cm, EV_int_response_formats); + } + ret = EVtransfer_events(cm, request->src_stone, request->dest_stone); + response.ret = ret;; + response.condition_var = request->condition_var; + CMwrite(conn, f, &response); +} + +typedef struct _EVunfreeze_stone_request { + int condition_var; + EVstone stone_id; +} EVunfreeze_stone_request; + +typedef struct _EVunfreeze_stone_response { + int condition_var; + int ret; +} EVunfreeze_stone_response; + +FMField EVunfreeze_stone_req_flds[] = { + {"condition_var", "integer", sizeof(int), FMOffset(EVunfreeze_stone_request*, condition_var)}, + {"stone_id", "integer", sizeof(EVstone), FMOffset(EVunfreeze_stone_request*,stone_id)}, + {NULL, NULL, 0, 0} +}; + +FMStructDescRec EVunfreeze_stone_req_formats[] = { + {"EV_EVunfreeze_stone_request", EVunfreeze_stone_req_flds, sizeof(EVunfreeze_stone_request), NULL}, + {NULL, NULL, 0, NULL} +}; + +extern int +INT_REVunfreeze_stone(CMConnection conn, EVstone stone_id) +{ + int cond; + CMFormat f; + EV_int_response response; + EVunfreeze_stone_request request; + memset(&request, 0, sizeof(request)); + cond = INT_CMCondition_get(conn->cm, conn); + f = INT_CMlookup_format(conn->cm, EVunfreeze_stone_req_formats); + request.stone_id = stone_id; + request.condition_var = cond; + if (f == NULL) { + f = INT_CMregister_format(conn->cm, EVunfreeze_stone_req_formats); + } + INT_CMCondition_set_client_data(conn->cm, cond, &response); + INT_CMwrite(conn, f, &request); + INT_CMCondition_wait(conn->cm, cond); + return response.ret; +} + +extern int +REVunfreeze_stone(CMConnection conn, EVstone stone_id) +{ + int ret; + CManager_lock(conn->cm); + ret = INT_REVunfreeze_stone(conn, stone_id); + CManager_unlock(conn->cm); + return ret; +} + +static void +REVunfreeze_stone_handler(CManager cm, CMConnection conn, void *data,void *client_data,attr_list message_attrs) +{ + EV_int_response response; + EVunfreeze_stone_request *request = (EVunfreeze_stone_request *) data; + int ret; + CMFormat f = CMlookup_format(conn->cm, EV_int_response_formats); + (void) message_attrs; + (void) client_data; + if (f == NULL) { + f = INT_CMregister_format(conn->cm, EV_int_response_formats); + } + ret = EVunfreeze_stone(cm, request->stone_id); + response.ret = ret;; + response.condition_var = request->condition_var; + CMwrite(conn, f, &response); +} + +typedef struct _EVunstall_stone_request { + int condition_var; + EVstone stone_id; +} EVunstall_stone_request; + +typedef struct _EVunstall_stone_response { + int condition_var; +} EVunstall_stone_response; + +FMField EVunstall_stone_req_flds[] = { + {"condition_var", "integer", sizeof(int), FMOffset(EVunstall_stone_request*, condition_var)}, + {"stone_id", "integer", sizeof(EVstone), FMOffset(EVunstall_stone_request*,stone_id)}, + {NULL, NULL, 0, 0} +}; + +FMStructDescRec EVunstall_stone_req_formats[] = { + {"EV_EVunstall_stone_request", EVunstall_stone_req_flds, sizeof(EVunstall_stone_request), NULL}, + {NULL, NULL, 0, NULL} +}; + +extern void +INT_REVunstall_stone(CMConnection conn, EVstone stone_id) +{ + int cond; + CMFormat f; + EVunstall_stone_request request; + memset(&request, 0, sizeof(request)); + cond = INT_CMCondition_get(conn->cm, conn); + f = INT_CMlookup_format(conn->cm, EVunstall_stone_req_formats); + request.stone_id = stone_id; + request.condition_var = cond; + if (f == NULL) { + f = INT_CMregister_format(conn->cm, EVunstall_stone_req_formats); + } + INT_CMCondition_set_client_data(conn->cm, cond, NULL); + INT_CMwrite(conn, f, &request); + INT_CMCondition_wait(conn->cm, cond); +} + +extern void +REVunstall_stone(CMConnection conn, EVstone stone_id) +{ + CManager_lock(conn->cm); + INT_REVunstall_stone(conn, stone_id); + CManager_unlock(conn->cm); + return; +} + +static void +REVunstall_stone_handler(CManager cm, CMConnection conn, void *data,void *client_data,attr_list message_attrs) +{ + EV_void_response response; + EVunstall_stone_request *request = (EVunstall_stone_request *) data; + CMFormat f = CMlookup_format(conn->cm, EV_void_response_formats); + (void) message_attrs; + (void) client_data; + if (f == NULL) { + f = INT_CMregister_format(conn->cm, EV_void_response_formats); + } + EVunstall_stone(cm, request->stone_id); + response.condition_var = request->condition_var; + CMwrite(conn, f, &response); +} +static void +REV_response_handler(CManager cm, CMConnection conn, void *data,void *client_data,attr_list attrs) +{ + EV_void_response *response = (EV_void_response*) data; + void **response_ptr = CMCondition_get_client_data(cm, response->condition_var); + if (NULL != response_ptr) { + *response_ptr = data; + } + CMCondition_signal(cm, response->condition_var); +} + +static void +REV_int_response_handler(CManager cm, CMConnection conn, void *data,void *client_data,attr_list attrs) +{ + 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)); + } + CMCondition_signal(cm, response->condition_var); +} + +static void +REV_string_response_handler(CManager cm, CMConnection conn, void *data,void *client_data,attr_list attrs) +{ + 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); + } + CMCondition_signal(cm, response->condition_var); +} + +static void +REV_EVevent_list_response_handler(CManager cm, CMConnection conn, void *data,void *client_data,attr_list attrs) +{ + 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); + } + CMCondition_signal(cm, response->condition_var); +} + +extern void +REVPinit(CManager cm) +{ + CMFormat tmp_format; + + tmp_format = INT_CMregister_format(cm, EVaction_add_split_target_req_formats); + INT_CMregister_handler(tmp_format, REVaction_add_split_target_handler, cm->evp); + + tmp_format = INT_CMregister_format(cm, EVaction_remove_split_target_req_formats); + INT_CMregister_handler(tmp_format, REVaction_remove_split_target_handler, cm->evp); + + tmp_format = INT_CMregister_format(cm, EVaction_set_output_req_formats); + INT_CMregister_handler(tmp_format, REVaction_set_output_handler, cm->evp); + + tmp_format = INT_CMregister_format(cm, EValloc_stone_req_formats); + INT_CMregister_handler(tmp_format, REValloc_stone_handler, cm->evp); + + tmp_format = INT_CMregister_format(cm, EVassoc_bridge_action_req_formats); + INT_CMregister_handler(tmp_format, REVassoc_bridge_action_handler, cm->evp); + + tmp_format = INT_CMregister_format(cm, EVassoc_filter_action_req_formats); + INT_CMregister_handler(tmp_format, REVassoc_filter_action_handler, cm->evp); + + tmp_format = INT_CMregister_format(cm, EVassoc_immediate_action_req_formats); + INT_CMregister_handler(tmp_format, REVassoc_immediate_action_handler, cm->evp); + + tmp_format = INT_CMregister_format(cm, EVassoc_multi_action_req_formats); + INT_CMregister_handler(tmp_format, REVassoc_multi_action_handler, cm->evp); + + tmp_format = INT_CMregister_format(cm, EVassoc_split_action_req_formats); + INT_CMregister_handler(tmp_format, REVassoc_split_action_handler, cm->evp); + + tmp_format = INT_CMregister_format(cm, EVassoc_store_action_req_formats); + INT_CMregister_handler(tmp_format, REVassoc_store_action_handler, cm->evp); + + tmp_format = INT_CMregister_format(cm, EVassoc_terminal_action_req_formats); + INT_CMregister_handler(tmp_format, REVassoc_terminal_action_handler, cm->evp); + + tmp_format = INT_CMregister_format(cm, EVclear_stored_req_formats); + INT_CMregister_handler(tmp_format, REVclear_stored_handler, cm->evp); + + tmp_format = INT_CMregister_format(cm, EVcreate_auto_stone_req_formats); + INT_CMregister_handler(tmp_format, REVcreate_auto_stone_handler, cm->evp); + + tmp_format = INT_CMregister_format(cm, EVcreate_bridge_action_req_formats); + INT_CMregister_handler(tmp_format, REVcreate_bridge_action_handler, cm->evp); + + tmp_format = INT_CMregister_format(cm, EVcreate_immediate_action_req_formats); + INT_CMregister_handler(tmp_format, REVcreate_immediate_action_handler, cm->evp); + + tmp_format = INT_CMregister_format(cm, EVcreate_split_action_req_formats); + INT_CMregister_handler(tmp_format, REVcreate_split_action_handler, cm->evp); + + tmp_format = INT_CMregister_format(cm, EVcreate_stone_action_req_formats); + INT_CMregister_handler(tmp_format, REVcreate_stone_action_handler, cm->evp); + + tmp_format = INT_CMregister_format(cm, EVcreate_store_action_req_formats); + INT_CMregister_handler(tmp_format, REVcreate_store_action_handler, cm->evp); + + tmp_format = INT_CMregister_format(cm, EVcreate_terminal_action_req_formats); + INT_CMregister_handler(tmp_format, REVcreate_terminal_action_handler, cm->evp); + + tmp_format = INT_CMregister_format(cm, EVdestroy_stone_req_formats); + INT_CMregister_handler(tmp_format, REVdestroy_stone_handler, cm->evp); + + tmp_format = INT_CMregister_format(cm, EVdrain_stone_req_formats); + INT_CMregister_handler(tmp_format, REVdrain_stone_handler, cm->evp); + + tmp_format = INT_CMregister_format(cm, EVenable_auto_stone_req_formats); + INT_CMregister_handler(tmp_format, REVenable_auto_stone_handler, cm->evp); + + tmp_format = INT_CMregister_format(cm, EVextract_attr_list_req_formats); + INT_CMregister_handler(tmp_format, REVextract_attr_list_handler, cm->evp); + + tmp_format = INT_CMregister_format(cm, EVfree_stone_req_formats); + INT_CMregister_handler(tmp_format, REVfree_stone_handler, cm->evp); + + tmp_format = INT_CMregister_format(cm, EVfreeze_stone_req_formats); + INT_CMregister_handler(tmp_format, REVfreeze_stone_handler, cm->evp); + + tmp_format = INT_CMregister_format(cm, EVset_attr_list_req_formats); + INT_CMregister_handler(tmp_format, REVset_attr_list_handler, cm->evp); + + tmp_format = INT_CMregister_format(cm, EVstall_stone_req_formats); + INT_CMregister_handler(tmp_format, REVstall_stone_handler, cm->evp); + + tmp_format = INT_CMregister_format(cm, EVstone_add_split_target_req_formats); + INT_CMregister_handler(tmp_format, REVstone_add_split_target_handler, cm->evp); + + tmp_format = INT_CMregister_format(cm, EVstone_remove_split_target_req_formats); + INT_CMregister_handler(tmp_format, REVstone_remove_split_target_handler, cm->evp); + + tmp_format = INT_CMregister_format(cm, EVstone_set_output_req_formats); + INT_CMregister_handler(tmp_format, REVstone_set_output_handler, cm->evp); + + tmp_format = INT_CMregister_format(cm, EVtransfer_events_req_formats); + INT_CMregister_handler(tmp_format, REVtransfer_events_handler, cm->evp); + + tmp_format = INT_CMregister_format(cm, EVunfreeze_stone_req_formats); + INT_CMregister_handler(tmp_format, REVunfreeze_stone_handler, cm->evp); + + tmp_format = INT_CMregister_format(cm, EVunstall_stone_req_formats); + INT_CMregister_handler(tmp_format, REVunstall_stone_handler, cm->evp); + + tmp_format = INT_CMregister_format(cm, EV_int_response_formats); + INT_CMregister_handler(tmp_format, REV_int_response_handler, cm->evp); + + tmp_format = INT_CMregister_format(cm, EV_void_response_formats); + INT_CMregister_handler(tmp_format, REV_response_handler, cm->evp); + + tmp_format = INT_CMregister_format(cm, EV_string_response_formats); + INT_CMregister_handler(tmp_format, REV_string_response_handler, cm->evp); + + tmp_format = INT_CMregister_format(cm, EV_EVevent_list_response_formats); + INT_CMregister_handler(tmp_format, REV_EVevent_list_response_handler, cm->evp); +} diff --git a/pregen-source/revp_internal.h b/pregen-source/revp_internal.h new file mode 100644 index 0000000000..b8bace6a31 --- /dev/null +++ b/pregen-source/revp_internal.h @@ -0,0 +1,106 @@ +/* + * This file is automatically generated by gen_interface.pl from evpath.h. + * + * DO NOT EDIT + * + */ + + +extern int +INT_REVaction_add_split_target(CMConnection conn, EVstone stone, EVaction action, EVstone target_stone); + +extern void +INT_REVaction_remove_split_target(CMConnection conn, EVstone stone, EVaction action, EVstone target_stone); + +extern int +INT_REVaction_set_output(CMConnection conn, EVstone stone, EVaction action, int output_index, EVstone target_stone); + +extern EVstone +INT_REValloc_stone(CMConnection conn); + +extern EVaction +INT_REVassoc_bridge_action(CMConnection conn, EVstone stone, attr_list contact_list, EVstone remote_stone); + +extern EVaction +INT_REVassoc_filter_action(CMConnection conn, EVstone stone, FMStructDescList incoming_format_list, char *handler, EVstone out_stone); + +extern EVaction +INT_REVassoc_immediate_action(CMConnection conn, EVstone stone, char *action_spec); + +extern EVaction +INT_REVassoc_multi_action(CMConnection conn, EVstone stone, char *action_spec); + +extern EVaction +INT_REVassoc_split_action(CMConnection conn, EVstone stone, EVstone *target_list); + +extern EVaction +INT_REVassoc_store_action(CMConnection conn, EVstone stone_num, EVstone out_stone, int store_limit); + +extern EVaction +INT_REVassoc_terminal_action(CMConnection conn, EVstone stone, FMStructDescList format_list, char *handler); + +extern void +INT_REVclear_stored(CMConnection conn, EVstone stone_num, EVaction action_num); + +extern EVstone +INT_REVcreate_auto_stone(CMConnection conn, int period_sec, int period_usec, char *action_spec, EVstone out_stone); + +extern EVstone +INT_REVcreate_bridge_action(CMConnection conn, attr_list contact_list, EVstone remote_stone); + +extern EVstone +INT_REVcreate_immediate_action(CMConnection conn, char *action_spec, EVstone *target_list); + +extern EVstone +INT_REVcreate_split_action(CMConnection conn, EVstone *target_list); + +extern EVstone +INT_REVcreate_stone_action(CMConnection conn, char *action_spec); + +extern EVstone +INT_REVcreate_store_action(CMConnection conn, EVstone out_stone, int store_limit); + +extern EVstone +INT_REVcreate_terminal_action(CMConnection conn, FMStructDescList format_list, char *handler); + +extern int +INT_REVdestroy_stone(CMConnection conn, EVstone stone_id); + +extern int +INT_REVdrain_stone(CMConnection conn, EVstone stone_id); + +extern void +INT_REVenable_auto_stone(CMConnection conn, EVstone stone_num, int period_sec, int period_usec); + +extern attr_list +INT_REVextract_attr_list(CMConnection conn, EVstone stone_id); + +extern void +INT_REVfree_stone(CMConnection conn, EVstone stone); + +extern int +INT_REVfreeze_stone(CMConnection conn, EVstone stone_id); + +extern void +INT_REVset_attr_list(CMConnection conn, EVstone stone_id, attr_list list); + +extern void +INT_REVstall_stone(CMConnection conn, EVstone stone_id); + +extern void +INT_REVstone_add_split_target(CMConnection conn, EVstone stone, EVstone target_stone); + +extern void +INT_REVstone_remove_split_target(CMConnection conn, EVstone stone, EVstone target_stone); + +extern int +INT_REVstone_set_output(CMConnection conn, EVstone stone, int output_index, EVstone target_stone); + +extern int +INT_REVtransfer_events(CMConnection conn, EVstone src_stone, EVstone dest_stone); + +extern int +INT_REVunfreeze_stone(CMConnection conn, EVstone stone_id); + +extern void +INT_REVunstall_stone(CMConnection conn, EVstone stone_id); diff --git a/pregen-source/revpath.h b/pregen-source/revpath.h new file mode 100644 index 0000000000..8bc4aa865a --- /dev/null +++ b/pregen-source/revpath.h @@ -0,0 +1,113 @@ +/* + * This file is automatically generated by gen_interface.pl from evpath.h. + * + * DO NOT EDIT + * + */ + +#ifdef __cplusplus +extern "C" { +#endif + +extern int +REVaction_add_split_target(CMConnection conn, EVstone stone, EVaction action, EVstone target_stone); + +extern void +REVaction_remove_split_target(CMConnection conn, EVstone stone, EVaction action, EVstone target_stone); + +extern int +REVaction_set_output(CMConnection conn, EVstone stone, EVaction action, int output_index, EVstone target_stone); + +extern EVstone +REValloc_stone(CMConnection conn); + +extern EVaction +REVassoc_bridge_action(CMConnection conn, EVstone stone, attr_list contact_list, EVstone remote_stone); + +extern EVaction +REVassoc_filter_action(CMConnection conn, EVstone stone, FMStructDescList incoming_format_list, char *handler, EVstone out_stone); + +extern EVaction +REVassoc_immediate_action(CMConnection conn, EVstone stone, char *action_spec); + +extern EVaction +REVassoc_multi_action(CMConnection conn, EVstone stone, char *action_spec); + +extern EVaction +REVassoc_split_action(CMConnection conn, EVstone stone, EVstone *target_list); + +extern EVaction +REVassoc_store_action(CMConnection conn, EVstone stone_num, EVstone out_stone, int store_limit); + +extern EVaction +REVassoc_terminal_action(CMConnection conn, EVstone stone, FMStructDescList format_list, char *handler); + +extern void +REVclear_stored(CMConnection conn, EVstone stone_num, EVaction action_num); + +extern EVstone +REVcreate_auto_stone(CMConnection conn, int period_sec, int period_usec, char *action_spec, EVstone out_stone); + +extern EVstone +REVcreate_bridge_action(CMConnection conn, attr_list contact_list, EVstone remote_stone); + +extern EVstone +REVcreate_immediate_action(CMConnection conn, char *action_spec, EVstone *target_list); + +extern EVstone +REVcreate_split_action(CMConnection conn, EVstone *target_list); + +extern EVstone +REVcreate_stone_action(CMConnection conn, char *action_spec); + +extern EVstone +REVcreate_store_action(CMConnection conn, EVstone out_stone, int store_limit); + +extern EVstone +REVcreate_terminal_action(CMConnection conn, FMStructDescList format_list, char *handler); + +extern int +REVdestroy_stone(CMConnection conn, EVstone stone_id); + +extern int +REVdrain_stone(CMConnection conn, EVstone stone_id); + +extern void +REVenable_auto_stone(CMConnection conn, EVstone stone_num, int period_sec, int period_usec); + +extern attr_list +REVextract_attr_list(CMConnection conn, EVstone stone_id); + +extern void +REVfree_stone(CMConnection conn, EVstone stone); + +extern int +REVfreeze_stone(CMConnection conn, EVstone stone_id); + +extern void +REVset_attr_list(CMConnection conn, EVstone stone_id, attr_list list); + +extern void +REVstall_stone(CMConnection conn, EVstone stone_id); + +extern void +REVstone_add_split_target(CMConnection conn, EVstone stone, EVstone target_stone); + +extern void +REVstone_remove_split_target(CMConnection conn, EVstone stone, EVstone target_stone); + +extern int +REVstone_set_output(CMConnection conn, EVstone stone, int output_index, EVstone target_stone); + +extern int +REVtransfer_events(CMConnection conn, EVstone src_stone, EVstone dest_stone); + +extern int +REVunfreeze_stone(CMConnection conn, EVstone stone_id); + +extern void +REVunstall_stone(CMConnection conn, EVstone stone_id); + +#ifdef __cplusplus +} +#endif 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..8373149d01 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); } +#ifndef HAVE_UNISTD_H 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..b31925a519 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.3 -- Tue Aug 6 13:53:13 EDT 2024\n"; #if defined (__INTEL_COMPILER) // Allow extern declarations with no prior decl