Browse Source

Misx

gh-pages
falkTX 11 years ago
parent
commit
1f2b3045d0
1 changed files with 25 additions and 16 deletions
  1. +25
    -16
      distrho/DistrhoUtils.hpp

+ 25
- 16
distrho/DistrhoUtils.hpp View File

@@ -49,6 +49,9 @@ inline float
inline float inline float
rint(float __x) rint(float __x)
{ return __builtin_rintf(__x); } { return __builtin_rintf(__x); }
inline float
round(float __x)
{ return __builtin_roundf(__x); }
} }
#endif #endif


@@ -70,44 +73,50 @@ long d_cconst(int a, int b, int c, int d) noexcept
static inline static inline
void d_debug(const char* const fmt, ...) void d_debug(const char* const fmt, ...)
{ {
va_list args;
va_start(args, fmt);
::va_list args;
::va_start(args, fmt);
std::fprintf(stdout, "\x1b[30;1m"); std::fprintf(stdout, "\x1b[30;1m");
std::vfprintf(stdout, fmt, args); std::vfprintf(stdout, fmt, args);
std::fprintf(stdout, "\x1b[0m\n"); std::fprintf(stdout, "\x1b[0m\n");
va_end(args);
::va_end(args);
} }
#endif #endif


static inline static inline
void d_stdout(const char* const fmt, ...) void d_stdout(const char* const fmt, ...)
{ {
va_list args;
va_start(args, fmt);
::va_list args;
::va_start(args, fmt);
std::vfprintf(stdout, fmt, args); std::vfprintf(stdout, fmt, args);
std::fprintf(stdout, "\n"); std::fprintf(stdout, "\n");
va_end(args);
::va_end(args);
} }


static inline static inline
void d_stderr(const char* const fmt, ...) void d_stderr(const char* const fmt, ...)
{ {
va_list args;
va_start(args, fmt);
::va_list args;
::va_start(args, fmt);
std::vfprintf(stderr, fmt, args); std::vfprintf(stderr, fmt, args);
std::fprintf(stderr, "\n"); std::fprintf(stderr, "\n");
va_end(args);
::va_end(args);
} }


static inline static inline
void d_stderr2(const char* const fmt, ...) void d_stderr2(const char* const fmt, ...)
{ {
va_list args;
va_start(args, fmt);
::va_list args;
::va_start(args, fmt);
std::fprintf(stderr, "\x1b[31m"); std::fprintf(stderr, "\x1b[31m");
std::vfprintf(stderr, fmt, args); std::vfprintf(stderr, fmt, args);
std::fprintf(stderr, "\x1b[0m\n"); std::fprintf(stderr, "\x1b[0m\n");
va_end(args);
::va_end(args);
}

static inline
void d_safe_assert(const char* const assertion, const char* const file, const int line)
{
d_stderr2("assertion failure: \"%s\" in file %s, line %i", assertion, file, line);
} }


// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
@@ -117,9 +126,9 @@ static inline
void d_sleep(unsigned int secs) void d_sleep(unsigned int secs)
{ {
#ifdef DISTRHO_OS_WINDOWS #ifdef DISTRHO_OS_WINDOWS
Sleep(secs * 1000);
::Sleep(secs * 1000);
#else #else
sleep(secs);
::sleep(secs);
#endif #endif
} }


@@ -127,9 +136,9 @@ static inline
void d_msleep(unsigned int msecs) void d_msleep(unsigned int msecs)
{ {
#ifdef DISTRHO_OS_WINDOWS #ifdef DISTRHO_OS_WINDOWS
Sleep(msecs);
::Sleep(msecs);
#else #else
usleep(msecs * 1000);
::usleep(msecs * 1000);
#endif #endif
} }




Loading…
Cancel
Save