113 Star 930 Fork 232

GVP李昂/pikapython

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
pika_config_gtest.c 1.87 KB
一键复制 编辑 原始数据 按行查看 历史
XieJC 提交于 2年前 . fix pdb shell buffer
#include "pika_config_gtest.h"
#include <stdio.h>
#include <stdlib.h>
#include "dataMemory.h"
#include "PikaVM.h"
char log_buff[LOG_BUFF_MAX][LOG_SIZE] = {0};
uint32_t log_index = 0;
/* save printf content to log_buff */
void pika_platform_printf(char* fmt, ...) {
for (int i = LOG_BUFF_MAX - 2; i >= 0; i--) {
memcpy(log_buff[i + 1], log_buff[i], LOG_SIZE);
}
va_list args;
va_start(args, fmt);
pika_platform_vsnprintf(log_buff[0], LOG_SIZE - 1, fmt, args);
va_end(args);
va_start(args, fmt);
pika_vprintf(fmt, args);
va_end(args);
}
// static volatile uint64_t tick_ms = 0;
// int64_t pika_platform_get_tick(void) {
// tick_ms += 50;
// return tick_ms;
// }
/* quick_malloc is always open */
uint8_t __is_quick_malloc(void) {
// return 1;
return 0;
}
void __gtest_hook_default(void) {
return;
}
typedef void (*hook_func)(void);
volatile int g_hook_cnt = 0;
volatile hook_func g_hook_func = __gtest_hook_default;
void __pks_hook_instruct(void) {
g_hook_cnt++;
g_hook_func();
}
volatile pika_bool g_always_repl_mode = pika_true;
PIKA_WEAK void pika_hook_unused_stack_arg(PikaVMFrame* vm, Arg* arg) {
if (vm->in_repl || g_always_repl_mode) {
arg_print(arg, pika_true, "\r\n");
}
}
#define GETCHAR_BUFFER_SIZE 1024
uint8_t getchar_buffer[GETCHAR_BUFFER_SIZE] = {0};
size_t getchar_buffer_index = 0;
int write_to_getchar_buffer(const char* str, size_t size) {
if (size > GETCHAR_BUFFER_SIZE - getchar_buffer_index) {
return -1;
}
memcpy(getchar_buffer + getchar_buffer_index, str, size);
getchar_buffer_index += size;
return 0;
}
char pika_platform_getchar(void) {
if (getchar_buffer_index > 0) {
char c = getchar_buffer[0];
memmove(getchar_buffer, getchar_buffer + 1, getchar_buffer_index - 1);
getchar_buffer_index--;
return c;
}
return getchar();
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C
1
https://gitee.com/Lyon1998/pikapython.git
git@gitee.com:Lyon1998/pikapython.git
Lyon1998
pikapython
pikapython
master

搜索帮助