From cf14717d435b38c0b8270a89de404b4447297f64 Mon Sep 17 00:00:00 2001 From: Jan Pochyla Date: Wed, 8 Nov 2017 18:07:33 +0100 Subject: [PATCH] unix: add shutdown() As sys/socket.h defines shutdown also, we can't include common.h in unix mocks. --- embed/extmod/modtrezorio/unix-msg-mock.h | 5 ++++- embed/unix/common.c | 5 +++++ embed/unix/common.h | 2 ++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/embed/extmod/modtrezorio/unix-msg-mock.h b/embed/extmod/modtrezorio/unix-msg-mock.h index 31adc5b6..5bf7a38f 100644 --- a/embed/extmod/modtrezorio/unix-msg-mock.h +++ b/embed/extmod/modtrezorio/unix-msg-mock.h @@ -13,10 +13,13 @@ #include #include -#include "../../unix/common.h" #include "../../trezorhal/usb.h" #include "../../trezorhal/touch.h" +void __attribute__((noreturn)) __fatal_error(const char *expr, const char *msg, const char *file, int line, const char *func); + +#define ensure(expr, msg) (((expr) == sectrue) ? (void)0 : __fatal_error(#expr, msg, __FILE__, __LINE__, __func__)) + #define TREZOR_UDP_IFACE 0 #define TREZOR_UDP_PORT 21324 diff --git a/embed/unix/common.c b/embed/unix/common.c index d4085810..1d848b2d 100644 --- a/embed/unix/common.c +++ b/embed/unix/common.c @@ -31,3 +31,8 @@ void hal_delay(uint32_t ms) { usleep(1000 * ms); } + +void shutdown(void) +{ + exit(1); +} diff --git a/embed/unix/common.h b/embed/unix/common.h index fde45ec8..d1daf8a1 100644 --- a/embed/unix/common.h +++ b/embed/unix/common.h @@ -9,4 +9,6 @@ void __attribute__((noreturn)) __fatal_error(const char *expr, const char *msg, void hal_delay(uint32_t ms); +void shutdown(void); + #endif