powerpc: Add tests for __ppc_set_ppr_* functions.
[glibc.git] / math / test-math-vector.h
blob8a9ae9caa1bcb131d7ccd83079eef23f2a654d52
1 /* Common definitions for libm tests for vector functions.
2 Copyright (C) 2014-2017 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
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.
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.
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/>. */
19 #define TEST_MATHVEC 1
20 #define TEST_FINITE 0
21 #define TEST_ERRNO 0
22 #define TEST_EXCEPTIONS 0
24 #define CNCT(x, y) x ## y
25 #define CONCAT(a, b) CNCT (a, b)
27 #define WRAPPER_NAME(function) CONCAT (function, VEC_SUFF)
29 /* This macro is used in VECTOR_WRAPPER macros for vector tests. */
30 #define TEST_VEC_LOOP(vec, len) \
31 do \
32 { \
33 for (i = 1; i < len; i++) \
34 { \
35 if ((FLOAT) vec[0] != (FLOAT) vec[i]) \
36 { \
37 vec[0] = (FLOAT) vec[0] + 0.1; \
38 break; \
39 } \
40 } \
41 } \
42 while (0)
44 #define INIT_VEC_LOOP(vec, val, len) \
45 do \
46 { \
47 for (i = 0; i < len; i++) \
48 { \
49 vec[i] = val; \
50 } \
51 } \
52 while (0)
54 #define WRAPPER_DECL(function) extern FLOAT function (FLOAT);
55 #define WRAPPER_DECL_ff(function) extern FLOAT function (FLOAT, FLOAT);
56 #define WRAPPER_DECL_fFF(function) extern void function (FLOAT, FLOAT *, FLOAT *);
58 /* Wrapper from scalar to vector function. */
59 #define VECTOR_WRAPPER(scalar_func, vector_func) \
60 extern VEC_TYPE vector_func (VEC_TYPE); \
61 FLOAT scalar_func (FLOAT x) \
62 { \
63 int i; \
64 VEC_TYPE mx; \
65 INIT_VEC_LOOP (mx, x, VEC_LEN); \
66 VEC_TYPE mr = vector_func (mx); \
67 TEST_VEC_LOOP (mr, VEC_LEN); \
68 return ((FLOAT) mr[0]); \
71 /* Wrapper from scalar 2 argument function to vector one. */
72 #define VECTOR_WRAPPER_ff(scalar_func, vector_func) \
73 extern VEC_TYPE vector_func (VEC_TYPE, VEC_TYPE); \
74 FLOAT scalar_func (FLOAT x, FLOAT y) \
75 { \
76 int i; \
77 VEC_TYPE mx, my; \
78 INIT_VEC_LOOP (mx, x, VEC_LEN); \
79 INIT_VEC_LOOP (my, y, VEC_LEN); \
80 VEC_TYPE mr = vector_func (mx, my); \
81 TEST_VEC_LOOP (mr, VEC_LEN); \
82 return ((FLOAT) mr[0]); \
85 /* Wrapper from scalar 3 argument function to vector one. */
86 #define VECTOR_WRAPPER_fFF(scalar_func, vector_func) \
87 extern void vector_func (VEC_TYPE, VEC_TYPE *, VEC_TYPE *); \
88 void scalar_func (FLOAT x, FLOAT * r, FLOAT * r1) \
89 { \
90 int i; \
91 VEC_TYPE mx, mr, mr1; \
92 INIT_VEC_LOOP (mx, x, VEC_LEN); \
93 vector_func (mx, &mr, &mr1); \
94 TEST_VEC_LOOP (mr, VEC_LEN); \
95 TEST_VEC_LOOP (mr1, VEC_LEN); \
96 *r = (FLOAT) mr[0]; \
97 *r1 = (FLOAT) mr1[0]; \
98 return; \