]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - android/external-libkmsxx.git/blob - libkms++util/kms++util.h
File/dir renames
[android/external-libkmsxx.git] / libkms++util / kms++util.h
1 #pragma once
3 #include "color.h"
4 #include <cstdio>
5 #include <cstdlib>
7 namespace kms
8 {
9 class IMappedFramebuffer;
11 void draw_color_bar(IMappedFramebuffer& buf, int old_xpos, int xpos, int width);
13 void draw_test_pattern(IMappedFramebuffer &fb);
15 void draw_rect(IMappedFramebuffer &fb, uint32_t x, uint32_t y, uint32_t w, uint32_t h, RGB color);
16 }
18 #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
20 #define unlikely(x) __builtin_expect(!!(x), 0)
22 #define ASSERT(x) \
23         if (unlikely(!(x))) { \
24                 fprintf(stderr, "%s:%d: %s: ASSERT(%s) failed\n", __FILE__, __LINE__, __PRETTY_FUNCTION__, __STRING(x)); \
25                 abort(); \
26         }
28 #define FAIL(fmt, ...) \
29         do { \
30                 fprintf(stderr, "%s:%d: %s:\n" fmt "\n", __FILE__, __LINE__, __PRETTY_FUNCTION__, ##__VA_ARGS__); \
31                 abort(); \
32         } while(0)
34 #define FAIL_IF(x, fmt, ...) \
35         if (unlikely(x)) { \
36                 fprintf(stderr, "%s:%d: %s:\n" fmt "\n", __FILE__, __LINE__, __PRETTY_FUNCTION__, ##__VA_ARGS__); \
37                 abort(); \
38         }
40 #define EXIT(fmt, ...) \
41         do { \
42                 fprintf(stderr, fmt "\n", ##__VA_ARGS__); \
43                 exit(-1); \
44         } while(0)