aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorClifford Wolf <clifford@clifford.at>2014-11-09 10:44:23 +0100
committerClifford Wolf <clifford@clifford.at>2014-11-09 10:44:23 +0100
commitfe829bdbdc436f425e082ab1cc8c3d276f168945 (patch)
tree5d73123ffc07ec247e095c76f65bd4800f567d1b /kernel
parentcb9e10b4624e6ba6fff215766790e3ff3b82e9a8 (diff)
downloadyosys-fe829bdbdc436f425e082ab1cc8c3d276f168945.tar.gz
yosys-fe829bdbdc436f425e082ab1cc8c3d276f168945.tar.bz2
yosys-fe829bdbdc436f425e082ab1cc8c3d276f168945.zip
Added log_warning() API
Diffstat (limited to 'kernel')
-rw-r--r--kernel/cost.h2
-rw-r--r--kernel/log.cc25
-rw-r--r--kernel/log.h4
-rw-r--r--kernel/rtlil.cc6
4 files changed, 30 insertions, 7 deletions
diff --git a/kernel/cost.h b/kernel/cost.h
index 5e99df993..61a693b9c 100644
--- a/kernel/cost.h
+++ b/kernel/cost.h
@@ -70,7 +70,7 @@ int get_cell_cost(RTLIL::IdString type, const std::map<RTLIL::IdString, RTLIL::C
return module_cost;
}
- log("Warning: Can't determine cost of %s cell (%d parameters).\n", log_id(type), GetSize(parameters));
+ log_warning("Can't determine cost of %s cell (%d parameters).\n", log_id(type), GetSize(parameters));
return 1;
}
diff --git a/kernel/log.cc b/kernel/log.cc
index 9f5f03b2f..9f9c4db9f 100644
--- a/kernel/log.cc
+++ b/kernel/log.cc
@@ -152,6 +152,19 @@ void logv_header(const char *format, va_list ap)
log_files.pop_back();
}
+void logv_warning(const char *format, va_list ap)
+{
+ if (log_errfile != NULL)
+ log_files.push_back(log_errfile);
+
+ log("Warning: ");
+ logv(format, ap);
+ log_flush();
+
+ if (log_errfile != NULL)
+ log_files.pop_back();
+}
+
void logv_error(const char *format, va_list ap)
{
if (log_errfile != NULL)
@@ -179,6 +192,14 @@ void log_header(const char *format, ...)
va_end(ap);
}
+void log_warning(const char *format, ...)
+{
+ va_list ap;
+ va_start(ap, format);
+ logv_warning(format, ap);
+ va_end(ap);
+}
+
void log_error(const char *format, ...)
{
va_list ap;
@@ -304,14 +325,14 @@ std::map<std::string, std::pair<std::string, int>> get_coverage_data()
for (auto &it : extra_coverage_data) {
if (coverage_data.count(it.first))
- log("WARNING: found duplicate coverage id \"%s\".\n", it.first.c_str());
+ log_warning("found duplicate coverage id \"%s\".\n", it.first.c_str());
coverage_data[it.first].first = it.second.first;
coverage_data[it.first].second += it.second.second;
}
for (CoverData *p = __start_yosys_cover_list; p != __stop_yosys_cover_list; p++) {
if (coverage_data.count(p->id))
- log("WARNING: found duplicate coverage id \"%s\".\n", p->id);
+ log_warning("found duplicate coverage id \"%s\".\n", p->id);
coverage_data[p->id].first = stringf("%s:%d:%s", p->file, p->line, p->func);
coverage_data[p->id].second += p->counter;
}
diff --git a/kernel/log.h b/kernel/log.h
index 93e8144a0..b003aba22 100644
--- a/kernel/log.h
+++ b/kernel/log.h
@@ -51,10 +51,12 @@ extern int log_verbose_level;
void logv(const char *format, va_list ap);
void logv_header(const char *format, va_list ap);
+void logv_warning(const char *format, va_list ap);
+_NORETURN_ void logv_error(const char *format, va_list ap) __attribute__((noreturn));
-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_warning(const char *format, ...) __attribute__((format(printf, 1, 2)));
_NORETURN_ void log_error(const char *format, ...) __attribute__((format(printf, 1, 2))) __attribute__((noreturn));
_NORETURN_ void log_cmd_error(const char *format, ...) __attribute__((format(printf, 1, 2))) __attribute__((noreturn));
diff --git a/kernel/rtlil.cc b/kernel/rtlil.cc
index 8cfc0c5f9..803d783af 100644
--- a/kernel/rtlil.cc
+++ b/kernel/rtlil.cc
@@ -440,7 +440,7 @@ std::vector<RTLIL::Module*> RTLIL::Design::selected_whole_modules_warn() const
if (selected_whole_module(it.first))
result.push_back(it.second);
else if (selected_module(it.first))
- log("Warning: Ignoring partially selected module %s.\n", log_id(it.first));
+ log_warning("Ignoring partially selected module %s.\n", log_id(it.first));
return result;
}
@@ -1062,14 +1062,14 @@ bool RTLIL::Module::has_processes() const
bool RTLIL::Module::has_memories_warn() const
{
if (!memories.empty())
- log("Warning: Ignoring module %s because it contains memories (run 'memory' command first).\n", log_id(this));
+ log_warning("Ignoring module %s because it contains memories (run 'memory' command first).\n", log_id(this));
return !memories.empty();
}
bool RTLIL::Module::has_processes_warn() const
{
if (!processes.empty())
- log("Warning: Ignoring module %s because it contains processes (run 'proc' command first).\n", log_id(this));
+ log_warning("Ignoring module %s because it contains processes (run 'proc' command first).\n", log_id(this));
return !processes.empty();
}