compilation: Add -Wconversion to more files and validate CONV_SOURCES

All files under the os, api and msgpack_rpc directories have -Wconversion
automatically applied. CONV_SOURCES is also checked for missing files(when
renaming, for example)
This commit is contained in:
Thiago de Arruda
2014-10-21 08:53:55 -03:00
parent cf9571b7b1
commit 79b7263f79
6 changed files with 61 additions and 60 deletions

View File

@@ -1,3 +1,4 @@
#include <assert.h>
#include <stdint.h>
#include <stdbool.h>
#include <time.h>
@@ -64,23 +65,6 @@ void os_microdelay(uint64_t microseconds, bool ignoreinput)
}
}
static void microdelay(uint64_t microseconds)
{
uint64_t hrtime;
int64_t ns = microseconds * 1000; // convert to nanoseconds
uv_mutex_lock(&delay_mutex);
while (ns > 0) {
hrtime = uv_hrtime();
if (uv_cond_timedwait(&delay_cond, &delay_mutex, ns) == UV_ETIMEDOUT)
break;
ns -= uv_hrtime() - hrtime;
}
uv_mutex_unlock(&delay_mutex);
}
/// Portable version of POSIX localtime_r()
///
/// @return NULL in case of error
@@ -112,3 +96,23 @@ struct tm *os_get_localtime(struct tm *result) FUNC_ATTR_NONNULL_ALL
time_t rawtime = time(NULL);
return os_localtime_r(&rawtime, result);
}
static void microdelay(uint64_t microseconds)
{
uint64_t elapsed = 0;
uint64_t ns = microseconds * 1000; // convert to nanoseconds
uint64_t base = uv_hrtime();
uv_mutex_lock(&delay_mutex);
while (elapsed < ns) {
if (uv_cond_timedwait(&delay_cond, &delay_mutex, ns - elapsed)
== UV_ETIMEDOUT)
break;
uint64_t now = uv_hrtime();
elapsed += now - base;
base = now;
}
uv_mutex_unlock(&delay_mutex);
}