File tree Expand file tree Collapse file tree 5 files changed +81
-3
lines changed
Expand file tree Collapse file tree 5 files changed +81
-3
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,8 @@ source `dirname ${BASH_SOURCE[0]}`/../config.sh
44
55echo " ::group::Build Aarch64 tests"
66 cd $ROOT_PATH /tests
7- cmake -S . -B build
7+ if [ $RUN_CONFIG = 1 ] || [ ! -f build/CMakeCache.txt ] ; then
8+ cmake -S . -B build
9+ fi
810 cmake --build build
911echo " ::endgroup::"
Original file line number Diff line number Diff line change 77
88#include <stdlib.h>
99#include <stdio.h>
10+ #include <complex.h>
1011
1112// Declare imported function.
1213// These functions were exported from the dll using __declspec( dllexport )
1314__declspec(dllimport ) int __cdecl add_c_export (int a , int b );
1415__declspec(dllimport ) int __stdcall add_std_export (int a , int b );
16+ __declspec(dllimport ) _Complex double __cdecl complex_add_c_export (_Complex double a , _Complex double b );
17+ __declspec(dllimport ) _Complex double __stdcall complex_add_std_export (_Complex double a , _Complex double b );
1518
1619// These functions were exported via a def file.
1720int __cdecl add_c_def (int a , int b );
@@ -40,6 +43,19 @@ int check_dll()
4043 return 5 ;
4144 if (test_func_pointer (add_c_def ) != 29 )
4245 return 6 ;
46+
47+ _Complex double a = 1.0 + 2.0 * I ;
48+ _Complex double b = 3.0 + 4.0 * I ;
49+ _Complex double c = complex_add_c_export (a , b );
50+ if (c != 4.000000 + 6.000000 * I ) {
51+ return 7 ;
52+ }
53+
54+ _Complex double d = complex_add_std_export (a , b );
55+ if (c != 4.000000 + 6.000000 * I ) {
56+ return 8 ;
57+ }
58+
4359 return 0 ;
4460}
4561
Original file line number Diff line number Diff line change @@ -21,4 +21,14 @@ __declspec(dllexport) int __cdecl add_c_export(int a, int b)
2121__declspec(dllexport ) int __stdcall add_std_export (int a , int b )
2222{
2323 return a + b ;
24- }
24+ }
25+
26+ __declspec(dllexport ) _Complex double __cdecl complex_add_c_export (_Complex double a , _Complex double b )
27+ {
28+ return a + b ;
29+ }
30+
31+ __declspec(dllexport ) _Complex double __stdcall complex_add_std_export (_Complex double a , _Complex double b )
32+ {
33+ return a + b ;
34+ }
Original file line number Diff line number Diff line change 11#include "gtest_like_c.h"
22
33#include <stdio.h>
4+ #include <complex.h>
45
56_Float128 foo (_Float128 x )
67{
@@ -23,6 +24,11 @@ _Float128 baz(_Float128 x)
2324 return x * __builtin_huge_valf128 ();
2425}
2526
27+ _Complex double complex_func (_Complex double a , _Complex double b )
28+ {
29+ return a + b ;
30+ }
31+
2632void math_test ()
2733{
2834 foo (1.2 Q );
@@ -37,7 +43,33 @@ void math_test()
3743 printf ("ok\n" );
3844}
3945
46+ void complex_func_test ()
47+ {
48+ _Complex double a = 1.0 + 2.0 * I ;
49+ _Complex double b = 3.0 + 4.0 * I ;
50+ _Complex double c = complex_func (a , b );
51+
52+ printf ("%f + %f * I\n" , creal (c ), cimag (c ));
53+ }
54+
55+ void cexp_test ()
56+ {
57+ _Complex double z = 1.0 + 2.0 * I ;
58+ _Complex double w = __builtin_cexp (z );
59+
60+ printf ("%f + %f * I\n" , creal (w ), cimag (w ));
61+ }
62+
63+
64+ void ccos_test ()
65+ {
66+ _Complex double z = 1.0 + 2.0 * I ;
67+ _Complex double w = __builtin_ccos (z );
68+
69+ printf ("%f + %f * I\n" , creal (w ), cimag (w ));
70+ }
71+
4072TEST (Aarch64MinGW , MathTest )
4173{
4274 math_test ();
43- }
75+ }
Original file line number Diff line number Diff line change 11#include < gtest/gtest.h>
22
33extern " C" void math_test ();
4+ extern " C" void complex_func_test ();
5+ extern " C" void cexp_test ();
6+ extern " C" void ccos_test ();
47
58TEST (Aarch64MinGW, MathTest)
69{
710 math_test ();
811}
12+
13+ TEST (Aarch64MinGW, ComplexFuncTest)
14+ {
15+ complex_func_test ();
16+ }
17+
18+ TEST (Aarch64MinGW, CexpTest)
19+ {
20+ cexp_test ();
21+ }
22+
23+ TEST (Aarch64MinGW, CcosTest)
24+ {
25+ ccos_test ();
26+ }
You can’t perform that action at this time.
0 commit comments