xref: /linux/tools/testing/selftests/powerpc/math/fpu.h (revision c532de5a67a70f8533d495f8f2aaa9a0491c3ad0)
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 /*
3  * Copyright 2023, Michael Ellerman, IBM Corporation.
4  */
5 
6 #ifndef _SELFTESTS_POWERPC_FPU_H
7 #define _SELFTESTS_POWERPC_FPU_H
8 
9 static inline void randomise_darray(double *darray, int num)
10 {
11 	long val;
12 
13 	for (int i = 0; i < num; i++) {
14 		val = random();
15 		if (val & 1)
16 			val *= -1;
17 
18 		if (val & 2)
19 			darray[i] = 1.0 / val;
20 		else
21 			darray[i] = val * val;
22 	}
23 }
24 
25 #endif /* _SELFTESTS_POWERPC_FPU_H */
26