equal
deleted
inserted
replaced
28 #define COMMON_H |
28 #define COMMON_H |
29 |
29 |
30 #include "config.h" |
30 #include "config.h" |
31 |
31 |
32 #include <stdio.h> |
32 #include <stdio.h> |
33 #include <stdarg.h> |
|
34 #include <math.h> |
33 #include <math.h> |
35 #include <float.h> |
34 #include <float.h> |
36 #include <pthread.h> |
35 #include <pthread.h> |
37 #include <string> |
36 #include <string> |
38 |
37 |
40 |
39 |
41 #ifdef PYRIT_DOUBLE |
40 #ifdef PYRIT_DOUBLE |
42 # define Float double |
41 # define Float double |
43 # define Eps DBL_EPSILON |
42 # define Eps DBL_EPSILON |
44 # define Inf DBL_MAX |
43 # define Inf DBL_MAX |
|
44 # define PI M_PI |
45 #else |
45 #else |
46 # define Float float |
46 # define Float float |
47 # define Eps 1e-6f |
47 # define Eps 1e-6f |
48 # define Inf FLT_MAX |
48 # define Inf FLT_MAX |
|
49 # define PI (float)M_PI |
49 #endif |
50 #endif |
50 |
51 |
51 // enable M_* constants in MSVC |
52 // enable M_* constants in MSVC |
52 #define _USE_MATH_DEFINES |
53 #define _USE_MATH_DEFINES |
53 |
54 |
59 4: thread debug |
60 4: thread debug |
60 default = 2 |
61 default = 2 |
61 */ |
62 */ |
62 extern int pyrit_verbosity; |
63 extern int pyrit_verbosity; |
63 |
64 |
64 inline void dbgmsg(const int vlevel, const char *format, ...) |
65 void dbgmsg(const int vlevel, const char *format, ...); |
65 { |
|
66 static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; |
|
67 if (pyrit_verbosity >= vlevel) |
|
68 { |
|
69 if (pyrit_verbosity >= 4) |
|
70 pthread_mutex_lock(&mutex); |
|
71 |
|
72 va_list ap; |
|
73 va_start(ap, format); |
|
74 vprintf(format, ap); |
|
75 va_end(ap); |
|
76 fflush(stdout); |
|
77 |
|
78 if (pyrit_verbosity >= 4) |
|
79 pthread_mutex_unlock(&mutex); |
|
80 } |
|
81 } |
|
82 |
66 |
83 template<typename Type> const Type &min3(const Type &a, const Type &b, const Type &c) |
67 template<typename Type> const Type &min3(const Type &a, const Type &b, const Type &c) |
84 { |
68 { |
85 if (a <= b) |
69 if (a <= b) |
86 { |
70 { |