~ubuntu-branches/ubuntu/saucy/emscripten/saucy-proposed

« back to all changes in this revision

Viewing changes to system/include/libcxx/support/win32/math_win32.h

  • Committer: Package Import Robot
  • Author(s): Sylvestre Ledru
  • Date: 2013-05-02 13:11:51 UTC
  • Revision ID: package-import@ubuntu.com-20130502131151-q8dvteqr1ef2x7xz
Tags: upstream-1.4.1~20130504~adb56cb
ImportĀ upstreamĀ versionĀ 1.4.1~20130504~adb56cb

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// -*- C++ -*-
 
2
//===---------------------- support/win32/math_win32.h --------------------===//
 
3
//
 
4
//                     The LLVM Compiler Infrastructure
 
5
//
 
6
// This file is dual licensed under the MIT and the University of Illinois Open
 
7
// Source Licenses. See LICENSE.TXT for details.
 
8
//
 
9
//===----------------------------------------------------------------------===//
 
10
 
 
11
#ifndef _LIBCPP_SUPPORT_WIN32_MATH_WIN32_H
 
12
#define _LIBCPP_SUPPORT_WIN32_MATH_WIN32_H
 
13
 
 
14
#if !defined(_MSC_VER)
 
15
#error "This header is MSVC specific, Clang and GCC should not include it"
 
16
#else
 
17
 
 
18
#include <math.h>
 
19
 
 
20
typedef float float_t;
 
21
typedef double double_t;
 
22
 
 
23
_LIBCPP_ALWAYS_INLINE bool isfinite( double num )
 
24
{
 
25
    return _finite(num) != 0;
 
26
}
 
27
_LIBCPP_ALWAYS_INLINE bool isinf( double num )
 
28
{
 
29
    return !isfinite(num) && !_isnan(num);
 
30
}
 
31
_LIBCPP_ALWAYS_INLINE bool isnan( double num )
 
32
{
 
33
    return _isnan(num) != 0;
 
34
}
 
35
_LIBCPP_ALWAYS_INLINE bool isnormal( double num )
 
36
{
 
37
    int class_ = _fpclass(num);
 
38
    return class_ == _FPCLASS_NN || class_ == _FPCLASS_PN;
 
39
}
 
40
 
 
41
_LIBCPP_ALWAYS_INLINE bool isgreater( double x, double y )
 
42
{
 
43
    if(_fpclass(x) == _FPCLASS_SNAN || _fpclass(y) == _FPCLASS_SNAN) return false;
 
44
    else return x > y;
 
45
}
 
46
 
 
47
_LIBCPP_ALWAYS_INLINE bool isgreaterequal( double x, double y )
 
48
{
 
49
    if(_fpclass(x) == _FPCLASS_SNAN || _fpclass(y) == _FPCLASS_SNAN) return false;
 
50
    else return x >= y;
 
51
}
 
52
 
 
53
_LIBCPP_ALWAYS_INLINE bool isless( double x, double y )
 
54
{
 
55
    if(_fpclass(x) == _FPCLASS_SNAN || _fpclass(y) == _FPCLASS_SNAN) return false;
 
56
    else return x < y;
 
57
}
 
58
 
 
59
_LIBCPP_ALWAYS_INLINE bool islessequal( double x, double y )
 
60
{
 
61
    if(::_fpclass(x) == _FPCLASS_SNAN || ::_fpclass(y) == _FPCLASS_SNAN) return false;
 
62
    else return x <= y;
 
63
}
 
64
 
 
65
_LIBCPP_ALWAYS_INLINE bool islessgreater( double x, double y )
 
66
{
 
67
    if(::_fpclass(x) == _FPCLASS_SNAN || ::_fpclass(y) == _FPCLASS_SNAN) return false;
 
68
    else return x < y || x > y;
 
69
}
 
70
 
 
71
_LIBCPP_ALWAYS_INLINE bool isunordered( double x, double y )
 
72
{
 
73
    return isnan(x) || isnan(y);
 
74
}
 
75
_LIBCPP_ALWAYS_INLINE bool signbit( double num )
 
76
{
 
77
    switch(_fpclass(num))
 
78
    {
 
79
        case _FPCLASS_SNAN:
 
80
        case _FPCLASS_QNAN:
 
81
        case _FPCLASS_NINF:
 
82
        case _FPCLASS_NN:
 
83
        case _FPCLASS_ND:
 
84
        case _FPCLASS_NZ:
 
85
            return true;
 
86
        case _FPCLASS_PZ:
 
87
        case _FPCLASS_PD:
 
88
        case _FPCLASS_PN:
 
89
        case _FPCLASS_PINF:
 
90
            return false;
 
91
    }
 
92
    return false;
 
93
}
 
94
_LIBCPP_ALWAYS_INLINE float copysignf( float x, float y )
 
95
{
 
96
    return (signbit (x) != signbit (y) ? - x : x);
 
97
}
 
98
_LIBCPP_ALWAYS_INLINE double copysign( double x, double y )
 
99
{
 
100
    return ::_copysign(x,y);
 
101
}
 
102
_LIBCPP_ALWAYS_INLINE double copysignl( long double x, long double y )
 
103
{
 
104
    return ::_copysignl(x,y);
 
105
}
 
106
_LIBCPP_ALWAYS_INLINE int fpclassify( double num )
 
107
{
 
108
    return _fpclass(num);
 
109
}
 
110
 
 
111
#endif // _MSC_VER
 
112
 
 
113
#endif // _LIBCPP_SUPPORT_WIN32_MATH_WIN32_H