@@ -2720,8 +2720,7 @@ class Bar {
2720
2720
2721
2721
@needs_dylink
2722
2722
def test_dlfcn_qsort (self ):
2723
- self .set_setting ('EXPORTED_FUNCTIONS' , ['_get_cmp' ])
2724
- create_file ('liblib.cpp' , '''
2723
+ create_file ('liblib.c' , '''
2725
2724
int lib_cmp(const void* left, const void* right) {
2726
2725
const int* a = (const int*) left;
2727
2726
const int* b = (const int*) right;
@@ -2732,14 +2731,13 @@ def test_dlfcn_qsort(self):
2732
2731
2733
2732
typedef int (*CMP_TYPE)(const void*, const void*);
2734
2733
2735
- extern "C" CMP_TYPE get_cmp() {
2734
+ CMP_TYPE get_cmp() {
2736
2735
return lib_cmp;
2737
2736
}
2738
2737
''' )
2739
- self .build_dlfcn_lib ('liblib.cpp ' )
2738
+ self .build_dlfcn_lib ('liblib.c ' )
2740
2739
2741
2740
self .prep_dlfcn_main ()
2742
- self .set_setting ('EXPORTED_FUNCTIONS' , ['_main' , '_malloc' ])
2743
2741
src = '''
2744
2742
#include <stdio.h>
2745
2743
#include <stdlib.h>
@@ -2798,7 +2796,7 @@ def test_dlfcn_data_and_fptr(self):
2798
2796
if self .is_wasm ():
2799
2797
self .banned_js_engines = [config .V8_ENGINE ]
2800
2798
2801
- create_file ('liblib.cpp ' , r'''
2799
+ create_file ('liblib.c ' , r'''
2802
2800
#include <stdio.h>
2803
2801
2804
2802
int theglobal = 42;
@@ -2818,14 +2816,13 @@ def test_dlfcn_data_and_fptr(self):
2818
2816
p_f();
2819
2817
}
2820
2818
2821
- extern "C" void (*func(int x, void(*fptr)()))() {
2819
+ void (*func(int x, void(*fptr)()))() {
2822
2820
printf("In func: %d\n", x);
2823
2821
fptr();
2824
2822
return lib_fptr;
2825
2823
}
2826
2824
''' )
2827
- self .set_setting ('EXPORTED_FUNCTIONS' , ['_func' ])
2828
- self .build_dlfcn_lib ('liblib.cpp' )
2825
+ self .build_dlfcn_lib ('liblib.c' )
2829
2826
2830
2827
self .prep_dlfcn_main ()
2831
2828
src = r'''
@@ -2881,15 +2878,14 @@ def test_dlfcn_data_and_fptr(self):
2881
2878
return 0;
2882
2879
}
2883
2880
'''
2884
- self .set_setting ('EXPORTED_FUNCTIONS' , ['_main' ])
2885
2881
self .do_run (src , '''\
2886
2882
In func: 13
2887
2883
First calling main_fptr from lib.
2888
2884
Second calling lib_fptr from main.
2889
2885
parent_func called from child
2890
2886
parent_func called from child
2891
2887
Var: 42
2892
- ''' )
2888
+ ''' , force_c = True )
2893
2889
2894
2890
@needs_dylink
2895
2891
def test_dlfcn_varargs (self ):
@@ -2898,12 +2894,11 @@ def test_dlfcn_varargs(self):
2898
2894
2899
2895
create_file ('liblib.cpp' , r'''
2900
2896
void print_ints(int n, ...);
2901
- extern "C" void func() {
2897
+ void func() {
2902
2898
print_ints(2, 13, 42);
2903
2899
}
2904
2900
''' )
2905
- self .set_setting ('EXPORTED_FUNCTIONS' , ['_func' ])
2906
- self .build_dlfcn_lib ('liblib.cpp' )
2901
+ self .build_dlfcn_lib ('liblib.c' )
2907
2902
2908
2903
self .prep_dlfcn_main ()
2909
2904
src = r'''
@@ -2935,8 +2930,7 @@ def test_dlfcn_varargs(self):
2935
2930
return 0;
2936
2931
}
2937
2932
'''
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 )
2940
2934
2941
2935
@needs_dylink
2942
2936
def test_dlfcn_alignment_and_zeroing (self ):
@@ -3038,7 +3032,6 @@ def test_dlfcn_unique_sig(self):
3038
3032
return 13;
3039
3033
}
3040
3034
''' )
3041
- self .set_setting ('EXPORTED_FUNCTIONS' , ['_myfunc' ])
3042
3035
self .build_dlfcn_lib ('liblib.c' )
3043
3036
3044
3037
self .prep_dlfcn_main ()
@@ -3065,7 +3058,6 @@ def test_dlfcn_unique_sig(self):
3065
3058
return 0;
3066
3059
}
3067
3060
''' )
3068
- self .set_setting ('EXPORTED_FUNCTIONS' , ['_main' , '_malloc' ])
3069
3061
self .do_runf ('main.c' , 'success' )
3070
3062
3071
3063
@needs_dylink
@@ -3077,7 +3069,6 @@ def test_dlfcn_info(self):
3077
3069
return 13;
3078
3070
}
3079
3071
''' )
3080
- self .set_setting ('EXPORTED_FUNCTIONS' , ['_myfunc' ])
3081
3072
self .build_dlfcn_lib ('liblib.c' )
3082
3073
3083
3074
self .prep_dlfcn_main ()
@@ -3119,7 +3110,6 @@ def test_dlfcn_info(self):
3119
3110
return 0;
3120
3111
}
3121
3112
''' )
3122
- self .set_setting ('EXPORTED_FUNCTIONS' , ['_main' , '_malloc' ])
3123
3113
self .do_runf ('main.c' , 'success' )
3124
3114
3125
3115
@needs_dylink
@@ -3139,7 +3129,6 @@ def test_dlfcn_stacks(self):
3139
3129
return strlen(bigstack);
3140
3130
}
3141
3131
''' )
3142
- self .set_setting ('EXPORTED_FUNCTIONS' , ['_myfunc' ])
3143
3132
self .build_dlfcn_lib ('liblib.c' )
3144
3133
3145
3134
self .prep_dlfcn_main ()
@@ -3174,7 +3163,6 @@ def test_dlfcn_stacks(self):
3174
3163
return 0;
3175
3164
}
3176
3165
''' )
3177
- self .set_setting ('EXPORTED_FUNCTIONS' , ['_main' , '_malloc' , '_strcmp' ])
3178
3166
self .do_runf ('main.c' , 'success' )
3179
3167
3180
3168
@needs_dylink
@@ -3210,7 +3198,6 @@ def test_dlfcn_funcs(self):
3210
3198
}
3211
3199
}
3212
3200
''' )
3213
- self .set_setting ('EXPORTED_FUNCTIONS' , ['_callvoid' , '_callint' , '_getvoid' , '_getint' ])
3214
3201
self .build_dlfcn_lib ('liblib.c' )
3215
3202
3216
3203
self .prep_dlfcn_main ()
@@ -3261,7 +3248,6 @@ def test_dlfcn_funcs(self):
3261
3248
return 0;
3262
3249
}
3263
3250
''' )
3264
- self .set_setting ('EXPORTED_FUNCTIONS' , ['_main' , '_malloc' ])
3265
3251
self .do_runf ('main.c' , '''go
3266
3252
void_main.
3267
3253
int_main 201
@@ -3286,11 +3272,9 @@ def test_dlfcn_mallocs(self):
3286
3272
void *mallocproxy(int n) { return malloc(n); }
3287
3273
void freeproxy(void *p) { free(p); }
3288
3274
''' )
3289
- self .set_setting ('EXPORTED_FUNCTIONS' , ['_mallocproxy' , '_freeproxy' ])
3290
3275
self .build_dlfcn_lib ('liblib.c' )
3291
3276
3292
3277
self .prep_dlfcn_main ()
3293
- self .set_setting ('EXPORTED_FUNCTIONS' , ['_main' , '_malloc' , '_free' ])
3294
3278
self .do_runf (test_file ('dlmalloc_proxy.c' ), '*294,153*' )
3295
3279
3296
3280
@needs_dylink
@@ -3338,7 +3322,6 @@ def test_dlfcn_longjmp(self):
3338
3322
return 0;
3339
3323
}
3340
3324
''' )
3341
- self .set_setting ('EXPORTED_FUNCTIONS' , ['_main' , '_malloc' , '_free' ])
3342
3325
self .do_runf ('main.c' , '''go!
3343
3326
pre 1
3344
3327
pre 2
@@ -3410,7 +3393,6 @@ def zzztest_dlfcn_exceptions(self):
3410
3393
return 0;
3411
3394
}
3412
3395
'''
3413
- self .set_setting ('EXPORTED_FUNCTIONS' , ['_main' , '_malloc' , '_free' ])
3414
3396
self .do_run (src , '''go!
3415
3397
ok: 65
3416
3398
int 123
@@ -3428,8 +3410,9 @@ def indir(name):
3428
3410
create_file ('a.cpp' , r'''
3429
3411
#include <stdio.h>
3430
3412
3431
- static struct a {
3432
- a() {
3413
+ static class A {
3414
+ public:
3415
+ A() {
3433
3416
puts("a: loaded");
3434
3417
}
3435
3418
} _;
@@ -3438,8 +3421,9 @@ def indir(name):
3438
3421
create_file ('b.cpp' , r'''
3439
3422
#include <stdio.h>
3440
3423
3441
- static struct b {
3442
- b() {
3424
+ static class B {
3425
+ public:
3426
+ B() {
3443
3427
puts("b: loaded");
3444
3428
}
3445
3429
} _;
@@ -3488,12 +3472,12 @@ def indir(name):
3488
3472
def test_dlfcn_feature_in_lib (self ):
3489
3473
self .emcc_args .append ('-mnontrapping-fptoint' )
3490
3474
3491
- create_file ('liblib.cpp ' , r'''
3492
- extern "C" int magic(float x) {
3475
+ create_file ('liblib.c ' , r'''
3476
+ int magic(float x) {
3493
3477
return __builtin_wasm_trunc_saturate_s_i32_f32(x);
3494
3478
}
3495
3479
''' )
3496
- self .build_dlfcn_lib ('liblib.cpp ' )
3480
+ self .build_dlfcn_lib ('liblib.c ' )
3497
3481
3498
3482
self .prep_dlfcn_main ()
3499
3483
src = r'''
0 commit comments