900643afc792218b2ffc46206a821b8b733f0b20
[Faustine.git] / interpretor / preprocessor / faust-0.9.47mr3 / architecture / misc.h
1
2 #ifndef __misc__
3 #define __misc__
4
5 #include <map>
6 #include <string.h>
7 #include <stdlib.h>
8
9 // On Intel set FZ (Flush to Zero) and DAZ (Denormals Are Zero)
10 // flags to avoid costly denormals
11 #ifdef __SSE__
12 #include <xmmintrin.h>
13 #ifdef __SSE2__
14 #define AVOIDDENORMALS _mm_setcsr(_mm_getcsr() | 0x8040)
15 #else
16 #define AVOIDDENORMALS _mm_setcsr(_mm_getcsr() | 0x8000)
17 #endif
18 #else
19 #define AVOIDDENORMALS
20 #endif
21
22 struct XXXX_Meta : std::map<const char*, const char*>
23 {
24 void declare (const char* key, const char* value) { (*this)[key]=value; }
25 };
26
27 struct Meta
28 {
29 virtual void declare (const char* key, const char* value) = 0;
30 };
31
32 struct MY_Meta : Meta, std::map<const char*, const char*>
33 {
34 void declare (const char* key, const char* value) { (*this)[key]=value; }
35 };
36
37 #define max(x,y) (((x)>(y)) ? (x) : (y))
38 #define min(x,y) (((x)<(y)) ? (x) : (y))
39
40 inline int lsr (int x, int n) { return int(((unsigned int)x) >> n); }
41 inline int int2pow2 (int x) { int r=0; while ((1<<r)<x) r++; return r; }
42
43 long lopt(char *argv[], const char *name, long def)
44 {
45 int i;
46 for (i = 0; argv[i]; i++) if (!strcmp(argv[i], name)) return atoi(argv[i+1]);
47 return def;
48 }
49
50 char* lopts(char *argv[], const char *name, char* def)
51 {
52 int i;
53 for (i = 0; argv[i]; i++) if (!strcmp(argv[i], name)) return argv[i+1];
54 return def;
55 }
56 #endif
57