From 4499864024a5b658bf5772ed87e218bcdaedc262 Mon Sep 17 00:00:00 2001 From: ZipCPU Date: Thu, 7 Jun 2018 15:38:24 -0400 Subject: Applied clang-format to my own contributions --- common/log.cc | 246 +++++++++++++++++++++++++--------------------------- common/log.h | 59 +++++++------ common/place.cc | 89 +++++++++---------- common/place.h | 8 +- common/rulecheck.cc | 108 ++++++++++++----------- 5 files changed, 255 insertions(+), 255 deletions(-) (limited to 'common') diff --git a/common/log.cc b/common/log.cc index 00e1765f..7a411fb2 100644 --- a/common/log.cc +++ b/common/log.cc @@ -17,27 +17,27 @@ * */ -#include -#include -#include -#include -#include #include #include #include +#include +#include +#include +#include +#include -#include "log.h" #include "design.h" +#include "log.h" -std::vector log_files; -std::vector log_streams; -FILE *log_errfile = NULL; +std::vector log_files; +std::vector log_streams; +FILE *log_errfile = NULL; -bool log_error_stderr = false; -bool log_cmd_error_throw = false; -bool log_quiet_warnings = false; -int log_verbose_level; -std::string log_last_error; +bool log_error_stderr = false; +bool log_cmd_error_throw = false; +bool log_quiet_warnings = false; +int log_verbose_level; +std::string log_last_error; void (*log_error_atexit)() = NULL; static bool next_print_log = false; @@ -45,204 +45,192 @@ static int log_newline_count = 0; std::string vstringf(const char *fmt, va_list ap) { - std::string string; - char *str = NULL; + std::string string; + char *str = NULL; #ifdef _WIN32 - int sz = 64+strlen(fmt), rc; - while (1) { - va_list apc; - va_copy(apc, ap); - str = (char*)realloc(str, sz); - rc = vsnprintf(str, sz, fmt, apc); - va_end(apc); - if (rc >= 0 && rc < sz) - break; - sz *= 2; - } + int sz = 64 + strlen(fmt), rc; + while (1) { + va_list apc; + va_copy(apc, ap); + str = (char *)realloc(str, sz); + rc = vsnprintf(str, sz, fmt, apc); + va_end(apc); + if (rc >= 0 && rc < sz) + break; + sz *= 2; + } #else - if (vasprintf(&str, fmt, ap) < 0) - str = NULL; + if (vasprintf(&str, fmt, ap) < 0) + str = NULL; #endif - if (str != NULL) { - string = str; - free(str); - } + if (str != NULL) { + string = str; + free(str); + } - return string; + return string; } void logv(const char *format, va_list ap) { - // - // Trim newlines from the beginning - while (format[0] == '\n' && format[1] != 0) { - log("\n"); - format++; - } + // + // Trim newlines from the beginning + while (format[0] == '\n' && format[1] != 0) { + log("\n"); + format++; + } - std::string str = vstringf(format, ap); + std::string str = vstringf(format, ap); - if (str.empty()) - return; + if (str.empty()) + return; - size_t nnl_pos = str.find_last_not_of('\n'); - if (nnl_pos == std::string::npos) - log_newline_count += str.size(); - else - log_newline_count = str.size() - nnl_pos - 1; + size_t nnl_pos = str.find_last_not_of('\n'); + if (nnl_pos == std::string::npos) + log_newline_count += str.size(); + else + log_newline_count = str.size() - nnl_pos - 1; - for (auto f : log_files) - fputs(str.c_str(), f); + for (auto f : log_files) + fputs(str.c_str(), f); - for (auto f : log_streams) - *f << str; + for (auto f : log_streams) + *f << str; } void logv_info(const char *format, va_list ap) { - std::string message = vstringf(format, ap); + std::string message = vstringf(format, ap); - log("Info: %s", message.c_str()); - log_flush(); + log("Info: %s", message.c_str()); + log_flush(); } void logv_warning(const char *format, va_list ap) { - std::string message = vstringf(format, ap); + std::string message = vstringf(format, ap); - log("Warning: %s", message.c_str()); - log_flush(); + log("Warning: %s", message.c_str()); + log_flush(); } void logv_warning_noprefix(const char *format, va_list ap) { - std::string message = vstringf(format, ap); + std::string message = vstringf(format, ap); - log("%s", message.c_str()); + log("%s", message.c_str()); } void logv_error(const char *format, va_list ap) { #ifdef EMSCRIPTEN - auto backup_log_files = log_files; + auto backup_log_files = log_files; #endif - if (log_errfile != NULL) - log_files.push_back(log_errfile); + if (log_errfile != NULL) + log_files.push_back(log_errfile); - if (log_error_stderr) - for (auto &f : log_files) - if (f == stdout) - f = stderr; + if (log_error_stderr) + for (auto &f : log_files) + if (f == stdout) + f = stderr; - log_last_error = vstringf(format, ap); - log("ERROR: %s", log_last_error.c_str()); - log_flush(); + log_last_error = vstringf(format, ap); + log("ERROR: %s", log_last_error.c_str()); + log_flush(); - if (log_error_atexit) - log_error_atexit(); + if (log_error_atexit) + log_error_atexit(); #ifdef EMSCRIPTEN - log_files = backup_log_files; - throw 0; + log_files = backup_log_files; + throw 0; #elif defined(_MSC_VER) - _exit(EXIT_FAILURE); + _exit(EXIT_FAILURE); #else - _Exit(EXIT_FAILURE); + _Exit(EXIT_FAILURE); #endif } void log(const char *format, ...) { - va_list ap; - va_start(ap, format); - logv(format, ap); - va_end(ap); + va_list ap; + va_start(ap, format); + logv(format, ap); + va_end(ap); } void log_info(const char *format, ...) { - va_list ap; - va_start(ap, format); - logv_info(format, ap); - va_end(ap); + va_list ap; + va_start(ap, format); + logv_info(format, ap); + va_end(ap); } void log_warning(const char *format, ...) { - va_list ap; - va_start(ap, format); - logv_warning(format, ap); - va_end(ap); + va_list ap; + va_start(ap, format); + logv_warning(format, ap); + va_end(ap); } void log_warning_noprefix(const char *format, ...) { - va_list ap; - va_start(ap, format); - logv_warning_noprefix(format, ap); - va_end(ap); + va_list ap; + va_start(ap, format); + logv_warning_noprefix(format, ap); + va_end(ap); } void log_error(const char *format, ...) { - va_list ap; - va_start(ap, format); - logv_error(format, ap); + va_list ap; + va_start(ap, format); + logv_error(format, ap); } void log_cmd_error(const char *format, ...) { - va_list ap; - va_start(ap, format); + va_list ap; + va_start(ap, format); - if (log_cmd_error_throw) { - log_last_error = vstringf(format, ap); - log("ERROR: %s", log_last_error.c_str()); - log_flush(); - throw log_cmd_error_exception(); - } + if (log_cmd_error_throw) { + log_last_error = vstringf(format, ap); + log("ERROR: %s", log_last_error.c_str()); + log_flush(); + throw log_cmd_error_exception(); + } - logv_error(format, ap); + logv_error(format, ap); } void log_spacer() { - if (log_newline_count < 2) log("\n"); - if (log_newline_count < 2) log("\n"); + if (log_newline_count < 2) + log("\n"); + if (log_newline_count < 2) + log("\n"); } -void log_push() -{ -} +void log_push() {} -void log_pop() -{ - log_flush(); -} +void log_pop() { log_flush(); } -void log_reset_stack() -{ - log_flush(); -} +void log_reset_stack() { log_flush(); } void log_flush() { - for (auto f : log_files) - fflush(f); + for (auto f : log_files) + fflush(f); - for (auto f : log_streams) - f->flush(); -} - -void log_cell(CellInfo *cell, std::string indent) -{ -} - -void log_net(NetInfo *net, std::string indent) -{ + for (auto f : log_streams) + f->flush(); } +void log_cell(CellInfo *cell, std::string indent) {} +void log_net(NetInfo *net, std::string indent) {} diff --git a/common/log.h b/common/log.h index 2bf1604a..374772b3 100644 --- a/common/log.h +++ b/common/log.h @@ -21,38 +21,40 @@ #define LOG_H #include -#include -#include -#include #include -#include +#include #include +#include +#include +#include #include "design.h" // from libs/sha1/sha1.h -#define NXP_NORETURN -#define NXP_ATTRIBUTE(...) __attribute__((__VA_ARGS__)) +#define NXP_NORETURN +#define NXP_ATTRIBUTE(...) __attribute__((__VA_ARGS__)) -struct log_cmd_error_exception { }; +struct log_cmd_error_exception +{ +}; -extern std::vector log_files; -extern std::vector log_streams; -extern FILE *log_errfile; +extern std::vector log_files; +extern std::vector log_streams; +extern FILE *log_errfile; -extern bool log_quiet_warnings; -extern int log_verbose_level; -extern std::string log_last_error; -extern void (*log_error_atexit)(); +extern bool log_quiet_warnings; +extern int log_verbose_level; +extern std::string log_last_error; +extern void (*log_error_atexit)(); void logv(const char *format, va_list ap); void logv_warning(const char *format, va_list ap); void logv_warning_noprefix(const char *format, va_list ap); NXP_NORETURN void logv_error(const char *format, va_list ap) - NXP_ATTRIBUTE(noreturn); + NXP_ATTRIBUTE(noreturn); -extern std::ostream clog; +extern std::ostream clog; void log(const char *format, ...); void log_header(const char *format, ...); void log_info(const char *format, ...); @@ -73,24 +75,29 @@ void log_flush(); const char *log_id(RTLIL::IdString id); template static inline const char *log_id(T *obj) { - return log_id(obj->name); + return log_id(obj->name); } */ -void log_cell(CellInfo *cell, std::string indent = ""); -void log_net(NetInfo *net, std::string indent = ""); +void log_cell(CellInfo *cell, std::string indent = ""); +void log_net(NetInfo *net, std::string indent = ""); #ifndef NDEBUG -static inline void log_assert_worker(bool cond, const char *expr, const char *file, int line) { - if (!cond) log_error("Assert `%s' failed in %s:%d.\n", expr, file, line); +static inline void log_assert_worker(bool cond, const char *expr, + const char *file, int line) +{ + if (!cond) + log_error("Assert `%s' failed in %s:%d.\n", expr, file, line); } -# define log_assert(_assert_expr_) YOSYS_NAMESPACE_PREFIX log_assert_worker(_assert_expr_, #_assert_expr_, __FILE__, __LINE__) +#define log_assert(_assert_expr_) \ + YOSYS_NAMESPACE_PREFIX log_assert_worker(_assert_expr_, #_assert_expr_, \ + __FILE__, __LINE__) #else -# define log_assert(_assert_expr_) +#define log_assert(_assert_expr_) #endif -#define log_abort() log_error("Abort in %s:%d.\n", __FILE__, __LINE__) -#define log_ping() log("-- %s:%d %s --\n", __FILE__, __LINE__, __PRETTY_FUNCTION__) - +#define log_abort() log_error("Abort in %s:%d.\n", __FILE__, __LINE__) +#define log_ping() \ + log("-- %s:%d %s --\n", __FILE__, __LINE__, __PRETTY_FUNCTION__) #endif diff --git a/common/place.cc b/common/place.cc index 172001a6..310a75e9 100644 --- a/common/place.cc +++ b/common/place.cc @@ -18,63 +18,64 @@ */ #include +#include +#include #include -#include +#include +#include #include +#include #include -#include #include -#include -#include -#include -#include "log.h" #include "design.h" +#include "log.h" #include "place.h" -void place_design(Design *design) { - std::set types_used; - std::set::iterator not_found, element; - std::set used_bels; +void place_design(Design *design) +{ + std::set types_used; + std::set::iterator not_found, element; + std::set used_bels; - for(auto cell_entry : design->cells) { - CellInfo *cell = cell_entry.second; - BelType bel_type; + for (auto cell_entry : design->cells) { + CellInfo *cell = cell_entry.second; + BelType bel_type; - element = types_used.find(cell->type); - if (element != types_used.end()) { - continue; - } + element = types_used.find(cell->type); + if (element != types_used.end()) { + continue; + } - bel_type = belTypeFromId(cell->type); - if (bel_type == BelType()) { - log_error("No Bel of type \'%s\' defined for " - "this chip\n", cell->type.c_str()); - } - types_used.insert(cell->type); - std::cout << cell->type << std::endl; - } + bel_type = belTypeFromId(cell->type); + if (bel_type == BelType()) { + log_error("No Bel of type \'%s\' defined for " + "this chip\n", + cell->type.c_str()); + } + types_used.insert(cell->type); + std::cout << cell->type << std::endl; + } - for(auto bel_type_name : types_used) { - auto blist = design->chip.getBels(); - BelType bel_type = belTypeFromId(bel_type_name); - auto bi = blist.begin(); + for (auto bel_type_name : types_used) { + auto blist = design->chip.getBels(); + BelType bel_type = belTypeFromId(bel_type_name); + auto bi = blist.begin(); - for(auto cell_entry : design->cells) { - CellInfo *cell = cell_entry.second; + for (auto cell_entry : design->cells) { + CellInfo *cell = cell_entry.second; - // Only place one type of Bel at a time - if (cell->type.compare(bel_type_name)!=0) - continue; + // Only place one type of Bel at a time + if (cell->type.compare(bel_type_name) != 0) + continue; - while((bi != blist.end()) - &&(design->chip.getBelType(*bi) != bel_type)) - bi++; - if (bi == blist.end()) - log_error("Too many \'%s\' used in design\n", - cell->type.c_str()); - cell->bel = *bi++; - } - } + while ((bi != blist.end()) && + (design->chip.getBelType(*bi) != bel_type)) + bi++; + if (bi == blist.end()) + log_error("Too many \'%s\' used in design\n", + cell->type.c_str()); + cell->bel = *bi++; + } + } } - diff --git a/common/place.h b/common/place.h index 483f11f3..8d3b4c42 100644 --- a/common/place.h +++ b/common/place.h @@ -16,11 +16,11 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ -#ifndef PLACE_H -#define PLACE_H +#ifndef PLACE_H +#define PLACE_H #include "design.h" -extern void place_design(Design *design); +extern void place_design(Design *design); -#endif // PLACE_H +#endif // PLACE_H diff --git a/common/rulecheck.cc b/common/rulecheck.cc index 7443c636..ca0fb76c 100644 --- a/common/rulecheck.cc +++ b/common/rulecheck.cc @@ -1,68 +1,72 @@ -#include #include +#include #include "design.h" #include "log.h" -bool check_all_nets_driven(Design *design) { - const bool debug = false; +bool check_all_nets_driven(Design *design) +{ + const bool debug = false; - log_info("Rule checker, Verifying pre-placed design\n"); + log_info("Rule checker, Verifying pre-placed design\n"); - for(auto cell_entry : design->cells) { - CellInfo *cell = cell_entry.second; + for (auto cell_entry : design->cells) { + CellInfo *cell = cell_entry.second; - if (debug) log_info(" Examining cell \'%s\', of type \'%s\'\n", - cell->name.c_str(), - cell->type.c_str()); - for(auto port_entry : cell->ports) { - PortInfo &port = port_entry.second; + if (debug) + log_info(" Examining cell \'%s\', of type \'%s\'\n", + cell->name.c_str(), cell->type.c_str()); + for (auto port_entry : cell->ports) { + PortInfo &port = port_entry.second; - if (debug) log_info(" Checking name of port \'%s\' " - "against \'%s\'\n", - port_entry.first.c_str(), - port.name.c_str()); - assert(port.name.compare(port_entry.first)==0); - assert(port.name.size() > 0); + if (debug) + log_info(" Checking name of port \'%s\' " + "against \'%s\'\n", + port_entry.first.c_str(), port.name.c_str()); + assert(port.name.compare(port_entry.first) == 0); + assert(port.name.size() > 0); - if (port.net == NULL) { - if (debug) log_warning(" Port \'%s\' in cell \'%s\' is unconnected\n", - port.name.c_str(), cell->name.c_str()); - } else { - assert(port.net); - if (debug) log_info(" Checking for a net named \'%s\'\n", - port.net->name.c_str()); - assert(design->nets.count(port.net->name)>0); - } - } - } + if (port.net == NULL) { + if (debug) + log_warning( + " Port \'%s\' in cell \'%s\' is unconnected\n", + port.name.c_str(), cell->name.c_str()); + } else { + assert(port.net); + if (debug) + log_info(" Checking for a net named \'%s\'\n", + port.net->name.c_str()); + assert(design->nets.count(port.net->name) > 0); + } + } + } - for(auto net_entry : design->nets) { - NetInfo *net = net_entry.second; + for (auto net_entry : design->nets) { + NetInfo *net = net_entry.second; - assert(net->name.compare(net_entry.first) == 0); - if ((net->driver.cell != NULL) - &&(net->driver.cell->type.compare("GND") != 0) - &&(net->driver.cell->type.compare("VCC") != 0)) { + assert(net->name.compare(net_entry.first) == 0); + if ((net->driver.cell != NULL) && + (net->driver.cell->type.compare("GND") != 0) && + (net->driver.cell->type.compare("VCC") != 0)) { - if (debug) log_info(" Checking for a driver cell named \'%s\'\n", - net->driver.cell->name.c_str()); - assert(design->cells.count(net->driver.cell->name) >0); - } + if (debug) + log_info(" Checking for a driver cell named \'%s\'\n", + net->driver.cell->name.c_str()); + assert(design->cells.count(net->driver.cell->name) > 0); + } - for(auto user : net->users) { - if ((user.cell != NULL) - &&(user.cell->type.compare("GND") != 0) - &&(user.cell->type.compare("VCC") != 0)) { + for (auto user : net->users) { + if ((user.cell != NULL) && (user.cell->type.compare("GND") != 0) && + (user.cell->type.compare("VCC") != 0)) { - if (debug) log_info(" Checking for a user cell named \'%s\'\n", - user.cell->name.c_str()); - assert(design->cells.count(user.cell->name) >0); - } + if (debug) + log_info(" Checking for a user cell named \'%s\'\n", + user.cell->name.c_str()); + assert(design->cells.count(user.cell->name) > 0); + } + } + } - } - } - - if (debug) log_info(" Verified!\n"); - return true; + if (debug) + log_info(" Verified!\n"); + return true; } - -- cgit v1.2.3