39 #define LONGLONG_LEN 4 101 *(--ptr) =
"0123456789ABCDEF"[
num & 0xf ] | case_mod;
106 while ( (
end - ptr ) < width )
111 *(--ptr) =
'X' | case_mod;
138 int pad = ( zpad |
' ' );
146 *(--ptr) =
'0' + (
num % 10 );
151 if ( negative && ( ! zpad ) )
155 while ( (
end - ptr ) < width )
159 if ( negative && zpad )
211 }
else if ( *
fmt ==
'0' ) {
221 if ( ( (
unsigned ) ( *
fmt -
'0' ) ) < 10 ) {
222 width = ( width * 10 ) + ( *
fmt -
'0' );
233 }
else if ( *
fmt ==
'l' ) {
235 }
else if ( *
fmt ==
'z' ) {
242 ptr = tmp_buf +
sizeof ( tmp_buf ) - 1;
257 }
else if ( *
fmt ==
's' ) {
259 ptr =
va_arg ( args,
char * );
263 wptr =
va_arg ( args,
wchar_t * );
267 }
else if ( *
fmt ==
'p' ) {
273 }
else if ( ( *
fmt & ~0x20 ) ==
'X' ) {
274 unsigned long long hex;
277 if ( *
length >=
sizeof (
unsigned long long ) ) {
278 hex =
va_arg ( args,
unsigned long long );
279 }
else if ( *
length >=
sizeof (
unsigned long ) ) {
285 }
else if ( ( *
fmt ==
'd' ) || ( *
fmt ==
'i' ) ){
288 if ( *
length >=
sizeof (
signed long ) ) {
289 decimal =
va_arg ( args,
signed long );
291 decimal =
va_arg ( args,
signed int );
298 if ( wptr ==
NULL ) {
299 for ( ; *ptr ; ptr++ ) {
303 for ( ; *wptr ; wptr++ ) {
304 size_t len = wcrtomb ( tmp_buf, *wptr,
NULL );
305 for ( ptr = tmp_buf ;
len-- ; ptr++ ) {
#define CHAR_LEN
"hh" length modifier
#define ALT_FORM
Use "alternate form".
static void cputchar(struct printf_context *ctx, unsigned char c)
Print character via a printf context.
static __always_inline void off_t int c
int printf(const char *fmt,...)
Write a formatted string to the console.
static char * format_decimal(char *end, signed long num, int width, int flags)
Format a decimal number.
void(* handler)(struct printf_context *ctx, unsigned int c)
Character handler.
uint8_t size
Entry size (in 32-bit words)
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
char hex[8]
Count (as an eight-digit hex value)
static void printf_putchar(struct printf_context *ctx __unused, unsigned int c)
Write character to console.
#define INT_LEN
no length modifier
struct golan_eq_context ctx
#define LCASE
Use lower-case for hexadecimal digits.
struct printf_context ctx
#define LONG_LEN
"l" length modifier
int ssnprintf(char *buf, ssize_t ssize, const char *fmt,...)
Version of vsnprintf() that accepts a signed buffer size.
#define SIZE_T_LEN
"z" length modifier
int vssnprintf(char *buf, ssize_t ssize, const char *fmt, va_list args)
Version of vsnprintf() that accepts a signed buffer size.
#define container_of(ptr, type, field)
Get containing structure.
#define __unused
Declare a variable or data structure as unused.
#define ZPAD
Use zero padding.
#define SHORT_LEN
"h" length modifier
static char * format_hex(char *end, unsigned long long num, int width, int flags)
Format a hexadecimal number.
static uint8_t type_sizes[]
__builtin_va_list va_list
#define LONGLONG_LEN
"ll" length modifier
size_t max_len
Buffer length (used by printf_sputc())
uint32_t end
Ending offset.
int ssize_t const char * fmt
int snprintf(char *buf, size_t size, const char *fmt,...)
Write a formatted string to a buffer.
int vprintf(const char *fmt, va_list args)
Write a formatted string to the console.
Context used by vsnprintf() and friends.
#define va_start(ap, last)
char * buf
Buffer for formatted string (used by printf_sputc())
static void printf_sputc(struct printf_context *ctx, unsigned int c)
Write character to buffer.
#define NULL
NULL pointer (VOID *)
int putchar(int character)
Write a single character to each console device.
size_t vcprintf(struct printf_context *ctx, const char *fmt, va_list args)
Write a formatted string to a printf context.
int vsnprintf(char *buf, size_t size, const char *fmt, va_list args)
Write a formatted string to a buffer.