]>
Commit | Line | Data |
---|---|---|
f9536db7 | 1 | /* Common definitions for libm tests for vector functions. |
04277e02 | 2 | Copyright (C) 2014-2019 Free Software Foundation, Inc. |
f9536db7 JM |
3 | This file is part of the GNU C Library. |
4 | ||
5 | The GNU C Library is free software; you can redistribute it and/or | |
6 | modify it under the terms of the GNU Lesser General Public | |
7 | License as published by the Free Software Foundation; either | |
8 | version 2.1 of the License, or (at your option) any later version. | |
9 | ||
10 | The GNU C Library is distributed in the hope that it will be useful, | |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 | Lesser General Public License for more details. | |
14 | ||
15 | You should have received a copy of the GNU Lesser General Public | |
16 | License along with the GNU C Library; if not, see | |
17 | <http://www.gnu.org/licenses/>. */ | |
18 | ||
19 | #define TEST_MATHVEC 1 | |
8e554659 | 20 | #define TEST_NARROW 0 |
5a28590a | 21 | #define TEST_FINITE 0 |
e3a00020 | 22 | #define TEST_ERRNO 0 |
12d6284c | 23 | #define TEST_EXCEPTIONS 0 |
f9536db7 JM |
24 | |
25 | #define CNCT(x, y) x ## y | |
26 | #define CONCAT(a, b) CNCT (a, b) | |
27 | ||
28 | #define WRAPPER_NAME(function) CONCAT (function, VEC_SUFF) | |
92061bb0 | 29 | #define FUNC_TEST(function) WRAPPER_NAME (FUNC (function)) |
f9536db7 JM |
30 | |
31 | /* This macro is used in VECTOR_WRAPPER macros for vector tests. */ | |
32 | #define TEST_VEC_LOOP(vec, len) \ | |
33 | do \ | |
34 | { \ | |
35 | for (i = 1; i < len; i++) \ | |
36 | { \ | |
37 | if ((FLOAT) vec[0] != (FLOAT) vec[i]) \ | |
38 | { \ | |
39 | vec[0] = (FLOAT) vec[0] + 0.1; \ | |
40 | break; \ | |
41 | } \ | |
42 | } \ | |
43 | } \ | |
44 | while (0) | |
45 | ||
46 | #define INIT_VEC_LOOP(vec, val, len) \ | |
47 | do \ | |
48 | { \ | |
49 | for (i = 0; i < len; i++) \ | |
50 | { \ | |
51 | vec[i] = val; \ | |
52 | } \ | |
53 | } \ | |
54 | while (0) | |
55 | ||
92061bb0 | 56 | #define WRAPPER_DECL_f(function) extern FLOAT function (FLOAT); |
f9536db7 JM |
57 | #define WRAPPER_DECL_ff(function) extern FLOAT function (FLOAT, FLOAT); |
58 | #define WRAPPER_DECL_fFF(function) extern void function (FLOAT, FLOAT *, FLOAT *); | |
59 | ||
60 | /* Wrapper from scalar to vector function. */ | |
61 | #define VECTOR_WRAPPER(scalar_func, vector_func) \ | |
62 | extern VEC_TYPE vector_func (VEC_TYPE); \ | |
63 | FLOAT scalar_func (FLOAT x) \ | |
64 | { \ | |
65 | int i; \ | |
66 | VEC_TYPE mx; \ | |
67 | INIT_VEC_LOOP (mx, x, VEC_LEN); \ | |
68 | VEC_TYPE mr = vector_func (mx); \ | |
69 | TEST_VEC_LOOP (mr, VEC_LEN); \ | |
70 | return ((FLOAT) mr[0]); \ | |
71 | } | |
72 | ||
73 | /* Wrapper from scalar 2 argument function to vector one. */ | |
74 | #define VECTOR_WRAPPER_ff(scalar_func, vector_func) \ | |
75 | extern VEC_TYPE vector_func (VEC_TYPE, VEC_TYPE); \ | |
76 | FLOAT scalar_func (FLOAT x, FLOAT y) \ | |
77 | { \ | |
78 | int i; \ | |
79 | VEC_TYPE mx, my; \ | |
80 | INIT_VEC_LOOP (mx, x, VEC_LEN); \ | |
81 | INIT_VEC_LOOP (my, y, VEC_LEN); \ | |
82 | VEC_TYPE mr = vector_func (mx, my); \ | |
83 | TEST_VEC_LOOP (mr, VEC_LEN); \ | |
84 | return ((FLOAT) mr[0]); \ | |
85 | } | |
86 | ||
87 | /* Wrapper from scalar 3 argument function to vector one. */ | |
88 | #define VECTOR_WRAPPER_fFF(scalar_func, vector_func) \ | |
89 | extern void vector_func (VEC_TYPE, VEC_TYPE *, VEC_TYPE *); \ | |
90 | void scalar_func (FLOAT x, FLOAT * r, FLOAT * r1) \ | |
91 | { \ | |
92 | int i; \ | |
93 | VEC_TYPE mx, mr, mr1; \ | |
94 | INIT_VEC_LOOP (mx, x, VEC_LEN); \ | |
95 | vector_func (mx, &mr, &mr1); \ | |
96 | TEST_VEC_LOOP (mr, VEC_LEN); \ | |
97 | TEST_VEC_LOOP (mr1, VEC_LEN); \ | |
98 | *r = (FLOAT) mr[0]; \ | |
99 | *r1 = (FLOAT) mr1[0]; \ | |
100 | return; \ | |
101 | } |