From e4495df72733b3584f15c7085664853bdc233c43 Mon Sep 17 00:00:00 2001 From: Jonathan Hollocombe Date: Thu, 29 Jun 2023 15:06:57 +0100 Subject: [PATCH 01/39] Renaming idamFree to udaFree and fixing udaFreeAll to make it callable in plugins. --- source/client/accAPI.cpp | 2 +- source/client/udaClient.cpp | 97 ++++++++++--------- source/client/udaClient.h | 6 +- source/client/udaPutAPI.cpp | 4 +- source/plugins/template/templatePlugin.cpp | 37 ++++++- source/plugins/uda/uda_plugin.cpp | 1 + source/plugins/udaPlugin.cpp | 47 +++++++++ source/plugins/udaPlugin.h | 3 + source/plugins/viewport/viewport.cpp | 8 +- source/wrappers/c++/result.cpp | 2 +- source/wrappers/fortran/accAPI_F.c | 4 +- source/wrappers/idl/idam_dlm.c | 10 +- source/wrappers/java/idam_jni.c | 2 +- source/wrappers/java/jIdam/Idam.java | 4 +- source/wrappers/matlab/dm_example.c | 4 +- source/wrappers/matlab/getIdamData.c | 2 +- source/wrappers/matlab/getIdamDoubleData.c | 2 +- .../wrappers/python/pyuda/cpyuda/handle.pyx | 2 +- source/wrappers/python/pyuda/cpyuda/uda.pxd | 2 +- 19 files changed, 166 insertions(+), 73 deletions(-) diff --git a/source/client/accAPI.cpp b/source/client/accAPI.cpp index 1b995c8d..c950c19c 100755 --- a/source/client/accAPI.cpp +++ b/source/client/accAPI.cpp @@ -291,7 +291,7 @@ int acc_getIdamNewDataHandle(CLIENT_FLAGS* client_flags) if ((client_flags->flags & CLIENTFLAG_REUSELASTHANDLE || client_flags->flags & CLIENTFLAG_FREEREUSELASTHANDLE) && (newHandleIndex = getIdamThreadLastHandle()) >= 0) { if (client_flags->flags & CLIENTFLAG_FREEREUSELASTHANDLE) { - idamFree(newHandleIndex); + udaFree(newHandleIndex); } else { // Application has responsibility for freeing heap in the Data Block initDataBlock(&data_blocks[newHandleIndex]); diff --git a/source/client/udaClient.cpp b/source/client/udaClient.cpp index 5bda918b..3335ad98 100755 --- a/source/client/udaClient.cpp +++ b/source/client/udaClient.cpp @@ -47,10 +47,13 @@ int client_version = 9; // previous version // FATCLIENT objects shared with server code #ifndef FATCLIENT -USERDEFINEDTYPELIST* user_defined_type_list = nullptr; // List of all known User Defined Structure Types -LOGMALLOCLIST* log_malloc_list = nullptr; // List of all Heap Allocations for Data -unsigned int last_malloc_index = 0; // Malloc Log search index last value -unsigned int* last_malloc_index_value = &last_malloc_index;; // Preserve Malloc Log search index last value in GENERAL_STRUCT +USERDEFINEDTYPELIST* g_user_defined_type_list = nullptr; // List of all known User Defined Structure Types +LOGMALLOCLIST* g_log_malloc_list = nullptr; // List of all Heap Allocations for Data +unsigned int g_last_malloc_index = 0; // Malloc Log search index last value +unsigned int* g_last_malloc_index_value = &g_last_malloc_index;; // Preserve Malloc Log search index last value in GENERAL_STRUCT +XDR* g_client_input = nullptr; +XDR* g_client_output = nullptr; +LOGSTRUCTLIST* g_log_struct_list = nullptr; #endif // FATCLIENT //---------------------------------------------------------------------------------------------------------------------- @@ -61,8 +64,6 @@ SERVER_BLOCK server_block; time_t tv_server_start = 0; time_t tv_server_end = 0; -//LOGSTRUCTLIST log_struct_list; - char client_username[STRING_LENGTH] = "client"; int authentication_needed = 1; // Enable the mutual authentication conversation at startup @@ -71,12 +72,12 @@ int authentication_needed = 1; // Enable the mutual authentication conversation void setUserDefinedTypeList(USERDEFINEDTYPELIST* userdefinedtypelist_in) { - user_defined_type_list = userdefinedtypelist_in; + g_user_defined_type_list = userdefinedtypelist_in; } void setLogMallocList(LOGMALLOCLIST* logmalloclist_in) { - log_malloc_list = logmalloclist_in; + g_log_malloc_list = logmalloclist_in; } #else @@ -248,7 +249,7 @@ fetchHierarchicalData(XDR* client_input, DATA_BLOCK* data_block, LOGSTRUCTLIST* UDA_LOG(UDA_LOG_DEBUG, "Receiving Hierarchical Data Structure from Server\n"); int err = 0; - if ((err = protocol2(client_input, protocol_id, XDR_RECEIVE, nullptr, log_malloc_list, user_defined_type_list, + if ((err = protocol2(client_input, protocol_id, XDR_RECEIVE, nullptr, g_log_malloc_list, g_user_defined_type_list, data_block, protocol_version, log_struct_list, private_flags, malloc_source)) != 0) { addIdamError(UDA_CODE_ERROR_TYPE, __func__, err, "Client Side Protocol Error (Opaque Structure Type)"); return err; @@ -289,35 +290,35 @@ fetchMeta(XDR* client_input, DATA_SYSTEM* data_system, SYSTEM_CONFIG* system_con int err = 0; #ifndef FATCLIENT // <========================== Client Server Code Only - if ((err = protocol2(client_input, UDA_PROTOCOL_DATA_SYSTEM, XDR_RECEIVE, nullptr, log_malloc_list, user_defined_type_list, + if ((err = protocol2(client_input, UDA_PROTOCOL_DATA_SYSTEM, XDR_RECEIVE, nullptr, g_log_malloc_list, g_user_defined_type_list, data_system, protocol_version, log_struct_list, private_flags, malloc_source)) != 0) { addIdamError(UDA_CODE_ERROR_TYPE, __func__, err, "Protocol 4 Error (Data System)"); return err; } printDataSystem(*data_system); - if ((err = protocol2(client_input, UDA_PROTOCOL_SYSTEM_CONFIG, XDR_RECEIVE, nullptr, log_malloc_list, user_defined_type_list, + if ((err = protocol2(client_input, UDA_PROTOCOL_SYSTEM_CONFIG, XDR_RECEIVE, nullptr, g_log_malloc_list, g_user_defined_type_list, system_config, protocol_version, log_struct_list, private_flags, malloc_source)) != 0) { addIdamError(UDA_CODE_ERROR_TYPE, __func__, err, "Protocol 5 Error (System Config)"); return err; } printSystemConfig(*system_config); - if ((err = protocol2(client_input, UDA_PROTOCOL_DATA_SOURCE, XDR_RECEIVE, nullptr, log_malloc_list, user_defined_type_list, + if ((err = protocol2(client_input, UDA_PROTOCOL_DATA_SOURCE, XDR_RECEIVE, nullptr, g_log_malloc_list, g_user_defined_type_list, data_source, protocol_version, log_struct_list, private_flags, malloc_source)) != 0) { addIdamError(UDA_CODE_ERROR_TYPE, __func__, err, "Protocol 6 Error (Data Source)"); return err; } printDataSource(*data_source); - if ((err = protocol2(client_input, UDA_PROTOCOL_SIGNAL, XDR_RECEIVE, nullptr, log_malloc_list, user_defined_type_list, + if ((err = protocol2(client_input, UDA_PROTOCOL_SIGNAL, XDR_RECEIVE, nullptr, g_log_malloc_list, g_user_defined_type_list, signal_rec, protocol_version, log_struct_list, private_flags, malloc_source)) != 0) { addIdamError(UDA_CODE_ERROR_TYPE, __func__, err, "Protocol 7 Error (Signal)"); return err; } printSignal(*signal_rec); - if ((err = protocol2(client_input, UDA_PROTOCOL_SIGNAL_DESC, XDR_RECEIVE, nullptr, log_malloc_list, user_defined_type_list, + if ((err = protocol2(client_input, UDA_PROTOCOL_SIGNAL_DESC, XDR_RECEIVE, nullptr, g_log_malloc_list, g_user_defined_type_list, signal_desc, protocol_version, log_struct_list, private_flags, malloc_source)) != 0) { addIdamError(UDA_CODE_ERROR_TYPE, __func__, err, "Protocol 8 Error (Signal Desc)"); return err; @@ -364,6 +365,11 @@ int idamClient(REQUEST_BLOCK* request_block, int* indices) static XDR* client_output = nullptr; static int malloc_source = UDA_MALLOC_SOURCE_NONE; +#ifndef FATCLIENT + g_client_input = client_input; // needed for udaFreeAll + g_client_output = client_output; // needed for udaFreeAll +#endif + LOGSTRUCTLIST log_struct_list; initLogStructList(&log_struct_list); @@ -436,14 +442,14 @@ int idamClient(REQUEST_BLOCK* request_block, int* indices) for (int i = 0; i < request_block->num_requests; ++i) { auto request = &request_block->requests[i]; DATA_BLOCK* data_block = &cached_data_block_list.data[i]; - int rc = check_file_cache(request, &data_block, log_malloc_list, user_defined_type_list, + int rc = check_file_cache(request, &data_block, g_log_malloc_list, g_user_defined_type_list, &log_struct_list, client_flags, *private_flags, malloc_source); if (rc >= 0) { request_block->requests[i].request = REQUEST_CACHED; ++num_cached; continue; } - rc = check_mem_cache(cache, request, &data_block, log_malloc_list, user_defined_type_list, + rc = check_mem_cache(cache, request, &data_block, g_log_malloc_list, g_user_defined_type_list, &log_struct_list, client_flags, *private_flags, malloc_source); if (rc >= 0) { request_block->requests[i].request = REQUEST_CACHED; @@ -662,7 +668,7 @@ int idamClient(REQUEST_BLOCK* request_block, int* indices) int protocol_id = UDA_PROTOCOL_CLIENT_BLOCK; // Send Client Block (proxy for authenticationStep = 6) - if ((err = protocol2(client_output, protocol_id, XDR_SEND, nullptr, log_malloc_list, user_defined_type_list, + if ((err = protocol2(client_output, protocol_id, XDR_SEND, nullptr, g_log_malloc_list, g_user_defined_type_list, &client_block, protocol_version, &log_struct_list, *private_flags, malloc_source)) != 0) { addIdamError(UDA_CODE_ERROR_TYPE, __func__, err, "Protocol 10 Error (Client Block)"); @@ -689,7 +695,7 @@ int idamClient(REQUEST_BLOCK* request_block, int* indices) protocol_id = UDA_PROTOCOL_SERVER_BLOCK; // Receive Server Block: Server Aknowledgement (proxy for authenticationStep = 8) - if ((err = protocol2(client_input, protocol_id, XDR_RECEIVE, nullptr, log_malloc_list, user_defined_type_list, + if ((err = protocol2(client_input, protocol_id, XDR_RECEIVE, nullptr, g_log_malloc_list, g_user_defined_type_list, &server_block, protocol_version, &log_struct_list, *private_flags, malloc_source)) != 0) { addIdamError(UDA_CODE_ERROR_TYPE, __func__, err, "Protocol 11 Error (Server Block #1)"); @@ -781,7 +787,7 @@ int idamClient(REQUEST_BLOCK* request_block, int* indices) int protocol_id = UDA_PROTOCOL_CLIENT_BLOCK; // Send Client Block - if ((err = protocol2(client_output, protocol_id, XDR_SEND, nullptr, log_malloc_list, user_defined_type_list, + if ((err = protocol2(client_output, protocol_id, XDR_SEND, nullptr, g_log_malloc_list, g_user_defined_type_list, &client_block, protocol_version, &log_struct_list, *private_flags, malloc_source)) != 0) { addIdamError(UDA_CODE_ERROR_TYPE, __func__, err, "Protocol 10 Error (Client Block)"); @@ -794,7 +800,7 @@ int idamClient(REQUEST_BLOCK* request_block, int* indices) protocol_id = UDA_PROTOCOL_REQUEST_BLOCK; // This is what the Client Wants - if ((err = protocol2(client_output, protocol_id, XDR_SEND, nullptr, log_malloc_list, user_defined_type_list, + if ((err = protocol2(client_output, protocol_id, XDR_SEND, nullptr, g_log_malloc_list, g_user_defined_type_list, request_block, protocol_version, &log_struct_list, *private_flags, malloc_source)) != 0) { addIdamError(UDA_CODE_ERROR_TYPE, __func__, err, "Protocol 1 Error (Request Block)"); @@ -810,7 +816,7 @@ int idamClient(REQUEST_BLOCK* request_block, int* indices) if (request->put) { protocol_id = UDA_PROTOCOL_PUTDATA_BLOCK_LIST; - if ((err = protocol2(client_output, protocol_id, XDR_SEND, nullptr, log_malloc_list, user_defined_type_list, + if ((err = protocol2(client_output, protocol_id, XDR_SEND, nullptr, g_log_malloc_list, g_user_defined_type_list, &(request->putDataBlockList), protocol_version, &log_struct_list, *private_flags, malloc_source)) != 0) { addIdamError(UDA_CODE_ERROR_TYPE, __func__, err, @@ -845,8 +851,8 @@ int idamClient(REQUEST_BLOCK* request_block, int* indices) UDA_LOG(UDA_LOG_DEBUG, "Waiting for Server Status Block\n"); - if ((err = protocol2(client_input, UDA_PROTOCOL_SERVER_BLOCK, XDR_RECEIVE, nullptr, log_malloc_list, - user_defined_type_list, &server_block, protocol_version, &log_struct_list, + if ((err = protocol2(client_input, UDA_PROTOCOL_SERVER_BLOCK, XDR_RECEIVE, nullptr, g_log_malloc_list, + g_user_defined_type_list, &server_block, protocol_version, &log_struct_list, *private_flags, malloc_source)) != 0) { UDA_LOG(UDA_LOG_DEBUG, "Protocol 11 Error (Server Block #2) = %d\n", err); addIdamError(UDA_CODE_ERROR_TYPE, __func__, err, " Protocol 11 Error (Server Block #2)"); @@ -897,8 +903,8 @@ int idamClient(REQUEST_BLOCK* request_block, int* indices) DATA_BLOCK_LIST recv_data_block_list; - if ((err = protocol2(client_input, UDA_PROTOCOL_DATA_BLOCK_LIST, XDR_RECEIVE, nullptr, log_malloc_list, - user_defined_type_list, &recv_data_block_list, protocol_version, + if ((err = protocol2(client_input, UDA_PROTOCOL_DATA_BLOCK_LIST, XDR_RECEIVE, nullptr, g_log_malloc_list, + g_user_defined_type_list, &recv_data_block_list, protocol_version, &log_struct_list, *private_flags, malloc_source)) != 0) { UDA_LOG(UDA_LOG_DEBUG, "Protocol 2 Error (Failure Receiving Data Block)\n"); @@ -955,7 +961,7 @@ int idamClient(REQUEST_BLOCK* request_block, int* indices) //------------------------------------------------------------------------------ // Cache the data if the server has passed permission and the application (client) has enabled caching if (client_flags->flags & CLIENTFLAG_FILECACHE) { - udaFileCacheWrite(data_block, request_block, log_malloc_list, user_defined_type_list, protocol_version, + udaFileCacheWrite(data_block, request_block, g_log_malloc_list, g_user_defined_type_list, protocol_version, &log_struct_list, *private_flags, malloc_source); } @@ -966,7 +972,7 @@ int idamClient(REQUEST_BLOCK* request_block, int* indices) # else if (cache != nullptr && client_flags->flags & CLIENTFLAG_CACHE) { # endif - cache_write(cache, &request_block->requests[i], data_block, log_malloc_list, user_defined_type_list, + cache_write(cache, &request_block->requests[i], data_block, g_log_malloc_list, g_user_defined_type_list, *environment, protocol_version, client_flags->flags, &log_struct_list, *private_flags, malloc_source); } @@ -1199,7 +1205,7 @@ int idamClient(REQUEST_BLOCK* request_block, int* indices) #endif // <========================== End of FatClient Code Only -void idamFree(int handle) +void udaFree(int handle) { // Free Heap Memory (Not the Data Blocks themselves: These will be re-used.) @@ -1232,10 +1238,10 @@ void idamFree(int handle) if (general_block->userdefinedtypelist != nullptr) { #ifndef FATCLIENT - if (user_defined_type_list == general_block->userdefinedtypelist) { // Is this the current setting? - freeUserDefinedTypeList(user_defined_type_list); - free(user_defined_type_list); - user_defined_type_list = nullptr; + if (g_user_defined_type_list == general_block->userdefinedtypelist) { // Is this the current setting? + freeUserDefinedTypeList(g_user_defined_type_list); + free(g_user_defined_type_list); + g_user_defined_type_list = nullptr; } else { freeUserDefinedTypeList(general_block->userdefinedtypelist); free(general_block->userdefinedtypelist); @@ -1248,10 +1254,10 @@ void idamFree(int handle) if (general_block->logmalloclist != nullptr) { #ifndef FATCLIENT - if (log_malloc_list == general_block->logmalloclist) { - freeMallocLogList(log_malloc_list); - free(log_malloc_list); - log_malloc_list = nullptr; + if (g_log_malloc_list == general_block->logmalloclist) { + freeMallocLogList(g_log_malloc_list); + free(g_log_malloc_list); + g_log_malloc_list = nullptr; } else { freeMallocLogList(general_block->logmalloclist); free(general_block->logmalloclist); @@ -1398,8 +1404,7 @@ void idamFree(int handle) data_block->handle = -1; // Flag this as ready for re-use } -void udaFreeAll(XDR* client_input, XDR* client_output, LOGSTRUCTLIST* log_struct_list, unsigned int private_flags, - int malloc_source) +void udaFreeAll() { // Free All Heap Memory #ifndef FATCLIENT @@ -1424,8 +1429,8 @@ void udaFreeAll(XDR* client_input, XDR* client_output, LOGSTRUCTLIST* log_struct acc_freeDataBlocks(); #ifndef FATCLIENT - user_defined_type_list = nullptr; // malloc'd within protocolXML - log_malloc_list = nullptr; + g_user_defined_type_list = nullptr; // malloc'd within protocolXML + g_log_malloc_list = nullptr; #endif closeUdaError(); @@ -1441,17 +1446,21 @@ void udaFreeAll(XDR* client_input, XDR* client_output, LOGSTRUCTLIST* log_struct client_block.timeout = 0; // Surrogate CLOSEDOWN instruction client_block.clientFlags = client_block.clientFlags | CLIENTFLAG_CLOSEDOWN; // Direct CLOSEDOWN instruction protocol_id = UDA_PROTOCOL_CLIENT_BLOCK; - protocol2(client_output, protocol_id, XDR_SEND, nullptr, log_malloc_list, user_defined_type_list, &client_block, - protocol_version, log_struct_list, private_flags, malloc_source); - xdrrec_endofrecord(client_output, 1); + protocol2(g_client_output, protocol_id, XDR_SEND, nullptr, g_log_malloc_list, g_user_defined_type_list, &client_block, + protocol_version, g_log_struct_list, *udaPrivateFlags(), UDA_MALLOC_SOURCE_NONE); + xdrrec_endofrecord(g_client_output, 1); } #endif // <========================== End of Client Server Code Only bool reopen_logs = false; +#ifndef FATCLIENT // Close the Socket, XDR Streams and All Files - closedown(ClosedownType::CLOSE_ALL, nullptr, client_input, client_output, &reopen_logs); + closedown(ClosedownType::CLOSE_ALL, nullptr, g_client_input, g_client_output, &reopen_logs); +#else + closedown(ClosedownType::CLOSE_ALL, nullptr, nullptr, nullptr, &reopen_logs); +#endif } SERVER_BLOCK getIdamThreadServerBlock() diff --git a/source/client/udaClient.h b/source/client/udaClient.h index 80996a48..6ac0d939 100755 --- a/source/client/udaClient.h +++ b/source/client/udaClient.h @@ -61,11 +61,9 @@ LIBRARY_API int idamClient(REQUEST_BLOCK* request_block, int* indices); LIBRARY_API void updateClientBlock(CLIENT_BLOCK* str, const CLIENT_FLAGS* client_flags, unsigned int private_flags); -LIBRARY_API void idamFree(int handle); +LIBRARY_API void udaFree(int handle); -LIBRARY_API void -udaFreeAll(XDR* client_input, XDR* client_output, LOGSTRUCTLIST* log_struct_list, unsigned int private_flags, - int malloc_source); +LIBRARY_API void udaFreeAll(); LIBRARY_API CLIENT_FLAGS* udaClientFlags(); LIBRARY_API unsigned int* udaPrivateFlags(); diff --git a/source/client/udaPutAPI.cpp b/source/client/udaPutAPI.cpp index 8d2a08f8..8c8663cb 100755 --- a/source/client/udaPutAPI.cpp +++ b/source/client/udaPutAPI.cpp @@ -61,7 +61,7 @@ int idamPutListAPI(const char* putInstruction, PUTDATA_BLOCK_LIST* inPutDataBloc /* logmalloclist = nullptr; */ /* userdefinedtypelist = nullptr; */ /* int h = idamGetAPI("help::ping()", ""); */ -/* idamFree(h); */ +/* udaFree(h); */ /* idamGetAPICalledOnce = 1; */ /* lastMallocIndex = 0; */ /* logmalloclist = oldlogmalloclist; */ @@ -142,7 +142,7 @@ int idamPutAPI(const char* putInstruction, PUTDATA_BLOCK* inPutData) /* logmalloclist = nullptr; */ /* userdefinedtypelist = nullptr; */ /* int h = idamGetAPI("help::ping()", ""); */ -/* idamFree(h); */ +/* udaFree(h); */ /* idamGetAPICalledOnce = 1; */ /* lastMallocIndex = 0; */ /* logmalloclist = oldlogmalloclist; */ diff --git a/source/plugins/template/templatePlugin.cpp b/source/plugins/template/templatePlugin.cpp index 9147439c..7346cda2 100755 --- a/source/plugins/template/templatePlugin.cpp +++ b/source/plugins/template/templatePlugin.cpp @@ -182,13 +182,48 @@ int TemplatePlugin::max_interface_version(IDAM_PLUGIN_INTERFACE* idam_plugin_int return setReturnDataIntScalar(idam_plugin_interface->data_block, THISPLUGIN_MAX_INTERFACE_VERSION, "Maximum Interface Version"); } +namespace { + +template +std::string to_string(T* array, size_t size) { + std::string result; + const char* delim = ""; + for (size_t i = 0; i < size; ++i) { + result += delim + std::to_string(array[i]); + delim = ", "; + } + return result; +} + +} // anon namespace + //---------------------------------------------------------------------------------------- // Add functionality here .... int TemplatePlugin::function(IDAM_PLUGIN_INTERFACE* idam_plugin_interface) { DATA_BLOCK* data_block = idam_plugin_interface->data_block; - setReturnDataString(data_block, "Hello World!", "templatePlugin: 'Hello World' single string returned"); + NameValueList& nvl = idam_plugin_interface->request_data->nameValueList; + + const char* required = nullptr; + FIND_REQUIRED_STRING_VALUE(nvl, required); + + double* array = nullptr; + size_t narray = -1; + FIND_REQUIRED_DOUBLE_ARRAY(nvl, array); + + int optional = -1; + bool optional_found = FIND_INT_VALUE(nvl, optional); + + std::string result = std::string("Passed args: required=") + required + + ", array=[" + to_string(array, narray) + "]"; + if (optional_found) { + result += ", optional=" + std::to_string(optional) + ")"; + } else { + result += ", optional=)"; + } + + setReturnDataString(data_block, result.c_str(), "result of TemplatePlugin::function"); strcpy(data_block->data_label, ""); strcpy(data_block->data_units, ""); diff --git a/source/plugins/uda/uda_plugin.cpp b/source/plugins/uda/uda_plugin.cpp index e9eeff90..30b4ec7c 100755 --- a/source/plugins/uda/uda_plugin.cpp +++ b/source/plugins/uda/uda_plugin.cpp @@ -58,6 +58,7 @@ extern int UDAPlugin(IDAM_PLUGIN_INTERFACE* idam_plugin_interface) // Resetting all UDA client properties resetIdamProperties(udaClientFlags()); + udaFreeAll(); putIdamServerHost(oldServerHost); // Original Host putIdamServerPort(oldPort); // Original Port diff --git a/source/plugins/udaPlugin.cpp b/source/plugins/udaPlugin.cpp index 51ad9a77..7d8f091e 100644 --- a/source/plugins/udaPlugin.cpp +++ b/source/plugins/udaPlugin.cpp @@ -1,10 +1,57 @@ #include "udaPlugin.h" +#include "server/initPluginList.h" +#include "server/serverPlugin.h" +#include "structures/struct.h" +#include #include #include #include #include +IDAM_PLUGIN_INTERFACE* udaCreatePluginInterface(const char* request) +{ + auto plugin_interface = (IDAM_PLUGIN_INTERFACE*)calloc(1, sizeof(IDAM_PLUGIN_INTERFACE)); + auto environment = getServerEnvironment(); + auto plugin_list = (PLUGINLIST*)calloc(1, sizeof(PLUGINLIST)); + + initPluginList(plugin_list, environment); + + auto request_data = (REQUEST_DATA*)calloc(1, sizeof(REQUEST_DATA)); + makeRequestData(request_data, *plugin_list, environment); + + auto user_defined_type_list = (USERDEFINEDTYPELIST*)calloc(1, sizeof(USERDEFINEDTYPELIST)); + auto log_malloc_list = (LOGMALLOCLIST*)calloc(1, sizeof(LOGMALLOCLIST)); + + plugin_interface->request_data = request_data; + plugin_interface->pluginList = plugin_list; + plugin_interface->environment = environment; + plugin_interface->userdefinedtypelist = user_defined_type_list; + plugin_interface->logmalloclist = log_malloc_list; + + plugin_interface->interfaceVersion = 1; + plugin_interface->pluginVersion = 0; + plugin_interface->housekeeping = 0; + plugin_interface->changePlugin = 0; + plugin_interface->error_stack.nerrors = 0; + plugin_interface->error_stack.idamerror = nullptr; + + return plugin_interface; +} + +void udaFreePluginInterface(IDAM_PLUGIN_INTERFACE* plugin_interface) +{ + free(plugin_interface->request_data); + freeUserDefinedTypeList(plugin_interface->userdefinedtypelist); + free(plugin_interface->userdefinedtypelist); + freeMallocLogList(plugin_interface->logmalloclist); + free(plugin_interface->logmalloclist); + freePluginList((PLUGINLIST*)plugin_interface->pluginList); + free((PLUGINLIST*)plugin_interface->pluginList); + free((ENVIRONMENT*)plugin_interface->environment); + free(plugin_interface); +} + int initPlugin(const IDAM_PLUGIN_INTERFACE* plugin_interface) { udaSetLogLevel((LOG_LEVEL)plugin_interface->environment->loglevel); diff --git a/source/plugins/udaPlugin.h b/source/plugins/udaPlugin.h index 908b35e1..a0749a10 100755 --- a/source/plugins/udaPlugin.h +++ b/source/plugins/udaPlugin.h @@ -33,6 +33,9 @@ typedef void (* ADDIDAMERRORFUNP)(UDA_ERROR_STACK*, int, char*, int, char*); / LIBRARY_API int callPlugin(const PLUGINLIST* pluginlist, const char* request, const IDAM_PLUGIN_INTERFACE* old_plugin_interface); +IDAM_PLUGIN_INTERFACE* udaCreatePluginInterface(const char* request); +void udaFreePluginInterface(IDAM_PLUGIN_INTERFACE* plugin_interface); + LIBRARY_API int findPluginIdByRequest(int request, const PLUGINLIST* plugin_list); LIBRARY_API int findPluginIdByFormat(const char* format, const PLUGINLIST* plugin_list); LIBRARY_API int findPluginIdByDevice(const char* device, const PLUGINLIST* plugin_list); diff --git a/source/plugins/viewport/viewport.cpp b/source/plugins/viewport/viewport.cpp index 0f803565..b52302a5 100755 --- a/source/plugins/viewport/viewport.cpp +++ b/source/plugins/viewport/viewport.cpp @@ -174,7 +174,7 @@ extern int viewport(IDAM_PLUGIN_INTERFACE* idam_plugin_interface) // Free Heap & reset counters for (int i = 0; i < handleCount; i++) { - idamFree(handles[i]); + udaFree(handles[i]); handles[i] = -1; } @@ -189,7 +189,7 @@ extern int viewport(IDAM_PLUGIN_INTERFACE* idam_plugin_interface) // Free Cached data if requested or filled for (int i = 0; i < handleCount; i++) { - idamFree(handles[i]); + udaFree(handles[i]); handles[i] = -1; } @@ -201,7 +201,7 @@ extern int viewport(IDAM_PLUGIN_INTERFACE* idam_plugin_interface) if (handleCount == MAXHANDLES) { // Free some Cached data if cache is full for (int i = 0; i < FREEHANDLEBLOCK; i++) { - idamFree(handles[i]); + udaFree(handles[i]); handles[i] = handles[i + FREEHANDLEBLOCK]; strcpy(signals[i], signals[i + FREEHANDLEBLOCK]); strcpy(sources[i], sources[i + FREEHANDLEBLOCK]); @@ -220,7 +220,7 @@ extern int viewport(IDAM_PLUGIN_INTERFACE* idam_plugin_interface) // Free Heap Cache & reset counters for (int i = 0; i < handleCount; i++) { - idamFree(handles[i]); + udaFree(handles[i]); handles[i] = -1; } diff --git a/source/wrappers/c++/result.cpp b/source/wrappers/c++/result.cpp index edb7e6d7..90686e6e 100755 --- a/source/wrappers/c++/result.cpp +++ b/source/wrappers/c++/result.cpp @@ -91,7 +91,7 @@ uda::Result::Result(int handle) uda::Result::~Result() { - idamFree(handle_); + udaFree(handle_); } const std::vector uda::Result::shape() const diff --git a/source/wrappers/fortran/accAPI_F.c b/source/wrappers/fortran/accAPI_F.c index 204b01bc..e3d81470 100755 --- a/source/wrappers/fortran/accAPI_F.c +++ b/source/wrappers/fortran/accAPI_F.c @@ -1173,12 +1173,12 @@ extern void getidamdimdatachecksum_(int* handle, int* ndim, int* sum) extern void idamfree_(int* hd) { int handle = *hd; - idamFree(handle); + udaFree(handle); } extern void idamfreeall_() { - idamFreeAll(); + udaFreeAll(); } extern void getidamenv_(char* str, int* rc, char* env, int lstr, int lenv) diff --git a/source/wrappers/idl/idam_dlm.c b/source/wrappers/idl/idam_dlm.c index 7619b66a..f19e5be3 100755 --- a/source/wrappers/idl/idam_dlm.c +++ b/source/wrappers/idl/idam_dlm.c @@ -1269,7 +1269,7 @@ IDL_VPTR IDL_CDECL idamputapi(int argc, IDL_VPTR argv[], char* argk) fprintf(stdout, "Freeing Heap for Handle %d\n", handle); } - idamFree(handle); + udaFree(handle); } //-------------------------------------------------------------------------- @@ -1695,7 +1695,7 @@ IDL_VPTR IDL_CDECL callidam2(int argc, IDL_VPTR argv[], char* argk) fprintf(stdout, "Freeing Heap for Handle %d\n", handle); } - idamFree(handle); + udaFree(handle); } //-------------------------------------------------------------------------- @@ -2618,7 +2618,7 @@ callidam(int argc, IDL_VPTR argv[], char* argk) fprintf(stdout, "Freeing Heap for Handle %d\n", handle); } - idamFree(handle); + udaFree(handle); } //-------------------------------------------------------------------------- @@ -4448,7 +4448,7 @@ freeidam(int argc, IDL_VPTR argv[], char* argk) //-------------------------------------------------------------------------- // Free IDAM Heap - idamFree(handle); + udaFree(handle); return (IDL_GettmpLong(0)); } @@ -4462,7 +4462,7 @@ freeidamall(int argc, IDL_VPTR argv[], char* argk) // Free All IDAM Heap + Close IDAM Server - idamFreeAll(); + udaFreeAll(); return (IDL_GettmpLong(0)); } diff --git a/source/wrappers/java/idam_jni.c b/source/wrappers/java/idam_jni.c index 66fa062c..b81d7096 100755 --- a/source/wrappers/java/idam_jni.c +++ b/source/wrappers/java/idam_jni.c @@ -754,6 +754,6 @@ JNIEXPORT jobjectArray JNICALL Java_jIdam_Idam_getVariablesRegex(JNIEnv* env, jo } END: - //RC idamFree(handle); + //RC udaFree(handle); return ret; } diff --git a/source/wrappers/java/jIdam/Idam.java b/source/wrappers/java/jIdam/Idam.java index 08a96541..dee74a69 100755 --- a/source/wrappers/java/jIdam/Idam.java +++ b/source/wrappers/java/jIdam/Idam.java @@ -20,8 +20,8 @@ public class Idam { // Idam API public static native int idamGetAPI(String signal, String source); - public static native void idamFree(int handle); - public static native void idamFreeAll(); + public static native void udaFree(int handle); + public static native void udaFreeAll(); // Multithread Idam API public static native int idamGetAPIMT(String signal, String source); diff --git a/source/wrappers/matlab/dm_example.c b/source/wrappers/matlab/dm_example.c index fba61ccf..fbd63126 100755 --- a/source/wrappers/matlab/dm_example.c +++ b/source/wrappers/matlab/dm_example.c @@ -121,9 +121,9 @@ int main() } } - idamFree(handle); // Free Heap for this signal + udaFree(handle); // Free Heap for this signal } - idamFreeAll(); // Free all Heap and signal the server to close + udaFreeAll(); // Free all Heap and signal the server to close return 0; } diff --git a/source/wrappers/matlab/getIdamData.c b/source/wrappers/matlab/getIdamData.c index 923b7d72..672aa79e 100755 --- a/source/wrappers/matlab/getIdamData.c +++ b/source/wrappers/matlab/getIdamData.c @@ -159,5 +159,5 @@ void mexFunction(int nlhs, mxArray * plhs[], int nrhs, const mxArray * prhs[]) } } - idamFree(handle); /* Free Heap for this signal */ + udaFree(handle); /* Free Heap for this signal */ } diff --git a/source/wrappers/matlab/getIdamDoubleData.c b/source/wrappers/matlab/getIdamDoubleData.c index 98658088..b01b6904 100755 --- a/source/wrappers/matlab/getIdamDoubleData.c +++ b/source/wrappers/matlab/getIdamDoubleData.c @@ -133,5 +133,5 @@ void mexFunction(int nlhs, mxArray * plhs[], int nrhs, const mxArray * prhs[]) } } - idamFree(handle); /* Free Heap for this signal */ + udaFree(handle); /* Free Heap for this signal */ } diff --git a/source/wrappers/python/pyuda/cpyuda/handle.pyx b/source/wrappers/python/pyuda/cpyuda/handle.pyx index 13c616f8..7cc35279 100644 --- a/source/wrappers/python/pyuda/cpyuda/handle.pyx +++ b/source/wrappers/python/pyuda/cpyuda/handle.pyx @@ -15,4 +15,4 @@ cdef class Handle(int): return self._handle def __dealloc__(self): - uda.idamFree(self._handle) + uda.udaFree(self._handle) diff --git a/source/wrappers/python/pyuda/cpyuda/uda.pxd b/source/wrappers/python/pyuda/cpyuda/uda.pxd index 57346ac5..aa32e499 100644 --- a/source/wrappers/python/pyuda/cpyuda/uda.pxd +++ b/source/wrappers/python/pyuda/cpyuda/uda.pxd @@ -5,7 +5,7 @@ cdef extern from "client/udaClient.h": int getIdamServerPort(); const char* getUdaBuildVersion(); const char* getUdaBuildDate(); - void idamFree(int handle); + void udaFree(int handle); CLIENT_FLAGS* udaClientFlags(); ctypedef struct CLIENT_FLAGS From 81dbcbee455302c23fbd7d10518927c476e2c895 Mon Sep 17 00:00:00 2001 From: Jonathan Hollocombe Date: Thu, 29 Jun 2023 15:08:21 +0100 Subject: [PATCH 02/39] Adding docs for creating a plugin. --- docs/creating_plugins.md | 124 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 123 insertions(+), 1 deletion(-) diff --git a/docs/creating_plugins.md b/docs/creating_plugins.md index 5092a9c1..bc56a98c 100644 --- a/docs/creating_plugins.md +++ b/docs/creating_plugins.md @@ -3,4 +3,126 @@ layout: default title: Creating a UDA plugin --- -TODO: Instructions for creating a new UDA plugin \ No newline at end of file +## UDA plugin + +A UDA plugin is shared library that is loaded dynamically by the +UDA server to enable extra functionality. The plugin makes available +a number of functions which can be called by the UDA client by specifying +the plugin name and function along with any number of arguments. + +For example, if we have a plugin which is called `TEST` we might have +functions: +- `TEST::help()` +- `TEST::readData(filename=foo)` +- `TEST::process(signal=foo,operation=bar,flag)` + +These functions read the arguments, do some processing, and return a +UDA `DataBlock` containing the data to be passed to the client. + +## Structure of a plugin + +The internals of a plugin is up to the plugin author. It can written in any +language that can be compiled to a shared library (.so on Linux, .dylib on MacOS, +.dll on Windows) but must provide a C style entry function which is +called by the UDA server. + +The entry function must look like: + +`int entryFunction(IDAM_PLUGIN_INTERFACE*)` + +Then function can have any name — the name is specified in the plugin configuration +file, see below. The `IDAM_PLUGIN_INTERFACE` is a structure defined in `uda/plugins.h` +and provides a mechanism for the plugin to interact with the UDA server — reading the +function arguments, returning the resultant data, etc. The returned `int` value specifies +the return state of the plugin call — zero for success or non-zero for an error state +(the actual error is returned via the `IDAM_PLUGIN_INTERFACE`). + +## Accessing function name and arguments + +The function being called is provided in the `IDAM_PLUGIN_INTERFACE` structure passed into +entry function as a C-string (`const char*`) via: + +`plugin_interface->request->function` + +The arguments that where passed to the plugin function is passed a list of name-value pairs +via: + +`plugin_interface->request->nameValueList` + +You can the provided helper functions to find the argument in the list and return the value: + +`bool findValue(NAMEVALUELIST* nvl, TYPE* value, const char* name)` + +where `` is the name of type being expected, i.e. `Int` or `Double`, `name` is the name of the argument +being read and `value` is where the found value is stored. If the argument is not found the function will return +`false`, otherwise it will return `true` and populate `data` with the found value. + +Help macros are also available when the name of the variable being read into is the same as the +name of the argument being read, i.e. to read a function argument called `arg1` we can used: + +```c +int arg1; +bool found = FIND_INT_VALUE(nvl, arg1); +``` + +If the function argument is required you can use another helper macro which will set an error message +and return from the function with a non-zero value, if the argument is not found: + +```c +int arg1;˚ +FIND_REQUIRED_INT_VALUE(nvl, arg1); +``` + +## Returning data from a plugin + +To return + +## Plugin configuration file + +The UDA server has a plugin configuration file that specifies how to load and use +the plugins available to the server. The plugin configuration file is a comman separated +text file with each line defined as: + +`NAME, TYPE, ENTRY_FUNC, LIBRARY, *, 1, 1, 1, DESC` + +Where: + +- `NAME`: the name of the plugin — this is the name by which the client can call the call the plugin. +- `TYPE`: the type of the plugin — should be `function` for the plugins defined here. +- `ENTRY_FUNC`: the name of the plugin entry function. +- `LIBRARY`: the file name of the compile shared library, including extension. +- `DESC`: a short description of the plugin which is used by UDA when listing the plugins available. + +Note: + +The other elements (`*, 1, 1, 1`) are not applicable to the `function` type plugins are should always be set +to these values. + +For example: + +`HELP, function, helpPlugin, libhelp_plugin.dylib, *, 1, 1, 1, Service Discovery: list the details on all registered services, HELP::services()` + +## Copying the template plugin + +The easies way to create a new plugin is to copy the `templatePlugin` from the UDA repository. +Copy the template plugin directory `source/plugin/template` and rename as required. The directory contains +the following files: + +- `CMakeLists.txt`: the CMake configuration file specifying how to build the plugin +- `templatePlugin.h`: the plugin header file +- `templatePlugin.cpp`: the plugin source file + +Now update the plugin: + +1. Rename the `templatePlugin.*` files to something that makes sense for your plugin and update +the `CMakeLists.txt` file as appropriate. +2. Change the entry function name in the source and header files from `templatePlugin(...)` to +something that corresponds to your plugin, and update `CMakeLists.txt` accordingly. +3. Implement the functionality required in the plugin. + +The template plugin is written in C++ and uses a TemplatePlugin object to handle any of the function +requests. The plugin object is static as data can be cached between calls to avoid having to repeat work, +for example holding onto file handles to avoid re-opening files. + +You can use the structure as provided or implement the functionality however you desire as long as each call +to the entry function handles the function requested and returns an error code accordingly. \ No newline at end of file From 825029322b545a37154877e2a28f1c18eac697fa Mon Sep 17 00:00:00 2001 From: Jonathan Hollocombe Date: Mon, 3 Jul 2023 23:54:14 +0100 Subject: [PATCH 03/39] Adding docker files for CentOS 8 and Ubuntu and fixing build on Ubuntu 22.10 --- docker/client.centos.8 | 67 ++++++++++++ docker/client.ubuntu.22.10 | 43 ++++++++ source/clientserver/protocolXML2Put.cpp | 4 +- source/structures/accessors.cpp | 28 ++--- source/structures/struct.cpp | 114 ++++++++++----------- source/structures/struct.h | 2 +- source/structures/xdrUserDefinedData.cpp | 4 +- source/wrappers/c++/scalar.hpp | 16 +-- source/wrappers/c++/vector.hpp | 14 +-- source/wrappers/matlab/dm_example.c | 53 +++++----- source/wrappers/matlab/getData.m | 2 - source/wrappers/matlab/getIdamData.c | 36 ++----- source/wrappers/matlab/getIdamDoubleData.c | 29 ++---- source/wrappers/python/CMakeLists.txt | 2 +- source/wrappers/python/setup.py.in | 4 +- 15 files changed, 250 insertions(+), 168 deletions(-) create mode 100644 docker/client.centos.8 create mode 100644 docker/client.ubuntu.22.10 diff --git a/docker/client.centos.8 b/docker/client.centos.8 new file mode 100644 index 00000000..63cd7eab --- /dev/null +++ b/docker/client.centos.8 @@ -0,0 +1,67 @@ +FROM centos:8 + +SHELL ["/bin/bash", "-c"] + +RUN sed -i 's/$releasever/$releasever-stream/g' /etc/yum.repos.d/CentOS-* +RUN yum update -y --allowerasing && \ + yum group install -y 'Development Tools' && \ + yum install -y \ + git \ + wget \ + boost-devel \ + openssl-devel \ + cmake \ + libxml2-devel \ + libtirpc-devel \ + python39-devel \ + python39-pip + +# Building libfmt from source +RUN cd /tmp && \ + wget https://github.com/fmtlib/fmt/archive/refs/tags/10.0.0.tar.gz && \ + tar xzf 10.0.0.tar.gz && \ + cd fmt-10.0.0 && \ + cmake -Bbuild -H. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local -DBUILD_SHARED_LIBS=ON && \ + cmake --build build -j && \ + cmake --install build + +# Building spdlog from source +RUN cd /tmp && \ + wget https://github.com/gabime/spdlog/archive/refs/tags/v1.11.0.tar.gz && \ + tar xzf v1.11.0.tar.gz && \ + cd spdlog-1.11.0 && \ + cmake -Bbuild -H. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local -DBUILD_SHARED_LIBS=ON && \ + cmake --build build -j && \ + cmake --install build + +RUN cd /tmp && \ + wget https://github.com/capnproto/capnproto/archive/refs/tags/v0.10.4.tar.gz && \ + tar xzf v0.10.4.tar.gz && \ + cd capnproto-0.10.4 && \ + cmake -Bbuild -H. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local -DBUILD_SHARED_LIBS=ON && \ + cmake --build build -j && \ + cmake --install build + +COPY . /uda + +RUN cd /uda && \ + cmake -B build \ + -DBUILD_SHARED_LIBS=ON \ + -DCMAKE_BUILD_TYPE=Release \ + -DSSLAUTHENTICATION=ON \ + -DCLIENT_ONLY=ON \ + -DENABLE_CAPNP=ON + +# LD_LIBRARY_PATH needed by capnp scheam generator binary +RUN cd /uda && LD_LIBRARY_PATH=/usr/local/lib64 cmake --build build --config Release + +RUN cd /uda && cmake --install build --config Release + +RUN cp -r /usr/local/python_installer ./python_installer && \ + export LD_LIBRARY_PATH=/usr/local/lib64 && \ + python3 -m venv ./venv && \ + source ./venv/bin/activate && \ + pip3 install Cython numpy && \ + pip3 install ./python_installer && \ + python3 -c 'import pyuda; print(pyuda.__version__)' + diff --git a/docker/client.ubuntu.22.10 b/docker/client.ubuntu.22.10 new file mode 100644 index 00000000..9081be9c --- /dev/null +++ b/docker/client.ubuntu.22.10 @@ -0,0 +1,43 @@ +FROM ubuntu:22.10 + +SHELL ["/bin/bash", "-c"] + +RUN apt-get update && apt-get install -y \ + git \ + libboost-dev \ + libboost-program-options-dev \ + libssl-dev \ + cmake \ + build-essential \ + pkg-config \ + libxml2-dev \ + libspdlog-dev \ + ninja-build \ + capnproto \ + libcapnp-dev \ + python3-dev \ + python3-pip \ + python3-venv + +COPY .. /uda + +RUN cd /uda && \ + cmake -G Ninja -B build \ + -DBUILD_SHARED_LIBS=ON \ + -DCMAKE_BUILD_TYPE=Release \ + -DSSLAUTHENTICATION=ON \ + -DCLIENT_ONLY=ON \ + -DENABLE_CAPNP=ON + +RUN cd /uda && cmake --build build --config Release + +RUN cd /uda && cmake --install build --config Release + +RUN apt-get install -y python3-dev python3-pip python3-venv + +RUN cp -r /usr/local/python_installer ./python_installer && \ + python3 -m venv ./venv && \ + source ./venv/bin/activate && \ + pip3 install Cython numpy && \ + pip3 install ./python_installer && \ + python3 -c 'import pyuda; print(pyuda.__version__)' diff --git a/source/clientserver/protocolXML2Put.cpp b/source/clientserver/protocolXML2Put.cpp index 2a00d310..4c82129b 100755 --- a/source/clientserver/protocolXML2Put.cpp +++ b/source/clientserver/protocolXML2Put.cpp @@ -1361,11 +1361,11 @@ int xdrUserDefinedDataPut(XDR* xdrs, LOGMALLOCLIST* logmalloclist, USERDEFINEDTY addMalloc(logmalloclist, (void*)newNTree->children, loopcount, sizeof(NTREE*), "NTREE *"); } else { // Multiple branches (user types) originating in the same node - NTREE** old = newNTree->children; + auto old = (VOIDTYPE)newNTree->children; newNTree->children = (NTREE**)realloc((void*)old, (newNTree->branches + loopcount) * sizeof(NTREE*)); // Individual node addresses remain valid - changeMalloc(logmalloclist, (void*)old, (void*)newNTree->children, + changeMalloc(logmalloclist, old, (void*)newNTree->children, newNTree->branches + loopcount, sizeof(NTREE*), "NTREE *"); } } diff --git a/source/structures/accessors.cpp b/source/structures/accessors.cpp index 30a7b743..9fa7f15a 100755 --- a/source/structures/accessors.cpp +++ b/source/structures/accessors.cpp @@ -132,15 +132,13 @@ findNTreeStructureComponent2(LOGMALLOCLIST* logmalloclist, NTREE* ntree, const c if ((strchr(target, '.') != nullptr) || strchr(target, '/') != nullptr) { int ntargets; - char** targetlist = nullptr; - NTREE* child = ntree; - - targetlist = parseTarget(target, &ntargets); // Deconstruct the Name and search for each hierarchy group + char** targetlist = parseTarget(target, &ntargets); // Deconstruct the Name and search for each hierarchy group *lastname = targetlist[ntargets - 1]; // Preserve the last element name // Search recursively for the first name + NTREE* child = ntree; if ((child = findNTreeStructureComponent1(child, targetlist[0])) == nullptr) { // Not found return nullptr; @@ -164,22 +162,29 @@ findNTreeStructureComponent2(LOGMALLOCLIST* logmalloclist, NTREE* ntree, const c } addMalloc(logmalloclist, (void*)targetlist[ntargets - 1], (int)strlen(targetlist[ntargets - 1]) + 1, sizeof(char), "char"); - for (int i = 0; i < ntargets - 1; i++) free(targetlist[i]); // Free all others + + const char* last_target = targetlist[ntargets - 1]; + + for (int i = 0; i < ntargets - 1; i++) { + free(targetlist[i]); // Free all others + } free(targetlist); // Free the list // Search the user defined type definition for the last name - return if an atomic type for (int i = 0; i < child->userdefinedtype->fieldcount; i++) { - if (STR_EQUALS(child->userdefinedtype->compoundfield[i].name, targetlist[ntargets - 1]) && + if (STR_EQUALS(child->userdefinedtype->compoundfield[i].name, last_target) && child->userdefinedtype->compoundfield[i].atomictype != UDA_TYPE_UNKNOWN) { - return (child); + return child; } // Atomic type found } // Search child nodes for structured types for (int j = 0; j < child->branches; j++) { - if (STR_EQUALS(child->children[j]->name, targetlist[ntargets - 1])) return child->children[j]; + if (STR_EQUALS(child->children[j]->name, last_target)) { + return child->children[j]; + } } return nullptr; // Not Found @@ -195,7 +200,6 @@ findNTreeStructureComponent2(LOGMALLOCLIST* logmalloclist, NTREE* ntree, const c } return nullptr; // Not found - } /** Find (search type B) and return a Pointer to the named Data Tree Node with a data structure of the same name. @@ -566,7 +570,7 @@ int idam_regulariseVlenStructures(LOGMALLOCLIST* logmalloclist, NTREE* tree, USE void* newnew = nullptr; if (tree->userdefinedtype->idamclass == UDA_TYPE_VLEN && STR_EQUALS(tree->userdefinedtype->name, target)) { - VLENTYPE* vlen = (VLENTYPE*)tree->data; + auto vlen = (VLENTYPE*)tree->data; // VLEN stuctures have only two fields: len and data // Need the size of the data component @@ -576,7 +580,7 @@ int idam_regulariseVlenStructures(LOGMALLOCLIST* logmalloclist, NTREE* tree, USE // VLEN Memory is contiguous so re-allocate: regularise by expanding to a consistent array size (No longer a VLEN!) - void* old = vlen->data; + auto old = (VOIDTYPE)vlen->data; USERDEFINEDTYPE* child = findUserDefinedType(userdefinedtypelist, tree->userdefinedtype->compoundfield[1].type, 0); vlen->data = realloc(vlen->data, count * child->size); // Expand Heap to regularise newnew = vlen->data; @@ -605,7 +609,7 @@ int idam_regulariseVlenStructures(LOGMALLOCLIST* logmalloclist, NTREE* tree, USE if (resetBranches > 0) { tree->branches = count; // Only update once all True children have been regularised - void* old = (void*)tree->children; + auto old = (VOIDTYPE)tree->children; tree->children = (NTREE**)realloc((void*)tree->children, count * sizeof(void*)); unsigned int ui; diff --git a/source/structures/struct.cpp b/source/structures/struct.cpp index cfed54f3..a34e77f8 100755 --- a/source/structures/struct.cpp +++ b/source/structures/struct.cpp @@ -131,7 +131,7 @@ void printSarray(SARRAY str) */ void addNTreeList(LOGMALLOCLIST* logmalloclist, NTREE* node, NTREELIST* ntree_list) { - NTREE* old = ntree_list->forrest; + VOIDTYPE old = (VOIDTYPE)ntree_list->forrest; ntree_list->forrest = (NTREE*)realloc((void*)ntree_list->forrest, (++ntree_list->listCount) * sizeof(NTREE*)); changeMalloc(logmalloclist, old, (void*)ntree_list->forrest, ntree_list->listCount, sizeof(NTREE*), "NTREE *"); ntree_list->forrest[ntree_list->listCount] = *node; @@ -725,18 +725,16 @@ addMalloc2(LOGMALLOCLIST* logmalloclist, void* heap, int count, size_t size, con * @param type The name of the type allocated. * @return void. */ -void changeMalloc(LOGMALLOCLIST* logmalloclist, void* old, void* anew, int count, size_t size, const char* type) +void changeMalloc(LOGMALLOCLIST* logmalloclist, VOIDTYPE old, void* anew, int count, size_t size, const char* type) { // Change a List Entry - - VOIDTYPE target, candidate; // int ok on 32 bit architecture - if (old == nullptr) { + if (old == 0) { addMalloc(logmalloclist, anew, count, size, type); return; } - target = (VOIDTYPE)((VOIDTYPE*)old); + auto target = (VOIDTYPE)((VOIDTYPE*)old); for (int i = 0; i < logmalloclist->listcount; i++) { - candidate = (VOIDTYPE)((VOIDTYPE*)logmalloclist->logmalloc[i].heap); + auto candidate = (VOIDTYPE)((VOIDTYPE*)logmalloclist->logmalloc[i].heap); if (target == candidate) { logmalloclist->logmalloc[i].heap = anew; logmalloclist->logmalloc[i].freed = 0; @@ -3927,29 +3925,31 @@ int getNTreeStructureCount(NTREE* ntree) */ char** getNTreeStructureNames(LOGMALLOCLIST* logmalloclist, NTREE* ntree) { - int count = 1, childcount; - char** names, ** childnames; - void* old; - if (ntree == nullptr) { ntree = udaGetFullNTree(); } - names = (char**)malloc(sizeof(char*)); + + auto names = (char**)malloc(sizeof(char*)); addMalloc(logmalloclist, (void*)names, 1, sizeof(char*), "char *"); names[0] = ntree->name; - if (ntree->branches == 0) return names; + + if (ntree->branches == 0) { + return names; + } + + int count = 1; for (int i = 0; i < ntree->branches; i++) { if (i == 0 || strcmp(ntree->children[i]->userdefinedtype->name, ntree->children[i - 1]->userdefinedtype->name) != 0) { - childcount = getNTreeStructureCount(ntree->children[i]); - old = (void*)names; + int childcount = getNTreeStructureCount(ntree->children[i]); + VOIDTYPE old = (VOIDTYPE)names; names = (char**)realloc((void*)names, (count + childcount) * sizeof(char*)); changeMalloc(logmalloclist, old, (void*)names, (count + childcount), sizeof(char*), "char *"); - childnames = getNTreeStructureNames(logmalloclist, ntree->children[i]); + char** childnames = getNTreeStructureNames(logmalloclist, ntree->children[i]); for (int j = 0; j < childcount; j++) { names[count + j] = childnames[j]; } - count = count + childcount; + count += childcount; } } return names; @@ -3962,25 +3962,24 @@ char** getNTreeStructureNames(LOGMALLOCLIST* logmalloclist, NTREE* ntree) */ char** getNTreeStructureTypes(LOGMALLOCLIST* logmalloclist, NTREE* ntree) { - int count = 1, childcount; - char** names, ** childnames; - void* old; - if (ntree == nullptr) { ntree = udaGetFullNTree(); } - names = (char**)malloc(sizeof(char*)); + + auto names = (char**)malloc(sizeof(char*)); addMalloc(logmalloclist, (void*)names, 1, sizeof(char*), "char *"); names[0] = ntree->userdefinedtype->name; if (ntree->branches == 0) return names; + + int count = 1; for (int i = 0; i < ntree->branches; i++) { if (i == 0 || strcmp(ntree->children[i]->userdefinedtype->name, ntree->children[i - 1]->userdefinedtype->name) != 0) { - childcount = getNTreeStructureCount(ntree->children[i]); - old = (void*)names; + int childcount = getNTreeStructureCount(ntree->children[i]); + VOIDTYPE old = (VOIDTYPE)names; names = (char**)realloc((void*)names, (count + childcount) * sizeof(char*)); changeMalloc(logmalloclist, old, (void*)names, (count + childcount), sizeof(char*), "char *"); - childnames = getNTreeStructureTypes(logmalloclist, ntree->children[i]); + char** childnames = getNTreeStructureTypes(logmalloclist, ntree->children[i]); for (int j = 0; j < childcount; j++) { names[count + j] = childnames[j]; } @@ -4047,30 +4046,29 @@ int getNTreeStructureComponentCount(NTREE* ntree) */ char** getNTreeStructureComponentNames(LOGMALLOCLIST* logmalloclist, NTREE* ntree) { - int count, childcount; - char** names, ** childnames; - void* old; - if (ntree == nullptr) { ntree = udaGetFullNTree(); } - count = ntree->userdefinedtype->fieldcount; + + int count = ntree->userdefinedtype->fieldcount; if (count == 0) { return nullptr; } - names = getNodeStructureComponentNames(ntree); + char** names = getNodeStructureComponentNames(ntree); for (int i = 0; i < ntree->branches; i++) { if (i == 0 || strcmp(ntree->children[i]->userdefinedtype->name, ntree->children[i - 1]->userdefinedtype->name) != 0) { - childcount = getNTreeStructureComponentCount(ntree->children[i]); - old = (void*)names; + int childcount = getNTreeStructureComponentCount(ntree->children[i]); + auto old = (VOIDTYPE)names; names = (char**)realloc((void*)names, (count + childcount) * sizeof(char*)); changeMalloc(logmalloclist, old, (void*)names, (count + childcount), sizeof(char*), "char *"); - childnames = getNTreeStructureComponentNames(logmalloclist, ntree->children[i]); - for (int j = 0; j < childcount; j++) names[count + j] = childnames[j]; - count = count + childcount; + char** childnames = getNTreeStructureComponentNames(logmalloclist, ntree->children[i]); + for (int j = 0; j < childcount; j++) { + names[count + j] = childnames[j]; + } + count += childcount; } } return names; @@ -4083,29 +4081,29 @@ char** getNTreeStructureComponentNames(LOGMALLOCLIST* logmalloclist, NTREE* ntre */ char** getNTreeStructureComponentTypes(LOGMALLOCLIST* logmalloclist, NTREE* ntree) { - int count, childcount; - char** names, ** childnames; - void* old; - if (ntree == nullptr) { ntree = udaGetFullNTree(); } - count = ntree->userdefinedtype->fieldcount; + + int count = ntree->userdefinedtype->fieldcount; if (count == 0) { return nullptr; } - names = getNodeStructureComponentTypes(ntree); + + char** names = getNodeStructureComponentTypes(ntree); for (int i = 0; i < ntree->branches; i++) { if (i == 0 || strcmp(ntree->children[i]->userdefinedtype->name, ntree->children[i - 1]->userdefinedtype->name) != 0) { - childcount = getNTreeStructureComponentCount(ntree->children[i]); - old = (void*)names; + int childcount = getNTreeStructureComponentCount(ntree->children[i]); + auto old = (VOIDTYPE)names; names = (char**)realloc((void*)names, (count + childcount) * sizeof(char*)); changeMalloc(logmalloclist, old, (void*)names, (count + childcount), sizeof(char*), "char *"); - childnames = getNTreeStructureComponentTypes(logmalloclist, ntree->children[i]); - for (int j = 0; j < childcount; j++) names[count + j] = childnames[j]; - count = count + childcount; + char** childnames = getNTreeStructureComponentTypes(logmalloclist, ntree->children[i]); + for (int j = 0; j < childcount; j++) { + names[count + j] = childnames[j]; + } + count += childcount; } } return names; @@ -4118,29 +4116,29 @@ char** getNTreeStructureComponentTypes(LOGMALLOCLIST* logmalloclist, NTREE* ntre */ char** getNTreeStructureComponentDescriptions(LOGMALLOCLIST* logmalloclist, NTREE* ntree) { - int count, childcount; - char** names, ** childnames; - void* old; - if (ntree == nullptr) { ntree = udaGetFullNTree(); } - count = ntree->userdefinedtype->fieldcount; + + int count = ntree->userdefinedtype->fieldcount; if (count == 0) { return nullptr; } - names = getNodeStructureComponentDescriptions(ntree); + + char** names = getNodeStructureComponentDescriptions(ntree); for (int i = 0; i < ntree->branches; i++) { if (i == 0 || strcmp(ntree->children[i]->userdefinedtype->name, ntree->children[i - 1]->userdefinedtype->name) != 0) { - childcount = getNTreeStructureComponentCount(ntree->children[i]); - old = (void*)names; + int childcount = getNTreeStructureComponentCount(ntree->children[i]); + auto old = (VOIDTYPE)names; names = (char**)realloc((void*)names, (count + childcount) * sizeof(char*)); changeMalloc(logmalloclist, old, (void*)names, (count + childcount), sizeof(char*), "char *"); - childnames = getNTreeStructureComponentDescriptions(logmalloclist, ntree->children[i]); - for (int j = 0; j < childcount; j++) names[count + j] = childnames[j]; - count = count + childcount; + char** childnames = getNTreeStructureComponentDescriptions(logmalloclist, ntree->children[i]); + for (int j = 0; j < childcount; j++) { + names[count + j] = childnames[j]; + } + count += childcount; } } return names; diff --git a/source/structures/struct.h b/source/structures/struct.h index 18991c68..a009e961 100755 --- a/source/structures/struct.h +++ b/source/structures/struct.h @@ -267,7 +267,7 @@ addMalloc2(LOGMALLOCLIST* logmalloclist, void* heap, int count, size_t size, con * @param type The name of the type allocated. * @return void. */ -void changeMalloc(LOGMALLOCLIST* logmalloclist, void* old, void* anew, int count, size_t size, const char* type); +void changeMalloc(LOGMALLOCLIST* logmalloclist, VOIDTYPE old, void* anew, int count, size_t size, const char* type); /** Change the logged memory location to a new location (necessary with realloc). * diff --git a/source/structures/xdrUserDefinedData.cpp b/source/structures/xdrUserDefinedData.cpp index a3daf20a..c19a5ed7 100755 --- a/source/structures/xdrUserDefinedData.cpp +++ b/source/structures/xdrUserDefinedData.cpp @@ -1412,11 +1412,11 @@ int xdrUserDefinedData(XDR* xdrs, LOGMALLOCLIST* logmalloclist, USERDEFINEDTYPEL loopcount * sizeof(NTREE*)); // Allocate the node array addMalloc(logmalloclist, (void*)newNTree->children, loopcount, sizeof(NTREE*), "NTREE *"); } else { // Multiple branches (user types) originating in the same node - NTREE** old = newNTree->children; + auto old = (VOIDTYPE)newNTree->children; newNTree->children = (NTREE**)realloc((void*)old, (newNTree->branches + loopcount) * sizeof(NTREE*)); // Individual node addresses remain valid - changeMalloc(logmalloclist, (void*)old, (void*)newNTree->children, + changeMalloc(logmalloclist, old, (void*)newNTree->children, newNTree->branches + loopcount, sizeof(NTREE*), "NTREE *"); } } diff --git a/source/wrappers/c++/scalar.hpp b/source/wrappers/c++/scalar.hpp index 91671aa4..bf04ff4a 100755 --- a/source/wrappers/c++/scalar.hpp +++ b/source/wrappers/c++/scalar.hpp @@ -27,18 +27,18 @@ class LIBRARY_API Scalar : public Data , type_(&typeid(T)) , data_size_(sizeof(T)) { - auto copy = new T; - *copy = value; - raw_data_ = std::shared_ptr(reinterpret_cast(copy)); + auto copy = new unsigned char[sizeof(T)]; + memcpy(copy, &value, sizeof(T)); + raw_data_ = std::shared_ptr(copy); } Scalar(const Scalar& other) = default; Scalar& operator=(const Scalar& other) = default; - size_t size() const override + [[nodiscard]] size_t size() const override { return 0; } - const std::type_info& type() const override + [[nodiscard]] const std::type_info& type() const override { return *type_; } template @@ -47,12 +47,12 @@ class LIBRARY_API Scalar : public Data static Scalar Null; - const unsigned char* byte_data() const override + [[nodiscard]] const unsigned char* byte_data() const override { return raw_data_.get(); } - size_t byte_length() const override + [[nodiscard]] size_t byte_length() const override { return data_size_; } @@ -68,7 +68,7 @@ class LIBRARY_API Scalar : public Data boost::any value_; const std::type_info* type_; - std::shared_ptr raw_data_; + std::shared_ptr raw_data_; size_t data_size_; }; diff --git a/source/wrappers/c++/vector.hpp b/source/wrappers/c++/vector.hpp index 5d8aa573..e82528a8 100755 --- a/source/wrappers/c++/vector.hpp +++ b/source/wrappers/c++/vector.hpp @@ -28,15 +28,15 @@ class LIBRARY_API Vector : public Data { , type_(&typeid(T)) , data_size_(size * sizeof(T)) { - auto copy = new T[size]; + auto copy = new unsigned char[size * sizeof(T)]; memcpy(copy, array, size * sizeof(T)); - raw_data_ = std::shared_ptr(reinterpret_cast(copy)); + raw_data_ = std::shared_ptr(copy); } Vector(const Vector& other) = default; Vector& operator=(const Vector& other) = default; - const std::type_info& type() const override + [[nodiscard]] const std::type_info& type() const override { return *type_; } template @@ -51,17 +51,17 @@ class LIBRARY_API Vector : public Data { T at(size_t idx) const { return boost::any_cast(vec_[idx]); } - size_t size() const override + [[nodiscard]] size_t size() const override { return vec_.size(); } static Vector Null; - const unsigned char* byte_data() const override + [[nodiscard]] const unsigned char* byte_data() const override { return raw_data_.get(); } - size_t byte_length() const override + [[nodiscard]] size_t byte_length() const override { return data_size_; } @@ -78,7 +78,7 @@ class LIBRARY_API Vector : public Data { private: std::vector vec_; const std::type_info* type_; - std::shared_ptr raw_data_; + std::shared_ptr raw_data_; size_t data_size_; template diff --git a/source/wrappers/matlab/dm_example.c b/source/wrappers/matlab/dm_example.c index fbd63126..e5ad1367 100755 --- a/source/wrappers/matlab/dm_example.c +++ b/source/wrappers/matlab/dm_example.c @@ -6,10 +6,9 @@ int main() { - int handle, nmax, ndata, rank, i, irank; - float * fvec = NULL; - double * dvec = NULL; + float* fvec = NULL; + double* dvec = NULL; int type; @@ -47,23 +46,23 @@ int main() type = getIdamDataType(handle); switch (type) { - case (UDA_TYPE_FLOAT): - fvec = (float *) getIdamData(handle); // pointer to the Data + case (UDA_TYPE_FLOAT): + fvec = (float*)getIdamData(handle); // pointer to the Data - for (int i = 0; i < nmax; i++) { - fprintf(stdout, "%d %f\n", i, fvec[i]); // print some data - } + for (int i = 0; i < nmax; i++) { + fprintf(stdout, "%d %f\n", i, fvec[i]); // print some data + } - break; + break; - case (UDA_TYPE_DOUBLE): - dvec = (double *) getIdamData(handle); + case (UDA_TYPE_DOUBLE): + dvec = (double*)getIdamData(handle); - for (int i = 0; i < nmax; i++) { - fprintf(stdout, "%d %f\n", i, dvec[i]); - } + for (int i = 0; i < nmax; i++) { + fprintf(stdout, "%d %f\n", i, dvec[i]); + } - break; + break; } rank = getIdamRank(handle); @@ -99,23 +98,23 @@ int main() type = getIdamDimType(handle, irank); switch (type) { - case (UDA_TYPE_FLOAT): - fvec = (float *) getIdamDimData(handle, irank); // pointer to the Dimension?s Data + case (UDA_TYPE_FLOAT): + fvec = (float*)getIdamDimData(handle, irank); // pointer to the Dimension?s Data - for (int i = 0; i < nmax; i++) { - fprintf(stdout, "%d %f\n", i, fvec[i]); // print some data - } + for (int i = 0; i < nmax; i++) { + fprintf(stdout, "%d %f\n", i, fvec[i]); // print some data + } - break; + break; - case (UDA_TYPE_DOUBLE): - dvec = (double *) getIdamDimData(handle, irank); + case (UDA_TYPE_DOUBLE): + dvec = (double*)getIdamDimData(handle, irank); - for (int i = 0; i < nmax; i++) { - fprintf(stdout, "%d %f\n", i, dvec[i]); - } + for (int i = 0; i < nmax; i++) { + fprintf(stdout, "%d %f\n", i, dvec[i]); + } - break; + break; } } diff --git a/source/wrappers/matlab/getData.m b/source/wrappers/matlab/getData.m index f1cbf0c7..7adc2b08 100755 --- a/source/wrappers/matlab/getData.m +++ b/source/wrappers/matlab/getData.m @@ -82,8 +82,6 @@ xlabel([s.TimeLabel ' ' s.TimeUnits], 'Interpreter', 'none') ylabel([s.DataLabel ' ' s.DataUnits], 'Interpreter', 'none') title([s.Name ' ' s.Source], 'Interpreter', 'none') - - end end diff --git a/source/wrappers/matlab/getIdamData.c b/source/wrappers/matlab/getIdamData.c index 672aa79e..cdccce67 100755 --- a/source/wrappers/matlab/getIdamData.c +++ b/source/wrappers/matlab/getIdamData.c @@ -1,11 +1,3 @@ -/* V3 output in a cell array - -Change History - -20May2010 dgm Changed to IDAM accessors getIdamDoubleData, getIdamDoubleDimData to cast atomic types to double. ------------------------------------------------------------------------------------------------------------------------- -*/ - #include "stdio.h" #include "string.h" #include "idammatlab.h" @@ -16,31 +8,31 @@ Change History int listIndex; -void addItem(mxArray * list, const mxArray * item) +void addItem(mxArray* list, const mxArray* item) { if (listIndex >= NFIELDS) { mexErrMsgTxt("Too many items"); } else { - mxSetCell(list, listIndex, (mxArray *)item); + mxSetCell(list, listIndex, (mxArray*)item); listIndex++; } } -void mexFunction(int nlhs, mxArray * plhs[], int nrhs, const mxArray * prhs[]) +void mexFunction(int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[]) { /* Matlab related data */ - mxArray * item; - double * ptr; - char * name, *source; + mxArray* item; + double* ptr; + char* name, * source; int ndata, erc; /* IDAM related data */ int handle, rank, order; - int * ivec = NULL; - float * fvec = NULL; - double * dvec = NULL; + int* ivec = NULL; + float* fvec = NULL; + double* dvec = NULL; if ((nlhs != 1) || (nrhs != 2)) { mexErrMsgTxt("One output and two inputs needed"); @@ -100,14 +92,12 @@ void mexFunction(int nlhs, mxArray * plhs[], int nrhs, const mxArray * prhs[]) ptr = mxGetPr(item); // Cast atomic data types to double - getIdamDoubleData(handle, ptr); - addItem(OUT, item); /* Error Data */ - char * error = getIdamError(handle); + char* error = getIdamError(handle); if (error != NULL) { addItem(OUT, mxCreateString("Error")); @@ -118,10 +108,8 @@ void mexFunction(int nlhs, mxArray * plhs[], int nrhs, const mxArray * prhs[]) ptr = mxGetPr(item); // Cast atomic data types to double - // Fudge as required accessor not in library - small loss of precision! - - float * fp = (float *) malloc( ndata * sizeof(float)); + float* fp = (float*)malloc(ndata * sizeof(float)); getIdamFloatError(handle, fp); for (int i = 0; i < ndata; i++) { @@ -152,9 +140,7 @@ void mexFunction(int nlhs, mxArray * plhs[], int nrhs, const mxArray * prhs[]) ptr = mxGetPr(item); // Cast atomic data types to double - getIdamDoubleDimData(handle, i, ptr); - addItem(OUT, item); } } diff --git a/source/wrappers/matlab/getIdamDoubleData.c b/source/wrappers/matlab/getIdamDoubleData.c index b01b6904..27bc1607 100755 --- a/source/wrappers/matlab/getIdamDoubleData.c +++ b/source/wrappers/matlab/getIdamDoubleData.c @@ -1,11 +1,3 @@ -/* V3 output in a cell array - -Change History - -20May2010 dgm Changed to IDAM accessors getIdamDoubleData, getIdamDoubleDimData to cast atomic types to double. ------------------------------------------------------------------------------------------------------------------------- -*/ - #include "stdio.h" #include "string.h" #include "idammatlab.h" @@ -16,7 +8,7 @@ Change History int listIndex; -void addItem(mxArray * list, const mxArray * item) +void addItem(mxArray* list, const mxArray* item) { if (listIndex >= NFIELDS) { mexErrMsgTxt("Too many items"); @@ -26,21 +18,21 @@ void addItem(mxArray * list, const mxArray * item) } } -void mexFunction(int nlhs, mxArray * plhs[], int nrhs, const mxArray * prhs[]) +void mexFunction(int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[]) { /* Matlab related data */ - mxArray * item; - double * ptr; - char * name, *source; + mxArray* item; + double* ptr; + char* name, * source; int ndata, erc; /* IDAM related data */ int handle, rank, order; - int * ivec = NULL; - float * fvec = NULL; - double * dvec = NULL; + int* ivec = NULL; + float* fvec = NULL; + double* dvec = NULL; if ((nlhs != 1) || (nrhs != 2)) { mexErrMsgTxt("One output and two inputs needed"); @@ -100,12 +92,9 @@ void mexFunction(int nlhs, mxArray * plhs[], int nrhs, const mxArray * prhs[]) ptr = mxGetPr(item); // Cast atomic data types to double - getIdamDoubleData(handle, ptr); - addItem(OUT, item); - /* do the same for the dimensions */ order = getIdamOrder(handle); @@ -126,9 +115,7 @@ void mexFunction(int nlhs, mxArray * plhs[], int nrhs, const mxArray * prhs[]) ptr = mxGetPr(item); // Cast atomic data types to double - getIdamDoubleDimData(handle, i, ptr); - addItem(OUT, item); } } diff --git a/source/wrappers/python/CMakeLists.txt b/source/wrappers/python/CMakeLists.txt index d89b6683..3ffaf649 100755 --- a/source/wrappers/python/CMakeLists.txt +++ b/source/wrappers/python/CMakeLists.txt @@ -19,7 +19,7 @@ if( LIBMEMCACHED_FOUND ) set( EXTRA_LIBS "memcached" ) endif() if( ENABLE_CAPNP ) - set( EXTRA_LIBS ${EXTRA_LIBS} capnp ) + set( EXTRA_LIBS ${EXTRA_LIBS} capnp kj ) set( UDA_LIBS ${UDA_LIBS} serialisation ) set( CAPNP_FLAG "True" ) else() diff --git a/source/wrappers/python/setup.py.in b/source/wrappers/python/setup.py.in index 5d2b0646..bd536185 100644 --- a/source/wrappers/python/setup.py.in +++ b/source/wrappers/python/setup.py.in @@ -55,7 +55,7 @@ ext = Extension( numpy.get_include(), '@LIBXML2_INCLUDE_DIR@' ], - libraries=['ssl', 'crypto', 'xml2', 'kj', 'capnp'] + extra_libs, + libraries=['ssl', 'crypto', 'xml2', 'fmt'] + extra_libs, library_dirs=[ '@OPENSSL_LIB_DIR@', '@LIBXML_LIB_DIR@' @@ -80,5 +80,5 @@ setup( url='https://git.iter.org/projects/IMAS/repos/uda/browse', packages=['pyuda'], ext_modules=cythonize([ext]), - install_requires=['numpy>=1.7', 'Cython>=0.29'], + install_requires=['numpy>=1.7', 'Cython>=0.29', 'six'], ) From 2cb24258e6168f0ff2e8b19ddd1820647e58806b Mon Sep 17 00:00:00 2001 From: Jonathan Hollocombe Date: Tue, 4 Jul 2023 09:17:24 +0100 Subject: [PATCH 04/39] Trying to fix GitHub macOS runner. --- .github/workflows/cmake.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index 0b80e4b4..c4e882df 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -53,7 +53,7 @@ jobs: - name: Install macos dependencies if: matrix.os == 'macos-latest' run: > - brew update && brew install + brew update-reset && brew install git boost openssl From b403ed3355f461d623e14c0309cf2c0a41fea1b6 Mon Sep 17 00:00:00 2001 From: Jonathan Hollocombe Date: Tue, 4 Jul 2023 09:24:37 +0100 Subject: [PATCH 05/39] Fixing Java wrapper build. --- source/wrappers/java/idam_jni.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/wrappers/java/idam_jni.c b/source/wrappers/java/idam_jni.c index b81d7096..0efaa344 100755 --- a/source/wrappers/java/idam_jni.c +++ b/source/wrappers/java/idam_jni.c @@ -68,12 +68,12 @@ JNIEXPORT void JNICALL Java_jIdam_Idam_idamCleanAllLocksMT(JNIEnv* env, jobject JNIEXPORT void JNICALL Java_jIdam_Idam_idamFree(JNIEnv* env, jobject obj, jint handle) { - idamFree((int)handle); + udaFree((int)handle); } JNIEXPORT void JNICALL Java_jIdam_Idam_idamFreeAll(JNIEnv* env, jobject obj) { -// udaFreeAll(); + udaFreeAll(); } From 448cf78f421c16bc0a90952cb839862990753c95 Mon Sep 17 00:00:00 2001 From: Jonathan Hollocombe Date: Tue, 4 Jul 2023 09:47:10 +0100 Subject: [PATCH 06/39] Tyring to fix pyuda build in ubuntu CI runner. --- .github/workflows/cmake.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index c4e882df..22ac952c 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -97,7 +97,7 @@ jobs: python3 -m venv ${{github.workspace}}/venv && source ${{github.workspace}}/venv/bin/activate && pip3 install --upgrade pip && - pip3 install Cython numpy && + pip3 install --upgrade cython numpy && pip3 install ${{github.workspace}}/python_installer # - name: Test From e183b2a409dbf5e99c572e059991acb43da93ab7 Mon Sep 17 00:00:00 2001 From: Jonathan Hollocombe Date: Thu, 29 Jun 2023 15:06:57 +0100 Subject: [PATCH 07/39] Renaming idamFree to udaFree and fixing udaFreeAll to make it callable in plugins. --- source/client/accAPI.cpp | 2 +- source/client/udaClient.cpp | 97 ++++++++++--------- source/client/udaClient.h | 6 +- source/client/udaPutAPI.cpp | 4 +- source/plugins/template/templatePlugin.cpp | 37 ++++++- source/plugins/uda/uda_plugin.cpp | 1 + source/plugins/udaPlugin.cpp | 47 +++++++++ source/plugins/udaPlugin.h | 3 + source/plugins/viewport/viewport.cpp | 8 +- source/wrappers/c++/result.cpp | 2 +- source/wrappers/fortran/accAPI_F.c | 4 +- source/wrappers/idl/idam_dlm.c | 10 +- source/wrappers/java/idam_jni.c | 2 +- source/wrappers/java/jIdam/Idam.java | 4 +- source/wrappers/matlab/dm_example.c | 4 +- source/wrappers/matlab/getIdamData.c | 2 +- source/wrappers/matlab/getIdamDoubleData.c | 2 +- .../wrappers/python/pyuda/cpyuda/handle.pyx | 2 +- source/wrappers/python/pyuda/cpyuda/uda.pxd | 2 +- 19 files changed, 166 insertions(+), 73 deletions(-) diff --git a/source/client/accAPI.cpp b/source/client/accAPI.cpp index af6685d0..982a06bc 100755 --- a/source/client/accAPI.cpp +++ b/source/client/accAPI.cpp @@ -291,7 +291,7 @@ int acc_getIdamNewDataHandle(CLIENT_FLAGS* client_flags) if ((client_flags->flags & CLIENTFLAG_REUSELASTHANDLE || client_flags->flags & CLIENTFLAG_FREEREUSELASTHANDLE) && (newHandleIndex = getIdamThreadLastHandle()) >= 0) { if (client_flags->flags & CLIENTFLAG_FREEREUSELASTHANDLE) { - idamFree(newHandleIndex); + udaFree(newHandleIndex); } else { // Application has responsibility for freeing heap in the Data Block initDataBlock(&data_blocks[newHandleIndex]); diff --git a/source/client/udaClient.cpp b/source/client/udaClient.cpp index 5bda918b..3335ad98 100755 --- a/source/client/udaClient.cpp +++ b/source/client/udaClient.cpp @@ -47,10 +47,13 @@ int client_version = 9; // previous version // FATCLIENT objects shared with server code #ifndef FATCLIENT -USERDEFINEDTYPELIST* user_defined_type_list = nullptr; // List of all known User Defined Structure Types -LOGMALLOCLIST* log_malloc_list = nullptr; // List of all Heap Allocations for Data -unsigned int last_malloc_index = 0; // Malloc Log search index last value -unsigned int* last_malloc_index_value = &last_malloc_index;; // Preserve Malloc Log search index last value in GENERAL_STRUCT +USERDEFINEDTYPELIST* g_user_defined_type_list = nullptr; // List of all known User Defined Structure Types +LOGMALLOCLIST* g_log_malloc_list = nullptr; // List of all Heap Allocations for Data +unsigned int g_last_malloc_index = 0; // Malloc Log search index last value +unsigned int* g_last_malloc_index_value = &g_last_malloc_index;; // Preserve Malloc Log search index last value in GENERAL_STRUCT +XDR* g_client_input = nullptr; +XDR* g_client_output = nullptr; +LOGSTRUCTLIST* g_log_struct_list = nullptr; #endif // FATCLIENT //---------------------------------------------------------------------------------------------------------------------- @@ -61,8 +64,6 @@ SERVER_BLOCK server_block; time_t tv_server_start = 0; time_t tv_server_end = 0; -//LOGSTRUCTLIST log_struct_list; - char client_username[STRING_LENGTH] = "client"; int authentication_needed = 1; // Enable the mutual authentication conversation at startup @@ -71,12 +72,12 @@ int authentication_needed = 1; // Enable the mutual authentication conversation void setUserDefinedTypeList(USERDEFINEDTYPELIST* userdefinedtypelist_in) { - user_defined_type_list = userdefinedtypelist_in; + g_user_defined_type_list = userdefinedtypelist_in; } void setLogMallocList(LOGMALLOCLIST* logmalloclist_in) { - log_malloc_list = logmalloclist_in; + g_log_malloc_list = logmalloclist_in; } #else @@ -248,7 +249,7 @@ fetchHierarchicalData(XDR* client_input, DATA_BLOCK* data_block, LOGSTRUCTLIST* UDA_LOG(UDA_LOG_DEBUG, "Receiving Hierarchical Data Structure from Server\n"); int err = 0; - if ((err = protocol2(client_input, protocol_id, XDR_RECEIVE, nullptr, log_malloc_list, user_defined_type_list, + if ((err = protocol2(client_input, protocol_id, XDR_RECEIVE, nullptr, g_log_malloc_list, g_user_defined_type_list, data_block, protocol_version, log_struct_list, private_flags, malloc_source)) != 0) { addIdamError(UDA_CODE_ERROR_TYPE, __func__, err, "Client Side Protocol Error (Opaque Structure Type)"); return err; @@ -289,35 +290,35 @@ fetchMeta(XDR* client_input, DATA_SYSTEM* data_system, SYSTEM_CONFIG* system_con int err = 0; #ifndef FATCLIENT // <========================== Client Server Code Only - if ((err = protocol2(client_input, UDA_PROTOCOL_DATA_SYSTEM, XDR_RECEIVE, nullptr, log_malloc_list, user_defined_type_list, + if ((err = protocol2(client_input, UDA_PROTOCOL_DATA_SYSTEM, XDR_RECEIVE, nullptr, g_log_malloc_list, g_user_defined_type_list, data_system, protocol_version, log_struct_list, private_flags, malloc_source)) != 0) { addIdamError(UDA_CODE_ERROR_TYPE, __func__, err, "Protocol 4 Error (Data System)"); return err; } printDataSystem(*data_system); - if ((err = protocol2(client_input, UDA_PROTOCOL_SYSTEM_CONFIG, XDR_RECEIVE, nullptr, log_malloc_list, user_defined_type_list, + if ((err = protocol2(client_input, UDA_PROTOCOL_SYSTEM_CONFIG, XDR_RECEIVE, nullptr, g_log_malloc_list, g_user_defined_type_list, system_config, protocol_version, log_struct_list, private_flags, malloc_source)) != 0) { addIdamError(UDA_CODE_ERROR_TYPE, __func__, err, "Protocol 5 Error (System Config)"); return err; } printSystemConfig(*system_config); - if ((err = protocol2(client_input, UDA_PROTOCOL_DATA_SOURCE, XDR_RECEIVE, nullptr, log_malloc_list, user_defined_type_list, + if ((err = protocol2(client_input, UDA_PROTOCOL_DATA_SOURCE, XDR_RECEIVE, nullptr, g_log_malloc_list, g_user_defined_type_list, data_source, protocol_version, log_struct_list, private_flags, malloc_source)) != 0) { addIdamError(UDA_CODE_ERROR_TYPE, __func__, err, "Protocol 6 Error (Data Source)"); return err; } printDataSource(*data_source); - if ((err = protocol2(client_input, UDA_PROTOCOL_SIGNAL, XDR_RECEIVE, nullptr, log_malloc_list, user_defined_type_list, + if ((err = protocol2(client_input, UDA_PROTOCOL_SIGNAL, XDR_RECEIVE, nullptr, g_log_malloc_list, g_user_defined_type_list, signal_rec, protocol_version, log_struct_list, private_flags, malloc_source)) != 0) { addIdamError(UDA_CODE_ERROR_TYPE, __func__, err, "Protocol 7 Error (Signal)"); return err; } printSignal(*signal_rec); - if ((err = protocol2(client_input, UDA_PROTOCOL_SIGNAL_DESC, XDR_RECEIVE, nullptr, log_malloc_list, user_defined_type_list, + if ((err = protocol2(client_input, UDA_PROTOCOL_SIGNAL_DESC, XDR_RECEIVE, nullptr, g_log_malloc_list, g_user_defined_type_list, signal_desc, protocol_version, log_struct_list, private_flags, malloc_source)) != 0) { addIdamError(UDA_CODE_ERROR_TYPE, __func__, err, "Protocol 8 Error (Signal Desc)"); return err; @@ -364,6 +365,11 @@ int idamClient(REQUEST_BLOCK* request_block, int* indices) static XDR* client_output = nullptr; static int malloc_source = UDA_MALLOC_SOURCE_NONE; +#ifndef FATCLIENT + g_client_input = client_input; // needed for udaFreeAll + g_client_output = client_output; // needed for udaFreeAll +#endif + LOGSTRUCTLIST log_struct_list; initLogStructList(&log_struct_list); @@ -436,14 +442,14 @@ int idamClient(REQUEST_BLOCK* request_block, int* indices) for (int i = 0; i < request_block->num_requests; ++i) { auto request = &request_block->requests[i]; DATA_BLOCK* data_block = &cached_data_block_list.data[i]; - int rc = check_file_cache(request, &data_block, log_malloc_list, user_defined_type_list, + int rc = check_file_cache(request, &data_block, g_log_malloc_list, g_user_defined_type_list, &log_struct_list, client_flags, *private_flags, malloc_source); if (rc >= 0) { request_block->requests[i].request = REQUEST_CACHED; ++num_cached; continue; } - rc = check_mem_cache(cache, request, &data_block, log_malloc_list, user_defined_type_list, + rc = check_mem_cache(cache, request, &data_block, g_log_malloc_list, g_user_defined_type_list, &log_struct_list, client_flags, *private_flags, malloc_source); if (rc >= 0) { request_block->requests[i].request = REQUEST_CACHED; @@ -662,7 +668,7 @@ int idamClient(REQUEST_BLOCK* request_block, int* indices) int protocol_id = UDA_PROTOCOL_CLIENT_BLOCK; // Send Client Block (proxy for authenticationStep = 6) - if ((err = protocol2(client_output, protocol_id, XDR_SEND, nullptr, log_malloc_list, user_defined_type_list, + if ((err = protocol2(client_output, protocol_id, XDR_SEND, nullptr, g_log_malloc_list, g_user_defined_type_list, &client_block, protocol_version, &log_struct_list, *private_flags, malloc_source)) != 0) { addIdamError(UDA_CODE_ERROR_TYPE, __func__, err, "Protocol 10 Error (Client Block)"); @@ -689,7 +695,7 @@ int idamClient(REQUEST_BLOCK* request_block, int* indices) protocol_id = UDA_PROTOCOL_SERVER_BLOCK; // Receive Server Block: Server Aknowledgement (proxy for authenticationStep = 8) - if ((err = protocol2(client_input, protocol_id, XDR_RECEIVE, nullptr, log_malloc_list, user_defined_type_list, + if ((err = protocol2(client_input, protocol_id, XDR_RECEIVE, nullptr, g_log_malloc_list, g_user_defined_type_list, &server_block, protocol_version, &log_struct_list, *private_flags, malloc_source)) != 0) { addIdamError(UDA_CODE_ERROR_TYPE, __func__, err, "Protocol 11 Error (Server Block #1)"); @@ -781,7 +787,7 @@ int idamClient(REQUEST_BLOCK* request_block, int* indices) int protocol_id = UDA_PROTOCOL_CLIENT_BLOCK; // Send Client Block - if ((err = protocol2(client_output, protocol_id, XDR_SEND, nullptr, log_malloc_list, user_defined_type_list, + if ((err = protocol2(client_output, protocol_id, XDR_SEND, nullptr, g_log_malloc_list, g_user_defined_type_list, &client_block, protocol_version, &log_struct_list, *private_flags, malloc_source)) != 0) { addIdamError(UDA_CODE_ERROR_TYPE, __func__, err, "Protocol 10 Error (Client Block)"); @@ -794,7 +800,7 @@ int idamClient(REQUEST_BLOCK* request_block, int* indices) protocol_id = UDA_PROTOCOL_REQUEST_BLOCK; // This is what the Client Wants - if ((err = protocol2(client_output, protocol_id, XDR_SEND, nullptr, log_malloc_list, user_defined_type_list, + if ((err = protocol2(client_output, protocol_id, XDR_SEND, nullptr, g_log_malloc_list, g_user_defined_type_list, request_block, protocol_version, &log_struct_list, *private_flags, malloc_source)) != 0) { addIdamError(UDA_CODE_ERROR_TYPE, __func__, err, "Protocol 1 Error (Request Block)"); @@ -810,7 +816,7 @@ int idamClient(REQUEST_BLOCK* request_block, int* indices) if (request->put) { protocol_id = UDA_PROTOCOL_PUTDATA_BLOCK_LIST; - if ((err = protocol2(client_output, protocol_id, XDR_SEND, nullptr, log_malloc_list, user_defined_type_list, + if ((err = protocol2(client_output, protocol_id, XDR_SEND, nullptr, g_log_malloc_list, g_user_defined_type_list, &(request->putDataBlockList), protocol_version, &log_struct_list, *private_flags, malloc_source)) != 0) { addIdamError(UDA_CODE_ERROR_TYPE, __func__, err, @@ -845,8 +851,8 @@ int idamClient(REQUEST_BLOCK* request_block, int* indices) UDA_LOG(UDA_LOG_DEBUG, "Waiting for Server Status Block\n"); - if ((err = protocol2(client_input, UDA_PROTOCOL_SERVER_BLOCK, XDR_RECEIVE, nullptr, log_malloc_list, - user_defined_type_list, &server_block, protocol_version, &log_struct_list, + if ((err = protocol2(client_input, UDA_PROTOCOL_SERVER_BLOCK, XDR_RECEIVE, nullptr, g_log_malloc_list, + g_user_defined_type_list, &server_block, protocol_version, &log_struct_list, *private_flags, malloc_source)) != 0) { UDA_LOG(UDA_LOG_DEBUG, "Protocol 11 Error (Server Block #2) = %d\n", err); addIdamError(UDA_CODE_ERROR_TYPE, __func__, err, " Protocol 11 Error (Server Block #2)"); @@ -897,8 +903,8 @@ int idamClient(REQUEST_BLOCK* request_block, int* indices) DATA_BLOCK_LIST recv_data_block_list; - if ((err = protocol2(client_input, UDA_PROTOCOL_DATA_BLOCK_LIST, XDR_RECEIVE, nullptr, log_malloc_list, - user_defined_type_list, &recv_data_block_list, protocol_version, + if ((err = protocol2(client_input, UDA_PROTOCOL_DATA_BLOCK_LIST, XDR_RECEIVE, nullptr, g_log_malloc_list, + g_user_defined_type_list, &recv_data_block_list, protocol_version, &log_struct_list, *private_flags, malloc_source)) != 0) { UDA_LOG(UDA_LOG_DEBUG, "Protocol 2 Error (Failure Receiving Data Block)\n"); @@ -955,7 +961,7 @@ int idamClient(REQUEST_BLOCK* request_block, int* indices) //------------------------------------------------------------------------------ // Cache the data if the server has passed permission and the application (client) has enabled caching if (client_flags->flags & CLIENTFLAG_FILECACHE) { - udaFileCacheWrite(data_block, request_block, log_malloc_list, user_defined_type_list, protocol_version, + udaFileCacheWrite(data_block, request_block, g_log_malloc_list, g_user_defined_type_list, protocol_version, &log_struct_list, *private_flags, malloc_source); } @@ -966,7 +972,7 @@ int idamClient(REQUEST_BLOCK* request_block, int* indices) # else if (cache != nullptr && client_flags->flags & CLIENTFLAG_CACHE) { # endif - cache_write(cache, &request_block->requests[i], data_block, log_malloc_list, user_defined_type_list, + cache_write(cache, &request_block->requests[i], data_block, g_log_malloc_list, g_user_defined_type_list, *environment, protocol_version, client_flags->flags, &log_struct_list, *private_flags, malloc_source); } @@ -1199,7 +1205,7 @@ int idamClient(REQUEST_BLOCK* request_block, int* indices) #endif // <========================== End of FatClient Code Only -void idamFree(int handle) +void udaFree(int handle) { // Free Heap Memory (Not the Data Blocks themselves: These will be re-used.) @@ -1232,10 +1238,10 @@ void idamFree(int handle) if (general_block->userdefinedtypelist != nullptr) { #ifndef FATCLIENT - if (user_defined_type_list == general_block->userdefinedtypelist) { // Is this the current setting? - freeUserDefinedTypeList(user_defined_type_list); - free(user_defined_type_list); - user_defined_type_list = nullptr; + if (g_user_defined_type_list == general_block->userdefinedtypelist) { // Is this the current setting? + freeUserDefinedTypeList(g_user_defined_type_list); + free(g_user_defined_type_list); + g_user_defined_type_list = nullptr; } else { freeUserDefinedTypeList(general_block->userdefinedtypelist); free(general_block->userdefinedtypelist); @@ -1248,10 +1254,10 @@ void idamFree(int handle) if (general_block->logmalloclist != nullptr) { #ifndef FATCLIENT - if (log_malloc_list == general_block->logmalloclist) { - freeMallocLogList(log_malloc_list); - free(log_malloc_list); - log_malloc_list = nullptr; + if (g_log_malloc_list == general_block->logmalloclist) { + freeMallocLogList(g_log_malloc_list); + free(g_log_malloc_list); + g_log_malloc_list = nullptr; } else { freeMallocLogList(general_block->logmalloclist); free(general_block->logmalloclist); @@ -1398,8 +1404,7 @@ void idamFree(int handle) data_block->handle = -1; // Flag this as ready for re-use } -void udaFreeAll(XDR* client_input, XDR* client_output, LOGSTRUCTLIST* log_struct_list, unsigned int private_flags, - int malloc_source) +void udaFreeAll() { // Free All Heap Memory #ifndef FATCLIENT @@ -1424,8 +1429,8 @@ void udaFreeAll(XDR* client_input, XDR* client_output, LOGSTRUCTLIST* log_struct acc_freeDataBlocks(); #ifndef FATCLIENT - user_defined_type_list = nullptr; // malloc'd within protocolXML - log_malloc_list = nullptr; + g_user_defined_type_list = nullptr; // malloc'd within protocolXML + g_log_malloc_list = nullptr; #endif closeUdaError(); @@ -1441,17 +1446,21 @@ void udaFreeAll(XDR* client_input, XDR* client_output, LOGSTRUCTLIST* log_struct client_block.timeout = 0; // Surrogate CLOSEDOWN instruction client_block.clientFlags = client_block.clientFlags | CLIENTFLAG_CLOSEDOWN; // Direct CLOSEDOWN instruction protocol_id = UDA_PROTOCOL_CLIENT_BLOCK; - protocol2(client_output, protocol_id, XDR_SEND, nullptr, log_malloc_list, user_defined_type_list, &client_block, - protocol_version, log_struct_list, private_flags, malloc_source); - xdrrec_endofrecord(client_output, 1); + protocol2(g_client_output, protocol_id, XDR_SEND, nullptr, g_log_malloc_list, g_user_defined_type_list, &client_block, + protocol_version, g_log_struct_list, *udaPrivateFlags(), UDA_MALLOC_SOURCE_NONE); + xdrrec_endofrecord(g_client_output, 1); } #endif // <========================== End of Client Server Code Only bool reopen_logs = false; +#ifndef FATCLIENT // Close the Socket, XDR Streams and All Files - closedown(ClosedownType::CLOSE_ALL, nullptr, client_input, client_output, &reopen_logs); + closedown(ClosedownType::CLOSE_ALL, nullptr, g_client_input, g_client_output, &reopen_logs); +#else + closedown(ClosedownType::CLOSE_ALL, nullptr, nullptr, nullptr, &reopen_logs); +#endif } SERVER_BLOCK getIdamThreadServerBlock() diff --git a/source/client/udaClient.h b/source/client/udaClient.h index 80996a48..6ac0d939 100755 --- a/source/client/udaClient.h +++ b/source/client/udaClient.h @@ -61,11 +61,9 @@ LIBRARY_API int idamClient(REQUEST_BLOCK* request_block, int* indices); LIBRARY_API void updateClientBlock(CLIENT_BLOCK* str, const CLIENT_FLAGS* client_flags, unsigned int private_flags); -LIBRARY_API void idamFree(int handle); +LIBRARY_API void udaFree(int handle); -LIBRARY_API void -udaFreeAll(XDR* client_input, XDR* client_output, LOGSTRUCTLIST* log_struct_list, unsigned int private_flags, - int malloc_source); +LIBRARY_API void udaFreeAll(); LIBRARY_API CLIENT_FLAGS* udaClientFlags(); LIBRARY_API unsigned int* udaPrivateFlags(); diff --git a/source/client/udaPutAPI.cpp b/source/client/udaPutAPI.cpp index 8d2a08f8..8c8663cb 100755 --- a/source/client/udaPutAPI.cpp +++ b/source/client/udaPutAPI.cpp @@ -61,7 +61,7 @@ int idamPutListAPI(const char* putInstruction, PUTDATA_BLOCK_LIST* inPutDataBloc /* logmalloclist = nullptr; */ /* userdefinedtypelist = nullptr; */ /* int h = idamGetAPI("help::ping()", ""); */ -/* idamFree(h); */ +/* udaFree(h); */ /* idamGetAPICalledOnce = 1; */ /* lastMallocIndex = 0; */ /* logmalloclist = oldlogmalloclist; */ @@ -142,7 +142,7 @@ int idamPutAPI(const char* putInstruction, PUTDATA_BLOCK* inPutData) /* logmalloclist = nullptr; */ /* userdefinedtypelist = nullptr; */ /* int h = idamGetAPI("help::ping()", ""); */ -/* idamFree(h); */ +/* udaFree(h); */ /* idamGetAPICalledOnce = 1; */ /* lastMallocIndex = 0; */ /* logmalloclist = oldlogmalloclist; */ diff --git a/source/plugins/template/templatePlugin.cpp b/source/plugins/template/templatePlugin.cpp index 9147439c..7346cda2 100755 --- a/source/plugins/template/templatePlugin.cpp +++ b/source/plugins/template/templatePlugin.cpp @@ -182,13 +182,48 @@ int TemplatePlugin::max_interface_version(IDAM_PLUGIN_INTERFACE* idam_plugin_int return setReturnDataIntScalar(idam_plugin_interface->data_block, THISPLUGIN_MAX_INTERFACE_VERSION, "Maximum Interface Version"); } +namespace { + +template +std::string to_string(T* array, size_t size) { + std::string result; + const char* delim = ""; + for (size_t i = 0; i < size; ++i) { + result += delim + std::to_string(array[i]); + delim = ", "; + } + return result; +} + +} // anon namespace + //---------------------------------------------------------------------------------------- // Add functionality here .... int TemplatePlugin::function(IDAM_PLUGIN_INTERFACE* idam_plugin_interface) { DATA_BLOCK* data_block = idam_plugin_interface->data_block; - setReturnDataString(data_block, "Hello World!", "templatePlugin: 'Hello World' single string returned"); + NameValueList& nvl = idam_plugin_interface->request_data->nameValueList; + + const char* required = nullptr; + FIND_REQUIRED_STRING_VALUE(nvl, required); + + double* array = nullptr; + size_t narray = -1; + FIND_REQUIRED_DOUBLE_ARRAY(nvl, array); + + int optional = -1; + bool optional_found = FIND_INT_VALUE(nvl, optional); + + std::string result = std::string("Passed args: required=") + required + + ", array=[" + to_string(array, narray) + "]"; + if (optional_found) { + result += ", optional=" + std::to_string(optional) + ")"; + } else { + result += ", optional=)"; + } + + setReturnDataString(data_block, result.c_str(), "result of TemplatePlugin::function"); strcpy(data_block->data_label, ""); strcpy(data_block->data_units, ""); diff --git a/source/plugins/uda/uda_plugin.cpp b/source/plugins/uda/uda_plugin.cpp index e9eeff90..30b4ec7c 100755 --- a/source/plugins/uda/uda_plugin.cpp +++ b/source/plugins/uda/uda_plugin.cpp @@ -58,6 +58,7 @@ extern int UDAPlugin(IDAM_PLUGIN_INTERFACE* idam_plugin_interface) // Resetting all UDA client properties resetIdamProperties(udaClientFlags()); + udaFreeAll(); putIdamServerHost(oldServerHost); // Original Host putIdamServerPort(oldPort); // Original Port diff --git a/source/plugins/udaPlugin.cpp b/source/plugins/udaPlugin.cpp index 51ad9a77..7d8f091e 100644 --- a/source/plugins/udaPlugin.cpp +++ b/source/plugins/udaPlugin.cpp @@ -1,10 +1,57 @@ #include "udaPlugin.h" +#include "server/initPluginList.h" +#include "server/serverPlugin.h" +#include "structures/struct.h" +#include #include #include #include #include +IDAM_PLUGIN_INTERFACE* udaCreatePluginInterface(const char* request) +{ + auto plugin_interface = (IDAM_PLUGIN_INTERFACE*)calloc(1, sizeof(IDAM_PLUGIN_INTERFACE)); + auto environment = getServerEnvironment(); + auto plugin_list = (PLUGINLIST*)calloc(1, sizeof(PLUGINLIST)); + + initPluginList(plugin_list, environment); + + auto request_data = (REQUEST_DATA*)calloc(1, sizeof(REQUEST_DATA)); + makeRequestData(request_data, *plugin_list, environment); + + auto user_defined_type_list = (USERDEFINEDTYPELIST*)calloc(1, sizeof(USERDEFINEDTYPELIST)); + auto log_malloc_list = (LOGMALLOCLIST*)calloc(1, sizeof(LOGMALLOCLIST)); + + plugin_interface->request_data = request_data; + plugin_interface->pluginList = plugin_list; + plugin_interface->environment = environment; + plugin_interface->userdefinedtypelist = user_defined_type_list; + plugin_interface->logmalloclist = log_malloc_list; + + plugin_interface->interfaceVersion = 1; + plugin_interface->pluginVersion = 0; + plugin_interface->housekeeping = 0; + plugin_interface->changePlugin = 0; + plugin_interface->error_stack.nerrors = 0; + plugin_interface->error_stack.idamerror = nullptr; + + return plugin_interface; +} + +void udaFreePluginInterface(IDAM_PLUGIN_INTERFACE* plugin_interface) +{ + free(plugin_interface->request_data); + freeUserDefinedTypeList(plugin_interface->userdefinedtypelist); + free(plugin_interface->userdefinedtypelist); + freeMallocLogList(plugin_interface->logmalloclist); + free(plugin_interface->logmalloclist); + freePluginList((PLUGINLIST*)plugin_interface->pluginList); + free((PLUGINLIST*)plugin_interface->pluginList); + free((ENVIRONMENT*)plugin_interface->environment); + free(plugin_interface); +} + int initPlugin(const IDAM_PLUGIN_INTERFACE* plugin_interface) { udaSetLogLevel((LOG_LEVEL)plugin_interface->environment->loglevel); diff --git a/source/plugins/udaPlugin.h b/source/plugins/udaPlugin.h index 908b35e1..a0749a10 100755 --- a/source/plugins/udaPlugin.h +++ b/source/plugins/udaPlugin.h @@ -33,6 +33,9 @@ typedef void (* ADDIDAMERRORFUNP)(UDA_ERROR_STACK*, int, char*, int, char*); / LIBRARY_API int callPlugin(const PLUGINLIST* pluginlist, const char* request, const IDAM_PLUGIN_INTERFACE* old_plugin_interface); +IDAM_PLUGIN_INTERFACE* udaCreatePluginInterface(const char* request); +void udaFreePluginInterface(IDAM_PLUGIN_INTERFACE* plugin_interface); + LIBRARY_API int findPluginIdByRequest(int request, const PLUGINLIST* plugin_list); LIBRARY_API int findPluginIdByFormat(const char* format, const PLUGINLIST* plugin_list); LIBRARY_API int findPluginIdByDevice(const char* device, const PLUGINLIST* plugin_list); diff --git a/source/plugins/viewport/viewport.cpp b/source/plugins/viewport/viewport.cpp index 0f803565..b52302a5 100755 --- a/source/plugins/viewport/viewport.cpp +++ b/source/plugins/viewport/viewport.cpp @@ -174,7 +174,7 @@ extern int viewport(IDAM_PLUGIN_INTERFACE* idam_plugin_interface) // Free Heap & reset counters for (int i = 0; i < handleCount; i++) { - idamFree(handles[i]); + udaFree(handles[i]); handles[i] = -1; } @@ -189,7 +189,7 @@ extern int viewport(IDAM_PLUGIN_INTERFACE* idam_plugin_interface) // Free Cached data if requested or filled for (int i = 0; i < handleCount; i++) { - idamFree(handles[i]); + udaFree(handles[i]); handles[i] = -1; } @@ -201,7 +201,7 @@ extern int viewport(IDAM_PLUGIN_INTERFACE* idam_plugin_interface) if (handleCount == MAXHANDLES) { // Free some Cached data if cache is full for (int i = 0; i < FREEHANDLEBLOCK; i++) { - idamFree(handles[i]); + udaFree(handles[i]); handles[i] = handles[i + FREEHANDLEBLOCK]; strcpy(signals[i], signals[i + FREEHANDLEBLOCK]); strcpy(sources[i], sources[i + FREEHANDLEBLOCK]); @@ -220,7 +220,7 @@ extern int viewport(IDAM_PLUGIN_INTERFACE* idam_plugin_interface) // Free Heap Cache & reset counters for (int i = 0; i < handleCount; i++) { - idamFree(handles[i]); + udaFree(handles[i]); handles[i] = -1; } diff --git a/source/wrappers/c++/result.cpp b/source/wrappers/c++/result.cpp index edb7e6d7..90686e6e 100755 --- a/source/wrappers/c++/result.cpp +++ b/source/wrappers/c++/result.cpp @@ -91,7 +91,7 @@ uda::Result::Result(int handle) uda::Result::~Result() { - idamFree(handle_); + udaFree(handle_); } const std::vector uda::Result::shape() const diff --git a/source/wrappers/fortran/accAPI_F.c b/source/wrappers/fortran/accAPI_F.c index 204b01bc..e3d81470 100755 --- a/source/wrappers/fortran/accAPI_F.c +++ b/source/wrappers/fortran/accAPI_F.c @@ -1173,12 +1173,12 @@ extern void getidamdimdatachecksum_(int* handle, int* ndim, int* sum) extern void idamfree_(int* hd) { int handle = *hd; - idamFree(handle); + udaFree(handle); } extern void idamfreeall_() { - idamFreeAll(); + udaFreeAll(); } extern void getidamenv_(char* str, int* rc, char* env, int lstr, int lenv) diff --git a/source/wrappers/idl/idam_dlm.c b/source/wrappers/idl/idam_dlm.c index 7619b66a..f19e5be3 100755 --- a/source/wrappers/idl/idam_dlm.c +++ b/source/wrappers/idl/idam_dlm.c @@ -1269,7 +1269,7 @@ IDL_VPTR IDL_CDECL idamputapi(int argc, IDL_VPTR argv[], char* argk) fprintf(stdout, "Freeing Heap for Handle %d\n", handle); } - idamFree(handle); + udaFree(handle); } //-------------------------------------------------------------------------- @@ -1695,7 +1695,7 @@ IDL_VPTR IDL_CDECL callidam2(int argc, IDL_VPTR argv[], char* argk) fprintf(stdout, "Freeing Heap for Handle %d\n", handle); } - idamFree(handle); + udaFree(handle); } //-------------------------------------------------------------------------- @@ -2618,7 +2618,7 @@ callidam(int argc, IDL_VPTR argv[], char* argk) fprintf(stdout, "Freeing Heap for Handle %d\n", handle); } - idamFree(handle); + udaFree(handle); } //-------------------------------------------------------------------------- @@ -4448,7 +4448,7 @@ freeidam(int argc, IDL_VPTR argv[], char* argk) //-------------------------------------------------------------------------- // Free IDAM Heap - idamFree(handle); + udaFree(handle); return (IDL_GettmpLong(0)); } @@ -4462,7 +4462,7 @@ freeidamall(int argc, IDL_VPTR argv[], char* argk) // Free All IDAM Heap + Close IDAM Server - idamFreeAll(); + udaFreeAll(); return (IDL_GettmpLong(0)); } diff --git a/source/wrappers/java/idam_jni.c b/source/wrappers/java/idam_jni.c index 66fa062c..b81d7096 100755 --- a/source/wrappers/java/idam_jni.c +++ b/source/wrappers/java/idam_jni.c @@ -754,6 +754,6 @@ JNIEXPORT jobjectArray JNICALL Java_jIdam_Idam_getVariablesRegex(JNIEnv* env, jo } END: - //RC idamFree(handle); + //RC udaFree(handle); return ret; } diff --git a/source/wrappers/java/jIdam/Idam.java b/source/wrappers/java/jIdam/Idam.java index 08a96541..dee74a69 100755 --- a/source/wrappers/java/jIdam/Idam.java +++ b/source/wrappers/java/jIdam/Idam.java @@ -20,8 +20,8 @@ public class Idam { // Idam API public static native int idamGetAPI(String signal, String source); - public static native void idamFree(int handle); - public static native void idamFreeAll(); + public static native void udaFree(int handle); + public static native void udaFreeAll(); // Multithread Idam API public static native int idamGetAPIMT(String signal, String source); diff --git a/source/wrappers/matlab/dm_example.c b/source/wrappers/matlab/dm_example.c index fba61ccf..fbd63126 100755 --- a/source/wrappers/matlab/dm_example.c +++ b/source/wrappers/matlab/dm_example.c @@ -121,9 +121,9 @@ int main() } } - idamFree(handle); // Free Heap for this signal + udaFree(handle); // Free Heap for this signal } - idamFreeAll(); // Free all Heap and signal the server to close + udaFreeAll(); // Free all Heap and signal the server to close return 0; } diff --git a/source/wrappers/matlab/getIdamData.c b/source/wrappers/matlab/getIdamData.c index 923b7d72..672aa79e 100755 --- a/source/wrappers/matlab/getIdamData.c +++ b/source/wrappers/matlab/getIdamData.c @@ -159,5 +159,5 @@ void mexFunction(int nlhs, mxArray * plhs[], int nrhs, const mxArray * prhs[]) } } - idamFree(handle); /* Free Heap for this signal */ + udaFree(handle); /* Free Heap for this signal */ } diff --git a/source/wrappers/matlab/getIdamDoubleData.c b/source/wrappers/matlab/getIdamDoubleData.c index 98658088..b01b6904 100755 --- a/source/wrappers/matlab/getIdamDoubleData.c +++ b/source/wrappers/matlab/getIdamDoubleData.c @@ -133,5 +133,5 @@ void mexFunction(int nlhs, mxArray * plhs[], int nrhs, const mxArray * prhs[]) } } - idamFree(handle); /* Free Heap for this signal */ + udaFree(handle); /* Free Heap for this signal */ } diff --git a/source/wrappers/python/pyuda/cpyuda/handle.pyx b/source/wrappers/python/pyuda/cpyuda/handle.pyx index 13c616f8..7cc35279 100644 --- a/source/wrappers/python/pyuda/cpyuda/handle.pyx +++ b/source/wrappers/python/pyuda/cpyuda/handle.pyx @@ -15,4 +15,4 @@ cdef class Handle(int): return self._handle def __dealloc__(self): - uda.idamFree(self._handle) + uda.udaFree(self._handle) diff --git a/source/wrappers/python/pyuda/cpyuda/uda.pxd b/source/wrappers/python/pyuda/cpyuda/uda.pxd index b108a80b..edbc188a 100644 --- a/source/wrappers/python/pyuda/cpyuda/uda.pxd +++ b/source/wrappers/python/pyuda/cpyuda/uda.pxd @@ -5,7 +5,7 @@ cdef extern from "client/udaClient.h": int getIdamServerPort(); const char* getUdaBuildVersion(); const char* getUdaBuildDate(); - void idamFree(int handle); + void udaFree(int handle); CLIENT_FLAGS* udaClientFlags(); ctypedef struct CLIENT_FLAGS From 1fdb0df5bf9700d22ec73b78130ff1f4c2c9baaa Mon Sep 17 00:00:00 2001 From: Jonathan Hollocombe Date: Thu, 29 Jun 2023 15:08:21 +0100 Subject: [PATCH 08/39] Adding docs for creating a plugin. --- docs/creating_plugins.md | 124 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 123 insertions(+), 1 deletion(-) diff --git a/docs/creating_plugins.md b/docs/creating_plugins.md index 5092a9c1..bc56a98c 100644 --- a/docs/creating_plugins.md +++ b/docs/creating_plugins.md @@ -3,4 +3,126 @@ layout: default title: Creating a UDA plugin --- -TODO: Instructions for creating a new UDA plugin \ No newline at end of file +## UDA plugin + +A UDA plugin is shared library that is loaded dynamically by the +UDA server to enable extra functionality. The plugin makes available +a number of functions which can be called by the UDA client by specifying +the plugin name and function along with any number of arguments. + +For example, if we have a plugin which is called `TEST` we might have +functions: +- `TEST::help()` +- `TEST::readData(filename=foo)` +- `TEST::process(signal=foo,operation=bar,flag)` + +These functions read the arguments, do some processing, and return a +UDA `DataBlock` containing the data to be passed to the client. + +## Structure of a plugin + +The internals of a plugin is up to the plugin author. It can written in any +language that can be compiled to a shared library (.so on Linux, .dylib on MacOS, +.dll on Windows) but must provide a C style entry function which is +called by the UDA server. + +The entry function must look like: + +`int entryFunction(IDAM_PLUGIN_INTERFACE*)` + +Then function can have any name — the name is specified in the plugin configuration +file, see below. The `IDAM_PLUGIN_INTERFACE` is a structure defined in `uda/plugins.h` +and provides a mechanism for the plugin to interact with the UDA server — reading the +function arguments, returning the resultant data, etc. The returned `int` value specifies +the return state of the plugin call — zero for success or non-zero for an error state +(the actual error is returned via the `IDAM_PLUGIN_INTERFACE`). + +## Accessing function name and arguments + +The function being called is provided in the `IDAM_PLUGIN_INTERFACE` structure passed into +entry function as a C-string (`const char*`) via: + +`plugin_interface->request->function` + +The arguments that where passed to the plugin function is passed a list of name-value pairs +via: + +`plugin_interface->request->nameValueList` + +You can the provided helper functions to find the argument in the list and return the value: + +`bool findValue(NAMEVALUELIST* nvl, TYPE* value, const char* name)` + +where `` is the name of type being expected, i.e. `Int` or `Double`, `name` is the name of the argument +being read and `value` is where the found value is stored. If the argument is not found the function will return +`false`, otherwise it will return `true` and populate `data` with the found value. + +Help macros are also available when the name of the variable being read into is the same as the +name of the argument being read, i.e. to read a function argument called `arg1` we can used: + +```c +int arg1; +bool found = FIND_INT_VALUE(nvl, arg1); +``` + +If the function argument is required you can use another helper macro which will set an error message +and return from the function with a non-zero value, if the argument is not found: + +```c +int arg1;˚ +FIND_REQUIRED_INT_VALUE(nvl, arg1); +``` + +## Returning data from a plugin + +To return + +## Plugin configuration file + +The UDA server has a plugin configuration file that specifies how to load and use +the plugins available to the server. The plugin configuration file is a comman separated +text file with each line defined as: + +`NAME, TYPE, ENTRY_FUNC, LIBRARY, *, 1, 1, 1, DESC` + +Where: + +- `NAME`: the name of the plugin — this is the name by which the client can call the call the plugin. +- `TYPE`: the type of the plugin — should be `function` for the plugins defined here. +- `ENTRY_FUNC`: the name of the plugin entry function. +- `LIBRARY`: the file name of the compile shared library, including extension. +- `DESC`: a short description of the plugin which is used by UDA when listing the plugins available. + +Note: + +The other elements (`*, 1, 1, 1`) are not applicable to the `function` type plugins are should always be set +to these values. + +For example: + +`HELP, function, helpPlugin, libhelp_plugin.dylib, *, 1, 1, 1, Service Discovery: list the details on all registered services, HELP::services()` + +## Copying the template plugin + +The easies way to create a new plugin is to copy the `templatePlugin` from the UDA repository. +Copy the template plugin directory `source/plugin/template` and rename as required. The directory contains +the following files: + +- `CMakeLists.txt`: the CMake configuration file specifying how to build the plugin +- `templatePlugin.h`: the plugin header file +- `templatePlugin.cpp`: the plugin source file + +Now update the plugin: + +1. Rename the `templatePlugin.*` files to something that makes sense for your plugin and update +the `CMakeLists.txt` file as appropriate. +2. Change the entry function name in the source and header files from `templatePlugin(...)` to +something that corresponds to your plugin, and update `CMakeLists.txt` accordingly. +3. Implement the functionality required in the plugin. + +The template plugin is written in C++ and uses a TemplatePlugin object to handle any of the function +requests. The plugin object is static as data can be cached between calls to avoid having to repeat work, +for example holding onto file handles to avoid re-opening files. + +You can use the structure as provided or implement the functionality however you desire as long as each call +to the entry function handles the function requested and returns an error code accordingly. \ No newline at end of file From 6a490a56afd33adf07f783e622b0dfc7e8a332db Mon Sep 17 00:00:00 2001 From: Jonathan Hollocombe Date: Mon, 3 Jul 2023 23:54:14 +0100 Subject: [PATCH 09/39] Adding docker files for CentOS 8 and Ubuntu and fixing build on Ubuntu 22.10 --- docker/client.centos.8 | 67 ++++++++++++ docker/client.ubuntu.22.10 | 43 ++++++++ source/clientserver/protocolXML2Put.cpp | 4 +- source/structures/accessors.cpp | 28 ++--- source/structures/struct.cpp | 114 ++++++++++----------- source/structures/struct.h | 2 +- source/structures/xdrUserDefinedData.cpp | 4 +- source/wrappers/c++/scalar.hpp | 16 +-- source/wrappers/c++/vector.hpp | 14 +-- source/wrappers/matlab/dm_example.c | 53 +++++----- source/wrappers/matlab/getData.m | 2 - source/wrappers/matlab/getIdamData.c | 36 ++----- source/wrappers/matlab/getIdamDoubleData.c | 29 ++---- source/wrappers/python/CMakeLists.txt | 2 +- 14 files changed, 248 insertions(+), 166 deletions(-) create mode 100644 docker/client.centos.8 create mode 100644 docker/client.ubuntu.22.10 diff --git a/docker/client.centos.8 b/docker/client.centos.8 new file mode 100644 index 00000000..63cd7eab --- /dev/null +++ b/docker/client.centos.8 @@ -0,0 +1,67 @@ +FROM centos:8 + +SHELL ["/bin/bash", "-c"] + +RUN sed -i 's/$releasever/$releasever-stream/g' /etc/yum.repos.d/CentOS-* +RUN yum update -y --allowerasing && \ + yum group install -y 'Development Tools' && \ + yum install -y \ + git \ + wget \ + boost-devel \ + openssl-devel \ + cmake \ + libxml2-devel \ + libtirpc-devel \ + python39-devel \ + python39-pip + +# Building libfmt from source +RUN cd /tmp && \ + wget https://github.com/fmtlib/fmt/archive/refs/tags/10.0.0.tar.gz && \ + tar xzf 10.0.0.tar.gz && \ + cd fmt-10.0.0 && \ + cmake -Bbuild -H. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local -DBUILD_SHARED_LIBS=ON && \ + cmake --build build -j && \ + cmake --install build + +# Building spdlog from source +RUN cd /tmp && \ + wget https://github.com/gabime/spdlog/archive/refs/tags/v1.11.0.tar.gz && \ + tar xzf v1.11.0.tar.gz && \ + cd spdlog-1.11.0 && \ + cmake -Bbuild -H. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local -DBUILD_SHARED_LIBS=ON && \ + cmake --build build -j && \ + cmake --install build + +RUN cd /tmp && \ + wget https://github.com/capnproto/capnproto/archive/refs/tags/v0.10.4.tar.gz && \ + tar xzf v0.10.4.tar.gz && \ + cd capnproto-0.10.4 && \ + cmake -Bbuild -H. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local -DBUILD_SHARED_LIBS=ON && \ + cmake --build build -j && \ + cmake --install build + +COPY . /uda + +RUN cd /uda && \ + cmake -B build \ + -DBUILD_SHARED_LIBS=ON \ + -DCMAKE_BUILD_TYPE=Release \ + -DSSLAUTHENTICATION=ON \ + -DCLIENT_ONLY=ON \ + -DENABLE_CAPNP=ON + +# LD_LIBRARY_PATH needed by capnp scheam generator binary +RUN cd /uda && LD_LIBRARY_PATH=/usr/local/lib64 cmake --build build --config Release + +RUN cd /uda && cmake --install build --config Release + +RUN cp -r /usr/local/python_installer ./python_installer && \ + export LD_LIBRARY_PATH=/usr/local/lib64 && \ + python3 -m venv ./venv && \ + source ./venv/bin/activate && \ + pip3 install Cython numpy && \ + pip3 install ./python_installer && \ + python3 -c 'import pyuda; print(pyuda.__version__)' + diff --git a/docker/client.ubuntu.22.10 b/docker/client.ubuntu.22.10 new file mode 100644 index 00000000..9081be9c --- /dev/null +++ b/docker/client.ubuntu.22.10 @@ -0,0 +1,43 @@ +FROM ubuntu:22.10 + +SHELL ["/bin/bash", "-c"] + +RUN apt-get update && apt-get install -y \ + git \ + libboost-dev \ + libboost-program-options-dev \ + libssl-dev \ + cmake \ + build-essential \ + pkg-config \ + libxml2-dev \ + libspdlog-dev \ + ninja-build \ + capnproto \ + libcapnp-dev \ + python3-dev \ + python3-pip \ + python3-venv + +COPY .. /uda + +RUN cd /uda && \ + cmake -G Ninja -B build \ + -DBUILD_SHARED_LIBS=ON \ + -DCMAKE_BUILD_TYPE=Release \ + -DSSLAUTHENTICATION=ON \ + -DCLIENT_ONLY=ON \ + -DENABLE_CAPNP=ON + +RUN cd /uda && cmake --build build --config Release + +RUN cd /uda && cmake --install build --config Release + +RUN apt-get install -y python3-dev python3-pip python3-venv + +RUN cp -r /usr/local/python_installer ./python_installer && \ + python3 -m venv ./venv && \ + source ./venv/bin/activate && \ + pip3 install Cython numpy && \ + pip3 install ./python_installer && \ + python3 -c 'import pyuda; print(pyuda.__version__)' diff --git a/source/clientserver/protocolXML2Put.cpp b/source/clientserver/protocolXML2Put.cpp index 2a00d310..4c82129b 100755 --- a/source/clientserver/protocolXML2Put.cpp +++ b/source/clientserver/protocolXML2Put.cpp @@ -1361,11 +1361,11 @@ int xdrUserDefinedDataPut(XDR* xdrs, LOGMALLOCLIST* logmalloclist, USERDEFINEDTY addMalloc(logmalloclist, (void*)newNTree->children, loopcount, sizeof(NTREE*), "NTREE *"); } else { // Multiple branches (user types) originating in the same node - NTREE** old = newNTree->children; + auto old = (VOIDTYPE)newNTree->children; newNTree->children = (NTREE**)realloc((void*)old, (newNTree->branches + loopcount) * sizeof(NTREE*)); // Individual node addresses remain valid - changeMalloc(logmalloclist, (void*)old, (void*)newNTree->children, + changeMalloc(logmalloclist, old, (void*)newNTree->children, newNTree->branches + loopcount, sizeof(NTREE*), "NTREE *"); } } diff --git a/source/structures/accessors.cpp b/source/structures/accessors.cpp index 30a7b743..9fa7f15a 100755 --- a/source/structures/accessors.cpp +++ b/source/structures/accessors.cpp @@ -132,15 +132,13 @@ findNTreeStructureComponent2(LOGMALLOCLIST* logmalloclist, NTREE* ntree, const c if ((strchr(target, '.') != nullptr) || strchr(target, '/') != nullptr) { int ntargets; - char** targetlist = nullptr; - NTREE* child = ntree; - - targetlist = parseTarget(target, &ntargets); // Deconstruct the Name and search for each hierarchy group + char** targetlist = parseTarget(target, &ntargets); // Deconstruct the Name and search for each hierarchy group *lastname = targetlist[ntargets - 1]; // Preserve the last element name // Search recursively for the first name + NTREE* child = ntree; if ((child = findNTreeStructureComponent1(child, targetlist[0])) == nullptr) { // Not found return nullptr; @@ -164,22 +162,29 @@ findNTreeStructureComponent2(LOGMALLOCLIST* logmalloclist, NTREE* ntree, const c } addMalloc(logmalloclist, (void*)targetlist[ntargets - 1], (int)strlen(targetlist[ntargets - 1]) + 1, sizeof(char), "char"); - for (int i = 0; i < ntargets - 1; i++) free(targetlist[i]); // Free all others + + const char* last_target = targetlist[ntargets - 1]; + + for (int i = 0; i < ntargets - 1; i++) { + free(targetlist[i]); // Free all others + } free(targetlist); // Free the list // Search the user defined type definition for the last name - return if an atomic type for (int i = 0; i < child->userdefinedtype->fieldcount; i++) { - if (STR_EQUALS(child->userdefinedtype->compoundfield[i].name, targetlist[ntargets - 1]) && + if (STR_EQUALS(child->userdefinedtype->compoundfield[i].name, last_target) && child->userdefinedtype->compoundfield[i].atomictype != UDA_TYPE_UNKNOWN) { - return (child); + return child; } // Atomic type found } // Search child nodes for structured types for (int j = 0; j < child->branches; j++) { - if (STR_EQUALS(child->children[j]->name, targetlist[ntargets - 1])) return child->children[j]; + if (STR_EQUALS(child->children[j]->name, last_target)) { + return child->children[j]; + } } return nullptr; // Not Found @@ -195,7 +200,6 @@ findNTreeStructureComponent2(LOGMALLOCLIST* logmalloclist, NTREE* ntree, const c } return nullptr; // Not found - } /** Find (search type B) and return a Pointer to the named Data Tree Node with a data structure of the same name. @@ -566,7 +570,7 @@ int idam_regulariseVlenStructures(LOGMALLOCLIST* logmalloclist, NTREE* tree, USE void* newnew = nullptr; if (tree->userdefinedtype->idamclass == UDA_TYPE_VLEN && STR_EQUALS(tree->userdefinedtype->name, target)) { - VLENTYPE* vlen = (VLENTYPE*)tree->data; + auto vlen = (VLENTYPE*)tree->data; // VLEN stuctures have only two fields: len and data // Need the size of the data component @@ -576,7 +580,7 @@ int idam_regulariseVlenStructures(LOGMALLOCLIST* logmalloclist, NTREE* tree, USE // VLEN Memory is contiguous so re-allocate: regularise by expanding to a consistent array size (No longer a VLEN!) - void* old = vlen->data; + auto old = (VOIDTYPE)vlen->data; USERDEFINEDTYPE* child = findUserDefinedType(userdefinedtypelist, tree->userdefinedtype->compoundfield[1].type, 0); vlen->data = realloc(vlen->data, count * child->size); // Expand Heap to regularise newnew = vlen->data; @@ -605,7 +609,7 @@ int idam_regulariseVlenStructures(LOGMALLOCLIST* logmalloclist, NTREE* tree, USE if (resetBranches > 0) { tree->branches = count; // Only update once all True children have been regularised - void* old = (void*)tree->children; + auto old = (VOIDTYPE)tree->children; tree->children = (NTREE**)realloc((void*)tree->children, count * sizeof(void*)); unsigned int ui; diff --git a/source/structures/struct.cpp b/source/structures/struct.cpp index cfed54f3..a34e77f8 100755 --- a/source/structures/struct.cpp +++ b/source/structures/struct.cpp @@ -131,7 +131,7 @@ void printSarray(SARRAY str) */ void addNTreeList(LOGMALLOCLIST* logmalloclist, NTREE* node, NTREELIST* ntree_list) { - NTREE* old = ntree_list->forrest; + VOIDTYPE old = (VOIDTYPE)ntree_list->forrest; ntree_list->forrest = (NTREE*)realloc((void*)ntree_list->forrest, (++ntree_list->listCount) * sizeof(NTREE*)); changeMalloc(logmalloclist, old, (void*)ntree_list->forrest, ntree_list->listCount, sizeof(NTREE*), "NTREE *"); ntree_list->forrest[ntree_list->listCount] = *node; @@ -725,18 +725,16 @@ addMalloc2(LOGMALLOCLIST* logmalloclist, void* heap, int count, size_t size, con * @param type The name of the type allocated. * @return void. */ -void changeMalloc(LOGMALLOCLIST* logmalloclist, void* old, void* anew, int count, size_t size, const char* type) +void changeMalloc(LOGMALLOCLIST* logmalloclist, VOIDTYPE old, void* anew, int count, size_t size, const char* type) { // Change a List Entry - - VOIDTYPE target, candidate; // int ok on 32 bit architecture - if (old == nullptr) { + if (old == 0) { addMalloc(logmalloclist, anew, count, size, type); return; } - target = (VOIDTYPE)((VOIDTYPE*)old); + auto target = (VOIDTYPE)((VOIDTYPE*)old); for (int i = 0; i < logmalloclist->listcount; i++) { - candidate = (VOIDTYPE)((VOIDTYPE*)logmalloclist->logmalloc[i].heap); + auto candidate = (VOIDTYPE)((VOIDTYPE*)logmalloclist->logmalloc[i].heap); if (target == candidate) { logmalloclist->logmalloc[i].heap = anew; logmalloclist->logmalloc[i].freed = 0; @@ -3927,29 +3925,31 @@ int getNTreeStructureCount(NTREE* ntree) */ char** getNTreeStructureNames(LOGMALLOCLIST* logmalloclist, NTREE* ntree) { - int count = 1, childcount; - char** names, ** childnames; - void* old; - if (ntree == nullptr) { ntree = udaGetFullNTree(); } - names = (char**)malloc(sizeof(char*)); + + auto names = (char**)malloc(sizeof(char*)); addMalloc(logmalloclist, (void*)names, 1, sizeof(char*), "char *"); names[0] = ntree->name; - if (ntree->branches == 0) return names; + + if (ntree->branches == 0) { + return names; + } + + int count = 1; for (int i = 0; i < ntree->branches; i++) { if (i == 0 || strcmp(ntree->children[i]->userdefinedtype->name, ntree->children[i - 1]->userdefinedtype->name) != 0) { - childcount = getNTreeStructureCount(ntree->children[i]); - old = (void*)names; + int childcount = getNTreeStructureCount(ntree->children[i]); + VOIDTYPE old = (VOIDTYPE)names; names = (char**)realloc((void*)names, (count + childcount) * sizeof(char*)); changeMalloc(logmalloclist, old, (void*)names, (count + childcount), sizeof(char*), "char *"); - childnames = getNTreeStructureNames(logmalloclist, ntree->children[i]); + char** childnames = getNTreeStructureNames(logmalloclist, ntree->children[i]); for (int j = 0; j < childcount; j++) { names[count + j] = childnames[j]; } - count = count + childcount; + count += childcount; } } return names; @@ -3962,25 +3962,24 @@ char** getNTreeStructureNames(LOGMALLOCLIST* logmalloclist, NTREE* ntree) */ char** getNTreeStructureTypes(LOGMALLOCLIST* logmalloclist, NTREE* ntree) { - int count = 1, childcount; - char** names, ** childnames; - void* old; - if (ntree == nullptr) { ntree = udaGetFullNTree(); } - names = (char**)malloc(sizeof(char*)); + + auto names = (char**)malloc(sizeof(char*)); addMalloc(logmalloclist, (void*)names, 1, sizeof(char*), "char *"); names[0] = ntree->userdefinedtype->name; if (ntree->branches == 0) return names; + + int count = 1; for (int i = 0; i < ntree->branches; i++) { if (i == 0 || strcmp(ntree->children[i]->userdefinedtype->name, ntree->children[i - 1]->userdefinedtype->name) != 0) { - childcount = getNTreeStructureCount(ntree->children[i]); - old = (void*)names; + int childcount = getNTreeStructureCount(ntree->children[i]); + VOIDTYPE old = (VOIDTYPE)names; names = (char**)realloc((void*)names, (count + childcount) * sizeof(char*)); changeMalloc(logmalloclist, old, (void*)names, (count + childcount), sizeof(char*), "char *"); - childnames = getNTreeStructureTypes(logmalloclist, ntree->children[i]); + char** childnames = getNTreeStructureTypes(logmalloclist, ntree->children[i]); for (int j = 0; j < childcount; j++) { names[count + j] = childnames[j]; } @@ -4047,30 +4046,29 @@ int getNTreeStructureComponentCount(NTREE* ntree) */ char** getNTreeStructureComponentNames(LOGMALLOCLIST* logmalloclist, NTREE* ntree) { - int count, childcount; - char** names, ** childnames; - void* old; - if (ntree == nullptr) { ntree = udaGetFullNTree(); } - count = ntree->userdefinedtype->fieldcount; + + int count = ntree->userdefinedtype->fieldcount; if (count == 0) { return nullptr; } - names = getNodeStructureComponentNames(ntree); + char** names = getNodeStructureComponentNames(ntree); for (int i = 0; i < ntree->branches; i++) { if (i == 0 || strcmp(ntree->children[i]->userdefinedtype->name, ntree->children[i - 1]->userdefinedtype->name) != 0) { - childcount = getNTreeStructureComponentCount(ntree->children[i]); - old = (void*)names; + int childcount = getNTreeStructureComponentCount(ntree->children[i]); + auto old = (VOIDTYPE)names; names = (char**)realloc((void*)names, (count + childcount) * sizeof(char*)); changeMalloc(logmalloclist, old, (void*)names, (count + childcount), sizeof(char*), "char *"); - childnames = getNTreeStructureComponentNames(logmalloclist, ntree->children[i]); - for (int j = 0; j < childcount; j++) names[count + j] = childnames[j]; - count = count + childcount; + char** childnames = getNTreeStructureComponentNames(logmalloclist, ntree->children[i]); + for (int j = 0; j < childcount; j++) { + names[count + j] = childnames[j]; + } + count += childcount; } } return names; @@ -4083,29 +4081,29 @@ char** getNTreeStructureComponentNames(LOGMALLOCLIST* logmalloclist, NTREE* ntre */ char** getNTreeStructureComponentTypes(LOGMALLOCLIST* logmalloclist, NTREE* ntree) { - int count, childcount; - char** names, ** childnames; - void* old; - if (ntree == nullptr) { ntree = udaGetFullNTree(); } - count = ntree->userdefinedtype->fieldcount; + + int count = ntree->userdefinedtype->fieldcount; if (count == 0) { return nullptr; } - names = getNodeStructureComponentTypes(ntree); + + char** names = getNodeStructureComponentTypes(ntree); for (int i = 0; i < ntree->branches; i++) { if (i == 0 || strcmp(ntree->children[i]->userdefinedtype->name, ntree->children[i - 1]->userdefinedtype->name) != 0) { - childcount = getNTreeStructureComponentCount(ntree->children[i]); - old = (void*)names; + int childcount = getNTreeStructureComponentCount(ntree->children[i]); + auto old = (VOIDTYPE)names; names = (char**)realloc((void*)names, (count + childcount) * sizeof(char*)); changeMalloc(logmalloclist, old, (void*)names, (count + childcount), sizeof(char*), "char *"); - childnames = getNTreeStructureComponentTypes(logmalloclist, ntree->children[i]); - for (int j = 0; j < childcount; j++) names[count + j] = childnames[j]; - count = count + childcount; + char** childnames = getNTreeStructureComponentTypes(logmalloclist, ntree->children[i]); + for (int j = 0; j < childcount; j++) { + names[count + j] = childnames[j]; + } + count += childcount; } } return names; @@ -4118,29 +4116,29 @@ char** getNTreeStructureComponentTypes(LOGMALLOCLIST* logmalloclist, NTREE* ntre */ char** getNTreeStructureComponentDescriptions(LOGMALLOCLIST* logmalloclist, NTREE* ntree) { - int count, childcount; - char** names, ** childnames; - void* old; - if (ntree == nullptr) { ntree = udaGetFullNTree(); } - count = ntree->userdefinedtype->fieldcount; + + int count = ntree->userdefinedtype->fieldcount; if (count == 0) { return nullptr; } - names = getNodeStructureComponentDescriptions(ntree); + + char** names = getNodeStructureComponentDescriptions(ntree); for (int i = 0; i < ntree->branches; i++) { if (i == 0 || strcmp(ntree->children[i]->userdefinedtype->name, ntree->children[i - 1]->userdefinedtype->name) != 0) { - childcount = getNTreeStructureComponentCount(ntree->children[i]); - old = (void*)names; + int childcount = getNTreeStructureComponentCount(ntree->children[i]); + auto old = (VOIDTYPE)names; names = (char**)realloc((void*)names, (count + childcount) * sizeof(char*)); changeMalloc(logmalloclist, old, (void*)names, (count + childcount), sizeof(char*), "char *"); - childnames = getNTreeStructureComponentDescriptions(logmalloclist, ntree->children[i]); - for (int j = 0; j < childcount; j++) names[count + j] = childnames[j]; - count = count + childcount; + char** childnames = getNTreeStructureComponentDescriptions(logmalloclist, ntree->children[i]); + for (int j = 0; j < childcount; j++) { + names[count + j] = childnames[j]; + } + count += childcount; } } return names; diff --git a/source/structures/struct.h b/source/structures/struct.h index 18991c68..a009e961 100755 --- a/source/structures/struct.h +++ b/source/structures/struct.h @@ -267,7 +267,7 @@ addMalloc2(LOGMALLOCLIST* logmalloclist, void* heap, int count, size_t size, con * @param type The name of the type allocated. * @return void. */ -void changeMalloc(LOGMALLOCLIST* logmalloclist, void* old, void* anew, int count, size_t size, const char* type); +void changeMalloc(LOGMALLOCLIST* logmalloclist, VOIDTYPE old, void* anew, int count, size_t size, const char* type); /** Change the logged memory location to a new location (necessary with realloc). * diff --git a/source/structures/xdrUserDefinedData.cpp b/source/structures/xdrUserDefinedData.cpp index a3daf20a..c19a5ed7 100755 --- a/source/structures/xdrUserDefinedData.cpp +++ b/source/structures/xdrUserDefinedData.cpp @@ -1412,11 +1412,11 @@ int xdrUserDefinedData(XDR* xdrs, LOGMALLOCLIST* logmalloclist, USERDEFINEDTYPEL loopcount * sizeof(NTREE*)); // Allocate the node array addMalloc(logmalloclist, (void*)newNTree->children, loopcount, sizeof(NTREE*), "NTREE *"); } else { // Multiple branches (user types) originating in the same node - NTREE** old = newNTree->children; + auto old = (VOIDTYPE)newNTree->children; newNTree->children = (NTREE**)realloc((void*)old, (newNTree->branches + loopcount) * sizeof(NTREE*)); // Individual node addresses remain valid - changeMalloc(logmalloclist, (void*)old, (void*)newNTree->children, + changeMalloc(logmalloclist, old, (void*)newNTree->children, newNTree->branches + loopcount, sizeof(NTREE*), "NTREE *"); } } diff --git a/source/wrappers/c++/scalar.hpp b/source/wrappers/c++/scalar.hpp index 91671aa4..bf04ff4a 100755 --- a/source/wrappers/c++/scalar.hpp +++ b/source/wrappers/c++/scalar.hpp @@ -27,18 +27,18 @@ class LIBRARY_API Scalar : public Data , type_(&typeid(T)) , data_size_(sizeof(T)) { - auto copy = new T; - *copy = value; - raw_data_ = std::shared_ptr(reinterpret_cast(copy)); + auto copy = new unsigned char[sizeof(T)]; + memcpy(copy, &value, sizeof(T)); + raw_data_ = std::shared_ptr(copy); } Scalar(const Scalar& other) = default; Scalar& operator=(const Scalar& other) = default; - size_t size() const override + [[nodiscard]] size_t size() const override { return 0; } - const std::type_info& type() const override + [[nodiscard]] const std::type_info& type() const override { return *type_; } template @@ -47,12 +47,12 @@ class LIBRARY_API Scalar : public Data static Scalar Null; - const unsigned char* byte_data() const override + [[nodiscard]] const unsigned char* byte_data() const override { return raw_data_.get(); } - size_t byte_length() const override + [[nodiscard]] size_t byte_length() const override { return data_size_; } @@ -68,7 +68,7 @@ class LIBRARY_API Scalar : public Data boost::any value_; const std::type_info* type_; - std::shared_ptr raw_data_; + std::shared_ptr raw_data_; size_t data_size_; }; diff --git a/source/wrappers/c++/vector.hpp b/source/wrappers/c++/vector.hpp index 5d8aa573..e82528a8 100755 --- a/source/wrappers/c++/vector.hpp +++ b/source/wrappers/c++/vector.hpp @@ -28,15 +28,15 @@ class LIBRARY_API Vector : public Data { , type_(&typeid(T)) , data_size_(size * sizeof(T)) { - auto copy = new T[size]; + auto copy = new unsigned char[size * sizeof(T)]; memcpy(copy, array, size * sizeof(T)); - raw_data_ = std::shared_ptr(reinterpret_cast(copy)); + raw_data_ = std::shared_ptr(copy); } Vector(const Vector& other) = default; Vector& operator=(const Vector& other) = default; - const std::type_info& type() const override + [[nodiscard]] const std::type_info& type() const override { return *type_; } template @@ -51,17 +51,17 @@ class LIBRARY_API Vector : public Data { T at(size_t idx) const { return boost::any_cast(vec_[idx]); } - size_t size() const override + [[nodiscard]] size_t size() const override { return vec_.size(); } static Vector Null; - const unsigned char* byte_data() const override + [[nodiscard]] const unsigned char* byte_data() const override { return raw_data_.get(); } - size_t byte_length() const override + [[nodiscard]] size_t byte_length() const override { return data_size_; } @@ -78,7 +78,7 @@ class LIBRARY_API Vector : public Data { private: std::vector vec_; const std::type_info* type_; - std::shared_ptr raw_data_; + std::shared_ptr raw_data_; size_t data_size_; template diff --git a/source/wrappers/matlab/dm_example.c b/source/wrappers/matlab/dm_example.c index fbd63126..e5ad1367 100755 --- a/source/wrappers/matlab/dm_example.c +++ b/source/wrappers/matlab/dm_example.c @@ -6,10 +6,9 @@ int main() { - int handle, nmax, ndata, rank, i, irank; - float * fvec = NULL; - double * dvec = NULL; + float* fvec = NULL; + double* dvec = NULL; int type; @@ -47,23 +46,23 @@ int main() type = getIdamDataType(handle); switch (type) { - case (UDA_TYPE_FLOAT): - fvec = (float *) getIdamData(handle); // pointer to the Data + case (UDA_TYPE_FLOAT): + fvec = (float*)getIdamData(handle); // pointer to the Data - for (int i = 0; i < nmax; i++) { - fprintf(stdout, "%d %f\n", i, fvec[i]); // print some data - } + for (int i = 0; i < nmax; i++) { + fprintf(stdout, "%d %f\n", i, fvec[i]); // print some data + } - break; + break; - case (UDA_TYPE_DOUBLE): - dvec = (double *) getIdamData(handle); + case (UDA_TYPE_DOUBLE): + dvec = (double*)getIdamData(handle); - for (int i = 0; i < nmax; i++) { - fprintf(stdout, "%d %f\n", i, dvec[i]); - } + for (int i = 0; i < nmax; i++) { + fprintf(stdout, "%d %f\n", i, dvec[i]); + } - break; + break; } rank = getIdamRank(handle); @@ -99,23 +98,23 @@ int main() type = getIdamDimType(handle, irank); switch (type) { - case (UDA_TYPE_FLOAT): - fvec = (float *) getIdamDimData(handle, irank); // pointer to the Dimension?s Data + case (UDA_TYPE_FLOAT): + fvec = (float*)getIdamDimData(handle, irank); // pointer to the Dimension?s Data - for (int i = 0; i < nmax; i++) { - fprintf(stdout, "%d %f\n", i, fvec[i]); // print some data - } + for (int i = 0; i < nmax; i++) { + fprintf(stdout, "%d %f\n", i, fvec[i]); // print some data + } - break; + break; - case (UDA_TYPE_DOUBLE): - dvec = (double *) getIdamDimData(handle, irank); + case (UDA_TYPE_DOUBLE): + dvec = (double*)getIdamDimData(handle, irank); - for (int i = 0; i < nmax; i++) { - fprintf(stdout, "%d %f\n", i, dvec[i]); - } + for (int i = 0; i < nmax; i++) { + fprintf(stdout, "%d %f\n", i, dvec[i]); + } - break; + break; } } diff --git a/source/wrappers/matlab/getData.m b/source/wrappers/matlab/getData.m index f1cbf0c7..7adc2b08 100755 --- a/source/wrappers/matlab/getData.m +++ b/source/wrappers/matlab/getData.m @@ -82,8 +82,6 @@ xlabel([s.TimeLabel ' ' s.TimeUnits], 'Interpreter', 'none') ylabel([s.DataLabel ' ' s.DataUnits], 'Interpreter', 'none') title([s.Name ' ' s.Source], 'Interpreter', 'none') - - end end diff --git a/source/wrappers/matlab/getIdamData.c b/source/wrappers/matlab/getIdamData.c index 672aa79e..cdccce67 100755 --- a/source/wrappers/matlab/getIdamData.c +++ b/source/wrappers/matlab/getIdamData.c @@ -1,11 +1,3 @@ -/* V3 output in a cell array - -Change History - -20May2010 dgm Changed to IDAM accessors getIdamDoubleData, getIdamDoubleDimData to cast atomic types to double. ------------------------------------------------------------------------------------------------------------------------- -*/ - #include "stdio.h" #include "string.h" #include "idammatlab.h" @@ -16,31 +8,31 @@ Change History int listIndex; -void addItem(mxArray * list, const mxArray * item) +void addItem(mxArray* list, const mxArray* item) { if (listIndex >= NFIELDS) { mexErrMsgTxt("Too many items"); } else { - mxSetCell(list, listIndex, (mxArray *)item); + mxSetCell(list, listIndex, (mxArray*)item); listIndex++; } } -void mexFunction(int nlhs, mxArray * plhs[], int nrhs, const mxArray * prhs[]) +void mexFunction(int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[]) { /* Matlab related data */ - mxArray * item; - double * ptr; - char * name, *source; + mxArray* item; + double* ptr; + char* name, * source; int ndata, erc; /* IDAM related data */ int handle, rank, order; - int * ivec = NULL; - float * fvec = NULL; - double * dvec = NULL; + int* ivec = NULL; + float* fvec = NULL; + double* dvec = NULL; if ((nlhs != 1) || (nrhs != 2)) { mexErrMsgTxt("One output and two inputs needed"); @@ -100,14 +92,12 @@ void mexFunction(int nlhs, mxArray * plhs[], int nrhs, const mxArray * prhs[]) ptr = mxGetPr(item); // Cast atomic data types to double - getIdamDoubleData(handle, ptr); - addItem(OUT, item); /* Error Data */ - char * error = getIdamError(handle); + char* error = getIdamError(handle); if (error != NULL) { addItem(OUT, mxCreateString("Error")); @@ -118,10 +108,8 @@ void mexFunction(int nlhs, mxArray * plhs[], int nrhs, const mxArray * prhs[]) ptr = mxGetPr(item); // Cast atomic data types to double - // Fudge as required accessor not in library - small loss of precision! - - float * fp = (float *) malloc( ndata * sizeof(float)); + float* fp = (float*)malloc(ndata * sizeof(float)); getIdamFloatError(handle, fp); for (int i = 0; i < ndata; i++) { @@ -152,9 +140,7 @@ void mexFunction(int nlhs, mxArray * plhs[], int nrhs, const mxArray * prhs[]) ptr = mxGetPr(item); // Cast atomic data types to double - getIdamDoubleDimData(handle, i, ptr); - addItem(OUT, item); } } diff --git a/source/wrappers/matlab/getIdamDoubleData.c b/source/wrappers/matlab/getIdamDoubleData.c index b01b6904..27bc1607 100755 --- a/source/wrappers/matlab/getIdamDoubleData.c +++ b/source/wrappers/matlab/getIdamDoubleData.c @@ -1,11 +1,3 @@ -/* V3 output in a cell array - -Change History - -20May2010 dgm Changed to IDAM accessors getIdamDoubleData, getIdamDoubleDimData to cast atomic types to double. ------------------------------------------------------------------------------------------------------------------------- -*/ - #include "stdio.h" #include "string.h" #include "idammatlab.h" @@ -16,7 +8,7 @@ Change History int listIndex; -void addItem(mxArray * list, const mxArray * item) +void addItem(mxArray* list, const mxArray* item) { if (listIndex >= NFIELDS) { mexErrMsgTxt("Too many items"); @@ -26,21 +18,21 @@ void addItem(mxArray * list, const mxArray * item) } } -void mexFunction(int nlhs, mxArray * plhs[], int nrhs, const mxArray * prhs[]) +void mexFunction(int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[]) { /* Matlab related data */ - mxArray * item; - double * ptr; - char * name, *source; + mxArray* item; + double* ptr; + char* name, * source; int ndata, erc; /* IDAM related data */ int handle, rank, order; - int * ivec = NULL; - float * fvec = NULL; - double * dvec = NULL; + int* ivec = NULL; + float* fvec = NULL; + double* dvec = NULL; if ((nlhs != 1) || (nrhs != 2)) { mexErrMsgTxt("One output and two inputs needed"); @@ -100,12 +92,9 @@ void mexFunction(int nlhs, mxArray * plhs[], int nrhs, const mxArray * prhs[]) ptr = mxGetPr(item); // Cast atomic data types to double - getIdamDoubleData(handle, ptr); - addItem(OUT, item); - /* do the same for the dimensions */ order = getIdamOrder(handle); @@ -126,9 +115,7 @@ void mexFunction(int nlhs, mxArray * plhs[], int nrhs, const mxArray * prhs[]) ptr = mxGetPr(item); // Cast atomic data types to double - getIdamDoubleDimData(handle, i, ptr); - addItem(OUT, item); } } diff --git a/source/wrappers/python/CMakeLists.txt b/source/wrappers/python/CMakeLists.txt index b4e37027..7db55cd1 100755 --- a/source/wrappers/python/CMakeLists.txt +++ b/source/wrappers/python/CMakeLists.txt @@ -15,7 +15,7 @@ find_package( LibMemcached QUIET ) find_package( fmt REQUIRED ) find_package( TIRPC QUIET ) -set( UDA_LIBS ) +set( UDA_LIBS ) set( EXTRA_LIBS ${EXTRA_LIBS} fmt ) if( LIBMEMCACHED_FOUND ) From a250bec671a4f02d11de68b0751e647b36b748f4 Mon Sep 17 00:00:00 2001 From: Jonathan Hollocombe Date: Tue, 4 Jul 2023 09:17:24 +0100 Subject: [PATCH 10/39] Trying to fix GitHub macOS runner. --- .github/workflows/cmake.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index efa87452..3e7bd558 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -57,7 +57,7 @@ jobs: - name: Install macos dependencies if: matrix.os == 'macos-latest' run: > - brew update && brew install + brew update-reset && brew install git boost openssl From 529f0352d9af0a5638125e0e8e32d91f13cbee18 Mon Sep 17 00:00:00 2001 From: Jonathan Hollocombe Date: Tue, 4 Jul 2023 09:24:37 +0100 Subject: [PATCH 11/39] Fixing Java wrapper build. --- source/wrappers/java/idam_jni.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/wrappers/java/idam_jni.c b/source/wrappers/java/idam_jni.c index b81d7096..0efaa344 100755 --- a/source/wrappers/java/idam_jni.c +++ b/source/wrappers/java/idam_jni.c @@ -68,12 +68,12 @@ JNIEXPORT void JNICALL Java_jIdam_Idam_idamCleanAllLocksMT(JNIEnv* env, jobject JNIEXPORT void JNICALL Java_jIdam_Idam_idamFree(JNIEnv* env, jobject obj, jint handle) { - idamFree((int)handle); + udaFree((int)handle); } JNIEXPORT void JNICALL Java_jIdam_Idam_idamFreeAll(JNIEnv* env, jobject obj) { -// udaFreeAll(); + udaFreeAll(); } From 4624658c6a0e90ed786f9ba864ce68aa0d18ca7d Mon Sep 17 00:00:00 2001 From: Jonathan Hollocombe Date: Tue, 4 Jul 2023 10:25:41 +0100 Subject: [PATCH 12/39] Reducing Boost version dependency to allow to build on CentOS 8. --- source/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index 2d7dbaa5..f67ef6f5 100755 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -1,7 +1,7 @@ if( NOT CLIENT_ONLY ) include( LibXml2StrPrintfConfig ) endif() -find_package( Boost 1.69 REQUIRED ) +find_package( Boost 1.60 REQUIRED ) include_directories( SYSTEM ${Boost_INCLUDE_DIR} ) # Hack to build on GCC/12.2.0 From c31900c823c1f48df1967dcaa82b95bc5fbbe988 Mon Sep 17 00:00:00 2001 From: Jonathan Hollocombe Date: Tue, 4 Jul 2023 10:52:00 +0100 Subject: [PATCH 13/39] Reducing Boost version dependency to allow to build on CentOS 8. --- .github/workflows/cmake.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index 3e7bd558..2a5acb54 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -53,6 +53,7 @@ jobs: python3-dev python3-pip python3-venv + cython3 - name: Install macos dependencies if: matrix.os == 'macos-latest' @@ -67,6 +68,7 @@ jobs: spdlog ninja capnp + cython - name: Configure CMake (linux) if: matrix.os == 'ubuntu-latest' From a68873bc249d3389bb544a74a0a4690e25c75814 Mon Sep 17 00:00:00 2001 From: Jonathan Hollocombe Date: Tue, 4 Jul 2023 11:04:16 +0100 Subject: [PATCH 14/39] Removing pyuda install from macOS CI build due to weird cython issue. --- .github/workflows/cmake.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index 2a5acb54..b5afbbde 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -53,7 +53,6 @@ jobs: python3-dev python3-pip python3-venv - cython3 - name: Install macos dependencies if: matrix.os == 'macos-latest' @@ -68,7 +67,6 @@ jobs: spdlog ninja capnp - cython - name: Configure CMake (linux) if: matrix.os == 'ubuntu-latest' @@ -98,6 +96,7 @@ jobs: run: sudo cmake --install ${{github.workspace}}/build --config ${{ matrix.release }} - name: Install pyuda + if: matrix.os == 'ubuntu-latest' run: > cp -r /usr/local/python_installer ${{github.workspace}}/python_installer && python3 -m venv ${{github.workspace}}/venv && @@ -106,6 +105,7 @@ jobs: pip3 install ${{github.workspace}}/python_installer - name: Test pyuda import + if: matrix.os == 'ubuntu-latest' run: > source ${{github.workspace}}/venv/bin/activate && python3 -c 'import pyuda; client=pyuda.Client()' From 70fae814c0011222fae57ff1bdd66b00bfa8aa73 Mon Sep 17 00:00:00 2001 From: Jonathan Hollocombe Date: Tue, 4 Jul 2023 15:59:32 +0100 Subject: [PATCH 15/39] ITER CODAC changes --- CMakeLists.txt | 8 ++++---- extlib/portablexdr-4.9.1/CMakeLists.txt | 6 +++--- extlib/portablexdr-4.9.1/rpc/types.h | 4 +--- source/CMakeLists.txt | 3 ++- source/client/CMakeLists.txt | 4 +++- source/client/connection.cpp | 4 ++-- source/client/makeClientRequestBlock.cpp | 21 +++++++++------------ source/client/makeClientRequestBlock.h | 1 + source/client/udaClient.cpp | 16 +++++++--------- source/client/udaGetAPI.cpp | 3 ++- source/clientserver/CMakeLists.txt | 1 + source/clientserver/compressDim.cpp | 11 ++++------- source/clientserver/makeRequestBlock.cpp | 4 +++- source/clientserver/manageSockets.cpp | 1 + source/structures/CMakeLists.txt | 1 + 15 files changed, 44 insertions(+), 44 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0893ed5b..993c219a 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,8 +14,8 @@ endmacro() macro( CONVERT_LIN_PATH VarName ) if( MINGW AND NOT "${${VarName}}" STREQUAL "" ) execute_process( COMMAND cygpath.exe -m ${${VarName}} OUTPUT_VARIABLE ${VarName} ) - string( STRIP ${${VarName}} ${VarName} ) - string( REGEX REPLACE "[\r\n]+" ";" ${VarName} ${${VarName}} ) + string( STRIP "${${VarName}}" ${VarName} ) + string( REGEX REPLACE "[\r\n]+" ";" ${VarName} "${${VarName}}" ) endif() endmacro() @@ -107,12 +107,11 @@ else() endif() endif() -if( NOT WIN32 OR MINGW ) +if( NOT WIN32 ) set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC -pthread -Wno-implicit-function-declaration" ) set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -pthread" ) if( MINGW ) - add_definitions( -D_WIN32 ) add_definitions( -DMINGW ) endif() @@ -224,6 +223,7 @@ if( WIN32 OR MINGW ) DESTINATION lib FILES_MATCHING PATTERN "*xdr*" ) + return() endif() ######################################################################################################################## diff --git a/extlib/portablexdr-4.9.1/CMakeLists.txt b/extlib/portablexdr-4.9.1/CMakeLists.txt index 93385d5d..30ead0a3 100644 --- a/extlib/portablexdr-4.9.1/CMakeLists.txt +++ b/extlib/portablexdr-4.9.1/CMakeLists.txt @@ -4,13 +4,13 @@ cmake_policy( SET CMP0048 NEW ) project( xdr VERSION 4.9.1 ) -if( NOT WIN32 OR MINGW ) +if( NOT WIN32 ) set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Werror -fno-strict-aliasing" ) endif() include( TestBigEndian ) -if( WIN32 OR MINGW ) +if( WIN32 ) add_definitions( -DBIG_ENDIAN=1 -DLITTLE_ENDIAN=2 ) test_big_endian( BIG_ENDIAN ) @@ -30,5 +30,5 @@ configure_file( include_directories( ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR} ) -add_library( ${PROJECT_NAME} ${SOURCES} ) +add_library( ${PROJECT_NAME} SHARED ${SOURCES} ) diff --git a/extlib/portablexdr-4.9.1/rpc/types.h b/extlib/portablexdr-4.9.1/rpc/types.h index ee487dd3..1409ecfa 100644 --- a/extlib/portablexdr-4.9.1/rpc/types.h +++ b/extlib/portablexdr-4.9.1/rpc/types.h @@ -71,9 +71,7 @@ typedef char * caddr_t; //#include #ifndef INADDR_LOOPBACK -# if defined(__GNUC__) -# define INADDR_LOOPBACK (u_long)0x7F000001 -# endif +# define INADDR_LOOPBACK (u_long)0x7F000001 #endif #ifndef MAXHOSTNAMELEN # define MAXHOSTNAMELEN 64 diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index f67ef6f5..9cb33e27 100755 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -14,6 +14,7 @@ endif() find_package( LibXml2 REQUIRED ) if( WIN32 AND NOT MINGW ) + add_compile_definitions( MINGW ) add_definitions( /W2 /WX ) else() add_definitions( -Wall -Werror -Wextra -Wno-unused-parameter -Wno-missing-field-initializers ) @@ -67,7 +68,7 @@ if( WIN32 AND NOT MINGW ) else() execute_process( COMMAND which env OUTPUT_VARIABLE ENV_PATH ) endif() -string( STRIP ${ENV_PATH} ENV_PATH ) +string( STRIP "${ENV_PATH}" ENV_PATH ) find_program( PYTHON_EXE NAMES python python3 PATHS /usr/bin/ ) diff --git a/source/client/CMakeLists.txt b/source/client/CMakeLists.txt index 945493a8..4db914e2 100755 --- a/source/client/CMakeLists.txt +++ b/source/client/CMakeLists.txt @@ -9,6 +9,8 @@ if( WIN32 OR MINGW ) find_package( XDR REQUIRED ) if( NOT MINGW ) find_package( dlfcn-win32 CONFIG REQUIRED ) + else() + find_package( dlfcn-win32 REQUIRED ) endif() else() find_package( TIRPC QUIET ) @@ -116,7 +118,7 @@ if( MINGW OR WIN32 ) include_directories( ${XDR_INCLUDE_DIR} ) set( CLIENT_LINK_LIBS ${CLIENT_LINK_LIBS} ws2_32 ${XDR_LIBRARIES} ) if ( MINGW ) - set( CLIENT_LINK_LIBS ${CLIENT_LINK_LIBS} dl stdc++ ) + set( CLIENT_LINK_LIBS ${CLIENT_LINK_LIBS} dlfcn-win32::dl stdc++ pthread ) else() set( CLIENT_LINK_LIBS ${CLIENT_LINK_LIBS} dlfcn-win32::dl ) endif() diff --git a/source/client/connection.cpp b/source/client/connection.cpp index a4dad3c0..3523a5e0 100755 --- a/source/client/connection.cpp +++ b/source/client/connection.cpp @@ -93,7 +93,7 @@ int reconnect(ENVIRONMENT* environment, XDR** client_input, XDR** client_output, int status; int fh; if (getSocket(&client_socketlist, TYPE_UDA_SERVER, &status, environment->server_host, environment->server_port, &fh) == 0) { - environment->server_socket=fh; + environment->server_socket = fh; environment->server_change_socket = 1; } else { time(tv_server_start); // Start a New Server AGE timer @@ -104,7 +104,7 @@ int reconnect(ENVIRONMENT* environment, XDR** client_input, XDR** client_output, // Client manages connections through the Socket id and specifies which running server to connect to - if (environment->server_change_socket){ + if (environment->server_change_socket) { int newsocketId; if ((newsocketId = getSocketRecordId(&client_socketlist, environment->server_socket)) < 0) { err = NO_SOCKET_CONNECTION; diff --git a/source/client/makeClientRequestBlock.cpp b/source/client/makeClientRequestBlock.cpp index 52039271..c1f2a861 100755 --- a/source/client/makeClientRequestBlock.cpp +++ b/source/client/makeClientRequestBlock.cpp @@ -152,19 +152,16 @@ int makeClientRequestBlock(const char** signals, const char** sources, int count return err; } -void freeClientRequestBlock(REQUEST_BLOCK* request_block){ - int i=0; - if(request_block!=NULL && request_block->requests!=NULL){ - for(i=0;inum_requests;i++){ - freeNameValueList(&request_block->requests[i].nameValueList); - freeClientPutDataBlockList(&request_block->requests[i].putDataBlockList); - - - } - free(request_block->requests); - request_block->requests=NULL; - } +void freeClientRequestBlock(REQUEST_BLOCK* request_block) { + if(request_block != nullptr && request_block->requests != nullptr) { + for (int i = 0; i < request_block->num_requests; i++) { + freeNameValueList(&request_block->requests[i].nameValueList); + freeClientPutDataBlockList(&request_block->requests[i].putDataBlockList); + } + free(request_block->requests); + request_block->requests = nullptr; + } } int shotRequestTest(const char* source) diff --git a/source/client/makeClientRequestBlock.h b/source/client/makeClientRequestBlock.h index 9967107f..6e8af6eb 100755 --- a/source/client/makeClientRequestBlock.h +++ b/source/client/makeClientRequestBlock.h @@ -11,6 +11,7 @@ extern "C" { LIBRARY_API int makeClientRequestBlock(const char** signals, const char** sources, int count, REQUEST_BLOCK* request_block); LIBRARY_API void freeClientRequestBlock(REQUEST_BLOCK* request_block); + #ifdef __cplusplus } #endif diff --git a/source/client/udaClient.cpp b/source/client/udaClient.cpp index 3335ad98..4ce8d76a 100755 --- a/source/client/udaClient.cpp +++ b/source/client/udaClient.cpp @@ -516,7 +516,12 @@ int idamClient(REQUEST_BLOCK* request_block, int* indices) startupStates = 0; # endif time(&tv_server_start); // Start the Clock again: Age of Server - if ((createConnection(client_input, client_output, &tv_server_start,client_flags->user_timeout)) != 0) { + + //------------------------------------------------------------------------- + // Create the XDR Record Streams + std::tie(client_input, client_output) = clientCreateXDRStream(); + + if ((createConnection(client_input, client_output, &tv_server_start, client_flags->user_timeout)) != 0) { err = NO_SOCKET_CONNECTION; addIdamError(UDA_CODE_ERROR_TYPE, __func__, err, "No Socket Connection to Server"); break; @@ -534,13 +539,6 @@ int idamClient(REQUEST_BLOCK* request_block, int* indices) # endif //------------------------------------------------------------------------- - // Create the XDR Record Streams - - if (initServer) { - std::tie(client_input, client_output) = clientCreateXDRStream(); - } - - //------------------------------------------------------------------------- #else // <========================== End of Client Server Code Only bool initServer = true; @@ -1038,7 +1036,7 @@ int idamClient(REQUEST_BLOCK* request_block, int* indices) UDA_LOG(UDA_LOG_DEBUG, "serverside : %d\n", serverside); free(cached_data_block_list.data); - cached_data_block_list.data = NULL; + cached_data_block_list.data = nullptr; #ifndef FATCLIENT // <========================== Client Server Code Only diff --git a/source/client/udaGetAPI.cpp b/source/client/udaGetAPI.cpp index f3b7e347..3c1fd02d 100755 --- a/source/client/udaGetAPI.cpp +++ b/source/client/udaGetAPI.cpp @@ -243,7 +243,8 @@ int idamGetAPIWithHost(const char* data_object, const char* data_source, const c #ifdef MEMDEBUG muntrace(); #endif -freeClientRequestBlock(&request_block); + + freeClientRequestBlock(&request_block); // Unlock the thread unlockUdaThread(client_flags); return handle; diff --git a/source/clientserver/CMakeLists.txt b/source/clientserver/CMakeLists.txt index d827f3fe..5bbd15c9 100755 --- a/source/clientserver/CMakeLists.txt +++ b/source/clientserver/CMakeLists.txt @@ -109,6 +109,7 @@ include_directories( if( MINGW OR WIN32 ) include_directories( ${XDR_INCLUDE_DIR} ) + add_compile_options( -Wno-error=use-after-free ) elseif( TIRPC_FOUND ) include_directories( ${TIRPC_INCLUDE_DIR} ) endif() diff --git a/source/clientserver/compressDim.cpp b/source/clientserver/compressDim.cpp index ab748e7d..2eefbd87 100755 --- a/source/clientserver/compressDim.cpp +++ b/source/clientserver/compressDim.cpp @@ -22,18 +22,15 @@ template <> double Precision::precision = DBL_EPSILON; template int compress(DIMS* ddim) { - if (ddim->compressed == 1) { - // already compressed - nothing to do. - return 0; - } - T* dim_data = (T*)ddim->dim; if (dim_data == nullptr) { - return 0; + return 1; } int ndata = ddim->dim_n; - if (ndata <= 1){ + + //no need to compress if the data is already compressed or if there are less or equal to 2 elements + if (ndata <= 3 || ddim->compressed == 1) { // prevent divide by 0 errors or accessing out-of-range memory return 1; } diff --git a/source/clientserver/makeRequestBlock.cpp b/source/clientserver/makeRequestBlock.cpp index ab7d6c02..7047a02d 100644 --- a/source/clientserver/makeRequestBlock.cpp +++ b/source/clientserver/makeRequestBlock.cpp @@ -1459,7 +1459,9 @@ void parse_name_value(const char* pair, NAMEVALUE* nameValue, unsigned short str // Regardless of whether or not the Value is not enclosed in quotes, strip out a possible closing parenthesis character (seen in placeholder value substitution) // This would not be a valid value unless at the end of a string enclosed in quotes! lstr = (int)strlen(nameValue->value); - if (nameValue->value[lstr - 1] == ')') nameValue->value[lstr - 1] = '\0'; + if (nameValue->value[lstr - 1] == ')' && strchr(nameValue->value, '(') == nullptr) { + nameValue->value[lstr - 1] = '\0'; + } UDA_LOG(UDA_LOG_DEBUG, "Name: %s Value: %s\n", nameValue->name, nameValue->value); if (strip) { // remove enclosing single or double quotes diff --git a/source/clientserver/manageSockets.cpp b/source/clientserver/manageSockets.cpp index dba12aad..eb16e6ae 100755 --- a/source/clientserver/manageSockets.cpp +++ b/source/clientserver/manageSockets.cpp @@ -10,6 +10,7 @@ # include # include #else +# include # include # define strcasecmp _stricmp # include diff --git a/source/structures/CMakeLists.txt b/source/structures/CMakeLists.txt index b780d2b2..22e4d75d 100755 --- a/source/structures/CMakeLists.txt +++ b/source/structures/CMakeLists.txt @@ -29,6 +29,7 @@ include_directories( if( MINGW OR WIN32 ) include_directories( ${XDR_INCLUDE_DIR} ) + add_compile_options( -Wno-error=use-after-free ) elseif( TIRPC_FOUND ) include_directories( ${TIRPC_INCLUDE_DIR} ) endif() From 6a9deffe784a6dd39e7ae38e5d90664f21d297bd Mon Sep 17 00:00:00 2001 From: Jonathan Hollocombe Date: Fri, 28 Jul 2023 14:21:10 +0100 Subject: [PATCH 16/39] Fixing memory leak in pyuda treenode data. --- source/wrappers/python/pyuda/cpyuda/tree_node.pyx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/wrappers/python/pyuda/cpyuda/tree_node.pyx b/source/wrappers/python/pyuda/cpyuda/tree_node.pyx index 6b5c34b9..6a5285f5 100644 --- a/source/wrappers/python/pyuda/cpyuda/tree_node.pyx +++ b/source/wrappers/python/pyuda/cpyuda/tree_node.pyx @@ -59,7 +59,7 @@ cdef class TreeNode: cdef int* shape = ashape[idx] cdef void* data = uda.getNodeStructureComponentData(logmalloclist, self._node, name) - return to_python_c(type, rank, shape, point, data, self) + return to_python_c(type, rank, shape, point, data, self._handle) cdef _import_data(self): cdef uda.LOGMALLOCLIST* logmalloclist = uda.getIdamLogMallocList(self._handle) From 8cd634f84b7b8c27982a6db818a1d7ec4075fdda Mon Sep 17 00:00:00 2001 From: Jonathan Hollocombe Date: Mon, 31 Jul 2023 09:46:48 +0200 Subject: [PATCH 17/39] Fixing issue with inheriting from int in Cython 3.0 --- .../python/pyuda/cpyuda/capnp_tree.pyx | 2 + source/wrappers/python/pyuda/cpyuda/dim.pyx | 16 +++---- .../wrappers/python/pyuda/cpyuda/handle.pyx | 2 +- .../wrappers/python/pyuda/cpyuda/result.pyx | 42 +++++++++---------- 4 files changed, 32 insertions(+), 30 deletions(-) diff --git a/source/wrappers/python/pyuda/cpyuda/capnp_tree.pyx b/source/wrappers/python/pyuda/cpyuda/capnp_tree.pyx index fb7a8180..027f6294 100644 --- a/source/wrappers/python/pyuda/cpyuda/capnp_tree.pyx +++ b/source/wrappers/python/pyuda/cpyuda/capnp_tree.pyx @@ -75,6 +75,8 @@ cdef class CapnpTreeNode: cdef int np_type = uda_type_to_numpy_type(type) self._data = np.PyArray_SimpleNew(rank, np_shape, np_type) + np.PyArray_SetBaseObject(self._data, self._handle) + Py_INCREF(self._handle) free(np_shape) diff --git a/source/wrappers/python/pyuda/cpyuda/dim.pyx b/source/wrappers/python/pyuda/cpyuda/dim.pyx index 15ce445c..7a207705 100644 --- a/source/wrappers/python/pyuda/cpyuda/dim.pyx +++ b/source/wrappers/python/pyuda/cpyuda/dim.pyx @@ -19,35 +19,35 @@ cdef class Dim: self._data_type = data_type def label(self): - cdef const char* label = uda.getIdamDimLabel(self._handle, self._num) + cdef const char* label = uda.getIdamDimLabel(int(self._handle), self._num) return label.decode(errors='replace') def units(self): - cdef const char* units = uda.getIdamDimUnits(self._handle, self._num) + cdef const char* units = uda.getIdamDimUnits(int(self._handle), self._num) return units.decode(errors='replace') cdef int _size(self): - cdef int size = uda.getIdamDimNum(self._handle, self._num) + cdef int size = uda.getIdamDimNum(int(self._handle), self._num) return size cdef int _type(self): - cdef int type = uda.getIdamDimType(self._handle, self._num) + cdef int type = uda.getIdamDimType(int(self._handle), self._num) return type def type(self): cdef int type if self._data_type == DataType.DATA: - type = uda.getIdamDimType(self._handle, self._num) + type = uda.getIdamDimType(int(self._handle), self._num) else: - type = uda.getIdamDimErrorType(self._handle, self._num) + type = uda.getIdamDimErrorType(int(self._handle), self._num) return type cdef const char* _data(self): cdef const char* data if self._data_type == DataType.DATA: - data = uda.getIdamDimData(self._handle, self._num) + data = uda.getIdamDimData(int(self._handle), self._num) else: - data = uda.getIdamDimError(self._handle, self._num) + data = uda.getIdamDimError(int(self._handle), self._num) return data def data(self): diff --git a/source/wrappers/python/pyuda/cpyuda/handle.pyx b/source/wrappers/python/pyuda/cpyuda/handle.pyx index 7cc35279..5d5e9777 100644 --- a/source/wrappers/python/pyuda/cpyuda/handle.pyx +++ b/source/wrappers/python/pyuda/cpyuda/handle.pyx @@ -5,7 +5,7 @@ Handle class, a thin wrapper around a handle integer that is refcounted. cimport uda -cdef class Handle(int): +cdef class Handle: cdef int _handle def __init__(self, handle): diff --git a/source/wrappers/python/pyuda/cpyuda/result.pyx b/source/wrappers/python/pyuda/cpyuda/result.pyx index 45bd61a4..ffd32b48 100644 --- a/source/wrappers/python/pyuda/cpyuda/result.pyx +++ b/source/wrappers/python/pyuda/cpyuda/result.pyx @@ -37,33 +37,33 @@ cdef class Result: self._meta["pass_date"] = source.pass_date def error_message(self): - return uda.getIdamErrorMsg(self._handle) + return uda.getIdamErrorMsg(int(self._handle)) def error_code(self): - return uda.getIdamErrorCode(self._handle) + return uda.getIdamErrorCode(int(self._handle)) def rank(self): - cdef int rank = uda.getIdamRank(self._handle) + cdef int rank = uda.getIdamRank(int(self._handle)) return rank cdef int _size(self): - cdef int size = uda.getIdamDataNum(self._handle) + cdef int size = uda.getIdamDataNum(int(self._handle)) return size cdef int _type(self, int data_type): cdef int type if data_type == DataType.DATA: - type = uda.getIdamDataType(self._handle) + type = uda.getIdamDataType(int(self._handle)) else: - type = uda.getIdamErrorType(self._handle) + type = uda.getIdamErrorType(int(self._handle)) return type def is_string(self): - cdef int type = uda.getIdamDataType(self._handle) + cdef int type = uda.getIdamDataType(int(self._handle)) return type == 17 def is_capnp(self): - cdef int type = uda.getIdamDataType(self._handle) + cdef int type = uda.getIdamDataType(int(self._handle)) IF CAPNP: return type == 22 ELSE: @@ -80,16 +80,16 @@ cdef class Result: cdef const char* _get_data(self, int data_type): cdef const char* data if data_type == DataType.DATA: - data = uda.getIdamData(self._handle) + data = uda.getIdamData(int(self._handle)) else: - data = uda.getIdamError(self._handle) + data = uda.getIdamError(int(self._handle)) return data cdef _data(self, int data_type): cdef const char* data = self._get_data(data_type) cdef int size cdef int type = self._type(data_type) - cdef int rank = uda.getIdamRank(self._handle) + cdef int rank = uda.getIdamRank(int(self._handle)) cdef int i cdef np.npy_intp shape[1024] if rank == 0: @@ -97,7 +97,7 @@ cdef class Result: shape[0] = size else: for i in range(rank): - size = uda.getIdamDimNum(self._handle, rank - 1 - i) + size = uda.getIdamDimNum(int(self._handle), rank - 1 - i) shape[i] = size arr = to_python_i(type, rank, shape, data) if isinstance(arr, np.ndarray): @@ -112,19 +112,19 @@ cdef class Result: return self._data(DataType.ERRORS) def label(self): - return uda.getIdamDataLabel(self._handle).decode(errors='replace') if self._handle >= 0 else "" + return uda.getIdamDataLabel(int(self._handle)).decode(errors='replace') if int(self._handle) >= 0 else "" def units(self): - return uda.getIdamDataUnits(self._handle).decode(errors='replace') if self._handle >= 0 else "" + return uda.getIdamDataUnits(int(self._handle)).decode(errors='replace') if int(self._handle) >= 0 else "" def description(self): - return uda.getIdamDataDesc(self._handle).decode(errors='replace') if self._handle >= 0 else "" + return uda.getIdamDataDesc(int(self._handle)).decode(errors='replace') if int(self._handle) >= 0 else "" def shape(self): - cdef int rank = uda.getIdamRank(self._handle) + cdef int rank = uda.getIdamRank(int(self._handle)) shape = numpy.zeros(rank, dtype=numpy.int32) for i in range(rank): - shape[i] = uda.getIdamDimNum(self._handle, rank - 1 - i) + shape[i] = uda.getIdamDimNum(int(self._handle), rank - 1 - i) return shape def dim(self, num, data_type): @@ -134,20 +134,20 @@ cdef class Result: return bool(self._is_tree) def tree(self): - cdef uda.NTREE* root = uda.getIdamDataTree(self._handle) + cdef uda.NTREE* root = uda.getIdamDataTree(int(self._handle)) return TreeNode.new_(self._handle, root) def meta(self): return self._meta def has_time_dim(self): - cdef int order = uda.getIdamOrder(self._handle) + cdef int order = uda.getIdamOrder(int(self._handle)) return order >= 0 def time_order(self): - cdef int order = uda.getIdamOrder(self._handle) + cdef int order = uda.getIdamOrder(int(self._handle)) return order def time_dim(self, data_type): - cdef int order = uda.getIdamOrder(self._handle) + cdef int order = uda.getIdamOrder(int(self._handle)) return Dim(self._handle, order, data_type) From 02e09cf5849f9df6d28fabbbc3ad183f57554894 Mon Sep 17 00:00:00 2001 From: Jonathan Hollocombe Date: Mon, 31 Jul 2023 10:18:56 +0200 Subject: [PATCH 18/39] Fixing error in pyuda --- source/wrappers/python/pyuda/cpyuda/capnp_tree.pyx | 4 ++-- source/wrappers/python/pyuda/cpyuda/result.pyx | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/source/wrappers/python/pyuda/cpyuda/capnp_tree.pyx b/source/wrappers/python/pyuda/cpyuda/capnp_tree.pyx index 027f6294..a7abba8d 100644 --- a/source/wrappers/python/pyuda/cpyuda/capnp_tree.pyx +++ b/source/wrappers/python/pyuda/cpyuda/capnp_tree.pyx @@ -29,8 +29,8 @@ cdef class CapnpTreeNode: tree_node = CapnpTreeNode() tree_node._handle = handle if tree == NULL: - data = uda.getIdamData(handle) - num = uda.getIdamDataNum(handle) + data = uda.getIdamData(int(handle)) + num = uda.getIdamDataNum(int(handle)) tree_node._tree = uda.uda_capnp_deserialise(data, num) tree_node._node = uda.uda_capnp_read_root(tree_node._tree) else: diff --git a/source/wrappers/python/pyuda/cpyuda/result.pyx b/source/wrappers/python/pyuda/cpyuda/result.pyx index ffd32b48..ca874e54 100644 --- a/source/wrappers/python/pyuda/cpyuda/result.pyx +++ b/source/wrappers/python/pyuda/cpyuda/result.pyx @@ -19,16 +19,16 @@ cdef class Result: def __init__(self, Handle handle): self._handle = handle - self._is_tree = 1 if uda.setIdamDataTree(handle) != 0 else 0 + self._is_tree = 1 if uda.setIdamDataTree(int(handle)) != 0 else 0 cdef uda.SIGNAL_DESC* signal_desc cdef uda.DATA_SOURCE* source self._meta = {} - if handle >= 0 and uda.getIdamProperties(handle).get_meta: - signal_desc = uda.getIdamSignalDesc(handle) + if int(handle) >= 0 and uda.getIdamProperties(int(handle)).get_meta: + signal_desc = uda.getIdamSignalDesc(int(handle)) self._meta["signal_name"] = signal_desc.signal_name self._meta["signal_alias"] = signal_desc.signal_alias - source = uda.getIdamDataSource(handle) + source = uda.getIdamDataSource(int(handle)) self._meta["path"] = source.path self._meta["filename"] = source.filename self._meta["format"] = source.format From 38c5bbf904e03b0448a858516e487914fb023d86 Mon Sep 17 00:00:00 2001 From: Jonathan Hollocombe Date: Wed, 2 Aug 2023 10:00:36 +0200 Subject: [PATCH 19/39] Fixing issues using the c++ wrapper in c++11 and adding generic setReturnData function --- source/plugins/udaPlugin.cpp | 52 ++++++++++++++++++++++++++++++++-- source/plugins/udaPlugin.h | 3 ++ source/wrappers/c++/scalar.hpp | 4 +-- source/wrappers/c++/vector.hpp | 4 +-- 4 files changed, 57 insertions(+), 6 deletions(-) diff --git a/source/plugins/udaPlugin.cpp b/source/plugins/udaPlugin.cpp index 7d8f091e..85d7a635 100644 --- a/source/plugins/udaPlugin.cpp +++ b/source/plugins/udaPlugin.cpp @@ -303,6 +303,41 @@ int setReturnDataString(DATA_BLOCK* data_block, const char* value, const char* d return 0; } +int setReturnData(DATA_BLOCK* data_block, void* value, size_t size, UDA_TYPE type, int rank, const int* shape, const char* description) +{ + initDataBlock(data_block); + + data_block->data_type = type; + data_block->data = (char*)malloc(size); + + memcpy(data_block->data, value, size); + + data_block->rank = rank; + data_block->dims = (DIMS*)malloc(data_block->rank * sizeof(DIMS)); + + for (unsigned int i = 0; i < data_block->rank; i++) { + initDimBlock(&data_block->dims[i]); + } + + if (description != nullptr) { + strncpy(data_block->data_desc, description, STRING_LENGTH); + data_block->data_desc[STRING_LENGTH - 1] = '\0'; + } + + for (unsigned int i = 0; i < data_block->rank; i++) { + data_block->dims[i].data_type = UDA_TYPE_UNSIGNED_INT; + data_block->dims[i].dim_n = shape[i]; + data_block->dims[i].compressed = 1; + data_block->dims[i].dim0 = 0.0; + data_block->dims[i].diff = 1.0; + data_block->dims[i].method = 0; + } + + data_block->data_n = data_block->dims[0].dim_n; + + return 0; +} + /** * Find the Plugin identity: return the reference id or -1 if not found. * @param request @@ -573,14 +608,14 @@ bool findValue(const NAMEVALUELIST* namevaluelist, const char* name) return found; } -int callPlugin(const PLUGINLIST* pluginlist, const char* singal, const IDAM_PLUGIN_INTERFACE* old_plugin_interface) +int callPlugin(const PLUGINLIST* pluginlist, const char* signal, const IDAM_PLUGIN_INTERFACE* old_plugin_interface) { IDAM_PLUGIN_INTERFACE idam_plugin_interface = *old_plugin_interface; REQUEST_DATA request = *old_plugin_interface->request_data; idam_plugin_interface.request_data = &request; request.source[0] = '\0'; - strcpy(request.signal, singal); + strcpy(request.signal, signal); makeRequestData(&request, *pluginlist, old_plugin_interface->environment); request.request = findPluginRequestByFormat(request.format, pluginlist); @@ -597,5 +632,18 @@ int callPlugin(const PLUGINLIST* pluginlist, const char* singal, const IDAM_PLUG RAISE_PLUGIN_ERROR("Data Access is not available for this data request!"); } + // Apply subsetting +// if (request_data->datasubset.nbound > 0) { +// UDA_LOG(UDA_LOG_DEBUG, "Calling serverSubsetData (SUBSET) %d\n", *depth); +// ACTION action = {}; +// initAction(&action); +// action.actionType = UDA_SUBSET_TYPE; +// action.subset = request_data->datasubset; +// if ((rc = serverSubsetData(data_block, action, logmalloclist)) != 0) { +// (*depth)--; +// return rc; +// } +// } + return err; } diff --git a/source/plugins/udaPlugin.h b/source/plugins/udaPlugin.h index a0749a10..9d41e419 100755 --- a/source/plugins/udaPlugin.h +++ b/source/plugins/udaPlugin.h @@ -8,6 +8,7 @@ #include #include #include +#include "clientserver/udaTypes.h" #ifdef __cplusplus extern "C" { @@ -52,6 +53,8 @@ LIBRARY_API int setReturnDataLongScalar(DATA_BLOCK* data_block, long value, cons LIBRARY_API int setReturnDataShortScalar(DATA_BLOCK* data_block, short value, const char* description); LIBRARY_API int setReturnDataString(DATA_BLOCK* data_block, const char* value, const char* description); +LIBRARY_API int setReturnData(DATA_BLOCK* data_block, void* value, size_t size, UDA_TYPE type, int rank, const int* shape, const char* description); + LIBRARY_API bool findStringValue(const NAMEVALUELIST* namevaluelist, const char** value, const char* name); LIBRARY_API bool findValue(const NAMEVALUELIST* namevaluelist, const char* name); LIBRARY_API bool findIntValue(const NAMEVALUELIST* namevaluelist, int* value, const char* name); diff --git a/source/wrappers/c++/scalar.hpp b/source/wrappers/c++/scalar.hpp index bf04ff4a..b2d9d4c4 100755 --- a/source/wrappers/c++/scalar.hpp +++ b/source/wrappers/c++/scalar.hpp @@ -29,7 +29,7 @@ class LIBRARY_API Scalar : public Data { auto copy = new unsigned char[sizeof(T)]; memcpy(copy, &value, sizeof(T)); - raw_data_ = std::shared_ptr(copy); + raw_data_ = std::shared_ptr(copy, std::default_delete()); } Scalar(const Scalar& other) = default; @@ -68,7 +68,7 @@ class LIBRARY_API Scalar : public Data boost::any value_; const std::type_info* type_; - std::shared_ptr raw_data_; + std::shared_ptr raw_data_; size_t data_size_; }; diff --git a/source/wrappers/c++/vector.hpp b/source/wrappers/c++/vector.hpp index e82528a8..69c638fb 100755 --- a/source/wrappers/c++/vector.hpp +++ b/source/wrappers/c++/vector.hpp @@ -30,7 +30,7 @@ class LIBRARY_API Vector : public Data { { auto copy = new unsigned char[size * sizeof(T)]; memcpy(copy, array, size * sizeof(T)); - raw_data_ = std::shared_ptr(copy); + raw_data_ = std::shared_ptr(copy, std::default_delete()); } Vector(const Vector& other) = default; @@ -78,7 +78,7 @@ class LIBRARY_API Vector : public Data { private: std::vector vec_; const std::type_info* type_; - std::shared_ptr raw_data_; + std::shared_ptr raw_data_; size_t data_size_; template From f913c8cd47d791a727db9db706f47c6f3acbe29c Mon Sep 17 00:00:00 2001 From: Toby James Date: Wed, 16 Aug 2023 15:00:17 +0100 Subject: [PATCH 20/39] Add default empty string as source argument to remove need for empty string arguments. --- source/wrappers/python/pyuda/_client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/wrappers/python/pyuda/_client.py b/source/wrappers/python/pyuda/_client.py index e07c3d25..7ea6cfa5 100644 --- a/source/wrappers/python/pyuda/_client.py +++ b/source/wrappers/python/pyuda/_client.py @@ -160,7 +160,7 @@ def get_batch(self, signals, sources, time_first=False, time_last=False, **kwarg signals.append(self._unpack(result, time_first, time_last)) return signals - def get(self, signal, source, time_first=False, time_last=False, **kwargs): + def get(self, signal, source="", time_first=False, time_last=False, **kwargs): """ UDA get data method. From 2810e2976ecb9040647753fc0051d219e3d308e9 Mon Sep 17 00:00:00 2001 From: Stephen Dixon Date: Fri, 4 Aug 2023 17:01:32 +0100 Subject: [PATCH 21/39] removing NDEBUG and associated debug messages from idam_dlm.pro in idl wrapper --- source/wrappers/idl/idam_dlm.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/source/wrappers/idl/idam_dlm.c b/source/wrappers/idl/idam_dlm.c index f19e5be3..39ec7752 100755 --- a/source/wrappers/idl/idam_dlm.c +++ b/source/wrappers/idl/idam_dlm.c @@ -29,7 +29,7 @@ #include #include -#define NDEBUG 0 +// #define NDEBUG 0 // Function Prototypes @@ -4295,9 +4295,9 @@ getdimdataarray(int argc, IDL_VPTR argv[], char* argk) ndata = getIdamDimNum(sin->handle, dimid); ilDims[0] = (IDL_MEMINT)ndata; - if (NDEBUG) { - fprintf(stdout, "No of Elements = %d\n", (int)ilDims[0]); - } + // if (NDEBUG) { + // fprintf(stdout, "No of Elements = %d\n", (int)ilDims[0]); + // } // Allocate Heap Memory for the IDL Array and Copy the Data to it. @@ -4433,14 +4433,14 @@ freeidam(int argc, IDL_VPTR argv[], char* argk) handle = IDL_LongScalar(argv[0]); - if (NDEBUG) { - fprintf(stdout, "Freeing IDAM data Handle %d\n", handle); - } + // if (NDEBUG) { + // fprintf(stdout, "Freeing IDAM data Handle %d\n", handle); + // } if (handle < 0) { - if (NDEBUG) { - fprintf(stdout, "Not a Valid IDAM data Handle!\n"); - } + // if (NDEBUG) { + // fprintf(stdout, "Not a Valid IDAM data Handle!\n"); + // } return (IDL_GettmpLong(GDE_NO_VALID_HANDLE)); } From 301094359eef3515682b01f592f990d4cd5d8a3d Mon Sep 17 00:00:00 2001 From: sdixon Date: Wed, 16 Aug 2023 22:30:32 +0100 Subject: [PATCH 22/39] removing -Wall and -Werror for idl wrapper (only) due to spurious -Wmaybe-unused in gcc. Adding additional cmake option to add library dir to pyuda rpath and another to add a static library path to the idl interface linker. Adding extra cmake configuration script for freia with idl/08.4 support --- scripts/cmake-freia-idl84.sh | 23 +++++++++++++++++++++++ scripts/cmake-freia.sh | 2 ++ source/etc/module.in | 5 +++-- source/wrappers/CMakeLists.txt | 2 ++ source/wrappers/idl/CMakeLists.txt | 4 +++- source/wrappers/idl/idam_dlm.c | 22 ++++++++++++---------- source/wrappers/python/CMakeLists.txt | 2 ++ source/wrappers/python/setup.py.in | 2 ++ 8 files changed, 49 insertions(+), 13 deletions(-) create mode 100755 scripts/cmake-freia-idl84.sh diff --git a/scripts/cmake-freia-idl84.sh b/scripts/cmake-freia-idl84.sh new file mode 100755 index 00000000..9fc1e519 --- /dev/null +++ b/scripts/cmake-freia-idl84.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +module purge +module load idl/08.4 +module load java/1.8 +module load hdf5-C/1.8.13 +module load gcc/7.3.0 +module load cmake/3.21.0 +module load capnproto/0.10.4 +module load fmt/10.0.0 +module load spdlog/1.11.0 + +export HDF5_USE_SHLIB=yes +export BOOST_ROOT=/usr/local/depot/boost-1-77-0-gcc7.3.0 + +CC=gcc CXX=g++ cmake -Bbuild_freia -H. \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_INSTALL_PREFIX=/projects/UDA/uda-install-develop \ + -DBUILD_SHARED_LIBS=ON \ + -DENABLE_CAPNP=ON \ + -DEXTRA_IDL_WRAPPER_LINK_ARGS="/usr/local/depot/gcc-7.3.0/lib64/libstdc++.a" \ + -DEXTRA_PYTHON_WRAPPER_LINK_DIR="/usr/local/depot/gcc-7.3.0" \ + $* diff --git a/scripts/cmake-freia.sh b/scripts/cmake-freia.sh index 33148b6f..0c95f453 100755 --- a/scripts/cmake-freia.sh +++ b/scripts/cmake-freia.sh @@ -18,4 +18,6 @@ CC=gcc CXX=g++ cmake -Bbuild_freia -H. \ -DCMAKE_INSTALL_PREFIX=/projects/UDA/uda-install-develop \ -DBUILD_SHARED_LIBS=ON \ -DENABLE_CAPNP=ON \ + -DEXTRA_IDL_WRAPPER_LINK_ARGS="/usr/local/depot/gcc-7.3.0/lib64/libstdc++.a" \ + -DEXTRA_PYTHON_WRAPPER_LINK_DIR="/usr/local/depot/gcc-7.3.0" \ $* diff --git a/source/etc/module.in b/source/etc/module.in index 90fb0343..e42e64d6 100755 --- a/source/etc/module.in +++ b/source/etc/module.in @@ -8,12 +8,13 @@ conflict uda conflict idam set UDA_DIR @CMAKE_INSTALL_PREFIX@ +set UDA_IDL_DIR @CMAKE_INSTALL_PREFIX@ setenv UDA_DIR $UDA_DIR setenv UDA_HOST @UDA_HOST@ setenv UDA_PORT @UDA_PORT@ prepend-path PYTHONPATH $UDA_DIR/python prepend-path LD_LIBRARY_PATH $UDA_DIR/lib -prepend-path IDL_DLM_PATH $UDA_DIR/dlm -prepend-path IDL_PATH $UDA_DIR/idl +prepend-path IDL_DLM_PATH $UDA_IDL_DIR/dlm +prepend-path IDL_PATH $UDA_IDL_DIR/idl prepend-path PKG_CONFIG_PATH $UDA_DIR/lib/pkgconfig diff --git a/source/wrappers/CMakeLists.txt b/source/wrappers/CMakeLists.txt index 085efe1b..bd5f36db 100755 --- a/source/wrappers/CMakeLists.txt +++ b/source/wrappers/CMakeLists.txt @@ -24,7 +24,9 @@ endif() if( NOT NO_IDL_WRAPPER ) if( IDL_FOUND ) + remove_definitions( -Wall -Werror ) add_subdirectory( idl ) + add_definitions( -Wall -Werror ) else() message( WARNING "IDL not found - not building IDL wrapper" ) endif() diff --git a/source/wrappers/idl/CMakeLists.txt b/source/wrappers/idl/CMakeLists.txt index 42b45ced..bc5b6b16 100755 --- a/source/wrappers/idl/CMakeLists.txt +++ b/source/wrappers/idl/CMakeLists.txt @@ -14,8 +14,8 @@ else() endif() endif() +set( EXTRA_IDL_WRAPPER_LINK_ARGS "" CACHE STRING "exact string to add to linker arguments, e.g. for setting rpath" ) set( LIB_NAME ${PROJECT_NAME}_idl ) - set( SRC_FILES idam_dlm.c idamStructs.c ) include_directories( @@ -65,6 +65,8 @@ set_target_properties( ${LIB_NAME} VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH} SOVERSION ${PROJECT_VERSION_MAJOR} C_STANDARD 99 + PROPERTY COMPILE_WARNING_AS_ERROR OFF + LINK_FLAGS ${EXTRA_IDL_WRAPPER_LINK_ARGS} ) if( FAT_IDL ) diff --git a/source/wrappers/idl/idam_dlm.c b/source/wrappers/idl/idam_dlm.c index 39ec7752..d27e786f 100755 --- a/source/wrappers/idl/idam_dlm.c +++ b/source/wrappers/idl/idam_dlm.c @@ -29,7 +29,9 @@ #include #include -// #define NDEBUG 0 +#ifndef NDEBUG + #define NDEBUG 0 +#endif // Function Prototypes @@ -4295,9 +4297,9 @@ getdimdataarray(int argc, IDL_VPTR argv[], char* argk) ndata = getIdamDimNum(sin->handle, dimid); ilDims[0] = (IDL_MEMINT)ndata; - // if (NDEBUG) { - // fprintf(stdout, "No of Elements = %d\n", (int)ilDims[0]); - // } + if (NDEBUG) { + fprintf(stdout, "No of Elements = %d\n", (int)ilDims[0]); + } // Allocate Heap Memory for the IDL Array and Copy the Data to it. @@ -4433,14 +4435,14 @@ freeidam(int argc, IDL_VPTR argv[], char* argk) handle = IDL_LongScalar(argv[0]); - // if (NDEBUG) { - // fprintf(stdout, "Freeing IDAM data Handle %d\n", handle); - // } + if (NDEBUG) { + fprintf(stdout, "Freeing IDAM data Handle %d\n", handle); + } if (handle < 0) { - // if (NDEBUG) { - // fprintf(stdout, "Not a Valid IDAM data Handle!\n"); - // } + if (NDEBUG) { + fprintf(stdout, "Not a Valid IDAM data Handle!\n"); + } return (IDL_GettmpLong(GDE_NO_VALID_HANDLE)); } diff --git a/source/wrappers/python/CMakeLists.txt b/source/wrappers/python/CMakeLists.txt index 7db55cd1..d05a9e57 100755 --- a/source/wrappers/python/CMakeLists.txt +++ b/source/wrappers/python/CMakeLists.txt @@ -15,6 +15,8 @@ find_package( LibMemcached QUIET ) find_package( fmt REQUIRED ) find_package( TIRPC QUIET ) +set( EXTRA_PYTHON_WRAPPER_LINK_DIR "" CACHE STRING "exact string to add to runtime libs e.g. for stdc++ lib on a shared system" ) + set( UDA_LIBS ) set( EXTRA_LIBS ${EXTRA_LIBS} fmt ) diff --git a/source/wrappers/python/setup.py.in b/source/wrappers/python/setup.py.in index 2c2d0709..a20c3395 100644 --- a/source/wrappers/python/setup.py.in +++ b/source/wrappers/python/setup.py.in @@ -58,12 +58,14 @@ ext = Extension( ])), libraries=list(filter(None, ['ssl', 'crypto', 'xml2'] + extra_libs)), library_dirs=list(filter(None, [ + '@EXTRA_PYTHON_WRAPPER_LINK_DIR', '@OPENSSL_LIB_DIR@', '@LIBXML_LIB_DIR@', '@CAPNP_LIB_DIR@', '@FMT_LIB_DIR@' ])), runtime_library_dirs=list(filter(None, [ + '@EXTRA_PYTHON_WRAPPER_LINK_DIR', '@OPENSSL_LIB_DIR@', '@LIBXML_LIB_DIR@', '@CAPNP_LIB_DIR@', From 56b8eb627756177d570eeceb413e7dfe6092c771 Mon Sep 17 00:00:00 2001 From: sdixon Date: Thu, 17 Aug 2023 12:08:55 +0100 Subject: [PATCH 23/39] fixing build on friea --- scripts/cmake-freia-idl84.sh | 4 +++- scripts/cmake-freia.sh | 4 +++- source/wrappers/idl/CMakeLists.txt | 6 +++--- source/wrappers/python/setup.py.in | 4 ++-- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/scripts/cmake-freia-idl84.sh b/scripts/cmake-freia-idl84.sh index 9fc1e519..6318f763 100755 --- a/scripts/cmake-freia-idl84.sh +++ b/scripts/cmake-freia-idl84.sh @@ -19,5 +19,7 @@ CC=gcc CXX=g++ cmake -Bbuild_freia -H. \ -DBUILD_SHARED_LIBS=ON \ -DENABLE_CAPNP=ON \ -DEXTRA_IDL_WRAPPER_LINK_ARGS="/usr/local/depot/gcc-7.3.0/lib64/libstdc++.a" \ - -DEXTRA_PYTHON_WRAPPER_LINK_DIR="/usr/local/depot/gcc-7.3.0" \ + -DEXTRA_PYTHON_WRAPPER_LINK_DIR="/usr/local/depot/gcc-7.3.0/lib64" \ + -DUDA_HOST=uda2.mast.l \ + -DUDA_PORT=56565 \ $* diff --git a/scripts/cmake-freia.sh b/scripts/cmake-freia.sh index 0c95f453..8d4c5064 100755 --- a/scripts/cmake-freia.sh +++ b/scripts/cmake-freia.sh @@ -19,5 +19,7 @@ CC=gcc CXX=g++ cmake -Bbuild_freia -H. \ -DBUILD_SHARED_LIBS=ON \ -DENABLE_CAPNP=ON \ -DEXTRA_IDL_WRAPPER_LINK_ARGS="/usr/local/depot/gcc-7.3.0/lib64/libstdc++.a" \ - -DEXTRA_PYTHON_WRAPPER_LINK_DIR="/usr/local/depot/gcc-7.3.0" \ + -DEXTRA_PYTHON_WRAPPER_LINK_DIR="/usr/local/depot/gcc-7.3.0/lib64" \ + -DUDA_HOST=uda2.mast.l \ + -DUDA_PORT=56565 \ $* diff --git a/source/wrappers/idl/CMakeLists.txt b/source/wrappers/idl/CMakeLists.txt index bc5b6b16..96b80d80 100755 --- a/source/wrappers/idl/CMakeLists.txt +++ b/source/wrappers/idl/CMakeLists.txt @@ -52,10 +52,10 @@ endif() if( FAT_IDL ) include( modules ) - target_link_libraries( ${LIB_NAME} LINK_PRIVATE ${IDL_LIBRARIES} ${LIBXML2_LIBRARIES} ) + target_link_libraries( ${LIB_NAME} LINK_PRIVATE ${IDL_LIBRARIES} ${LIBXML2_LIBRARIES} ${EXTRA_IDL_WRAPPER_LINK_ARGS} ) link_modules( ${LIB_NAME} ) else() - target_link_libraries( ${LIB_NAME} LINK_PRIVATE client-static ${IDL_LIBRARIES} ${LIBXML2_LIBRARIES} ) + target_link_libraries( ${LIB_NAME} LINK_PRIVATE client-static ${IDL_LIBRARIES} ${LIBXML2_LIBRARIES} ${EXTRA_IDL_WRAPPER_LINK_ARGS} ) endif() set_target_properties( ${LIB_NAME} @@ -65,7 +65,7 @@ set_target_properties( ${LIB_NAME} VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH} SOVERSION ${PROJECT_VERSION_MAJOR} C_STANDARD 99 - PROPERTY COMPILE_WARNING_AS_ERROR OFF + COMPILE_WARNING_AS_ERROR OFF LINK_FLAGS ${EXTRA_IDL_WRAPPER_LINK_ARGS} ) diff --git a/source/wrappers/python/setup.py.in b/source/wrappers/python/setup.py.in index a20c3395..9c37c649 100644 --- a/source/wrappers/python/setup.py.in +++ b/source/wrappers/python/setup.py.in @@ -58,14 +58,14 @@ ext = Extension( ])), libraries=list(filter(None, ['ssl', 'crypto', 'xml2'] + extra_libs)), library_dirs=list(filter(None, [ - '@EXTRA_PYTHON_WRAPPER_LINK_DIR', + '@EXTRA_PYTHON_WRAPPER_LINK_DIR@', '@OPENSSL_LIB_DIR@', '@LIBXML_LIB_DIR@', '@CAPNP_LIB_DIR@', '@FMT_LIB_DIR@' ])), runtime_library_dirs=list(filter(None, [ - '@EXTRA_PYTHON_WRAPPER_LINK_DIR', + '@EXTRA_PYTHON_WRAPPER_LINK_DIR@', '@OPENSSL_LIB_DIR@', '@LIBXML_LIB_DIR@', '@CAPNP_LIB_DIR@', From 2faccdf61c2c60b5496becce361ba003c78867b8 Mon Sep 17 00:00:00 2001 From: sdixon Date: Fri, 18 Aug 2023 20:28:32 +0100 Subject: [PATCH 24/39] adding rpaths to linker options for building CLI binary --- source/bin/CMakeLists.txt | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/source/bin/CMakeLists.txt b/source/bin/CMakeLists.txt index fd834ad9..0d369107 100644 --- a/source/bin/CMakeLists.txt +++ b/source/bin/CMakeLists.txt @@ -1,19 +1,26 @@ add_executable( uda_cli uda_cli.cpp ) +set( Boost_USE_STATIC_LIBS ON ) find_package( Boost COMPONENTS program_options REQUIRED ) target_include_directories( uda_cli PRIVATE ${CMAKE_SOURCE_DIR}/source ${CMAKE_SOURCE_DIR}/extlib/GSL-4.0.0/include ) -if( BUILD_SHARED_LIBS ) - target_link_libraries( uda_cli PRIVATE client-shared uda_cpp-shared ) -else() - target_link_libraries( uda_cli PRIVATE client-static uda_cpp-static ) -endif() +target_link_libraries( uda_cli PRIVATE client-static uda_cpp-static ) +target_link_libraries( uda_cli PRIVATE Boost::program_options ) + if( ENABLE_CAPNP ) - target_link_libraries( uda_cli PRIVATE serialisation-static ) -endif() + find_package( CapnProto REQUIRED ) -target_link_libraries( uda_cli PRIVATE Boost::program_options ) + target_link_libraries( uda_cli PRIVATE serialisation-static ) + + find_library( STDCXX_LIBRARY_FILE stdc++ HINTS ${CMAKE_CXX_IMPLICIT_LINK_DIRECTORIES} ) + get_filename_component(STDCXX_LIBRARY_DIR ${STDCXX_LIBRARY_FILE} DIRECTORY ) + + set_target_properties( uda_cli + PROPERTIES + LINK_FLAGS "-Wl,-rpath,${capnp_LIBRARY_DIRS} -L${capnp_LIBRARY_DIRS} -lcapnp-0.10.4 -lkj -Wl,-rpath,${STDCXX_LIBRARY_DIR} -L${STDCXX_LIBRARY_DIR} -lstdc++" + ) +endif() install( TARGETS uda_cli From 5abfab421a1e9e6aa15dad9becb3abef31748e6d Mon Sep 17 00:00:00 2001 From: sdixon Date: Fri, 18 Aug 2023 20:51:51 +0100 Subject: [PATCH 25/39] replacing user-supplied stdc++.a path with cmake find_library() call for the IDL wrapper --- scripts/cmake-freia.sh | 1 - source/wrappers/idl/CMakeLists.txt | 16 +++++++++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/scripts/cmake-freia.sh b/scripts/cmake-freia.sh index 8d4c5064..854c7a4a 100755 --- a/scripts/cmake-freia.sh +++ b/scripts/cmake-freia.sh @@ -18,7 +18,6 @@ CC=gcc CXX=g++ cmake -Bbuild_freia -H. \ -DCMAKE_INSTALL_PREFIX=/projects/UDA/uda-install-develop \ -DBUILD_SHARED_LIBS=ON \ -DENABLE_CAPNP=ON \ - -DEXTRA_IDL_WRAPPER_LINK_ARGS="/usr/local/depot/gcc-7.3.0/lib64/libstdc++.a" \ -DEXTRA_PYTHON_WRAPPER_LINK_DIR="/usr/local/depot/gcc-7.3.0/lib64" \ -DUDA_HOST=uda2.mast.l \ -DUDA_PORT=56565 \ diff --git a/source/wrappers/idl/CMakeLists.txt b/source/wrappers/idl/CMakeLists.txt index 96b80d80..77e2c4fa 100755 --- a/source/wrappers/idl/CMakeLists.txt +++ b/source/wrappers/idl/CMakeLists.txt @@ -14,7 +14,15 @@ else() endif() endif() -set( EXTRA_IDL_WRAPPER_LINK_ARGS "" CACHE STRING "exact string to add to linker arguments, e.g. for setting rpath" ) +# stc++.so is loaded at startup of IDL interpreter. This will lead to ABI mismatch if the uda.so library +# is built with a different compiler version than IDL uses. link static stdc++ library explicitly to protect. +if (WIN32 OR MSVC) + set(CMAKE_FIND_LIBRARY_SUFFIXES ".lib") + elseif (UNIX) + set(CMAKE_FIND_LIBRARY_SUFFIXES ".a") + endif() +find_library( STDCXX_STATIC stdc++ HINTS ${CMAKE_CXX_IMPLICIT_LINK_DIRECTORIES} ) + set( LIB_NAME ${PROJECT_NAME}_idl ) set( SRC_FILES idam_dlm.c idamStructs.c ) @@ -52,10 +60,10 @@ endif() if( FAT_IDL ) include( modules ) - target_link_libraries( ${LIB_NAME} LINK_PRIVATE ${IDL_LIBRARIES} ${LIBXML2_LIBRARIES} ${EXTRA_IDL_WRAPPER_LINK_ARGS} ) + target_link_libraries( ${LIB_NAME} LINK_PRIVATE ${IDL_LIBRARIES} ${LIBXML2_LIBRARIES} ${STDCXX_STATIC} ${EXTRA_IDL_WRAPPER_LINK_ARGS} ) link_modules( ${LIB_NAME} ) else() - target_link_libraries( ${LIB_NAME} LINK_PRIVATE client-static ${IDL_LIBRARIES} ${LIBXML2_LIBRARIES} ${EXTRA_IDL_WRAPPER_LINK_ARGS} ) + target_link_libraries( ${LIB_NAME} LINK_PRIVATE client-static ${IDL_LIBRARIES} ${LIBXML2_LIBRARIES} ${STDCXX_STATIC} ${EXTRA_IDL_WRAPPER_LINK_ARGS} ) endif() set_target_properties( ${LIB_NAME} @@ -65,8 +73,6 @@ set_target_properties( ${LIB_NAME} VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH} SOVERSION ${PROJECT_VERSION_MAJOR} C_STANDARD 99 - COMPILE_WARNING_AS_ERROR OFF - LINK_FLAGS ${EXTRA_IDL_WRAPPER_LINK_ARGS} ) if( FAT_IDL ) From 3746674c2810fdfd29e99a88b9c7dc933ad6c5f6 Mon Sep 17 00:00:00 2001 From: sdixon Date: Fri, 18 Aug 2023 21:15:12 +0100 Subject: [PATCH 26/39] replacing user-defined link-directory variable with cmake find_library() call for python wrapper --- source/etc/module.in | 1 + source/wrappers/python/CMakeLists.txt | 3 ++- source/wrappers/python/setup.py.in | 4 ++-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/source/etc/module.in b/source/etc/module.in index e42e64d6..c73d2c2c 100755 --- a/source/etc/module.in +++ b/source/etc/module.in @@ -18,3 +18,4 @@ prepend-path LD_LIBRARY_PATH $UDA_DIR/lib prepend-path IDL_DLM_PATH $UDA_IDL_DIR/dlm prepend-path IDL_PATH $UDA_IDL_DIR/idl prepend-path PKG_CONFIG_PATH $UDA_DIR/lib/pkgconfig +set-alias uda $UDA_DIR/bin/uda_cli diff --git a/source/wrappers/python/CMakeLists.txt b/source/wrappers/python/CMakeLists.txt index d05a9e57..58eeef4a 100755 --- a/source/wrappers/python/CMakeLists.txt +++ b/source/wrappers/python/CMakeLists.txt @@ -15,7 +15,8 @@ find_package( LibMemcached QUIET ) find_package( fmt REQUIRED ) find_package( TIRPC QUIET ) -set( EXTRA_PYTHON_WRAPPER_LINK_DIR "" CACHE STRING "exact string to add to runtime libs e.g. for stdc++ lib on a shared system" ) +find_library( STDCXX_LIBRARY_FILE stdc++ HINTS ${CMAKE_CXX_IMPLICIT_LINK_DIRECTORIES} ) +get_filename_component(STDCXX_LIB_DIR ${STDCXX_LIBRARY_FILE} DIRECTORY ) set( UDA_LIBS ) set( EXTRA_LIBS ${EXTRA_LIBS} fmt ) diff --git a/source/wrappers/python/setup.py.in b/source/wrappers/python/setup.py.in index 9c37c649..c94e793f 100644 --- a/source/wrappers/python/setup.py.in +++ b/source/wrappers/python/setup.py.in @@ -58,14 +58,14 @@ ext = Extension( ])), libraries=list(filter(None, ['ssl', 'crypto', 'xml2'] + extra_libs)), library_dirs=list(filter(None, [ - '@EXTRA_PYTHON_WRAPPER_LINK_DIR@', + '@STDCXX_LIB_DIR@', '@OPENSSL_LIB_DIR@', '@LIBXML_LIB_DIR@', '@CAPNP_LIB_DIR@', '@FMT_LIB_DIR@' ])), runtime_library_dirs=list(filter(None, [ - '@EXTRA_PYTHON_WRAPPER_LINK_DIR@', + '@STDCXX_LIB_DIR@', '@OPENSSL_LIB_DIR@', '@LIBXML_LIB_DIR@', '@CAPNP_LIB_DIR@', From d52ce55c08ee850f5458ae4754101656628edeb7 Mon Sep 17 00:00:00 2001 From: sdixon Date: Mon, 21 Aug 2023 13:52:50 +0100 Subject: [PATCH 27/39] setting build without memcache to be default option in cmake. Fixing a few minor typos --- CMakeLists.txt | 2 +- source/bin/CMakeLists.txt | 2 +- source/wrappers/python/pyuda/_client.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 993c219a..2999eaf7 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -160,7 +160,7 @@ endif() option( CLIENT_ONLY "Only build UDA client" OFF ) option( SERVER_ONLY "Only build UDA server" OFF ) option( BUILD_SHARED_LIBS "Build shared libraries" OFF ) -option( NO_MEMCACHE "Do not attempt to build with libmemcached support" OFF ) +option( NO_MEMCACHE "Do not attempt to build with libmemcached support" ON ) option( ENABLE_CAPNP "Enable Cap’n Proto serialisation" OFF ) # Wrapper configuration diff --git a/source/bin/CMakeLists.txt b/source/bin/CMakeLists.txt index 0d369107..662fb8ba 100644 --- a/source/bin/CMakeLists.txt +++ b/source/bin/CMakeLists.txt @@ -18,7 +18,7 @@ if( ENABLE_CAPNP ) set_target_properties( uda_cli PROPERTIES - LINK_FLAGS "-Wl,-rpath,${capnp_LIBRARY_DIRS} -L${capnp_LIBRARY_DIRS} -lcapnp-0.10.4 -lkj -Wl,-rpath,${STDCXX_LIBRARY_DIR} -L${STDCXX_LIBRARY_DIR} -lstdc++" + LINK_FLAGS "-Wl,-rpath,${capnp_LIBRARY_DIRS} -L${capnp_LIBRARY_DIRS} -lcapnp -lkj -Wl,-rpath,${STDCXX_LIBRARY_DIR} -L${STDCXX_LIBRARY_DIR} -lstdc++" ) endif() diff --git a/source/wrappers/python/pyuda/_client.py b/source/wrappers/python/pyuda/_client.py index 7ea6cfa5..b918721d 100644 --- a/source/wrappers/python/pyuda/_client.py +++ b/source/wrappers/python/pyuda/_client.py @@ -191,4 +191,4 @@ def close_connection(self): cpyuda.close_connection() def reset_connection(self): - cpyuda.reset_connection() + cpyuda.close_connection() From 6896e878a67f49b2fdb3ac2507bc224f8caedb7d Mon Sep 17 00:00:00 2001 From: sdixon Date: Tue, 22 Aug 2023 11:18:07 +0100 Subject: [PATCH 28/39] testing fix for macos CI build --- source/bin/CMakeLists.txt | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/source/bin/CMakeLists.txt b/source/bin/CMakeLists.txt index 662fb8ba..9ae4d220 100644 --- a/source/bin/CMakeLists.txt +++ b/source/bin/CMakeLists.txt @@ -11,14 +11,20 @@ target_link_libraries( uda_cli PRIVATE Boost::program_options ) if( ENABLE_CAPNP ) find_package( CapnProto REQUIRED ) - target_link_libraries( uda_cli PRIVATE serialisation-static ) + get_cmake_property(_variableNames VARIABLES) + list (SORT _variableNames) + foreach (_variableName ${_variableNames}) + message(STATUS "${_variableName}=${${_variableName}}") + endforeach() + + target_link_libraries( uda_cli PRIVATE serialisation-static capnp kj stdc++) find_library( STDCXX_LIBRARY_FILE stdc++ HINTS ${CMAKE_CXX_IMPLICIT_LINK_DIRECTORIES} ) get_filename_component(STDCXX_LIBRARY_DIR ${STDCXX_LIBRARY_FILE} DIRECTORY ) set_target_properties( uda_cli PROPERTIES - LINK_FLAGS "-Wl,-rpath,${capnp_LIBRARY_DIRS} -L${capnp_LIBRARY_DIRS} -lcapnp -lkj -Wl,-rpath,${STDCXX_LIBRARY_DIR} -L${STDCXX_LIBRARY_DIR} -lstdc++" + LINK_FLAGS "-Wl,-rpath,${capnp_LIBRARY_DIRS} -L${capnp_LIBRARY_DIRS} -Wl,-rpath,${STDCXX_LIBRARY_DIR} -L${STDCXX_LIBRARY_DIR} " ) endif() From 973f9c33a4b2360440c106f9f776bb22fd02ffb3 Mon Sep 17 00:00:00 2001 From: sdixon Date: Tue, 22 Aug 2023 11:50:59 +0100 Subject: [PATCH 29/39] testing fix for macos CI build --- source/bin/CMakeLists.txt | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/source/bin/CMakeLists.txt b/source/bin/CMakeLists.txt index 9ae4d220..256a2812 100644 --- a/source/bin/CMakeLists.txt +++ b/source/bin/CMakeLists.txt @@ -22,9 +22,19 @@ if( ENABLE_CAPNP ) find_library( STDCXX_LIBRARY_FILE stdc++ HINTS ${CMAKE_CXX_IMPLICIT_LINK_DIRECTORIES} ) get_filename_component(STDCXX_LIBRARY_DIR ${STDCXX_LIBRARY_FILE} DIRECTORY ) + if ( "${capnp_LIBRARY_DIRS}" STREQUAL "" ) + set( CAPNP_RPATH ${CapnProto_DIR} ) + cmake_path( APPEND CAPNP_RPATH_LIB "${CapnProto_DIR}" "lib" ) + if ( EXISTS "${CAPNP_RPATH_LIB}" ) + set( CAPNP_RPATH "${CAPNP_RPATH_LIB}" ) + else() + cmake_path( APPEND CAPNP_RPATH_LIB64 "${CapnProto_DIR}" "lib64" ) + set( CAPNP_RPATH "${CAPNP_RPATH_LIB64}" ) + endif() + set_target_properties( uda_cli PROPERTIES - LINK_FLAGS "-Wl,-rpath,${capnp_LIBRARY_DIRS} -L${capnp_LIBRARY_DIRS} -Wl,-rpath,${STDCXX_LIBRARY_DIR} -L${STDCXX_LIBRARY_DIR} " + LINK_FLAGS "-Wl,-rpath,${CAPNP_RPATH} -L${CAPNP_RPATH} -Wl,-rpath,${STDCXX_LIBRARY_DIR} -L${STDCXX_LIBRARY_DIR} " ) endif() From 6c24a8f6a47d174d0ec00c28593c1983da3e537d Mon Sep 17 00:00:00 2001 From: sdixon Date: Tue, 22 Aug 2023 11:52:51 +0100 Subject: [PATCH 30/39] testing fix for macos CI build --- source/bin/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/source/bin/CMakeLists.txt b/source/bin/CMakeLists.txt index 256a2812..84e47440 100644 --- a/source/bin/CMakeLists.txt +++ b/source/bin/CMakeLists.txt @@ -30,6 +30,7 @@ if( ENABLE_CAPNP ) else() cmake_path( APPEND CAPNP_RPATH_LIB64 "${CapnProto_DIR}" "lib64" ) set( CAPNP_RPATH "${CAPNP_RPATH_LIB64}" ) + endif() endif() set_target_properties( uda_cli From 0b9b8a9e1de4ee44eb2756cdab698dd1d1dca996 Mon Sep 17 00:00:00 2001 From: sdixon Date: Tue, 22 Aug 2023 13:08:09 +0100 Subject: [PATCH 31/39] testing fix for macos CI build --- source/bin/CMakeLists.txt | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/source/bin/CMakeLists.txt b/source/bin/CMakeLists.txt index 84e47440..589011fd 100644 --- a/source/bin/CMakeLists.txt +++ b/source/bin/CMakeLists.txt @@ -11,31 +11,30 @@ target_link_libraries( uda_cli PRIVATE Boost::program_options ) if( ENABLE_CAPNP ) find_package( CapnProto REQUIRED ) - get_cmake_property(_variableNames VARIABLES) - list (SORT _variableNames) - foreach (_variableName ${_variableNames}) - message(STATUS "${_variableName}=${${_variableName}}") - endforeach() - target_link_libraries( uda_cli PRIVATE serialisation-static capnp kj stdc++) find_library( STDCXX_LIBRARY_FILE stdc++ HINTS ${CMAKE_CXX_IMPLICIT_LINK_DIRECTORIES} ) get_filename_component(STDCXX_LIBRARY_DIR ${STDCXX_LIBRARY_FILE} DIRECTORY ) + + if ( "${STDCXX_LIBRARY_FILE}" STREQUAL "" ) + set ( STDCXX_RPATH "" ) + else() + set ( STDCXX_RPATH "-Wl,-rpath,${STDCXX_LIBRARY_FILE} -L${STDCXX_LIBRARY_FILE}" ) + + endif() + + # get_filename_component( CAPNP_LIB_CMAKE_DIR ${CapnProto_DIR} DIRECTORY ) + # get_filename_component( CAPNP_LIB_DIR ${CAPNP_LIB_CMAKE_DIR} DIRECTORY ) if ( "${capnp_LIBRARY_DIRS}" STREQUAL "" ) - set( CAPNP_RPATH ${CapnProto_DIR} ) - cmake_path( APPEND CAPNP_RPATH_LIB "${CapnProto_DIR}" "lib" ) - if ( EXISTS "${CAPNP_RPATH_LIB}" ) - set( CAPNP_RPATH "${CAPNP_RPATH_LIB}" ) - else() - cmake_path( APPEND CAPNP_RPATH_LIB64 "${CapnProto_DIR}" "lib64" ) - set( CAPNP_RPATH "${CAPNP_RPATH_LIB64}" ) - endif() + set( CAPNP_RPATH "" ) + else() + set( CAPNP_RPATH "-Wl,-rpath,${capnp_LIBRARY_DIRS} -L${capnp_LIBRARY_DIRS}" ) endif() set_target_properties( uda_cli PROPERTIES - LINK_FLAGS "-Wl,-rpath,${CAPNP_RPATH} -L${CAPNP_RPATH} -Wl,-rpath,${STDCXX_LIBRARY_DIR} -L${STDCXX_LIBRARY_DIR} " + LINK_FLAGS "${CAPNP_RPATH STDCXX_RPATH} " ) endif() From 486a8b0c5bc311ea55f445a026225cf39b21c330 Mon Sep 17 00:00:00 2001 From: sdixon Date: Tue, 22 Aug 2023 13:22:26 +0100 Subject: [PATCH 32/39] testing fix for macos CI build --- source/bin/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/bin/CMakeLists.txt b/source/bin/CMakeLists.txt index 589011fd..5332ec26 100644 --- a/source/bin/CMakeLists.txt +++ b/source/bin/CMakeLists.txt @@ -34,7 +34,7 @@ if( ENABLE_CAPNP ) set_target_properties( uda_cli PROPERTIES - LINK_FLAGS "${CAPNP_RPATH STDCXX_RPATH} " + LINK_FLAGS "${CAPNP_RPATH} ${STDCXX_RPATH}" ) endif() From 3c9a6a3fe245a42b6cf6729db6a479825208ea77 Mon Sep 17 00:00:00 2001 From: sdixon Date: Tue, 22 Aug 2023 14:34:57 +0100 Subject: [PATCH 33/39] testing fix for macos CI build --- source/bin/CMakeLists.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/source/bin/CMakeLists.txt b/source/bin/CMakeLists.txt index 5332ec26..189c7951 100644 --- a/source/bin/CMakeLists.txt +++ b/source/bin/CMakeLists.txt @@ -11,7 +11,7 @@ target_link_libraries( uda_cli PRIVATE Boost::program_options ) if( ENABLE_CAPNP ) find_package( CapnProto REQUIRED ) - target_link_libraries( uda_cli PRIVATE serialisation-static capnp kj stdc++) + target_link_libraries( uda_cli PRIVATE serialisation-static ) find_library( STDCXX_LIBRARY_FILE stdc++ HINTS ${CMAKE_CXX_IMPLICIT_LINK_DIRECTORIES} ) get_filename_component(STDCXX_LIBRARY_DIR ${STDCXX_LIBRARY_FILE} DIRECTORY ) @@ -19,7 +19,7 @@ if( ENABLE_CAPNP ) if ( "${STDCXX_LIBRARY_FILE}" STREQUAL "" ) set ( STDCXX_RPATH "" ) else() - set ( STDCXX_RPATH "-Wl,-rpath,${STDCXX_LIBRARY_FILE} -L${STDCXX_LIBRARY_FILE}" ) + set ( STDCXX_RPATH "-Wl,-rpath,${STDCXX_LIBRARY_FILE} -L${STDCXX_LIBRARY_FILE} -lstdc++" ) endif() @@ -29,7 +29,7 @@ if( ENABLE_CAPNP ) if ( "${capnp_LIBRARY_DIRS}" STREQUAL "" ) set( CAPNP_RPATH "" ) else() - set( CAPNP_RPATH "-Wl,-rpath,${capnp_LIBRARY_DIRS} -L${capnp_LIBRARY_DIRS}" ) + set( CAPNP_RPATH "-Wl,-rpath,${capnp_LIBRARY_DIRS} -L${capnp_LIBRARY_DIRS} -lcapnp -lkj" ) endif() set_target_properties( uda_cli From 162a19c77de30d2109c7963bfe9d7aa01731d43d Mon Sep 17 00:00:00 2001 From: sdixon Date: Wed, 23 Aug 2023 01:04:10 +0100 Subject: [PATCH 34/39] adding cmake option for linking CLI binary with static boost library --- scripts/cmake-freia-idl84.sh | 3 +-- scripts/cmake-freia.sh | 2 +- source/bin/CMakeLists.txt | 7 ++++++- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/scripts/cmake-freia-idl84.sh b/scripts/cmake-freia-idl84.sh index 6318f763..29501fbd 100755 --- a/scripts/cmake-freia-idl84.sh +++ b/scripts/cmake-freia-idl84.sh @@ -18,8 +18,7 @@ CC=gcc CXX=g++ cmake -Bbuild_freia -H. \ -DCMAKE_INSTALL_PREFIX=/projects/UDA/uda-install-develop \ -DBUILD_SHARED_LIBS=ON \ -DENABLE_CAPNP=ON \ - -DEXTRA_IDL_WRAPPER_LINK_ARGS="/usr/local/depot/gcc-7.3.0/lib64/libstdc++.a" \ - -DEXTRA_PYTHON_WRAPPER_LINK_DIR="/usr/local/depot/gcc-7.3.0/lib64" \ + -DUDA_CLI_BOOST_STATIC=ON \ -DUDA_HOST=uda2.mast.l \ -DUDA_PORT=56565 \ $* diff --git a/scripts/cmake-freia.sh b/scripts/cmake-freia.sh index 854c7a4a..703a2d0f 100755 --- a/scripts/cmake-freia.sh +++ b/scripts/cmake-freia.sh @@ -18,7 +18,7 @@ CC=gcc CXX=g++ cmake -Bbuild_freia -H. \ -DCMAKE_INSTALL_PREFIX=/projects/UDA/uda-install-develop \ -DBUILD_SHARED_LIBS=ON \ -DENABLE_CAPNP=ON \ - -DEXTRA_PYTHON_WRAPPER_LINK_DIR="/usr/local/depot/gcc-7.3.0/lib64" \ + -DUDA_CLI_BOOST_STATIC=ON \ -DUDA_HOST=uda2.mast.l \ -DUDA_PORT=56565 \ $* diff --git a/source/bin/CMakeLists.txt b/source/bin/CMakeLists.txt index 189c7951..5a068cf6 100644 --- a/source/bin/CMakeLists.txt +++ b/source/bin/CMakeLists.txt @@ -1,6 +1,11 @@ add_executable( uda_cli uda_cli.cpp ) -set( Boost_USE_STATIC_LIBS ON ) +option( UDA_CLI_BOOST_STATIC "compile commandline interface with static boost libraries" OFF ) + +if ( UDA_CLI_BOOST_STATIC ) + set( Boost_USE_STATIC_LIBS ON ) +endif() + find_package( Boost COMPONENTS program_options REQUIRED ) target_include_directories( uda_cli PRIVATE ${CMAKE_SOURCE_DIR}/source ${CMAKE_SOURCE_DIR}/extlib/GSL-4.0.0/include ) From 794664af6d05c20601cf3a44a6239e79a2ad73df Mon Sep 17 00:00:00 2001 From: sdixon Date: Wed, 23 Aug 2023 14:33:45 +0100 Subject: [PATCH 35/39] adding new mast wrapper function to pyuda registered subclients --- source/wrappers/python/pyuda/_client.py | 1 + 1 file changed, 1 insertion(+) diff --git a/source/wrappers/python/pyuda/_client.py b/source/wrappers/python/pyuda/_client.py index b918721d..07d177d3 100644 --- a/source/wrappers/python/pyuda/_client.py +++ b/source/wrappers/python/pyuda/_client.py @@ -76,6 +76,7 @@ def __init__(self, debug_level=logging.ERROR): self._registered_subclients['listGeomGroups'] = GeomClient(self) self._registered_subclients['list'] = MastClient(self) self._registered_subclients['list_archive_files'] = MastClient(self) + self._registered_subclients['list_archive_file_info'] = MastClient(self) self._registered_subclients['list_archive_directories'] = MastClient(self) self._registered_subclients['list_file_signals'] = MastClient(self) self._registered_subclients['list_signals'] = MastClient(self) From e4c0e65fb1a12224c197aa4c81af16cf779e9c6e Mon Sep 17 00:00:00 2001 From: sdixon Date: Thu, 24 Aug 2023 11:51:06 +0100 Subject: [PATCH 36/39] adding LIBRAY_API back into structured data function definitions as required by IDL wrapper --- source/structures/accessors.h | 46 +++--- source/structures/struct.h | 278 +++++++++++++++++----------------- 2 files changed, 162 insertions(+), 162 deletions(-) diff --git a/source/structures/accessors.h b/source/structures/accessors.h index ee2240d6..2aadbb79 100755 --- a/source/structures/accessors.h +++ b/source/structures/accessors.h @@ -17,7 +17,7 @@ * @param lastname Returns the name of the element, i.e., the name of the last item in the name hierarchy. * @return the Tree Node containing the named element. */ -NTREE* +LIBRARY_API NTREE* findNTreeStructureComponent2(LOGMALLOCLIST* logmalloclist, NTREE* ntree, const char* target, const char** lastname); /** Find (search type B) and return a Pointer to the named Data Tree Node with a data structure of the same name. @@ -30,7 +30,7 @@ findNTreeStructureComponent2(LOGMALLOCLIST* logmalloclist, NTREE* ntree, const c * @param lastname Returns the name of the Structure, i.e., the name of the last node in the name hierarchy. * @return the Data Tree Node with the structure name. */ -NTREE* findNTreeStructure2(LOGMALLOCLIST* logmalloclist, NTREE* ntree, const char* target, const char** lastname); +LIBRARY_API NTREE* findNTreeStructure2(LOGMALLOCLIST* logmalloclist, NTREE* ntree, const char* target, const char** lastname); /** Find (search type A) and return a Pointer to the Data Tree Node with a data structure that contains a named element. * @@ -41,7 +41,7 @@ NTREE* findNTreeStructure2(LOGMALLOCLIST* logmalloclist, NTREE* ntree, const cha * This element may be either a structure itself or an atomic typed element. * @return the Data Tree Node. */ -NTREE* findNTreeStructureComponent(LOGMALLOCLIST* logmalloclist, NTREE* ntree, const char* target); +LIBRARY_API NTREE* findNTreeStructureComponent(LOGMALLOCLIST* logmalloclist, NTREE* ntree, const char* target); /** Find (search type A) and return a Pointer to the Child Data Tree Node with a data structure that contains a named element. * @@ -52,7 +52,7 @@ NTREE* findNTreeStructureComponent(LOGMALLOCLIST* logmalloclist, NTREE* ntree, c * This element may be either a structure itself or an atomic typed element. * @return the Data Tree Node. */ -NTREE* findNTreeChildStructureComponent(LOGMALLOCLIST* logmalloclist, NTREE* ntree, const char* target); +LIBRARY_API NTREE* findNTreeChildStructureComponent(LOGMALLOCLIST* logmalloclist, NTREE* ntree, const char* target); /** Find (search type B) and return a Pointer to the named Data Tree Node with a data structure of the same name. * @@ -62,7 +62,7 @@ NTREE* findNTreeChildStructureComponent(LOGMALLOCLIST* logmalloclist, NTREE* ntr * @param target The name of the Structure (case sensitive) using a hierachical naming syntax a.b.c or a/b/c. * @return the Data Tree Node. */ -NTREE* findNTreeStructure(LOGMALLOCLIST* logmalloclist, NTREE* ntree, const char* target); +LIBRARY_API NTREE* findNTreeStructure(LOGMALLOCLIST* logmalloclist, NTREE* ntree, const char* target); /** Find (search type B) and return a Pointer to the named Data Tree Node with a data structure of the same name. * @@ -72,7 +72,7 @@ NTREE* findNTreeStructure(LOGMALLOCLIST* logmalloclist, NTREE* ntree, const char * @param target The name of the Structure (case sensitive) using a hierachical naming syntax a.b.c or a/b/c. * @return the child Data Tree Node. */ -NTREE* findNTreeChildStructure(LOGMALLOCLIST* logmalloclist, NTREE* ntree, const char* target); +LIBRARY_API NTREE* findNTreeChildStructure(LOGMALLOCLIST* logmalloclist, NTREE* ntree, const char* target); /** Find and return a Pointer to a Data Tree Node with a data structure located at a specific memory location. * @@ -82,7 +82,7 @@ NTREE* findNTreeChildStructure(LOGMALLOCLIST* logmalloclist, NTREE* ntree, const * @param data The heap address of the data. * @return the Data Tree Node. */ -NTREE* findNTreeStructureMalloc(NTREE* ntree, void* data); +LIBRARY_API NTREE* findNTreeStructureMalloc(NTREE* ntree, void* data); /** Locate a tree node with structured data having the specified Structure Definition name. * @@ -92,7 +92,7 @@ NTREE* findNTreeStructureMalloc(NTREE* ntree, void* data); * @param target The name of the Structure Definition. * @return A pointer to the First tree node found with the targeted structure definition. */ -NTREE* findNTreeStructureDefinition(NTREE* ntree, const char* target); +LIBRARY_API NTREE* findNTreeStructureDefinition(NTREE* ntree, const char* target); /** Locate a tree node with structured data having the specified Structure Definition name. * @@ -102,7 +102,7 @@ NTREE* findNTreeStructureDefinition(NTREE* ntree, const char* target); * @param target The name of the Structure Definition. * @return A pointer to the First tree node found with the targeted structure definition. */ -NTREE* findNTreeStructureComponentDefinition(NTREE* tree, const char* target); +LIBRARY_API NTREE* findNTreeStructureComponentDefinition(NTREE* tree, const char* target); /** Locate a tree node with structured data having a Specific Structure Class. * @@ -112,7 +112,7 @@ NTREE* findNTreeStructureComponentDefinition(NTREE* tree, const char* target); * @param class The Structure Class, e.g., UDA_TYPE_VLEN. * @return A pointer to the First tree node found with the targeted structure class. */ -NTREE* idam_findNTreeStructureClass(NTREE* tree, int cls); +LIBRARY_API NTREE* idam_findNTreeStructureClass(NTREE* tree, int cls); /** Identify the largest count of a Variable Length Array with a given structure type. * @@ -123,7 +123,7 @@ NTREE* idam_findNTreeStructureClass(NTREE* tree, int cls); * @param reset Reset the counbter to zero. * @return An integer returning the maximum count value. */ -int idam_maxCountVlenStructureArray(NTREE* tree, const char* target, int reset); +LIBRARY_API int idam_maxCountVlenStructureArray(NTREE* tree, const char* target, int reset); /** Regularise a specific VLEN structure. * @@ -134,7 +134,7 @@ int idam_maxCountVlenStructureArray(NTREE* tree, const char* target, int reset); * @param count The maximum count size for the VLEN data arrays. * @return An integer returning an error code: 0 => OK. */ -int idam_regulariseVlenStructures(LOGMALLOCLIST* logmalloclist, NTREE* tree, USERDEFINEDTYPELIST* userdefinedtypelist, +LIBRARY_API int idam_regulariseVlenStructures(LOGMALLOCLIST* logmalloclist, NTREE* tree, USERDEFINEDTYPELIST* userdefinedtypelist, const char* target, unsigned int count); /** Regularise the Shape of All VLEN structured data arrays in the data tree: necessary for accessing in some languages, e.g. IDL. @@ -144,7 +144,7 @@ int idam_regulariseVlenStructures(LOGMALLOCLIST* logmalloclist, NTREE* tree, USE * @param tree A pointer to a parent tree node. If NULL the root node is assumed. * @return An integer returning an error code: 0 => OK. */ -int idam_regulariseVlenData(LOGMALLOCLIST* logmalloclist, NTREE* tree, USERDEFINEDTYPELIST* userdefinedtypelist); +LIBRARY_API int idam_regulariseVlenData(LOGMALLOCLIST* logmalloclist, NTREE* tree, USERDEFINEDTYPELIST* userdefinedtypelist); //--------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------- @@ -157,7 +157,7 @@ int idam_regulariseVlenData(LOGMALLOCLIST* logmalloclist, NTREE* tree, USERDEFIN * @param ntree A pointer to a tree node. If NULL the root node is assumed. * @return the Count of structured data array elements. */ -int getNodeStructureDataCount(LOGMALLOCLIST* logmalloclist, NTREE* ntree); +LIBRARY_API int getNodeStructureDataCount(LOGMALLOCLIST* logmalloclist, NTREE* ntree); /** Return the Size (bytes) of the structured data array attached to this tree node. * @@ -166,7 +166,7 @@ int getNodeStructureDataCount(LOGMALLOCLIST* logmalloclist, NTREE* ntree); * @param ntree A pointer to a tree node. If NULL the root node is assumed. * @return the Size (bytes) of the structured data array. */ -int getNodeStructureDataSize(LOGMALLOCLIST* logmalloclist, NTREE* ntree); +LIBRARY_API int getNodeStructureDataSize(LOGMALLOCLIST* logmalloclist, NTREE* ntree); /** Return the rank of the structured data array attached to this tree node. * @@ -175,7 +175,7 @@ int getNodeStructureDataSize(LOGMALLOCLIST* logmalloclist, NTREE* ntree); * @param ntree A pointer to a tree node. If NULL the root node is assumed. * @return The rank of the structured data array. */ -int getNodeStructureDataRank(LOGMALLOCLIST* logmalloclist, NTREE* ntree); +LIBRARY_API int getNodeStructureDataRank(LOGMALLOCLIST* logmalloclist, NTREE* ntree); /** Return the shape of the structured data array attached to this tree node. * @@ -184,7 +184,7 @@ int getNodeStructureDataRank(LOGMALLOCLIST* logmalloclist, NTREE* ntree); * @param ntree A pointer to a tree node. If NULL the root node is assumed. * @return A pointer to the integer shape array of the structured data array. */ -int* getNodeStructureDataShape(LOGMALLOCLIST* logmalloclist, NTREE* ntree); +LIBRARY_API int* getNodeStructureDataShape(LOGMALLOCLIST* logmalloclist, NTREE* ntree); /** Return a pointer to the structured data type name of the data array attached to this tree node. * @@ -193,7 +193,7 @@ int* getNodeStructureDataShape(LOGMALLOCLIST* logmalloclist, NTREE* ntree); * @param ntree A pointer to a tree node. If NULL the root node is assumed. * @return the data type name of the structured data array. */ -const char* getNodeStructureDataDataType(LOGMALLOCLIST* logmalloclist, NTREE* ntree); +LIBRARY_API const char* getNodeStructureDataDataType(LOGMALLOCLIST* logmalloclist, NTREE* ntree); /** Return a pointer to the data attached to this tree node. * @@ -202,7 +202,7 @@ const char* getNodeStructureDataDataType(LOGMALLOCLIST* logmalloclist, NTREE* nt * @param ntree A pointer to a tree node. If NULL the root node is assumed. * @return A void pointer to the data . */ -void* getNodeStructureData(NTREE* ntree); +LIBRARY_API void* getNodeStructureData(NTREE* ntree); //---------------------------------------------------------------------------------------------------------- // Sundry utility functions @@ -217,7 +217,7 @@ void* getNodeStructureData(NTREE* ntree); * @param imagecount The number of bytes in the image text block. * @return Void */ -void printImage(const char* image, int imagecount); +LIBRARY_API void printImage(const char* image, int imagecount); //---------------------------------------------------------------------------------------------------------- /**User defined structure field definition for common types @@ -231,8 +231,8 @@ void printImage(const char* image, int imagecount); * @param type_id Enumerated key indicating the type of data field, e.g. float array * @return Void */ -void defineField(COMPOUNDFIELD* field, const char* name, const char* desc, int* offset, unsigned short type_id); +LIBRARY_API void defineField(COMPOUNDFIELD* field, const char* name, const char* desc, int* offset, unsigned short type_id); -void defineCompoundField(COMPOUNDFIELD* field, const char* type, const char* name, char* desc, int offset, int size); +LIBRARY_API void defineCompoundField(COMPOUNDFIELD* field, const char* type, const char* name, char* desc, int offset, int size); -#endif // UDA_STRUCTURES_ACCESSORS_H \ No newline at end of file +#endif // UDA_STRUCTURES_ACCESSORS_H diff --git a/source/structures/struct.h b/source/structures/struct.h index a009e961..6a0cc533 100755 --- a/source/structures/struct.h +++ b/source/structures/struct.h @@ -12,17 +12,17 @@ # include #endif -NTREE* udaGetFullNTree(); -void udaSetFullNTree(NTREE* ntree); +LIBRARY_API NTREE* udaGetFullNTree(); +LIBRARY_API void udaSetFullNTree(NTREE* ntree); -void setLastMallocIndexValue(unsigned int* lastMallocIndexValue_in); +LIBRARY_API void setLastMallocIndexValue(unsigned int* lastMallocIndexValue_in); /** Initialise a SARRAY data structure. * * @param str A pointer to a SARRAY data structure instance. * @return Void. */ -void initSArray(SARRAY* str); +LIBRARY_API void initSArray(SARRAY* str); /** Print the Contents of a SARRAY data structure. * @@ -30,14 +30,14 @@ void initSArray(SARRAY* str); * @param str A SARRAY data structure instance. * @return Void. */ -void printSarray(SARRAY str); +LIBRARY_API void printSarray(SARRAY str); /** Add an NTREE List entry. * * @param node A NTREE node to add. * @return Void. */ -void addNTreeList(LOGMALLOCLIST* logmalloclist, NTREE* node); +LIBRARY_API void addNTreeList(LOGMALLOCLIST* logmalloclist, NTREE* node); /** Add an NTREE node to an array of child nodes. * @@ -45,14 +45,14 @@ void addNTreeList(LOGMALLOCLIST* logmalloclist, NTREE* node); * @param child A NTREE node to add to the existing set of child nodes * @return Void. */ -void addNTree(NTREE* parent, NTREE* child); +LIBRARY_API void addNTree(NTREE* parent, NTREE* child); /** Free an NTREE node together with the array of child nodes. * * @param ntree A NTREE node with or without a set of child nodes * @return Void. */ -void freeNTreeNode(NTREE* ntree); +LIBRARY_API void freeNTreeNode(NTREE* ntree); /** Add a new image line to the existing image. * @@ -61,7 +61,7 @@ void freeNTreeNode(NTREE* ntree); * @param line A new image line to add to the existing image. * @return Both image and image count are updated on return. */ -void addImage(char** image, int* imagecount, const char* line); +LIBRARY_API void addImage(char** image, int* imagecount, const char* line); /** Expand an image line that contains header defines and include the numerical value * @@ -72,62 +72,62 @@ void addImage(char** image, int* imagecount, const char* line); * @param expand A pre-allocated array of char to be used to receive the expanded buffer string. * @return expand An expanded Image line. */ -void expandImage(char* buffer, char defnames[MAXELEMENTS][MAXELEMENTNAME], int* defvalues, int defCount, char* expand); +LIBRARY_API void expandImage(char* buffer, char defnames[MAXELEMENTS][MAXELEMENTNAME], int* defvalues, int defCount, char* expand); /** Initialise a LOGMALLOCLIST data structure. * * @param str A pointer to a LOGMALLOCLIST data structure instance. * @return Void. */ -void initLogMallocList(LOGMALLOCLIST* str); +LIBRARY_API void initLogMallocList(LOGMALLOCLIST* str); /** Initialise a LOGMALLOC data structure. * * @param str A pointer to a LOGMALLOC data structure instance. * @return Void. */ -void initLogMalloc(LOGMALLOC* str); +LIBRARY_API void initLogMalloc(LOGMALLOC* str); /** Initialise a LOGSTRUCTLIST data structure. * * @return Void. */ -void initLogStructList(LOGSTRUCTLIST* logstructlist); +LIBRARY_API void initLogStructList(LOGSTRUCTLIST* logstructlist); /** Initialise a LOGSTRUCT data structure. * * @param str A pointer to a LOGSTRUCT data structure instance. * @return Void. */ -void initLogStruct(LOGSTRUCT* str); +LIBRARY_API void initLogStruct(LOGSTRUCT* str); /** Initialise a COMPOUNDFIELD data structure. * * @param str A pointer to a COMPOUNDFIELD data structure instance. * @return Void. */ -void initCompoundField(COMPOUNDFIELD* str); +LIBRARY_API void initCompoundField(COMPOUNDFIELD* str); /** Initialise a USERDEFINEDTYPE data structure. * * @param str A pointer to a USERDEFINEDTYPE data structure instance. * @return Void. */ -void initUserDefinedType(USERDEFINEDTYPE* str); +LIBRARY_API void initUserDefinedType(USERDEFINEDTYPE* str); /** Initialise a USERDEFINEDTYPELIST data structure. * * @param str A pointer to a USERDEFINEDTYPELIST data structure instance. * @return Void. */ -void initUserDefinedTypeList(USERDEFINEDTYPELIST* str); +LIBRARY_API void initUserDefinedTypeList(USERDEFINEDTYPELIST* str); /** Initialise a GENERAL_BLOCK data structure. * * @param str A pointer to a GENERAL_BLOCK data structure instance. * @return Void. */ -void initGeneralBlock(GENERAL_BLOCK* str); +LIBRARY_API void initGeneralBlock(GENERAL_BLOCK* str); /** Print the Contents of a COMPOUNDFIELD data structure. * @@ -135,7 +135,7 @@ void initGeneralBlock(GENERAL_BLOCK* str); * @param str A COMPOUNDFIELD data structure instance. * @return Void. */ -void printCompoundField(COMPOUNDFIELD str); +LIBRARY_API void printCompoundField(COMPOUNDFIELD str); /** Print the Tabulated Contents of a COMPOUNDFIELD data structure. * @@ -143,7 +143,7 @@ void printCompoundField(COMPOUNDFIELD str); * @param str A COMPOUNDFIELD data structure instance. * @return Void. */ -void printCompoundFieldTable(COMPOUNDFIELD str); +LIBRARY_API void printCompoundFieldTable(COMPOUNDFIELD str); /** Print the Contents of a USERDEFINEDTYPE data structure. * @@ -151,7 +151,7 @@ void printCompoundFieldTable(COMPOUNDFIELD str); * @param str A USERDEFINEDTYPE data structure instance. * @return Void. */ -void printUserDefinedType(USERDEFINEDTYPE str); +LIBRARY_API void printUserDefinedType(USERDEFINEDTYPE str); /** Print the Tabulated Contents of a USERDEFINEDTYPE data structure. * @@ -159,7 +159,7 @@ void printUserDefinedType(USERDEFINEDTYPE str); * @param str A USERDEFINEDTYPE data structure instance. * @return Void. */ -void printUserDefinedTypeTable(USERDEFINEDTYPELIST* userdefinedtypelist, USERDEFINEDTYPE str); +LIBRARY_API void printUserDefinedTypeTable(USERDEFINEDTYPELIST* userdefinedtypelist, USERDEFINEDTYPE str); /** Print the Tabulated Contents of a USERDEFINEDTYPE data structure with Zero Sized elements. * @@ -167,7 +167,7 @@ void printUserDefinedTypeTable(USERDEFINEDTYPELIST* userdefinedtypelist, USERDEF * @param str A USERDEFINEDTYPE data structure instance. * @return Void. */ -void printZeroSizedUserDefinedTypeTable(USERDEFINEDTYPE str); +LIBRARY_API void printZeroSizedUserDefinedTypeTable(USERDEFINEDTYPE str); /** Print the Contents of a USERDEFINEDTYPELIST data structure. * @@ -175,7 +175,7 @@ void printZeroSizedUserDefinedTypeTable(USERDEFINEDTYPE str); * @param str A USERDEFINEDTYPELIST data structure instance. * @return Void. */ -void printUserDefinedTypeList(USERDEFINEDTYPELIST str); +LIBRARY_API void printUserDefinedTypeList(USERDEFINEDTYPELIST str); /** Print the Tabulated Contents of a USERDEFINEDTYPELIST data structure. * @@ -183,7 +183,7 @@ void printUserDefinedTypeList(USERDEFINEDTYPELIST str); * @param str A USERDEFINEDTYPELIST data structure instance. * @return Void. */ -void printUserDefinedTypeListTable(USERDEFINEDTYPELIST str); +LIBRARY_API void printUserDefinedTypeListTable(USERDEFINEDTYPELIST str); /** Print the Tabulated Contents of a USERDEFINEDTYPELIST data structure where the size is zero. * @@ -191,7 +191,7 @@ void printUserDefinedTypeListTable(USERDEFINEDTYPELIST str); * @param str A USERDEFINEDTYPELIST data structure instance. * @return Void. */ -void printZeroSizedUserDefinedTypeListTable(USERDEFINEDTYPELIST str); +LIBRARY_API void printZeroSizedUserDefinedTypeListTable(USERDEFINEDTYPELIST str); /** Print the Contents of a LOGMALLOC data structure. * @@ -199,14 +199,14 @@ void printZeroSizedUserDefinedTypeListTable(USERDEFINEDTYPELIST str); * @param str A LOGMALLOC data structure instance. * @return Void. */ -void printMallocLog(LOGMALLOC str); +LIBRARY_API void printMallocLog(LOGMALLOC str); /** Print the Contents of the Global LOGMALLOCLIST data structure. * * @param fd A File Descriptor. * @return Void. */ -void printMallocLogList(const LOGMALLOCLIST* logmalloclist); +LIBRARY_API void printMallocLogList(const LOGMALLOCLIST* logmalloclist); //============================================================================================================== // Utility Functions @@ -219,7 +219,7 @@ void printMallocLogList(const LOGMALLOCLIST* logmalloclist); * @param type The name of the type allocated. * @return void. */ -void addNonMalloc(LOGMALLOCLIST* logmalloclist, void* stack, int count, size_t size, const char* type); +LIBRARY_API void addNonMalloc(LOGMALLOCLIST* logmalloclist, void* stack, int count, size_t size, const char* type); /** Add a stack memory location to the LOGMALLOCLIST data structure. These are not freed. * @@ -232,7 +232,7 @@ void addNonMalloc(LOGMALLOCLIST* logmalloclist, void* stack, int count, size_t s * @return void. */ -void addNonMalloc2(LOGMALLOCLIST* logmalloclist, void* stack, int count, size_t size, const char* type, int rank, +LIBRARY_API void addNonMalloc2(LOGMALLOCLIST* logmalloclist, void* stack, int count, size_t size, const char* type, int rank, int* shape); /** Add a heap memory location to the LOGMALLOCLIST data structure. These are freed. @@ -243,7 +243,7 @@ void addNonMalloc2(LOGMALLOCLIST* logmalloclist, void* stack, int count, size_t * @param type The name of the type allocated. * @return void. */ -void addMalloc(LOGMALLOCLIST* logmalloclist, void* heap, int count, size_t size, const char* type); +LIBRARY_API void addMalloc(LOGMALLOCLIST* logmalloclist, void* heap, int count, size_t size, const char* type); /** Add a heap memory location to the LOGMALLOCLIST data structure. These are freed. * @@ -255,7 +255,7 @@ void addMalloc(LOGMALLOCLIST* logmalloclist, void* heap, int count, size_t size, * @param shape The shape of the allocated array. Only required when rank > 1. * @return void. */ -void +LIBRARY_API void addMalloc2(LOGMALLOCLIST* logmalloclist, void* heap, int count, size_t size, const char* type, int rank, int* shape); /** Change the logged memory location to a new location (necessary with realloc). @@ -267,7 +267,7 @@ addMalloc2(LOGMALLOCLIST* logmalloclist, void* heap, int count, size_t size, con * @param type The name of the type allocated. * @return void. */ -void changeMalloc(LOGMALLOCLIST* logmalloclist, VOIDTYPE old, void* anew, int count, size_t size, const char* type); +LIBRARY_API void changeMalloc(LOGMALLOCLIST* logmalloclist, VOIDTYPE old, void* anew, int count, size_t size, const char* type); /** Change the logged memory location to a new location (necessary with realloc). * @@ -278,21 +278,21 @@ void changeMalloc(LOGMALLOCLIST* logmalloclist, VOIDTYPE old, void* anew, int co * @param type The name of the type allocated. * @return void. */ -void changeNonMalloc(LOGMALLOCLIST* logmalloclist, void* old, void* anew, int count, size_t size, const char* type); +LIBRARY_API void changeNonMalloc(LOGMALLOCLIST* logmalloclist, void* old, void* anew, int count, size_t size, const char* type); -int dupCountMallocLog(LOGMALLOCLIST* str); +LIBRARY_API int dupCountMallocLog(LOGMALLOCLIST* str); /** Free allocated heap memory but preserve the addresses. There are no arguments. * * @return void. */ -void freeMallocLog(LOGMALLOCLIST* str); +LIBRARY_API void freeMallocLog(LOGMALLOCLIST* str); /** Free allocated heap memory and reinitialise a new logmalloclist-> There are no arguments. * * @return void. */ -void freeMallocLogList(LOGMALLOCLIST* str); +LIBRARY_API void freeMallocLogList(LOGMALLOCLIST* str); /** Find the meta data associated with a specific memory location. * @@ -302,7 +302,7 @@ void freeMallocLogList(LOGMALLOCLIST* str); * @param type The returned allocation type. * @return void. */ -void findMalloc(LOGMALLOCLIST* logmalloclist, void* heap, int* count, int* size, const char** type); +LIBRARY_API void findMalloc(LOGMALLOCLIST* logmalloclist, void* heap, int* count, int* size, const char** type); /** Find the meta data associated with a specific memory location. * @@ -315,7 +315,7 @@ void findMalloc(LOGMALLOCLIST* logmalloclist, void* heap, int* count, int* size, * @return void. */ -void +LIBRARY_API void findMalloc2(LOGMALLOCLIST* logmalloclist, void* heap, int* count, int* size, const char** type, int* rank, int** shape); /** Add a heap memory location to the LOGSTRUCTLIST data structure. These are freed. @@ -324,13 +324,13 @@ findMalloc2(LOGMALLOCLIST* logmalloclist, void* heap, int* count, int* size, con * @param type The name of the type allocated. * @return void. */ -void addStruct(void* heap, const char* type); +LIBRARY_API void addStruct(void* heap, const char* type); /** Free allocated heap memory and reinitialise a new LOGSTRUCTLIST. There are no arguments. * * @return void. */ -void freeLogStructList(LOGSTRUCTLIST* log_struct_list); +LIBRARY_API void freeLogStructList(LOGSTRUCTLIST* log_struct_list); /** Find the meta data associated with a specific Structure. * @@ -338,7 +338,7 @@ void freeLogStructList(LOGSTRUCTLIST* log_struct_list); * @param type The returned structure type. * @return The structure id. */ -int findStructId(void* heap, char** type); +LIBRARY_API int findStructId(void* heap, char** type); /** Find the Heap address and Data Type of a specific Structure. * @@ -346,7 +346,7 @@ int findStructId(void* heap, char** type); * @param type The returned structure type. * @return The heap memory location */ -void* findStructHeap(int id, char** type); +LIBRARY_API void* findStructHeap(int id, char** type); /** Copy a User Defined Structure Definition. * @@ -354,21 +354,21 @@ void* findStructHeap(int id, char** type); * @param anew The copy of the type definition. * @return void. */ -void copyUserDefinedType(USERDEFINEDTYPE* old, USERDEFINEDTYPE* anew); +LIBRARY_API void copyUserDefinedType(USERDEFINEDTYPE* old, USERDEFINEDTYPE* anew); /** Copy the Master User Defined Structure Definition List. * * @param anew The copy of the type definition list. * @return void. */ -void copyUserDefinedTypeList(USERDEFINEDTYPELIST** anew, const USERDEFINEDTYPELIST* parseduserdefinedtypelist); +LIBRARY_API void copyUserDefinedTypeList(USERDEFINEDTYPELIST** anew, const USERDEFINEDTYPELIST* parseduserdefinedtypelist); /** Create the Initial User Defined Structure Definition List. * * @param anew The initial type definition list. * @return void. */ -void getInitialUserDefinedTypeList(USERDEFINEDTYPELIST** anew); +LIBRARY_API void getInitialUserDefinedTypeList(USERDEFINEDTYPELIST** anew); /** Add a Compound Field type to a structure definition. * @@ -376,7 +376,7 @@ void getInitialUserDefinedTypeList(USERDEFINEDTYPELIST** anew); * @param field The Compound field type. * @return void. */ -void addCompoundField(USERDEFINEDTYPE* str, COMPOUNDFIELD field); +LIBRARY_API void addCompoundField(USERDEFINEDTYPE* str, COMPOUNDFIELD field); /** Add a structure definition to the List of structure types * @@ -384,7 +384,7 @@ void addCompoundField(USERDEFINEDTYPE* str, COMPOUNDFIELD field); * @param type The new definition to add to the list. * @return void. */ -void addUserDefinedType(USERDEFINEDTYPELIST* str, USERDEFINEDTYPE type); +LIBRARY_API void addUserDefinedType(USERDEFINEDTYPELIST* str, USERDEFINEDTYPE type); /** Replace/Update the structure definition list with an different structure type. * @@ -393,7 +393,7 @@ void addUserDefinedType(USERDEFINEDTYPELIST* str, USERDEFINEDTYPE type); * @param type The definition to add into the list. * @return void. */ -void updateUserDefinedType(USERDEFINEDTYPELIST* str, int typeId, USERDEFINEDTYPE type); +LIBRARY_API void updateUserDefinedType(USERDEFINEDTYPELIST* str, int typeId, USERDEFINEDTYPE type); /** Change a structure element's property in the structure definition * @@ -404,7 +404,7 @@ void updateUserDefinedType(USERDEFINEDTYPELIST* str, int typeId, USERDEFINEDTYPE * @param value The new property value * @return void. */ -void +LIBRARY_API void changeUserDefinedTypeElementProperty(USERDEFINEDTYPELIST* str, int typeId, char* element, char* property, void* value); /** The number of Structure Definitions or User Defined Types in the structure list @@ -412,42 +412,42 @@ changeUserDefinedTypeElementProperty(USERDEFINEDTYPELIST* str, int typeId, char* * @param str The list of structure definitions. * @return The count of structured types. */ -int countUserDefinedType(USERDEFINEDTYPELIST* str); +LIBRARY_API int countUserDefinedType(USERDEFINEDTYPELIST* str); /** Free heap from a Compound Field. * * @param str The Compound Field. * @return void. */ -void freeCompoundField(COMPOUNDFIELD* str); +LIBRARY_API void freeCompoundField(COMPOUNDFIELD* str); /** Free heap from a User Defined Type. * * @param type The User Defined Type. * @return void. */ -void freeUserDefinedType(USERDEFINEDTYPE* type); +LIBRARY_API void freeUserDefinedType(USERDEFINEDTYPE* type); /** Free heap from a User Defined Type List. * * @param userdefinedtypelist The User Defined Type List. * @return void. */ -void freeUserDefinedTypeList(USERDEFINEDTYPELIST* userdefinedtypelist); +LIBRARY_API void freeUserDefinedTypeList(USERDEFINEDTYPELIST* userdefinedtypelist); /** The size or byte count of an atomic or structured type * * @param type The name of the type * @return The size in bytes. */ -size_t getsizeof(USERDEFINEDTYPELIST* userdefinedtypelist, const char* type); +LIBRARY_API size_t getsizeof(USERDEFINEDTYPELIST* userdefinedtypelist, const char* type); /** The value of the IDAM enumeration type for a named regular atomic type * * @param type The name of the atomic type * @return The integer value of the corresponding IDAM enumeration. */ -int gettypeof(const char* type); +LIBRARY_API int gettypeof(const char* type); /** Return structure element alignment byte boundary * @@ -472,25 +472,25 @@ int gettypeof(const char* type); * * */ -int getalignmentof(const char* type); +LIBRARY_API int getalignmentof(const char* type); -size_t newoffset(size_t offset, const char* type); +LIBRARY_API size_t newoffset(size_t offset, const char* type); -size_t padding(size_t offset, const char* type); +LIBRARY_API size_t padding(size_t offset, const char* type); /** The name of an atomic type corresponding to a value of the IDAM enumeration type. * * @param type The integer value of the type enumeration. * @return The name of the atomic type. */ -const char* udaNameType(UDA_TYPE type); +LIBRARY_API const char* udaNameType(UDA_TYPE type); /** The size or byte count of a user defined structured type. * * @param str The user defined structure definition. * @return The size in bytes. */ -size_t getStructureSize(USERDEFINEDTYPELIST* userdefinedtypelist, USERDEFINEDTYPE* str); +LIBRARY_API size_t getStructureSize(USERDEFINEDTYPELIST* userdefinedtypelist, USERDEFINEDTYPE* str); /** Print an error message. * @@ -501,7 +501,7 @@ size_t getStructureSize(USERDEFINEDTYPELIST* userdefinedtypelist, USERDEFINEDTYP * @param msg The message to print. * @return The size in bytes. */ -void printError(int warning, int line, char* file, char* msg); +LIBRARY_API void printError(int warning, int line, char* file, char* msg); //============================================================================================================== @@ -522,20 +522,20 @@ void printError(int warning, int line, char* file, char* msg); // The count of data structures to be received is passed ... // -int xdrAtomicData(LOGMALLOCLIST* logmalloclist, XDR* xdrs, const char* type, int count, int size, char** data); +LIBRARY_API int xdrAtomicData(LOGMALLOCLIST* logmalloclist, XDR* xdrs, const char* type, int count, int size, char** data); // Send/Receive Array of Structures -int xdrUserDefinedTypeData(XDR* xdrs, LOGMALLOCLIST* logmalloclist, USERDEFINEDTYPELIST* userdefinedtypelist, +LIBRARY_API int xdrUserDefinedTypeData(XDR* xdrs, LOGMALLOCLIST* logmalloclist, USERDEFINEDTYPELIST* userdefinedtypelist, USERDEFINEDTYPE* userdefinedtype, void** data, int protocolVersion, bool xdr_stdio_flag, LOGSTRUCTLIST* log_struct_list, int malloc_source); -int findUserDefinedTypeId(USERDEFINEDTYPELIST* userdefinedtypelist, const char* name); +LIBRARY_API int findUserDefinedTypeId(USERDEFINEDTYPELIST* userdefinedtypelist, const char* name); USERDEFINEDTYPE* findUserDefinedType(USERDEFINEDTYPELIST* userdefinedtypelist, const char* name, int ref_id); -int testUserDefinedType(USERDEFINEDTYPELIST* userdefinedtypelist, USERDEFINEDTYPE* udt); +LIBRARY_API int testUserDefinedType(USERDEFINEDTYPELIST* userdefinedtypelist, USERDEFINEDTYPE* udt); //============================================================================================================== // Functions to Send or Receive Definitions of User Defined Structure @@ -560,7 +560,7 @@ bool_t xdr_userdefinedtypelist(XDR* xdrs, USERDEFINEDTYPELIST* str, bool xdr_std * @param label A label to print before the value. * @return Void */ -void printAtomicData(void* data, int atomictype, int count, const char* label); +LIBRARY_API void printAtomicData(void* data, int atomictype, int count, const char* label); /** Print the data from a named array of Atomic Type from a given tree node to a specified File Descriptor. * @@ -572,7 +572,7 @@ void printAtomicData(void* data, int atomictype, int count, const char* label); * \todo {When the structure is an array, either print data from a single array element or print data from * all structure elements} */ -void printAtomicType(LOGMALLOCLIST* logmalloclist, NTREE* tree, const char* target); +LIBRARY_API void printAtomicType(LOGMALLOCLIST* logmalloclist, NTREE* tree, const char* target); /** Print the Count of elements of a named data array from a given tree node to a specified File Descriptor. * @@ -581,7 +581,7 @@ void printAtomicType(LOGMALLOCLIST* logmalloclist, NTREE* tree, const char* targ * @param target The name of a Structure element. * @return Void */ -void printTypeCount(NTREE* ntree, const char* target); +LIBRARY_API void printTypeCount(NTREE* ntree, const char* target); // The compound field element of the structure definition contains the count, rank and shape details // of non-pointer data. @@ -607,7 +607,7 @@ COMPOUNDFIELD* getNodeStructureComponent(LOGMALLOCLIST* logmalloclist, NTREE* nt * @param ntargets A returned count of the number of names in the returned list. * @return the list of structure component names. */ -char** parseTarget(const char* target, int* ntargets); +LIBRARY_API char** parseTarget(const char* target, int* ntargets); /** Print the Contents of a tree node to a specified File Descriptor. * @@ -615,7 +615,7 @@ char** parseTarget(const char* target, int* ntargets); * @param tree A pointer to a tree node. If NULL the root node is assumed. * @return Void */ -void printNode(NTREE* tree); +LIBRARY_API void printNode(NTREE* tree); /** Print the Contents of a tree node with the specified User Defined Structure name to a specified File Descriptor. * @@ -624,7 +624,7 @@ void printNode(NTREE* tree); * of the root node is used. * @return Void */ -void printNodeStructureDefinition(const char* target); +LIBRARY_API void printNodeStructureDefinition(const char* target); /** Print an Image of the Named Structure Definition to a specified File Descriptor. * @@ -632,7 +632,7 @@ void printNodeStructureDefinition(const char* target); * @param target The name of a User Defined Structure type. * @return Void */ -void printNodeStructureImage(const char* target); +LIBRARY_API void printNodeStructureImage(const char* target); /** Return a Pointer to the User Defined Type Structure of the data attached to this tree node. @@ -647,21 +647,21 @@ USERDEFINEDTYPE* getNodeUserDefinedType(NTREE* ntree); * @param ntree A pointer to a tree node. If NULL the root node is assumed. * @return the name of the User Defined Type Structure. */ -char* getNodeStructureName(NTREE* ntree); +LIBRARY_API char* getNodeStructureName(NTREE* ntree); /** Return the Type of the User Defined Type Structure. * * @param ntree A pointer to a tree node. If NULL the root node is assumed. * @return the Type of the User Defined Type Structure. */ -char* getNodeStructureType(NTREE* ntree); +LIBRARY_API char* getNodeStructureType(NTREE* ntree); /** Return the Size of the User Defined Type Structure. * * @param ntree A pointer to a tree node. If NULL the root node is assumed. * @return the Size (Bytes) of the User Defined Type Structure. */ -int getNodeStructureSize(NTREE* ntree); +LIBRARY_API int getNodeStructureSize(NTREE* ntree); /** Return a pointer to a Tree Nodes's Data Structure Array element. * @@ -669,7 +669,7 @@ int getNodeStructureSize(NTREE* ntree); * @param index The array index * @return a Pointer to a Structure Array element. */ -void* getNodeStructureArrayData(LOGMALLOCLIST* logmalloclist, NTREE* ntree, int index); +LIBRARY_API void* getNodeStructureArrayData(LOGMALLOCLIST* logmalloclist, NTREE* ntree, int index); /** Return a pointer to a Component Data Structure Array element. * @@ -679,7 +679,7 @@ void* getNodeStructureArrayData(LOGMALLOCLIST* logmalloclist, NTREE* ntree, int * @param componentindex The structure element index * @return a Pointer to a Component Structure Array element. */ -void* +LIBRARY_API void* getNodeStructureComponentArrayData(LOGMALLOCLIST* logmalloclist, NTREE* ntree, const char* target, int structureindex, int componentindex); @@ -688,7 +688,7 @@ getNodeStructureComponentArrayData(LOGMALLOCLIST* logmalloclist, NTREE* ntree, c * @param ntree A pointer to a tree node. If NULL the root node is assumed. * @return the name of the User Defined Type Structure. */ -int getNodeChildrenCount(NTREE* ntree); +LIBRARY_API int getNodeChildrenCount(NTREE* ntree); /** Return a Child Node. * @@ -696,7 +696,7 @@ int getNodeChildrenCount(NTREE* ntree); * @param child A integer index identifying which child from the child array to return * @return the Child Node. */ -NTREE* getNodeChild(NTREE* ntree, int child); +LIBRARY_API NTREE* getNodeChild(NTREE* ntree, int child); /** Return a Child Node'd ID (Branch index value). * @@ -704,28 +704,28 @@ NTREE* getNodeChild(NTREE* ntree, int child); * @param child A ipointer to a Child tree node. * @return the Child Node's ID. */ -int getNodeChildId(NTREE* ntree, NTREE* child); +LIBRARY_API int getNodeChildId(NTREE* ntree, NTREE* child); /** Return a Pointer to the children of this tree node. * * @param ntree A pointer to a tree node. If NULL the root node is assumed. * @return the Array of children. */ -NTREE** getNodeChildren(NTREE* ntree); +LIBRARY_API NTREE** getNodeChildren(NTREE* ntree); /** Return the parent Node. * * @param ntree A pointer to a tree node. If NULL the root node is assumed. * @return the Parent Node. */ -NTREE* getNodeParent(NTREE* ntree); +LIBRARY_API NTREE* getNodeParent(NTREE* ntree); /** Return the Data pointer. * * @param ntree A pointer to a tree node. If NULL the root node is assumed. * @return a Pointer to the Data. */ -void* getNodeData(NTREE* ntree); +LIBRARY_API void* getNodeData(NTREE* ntree); /** Return a Count of Structured Component Types attached to a tree node. * @@ -733,7 +733,7 @@ void* getNodeData(NTREE* ntree); * @return the Count of Structured types. */ -int getNodeStructureCount(NTREE* ntree); +LIBRARY_API int getNodeStructureCount(NTREE* ntree); /** Return a Count of Atomic Component Types attached to a tree node. * @@ -741,7 +741,7 @@ int getNodeStructureCount(NTREE* ntree); * @return the Count of Atomic types. */ -int getNodeAtomicCount(NTREE* ntree); +LIBRARY_API int getNodeAtomicCount(NTREE* ntree); /** Return a List of Structure component Names attached to a tree node. * @@ -749,63 +749,63 @@ int getNodeAtomicCount(NTREE* ntree); * @return the List of Structure names. */ -char** getNodeStructureNames(LOGMALLOCLIST* logmalloclist, NTREE* ntree); +LIBRARY_API char** getNodeStructureNames(LOGMALLOCLIST* logmalloclist, NTREE* ntree); /** Return a List of Atomic component Names attached to a tree node. * * @param ntree A pointer to a tree node. If NULL the root node is assumed. * @return the List of Atomic element names. */ -char** getNodeAtomicNames(LOGMALLOCLIST* logmalloclist, NTREE* ntree); +LIBRARY_API char** getNodeAtomicNames(LOGMALLOCLIST* logmalloclist, NTREE* ntree); /** Return a List of Structure Component Type Names attached to a tree node. * * @param ntree A pointer to a tree node. If NULL the root node is assumed. * @return the List of Structure Type names. */ -char** getNodeStructureTypes(LOGMALLOCLIST* logmalloclist, NTREE* ntree); +LIBRARY_API char** getNodeStructureTypes(LOGMALLOCLIST* logmalloclist, NTREE* ntree); /** Return a List of Atomic Component Type Names attached to a tree node. * * @param ntree A pointer to a tree node. If NULL the root node is assumed. * @return the List of Atomic Type names. */ -char** getNodeAtomicTypes(LOGMALLOCLIST* logmalloclist, NTREE* ntree); +LIBRARY_API char** getNodeAtomicTypes(LOGMALLOCLIST* logmalloclist, NTREE* ntree); /** Return a List of Structure Component Pointer property attached to a tree node. * * @param ntree A pointer to a tree node. If NULL the root node is assumed. * @return the List of Structure Pointer Properties. */ -int* getNodeStructurePointers(LOGMALLOCLIST* logmalloclist, NTREE* ntree); +LIBRARY_API int* getNodeStructurePointers(LOGMALLOCLIST* logmalloclist, NTREE* ntree); /** Return a List of Atomic Component Pointer property attached to a tree node. * * @param ntree A pointer to a tree node. If NULL the root node is assumed. * @return the List of Atomic Pointer Properties. */ -int* getNodeAtomicPointers(LOGMALLOCLIST* logmalloclist, NTREE* ntree); +LIBRARY_API int* getNodeAtomicPointers(LOGMALLOCLIST* logmalloclist, NTREE* ntree); /** Return a List of Rank values of the Structure Components attached to a tree node. * * @param ntree A pointer to a tree node. If NULL the root node is assumed. * @return the List of Structure Ranks. */ -int* getNodeStructureRank(LOGMALLOCLIST* logmalloclist, NTREE* ntree); +LIBRARY_API int* getNodeStructureRank(LOGMALLOCLIST* logmalloclist, NTREE* ntree); /** Return a List of Rank values of the Atomic Components attached to a tree node. * * @param ntree A pointer to a tree node. If NULL the root node is assumed. * @return the List of Atomic Ranks. */ -int* getNodeAtomicRank(LOGMALLOCLIST* logmalloclist, NTREE* ntree); +LIBRARY_API int* getNodeAtomicRank(LOGMALLOCLIST* logmalloclist, NTREE* ntree); /** Return a List of Shape Arrays of the Structure Components attached to a tree node. * * @param ntree A pointer to a tree node. If NULL the root node is assumed. * @return the List of Structure Shape Arrays. */ -int** getNodeStructureShape(LOGMALLOCLIST* logmalloclist, NTREE* ntree); +LIBRARY_API int** getNodeStructureShape(LOGMALLOCLIST* logmalloclist, NTREE* ntree); /** Return a List of Shape Arrays of the Atomic Components attached to a tree node. * @@ -813,7 +813,7 @@ int** getNodeStructureShape(LOGMALLOCLIST* logmalloclist, NTREE* ntree); * @return the List of Atomic Shape Arrays. */ -int** getNodeAtomicShape(LOGMALLOCLIST* logmalloclist, NTREE* ntree); +LIBRARY_API int** getNodeAtomicShape(LOGMALLOCLIST* logmalloclist, NTREE* ntree); /** Print the Names and Types of all Node Data Elements to a specified File Descriptor. @@ -823,7 +823,7 @@ int** getNodeAtomicShape(LOGMALLOCLIST* logmalloclist, NTREE* ntree); * @return Void */ -void printNodeNames(LOGMALLOCLIST* logmalloclist, NTREE* tree); +LIBRARY_API void printNodeNames(LOGMALLOCLIST* logmalloclist, NTREE* tree); /** Print the Atomic Data from a data node to a specified File Descriptor. * @@ -832,35 +832,35 @@ void printNodeNames(LOGMALLOCLIST* logmalloclist, NTREE* tree); * @return Void */ -void printNodeAtomic(LOGMALLOCLIST* logmalloclist, NTREE* tree); +LIBRARY_API void printNodeAtomic(LOGMALLOCLIST* logmalloclist, NTREE* tree); /** Return the number of User Defined Type Structure Definition Components attached to this tree node. * * @param ntree A pointer to a tree node. If NULL the root node is assumed. * @return the number of User Defined Type Structure Definition Components. */ -int getNodeStructureComponentCount(NTREE* ntree); +LIBRARY_API int getNodeStructureComponentCount(NTREE* ntree); /** Return a List of User Defined Type Structure Definition Components Names attached to this tree node. * * @param ntree A pointer to a tree node. If NULL the root node is assumed. * @return the List of User Defined Type Structure Definition Component names. */ -char** getNodeStructureComponentNames(NTREE* ntree); +LIBRARY_API char** getNodeStructureComponentNames(NTREE* ntree); /** Return a List of User Defined Type Structure Definition Components Types attached to this tree node. * * @param ntree A pointer to a tree node. If NULL the root node is assumed. * @return the List of User Defined Type Structure Definition Component Types. */ -char** getNodeStructureComponentTypes(NTREE* ntree); +LIBRARY_API char** getNodeStructureComponentTypes(NTREE* ntree); /** Return a List of User Defined Type Structure Definition Components Descriptions attached to this tree node. * * @param ntree A pointer to a tree node. If NULL the root node is assumed. * @return the List of User Defined Type Structure Definition Component Descriptions. */ -char** getNodeStructureComponentDescriptions(NTREE* ntree); +LIBRARY_API char** getNodeStructureComponentDescriptions(NTREE* ntree); /** Return the Count of User Defined Structure Component Data array elements attached to this tree node. @@ -870,7 +870,7 @@ char** getNodeStructureComponentDescriptions(NTREE* ntree); * @return the Count of User Defined Structure Component Data Array elements. */ -int getNodeStructureComponentDataCount(LOGMALLOCLIST* logmalloclist, NTREE* ntree, const char* target); +LIBRARY_API int getNodeStructureComponentDataCount(LOGMALLOCLIST* logmalloclist, NTREE* ntree, const char* target); /** Return the Rank of User Defined Structure Component Data array attached to this tree node. * @@ -879,7 +879,7 @@ int getNodeStructureComponentDataCount(LOGMALLOCLIST* logmalloclist, NTREE* ntre * @return the Rank of User Defined Structure Component Data array. */ -int getNodeStructureComponentDataRank(LOGMALLOCLIST* logmalloclist, NTREE* ntree, const char* target); +LIBRARY_API int getNodeStructureComponentDataRank(LOGMALLOCLIST* logmalloclist, NTREE* ntree, const char* target); /** Return the Shape array of the User Defined Structure Component Data array attached to this tree node. * @@ -888,7 +888,7 @@ int getNodeStructureComponentDataRank(LOGMALLOCLIST* logmalloclist, NTREE* ntree * @return the Shape array of length Rank of the User Defined Structure Component Data array. */ -int* getNodeStructureComponentDataShape(LOGMALLOCLIST* logmalloclist, NTREE* ntree, const char* target); +LIBRARY_API int* getNodeStructureComponentDataShape(LOGMALLOCLIST* logmalloclist, NTREE* ntree, const char* target); /** Return True (1) if the User Defined Structure Component Data array, attached to this tree node, * is a pointer type. Returns False (0) otherwise. @@ -898,7 +898,7 @@ int* getNodeStructureComponentDataShape(LOGMALLOCLIST* logmalloclist, NTREE* ntr * @return the value 1 if the User Defined Structure Component Data array is a pointer type. */ -int getNodeStructureComponentDataIsPointer(LOGMALLOCLIST* logmalloclist, NTREE* ntree, const char* target); +LIBRARY_API int getNodeStructureComponentDataIsPointer(LOGMALLOCLIST* logmalloclist, NTREE* ntree, const char* target); /** Return the Size of a User Defined Structure Component. * @@ -907,7 +907,7 @@ int getNodeStructureComponentDataIsPointer(LOGMALLOCLIST* logmalloclist, NTREE* * @return the Size of the User Defined Structure Component. */ -int getNodeStructureComponentDataSize(LOGMALLOCLIST* logmalloclist, NTREE* ntree, const char* target); +LIBRARY_API int getNodeStructureComponentDataSize(LOGMALLOCLIST* logmalloclist, NTREE* ntree, const char* target); /** Return the Type Name of a User Defined Structure Component. * @@ -916,7 +916,7 @@ int getNodeStructureComponentDataSize(LOGMALLOCLIST* logmalloclist, NTREE* ntree * @return the Type Name of the User Defined Structure Component. */ -const char* getNodeStructureComponentDataDataType(LOGMALLOCLIST* logmalloclist, NTREE* ntree, const char* target); +LIBRARY_API const char* getNodeStructureComponentDataDataType(LOGMALLOCLIST* logmalloclist, NTREE* ntree, const char* target); /** Return a pointer to a User Defined Structure Component's data. * @@ -925,7 +925,7 @@ const char* getNodeStructureComponentDataDataType(LOGMALLOCLIST* logmalloclist, * @return the User Defined Structure Component's data. */ -void* getNodeStructureComponentData(LOGMALLOCLIST* logmalloclist, NTREE* ntree, const char* target); +LIBRARY_API void* getNodeStructureComponentData(LOGMALLOCLIST* logmalloclist, NTREE* ntree, const char* target); /** Print a User Defined Structure Component's data. * @@ -935,7 +935,7 @@ void* getNodeStructureComponentData(LOGMALLOCLIST* logmalloclist, NTREE* ntree, * @return void. */ -void +LIBRARY_API void printNodeStructureComponentData(NTREE* ntree, LOGMALLOCLIST* logmalloclist, USERDEFINEDTYPELIST* userdefinedtypelist, const char* target); @@ -946,7 +946,7 @@ printNodeStructureComponentData(NTREE* ntree, LOGMALLOCLIST* logmalloclist, USER * @return void. */ -void printNodeStructure(LOGMALLOCLIST* logmalloclist, NTREE* ntree); +LIBRARY_API void printNodeStructure(LOGMALLOCLIST* logmalloclist, NTREE* ntree); /** Return a pointer to a User Defined Structure Component's data cast to FLOAT. * @@ -976,14 +976,14 @@ double* castNodeStructureComponentDatatoDouble(LOGMALLOCLIST* logmalloclist, NTR * @return Void. */ -void initNTree(NTREE* str); +LIBRARY_API void initNTree(NTREE* str); /** Initialise the Global NTREE list structure. * * @return Void. */ -void initNTreeList(); +LIBRARY_API void initNTreeList(); /** Print the Contents of a tree node to a specified File Descriptor. * @@ -992,7 +992,7 @@ void initNTreeList(); * @return Void */ -void printNTree2(NTREE* tree); +LIBRARY_API void printNTree2(NTREE* tree); /** Print the Contents of a tree node to a specified File Descriptor. * @@ -1001,7 +1001,7 @@ void printNTree2(NTREE* tree); * @return Void */ -void printNTree(NTREE* tree, USERDEFINEDTYPELIST* userdefinedtypelist); +LIBRARY_API void printNTree(NTREE* tree, USERDEFINEDTYPELIST* userdefinedtypelist); /** Print Details of the tree node List to a specified File Descriptor. * @@ -1010,7 +1010,7 @@ void printNTree(NTREE* tree, USERDEFINEDTYPELIST* userdefinedtypelist); * @return Void */ -void printNTreeList(NTREE* tree); +LIBRARY_API void printNTreeList(NTREE* tree); /** Return a Count of User Defined Type Tree Nodes from and including the passed tree node. * @@ -1018,7 +1018,7 @@ void printNTreeList(NTREE* tree); * @return the Count of Tree Nodes. */ -int getNTreeStructureCount(NTREE* ntree); +LIBRARY_API int getNTreeStructureCount(NTREE* ntree); /** Return a List of User Defined Type Structure Names attached to this tree branch. * @@ -1026,7 +1026,7 @@ int getNTreeStructureCount(NTREE* ntree); * @return the List of User Defined Type Structure names. */ -char** getNTreeStructureNames(LOGMALLOCLIST* logmalloclist, NTREE* ntree); +LIBRARY_API char** getNTreeStructureNames(LOGMALLOCLIST* logmalloclist, NTREE* ntree); /** Return a List of User Defined Type Structure Type Names attached to this tree branch. @@ -1034,7 +1034,7 @@ char** getNTreeStructureNames(LOGMALLOCLIST* logmalloclist, NTREE* ntree); * @param ntree A pointer to a tree node. If NULL the root node is assumed. * @return the List of User Defined Type Structure Type names. */ -char** getNTreeStructureTypes(LOGMALLOCLIST* logmalloclist, NTREE* ntree); +LIBRARY_API char** getNTreeStructureTypes(LOGMALLOCLIST* logmalloclist, NTREE* ntree); /** Print the Names and Types of all Data Structures to a specified File Descriptor. * @@ -1042,35 +1042,35 @@ char** getNTreeStructureTypes(LOGMALLOCLIST* logmalloclist, NTREE* ntree); * @param tree A pointer to a tree node. If NULL the root node is assumed. * @return Void */ -void printNTreeStructureNames(LOGMALLOCLIST* logmalloclist, NTREE* tree); +LIBRARY_API void printNTreeStructureNames(LOGMALLOCLIST* logmalloclist, NTREE* tree); /** Return the total number of User Defined Type Structure Definition Components attached to this tree branch. * * @param ntree A pointer to a tree node. If NULL the root node is assumed. * @return the number of User Defined Type Structure Definition Components. */ -int getNTreeStructureComponentCount(NTREE* ntree); +LIBRARY_API int getNTreeStructureComponentCount(NTREE* ntree); /** Return a List of User Defined Type Structure Definition Components Names attached to this tree branch. * * @param ntree A pointer to a tree node. If NULL the root node is assumed. * @return the List of User Defined Type Structure Definition Component names. */ -char** getNTreeStructureComponentNames(LOGMALLOCLIST* logmalloclist, NTREE* ntree); +LIBRARY_API char** getNTreeStructureComponentNames(LOGMALLOCLIST* logmalloclist, NTREE* ntree); /** Return a List of User Defined Type Structure Definition Components Types attached to this tree branch. * * @param ntree A pointer to a tree node. If NULL the root node is assumed. * @return the List of User Defined Type Structure Definition Component Types. */ -char** getNTreeStructureComponentTypes(LOGMALLOCLIST* logmalloclist, NTREE* ntree); +LIBRARY_API char** getNTreeStructureComponentTypes(LOGMALLOCLIST* logmalloclist, NTREE* ntree); /** Return a List of User Defined Type Structure Definition Components Descriptions attached to this tree branch. * * @param ntree A pointer to a tree node. If NULL the root node is assumed. * @return the List of User Defined Type Structure Definition Component Descriptions. */ -char** getNTreeStructureComponentDescriptions(LOGMALLOCLIST* logmalloclist, NTREE* ntree); +LIBRARY_API char** getNTreeStructureComponentDescriptions(LOGMALLOCLIST* logmalloclist, NTREE* ntree); /** Print the Names and Types of all Data Elements to a specified File Descriptor. * @@ -1078,42 +1078,42 @@ char** getNTreeStructureComponentDescriptions(LOGMALLOCLIST* logmalloclist, NTRE * @param tree A pointer to a tree node. If NULL the root node is assumed. * @return Void */ -void printNTreeStructureComponentNames(LOGMALLOCLIST* logmalloclist, NTREE* tree); +LIBRARY_API void printNTreeStructureComponentNames(LOGMALLOCLIST* logmalloclist, NTREE* tree); //======================================================================================================= // Print utility functions: explicit output to stdout -void printNode_stdout(NTREE* tree); +LIBRARY_API void printNode_stdout(NTREE* tree); -void printNodeNames_stdout(LOGMALLOCLIST* logmalloclist, NTREE* tree); +LIBRARY_API void printNodeNames_stdout(LOGMALLOCLIST* logmalloclist, NTREE* tree); -void printNodeAtomic_stdout(LOGMALLOCLIST* logmalloclist, NTREE* tree); +LIBRARY_API void printNodeAtomic_stdout(LOGMALLOCLIST* logmalloclist, NTREE* tree); -void printNTreeStructureNames_stdout(LOGMALLOCLIST* logmalloclist, NTREE* tree); +LIBRARY_API void printNTreeStructureNames_stdout(LOGMALLOCLIST* logmalloclist, NTREE* tree); -void printNTreeStructureComponentNames_stdout(LOGMALLOCLIST* logmalloclist, NTREE* tree); +LIBRARY_API void printNTreeStructureComponentNames_stdout(LOGMALLOCLIST* logmalloclist, NTREE* tree); -void printAtomicType_stdout(LOGMALLOCLIST* logmalloclist, NTREE* tree, const char* target); +LIBRARY_API void printAtomicType_stdout(LOGMALLOCLIST* logmalloclist, NTREE* tree, const char* target); -void getNodeStructureComponentDataShape_f(LOGMALLOCLIST* logmalloclist, NTREE* ntree, const char* target, int* shape_f); +LIBRARY_API void getNodeStructureComponentDataShape_f(LOGMALLOCLIST* logmalloclist, NTREE* ntree, const char* target, int* shape_f); -void getNodeStructureComponentShortData_f(LOGMALLOCLIST* logmalloclist, NTREE* node, const char* target, short* data_f); +LIBRARY_API void getNodeStructureComponentShortData_f(LOGMALLOCLIST* logmalloclist, NTREE* node, const char* target, short* data_f); -void getNodeStructureComponentFloatData_f(LOGMALLOCLIST* logmalloclist, NTREE* node, const char* target, float* data_f); +LIBRARY_API void getNodeStructureComponentFloatData_f(LOGMALLOCLIST* logmalloclist, NTREE* node, const char* target, float* data_f); -void dereferenceShortData(short* data_c, int count, short* data_f); +LIBRARY_API void dereferenceShortData(short* data_c, int count, short* data_f); -void dereferenceFloatData(float* data_c, int count, float* data_f); +LIBRARY_API void dereferenceFloatData(float* data_c, int count, float* data_f); short* castNodeStructureComponentDatatoShort(LOGMALLOCLIST* logmalloclist, NTREE* ntree, const char* target); -void +LIBRARY_API void castNodeStructureComponentDatatoShort_f(LOGMALLOCLIST* logmalloclist, NTREE* node, const char* target, short* data_f); -void +LIBRARY_API void castNodeStructureComponentDatatoFloat_f(LOGMALLOCLIST* logmalloclist, NTREE* node, const char* target, float* data_f); -void +LIBRARY_API void addStructureField(USERDEFINEDTYPE* user_type, const char* name, const char* desc, UDA_TYPE data_type, bool is_pointer, int rank, int* shape, size_t offset); From 40b96d592b7020c7bff1c1ea81794907879972f8 Mon Sep 17 00:00:00 2001 From: sdixon Date: Thu, 24 Aug 2023 16:47:26 +0100 Subject: [PATCH 37/39] adding extern C back into structure function headers for IDL wrapper compatibility --- source/structures/accessors.h | 8 ++++++++ source/structures/struct.h | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/source/structures/accessors.h b/source/structures/accessors.h index 2aadbb79..7c061d07 100755 --- a/source/structures/accessors.h +++ b/source/structures/accessors.h @@ -1,6 +1,10 @@ #ifndef UDA_STRUCTURES_ACCESSORS_H #define UDA_STRUCTURES_ACCESSORS_H +#ifdef __cplusplus +} +#endif + #include #include @@ -235,4 +239,8 @@ LIBRARY_API void defineField(COMPOUNDFIELD* field, const char* name, const char* LIBRARY_API void defineCompoundField(COMPOUNDFIELD* field, const char* type, const char* name, char* desc, int offset, int size); +#ifdef __cplusplus +} +#endif + #endif // UDA_STRUCTURES_ACCESSORS_H diff --git a/source/structures/struct.h b/source/structures/struct.h index 6a0cc533..3933bcc0 100755 --- a/source/structures/struct.h +++ b/source/structures/struct.h @@ -12,6 +12,10 @@ # include #endif +#ifdef __cplusplus +extern "C" { +#endif + LIBRARY_API NTREE* udaGetFullNTree(); LIBRARY_API void udaSetFullNTree(NTREE* ntree); @@ -1117,5 +1121,9 @@ LIBRARY_API void addStructureField(USERDEFINEDTYPE* user_type, const char* name, const char* desc, UDA_TYPE data_type, bool is_pointer, int rank, int* shape, size_t offset); +#ifdef __cplusplus +} +#endif + #endif // UDA_STRUCTURES_STRUCT_H From 7cb0d4cd16cdc122d7980347a66d2aa4b1a0c22f Mon Sep 17 00:00:00 2001 From: sdixon Date: Thu, 24 Aug 2023 16:59:18 +0100 Subject: [PATCH 38/39] fixing minor typo --- source/structures/accessors.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/structures/accessors.h b/source/structures/accessors.h index 7c061d07..b6ab2810 100755 --- a/source/structures/accessors.h +++ b/source/structures/accessors.h @@ -2,7 +2,7 @@ #define UDA_STRUCTURES_ACCESSORS_H #ifdef __cplusplus -} +extern "C" { #endif #include From 832925e136c3dbbc01afe85c276c73aae10b82bc Mon Sep 17 00:00:00 2001 From: sdixon Date: Mon, 28 Aug 2023 22:42:27 +0100 Subject: [PATCH 39/39] updating path in machine.d for mastu archive mount --- source/etc/machine.d/mast.l.cfg | 4 ++-- source/etc/xinetd.conf.in | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/source/etc/machine.d/mast.l.cfg b/source/etc/machine.d/mast.l.cfg index 8daad611..9882e812 100644 --- a/source/etc/machine.d/mast.l.cfg +++ b/source/etc/machine.d/mast.l.cfg @@ -10,7 +10,7 @@ export UDA_SQLUSER=readonly # SQL Database User export UDA_HOST2=${UDA_HOST} export UDA_PORT2=${UDA_PORT} -DATA_ARCHIVE=/net/mustrgsrvr1/export/mastu/data +DATA_ARCHIVE=/net/raidsrvr/data export MAST_DATA=${DATA_ARCHIVE}/MAST_Data export MAST_IMAGES=${DATA_ARCHIVE}/MAST_IMAGES @@ -26,4 +26,4 @@ export START_DATA=${DATA_ARCHIVE}/START_RES export UDA_METADATA_PLUGIN=MASTU_DB export UDA_TESTDB_SQLDBNAME=uda # SQL Database Name -export UDA_PLUGIN_DEBUG_SINGLEFILE=1 \ No newline at end of file +export UDA_PLUGIN_DEBUG_SINGLEFILE=1 diff --git a/source/etc/xinetd.conf.in b/source/etc/xinetd.conf.in index 368a98f1..028b2b69 100755 --- a/source/etc/xinetd.conf.in +++ b/source/etc/xinetd.conf.in @@ -15,8 +15,8 @@ service @USER@uda server = @CMAKE_INSTALL_PREFIX@/etc/udaserver.sh #env = UDAHOSTNAME=uda-external-jet - instances = 50 - per_source = 10 + instances = 100 + per_source = 30 v6only = no groups = yes