blob: b0d15e15a5d3920d858a9c199b3863849692b81c [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001// SPDX-License-Identifier: GPL-2.0
Linus Torvalds1da177e2005-04-16 15:20:36 -07002#include <linux/types.h>
3#include <linux/errno.h>
Linus Torvalds7c0f6ba2016-12-24 11:46:01 -08004#include <linux/uaccess.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -07005
Kumar Galad2b194e2008-06-04 02:59:29 -05006#include <asm/sfp-machine.h>
7#include <math-emu/soft-fp.h>
8#include <math-emu/double.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -07009
10int
11fsel(u32 *frD, void *frA, u32 *frB, u32 *frC)
12{
13 FP_DECL_D(A);
Kumar Galad2b194e2008-06-04 02:59:29 -050014 FP_DECL_EX;
Linus Torvalds1da177e2005-04-16 15:20:36 -070015
16#ifdef DEBUG
Harvey Harrisone48b1b42008-03-29 08:21:07 +110017 printk("%s: %p %p %p %p\n", __func__, frD, frA, frB, frC);
Linus Torvalds1da177e2005-04-16 15:20:36 -070018#endif
19
Kumar Galad2b194e2008-06-04 02:59:29 -050020 FP_UNPACK_DP(A, frA);
Linus Torvalds1da177e2005-04-16 15:20:36 -070021
22#ifdef DEBUG
23 printk("A: %ld %lu %lu %ld (%ld)\n", A_s, A_f1, A_f0, A_e, A_c);
24 printk("B: %08x %08x\n", frB[0], frB[1]);
25 printk("C: %08x %08x\n", frC[0], frC[1]);
26#endif
27
28 if (A_c == FP_CLS_NAN || (A_c != FP_CLS_ZERO && A_s)) {
29 frD[0] = frB[0];
30 frD[1] = frB[1];
31 } else {
32 frD[0] = frC[0];
33 frD[1] = frC[1];
34 }
35
36#ifdef DEBUG
37 printk("D: %08x.%08x\n", frD[0], frD[1]);
38#endif
39
40 return 0;
41}