17 #ifndef DISTRHO_UTILS_HPP_INCLUDED 
   18 #define DISTRHO_UTILS_HPP_INCLUDED 
   20 #include "src/DistrhoDefines.h" 
   30 #ifdef DISTRHO_PROPER_CPP11_SUPPORT 
   36 #if defined(DISTRHO_OS_MAC) && ! defined(CARLA_OS_MAC) 
   38 inline float fmin(
float __x, 
float __y)
 
   39   { 
return __builtin_fminf(__x, __y); }
 
   40 inline float fmax(
float __x, 
float __y)
 
   41   { 
return __builtin_fmaxf(__x, __y); }
 
   42 inline float rint(
float __x)
 
   43   { 
return __builtin_rintf(__x); }
 
   44 inline float round(
float __x)
 
   45   { 
return __builtin_roundf(__x); }
 
   50 # define M_PI 3.14159265358979323846 
   60 int64_t d_cconst(
const uint8_t a, 
const uint8_t b, 
const uint8_t c, 
const uint8_t d) noexcept
 
   62     return (a << 24) | (b << 16) | (c << 8) | (d << 0);
 
   69 void d_pass() noexcept {}
 
   82 void d_debug(
const char* 
const fmt, ...) noexcept
 
   86         ::va_start(args, fmt);
 
   87         std::fprintf(stdout, 
"\x1b[30;1m");
 
   88         std::vfprintf(stdout, fmt, args);
 
   89         std::fprintf(stdout, 
"\x1b[0m\n");
 
   99 void d_stdout(
const char* 
const fmt, ...) noexcept
 
  103         ::va_start(args, fmt);
 
  104         std::vfprintf(stdout, fmt, args);
 
  105         std::fprintf(stdout, 
"\n");
 
  114 void d_stderr(
const char* 
const fmt, ...) noexcept
 
  118         ::va_start(args, fmt);
 
  119         std::vfprintf(stderr, fmt, args);
 
  120         std::fprintf(stderr, 
"\n");
 
  129 void d_stderr2(
const char* 
const fmt, ...) noexcept
 
  133         ::va_start(args, fmt);
 
  134         std::fprintf(stderr, 
"\x1b[31m");
 
  135         std::vfprintf(stderr, fmt, args);
 
  136         std::fprintf(stderr, 
"\x1b[0m\n");
 
  145 void d_safe_assert(
const char* 
const assertion, 
const char* 
const file, 
const int line) noexcept
 
  147     d_stderr2(
"assertion failure: \"%s\" in file %s, line %i", assertion, file, line);
 
  154 void d_safe_exception(
const char* 
const exception, 
const char* 
const file, 
const int line) noexcept
 
  156     d_stderr2(
"exception caught: \"%s\" in file %s, line %i", exception, file, line);
 
  168 bool d_isEqual(
const T& v1, 
const T& v2)
 
  170     return std::abs(v1-v2) < std::numeric_limits<T>::epsilon();
 
  179 bool d_isNotEqual(
const T& v1, 
const T& v2)
 
  181     return std::abs(v1-v2) >= std::numeric_limits<T>::epsilon();
 
  189 bool d_isZero(
const T& value)
 
  191     return std::abs(value) < std::numeric_limits<T>::epsilon();
 
  199 bool d_isNotZero(
const T& value)
 
  201     return std::abs(value) >= std::numeric_limits<T>::epsilon();
 
  206 #endif // DISTRHO_UTILS_HPP_INCLUDED