Kernel, libc: Implement %p in *printf()
So we can avoid writing (unsigned long)ptr or (uint64_t)ptr everywhere when wanting to print a pointer.
This commit is contained in:
parent
247645d301
commit
c67079dd74
@ -159,6 +159,14 @@ static int internal_printf(const char* format, PutString put_string_callback, ss
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case 'p': {
|
||||||
|
char result[25];
|
||||||
|
ultoa(va_arg(ap, uint64_t), result, 16);
|
||||||
|
if (buffer_insert_index + strlen(result) > 1024) flush_buffer();
|
||||||
|
memcpy(buffer + buffer_insert_index, result, strlen(result));
|
||||||
|
buffer_insert_index += strlen(result);
|
||||||
|
if (buffer_insert_index == 1024) flush_buffer();
|
||||||
|
}
|
||||||
case 's': {
|
case 's': {
|
||||||
const char* str = va_arg(ap, const char*);
|
const char* str = va_arg(ap, const char*);
|
||||||
while (strlen(str) > 1024)
|
while (strlen(str) > 1024)
|
||||||
|
@ -242,6 +242,14 @@ static int internal_printf(const char* format, PutString put_string_callback, ss
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case 'p': {
|
||||||
|
char result[25];
|
||||||
|
__unsignedtoa<unsigned long>(va_arg(ap, uint64_t), result, 16);
|
||||||
|
if (buffer_insert_index + strlen(result) > 1024) flush_buffer();
|
||||||
|
memcpy(buffer + buffer_insert_index, result, strlen(result));
|
||||||
|
buffer_insert_index += strlen(result);
|
||||||
|
if (buffer_insert_index == 1024) flush_buffer();
|
||||||
|
}
|
||||||
case 's': {
|
case 's': {
|
||||||
const char* str = va_arg(ap, const char*);
|
const char* str = va_arg(ap, const char*);
|
||||||
while (strlen(str) > 1024)
|
while (strlen(str) > 1024)
|
||||||
|
Loading…
Reference in New Issue
Block a user