You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
就是比较费栈[
/* LICENSE_PLACEHODLER */
#include <stdarg.h>
#include <stdbool.h>
#include <svcnum.h>
/* Staging buffer in stack for collecting formated string */
#define STAGING_BUFFER_SIZE 16
struct staging_buffer_t {
char buf[STAGING_BUFFER_SIZE];
unsigned int pos;
unsigned int total;
};
/*
Embedded assembler function can't be inline or the mixed code
would be chaos, especially with high optimization level.
*/
attribute ((noinline))
static void flush_stgbuf(struct staging_buffer_t *p_stgbuf)
{
__asm volatile (
"mov r0, %0 \n"
"mov r1, %1 \n"
"svc %2 \n"
::"r" (p_stgbuf->buf),
"r" (p_stgbuf->pos),
"I" (SVC_LOGGING_SAFE));
p_stgbuf->pos = 0;
}
attribute ((noinline))
static void putchar_to_stgbuf(const char ch, struct staging_buffer_t *p_stgbuf)
{
p_stgbuf->buf[p_stgbuf->pos++] = ch;
p_stgbuf->total++;
if (p_stgbuf->pos == sizeof(p_stgbuf->buf)) {
flush_stgbuf(p_stgbuf);
}
}
static const char hex_digits_lo[] = { '0', '1', '2', '3', '4', '5', '6', '7',
'8', '9', 'a', 'b', 'c', 'd', 'e', 'f' };
static const char hex_digits_hi[] = { '0', '1', '2', '3', '4', '5', '6', '7',
'8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
attribute ((noinline))
static int output_digits(struct staging_buffer_t *out,
unsigned int number,
bool zero_padding,
bool is_decimal,
bool is_signed,
int visible_digits,
const char *digits_char_tbl)
{
unsigned int the_digit, max_dec_div = 1000000000;
int pos, max_digits, valid_digits = 0;
}
int printf(const char *fmt, ...)
{
va_list vl;
bool escaped = false;
bool zero_padding = false;
bool is_decimal = false;
bool is_signed = false;
struct staging_buffer_t staging_buf;
int visible_digits = sizeof(staging_buf.buf);
const char *str_indicator = hex_digits_hi;
}
Beta Was this translation helpful? Give feedback.
All reactions