> compile NEMU
221220000 张三 Linux zzy 5.15.146.1-microsoft-standard-WSL2 #1 SMP Thu Jan 11 04:09:03 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux 21:31:47 up 2 days, 16:37, 1 user, load average: 0.71, 0.53, 0.36
This commit is contained in:
@ -29,16 +29,15 @@ int num_to_ascii(int num, int power, int size, char *buf) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline int print_fmt(char **out, int n, const char** fmt, void* _ap) {
|
||||
va_list ap = *(va_list*)_ap;
|
||||
static inline int print_fmt(char **out, int n, const char** fmt, va_list (*ap)) {
|
||||
int ret = 0;
|
||||
switch (**fmt) {
|
||||
case 'd':
|
||||
ret = num_to_ascii(va_arg(ap, int), 10, n, *out);
|
||||
ret = num_to_ascii(va_arg(*ap, int), 10, n, *out);
|
||||
(*out) += ret;
|
||||
break;
|
||||
case 's':
|
||||
const char* str = va_arg(ap, const char*);
|
||||
const char* str = va_arg(*ap, const char*);
|
||||
if (ret > n) break;
|
||||
for (; *str; str ++, (*out) ++, ret ++ ) {
|
||||
if (ret >= n) {
|
||||
@ -48,20 +47,19 @@ static inline int print_fmt(char **out, int n, const char** fmt, void* _ap) {
|
||||
}
|
||||
break;
|
||||
case 'c':
|
||||
char ch = va_arg(ap, int);
|
||||
char ch = va_arg(*ap, int);
|
||||
ret = 1;
|
||||
**out = ch;
|
||||
(*out) ++;
|
||||
break;
|
||||
case 'x':
|
||||
ret = num_to_ascii(va_arg(ap, int), 16, n, *out);
|
||||
ret = num_to_ascii(va_arg(*ap, int), 16, n, *out);
|
||||
(*out) += ret;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
(*fmt) ++;
|
||||
*(va_list*)_ap = ap;
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -71,7 +69,7 @@ int rvsnprintf(char* out, size_t n, const char* fmt, va_list ap) {
|
||||
if (*fmt == '%') {
|
||||
// FIXME
|
||||
fmt++;
|
||||
print_fmt(&out, 123, &fmt, &ap);
|
||||
print_fmt(&out, 123, &fmt, (va_list*)&ap);
|
||||
continue;
|
||||
}
|
||||
*out = *fmt;
|
||||
|
@ -40,7 +40,7 @@ void *malloc(size_t size) {
|
||||
ptr += size;
|
||||
return ptr - size;
|
||||
#endif
|
||||
return NULL;
|
||||
return ptr;
|
||||
}
|
||||
|
||||
void free(void *ptr) {
|
||||
|
Reference in New Issue
Block a user