Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
torvalds
GitHub Repository: torvalds/linux
Path: blob/master/include/math-emu/single.h
26278 views
1
/* Software floating-point emulation.
2
Definitions for IEEE Single Precision.
3
Copyright (C) 1997,1998,1999 Free Software Foundation, Inc.
4
This file is part of the GNU C Library.
5
Contributed by Richard Henderson ([email protected]),
6
Jakub Jelinek ([email protected]),
7
David S. Miller ([email protected]) and
8
Peter Maydell ([email protected]).
9
10
The GNU C Library is free software; you can redistribute it and/or
11
modify it under the terms of the GNU Library General Public License as
12
published by the Free Software Foundation; either version 2 of the
13
License, or (at your option) any later version.
14
15
The GNU C Library is distributed in the hope that it will be useful,
16
but WITHOUT ANY WARRANTY; without even the implied warranty of
17
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18
Library General Public License for more details.
19
20
You should have received a copy of the GNU Library General Public
21
License along with the GNU C Library; see the file COPYING.LIB. If
22
not, write to the Free Software Foundation, Inc.,
23
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
24
25
#ifndef __MATH_EMU_SINGLE_H__
26
#define __MATH_EMU_SINGLE_H__
27
28
#if _FP_W_TYPE_SIZE < 32
29
#error "Here's a nickel kid. Go buy yourself a real computer."
30
#endif
31
32
#define _FP_FRACBITS_S 24
33
#define _FP_FRACXBITS_S (_FP_W_TYPE_SIZE - _FP_FRACBITS_S)
34
#define _FP_WFRACBITS_S (_FP_WORKBITS + _FP_FRACBITS_S)
35
#define _FP_WFRACXBITS_S (_FP_W_TYPE_SIZE - _FP_WFRACBITS_S)
36
#define _FP_EXPBITS_S 8
37
#define _FP_EXPBIAS_S 127
38
#define _FP_EXPMAX_S 255
39
#define _FP_QNANBIT_S ((_FP_W_TYPE)1 << (_FP_FRACBITS_S-2))
40
#define _FP_IMPLBIT_S ((_FP_W_TYPE)1 << (_FP_FRACBITS_S-1))
41
#define _FP_OVERFLOW_S ((_FP_W_TYPE)1 << (_FP_WFRACBITS_S))
42
43
/* The implementation of _FP_MUL_MEAT_S and _FP_DIV_MEAT_S should be
44
chosen by the target machine. */
45
46
union _FP_UNION_S
47
{
48
float flt;
49
struct {
50
#if __BYTE_ORDER == __BIG_ENDIAN
51
unsigned sign : 1;
52
unsigned exp : _FP_EXPBITS_S;
53
unsigned frac : _FP_FRACBITS_S - (_FP_IMPLBIT_S != 0);
54
#else
55
unsigned frac : _FP_FRACBITS_S - (_FP_IMPLBIT_S != 0);
56
unsigned exp : _FP_EXPBITS_S;
57
unsigned sign : 1;
58
#endif
59
} bits __attribute__((packed));
60
};
61
62
#define FP_DECL_S(X) _FP_DECL(1,X)
63
#define FP_UNPACK_RAW_S(X,val) _FP_UNPACK_RAW_1(S,X,val)
64
#define FP_UNPACK_RAW_SP(X,val) _FP_UNPACK_RAW_1_P(S,X,val)
65
#define FP_PACK_RAW_S(val,X) _FP_PACK_RAW_1(S,val,X)
66
#define FP_PACK_RAW_SP(val,X) \
67
do { \
68
if (!FP_INHIBIT_RESULTS) \
69
_FP_PACK_RAW_1_P(S,val,X); \
70
} while (0)
71
72
#define FP_UNPACK_S(X,val) \
73
do { \
74
_FP_UNPACK_RAW_1(S,X,val); \
75
_FP_UNPACK_CANONICAL(S,1,X); \
76
} while (0)
77
78
#define FP_UNPACK_SP(X,val) \
79
do { \
80
_FP_UNPACK_RAW_1_P(S,X,val); \
81
_FP_UNPACK_CANONICAL(S,1,X); \
82
} while (0)
83
84
#define FP_PACK_S(val,X) \
85
do { \
86
_FP_PACK_CANONICAL(S,1,X); \
87
_FP_PACK_RAW_1(S,val,X); \
88
} while (0)
89
90
#define FP_PACK_SP(val,X) \
91
do { \
92
_FP_PACK_CANONICAL(S,1,X); \
93
if (!FP_INHIBIT_RESULTS) \
94
_FP_PACK_RAW_1_P(S,val,X); \
95
} while (0)
96
97
#define FP_ISSIGNAN_S(X) _FP_ISSIGNAN(S,1,X)
98
#define FP_NEG_S(R,X) _FP_NEG(S,1,R,X)
99
#define FP_ADD_S(R,X,Y) _FP_ADD(S,1,R,X,Y)
100
#define FP_SUB_S(R,X,Y) _FP_SUB(S,1,R,X,Y)
101
#define FP_MUL_S(R,X,Y) _FP_MUL(S,1,R,X,Y)
102
#define FP_DIV_S(R,X,Y) _FP_DIV(S,1,R,X,Y)
103
#define FP_SQRT_S(R,X) _FP_SQRT(S,1,R,X)
104
#define _FP_SQRT_MEAT_S(R,S,T,X,Q) _FP_SQRT_MEAT_1(R,S,T,X,Q)
105
106
#define FP_CMP_S(r,X,Y,un) _FP_CMP(S,1,r,X,Y,un)
107
#define FP_CMP_EQ_S(r,X,Y) _FP_CMP_EQ(S,1,r,X,Y)
108
109
#define FP_TO_INT_S(r,X,rsz,rsg) _FP_TO_INT(S,1,r,X,rsz,rsg)
110
#define FP_TO_INT_ROUND_S(r,X,rsz,rsg) _FP_TO_INT_ROUND(S,1,r,X,rsz,rsg)
111
#define FP_FROM_INT_S(X,r,rs,rt) _FP_FROM_INT(S,1,X,r,rs,rt)
112
113
#define _FP_FRAC_HIGH_S(X) _FP_FRAC_HIGH_1(X)
114
#define _FP_FRAC_HIGH_RAW_S(X) _FP_FRAC_HIGH_1(X)
115
116
#endif /* __MATH_EMU_SINGLE_H__ */
117
118