From: William Speirs Date: Tue, 14 Oct 2014 21:07:30 +0000 (-0400) Subject: Fixed log so it will compile under Visual Studio X-Git-Tag: yosys-0.4~52^2~9 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=0352dbfd65072f42824852b2f5b925e7d9865a90;p=yosys.git Fixed log so it will compile under Visual Studio - Included an implementation of gettimeofday --- diff --git a/kernel/log.cc b/kernel/log.cc index 87a75410d..4585e7eff 100644 --- a/kernel/log.cc +++ b/kernel/log.cc @@ -21,7 +21,10 @@ #include "libs/sha1/sha1.h" #include "backends/ilang/ilang_backend.h" -#include +#ifndef _WIN32 + #include +#endif + #include #include #include @@ -48,6 +51,26 @@ static struct timeval initial_tv = { 0, 0 }; static bool next_print_log = false; static int log_newline_count = 0; +#ifdef _WIN32 +// this will get time information and return it in timeval, simulating gettimeofday() +int gettimeofday(struct timeval *tv, struct timezone *tz) +{ + LARGE_INTEGER counter; + LARGE_INTEGER freq; + + QueryPerformanceFrequency(&freq); + QueryPerformanceCounter(&counter); + + counter.QuadPart *= 1000000; + counter.QuadPart /= freq.QuadPart; + + tv->tv_sec = counter.QuadPart / 1000000; + tv->tv_usec = counter.QuadPart % 1000000; + + return 0; +} +#endif + void logv(const char *format, va_list ap) { while (format[0] == '\n' && format[1] != 0) { diff --git a/kernel/log.h b/kernel/log.h index b4182b5f3..d4b21110c 100644 --- a/kernel/log.h +++ b/kernel/log.h @@ -23,10 +23,10 @@ #define LOG_H #include -#include #ifndef _WIN32 -# include + #include + #include #endif // from libs/sha1/sha1.h @@ -51,12 +51,20 @@ extern int log_verbose_level; void logv(const char *format, va_list ap); void logv_header(const char *format, va_list ap); -void logv_error(const char *format, va_list ap) __attribute__ ((noreturn)); -void log(const char *format, ...) __attribute__ ((format (printf, 1, 2))); -void log_header(const char *format, ...) __attribute__ ((format (printf, 1, 2))); -void log_error(const char *format, ...) __attribute__ ((format (printf, 1, 2))) __attribute__ ((noreturn)); -void log_cmd_error(const char *format, ...) __attribute__ ((format (printf, 1, 2))) __attribute__ ((noreturn)); +#if !defined(__GNUC__) && !defined(__clang__) + void logv_error(const char *format, va_list ap); + void log(const char *format, ...); + void log_header(const char *format, ...); + void log_error(const char *format, ...); + void log_cmd_error(const char *format, ...); +#else + void logv_error(const char *format, va_list ap) __attribute__((noreturn)); + void log(const char *format, ...) __attribute__((format(printf, 1, 2))); + void log_header(const char *format, ...) __attribute__((format(printf, 1, 2))); + void log_error(const char *format, ...) __attribute__((format(printf, 1, 2))) __attribute__((noreturn)); + void log_cmd_error(const char *format, ...) __attribute__((format(printf, 1, 2))) __attribute__((noreturn)); +#endif void log_spacer(); void log_push();