1 /************************************************************************
2 ************************************************************************
4 Copyright (C) 2003-2004 GRAME, Centre National de Creation Musicale
5 ---------------------------------------------------------------------
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 ************************************************************************
20 ************************************************************************/
23 #if defined( __MINGW32__) || defined (WIN32)
24 // Simulate some Unix fonctions on Windows
29 #if defined(_MBCS) || __MINGW32__
30 bool chdir(const char* path
)
32 return !SetCurrentDirectory(path
);
35 int mkdir(const char* path
, unsigned int attribute
)
37 return CreateDirectory(path
,NULL
);
40 char* getcwd(char* str
, unsigned int size
)
42 GetCurrentDirectory(size
, str
);
45 void getFaustPathname(char* str
, unsigned int size
)
47 GetModuleFileName(NULL
, str
, size
);
50 bool chdir(const char* path
)
53 mbstowcs(wstr
,path
,2048);
54 return !SetCurrentDirectory(wstr
);
57 int mkdir(const char* path
, unsigned int attribute
)
60 mbstowcs(wstr
,path
,2048);
61 return CreateDirectory(wstr
,NULL
);
64 char* getcwd(char* str
, unsigned int size
)
67 GetCurrentDirectory(2048, wstr
);
68 wcstombs(str
,wstr
,size
);
72 void getFaustPathname(char* str
, unsigned int size
)
75 GetModuleFileName(NULL
, wstr
, 2048);
76 wcstombs(str
,wstr
,size
);
86 #if !defined(__MINGW32__)
96 } ieee_double_shape_type
;
99 #define EXTRACT_WORDS(ix0,ix1,d) \
101 ieee_double_shape_type ew_u; \
103 (ix0) = ew_u.parts.msw; \
104 (ix1) = ew_u.parts.lsw; \
107 /* Get the more significant 32 bit int from a double. */
109 #define GET_HIGH_WORD(i,d) \
111 ieee_double_shape_type gh_u; \
113 (i) = gh_u.parts.msw; \
116 /* Get the less significant 32 bit int from a double. */
118 #define GET_LOW_WORD(i,d) \
120 ieee_double_shape_type gl_u; \
122 (i) = gl_u.parts.lsw; \
125 #define SET_HIGH_WORD(d,v) \
127 ieee_double_shape_type sh_u; \
129 sh_u.parts.msw = (v); \
133 double remainder(double x
, double p
)
136 unsigned int sx
,lx
,lp
;
139 EXTRACT_WORDS(hx
,lx
,x
);
140 EXTRACT_WORDS(hp
,lp
,p
);
145 /* purge off exception values */
146 if((hp
|lp
)==0) return (x
*p
)/(x
*p
); /* p = 0 */
147 if((hx
>=0x7ff00000)|| /* x not finite */
148 ((hp
>=0x7ff00000)&& /* p is NaN */
149 (((hp
-0x7ff00000)|lp
)!=0)))
153 static const double zero
= 0.0;
154 if (hp
<=0x7fdfffff) x
= fmod(x
,p
+p
); /* now x < 2p */
155 if (((hx
-hp
)|(lx
-lp
))==0) return zero
*x
;
167 if(x
>=p_half
) x
-= p
;
171 SET_HIGH_WORD(x
,hx
^sx
);
180 void getFaustPathname(char* str
, unsigned int size
)
182 char* path
= getenv("_");
184 strncpy(str
, path
, size
);
186 // prevent the case of _ undefined
187 strncpy(str
, "/usr/local/bin/faust", size
);