~siborgium/prelockdpp

a3c48ca02c0172e2898a8ed94945756dd91f69fe — Sergey Smirnykh 2 years ago 4f6dbb3
Add .gitignore
2 files changed, 8 insertions(+), 6 deletions(-)

A .gitignore
M main.cpp
A .gitignore => .gitignore +2 -0
@@ 0,0 1,2 @@
build
*.kdev4

M main.cpp => main.cpp +6 -6
@@ 20,17 20,17 @@
#include <signal.h>
#include <unistd.h>

template <typename F> struct finally {
template <typename F> struct defer_impl {
    F f;
    finally(F&& f): f{ f } {}
    ~finally() {
    defer_impl(F&& f): f{ f } {}
    ~defer_impl() {
        f();
    }
};
template <typename F> finally(F&&) -> finally<F>;
template <typename F> defer_impl(F&&) -> defer_impl<F>;

#define CONCAT(x, y) x##y
#define DEFER        finally CONCAT(_defer_, __COUNTER__) = [&]()
#define DEFER        defer_impl CONCAT(_defer_, __COUNTER__) = [&]()

namespace fs = std::filesystem;



@@ 53,6 53,7 @@ auto concat(auto&& ... xs) {

struct errno_exception: public std::runtime_error {
    errno_exception(std::string_view reason, int err):
        // FIXME: possible strerror invalidation
        std::runtime_error{ concat(reason, ": ", std::strerror(err)) }
    {
        // intentionally left blank


@@ 160,7 161,6 @@ struct context {
        }
    }
    auto get_uptime() {
        // FIXME: proper open, avoid streams
        int fd = open("/proc/uptime", O_RDONLY);
        if (fd == -1) {
            throw errno_exception("open(/proc/uptime) failed", errno);