Skip to content

Commit

Permalink
generic / fixes in new changes
Browse files Browse the repository at this point in the history
  • Loading branch information
radkesvat committed Aug 1, 2024
1 parent 4dce6a8 commit 2e9e94f
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 13 deletions.
2 changes: 2 additions & 0 deletions tunnels/adapters/connector/udp/udp_connector.c
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,8 @@ tunnel_t *newUdpConnector(node_instance_context_t *instance_info)
}
if (state->dest_addr_selected.status == kDvsConstant)
{
state->constant_dest_addr.address_type = getHostAddrType(state->dest_addr_selected.value_ptr);

if (state->constant_dest_addr.address_type == kSatDomainName)
{
socketContextDomainSetConstMem(&(state->constant_dest_addr), state->dest_addr_selected.value_ptr,
Expand Down
46 changes: 45 additions & 1 deletion ww/library_loader.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "loggers/core_logger.h" //NOLINT
#include "stc/common.h"
#include "utils/hashutils.h"
#include "hplatform.h"
#include <stdlib.h>
#include <string.h>

Expand All @@ -17,6 +18,49 @@ static struct
vec_static_libs slibs;
} *state;


// #ifdef OS_WIN
// #include <windows.h> // for Windows LoadLibrary/GetProcAddress
// #else
// #include <dlfcn.h> // for POSIX dlopen/dlsym
// #endif

// void *getSymbol(void *libHandle, const char *name) {
// #ifdef OS_WIN
// return GetProcAddress((HMODULE)libHandle, name);
// #else
// return dlsym(libHandle, name);
// #endif
// }

// static tunnel_lib_t dynLoadTunnelLib(hash_t hname) {
// char libName[256];
// snprintf(libName, sizeof(libName), "libname-%u.so", hname); // Example library name generation

// void *handle = NULL;
// #ifdef OS_WIN
// handle = LoadLibrary(libName);
// #else
// handle = dlopen(libName, RTLD_LAZY);
// #endif

// if (!handle) {
// LOGF("Failed to load library: %s", libName);
// return (tunnel_lib_t){0};
// }

// tunnel_lib_t lib = {0};
// lib.createHandle = (struct tunnel_s *(*)(node_instance_context_t *))getSymbol(handle, "createHandle");
// lib.destroyHandle = (struct tunnel_s *(*)(struct tunnel_s *))getSymbol(handle, "destroyHandle");
// lib.apiHandle = (api_result_t (*)(struct tunnel_s *, const char *))getSymbol(handle, "apiHandle");
// lib.getMetadataHandle = (tunnel_metadata_t (*)(void))getSymbol(handle, "getMetadataHandle");
// lib.hash_name = hname;

// return lib;
// }



static tunnel_lib_t dynLoadTunnelLib(hash_t hname)
{
(void) hname;
Expand All @@ -39,13 +83,13 @@ tunnel_lib_t loadTunnelLibByHash(hash_t hname)
}
return dynLoadTunnelLib(hname);
}

tunnel_lib_t loadTunnelLib(const char *name)
{
hash_t hname = CALC_HASH_BYTES(name, strlen(name));
return loadTunnelLibByHash(hname);
}

// CHECKFOR(TcpListener);

void registerStaticLib(tunnel_lib_t lib)
{
Expand Down
14 changes: 8 additions & 6 deletions ww/managers/memory_manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,21 @@ enum

#ifdef ALLOCATOR_BYPASS

dedicated_memory_t *initMemoryManager(void)
{
return NULL;
}

dedicated_memory_t *getMemoryManager(void)
void initMemoryManager(void)
{
return NULL;
// assert(state == NULL);
// state = createWWDedicatedMemory();
// return state;
}


void setMemoryManager(dedicated_memory_t *new_state)
{
(void) new_state;

// assert(state == NULL);
// state = new_state;
}

dedicated_memory_t *createWWDedicatedMemory(void)
Expand Down
12 changes: 6 additions & 6 deletions ww/ww.c
Original file line number Diff line number Diff line change
Expand Up @@ -135,12 +135,12 @@ static void initializeShortCuts(void)

void **space = globalMalloc(sizeof(void *) * kShourtcutsCount * total_workers);

GSTATE.shortcut_loops = (hloop_t **) (space + (0 * sizeof(void *) * total_workers));
GSTATE.shortcut_buffer_pools = (buffer_pool_t **) (space + (1 * sizeof(void *) * total_workers));
GSTATE.shortcut_shift_buffer_pools = (generic_pool_t **) (space + (2 * sizeof(void *) * total_workers));
GSTATE.shortcut_context_pools = (generic_pool_t **) (space + (3 * sizeof(void *) * total_workers));
GSTATE.shortcut_line_pools = (generic_pool_t **) (space + (4 * sizeof(void *) * total_workers));
GSTATE.shortcut_pipeline_msg_pools = (generic_pool_t **) (space + (5 * sizeof(void *) * total_workers));
GSTATE.shortcut_loops = (hloop_t **) (space + (0 *total_workers));
GSTATE.shortcut_buffer_pools = (buffer_pool_t **) (space + (1 * total_workers));
GSTATE.shortcut_shift_buffer_pools = (generic_pool_t **) (space + (2 * total_workers));
GSTATE.shortcut_context_pools = (generic_pool_t **) (space + (3 * total_workers));
GSTATE.shortcut_line_pools = (generic_pool_t **) (space + (4 * total_workers));
GSTATE.shortcut_pipeline_msg_pools = (generic_pool_t **) (space + (5 * total_workers));
}

void createWW(const ww_construction_data_t init_data)
Expand Down

0 comments on commit 2e9e94f

Please sign in to comment.