#ifndef LEPTO_LEPTO_HPP
#define LEPTO_LEPTO_HPP
//----------------------------------------------------------------------------
//
// \file    lepto.h
// \brief   general stuff
//
//          See implementation for further documentation.
//
//----------------------------------------------------------------------------


//#if ! defined(LEPTO_CONFIG_HEADER)
//   #error LEPTO_CONFIG_HEADER not defined. The configuration header was probably not involved.
//#endif

//#include LEPTO_CONFIG_HEADER
// #include <configFoo.h>
//#include <config.h>

#if ! defined(LEPTO_CONFIGURED)
   #error   LEPTO_CONFIGURED not defined. The configuration header was \
            probably not involved. If the file is present make sure the macro \
            'LEPTO_CONFIGURED' is defined in the configuration header.
#endif

#if ! defined (MAX)
   #define MAX(x, y) (((x) > (y)) ? (x) : (y))
#endif
#if ! defined (MIN)
   #define MIN(x, y) (((x) < (y)) ? (x) : (y))
#endif

#define arraySize(array) (int)(sizeof(array)/sizeof(array[0]) )
#define xstringify(path) "" #path ""
#define stringify(path) xstringify(path)

#if defined(_LP64)
   #include <stdint.h>
   #define address_t uint64_t
   #define FI32   "%d"
#else
   #define address_t uint32_t
   #define FI32   "%ld"
#endif

#define address32_t uint32_t

// Helper macros to check if something is 'enabled' via macro. The macro can
// either be just defined, set to '1', 'y', or 'yes'.
// Setting the define to '0' or something else will 'disable' a feature.
#define ARG_1     1
#define ARG_y     1
#define ARG_yes   1
#define ARG_0     0
#define ARG_      1
//#define ARG_      "define feature as '1', 'y' or 'yes' to enable it."
// Need two stages to resolve defines; e.g. make "ARG_" instead of "ARG_FOO"
#define IS_ENABLED(a) _V_IS_ENABLED( a )
#define IS_SET(a) _V_IS_ENABLED( a )
// #define _V_IS_ENABLED(a) ARG_##a
#define _V_IS_ENABLED(a) __V_IS_ENABLED( a )
#define __V_IS_ENABLED(a) ARG_##a

#define CONFIG_TEST_ENABLED
#define CONFIG_TEST_ENABLED_1    1
#define CONFIG_TEST_DISABLED_0   0
#define CONFIG_TEST_DISABLED_n   n

#if ! IS_ENABLED( CONFIG_TEST_ENABLED )
   #error IS_ENABLED does not work [1]
#endif

#if ! IS_ENABLED( CONFIG_TEST_ENABLED_1 )
   #error IS_ENABLED does not work [2]
#endif

#if IS_ENABLED( CONFIG_TEST_DISABLED )
   #error IS_ENABLED does not work [3]
#endif

#if IS_ENABLED( CONFIG_TEST_DISABLED_0 )
   #error IS_ENABLED does not work [3]
#endif

#if IS_ENABLED( CONFIG_TEST_DISABLED_n )
   #error IS_ENABLED does not work [4]
#endif

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wexpansion-to-defined"

// This block is just for testing. Not needed for sourcecode.
#if 0

#define IS_DEFINED(a) defined( CONFIG_ ## a )

#if ! IS_DEFINED( TEST_DISABLED_0 )
#error IS_DEFINED does not work
#endif

#if ! IS_DEFINED( TEST_ENABLED )
#error IS_DEFINED does not work
#endif

#if ! IS_DEFINED( TEST_ENABLED_1 )
#error IS_DEFINED does not work
#endif

#endif // ? 0

#pragma GCC diagnostic pop

#define LEPTO_CODE            0x1

// When CONFIG_LEPTO_LOG_USE_PRETTY_PRINT is not defined, enable it only when
// CONFIG_LEPTO_LOG_DOWNSIZE is not set.
// Make it a nice default configuration.
#if ! defined CONFIG_LEPTO_LOG_USE_PRETTY_PRINT
   #if ! IS_ENABLED( CONFIG_LEPTO_LOG_DOWNSIZE )
      #define CONFIG_LEPTO_LOG_USE_PRETTY_PRINT          1
   #endif
#endif // ? ! defined CONFIG_LEPTO_LOG_USE_PRETTY_PRINT


//---fin----------------------------------------------------------------------
#endif // ? ! LEPTO_LEPTO_HPP
