~ubuntu-branches/ubuntu/saucy/faust/saucy

« back to all changes in this revision

Viewing changes to architecture/misc.h

  • Committer: Package Import Robot
  • Author(s): Mario Lang
  • Date: 2012-04-04 13:52:01 UTC
  • mfrom: (1.1.6) (3.1.7 sid)
  • Revision ID: package-import@ubuntu.com-20120404135201-hpsrk87x3hga94tc
Tags: 0.9.46-2
* Fix "ftbfs with GCC-4.7":
  - debian/patches/unistd: Include <unistd.h> where necessary.
    (Closes: #667163)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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