refactor(common): Cleanup
This commit is contained in:
parent
c2bee14d34
commit
5b33ada576
@ -1,6 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
|
#include <cstdlib>
|
||||||
|
|
||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
#include <ifaddrs.h>
|
#include <ifaddrs.h>
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <functional>
|
||||||
|
|
||||||
#define POLYBAR_NS \
|
#define POLYBAR_NS \
|
||||||
namespace polybar { \
|
namespace polybar { \
|
||||||
@ -19,22 +20,12 @@
|
|||||||
#define PIPE_WRITE 1
|
#define PIPE_WRITE 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef STDOUT_FILENO
|
|
||||||
#define STDOUT_FILENO 1
|
|
||||||
#endif
|
|
||||||
#ifndef STDERR_FILENO
|
|
||||||
#define STDERR_FILENO 2
|
|
||||||
#endif
|
|
||||||
|
|
||||||
POLYBAR_NS
|
POLYBAR_NS
|
||||||
|
|
||||||
namespace placeholders = std::placeholders;
|
|
||||||
|
|
||||||
using std::string;
|
using std::string;
|
||||||
using std::stringstream;
|
using std::stringstream;
|
||||||
using std::size_t;
|
using std::size_t;
|
||||||
using std::move;
|
using std::move;
|
||||||
using std::bind;
|
|
||||||
using std::forward;
|
using std::forward;
|
||||||
using std::pair;
|
using std::pair;
|
||||||
using std::function;
|
using std::function;
|
||||||
|
@ -7,6 +7,13 @@
|
|||||||
|
|
||||||
#include "common.hpp"
|
#include "common.hpp"
|
||||||
|
|
||||||
|
#ifndef STDOUT_FILENO
|
||||||
|
#define STDOUT_FILENO 1
|
||||||
|
#endif
|
||||||
|
#ifndef STDERR_FILENO
|
||||||
|
#define STDERR_FILENO 2
|
||||||
|
#endif
|
||||||
|
|
||||||
POLYBAR_NS
|
POLYBAR_NS
|
||||||
|
|
||||||
enum class loglevel : uint8_t {
|
enum class loglevel : uint8_t {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <cstring>
|
#include <cstdlib>
|
||||||
|
|
||||||
#include "common.hpp"
|
#include "common.hpp"
|
||||||
|
|
||||||
@ -13,8 +13,8 @@ namespace memory_util {
|
|||||||
/**
|
/**
|
||||||
* Create a shared pointer using malloc/free
|
* Create a shared pointer using malloc/free
|
||||||
*/
|
*/
|
||||||
template <typename T, size_t Size = sizeof(T), typename Deleter = decltype(free)>
|
template <typename T, size_t Size = sizeof(T), typename Deleter = decltype(std::free)>
|
||||||
inline malloc_ptr_t<T> make_malloc_ptr(Deleter deleter = free) {
|
inline malloc_ptr_t<T> make_malloc_ptr(Deleter deleter = std::free) {
|
||||||
return malloc_ptr_t<T>(static_cast<T*>(calloc(1, Size)), deleter);
|
return malloc_ptr_t<T>(static_cast<T*>(calloc(1, Size)), deleter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <csignal>
|
#include <csignal>
|
||||||
|
#include <cstdlib>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
#include "errors.hpp"
|
#include "errors.hpp"
|
||||||
@ -8,6 +9,13 @@
|
|||||||
#include "utils/io.hpp"
|
#include "utils/io.hpp"
|
||||||
#include "utils/process.hpp"
|
#include "utils/process.hpp"
|
||||||
|
|
||||||
|
#ifndef STDOUT_FILENO
|
||||||
|
#define STDOUT_FILENO 1
|
||||||
|
#endif
|
||||||
|
#ifndef STDERR_FILENO
|
||||||
|
#define STDERR_FILENO 2
|
||||||
|
#endif
|
||||||
|
|
||||||
POLYBAR_NS
|
POLYBAR_NS
|
||||||
|
|
||||||
command::command(const logger& logger, string cmd) : m_log(logger), m_cmd(move(cmd)) {
|
command::command(const logger& logger, string cmd) : m_log(logger), m_cmd(move(cmd)) {
|
||||||
|
@ -67,8 +67,8 @@ int main() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
"round_to_nearest_5"_test = [] {
|
"round_to_nearest_5"_test = [] {
|
||||||
expect(math_util::nearest_5(52) == 55);
|
expect(math_util::nearest_5(52) == 50);
|
||||||
expect(math_util::nearest_5(9.1) == 5);
|
expect(math_util::nearest_5(9.1) == 10);
|
||||||
expect(math_util::nearest_5(95.0) == 95);
|
expect(math_util::nearest_5(95.0) == 95);
|
||||||
expect(math_util::nearest_5(94.9) == 95);
|
expect(math_util::nearest_5(94.9) == 95);
|
||||||
expect(math_util::nearest_5(1) == 0);
|
expect(math_util::nearest_5(1) == 0);
|
||||||
|
Loading…
Reference in New Issue
Block a user