3 /********************************************************************
5 * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. *
6 * USE, DISTRIBUTION AND REPRODUCTION OF THIS SOURCE IS GOVERNED BY *
7 * THE GNU LESSER/LIBRARY PUBLIC LICENSE, WHICH IS INCLUDED WITH *
8 * THIS SOURCE. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
10 * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2000 *
11 * by Monty <monty@xiph.org> and the XIPHOPHORUS Company *
12 * http://www.xiph.org/ *
14 ********************************************************************
16 function: #ifdef jail to whip a few platforms into the UNIX ideal.
17 last mod: $Id: os.h,v 1.17 2000/12/13 18:12:34 giles Exp $
19 ********************************************************************/
22 #include <ogg/os_types.h>
24 #ifndef _V_IFDEFJAIL_H_
25 #define _V_IFDEFJAIL_H_
28 #define M_PI (3.14159265358979323846)
34 # define rint(x) (floor((x)+0.5))
39 # define FAST_HYPOT(a, b) sqrt((a)*(a) + (b)*(b))
40 #else /* if not _WIN32 */
41 # define FAST_HYPOT hypot
55 # define min(x,y) ((x)>(y)?(y):(x))
59 # define max(x,y) ((x)<(y)?(y):(x))
63 #if defined(__i386__) && defined(__GNUC__)
67 /* both GCC and MSVC are kinda stupid about rounding/casting to int.
68 Because of encapsulation constraints (GCC can't see inside the asm
69 block and so we end up doing stupid things like a store/load that
70 is collectively a noop), we do it this way */
72 /* we must set up the fpu before this works!! */
74 typedef ogg_int16_t vorbis_fpu_control;
76 static inline void vorbis_fpu_setround(vorbis_fpu_control *fpu){
79 __asm__ __volatile__("fnstcw %0\n\t"
83 "fldcw %1\n\t":"=m"(ret):"m"(temp): "dx");
87 static inline void vorbis_fpu_restore(vorbis_fpu_control fpu){
88 __asm__ __volatile__("fldcw %0":: "m"(fpu));
91 /* assumes the FPU is in round mode! */
92 static inline int vorbis_ftoi(double f){ /* yes, double! Otherwise,
93 we get extra fst/fld to
96 __asm__("fistl %0": "=m"(i) : "t"(f));
101 /* this is for beos */
103 typedef int vorbis_fpu_control;
104 static int vorbis_ftoi(double f){
108 /* We don't have special code for this compiler/arch, so do it the slow way */
109 #define vorbis_fpu_setround(vorbis_fpu_control) {}
110 #define vorbis_fpu_restore(vorbis_fpu_control) {}
117 typedef int vorbis_fpu_control;
121 static __inline int vorbis_ftoi(double f){
130 static __inline void vorbis_fpu_setround(vorbis_fpu_control *fpu){
133 static __inline void vorbis_fpu_restore(vorbis_fpu_control fpu){
137 static int vorbis_ftoi(double f){
141 /* We don't have special code for this compiler/arch, so do it the slow way */
142 #define vorbis_fpu_setround(vorbis_fpu_control) {}
143 #define vorbis_fpu_restore(vorbis_fpu_control) {}