~ubuntu-branches/ubuntu/utopic/libpthread-workqueue/utopic

« back to all changes in this revision

Viewing changes to src/debug.h

  • Committer: Bazaar Package Importer
  • Author(s): Mark Heily
  • Date: 2011-05-07 11:57:22 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20110507115722-n8ftqsa8w2el0xkn
Tags: 0.5.1-1
* New upstream version.
* Update control file with new Standards-Version.
* Remove -m64 from CFLAGS (Closes: #622798)
* Limit architecture to linux-any (Closes: #622799)

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
 
20
20
#include <assert.h>
21
21
 
22
 
extern int DEBUG;
 
22
extern int DEBUG_ACTIVE;
23
23
extern char *DEBUG_IDENT;
24
24
 
25
25
#if defined(__linux__)
31
31
# define THREAD_ID ((pid_t)  syscall(__NR_gettid))
32
32
#elif defined(__sun)
33
33
# define THREAD_ID (pthread_self())
 
34
#elif defined(__FreeBSD__)  /* FIXME -- could use thr_self() */
 
35
# define THREAD_ID (0)
34
36
#elif defined(_WIN32)
35
 
# define THREAD_ID (GetCurrentThreadId())
 
37
# define THREAD_ID (int)(GetCurrentThreadId())
36
38
#else 
37
39
# error Unsupported platform
38
40
#endif
40
42
 
41
43
#ifndef NDEBUG
42
44
#define dbg_puts(str)           do {                                \
43
 
    if (DEBUG)                                                      \
 
45
    if (DEBUG_ACTIVE)                                                      \
44
46
      fprintf(stderr, "%s [%d]: %s(): %s\n",                        \
45
47
              DEBUG_IDENT, THREAD_ID, __func__, str);               \
46
48
} while (0)
47
49
 
48
50
#define dbg_printf(fmt,...)     do {                                \
49
 
    if (DEBUG)                                                      \
 
51
    if (DEBUG_ACTIVE)                                                      \
50
52
      fprintf(stderr, "%s [%d]: %s(): "fmt"\n",                     \
51
53
              DEBUG_IDENT, THREAD_ID, __func__, __VA_ARGS__);       \
52
54
} while (0)
53
55
 
54
56
#define dbg_perror(str)         do {                                \
55
 
    if (DEBUG)                                                      \
 
57
    if (DEBUG_ACTIVE)                                                      \
56
58
      fprintf(stderr, "%s [%d]: %s(): %s: %s (errno=%d)\n",         \
57
59
              DEBUG_IDENT, THREAD_ID, __func__, str,                \
58
60
              strerror(errno), errno);                              \
62
64
 
63
65
# if defined(_WIN32)
64
66
#  define dbg_lasterror(str)     do {                                \
65
 
    if (DEBUG)                                                      \
 
67
    if (DEBUG_ACTIVE)                                                      \
66
68
      fprintf(stderr, "%s: [%d] %s(): %s: (LastError=%d)\n",        \
67
69
              THREAD_ID, __func__, str, GetLastError());            \
68
70
} while (0)