Skip to content

Commit

Permalink
move _vinit_caller/_vcleanup_caller fn declare forword
Browse files Browse the repository at this point in the history
  • Loading branch information
kbkpbot committed Jan 18, 2025
1 parent 5dd28cf commit 9ea8525
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
12 changes: 2 additions & 10 deletions vlib/v/gen/c/cgen.v
Original file line number Diff line number Diff line change
Expand Up @@ -6286,11 +6286,7 @@ fn (mut g Gen) write_init_function() {
// provide a constructor/destructor pair, ensuring that all constants
// are initialized just once, and that they will be freed too.
// Note: os.args in this case will be [].
if g.pref.os == .windows {
g.writeln('// workaround for windows, export _vinit_caller, let dl.open() call it')
g.writeln('// NOTE: This is hardcoded in vlib/dl/dl_windows.c.v!')
g.writeln('VV_EXPORTED_SYMBOL void _vinit_caller();')
} else {
if g.pref.os != .windows {
g.writeln('__attribute__ ((constructor))')
}
g.writeln('void _vinit_caller() {')
Expand All @@ -6301,11 +6297,7 @@ fn (mut g Gen) write_init_function() {
g.writeln('\t_vinit(0,0);')
g.writeln('}')

if g.pref.os == .windows {
g.writeln('// workaround for windows, export _vcleanup_caller, let dl.close() call it')
g.writeln('// NOTE: This is hardcoded in vlib/dl/dl_windows.c.v!')
g.writeln('VV_EXPORTED_SYMBOL void _vcleanup_caller();')
} else {
if g.pref.os != .windows {
g.writeln('__attribute__ ((destructor))')
}
g.writeln('void _vcleanup_caller() {')
Expand Down
6 changes: 6 additions & 0 deletions vlib/v/gen/c/cheaders.v
Original file line number Diff line number Diff line change
Expand Up @@ -536,6 +536,12 @@ typedef int (*qsort_callback_func)(const void*, const void*);
int load_so(byteptr);
void _vinit(int ___argc, voidptr ___argv);
void _vcleanup(void);
#ifdef _WIN32
// workaround for windows, export _vinit_caller/_vcleanup_caller, let dl.open()/dl.close() call it
// NOTE: This is hardcoded in vlib/dl/dl_windows.c.v!
VV_EXPORTED_SYMBOL void _vinit_caller();
VV_EXPORTED_SYMBOL void _vcleanup_caller();
#endif
#define sigaction_size sizeof(sigaction);
#define _ARR_LEN(a) ( (sizeof(a)) / (sizeof(a[0])) )
Expand Down

0 comments on commit 9ea8525

Please sign in to comment.