#include #include #include #include #include #include #include #include #include #include #include #include #include #include #define ZN_ASSERT(expr) \ do { \ zn_status_t status = expr; \ if (status != ZN_OK) { \ zn_printf("initd: " #expr " failed: %s\n", zn_status_to_string(status)); \ return EXIT_FAILURE; \ } \ } while (0) [[__format(printf, 1, 2)]] static void zn_printf(const char* msg, ...) { char buf[1024]; va_list args; va_start(args, msg); int32_t len = vsnprintf(buf, sizeof(buf), msg, args); va_end(args); write(1, buf, len); // zn_log(buf, len); } int main(int argc, char* argv[], char* envp[]) { zn_printf("initd: starting...\n"); zn_handle_t channel = getauxval(0x1000); while (true) { static thread_local zn_handle_t handles[32]; static thread_local char buf[1024]; ZN_ASSERT(zn_channel_read(channel, handles, buf, ARRAY_SIZE(handles), ARRAY_SIZE(buf), nullptr, nullptr)); } }