Fix a typo in comments in memmove-vec-unaligned-erms.S
[glibc.git] / math / test-math-vector.h
blobc2691088cba0d7b5d87633e764da9775670e0c2d
1 /* Common definitions for libm tests for vector functions.
2 Copyright (C) 2014-2016 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
23 #define CNCT(x, y) x ## y
24 #define CONCAT(a, b) CNCT (a, b)
26 #define WRAPPER_NAME(function) CONCAT (function, VEC_SUFF)
28 /* This macro is used in VECTOR_WRAPPER macros for vector tests. */
29 #define TEST_VEC_LOOP(vec, len) \
30 do \
31 { \
32 for (i = 1; i < len; i++) \
33 { \
34 if ((FLOAT) vec[0] != (FLOAT) vec[i]) \
35 { \
36 vec[0] = (FLOAT) vec[0] + 0.1; \
37 break; \
38 } \
39 } \
40 } \
41 while (0)
43 #define INIT_VEC_LOOP(vec, val, len) \
44 do \
45 { \
46 for (i = 0; i < len; i++) \
47 { \
48 vec[i] = val; \
49 } \
50 } \
51 while (0)
53 #define WRAPPER_DECL(function) extern FLOAT function (FLOAT);
54 #define WRAPPER_DECL_ff(function) extern FLOAT function (FLOAT, FLOAT);
55 #define WRAPPER_DECL_fFF(function) extern void function (FLOAT, FLOAT *, FLOAT *);
57 /* Wrapper from scalar to vector function. */
58 #define VECTOR_WRAPPER(scalar_func, vector_func) \
59 extern VEC_TYPE vector_func (VEC_TYPE); \
60 FLOAT scalar_func (FLOAT x) \
61 { \
62 int i; \
63 VEC_TYPE mx; \
64 INIT_VEC_LOOP (mx, x, VEC_LEN); \
65 VEC_TYPE mr = vector_func (mx); \
66 TEST_VEC_LOOP (mr, VEC_LEN); \
67 return ((FLOAT) mr[0]); \
70 /* Wrapper from scalar 2 argument function to vector one. */
71 #define VECTOR_WRAPPER_ff(scalar_func, vector_func) \
72 extern VEC_TYPE vector_func (VEC_TYPE, VEC_TYPE); \
73 FLOAT scalar_func (FLOAT x, FLOAT y) \
74 { \
75 int i; \
76 VEC_TYPE mx, my; \
77 INIT_VEC_LOOP (mx, x, VEC_LEN); \
78 INIT_VEC_LOOP (my, y, VEC_LEN); \
79 VEC_TYPE mr = vector_func (mx, my); \
80 TEST_VEC_LOOP (mr, VEC_LEN); \
81 return ((FLOAT) mr[0]); \
84 /* Wrapper from scalar 3 argument function to vector one. */
85 #define VECTOR_WRAPPER_fFF(scalar_func, vector_func) \
86 extern void vector_func (VEC_TYPE, VEC_TYPE *, VEC_TYPE *); \
87 void scalar_func (FLOAT x, FLOAT * r, FLOAT * r1) \
88 { \
89 int i; \
90 VEC_TYPE mx, mr, mr1; \
91 INIT_VEC_LOOP (mx, x, VEC_LEN); \
92 vector_func (mx, &mr, &mr1); \
93 TEST_VEC_LOOP (mr, VEC_LEN); \
94 TEST_VEC_LOOP (mr1, VEC_LEN); \
95 *r = (FLOAT) mr[0]; \
96 *r1 = (FLOAT) mr1[0]; \
97 return; \