25 #if defined(__MINGW32__) || defined (WIN32)
30 double rint(
double nr)
34 return (((c -nr) >= (nr - f)) ? f : c);
38 #if defined(_MSC_VER) || defined(_MSC_EXTENSIONS)
39 #define DELTA_EPOCH_IN_MICROSECS 11644473600000000Ui64
41 #define DELTA_EPOCH_IN_MICROSECS 11644473600000000ULL
44 int gettimeofday(
struct timeval *tv,
struct timezone *tz)
47 unsigned __int64 tmpres = 0;
52 GetSystemTimeAsFileTime(&ft);
54 tmpres |= ft.dwHighDateTime;
56 tmpres |= ft.dwLowDateTime;
59 tmpres -= DELTA_EPOCH_IN_MICROSECS;
61 tv->tv_sec = (long)(tmpres / 1000000UL);
62 tv->tv_usec = (long)(tmpres % 1000000UL);
72 tz->tz_minuteswest = _timezone / 60;
73 tz->tz_dsttime = _daylight;
78 #if defined(_MBCS) || __MINGW32__
79 bool chdir(
const char* path)
81 return !SetCurrentDirectory(path);
84 int mkdir(
const char* path,
unsigned int attribute)
86 return CreateDirectory(path,NULL);
89 char* getcwd(
char* str,
unsigned int size)
91 GetCurrentDirectory(size, str);
96 GetModuleFileName(NULL, str, size);
99 bool chdir(
const char* path)
102 mbstowcs(wstr,path,2048);
103 return !SetCurrentDirectory(wstr);
106 int mkdir(
const char* path,
unsigned int attribute)
109 mbstowcs(wstr,path,2048);
110 return CreateDirectory(wstr,NULL);
113 char* getcwd(
char* str,
unsigned int size)
116 GetCurrentDirectory(2048, wstr);
117 wcstombs(str,wstr,size);
124 GetModuleFileName(NULL, wstr, 2048);
125 wcstombs(str,wstr,size);
130 #if !defined(__MINGW32__)
140 } ieee_double_shape_type;
143 #define EXTRACT_WORDS(ix0,ix1,d) \
145 ieee_double_shape_type ew_u; \
147 (ix0) = ew_u.parts.msw; \
148 (ix1) = ew_u.parts.lsw; \
153 #define GET_HIGH_WORD(i,d) \
155 ieee_double_shape_type gh_u; \
157 (i) = gh_u.parts.msw; \
162 #define GET_LOW_WORD(i,d) \
164 ieee_double_shape_type gl_u; \
166 (i) = gl_u.parts.lsw; \
169 #define SET_HIGH_WORD(d,v) \
171 ieee_double_shape_type sh_u; \
173 sh_u.parts.msw = (v); \
177 double remainder(
double x,
double p)
180 unsigned int sx,lx,lp;
183 EXTRACT_WORDS(hx,lx,x);
184 EXTRACT_WORDS(hp,lp,p);
190 if((hp|lp)==0)
return (x*p)/(x*p);
191 if((hx>=0x7ff00000)||
193 (((hp-0x7ff00000)|lp)!=0)))
197 static const double zero = 0.0;
198 if (hp<=0x7fdfffff) x = fmod(x,p+p);
199 if (((hx-hp)|(lx-lp))==0)
return zero*x;
211 if(x>=p_half) x -= p;
215 SET_HIGH_WORD(x,hx^sx);
226 char* path = getenv(
"_");
228 strncpy(str, path, size);
231 strncpy(str,
"/usr/local/bin/faust", size);
void getFaustPathname(char *str, unsigned int size)