File: pocl_debug.h

package info (click to toggle)
pocl 7.1-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 29,768 kB
  • sloc: lisp: 151,669; ansic: 135,425; cpp: 65,801; python: 1,846; sh: 1,084; ruby: 255; pascal: 231; tcl: 180; makefile: 174; asm: 81; java: 72; xml: 49
file content (583 lines) | stat: -rw-r--r-- 30,963 bytes parent folder | download
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
/* pocl_debug.h: Internal debugging aids.

   Copyright (c) 2011-2024 pocl developers

   Permission is hereby granted, free of charge, to any person obtaining a copy
   of this software and associated documentation files (the "Software"), to
   deal in the Software without restriction, including without limitation the
   rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
   sell copies of the Software, and to permit persons to whom the Software is
   furnished to do so, subject to the following conditions:

   The above copyright notice and this permission notice shall be included in
   all copies or substantial portions of the Software.

   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
   FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
   AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
   LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
   FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
   IN THE SOFTWARE.
*/

#ifndef POCL_DEBUG_H
#define POCL_DEBUG_H

#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#ifndef __STDC_FORMAT_MACROS
#define __STDC_FORMAT_MACROS
#endif
#include <inttypes.h>

#include "config.h"

#include "CL/cl.h"
#include "pocl_export.h"
#include "pocl_threads.h"

// size_t print spec
#ifndef PRIuS
#ifdef _MSC_VER
#define PRIuS "Iu"
#else
# define PRIuS "zu"
#endif
#endif

#ifndef PRId64
# define PRId64 PRIu64
#endif

#if defined(__ANDROID__)
#include <android/log.h>
#define log_printf(...)                                                       \
  __android_log_print (ANDROID_LOG_INFO, "POCL_LOG", __VA_ARGS__)
#else
#define log_printf(...) fprintf (stderr, __VA_ARGS__)
#endif

#ifdef __cplusplus
extern "C" {
#endif

// should use some terminfo library, but..
#define POCL_COLOR_RESET   "\033[0m"
#define POCL_COLOR_BLACK   "\033[30m"      /* Black */
#define POCL_COLOR_RED     "\033[31m"      /* Red */
#define POCL_COLOR_GREEN   "\033[32m"      /* Green */
#define POCL_COLOR_YELLOW  "\033[33m"      /* Yellow */
#define POCL_COLOR_BLUE    "\033[34m"      /* Blue */
#define POCL_COLOR_MAGENTA "\033[35m"      /* Magenta */
#define POCL_COLOR_CYAN    "\033[36m"      /* Cyan */
#define POCL_COLOR_WHITE   "\033[37m"      /* White */
#define POCL_COLOR_BOLDBLACK   "\033[1m\033[30m"      /* Bold Black */
#define POCL_COLOR_BOLDRED     "\033[1m\033[31m"      /* Bold Red */
#define POCL_COLOR_BOLDGREEN   "\033[1m\033[32m"      /* Bold Green */
#define POCL_COLOR_BOLDYELLOW  "\033[1m\033[33m"      /* Bold Yellow */
#define POCL_COLOR_BOLDBLUE    "\033[1m\033[34m"      /* Bold Blue */
#define POCL_COLOR_BOLDMAGENTA "\033[1m\033[35m"      /* Bold Magenta */
#define POCL_COLOR_BOLDCYAN    "\033[1m\033[36m"      /* Bold Cyan */
#define POCL_COLOR_BOLDWHITE   "\033[1m\033[37m"      /* Bold White */

/* bitfield values for pocl_debug_messages_filter */
#define POCL_DEBUG_FLAG_GENERAL 0x1
#define POCL_DEBUG_FLAG_MEMORY 0x2
#define POCL_DEBUG_FLAG_LLVM 0x4
#define POCL_DEBUG_FLAG_EVENTS 0x8
#define POCL_DEBUG_FLAG_CACHE 0x10
#define POCL_DEBUG_FLAG_LOCKING 0x20
#define POCL_DEBUG_FLAG_REFCOUNTS 0x40
#define POCL_DEBUG_FLAG_TIMING 0x80
#define POCL_DEBUG_FLAG_HSA 0x100
#define POCL_DEBUG_FLAG_TCE 0x200
#define POCL_DEBUG_FLAG_CUDA 0x400
#define POCL_DEBUG_FLAG_ALMAIF 0x800
#define POCL_DEBUG_FLAG_PROXY 0x1000
#define POCL_DEBUG_FLAG_ALMAIF_MMAP 0x2000
#define POCL_DEBUG_FLAG_LEVEL0 0x4000
#define POCL_DEBUG_FLAG_REMOTE 0x8000
#define POCL_DEBUG_FLAG_STREAM 0x10000

#define POCL_DEBUG_FLAG_VULKAN 0x80000

#define POCL_DEBUG_FLAG_WARNING  0x8000000000UL
#define POCL_DEBUG_FLAG_ERROR   0x10000000000UL
#define POCL_DEBUG_FLAG_ALL (uint64_t)(-1)

#define POCL_FILTER_TYPE_INFO 1
#define POCL_FILTER_TYPE_WARN 2
#define POCL_FILTER_TYPE_ERR 3

/* Debugging macros. Also macros for marking unimplemented parts of specs or
   untested parts of the implementation. */

#define POCL_ABORT_UNIMPLEMENTED(MSG)                                         \
  do                                                                          \
    {                                                                         \
      log_printf ("%s is unimplemented (%s:%d)\n", MSG, __FILE__, __LINE__);  \
      exit (2);                                                               \
    }                                                                         \
  while (0)

#define POCL_WARN_UNTESTED()                                                  \
  do                                                                          \
    {                                                                         \
      log_printf ("pocl warning: encountered untested part of the "           \
                  "implementation in %s:%d\n",                                \
                  __FILE__, __LINE__);                                        \
    }                                                                         \
  while (0)

#define POCL_WARN_INCOMPLETE()                                                \
  do                                                                          \
    {                                                                         \
      log_printf ("pocl warning: encountered incomplete implementation"       \
                  " in %s:%d\n",                                              \
                  __FILE__, __LINE__);                                        \
    }                                                                         \
  while (0)

#define POCL_ABORT(...)                                                       \
  do                                                                          \
    {                                                                         \
      log_printf (__VA_ARGS__);                                               \
      abort ();                                                               \
    }                                                                         \
  while (0)

#define POCL_ERROR(x) do { if (errcode_ret != NULL) {                   \
                              *errcode_ret = (x);                       \
                           } return NULL; } while (0)

#define POCL_SUCCESS() do { if (errcode_ret != NULL) {                  \
                              *errcode_ret = CL_SUCCESS;                \
                            } } while (0)

#ifdef POCL_DEBUG_MESSAGES

POCL_EXPORT
    extern uint64_t pocl_debug_messages_filter;
POCL_EXPORT
    extern int pocl_stderr_is_a_tty;

    #define POCL_DEBUGGING_ON (pocl_debug_messages_filter)

        #define POCL_DEBUG_HEADER(FILTER, FILTER_TYPE) \
            pocl_debug_print_header (__func__, __LINE__, #FILTER, FILTER_TYPE);
/**
 * Dumps all commands and events of the context as a graphviz dot file.
 *
 * Currently works only with PoCL contexts.
 *
 * \param context the OpenCL context to dump.
 * \param file_name the target file name.
 */
POCL_EXPORT
void pocl_dump_dot_task_graph (cl_context context, const char *file_name);

POCL_EXPORT
void pocl_dump_dot_task_graph_wait ();

POCL_EXPORT
void pocl_dump_dot_task_graph_signal ();

/**
 * Converts a command type to a string.
 *
 * \param cmd The command.
 * \param shortened Set to 1 for a shortened string.
 */
POCL_EXPORT
const char *pocl_command_type_to_str (cl_command_type cmd, int shortened);

POCL_EXPORT
        extern void pocl_debug_output_lock (void);
POCL_EXPORT
        extern void pocl_debug_output_unlock (void);
POCL_EXPORT
        extern void pocl_debug_messages_setup (const char *debug);
POCL_EXPORT
        extern void pocl_debug_print_header (const char * func, unsigned line,
                                             const char* filter, int filter_type);
POCL_EXPORT
        extern void pocl_debug_measure_start (uint64_t* start);
POCL_EXPORT
        extern void pocl_debug_measure_finish (uint64_t* start, uint64_t* finish,
                                               const char* msg,
                                               const char *func,
                                               unsigned line);
POCL_EXPORT
        extern void pocl_debug_print_duration (const char* func, unsigned line,
                                               const char* msg, uint64_t nanosecs);
        #define POCL_MEASURE_START(SUFFIX) \
          uint64_t pocl_time_start_ ## SUFFIX, pocl_time_finish_ ## SUFFIX; \
          pocl_debug_measure_start(&pocl_time_start_ ## SUFFIX);

        #define POCL_MEASURE_FINISH(SUFFIX) \
          pocl_debug_measure_finish (&pocl_time_start_ ## SUFFIX,           \
                         &pocl_time_finish_ ## SUFFIX, "API: " #SUFFIX,     \
                         __func__, __LINE__);

    #define POCL_MSG_PRINT_F(FILTER, TYPE, ERRCODE, ...)                    \
        do {                                                                \
          if (pocl_debug_messages_filter & POCL_DEBUG_FLAG_ ## FILTER) {    \
            pocl_debug_output_lock ();                                      \
                POCL_DEBUG_HEADER(FILTER, POCL_FILTER_TYPE_ ## TYPE)        \
                if (pocl_stderr_is_a_tty)                                   \
                  log_printf ( "%s", POCL_COLOR_BOLDRED                 \
                                    ERRCODE " "  POCL_COLOR_RESET);         \
                else                                                        \
                  log_printf ( "%s", ERRCODE " ");                      \
                log_printf ( __VA_ARGS__);                              \
            pocl_debug_output_unlock ();                                    \
          }                                                                 \
        } while (0)

    #define POCL_MSG_PRINT2(FILTER, func, line, ...)                        \
        do {                                                                \
          if (pocl_debug_messages_filter & POCL_DEBUG_FLAG_ ## FILTER) {    \
            pocl_debug_output_lock ();                                      \
                pocl_debug_print_header (func, line,                        \
                                 #FILTER, POCL_FILTER_TYPE_INFO);           \
                log_printf (__VA_ARGS__);                             \
            pocl_debug_output_unlock ();                                    \
          }                                                                 \
        } while (0)


    #define POCL_MSG_WARN2(errcode, ...) \
              POCL_MSG_PRINT_F(WARNING, WARN, errcode, __VA_ARGS__)
    #define POCL_MSG_WARN(...)  POCL_MSG_WARN2("", __VA_ARGS__)

    #define POCL_MSG_ERR2(errcode, ...) \
          POCL_MSG_PRINT_F(ERROR, ERR, errcode, __VA_ARGS__)
    #define POCL_MSG_ERR(...)  POCL_MSG_ERR2("", __VA_ARGS__)

    #define POCL_MSG_PRINT_INFO2(errcode, ...) \
          POCL_MSG_PRINT_F(GENERAL, INFO, errcode, __VA_ARGS__)
    #define POCL_MSG_PRINT_INFO(...) POCL_MSG_PRINT_INFO2("", __VA_ARGS__)

    #define POCL_MSG_PRINT_INFO_F(filter, errcode, ...) \
          POCL_MSG_PRINT_F(filter, INFO, errcode, __VA_ARGS__)

    #define POCL_MSG_PRINT_ALMAIF2(errcode, ...) POCL_MSG_PRINT_INFO_F(ALMAIF, errcode, __VA_ARGS__)
    #define POCL_MSG_PRINT_ALMAIF(...) POCL_MSG_PRINT_INFO_F(ALMAIF, "", __VA_ARGS__)
    #define POCL_MSG_PRINT_ALMAIF_MMAP(...) POCL_MSG_PRINT_INFO_F(ALMAIF_MMAP, "", __VA_ARGS__)
#define POCL_MSG_PRINT_STREAM2(errcode, ...)                                  \
  POCL_MSG_PRINT_INFO_F (STREAM, errcode, __VA_ARGS__)
#define POCL_MSG_PRINT_STREAM(...)                                            \
  POCL_MSG_PRINT_INFO_F (STREAM, "", __VA_ARGS__)
#define POCL_MSG_PRINT_PROXY2(errcode, ...)                                   \
  POCL_MSG_PRINT_INFO_F (PROXY, errcode, __VA_ARGS__)
#define POCL_MSG_PRINT_PROXY(...)                                             \
  POCL_MSG_PRINT_INFO_F (PROXY, "", __VA_ARGS__)
#define POCL_MSG_PRINT_LEVEL0(...)                                            \
  POCL_MSG_PRINT_INFO_F (LEVEL0, "", __VA_ARGS__)
#define POCL_MSG_PRINT_VULKAN2(errcode, ...)                                  \
  POCL_MSG_PRINT_INFO_F (VULKAN, errcode, __VA_ARGS__)
#define POCL_MSG_PRINT_VULKAN(...)                                            \
  POCL_MSG_PRINT_INFO_F (VULKAN, "", __VA_ARGS__)
#define POCL_MSG_PRINT_REMOTE2(errcode, ...)                                  \
  POCL_MSG_PRINT_INFO_F (REMOTE, errcode, __VA_ARGS__)
#define POCL_MSG_PRINT_REMOTE(...)                                            \
  POCL_MSG_PRINT_INFO_F (REMOTE, "", __VA_ARGS__)
#define POCL_MSG_PRINT_CUDA2(errcode, ...)                                    \
  POCL_MSG_PRINT_INFO_F (CUDA, errcode, __VA_ARGS__)
#define POCL_MSG_PRINT_CUDA(...) POCL_MSG_PRINT_INFO_F (CUDA, "", __VA_ARGS__)
#define POCL_MSG_PRINT_HSA2(errcode, ...)                                     \
  POCL_MSG_PRINT_INFO_F (HSA, errcode, __VA_ARGS__)
#define POCL_MSG_PRINT_HSA(...) POCL_MSG_PRINT_INFO_F (HSA, "", __VA_ARGS__)
#define POCL_MSG_PRINT_TCE2(errcode, ...)                                     \
  POCL_MSG_PRINT_INFO_F (TCE, errcode, __VA_ARGS__)
#define POCL_MSG_PRINT_TCE(...) POCL_MSG_PRINT_INFO_F (TCE, "", __VA_ARGS__)
#define POCL_MSG_PRINT_LOCKING2(errcode, ...)                                 \
  POCL_MSG_PRINT_INFO_F (LOCKING, errcode, __VA_ARGS__)
#define POCL_MSG_PRINT_LOCKING(...)                                           \
  POCL_MSG_PRINT_INFO_F (LOCKING, "", __VA_ARGS__)
#define POCL_MSG_PRINT_REFCOUNTS2(errcode, ...)                               \
  POCL_MSG_PRINT_INFO_F (REFCOUNTS, errcode, __VA_ARGS__)
#define POCL_MSG_PRINT_REFCOUNTS(...)                                         \
  POCL_MSG_PRINT_INFO_F (REFCOUNTS, "", __VA_ARGS__)
#define POCL_MSG_PRINT_CACHE2(errcode, ...)                                   \
  POCL_MSG_PRINT_INFO_F (CACHE, errcode, __VA_ARGS__)
#define POCL_MSG_PRINT_CACHE(...)                                             \
  POCL_MSG_PRINT_INFO_F (CACHE, "", __VA_ARGS__)
#define POCL_MSG_PRINT_EVENTS2(errcode, ...)                                  \
  POCL_MSG_PRINT_INFO_F (EVENTS, errcode, __VA_ARGS__)
#define POCL_MSG_PRINT_EVENTS(...)                                            \
  POCL_MSG_PRINT_INFO_F (EVENTS, "", __VA_ARGS__)
#define POCL_MSG_PRINT_LLVM2(errcode, ...)                                    \
  POCL_MSG_PRINT_INFO_F (LLVM, errcode, __VA_ARGS__)
#define POCL_MSG_PRINT_LLVM(...) POCL_MSG_PRINT_INFO_F (LLVM, "", __VA_ARGS__)
#define POCL_MSG_PRINT_MEMORY2(errcode, ...)                                  \
  POCL_MSG_PRINT_INFO_F (MEMORY, errcode, __VA_ARGS__)
#define POCL_MSG_PRINT_MEMORY(...)                                            \
  POCL_MSG_PRINT_INFO_F (MEMORY, "", __VA_ARGS__)
#define POCL_MSG_PRINT_GENERAL2(errcode, ...)                                 \
  POCL_MSG_PRINT_INFO_F (GENERAL, errcode, __VA_ARGS__)
#define POCL_MSG_PRINT_GENERAL(...)                                           \
  POCL_MSG_PRINT_INFO_F (GENERAL, "", __VA_ARGS__)

#else

    #define POCL_DEBUGGING_ON 0

    #define POCL_MSG_PRINT_F(...)  do {} while (0)
    #define POCL_MSG_PRINT(...)  do {} while (0)
    #define POCL_MSG_PRINT2(...)  do {} while (0)
    #define POCL_MSG_WARN(...)  do {} while (0)
    #define POCL_MSG_WARN2(...)  do {} while (0)
    #define POCL_MSG_ERR(...)  do {} while (0)
    #define POCL_MSG_ERR2(...)  do {} while (0)
    #define POCL_MSG_PRINT_INFO(...)  do {} while (0)
    #define POCL_MSG_PRINT_INFO2(...)  do {} while (0)
    #define POCL_MSG_PRINT_INFO_F(...)  do {} while (0)

    #define POCL_DEBUG_HEADER
    #define POCL_MEASURE_START(...)  do {} while (0)
    #define POCL_MEASURE_FINISH(...)  do {} while (0)
    #define POCL_DEBUG_EVENT_TIME(...)  do {} while (0)

    #define POCL_MSG_PRINT_ALMAIF2(...)  do {} while (0)
    #define POCL_MSG_PRINT_ALMAIF(...)  do {} while (0)
    #define POCL_MSG_PRINT_ALMAIF_MMAP(...)  do {} while (0)
#define POCL_MSG_PRINT_STREAM2(...)                                           \
  do                                                                          \
    {                                                                         \
    }                                                                         \
  while (0)
#define POCL_MSG_PRINT_STREAM(...)                                            \
  do                                                                          \
    {                                                                         \
    }                                                                         \
  while (0)
#define POCL_MSG_PRINT_PROXY2(...)                                            \
  do                                                                          \
    {                                                                         \
    }                                                                         \
  while (0)
#define POCL_MSG_PRINT_PROXY(...)                                             \
  do                                                                          \
    {                                                                         \
    }                                                                         \
  while (0)
#define POCL_MSG_PRINT_LEVEL0(...)                                            \
  do                                                                          \
    {                                                                         \
    }                                                                         \
  while (0)
#define POCL_MSG_PRINT_VULKAN2(...)                                           \
  do                                                                          \
    {                                                                         \
    }                                                                         \
  while (0)
#define POCL_MSG_PRINT_VULKAN(...)                                            \
  do                                                                          \
    {                                                                         \
    }                                                                         \
  while (0)
#define POCL_MSG_PRINT_REMOTE2(...)                                           \
  do                                                                          \
    {                                                                         \
    }                                                                         \
  while (0)
#define POCL_MSG_PRINT_REMOTE(...)                                            \
  do                                                                          \
    {                                                                         \
    }                                                                         \
  while (0)
#define POCL_MSG_PRINT_CUDA2(...)                                             \
  do                                                                          \
    {                                                                         \
    }                                                                         \
  while (0)
#define POCL_MSG_PRINT_CUDA(...)                                              \
  do                                                                          \
    {                                                                         \
    }                                                                         \
  while (0)
#define POCL_MSG_PRINT_HSA2(...)                                              \
  do                                                                          \
    {                                                                         \
    }                                                                         \
  while (0)
#define POCL_MSG_PRINT_HSA(...)                                               \
  do                                                                          \
    {                                                                         \
    }                                                                         \
  while (0)
#define POCL_MSG_PRINT_TCE2(...)                                              \
  do                                                                          \
    {                                                                         \
    }                                                                         \
  while (0)
#define POCL_MSG_PRINT_TCE(...)                                               \
  do                                                                          \
    {                                                                         \
    }                                                                         \
  while (0)
#define POCL_MSG_PRINT_LOCKING2(...)                                          \
  do                                                                          \
    {                                                                         \
    }                                                                         \
  while (0)
#define POCL_MSG_PRINT_LOCKING(...)                                           \
  do                                                                          \
    {                                                                         \
    }                                                                         \
  while (0)
#define POCL_MSG_PRINT_REFCOUNTS2(...)                                        \
  do                                                                          \
    {                                                                         \
    }                                                                         \
  while (0)
#define POCL_MSG_PRINT_REFCOUNTS(...)                                         \
  do                                                                          \
    {                                                                         \
    }                                                                         \
  while (0)
#define POCL_MSG_PRINT_CACHE2(...)                                            \
  do                                                                          \
    {                                                                         \
    }                                                                         \
  while (0)
#define POCL_MSG_PRINT_CACHE(...)                                             \
  do                                                                          \
    {                                                                         \
    }                                                                         \
  while (0)
#define POCL_MSG_PRINT_EVENTS2(...)                                           \
  do                                                                          \
    {                                                                         \
    }                                                                         \
  while (0)
#define POCL_MSG_PRINT_EVENTS(...)                                            \
  do                                                                          \
    {                                                                         \
    }                                                                         \
  while (0)
#define POCL_MSG_PRINT_LLVM2(...)                                             \
  do                                                                          \
    {                                                                         \
    }                                                                         \
  while (0)
#define POCL_MSG_PRINT_LLVM(...)                                              \
  do                                                                          \
    {                                                                         \
    }                                                                         \
  while (0)
#define POCL_MSG_PRINT_MEMORY2(...)                                           \
  do                                                                          \
    {                                                                         \
    }                                                                         \
  while (0)
#define POCL_MSG_PRINT_MEMORY(...)                                            \
  do                                                                          \
    {                                                                         \
    }                                                                         \
  while (0)
#define POCL_MSG_PRINT_GENERAL2(...)                                          \
  do                                                                          \
    {                                                                         \
    }                                                                         \
  while (0)
#define POCL_MSG_PRINT_GENERAL(...)                                           \
  do                                                                          \
    {                                                                         \
    }                                                                         \
  while (0)

#endif

#define POCL_RETURN_ERROR(err_code, ...)                                      \
        POCL_MSG_ERR2 (#err_code, __VA_ARGS__);                               \
        return err_code

#define POCL_GOTO_ERROR(err_code, ...)                                        \
        POCL_MSG_ERR2 (#err_code, __VA_ARGS__);                               \
        errcode = err_code;                                                   \
        goto err_code

#define POCL_GOTO_ERROR_ON(cond, err_code, ...)                             \
  do                                                                        \
    {                                                                       \
      if (cond)                                                             \
        {                                                                   \
            POCL_MSG_ERR2(#err_code, __VA_ARGS__);                          \
            errcode = err_code;                                             \
            goto ERROR;                                                     \
        }                                                                   \
    }                                                                       \
  while (0)

#define POCL_RETURN_ERROR_ON(cond, err_code, ...)                             \
        do                                                                    \
          {                                                                   \
            if (cond)                                                         \
              {                                                               \
                POCL_MSG_ERR2 (#err_code, __VA_ARGS__);                       \
                return err_code;                                              \
              }                                                               \
          }                                                                   \
        while (0)

#define POCL_RETURN_ERROR_COND(cond, err_code)                              \
  do                                                                        \
    {                                                                       \
      if (cond)                                                             \
        {                                                                   \
          POCL_MSG_ERR2(#err_code, "%s\n", #cond);                          \
          return err_code;                                                  \
        }                                                                   \
    }                                                                       \
  while (0)

#define POCL_GOTO_ERROR_COND(cond, err_code)                                \
  do                                                                        \
    {                                                                       \
      if (cond)                                                             \
        {                                                                   \
          POCL_MSG_ERR2(#err_code, "%s\n", #cond);                          \
          errcode = err_code;                                               \
          goto ERROR;                                                       \
        }                                                                   \
    }                                                                       \
  while (0)

#define POCL_GOTO_LABEL_COND(label, cond, err_code)                           \
  do                                                                          \
    {                                                                         \
      if (cond)                                                               \
        {                                                                     \
          POCL_MSG_ERR2 (#err_code, "%s\n", #cond);                           \
          errcode = err_code;                                                 \
          goto label;                                                         \
        }                                                                     \
    }                                                                         \
  while (0)

#define POCL_GOTO_LABEL_ON(label, cond, err_code, ...)                        \
  do                                                                          \
    {                                                                         \
      if (cond)                                                               \
        {                                                                     \
          POCL_MSG_ERR2 (#err_code, __VA_ARGS__);                             \
          errcode = err_code;                                                 \
          goto label;                                                         \
        }                                                                     \
    }                                                                         \
  while (0)


#ifdef __cplusplus
}
#endif


#endif