libg722_1 0.1.0
tgmath.h
1/*
2 * SpanDSP - a series of DSP components for telephony
3 *
4 * tgmath.h - a fudge for MSVC, which lacks this header
5 *
6 * Written by Steve Underwood <steveu@coppice.org>
7 *
8 * Copyright (C) 2006 Michael Jerris
9 *
10 *
11 * This file is released in the public domain.
12 *
13 */
14
15#if !defined(_TGMATH_H_)
16#define _TGMATH_H_
17
18#include <math.h>
19
20#if !defined(M_PI)
21/* C99 systems may not define M_PI */
22#define M_PI 3.14159265358979323846264338327
23#endif
24
25
26#ifdef __cplusplus
27extern "C" {
28#endif
29
30/* A kindofa rint() for VC++ (only kindofa, because rint should be type generic,
31 and this one is purely float to int */
32static inline long int lrintf(float a)
33{
34 long int i;
35
36 __asm
37 {
38 fld a
39 fistp i
40 }
41 return i;
42}
43
44static inline long int lrint(double a)
45{
46 long int i;
47
48 __asm
49 {
50 fld a
51 fistp i
52 }
53 return i;
54}
55
56static inline int rintf(float a)
57{
58 int i;
59
60 __asm
61 {
62 fld a
63 fistp i
64 }
65 return i;
66}
67
68static inline int rint(double a)
69{
70 int i;
71
72 __asm
73 {
74 fld a
75 fistp i
76 }
77 return i;
78}
79
80#ifdef __cplusplus
81}
82#endif
83
84#endif