Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cgen,cheaders: move _vinit_caller()/_vcleanup_caller() fn declare forword #23507

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Comment on lines +539 to +544
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I fail to see, what the benefit of this is, compared to the previous approach, of only generating those lines conditionally.

#define sigaction_size sizeof(sigaction);
#define _ARR_LEN(a) ( (sizeof(a)) / (sizeof(a[0])) )
Expand Down
Loading