9 #define ATTR_FORMAT(stringindex, firsttocheck) \
10 __attribute__((format(printf, stringindex, firsttocheck)))
11 #define ATTR_NORETURN __attribute__((noreturn))
13 #define ATTR_FORMAT(stringindex, firsttocheck)
17 void lognotice(char const *fmt, ...) noexcept ATTR_FORMAT(1, 2);
18 void logerror(char const *fmt, ...) noexcept ATTR_FORMAT(1, 2);
19 void fatal(char const *fmt, ...) noexcept ATTR_FORMAT(1, 2) ATTR_NORETURN;
22 void logdebug(char const *fmt, ...) noexcept ATTR_FORMAT(1, 2);
24 static inline void logdebug(char const *fmt, ...) noexcept ATTR_FORMAT(1, 2);
25 static inline void logdebug(char const *fmt, ...) noexcept {}
29 // ___| |_ _ __ _ _ ___| |_ _ _ _ __ (_) __ _ _ _ ___ / _| __| |
30 // / __| __| '__| | | |/ __| __| | | | | '_ \| |/ _` | | | |/ _ \ | |_ / _` |
31 // \__ \ |_| | | |_| | (__| |_ | |_| | | | | | (_| | |_| | __/ | _| (_| |
32 // |___/\__|_| \__,_|\___|\__| \__,_|_| |_|_|\__, |\__,_|\___|___|_| \__,_|
36 unique_fd() = default;
37 explicit unique_fd(int f) : fd{f} {}
38 operator int() const { return fd; }
40 unique_fd(unique_fd const &) = delete;
41 unique_fd &operator=(unique_fd const &) = delete;
42 unique_fd(unique_fd &&o) : fd(o.fd) { o.fd = -1; }
43 unique_fd &operator=(unique_fd &&o) {
44 std::swap(this->fd, o.fd);
50 // ___| |_ _ __ _ _ ___| |_ | _ \ ___ | | | ___ _ __
51 // / __| __| '__| | | |/ __| __| | |_) / _ \| | |/ _ \ '__|
52 // \__ \ |_| | | |_| | (__| |_ | __/ (_) | | | __/ |
53 // |___/\__|_| \__,_|\___|\__| |_| \___/|_|_|\___|_|
56 std::vector<std::function<int(int)>> handlers;
57 std::vector<struct pollfd> pfds;
60 void add_fd(int fd, std::function<int(int)> handler);
64 #endif // !WM_UTIL_HPP