Skip to content

Commit a8c618a

Browse files
committed
x
1 parent ce7ee13 commit a8c618a

File tree

6 files changed

+22
-19
lines changed

6 files changed

+22
-19
lines changed

.github/workflows/reusable_proxy_lib.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ jobs:
5454
- name: Build UMF
5555
run: cmake --build ${{env.BUILD_DIR}} -j $(nproc)
5656

57+
- name: Run "ctest --output-on-failure" without proxy library
58+
working-directory: ${{env.BUILD_DIR}}
59+
run: ctest --output-on-failure
60+
5761
- name: Run "ctest --output-on-failure" with proxy library
5862
working-directory: ${{env.BUILD_DIR}}
5963
run: LD_PRELOAD=./lib/libumf_proxy.so ctest --output-on-failure

src/coarse/coarse.c

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,6 @@
2222
#include "utils_concurrency.h"
2323
#include "utils_log.h"
2424

25-
#ifdef _WIN32
26-
UTIL_ONCE_FLAG Log_initialized = UTIL_ONCE_FLAG_INIT;
27-
#else
28-
void __attribute__((constructor)) coarse_init(void) { utils_log_init(); }
29-
void __attribute__((destructor)) coarse_destroy(void) {}
30-
#endif /* _WIN32 */
31-
3225
typedef struct coarse_t {
3326
// handle of the memory provider
3427
void *provider;

src/libumf_linux.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99

1010
#include <umf.h>
1111

12-
void __attribute__((constructor)) umfCreate(void) { (void)umfInit(); }
12+
void __attribute__((constructor(102))) umfCreate(void) { (void)umfInit(); }
1313

14-
void __attribute__((destructor)) umfDestroy(void) { (void)umfTearDown(); }
14+
void __attribute__((destructor(102))) umfDestroy(void) { (void)umfTearDown(); }
1515

1616
void libumfInit(void) {
1717
// do nothing, additional initialization not needed

src/proxy_lib/proxy_lib_linux.c

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
*
3-
* Copyright (C) 2024 Intel Corporation
3+
* Copyright (C) 2024-2025 Intel Corporation
44
*
55
* Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT.
66
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
@@ -9,15 +9,10 @@
99

1010
#include "proxy_lib.h"
1111

12-
// The priority 102 is used, because the constructor should be called as the second one
13-
// (just after the first constructor of the base allocator with priority 101)
14-
// and the destructor as the last but one (just before the last destructor
15-
// of the base allocator with priority 101), because this library
16-
// provides the memory allocation API.
17-
void __attribute__((constructor(102))) proxy_lib_create(void) {
12+
void __attribute__((constructor(101))) proxy_lib_create(void) {
1813
proxy_lib_create_common();
1914
}
2015

21-
void __attribute__((destructor(102))) proxy_lib_destroy(void) {
16+
void __attribute__((destructor(101))) proxy_lib_destroy(void) {
2217
proxy_lib_destroy_common();
2318
}

src/utils/utils_load_library.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,16 @@ void *utils_open_library(const char *filename, int userFlags) {
7979
LOG_FATAL("dlopen(%s) failed with error: %s", filename, dlerror());
8080
}
8181

82+
LOG_DEBUG("Opened library %s with handle %p", filename, handle);
83+
8284
return handle;
8385
}
8486

85-
int utils_close_library(void *handle) { return dlclose(handle); }
87+
int utils_close_library(void *handle) {
88+
LOG_DEBUG("Closing library handle %p", handle);
89+
90+
return dlclose(handle);
91+
}
8692

8793
void *utils_get_symbol_addr(void *handle, const char *symbol,
8894
const char *libname) {

src/utils/utils_log.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include "ctl/ctl_internal.h"
3131
#include "utils_assert.h"
3232
#include "utils_common.h"
33+
#include "utils_concurrency.h"
3334
#include "utils_log.h"
3435

3536
#define UMF_MAGIC_STR "\x00@(#) "
@@ -60,6 +61,8 @@ char const __umf_str_1__all_cmake_vars[] =
6061
#define MAX_FILE_PATH 256
6162
#define MAX_ENV_LEN 2048
6263

64+
static UTIL_ONCE_FLAG initOnce = UTIL_ONCE_FLAG_INIT;
65+
6366
typedef struct {
6467
bool enableTimestamp;
6568
bool enablePid;
@@ -247,7 +250,7 @@ void utils_plog(utils_log_level_t level, const char *func, const char *format,
247250

248251
static const char *bool_to_str(int b) { return b ? "yes" : "no"; }
249252

250-
void utils_log_init(void) {
253+
static void utils_log_init_once(void) {
251254
const char *envVar = getenv("UMF_LOG");
252255

253256
if (!envVar) {
@@ -342,6 +345,8 @@ void utils_log_init(void) {
342345
bool_to_str(loggerConfig.enableTimestamp));
343346
}
344347

348+
void utils_log_init(void) { utils_init_once(&initOnce, utils_log_init_once); }
349+
345350
// this is needed for logger unit test
346351
#ifndef DISABLE_CTL_LOGGER
347352
static umf_result_t

0 commit comments

Comments
 (0)