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__)
39 std::ostringstream o; \
40 o << __FILE__ << ":" << __LINE__ << ":" << __func__ << ": " << expr; \
41 logdebug("%s", o.str().c_str()); \
49 // ___| |_ _ __ _ _ ___| |_ _ _ _ __ (_) __ _ _ _ ___ / _| __| |
50 // / __| __| '__| | | |/ __| __| | | | | '_ \| |/ _` | | | |/ _ \ | |_ / _` |
51 // \__ \ |_| | | |_| | (__| |_ | |_| | | | | | (_| | |_| | __/ | _| (_| |
52 // |___/\__|_| \__,_|\___|\__| \__,_|_| |_|_|\__, |\__,_|\___|___|_| \__,_|
56 unique_fd() = default;
57 explicit unique_fd(int f) : fd{f} {}
58 operator int() const { return fd; }
60 unique_fd(unique_fd const &) = delete;
61 unique_fd &operator=(unique_fd const &) = delete;
62 unique_fd(unique_fd &&o) : fd(o.fd) { o.fd = -1; }
63 unique_fd &operator=(unique_fd &&o) {
64 std::swap(this->fd, o.fd);
70 // ___| |_ _ __ _ _ ___| |_ | _ \ ___ | | | ___ _ __
71 // / __| __| '__| | | |/ __| __| | |_) / _ \| | |/ _ \ '__|
72 // \__ \ |_| | | |_| | (__| |_ | __/ (_) | | | __/ |
73 // |___/\__|_| \__,_|\___|\__| |_| \___/|_|_|\___|_|
76 std::vector<std::function<int(int)>> handlers;
77 std::vector<struct pollfd> pfds;
80 void add_fd(int fd, std::function<int(int)> handler);
84 #endif // !WM_UTIL_HPP