> 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 13:40:34 up 2:05, 1 user, load average: 0.31, 0.17, 0.07
This commit is contained in:
@ -1,3 +1,7 @@
|
||||
#include <stddef.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include <am.h>
|
||||
#include <klib.h>
|
||||
#include <klib-macros.h>
|
||||
@ -42,16 +46,32 @@ int vsnprintf(char *out, size_t n, const char *fmt, va_list ap) {
|
||||
}
|
||||
|
||||
static int rvsnprintf(char* out, size_t n, const char* fmt, va_list ap) {
|
||||
while (n) {
|
||||
bool is_fmt;
|
||||
for (is_fmt = false; *fmt && n; fmt ++, *out ++, n --) {
|
||||
switch (*fmt)
|
||||
{
|
||||
case '%':
|
||||
is_fmt = true;
|
||||
break;
|
||||
case 'd':
|
||||
if (is_fmt) {
|
||||
int va = va_arg(ap, int);
|
||||
for (; va; va /= 10) {
|
||||
*out = va % 10 + '0';
|
||||
n --;
|
||||
out ++;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 's':
|
||||
if (is_fmt) {
|
||||
const char* va = va_arg(ap, const char*);
|
||||
size_t len = strlen(va);
|
||||
strncpy(out, va, len);
|
||||
n += len;
|
||||
}
|
||||
default:
|
||||
*out = *fmt;
|
||||
out ++;
|
||||
fmt ++;
|
||||
n --;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -58,12 +58,11 @@ void *memset(void *s, int c, size_t n) {
|
||||
}
|
||||
|
||||
void *memmove(void *dst, const void *src, size_t n) {
|
||||
unsigned char* _dst = (unsigned char*)dst;
|
||||
const unsigned char* _src = (const unsigned char*)src;
|
||||
const unsigned char* _dst_end = _dst + n;
|
||||
const unsigned char* _src_end = _src + n;
|
||||
if (_src < _dst_end && _src + n > _dst) {
|
||||
})
|
||||
// unsigned char* _dst = (unsigned char*)dst;
|
||||
// const unsigned char* _src = (const unsigned char*)src;
|
||||
// const unsigned char* _dst_end = _dst + n;
|
||||
// const unsigned char* _src_end = _src + n;
|
||||
panic("Not implemented");
|
||||
}
|
||||
|
||||
void *memcpy(void *out, const void *in, size_t n) {
|
||||
|
Reference in New Issue
Block a user