Commit e274ebb0 authored by npzacs's avatar npzacs
Browse files

Simple logging optimization

parent 5bde0423
......@@ -17,8 +17,8 @@
* <http://www.gnu.org/licenses/>.
*/
#ifndef LIBBLURAY_ATTRIBUTES_H_
#define LIBBLURAY_ATTRIBUTES_H_
#ifndef LIBAACS_ATTRIBUTES_H_
#define LIBAACS_ATTRIBUTES_H_
#if defined(__GNUC__) && (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3 ))
# define AACS_ATTR_FORMAT_PRINTF(format,var) \
......@@ -47,4 +47,12 @@
# define AACS_PRIVATE
#endif
#endif /* LIBBLURAY_ATTRIBUTES_H_ */
#if !defined(__GNUC__) || __GNUC__ < 3
# define AACS_LIKELY(x) (x)
# define AACS_UNLIKELY(x) (x)
#else
# define AACS_LIKELY(x) __builtin_expect((x),1)
# define AACS_UNLIKELY(x) __builtin_expect((x),0)
#endif
#endif /* LIBAACS_ATTRIBUTES_H_ */
......@@ -24,7 +24,7 @@
#include <stdarg.h>
#include <string.h>
static debug_mask_t debug_mask = DBG_CRIT;
uint32_t debug_mask = (uint32_t)-1; /* set all bits to make sure aacs_debug() is called for initialization */
char *print_hex(char *out, const uint8_t *buf, int count)
{
......
......@@ -24,7 +24,14 @@
#include <stdint.h>
#define DEBUG(MASK,...) aacs_debug(__FILE__,__LINE__,MASK,##__VA_ARGS__)
AACS_PRIVATE extern uint32_t debug_mask;
#define DEBUG(MASK,...) \
do { \
if (AACS_UNLIKELY((MASK) & debug_mask)) { \
aacs_debug(__FILE__,__LINE__,MASK,__VA_ARGS__); \
} \
} while (0)
enum debug_mask_enum {
DBG_RESERVED = 0x0001,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment