home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
NeXTSTEP 3.2 (Developer)
/
NS_dev_3.2.iso
/
NextDeveloper
/
Headers
/
ansi
/
m68k
/
math.h
< prev
next >
Wrap
C/C++ Source or Header
|
1993-01-07
|
5KB
|
159 lines
/* Copyright (c) 1992 NeXT Computer, Inc. All rights reserved.
*
* File: <ansi/m68k/math.h>
*/
/* Inline routines. */
#ifndef _ANSI_M68K_MATH_H
#define _ANSI_M68K_MATH_H
#ifdef INLINE_MATH
#include <errno.h>
#define acos(x) _builtin_acos(x)
static inline double __const__ acos(double x) {
double v;
asm("facosx %1,%0": "=f" (v): "f" (x)); if (v!=v) errno=EDOM; return v;
}
#define asin(x) _builtin_asin(x)
static inline double __const__ asin(double x) {
double v;
asm("fasinx %1,%0": "=f" (v): "f" (x)); if (v!=v) errno=EDOM; return v;
}
#define atan(x) _builtin_atan(x)
static inline double __const__ atan(double x) {
double v; asm("fatanx %1,%0": "=f" (v): "f" (x)); return v;
}
#define cos(x) _builtin_cos(x)
static inline double __const__ cos(double x) {
double v; asm("fcosx %1,%0": "=f" (v): "f" (x)); return v;
}
#define sin(x) _builtin_sin(x)
static inline double __const__ sin(double x) {
double v; asm("fsinx %1,%0": "=f" (v): "f" (x)); return v;
}
#define tan(x) _builtin_tan(x)
static inline double __const__ tan(double x) {
double v; asm("ftanx %1,%0": "=f" (v): "f" (x)); return v;
}
#define cosh(x) _builtin_cosh(x)
static inline double __const__ cosh(double x) {
double v;
struct { unsigned pad:19; unsigned ovfl:1; unsigned pad2:12;} fpsr;
asm("fcoshx %1,%0": "=f" (v): "f" (x));
asm("fmovel fps,%0": "=g" (fpsr)); if (fpsr.ovfl) errno = ERANGE;
return v;
}
#define sinh(x) _builtin_sinh(x)
static inline double __const__ sinh(double x) {
double v;
struct { unsigned pad:19; unsigned ovfl:1; unsigned pad2:12;} fpsr;
asm("fsinhx %1,%0": "=f" (v): "f" (x));
asm("fmovel fps,%0": "=g" (fpsr)); if (fpsr.ovfl) errno = ERANGE;
return v;
}
#define tanh(x) _builtin_tanh(x)
static inline double __const__ tanh(double x) {
double v; asm("ftanhx %1,%0": "=f" (v): "f" (x)); return v;
}
#define exp(x) _builtin_exp(x)
static inline double __const__ exp(double x) {
double v;
struct { unsigned pad:19; unsigned ovfl:1; unsigned pad2:12;} fpsr;
asm("fetoxx %1,%0": "=f" (v): "f" (x));
asm("fmovel fps,%0": "=g" (fpsr)); if (fpsr.ovfl) errno = ERANGE;
return v;
}
#define log(x) _builtin_log(x)
static inline double __const__ log(double x) {
double v;
if (x<0.0) errno=EDOM; asm("flognx %1,%0": "=f" (v): "f" (x)); return v;
}
#define log10(x) _builtin_log10(x)
static inline double __const__ log10(double x) {
double v;
if (x<0.0) errno=EDOM; asm("flog10x %1,%0": "=f" (v): "f" (x)); return v;
}
#define sqrt(x) _builtin_sqrt(x)
static inline double __const__ sqrt(double x) {
double v;
if (x<0.0) errno=EDOM; asm("fsqrtx %1,%0": "=f" (v): "f" (x)); return v;
}
#define fabs(x) _builtin_fabs(x)
static inline double __const__ fabs(double x) {
double v; asm("fabsx %1,%0": "=f" (v): "f" (x)); return v;
}
#define atanh(x) _builtin_atanh(x)
static inline double __const__ atanh(double x) {
double v; asm("fatanhx %1,%0": "=f" (v): "f" (x)); return v;
}
#define expm1(x) _builtin_expm1(x)
static inline double __const__ expm1(double x) {
double v; asm("fetoxm1x %1,%0": "=f" (v): "f" (x)); return v;
}
#define log1p(x) _builtin_log1p(x)
static inline double __const__ log1p(double x) {
double v; asm("flognp1x %1,%0": "=f" (v): "f" (x)); return v;
}
#define rint(x) _builtin_rint(x)
static inline double rint(double x) {
double v; asm("fintx %1,%0": "=f" (v): "f" (x)); return v;
}
#define logb(x) _builtin_logb(x)
static inline double logb(double x) {
double v; asm("fgetexpx %1,%0": "=f" (v): "f" (x)); return v;
}
#endif /* INLINE_MATH */
/* Constants. */
#if defined(__STRICT_ANSI__) || defined(_NEXT_SOURCE)
#define HUGE_VAL (1e999)
#endif /* __STRICT_ANSI__ || _NEXT_SOURCE */
#ifndef __STRICT_ANSI__
#define HUGE HUGE_VAL
#define NAN (HUGE/HUGE)
#define MAXCHAR ((char)0x7f)
#define MAXSHORT ((short)0x7fff)
#define MAXINT ((int)0x7fffffff) /* max pos 32-bit int */
#define MAXLONG ((long)0x7fffffff)
#define MINCHAR ((char)0x80)
#define MINSHORT ((short)0x8000)
#define MININT ((int)0x80000000) /* max negative 32-bit integer */
#define MINLONG ((long)0x80000000)
#define MAXFLOAT ((float)3.4028234663852886e38)
#define MINFLOAT ((float)1.4012984643248171e-45)
#define MAXDOUBLE ((double)1.7976931348623157e308)
#define MINDOUBLE ((double)4.9406564584124654e-324)
#define LN_MAXFLOAT ((float)8.872283935546875e1)
#define LN_MINFLOAT ((float)-1.032789306640625e2)
#define LN_MAXDOUBLE ((double)7.0978271289338397e2)
#define LN_MINDOUBLE ((double)-7.4444007192138122e2)
#define M_E 2.7182818284590452354
#define M_LOG2E 1.4426950408889634074
#define M_LOG10E 0.43429448190325182765
#define M_LN2 0.69314718055994530942
#define M_LN10 2.30258509299404568402
#define M_PI 3.14159265358979323846
#define M_PI_2 1.57079632679489661923
#define M_PI_4 0.78539816339744830962
#define M_1_PI 0.31830988618379067154
#define M_2_PI 0.63661977236758134308
#define M_2_SQRTPI 1.12837916709551257390
#define M_SQRT2 1.41421356237309504880
#define M_SQRT1_2 0.70710678118654752440
#endif /* __STRICT_ANSI__ */
#endif /* _ANSI_M68K_MATH_H */