-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmisc.c
49 lines (38 loc) · 1.08 KB
/
misc.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include "misc.h"
/* returns the time in ms*/
double cputime () {
struct rusage rus;
getrusage (RUSAGE_SELF, &rus);
return ( (double)rus.ru_utime.tv_sec * 1000 + (double)rus.ru_utime.tv_usec / 1000 );
}
int msglevel=1; /* default debug messages level (higher = more messages...) */
#if defined(NDEBUG) && defined(__GNUC__)
/* Nothing. pmesg has been "defined away" in misc.h already. */
#else
void pmesg(int level, char* format, ...) {
#ifdef NDEBUG
/* Empty body, so a good compiler will optimise calls
to pmesg away */
#else
va_list args;
if (level>msglevel)
return;
va_start(args, format);
vfprintf(stderr, format, args);
va_end(args);
#endif /* NDEBUG */
}
void gmp_pmesg(int level, char* format, ...) {
#ifdef NDEBUG
/* Empty body, so a good compiler will optimise calls
to pmesg away */
#else
va_list args;
if (level>msglevel)
return;
va_start(args, format);
gmp_vfprintf(stderr, format, args);
va_end(args);
#endif /* NDEBUG */
}
#endif /* NDEBUG && __GNUC__ */