9 #include <afb/afb-binding.h>
13 #define ATTR_FORMAT(stringindex, firsttocheck) \
14 __attribute__((format(printf, stringindex, firsttocheck)))
15 #define ATTR_NORETURN __attribute__((noreturn))
17 #define ATTR_FORMAT(stringindex, firsttocheck)
21 #define lognotice(...) AFB_NOTICE(__VA_ARGS__)
22 #define logerror(...) AFB_ERROR(__VA_ARGS__)
25 AFB_ERROR(__VA_ARGS__); \
30 #define logdebug(...) AFB_DEBUG(__VA_ARGS__)
36 // ___| |_ _ __ _ _ ___| |_ _ _ _ __ (_) __ _ _ _ ___ / _| __| |
37 // / __| __| '__| | | |/ __| __| | | | | '_ \| |/ _` | | | |/ _ \ | |_ / _` |
38 // \__ \ |_| | | |_| | (__| |_ | |_| | | | | | (_| | |_| | __/ | _| (_| |
39 // |___/\__|_| \__,_|\___|\__| \__,_|_| |_|_|\__, |\__,_|\___|___|_| \__,_|
43 unique_fd() = default;
44 explicit unique_fd(int f) : fd{f} {}
45 operator int() const { return fd; }
47 unique_fd(unique_fd const &) = delete;
48 unique_fd &operator=(unique_fd const &) = delete;
49 unique_fd(unique_fd &&o) : fd(o.fd) { o.fd = -1; }
50 unique_fd &operator=(unique_fd &&o) {
51 std::swap(this->fd, o.fd);
57 // ___| |_ _ __ _ _ ___| |_ | _ \ ___ | | | ___ _ __
58 // / __| __| '__| | | |/ __| __| | |_) / _ \| | |/ _ \ '__|
59 // \__ \ |_| | | |_| | (__| |_ | __/ (_) | | | __/ |
60 // |___/\__|_| \__,_|\___|\__| |_| \___/|_|_|\___|_|
63 std::vector<std::function<int(int)>> handlers;
64 std::vector<struct pollfd> pfds;
67 void add_fd(int fd, std::function<int(int)> handler);
71 #endif // !WM_UTIL_HPP