Update copyright notices with scripts/update-copyrights
[glibc.git] / sysdeps / powerpc / fpu / s_float_bitwise.h
blob7aae8def9124c3247cdc8bfdbe4db3d04c7623e2
1 /* Bitwise manipulation over float. Function prototypes.
2 Copyright (C) 2011-2014 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4 Contributed by Adhemerval Zanella <azanella@br.ibm.com>, 2011
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, see
18 <http://www.gnu.org/licenses/>. */
20 #ifndef _FLOAT_BITWISE_
21 #define _FLOAT_BITWISE_ 1
23 #include <math_private.h>
25 /* Returns (int)(num & 0x7FFFFFF0 == value) */
26 static inline int
27 __float_and_test28 (float num, float value)
29 float ret;
30 #ifdef _ARCH_PWR7
31 union {
32 int i;
33 float f;
34 } mask = { .i = 0x7ffffff0 };
35 __asm__ (
36 /* the 'f' constraint is used on mask because we just need
37 * to compare floats, not full vector */
38 "xxland %x0,%x1,%x2" : "=f" (ret) : "f" (num), "f" (mask.f)
40 #else
41 int32_t inum;
42 GET_FLOAT_WORD(inum, num);
43 inum = (inum & 0x7ffffff0);
44 SET_FLOAT_WORD(ret, inum);
45 #endif
46 return (ret == value);
49 /* Returns (int)(num & 0x7FFFFF00 == value) */
50 static inline int
51 __float_and_test24 (float num, float value)
53 float ret;
54 #ifdef _ARCH_PWR7
55 union {
56 int i;
57 float f;
58 } mask = { .i = 0x7fffff00 };
59 __asm__ (
60 "xxland %x0,%x1,%x2" : "=f" (ret) : "f" (num), "f" (mask.f)
62 #else
63 int32_t inum;
64 GET_FLOAT_WORD(inum, num);
65 inum = (inum & 0x7fffff00);
66 SET_FLOAT_WORD(ret, inum);
67 #endif
68 return (ret == value);
71 /* Returns (float)(num & 0x7F800000) */
72 static inline float
73 __float_and8 (float num)
75 float ret;
76 #ifdef _ARCH_PWR7
77 union {
78 int i;
79 float f;
80 } mask = { .i = 0x7f800000 };
81 __asm__ (
82 "xxland %x0,%x1,%x2" : "=f" (ret) : "f" (num), "f" (mask.f)
84 #else
85 int32_t inum;
86 GET_FLOAT_WORD(inum, num);
87 inum = (inum & 0x7f800000);
88 SET_FLOAT_WORD(ret, inum);
89 #endif
90 return ret;
93 /* Returns ((int32_t)(num & 0x7F800000) >> 23) */
94 static inline int32_t
95 __float_get_exp (float num)
97 int32_t inum;
98 #ifdef _ARCH_PWR7
99 float ret;
100 union {
101 int i;
102 float f;
103 } mask = { .i = 0x7f800000 };
104 __asm__ (
105 "xxland %x0,%x1,%x2" : "=f" (ret) : "f" (num), "f" (mask.f)
107 GET_FLOAT_WORD(inum, ret);
108 #else
109 GET_FLOAT_WORD(inum, num);
110 inum = inum & 0x7f800000;
111 #endif
112 return inum >> 23;
115 #endif /* s_float_bitwise.h */