Skip to content

Commit

Permalink
Fix compiler errors/warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
trolando committed Jun 24, 2024
1 parent 86cb658 commit eec8254
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 24 deletions.
11 changes: 1 addition & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ macro(set_target_props NAME)
target_compile_features(${NAME} PUBLIC c_std_17 cxx_std_17)
target_compile_options(${NAME} PRIVATE -Wall -Wextra)
target_include_directories(${NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src ${Boost_INCLUDE_DIRS})
target_link_libraries(${NAME} oink::oink pthread)
target_link_libraries(${NAME} oink::oink)
endmacro(set_target_props)

add_executable(solve)
Expand Down Expand Up @@ -149,42 +149,33 @@ if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)

add_executable(counter_rr src/tools/counter_rr.cpp)
set_target_props(counter_rr)
target_link_libraries(counter_rr oink)

add_executable(counter_dp src/tools/counter_dp.cpp)
set_target_props(counter_dp)
target_link_libraries(counter_dp oink)

add_executable(counter_m src/tools/counter_m.cpp)
set_target_props(counter_m)
target_link_libraries(counter_m oink)

add_executable(counter_core src/tools/counter_core.cpp)
set_target_props(counter_core)
target_link_libraries(counter_core oink)

add_executable(counter_rob src/tools/counter_rob.cpp)
set_target_props(counter_rob)
target_link_libraries(counter_rob oink)

add_executable(counter_symsi src/tools/counter_symsi.cpp)
set_target_props(counter_symsi)
target_link_libraries(counter_symsi oink)

add_executable(counter_ortl src/tools/counter_ortl.cpp)
set_target_props(counter_ortl)
target_link_libraries(counter_ortl oink)

add_executable(counter_qpt src/tools/counter_qpt.cpp)
set_target_props(counter_qpt)

add_executable(tc src/tools/tc.cpp)
set_target_props(tc)
target_link_libraries(tc oink)

add_executable(tc+ src/tools/tc+.cpp)
set_target_props(tc+)
target_link_libraries(tc+ oink)
endif()

if(OINK_BUILD_TESTS)
Expand Down
21 changes: 10 additions & 11 deletions src/tools/solve.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,14 +170,16 @@ setsighandlers(void)

/*------------------------------------------------------------------------*/

static char*
to_h(double size, char *buf)
{
std::string to_h(double size) {
const char* units[] = {"B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"};
int i = 0;
for (;size>1024;size/=1024) i++;
sprintf(buf, "%.*f %s", i, size, units[i]);
return buf;
while (size > 1024 && i < 8) {
size /= 1024;
i++;
}
std::ostringstream oss;
oss << std::fixed << std::setprecision(i) << size << " " << units[i];
return oss.str();
}

/*------------------------------------------------------------------------*/
Expand Down Expand Up @@ -377,11 +379,8 @@ int main(int argc, char **argv)
}
}

char buf[32];
to_h(getCurrentRSS(), buf);
out << "current memory usage: " << buf << std::endl;
to_h(getPeakRSS(), buf);
out << "peak memory usage: " << buf << std::endl;
out << "current memory usage: " << to_h(getCurrentRSS()) << std::endl;
out << "peak memory usage: " << to_h(getPeakRSS()) << std::endl;

/**
* STEP 8
Expand Down
4 changes: 1 addition & 3 deletions test/test_solvers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ main(int argc, char **argv)
int final_res = 0;
std::stringstream log;
double time;
long total=0, good=0;
long total=0;

double times[solvers.count()];
for (unsigned i=0; i<solvers.count(); i++) times[i] = 0.0;
Expand Down Expand Up @@ -286,7 +286,6 @@ main(int argc, char **argv)
int res = test_solver(game, id, time, opt_trace == -1 ? log : std::cout);
if (res == 0) {
sgood[id]++;
good++;
std::cout << "\033[38;5;82m" << solvers.label(id) << "\033[m";
} else {
final_res = res;
Expand Down Expand Up @@ -341,7 +340,6 @@ main(int argc, char **argv)
int res = test_solver(g, id, time, opt_trace == -1 ? log : std::cout);
if (res == 0) {
sgood[id]++;
good++;
std::cout << "\033[38;5;82m" << solvers.label(id) << "\033[m";
} else {
final_res = res;
Expand Down

0 comments on commit eec8254

Please sign in to comment.