Rename con_puts length template

This commit is contained in:
Kp 2013-12-19 22:52:03 +00:00
parent 7ea8507470
commit 84a0dcba27
2 changed files with 5 additions and 6 deletions

View file

@ -37,17 +37,14 @@ typedef struct console_buffer
void con_init(void); void con_init(void);
void con_puts(int level, const char *str, size_t len) __attribute_nonnull(); void con_puts(int level, const char *str, size_t len) __attribute_nonnull();
static inline void con_puts(int level, const char *str)
{
con_puts(level, str, strlen(str));
}
template <size_t len> template <size_t len>
static inline void con_puts(int level, const char (&str)[len]) static inline void con_puts_literal(int level, const char (&str)[len])
{ {
con_puts(level, str, len - 1); con_puts(level, str, len - 1);
} }
#define con_puts(A1,S,...) (con_puts(A1,S, _dxx_call_puts_parameter2(1, ## __VA_ARGS__, strlen(S))))
void con_printf(int level, const char *fmt, ...) __attribute_format_printf(2, 3); void con_printf(int level, const char *fmt, ...) __attribute_format_printf(2, 3);
#define con_printf(A1,F,...) dxx_call_printf_checked(con_printf,con_puts,(A1),(F),##__VA_ARGS__) #define con_printf(A1,F,...) dxx_call_printf_checked(con_printf,con_puts_literal,(A1),(F),##__VA_ARGS__)
void con_showup(void); void con_showup(void);
#endif #endif

View file

@ -12,6 +12,8 @@
#define _dxx_printf_raise_error(N,S) (0) #define _dxx_printf_raise_error(N,S) (0)
#endif #endif
#define _dxx_call_puts_parameter2(A,B,...) B
#define _dxx_call_printf_unwrap_args(...) , ## __VA_ARGS__ #define _dxx_call_printf_unwrap_args(...) , ## __VA_ARGS__
#define _dxx_call_printf_delete_comma2(A,...) __VA_ARGS__ #define _dxx_call_printf_delete_comma2(A,...) __VA_ARGS__
#define _dxx_call_printf_delete_comma(A,...) _dxx_call_printf_delete_comma2( A , ## __VA_ARGS__ ) #define _dxx_call_printf_delete_comma(A,...) _dxx_call_printf_delete_comma2( A , ## __VA_ARGS__ )