// Vorosweep - Copyright (C) 2010-2014 T. Mouton
//
// See the LICENSE.txt file for license information. Please report all
// bugs and problems to <thibaud.mouton@gmail.com>.

#include <stdio.h>
#include <time.h>

#ifndef _common_include
#define _common_include

// relative to unit tests
#if COMPILE_UNIT_TESTS
#define DEBUG_LEVEL 0
#else
#define DEBUG_LEVEL 0
#endif

// #define DURTY

// macro dbgprintf
#if DEBUG_LEVEL > 0
#define dbgprintf(x, ...) if(x<=DEBUG_LEVEL) printf(__VA_ARGS__)
#else
#define dbgprintf(x, ...) {}
#endif
// fin de macro dbgprintf

// macro tprintf
#define tprintf(...) printf("### %lf ### ", clock ()*1e-6); printf(__VA_ARGS__)
// fin de macro tprintf

#define MAX(a, b) (((a) > (b)) ? (a) : (b))
#define MIN(a, b) (((a) < (b)) ? (a) : (b))

#define CLEAR_BIT(var,pos) ((var) &= ~(1 << (pos)))
#define CHECK_BIT(var,pos) !!((var) & (1<<(pos)))
#define SET_BIT(var,pos) ((var) |= (1 << (pos)))
#define XOR_BIT(var,pos) ((var) ^= (1 << (pos)))

// #if !defined(NDEBUG)
// #  include <assert.h>
// #else               /* debugging not enabled */
// #  define assert(x) /* empty macro to prevent errors */
// #endif

#include "pempek_assert.h"

// custom prefix
#define ASSERT PEMPEK_ASSERT
#define ASSERT_WARNING PEMPEK_ASSERT_WARNING
#define ASSERT_DEBUG PEMPEK_ASSERT_DEBUG
#define ASSERT_ERROR PEMPEK_ASSERT_ERROR
#define ASSERT_FATAL PEMPEK_ASSERT_FATAL
#define ASSERT_CUSTOM PEMPEK_ASSERT_CUSTOM
#define ASSERT_USED PEMPEK_ASSERT_USED

#define MAX_EVENT_LIST 10000

#endif