@@ -2720,8 +2720,7 @@ class Bar {
27202720
27212721 @needs_dylink
27222722 def test_dlfcn_qsort (self ):
2723- self .set_setting ('EXPORTED_FUNCTIONS' , ['_get_cmp' ])
2724- create_file ('liblib.cpp' , '''
2723+ create_file ('liblib.c' , '''
27252724 int lib_cmp(const void* left, const void* right) {
27262725 const int* a = (const int*) left;
27272726 const int* b = (const int*) right;
@@ -2732,14 +2731,13 @@ def test_dlfcn_qsort(self):
27322731
27332732 typedef int (*CMP_TYPE)(const void*, const void*);
27342733
2735- extern "C" CMP_TYPE get_cmp() {
2734+ CMP_TYPE get_cmp() {
27362735 return lib_cmp;
27372736 }
27382737 ''' )
2739- self .build_dlfcn_lib ('liblib.cpp ' )
2738+ self .build_dlfcn_lib ('liblib.c ' )
27402739
27412740 self .prep_dlfcn_main ()
2742- self .set_setting ('EXPORTED_FUNCTIONS' , ['_main' , '_malloc' ])
27432741 src = '''
27442742 #include <stdio.h>
27452743 #include <stdlib.h>
@@ -2798,7 +2796,7 @@ def test_dlfcn_data_and_fptr(self):
27982796 if self .is_wasm ():
27992797 self .banned_js_engines = [config .V8_ENGINE ]
28002798
2801- create_file ('liblib.cpp ' , r'''
2799+ create_file ('liblib.c ' , r'''
28022800 #include <stdio.h>
28032801
28042802 int theglobal = 42;
@@ -2818,14 +2816,13 @@ def test_dlfcn_data_and_fptr(self):
28182816 p_f();
28192817 }
28202818
2821- extern "C" void (*func(int x, void(*fptr)()))() {
2819+ void (*func(int x, void(*fptr)()))() {
28222820 printf("In func: %d\n", x);
28232821 fptr();
28242822 return lib_fptr;
28252823 }
28262824 ''' )
2827- self .set_setting ('EXPORTED_FUNCTIONS' , ['_func' ])
2828- self .build_dlfcn_lib ('liblib.cpp' )
2825+ self .build_dlfcn_lib ('liblib.c' )
28292826
28302827 self .prep_dlfcn_main ()
28312828 src = r'''
@@ -2881,15 +2878,14 @@ def test_dlfcn_data_and_fptr(self):
28812878 return 0;
28822879 }
28832880 '''
2884- self .set_setting ('EXPORTED_FUNCTIONS' , ['_main' ])
28852881 self .do_run (src , '''\
28862882 In func: 13
28872883First calling main_fptr from lib.
28882884Second calling lib_fptr from main.
28892885parent_func called from child
28902886parent_func called from child
28912887Var: 42
2892- ''' )
2888+ ''' , force_c = True )
28932889
28942890 @needs_dylink
28952891 def test_dlfcn_varargs (self ):
@@ -2898,12 +2894,11 @@ def test_dlfcn_varargs(self):
28982894
28992895 create_file ('liblib.cpp' , r'''
29002896 void print_ints(int n, ...);
2901- extern "C" void func() {
2897+ void func() {
29022898 print_ints(2, 13, 42);
29032899 }
29042900 ''' )
2905- self .set_setting ('EXPORTED_FUNCTIONS' , ['_func' ])
2906- self .build_dlfcn_lib ('liblib.cpp' )
2901+ self .build_dlfcn_lib ('liblib.c' )
29072902
29082903 self .prep_dlfcn_main ()
29092904 src = r'''
@@ -2935,8 +2930,7 @@ def test_dlfcn_varargs(self):
29352930 return 0;
29362931 }
29372932 '''
2938- self .set_setting ('EXPORTED_FUNCTIONS' , ['_main' ])
2939- self .do_run (src , '100\n 200\n 13\n 42\n ' )
2933+ self .do_run (src , '100\n 200\n 13\n 42\n ' , force_c = True )
29402934
29412935 @needs_dylink
29422936 def test_dlfcn_alignment_and_zeroing (self ):
@@ -3038,7 +3032,6 @@ def test_dlfcn_unique_sig(self):
30383032 return 13;
30393033 }
30403034 ''' )
3041- self .set_setting ('EXPORTED_FUNCTIONS' , ['_myfunc' ])
30423035 self .build_dlfcn_lib ('liblib.c' )
30433036
30443037 self .prep_dlfcn_main ()
@@ -3065,7 +3058,6 @@ def test_dlfcn_unique_sig(self):
30653058 return 0;
30663059 }
30673060 ''' )
3068- self .set_setting ('EXPORTED_FUNCTIONS' , ['_main' , '_malloc' ])
30693061 self .do_runf ('main.c' , 'success' )
30703062
30713063 @needs_dylink
@@ -3077,7 +3069,6 @@ def test_dlfcn_info(self):
30773069 return 13;
30783070 }
30793071 ''' )
3080- self .set_setting ('EXPORTED_FUNCTIONS' , ['_myfunc' ])
30813072 self .build_dlfcn_lib ('liblib.c' )
30823073
30833074 self .prep_dlfcn_main ()
@@ -3119,7 +3110,6 @@ def test_dlfcn_info(self):
31193110 return 0;
31203111 }
31213112 ''' )
3122- self .set_setting ('EXPORTED_FUNCTIONS' , ['_main' , '_malloc' ])
31233113 self .do_runf ('main.c' , 'success' )
31243114
31253115 @needs_dylink
@@ -3139,7 +3129,6 @@ def test_dlfcn_stacks(self):
31393129 return strlen(bigstack);
31403130 }
31413131 ''' )
3142- self .set_setting ('EXPORTED_FUNCTIONS' , ['_myfunc' ])
31433132 self .build_dlfcn_lib ('liblib.c' )
31443133
31453134 self .prep_dlfcn_main ()
@@ -3174,7 +3163,6 @@ def test_dlfcn_stacks(self):
31743163 return 0;
31753164 }
31763165 ''' )
3177- self .set_setting ('EXPORTED_FUNCTIONS' , ['_main' , '_malloc' , '_strcmp' ])
31783166 self .do_runf ('main.c' , 'success' )
31793167
31803168 @needs_dylink
@@ -3210,7 +3198,6 @@ def test_dlfcn_funcs(self):
32103198 }
32113199 }
32123200 ''' )
3213- self .set_setting ('EXPORTED_FUNCTIONS' , ['_callvoid' , '_callint' , '_getvoid' , '_getint' ])
32143201 self .build_dlfcn_lib ('liblib.c' )
32153202
32163203 self .prep_dlfcn_main ()
@@ -3261,7 +3248,6 @@ def test_dlfcn_funcs(self):
32613248 return 0;
32623249 }
32633250 ''' )
3264- self .set_setting ('EXPORTED_FUNCTIONS' , ['_main' , '_malloc' ])
32653251 self .do_runf ('main.c' , '''go
32663252void_main.
32673253int_main 201
@@ -3286,11 +3272,9 @@ def test_dlfcn_mallocs(self):
32863272 void *mallocproxy(int n) { return malloc(n); }
32873273 void freeproxy(void *p) { free(p); }
32883274 ''' )
3289- self .set_setting ('EXPORTED_FUNCTIONS' , ['_mallocproxy' , '_freeproxy' ])
32903275 self .build_dlfcn_lib ('liblib.c' )
32913276
32923277 self .prep_dlfcn_main ()
3293- self .set_setting ('EXPORTED_FUNCTIONS' , ['_main' , '_malloc' , '_free' ])
32943278 self .do_runf (test_file ('dlmalloc_proxy.c' ), '*294,153*' )
32953279
32963280 @needs_dylink
@@ -3338,7 +3322,6 @@ def test_dlfcn_longjmp(self):
33383322 return 0;
33393323 }
33403324 ''' )
3341- self .set_setting ('EXPORTED_FUNCTIONS' , ['_main' , '_malloc' , '_free' ])
33423325 self .do_runf ('main.c' , '''go!
33433326pre 1
33443327pre 2
@@ -3410,7 +3393,6 @@ def zzztest_dlfcn_exceptions(self):
34103393 return 0;
34113394 }
34123395 '''
3413- self .set_setting ('EXPORTED_FUNCTIONS' , ['_main' , '_malloc' , '_free' ])
34143396 self .do_run (src , '''go!
34153397ok: 65
34163398int 123
@@ -3428,8 +3410,9 @@ def indir(name):
34283410 create_file ('a.cpp' , r'''
34293411 #include <stdio.h>
34303412
3431- static struct a {
3432- a() {
3413+ static class A {
3414+ public:
3415+ A() {
34333416 puts("a: loaded");
34343417 }
34353418 } _;
@@ -3438,8 +3421,9 @@ def indir(name):
34383421 create_file ('b.cpp' , r'''
34393422 #include <stdio.h>
34403423
3441- static struct b {
3442- b() {
3424+ static class B {
3425+ public:
3426+ B() {
34433427 puts("b: loaded");
34443428 }
34453429 } _;
@@ -3488,12 +3472,12 @@ def indir(name):
34883472 def test_dlfcn_feature_in_lib (self ):
34893473 self .emcc_args .append ('-mnontrapping-fptoint' )
34903474
3491- create_file ('liblib.cpp ' , r'''
3492- extern "C" int magic(float x) {
3475+ create_file ('liblib.c ' , r'''
3476+ int magic(float x) {
34933477 return __builtin_wasm_trunc_saturate_s_i32_f32(x);
34943478 }
34953479 ''' )
3496- self .build_dlfcn_lib ('liblib.cpp ' )
3480+ self .build_dlfcn_lib ('liblib.c ' )
34973481
34983482 self .prep_dlfcn_main ()
34993483 src = r'''
0 commit comments