-
Notifications
You must be signed in to change notification settings - Fork 0
/
debug.h
37 lines (30 loc) · 1.04 KB
/
debug.h
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
/*
* Copyright (c) 2012-2022 Israel Jacquez
* See LICENSE for details.
*
* Israel Jacquez <[email protected]>
*/
#ifndef _LIBSSUSB_DEBUG_H_
#define _LIBSSUSB_DEBUG_H_
#ifdef DEBUG
#include <stdio.h>
#include <stdbool.h>
#define DEBUG_PRINTF(fmt, ...) do { \
(void)fprintf(stderr, "%s():%s:L%i:" " " fmt, \
__func__, __FILE__, __LINE__, \
##__VA_ARGS__); \
(void)fflush(stderr); \
} while(false)
#else
#define DEBUG_PRINTF(...)
#endif /* DEBUG */
#ifdef DEBUG
#include <inttypes.h>
void debug_hexdump(const char *buffer, size_t size, uint32_t width);
#define DEBUG_HEXDUMP(buffer, size) do { \
debug_hexdump((void *)buffer, size, 24); \
} while (false)
#else
#define DEBUG_HEXDUMP(...)
#endif /* DEBUG */
#endif /* !_LIBSSUSB_DEBUG_H_ */