Skip to content

Commit 8b75a3a

Browse files
author
Robert Mijaković
committed
Pushes some pending changes.
1 parent 5eaa1b9 commit 8b75a3a

File tree

2 files changed

+2
-46
lines changed

2 files changed

+2
-46
lines changed

EnoptMP.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ int32_t init( void )
4040
{
4141
debug_printf( "EnoptMP: %s: Entering\n", __func__ );
4242

43-
if( init_enopt_wrapper() != 0 )
43+
if( enopt_init() != 0 )
4444
{
4545
printf( "EnoptMP: %s: enopt_init: Unable to initialize enopt metric source\n", __func__ );
4646
return -1;
@@ -174,7 +174,7 @@ void fini( void )
174174
debug_printf( "EnoptMP: %s: Entering\n", __func__ );
175175
enopt_stop();
176176

177-
if( finalize_enopt_wrapper() != 0 )
177+
if( enopt_finalize() != 0 )
178178
{
179179
printf( "EnoptMP: %s: Unable to finalize enopt metric source\n", __func__ );
180180
abort();

Shared.c

-44
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99

1010
const char* ENV_VAR_DEBUG_OUTPUT = "ENOPT_ENABLE_DEBUG_OUTPUT";
11-
const char* ENV_VAR_INIT_COUNTER = "ENOPT_INIT_COUNT";
1211

1312

1413
void debug_printf(const char* format, ...) {
@@ -20,46 +19,3 @@ void debug_printf(const char* format, ...) {
2019
vfprintf(stderr, format, ap);
2120
va_end(ap);
2221
}
23-
24-
25-
int read_count() {
26-
const char* countStr = getenv(ENV_VAR_INIT_COUNTER);
27-
return countStr ? strtol(countStr, NULL, 10) : 0;
28-
}
29-
30-
31-
void write_count(int count) {
32-
char str[16];
33-
sprintf(str, "%d", count);
34-
setenv(ENV_VAR_INIT_COUNTER, str, 1);
35-
}
36-
37-
38-
int init_enopt_wrapper() {
39-
int count = read_count();
40-
int result = (count == 0) ? enopt_init() : 0;
41-
write_count(++count);
42-
debug_printf("NOTE: After increasing, the new init count is: %i\n", count);
43-
44-
return result;
45-
}
46-
47-
48-
int finalize_enopt_wrapper() {
49-
int count = read_count();
50-
if( count <= 0 ) {
51-
printf("ERROR: Finalize called more often than initialize!\n");
52-
abort();
53-
}
54-
55-
int result = 0;
56-
if( count == 1 ) {
57-
debug_printf("NOTE: Init count is going to 0, finalizing Enopt...\n");
58-
result = enopt_finalize();
59-
}
60-
61-
write_count(--count);
62-
debug_printf("NOTE: After decreasing, the new init count is: %i\n", count);
63-
64-
return result;
65-
}

0 commit comments

Comments
 (0)