]> git.ipfire.org Git - thirdparty/glibc.git/blame - sysdeps/powerpc/fpu/s_float_bitwise.h
nss/tst-nss-files-alias-leak: add missing opening quote in printf
[thirdparty/glibc.git] / sysdeps / powerpc / fpu / s_float_bitwise.h
CommitLineData
77a2a8b4 1/* Bitwise manipulation over float. Function prototypes.
04277e02 2 Copyright (C) 2011-2019 Free Software Foundation, Inc.
77a2a8b4
AZ
3 This file is part of the GNU C Library.
4 Contributed by Adhemerval Zanella <azanella@br.ibm.com>, 2011
5
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.
10
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.
15
16 You should have received a copy of the GNU Lesser General Public
59ba27a6
PE
17 License along with the GNU C Library; if not, see
18 <http://www.gnu.org/licenses/>. */
77a2a8b4
AZ
19
20#ifndef _FLOAT_BITWISE_
21#define _FLOAT_BITWISE_ 1
22
1ed0291c 23#include <math_private.h>
77a2a8b4
AZ
24
25/* Returns (int)(num & 0x7FFFFFF0 == value) */
603e8410
AM
26static inline int
27__float_and_test28 (float num, float value)
77a2a8b4
AZ
28{
29 float ret;
30#ifdef _ARCH_PWR7
603e8410
AM
31 union {
32 int i;
33 float f;
34 } mask = { .i = 0x7ffffff0 };
77a2a8b4 35 __asm__ (
603e8410 36 /* the 'f' constraint is used on mask because we just need
77a2a8b4 37 * to compare floats, not full vector */
603e8410 38 "xxland %x0,%x1,%x2" : "=f" (ret) : "f" (num), "f" (mask.f)
77a2a8b4
AZ
39 );
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);
47}
48
49/* Returns (int)(num & 0x7FFFFF00 == value) */
603e8410
AM
50static inline int
51__float_and_test24 (float num, float value)
77a2a8b4
AZ
52{
53 float ret;
54#ifdef _ARCH_PWR7
603e8410
AM
55 union {
56 int i;
57 float f;
58 } mask = { .i = 0x7fffff00 };
77a2a8b4 59 __asm__ (
603e8410 60 "xxland %x0,%x1,%x2" : "=f" (ret) : "f" (num), "f" (mask.f)
77a2a8b4
AZ
61 );
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);
69}
70
71/* Returns (float)(num & 0x7F800000) */
603e8410
AM
72static inline float
73__float_and8 (float num)
77a2a8b4
AZ
74{
75 float ret;
76#ifdef _ARCH_PWR7
603e8410
AM
77 union {
78 int i;
79 float f;
80 } mask = { .i = 0x7f800000 };
77a2a8b4 81 __asm__ (
603e8410 82 "xxland %x0,%x1,%x2" : "=f" (ret) : "f" (num), "f" (mask.f)
77a2a8b4
AZ
83 );
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;
91}
92
93/* Returns ((int32_t)(num & 0x7F800000) >> 23) */
603e8410
AM
94static inline int32_t
95__float_get_exp (float num)
77a2a8b4
AZ
96{
97 int32_t inum;
98#ifdef _ARCH_PWR7
99 float ret;
603e8410
AM
100 union {
101 int i;
102 float f;
103 } mask = { .i = 0x7f800000 };
77a2a8b4 104 __asm__ (
603e8410 105 "xxland %x0,%x1,%x2" : "=f" (ret) : "f" (num), "f" (mask.f)
77a2a8b4
AZ
106 );
107 GET_FLOAT_WORD(inum, ret);
108#else
109 GET_FLOAT_WORD(inum, num);
110 inum = inum & 0x7f800000;
111#endif
112 return inum >> 23;
113}
114
115#endif /* s_float_bitwise.h */