1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/node/ synced 2025-03-09 00:00:00 +01:00

smaller fixups

This commit is contained in:
Steffen Vogel 2018-10-19 16:32:44 +02:00
parent b43c494c3f
commit 9fd43318c4
7 changed files with 92 additions and 15 deletions

View file

@ -26,10 +26,6 @@
#pragma once
#ifndef V
#define V 2
#endif
#define PROJECT_VERSION_STR "@CMAKE_PROJECT_VERSION_STR@"
#define PROJECT_VERSION "@CMAKE_PROJECT_VERSION@"
#define PROJECT_MAJOR_VERSION @CMAKE_PROJECT_MAJOR_VERSION@
@ -52,6 +48,7 @@
#cmakedefine LIBCONFIG_FOUND
/* Paths */
#define PREFIX "@CMAKE_INSTALL_PREFIX@"
#define PLUGIN_PATH "@CMAKE_INSTALL_PREFIX@/share/villas/node/plugins"
#define WEB_PATH "@CMAKE_INSTALL_PREFIX@/share/villas/node/web"
#define SYSFS_PATH "/sys"

View file

@ -191,10 +191,7 @@ public:
}
};
#endif
} // namespace villas
} // namespace utils
#include <fmt/format.h>
#endif

View file

@ -74,9 +74,11 @@ public:
template<typename... Args>
JsonError(const json_error_t &err, const std::string &what, Args&&... args) :
std::runtime_error(fmt::format(what, std::forward<Args>(args)...))
{ }
{
(void) err;
}
virtual const char * what()
virtual const char * what() const noexcept
{
return fmt::format("{}: {} in {}:{}:{}",
std::runtime_error::what(),
@ -100,14 +102,14 @@ public:
setting(s)
{ }
std::string docUri()
std::string docUri() const
{
std::string baseUri = "https://villas.fein-aachen.org/doc/jump?";
return baseUri + id;
}
virtual const char * what()
virtual const char * what() const noexcept
{
std::stringstream ss;

View file

@ -30,7 +30,8 @@ add_library(villas-common SHARED
hash_table.c
hist.c
kernel/kernel.c
kernel/rt.c
kernel/kernel.cpp
kernel/rt.cpp
list.c
log.cpp
log_legacy.cpp
@ -44,6 +45,7 @@ add_library(villas-common SHARED
utils.c
utils.cpp
cpuset.cpp
terminal.cpp
version.cpp
)

View file

@ -34,7 +34,9 @@
#include <villas/kernel/kernel.hpp>
#include <villas/kernel/rt.hpp>
using villas::utils::CpuSet;
#ifdef __linux__
using villas::utils::CpuSet;
#endif /* __linux__ */
namespace villas {
namespace kernel {
@ -67,6 +69,8 @@ int init(int priority, int affinity)
lockMemory();
#else
logger->warn("This platform is not optimized for real-time execution");
(void) affinity;
(void) priority;
#endif
return 0;

View file

@ -233,7 +233,7 @@ MemoryTranslation::operator+=(const MemoryTranslation& other)
this->dst = other.dst;
// the source stays the same and can only increase with merged translations
this->src = this->src;
//this->src = this->src;
if(otherSrcIsSmaller) {
// other mapping starts at lower addresses, so we actually arrive at

75
common/lib/terminal.cpp Normal file
View file

@ -0,0 +1,75 @@
/** Terminal handling.
*
* @author Steffen Vogel <stvogel@eonerc.rwth-aachen.de>
* @copyright 2018, Institute for Automation of Complex Power Systems, EONERC
* @license GNU General Public License (version 3)
*
* VILLAScommon
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*********************************************************************************/
#include <unistd.h>
#include <villas/terminal.hpp>
#include <villas/exceptions.hpp>
#include <villas/log.hpp>
using namespace villas;
struct winsize Terminal::window;
Terminal::Terminal()
{
int ret;
isTty = isatty(fileno(stdin));
if (isTty) {
struct sigaction sa_resize;
sa_resize.sa_flags = SA_SIGINFO;
sa_resize.sa_sigaction = resize;
sigemptyset(&sa_resize.sa_mask);
ret = sigaction(SIGWINCH, &sa_resize, NULL);
if (ret)
throw new SystemError("Failed to register signal handler");
/* Try to get initial terminal dimensions */
ret = ioctl(STDERR_FILENO, TIOCGWINSZ, &window);
if (ret)
throw new SystemError("Failed to get terminal dimensions");
}
/* Fallback if for some reason we can not determine a prober window size */
if (window.ws_col == 0)
window.ws_col = 150;
if (window.ws_row == 0)
window.ws_row = 50;
}
void Terminal::resize(int, siginfo_t *, void *)
{
int ret;
ret = ioctl(STDERR_FILENO, TIOCGWINSZ, &window);
if (ret)
throw new SystemError("Failed to get terminal dimensions");
auto logger = logging.get("terminal");
logger->debug("New terminal size: {}x{}", window.ws_row, window.ws_col);
};