10 #include <afb/afb-binding.h>
14 #define ATTR_FORMAT(stringindex, firsttocheck) \
15 __attribute__((format(printf, stringindex, firsttocheck)))
16 #define ATTR_NORETURN __attribute__((noreturn))
18 #define ATTR_FORMAT(stringindex, firsttocheck)
22 #define lognotice(...) AFB_NOTICE(__VA_ARGS__)
23 #define logerror(...) AFB_ERROR(__VA_ARGS__)
26 AFB_ERROR(__VA_ARGS__); \
31 #define logdebug(...) AFB_DEBUG(__VA_ARGS__)
37 // ___| |_ _ __ _ _ ___| |_ _ _ _ __ (_) __ _ _ _ ___ / _| __| |
38 // / __| __| '__| | | |/ __| __| | | | | '_ \| |/ _` | | | |/ _ \ | |_ / _` |
39 // \__ \ |_| | | |_| | (__| |_ | |_| | | | | | (_| | |_| | __/ | _| (_| |
40 // |___/\__|_| \__,_|\___|\__| \__,_|_| |_|_|\__, |\__,_|\___|___|_| \__,_|
44 unique_fd() = default;
45 explicit unique_fd(int f) : fd{f} {}
46 operator int() const { return fd; }
48 unique_fd(unique_fd const &) = delete;
49 unique_fd &operator=(unique_fd const &) = delete;
50 unique_fd(unique_fd &&o) : fd(o.fd) { o.fd = -1; }
51 unique_fd &operator=(unique_fd &&o) {
52 std::swap(this->fd, o.fd);
58 // ___| |_ _ __ _ _ ___| |_ | _ \ ___ | | | ___ _ __
59 // / __| __| '__| | | |/ __| __| | |_) / _ \| | |/ _ \ '__|
60 // \__ \ |_| | | |_| | (__| |_ | __/ (_) | | | __/ |
61 // |___/\__|_| \__,_|\___|\__| |_| \___/|_|_|\___|_|
64 std::vector<std::function<int(int)>> handlers;
65 std::vector<struct pollfd> pfds;
68 void add_fd(int fd, std::function<int(int)> handler);
72 #endif // !WM_UTIL_HPP