summaryrefslogtreecommitdiff
path: root/sysdeps/m68k/m680x0/fpu/mathimpl.h
blob: 70d79fd2786b0ba511e3bcb30d744efb50ec20a5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
/* Definitions of libc internal inline math functions implemented
   by the m68881/2.
   Copyright (C) 1991-2015 Free Software Foundation, Inc.
   This file is part of the GNU C Library.

   The GNU C Library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public
   License as published by the Free Software Foundation; either
   version 2.1 of the License, or (at your option) any later version.

   The GNU C Library is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   Lesser General Public License for more details.

   You should have received a copy of the GNU Lesser General Public
   License along with the GNU C Library.  If not, see
   <http://www.gnu.org/licenses/>.  */

/* This file contains the definitions of the inline math functions that
   are only used internally inside libm, not visible to the user.  */

__inline_mathop	(__ieee754_acos, acos)
__inline_mathop	(__ieee754_asin, asin)
__inline_mathop	(__ieee754_cosh, cosh)
__inline_mathop	(__ieee754_sinh, sinh)
__inline_mathop	(__ieee754_exp, etox)
__inline_mathop	(__ieee754_exp2, twotox)
__inline_mathop	(__ieee754_exp10, tentox)
__inline_mathop	(__ieee754_log10, log10)
__inline_mathop	(__ieee754_log2, log2)
__inline_mathop	(__ieee754_log, logn)
__inline_mathop	(__ieee754_sqrt, sqrt)
__inline_mathop	(__ieee754_atanh, atanh)

__m81_defun (double, __ieee754_remainder, (double __x, double __y))
{
  double __result;
  __asm ("frem%.x %1, %0" : "=f" (__result) : "f" (__y), "0" (__x));
  return __result;
}

__m81_defun (float, __ieee754_remainderf, (float __x, float __y))
{
  float __result;
  __asm ("frem%.x %1, %0" : "=f" (__result) : "f" (__y), "0" (__x));
  return __result;
}

__m81_defun (long double,
	     __ieee754_remainderl, (long double __x, long double __y))
{
  long double __result;
  __asm ("frem%.x %1, %0" : "=f" (__result) : "f" (__y), "0" (__x));
  return __result;
}

__m81_defun (double, __ieee754_fmod, (double __x, double __y))
{
  double __result;
  __asm ("fmod%.x %1, %0" : "=f" (__result) : "f" (__y), "0" (__x));
  return __result;
}

__m81_defun (float, __ieee754_fmodf, (float __x, float __y))
{
  float __result;
  __asm ("fmod%.x %1, %0" : "=f" (__result) : "f" (__y), "0" (__x));
  return __result;
}

__m81_defun (long double,
	     __ieee754_fmodl, (long double __x, long double __y))
{
  long double __result;
  __asm ("fmod%.x %1, %0" : "=f" (__result) : "f" (__y), "0" (__x));
  return __result;
}

/* Get the m68881 condition codes, to quickly check multiple conditions.  */
static __inline__ unsigned long
__m81_test (long double __val)
{
  unsigned long __fpsr;
  __asm ("ftst%.x %1; fmove%.l %/fpsr,%0" : "=dm" (__fpsr) : "f" (__val));
  return __fpsr;
}

/* Bit values returned by __m81_test.  */
#define __M81_COND_NAN  (1 << 24)
#define __M81_COND_INF  (2 << 24)
#define __M81_COND_ZERO (4 << 24)
#define __M81_COND_NEG  (8 << 24)