2024-06-18 19:37:43 +08:00
|
|
|
#include "stdio.h"
|
|
|
|
#include "regex.h"
|
|
|
|
#include "stdlib.h"
|
|
|
|
#include "stdint.h"
|
|
|
|
#include "soft/exception.h"
|
|
|
|
#include "soft/mythread.h"
|
|
|
|
#include "unistd.h"
|
2024-06-21 15:20:47 +08:00
|
|
|
#include "soft/debug.h"
|
2024-10-30 19:08:46 +08:00
|
|
|
#include "string.h"
|
|
|
|
#include "soft/clexical.h"
|
2024-06-18 19:37:43 +08:00
|
|
|
|
|
|
|
|
2024-10-30 19:08:46 +08:00
|
|
|
|
|
|
|
|
|
|
|
const char g_str[ ] = "int main(){\n"
|
2024-10-30 23:30:35 +08:00
|
|
|
"int index=1000;\n"
|
|
|
|
"while(index--){\n"
|
2024-10-30 19:08:46 +08:00
|
|
|
"printf(index)\n"
|
|
|
|
"}\n"
|
|
|
|
"}";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int thread_fun(void* t) {
|
2024-06-21 15:20:47 +08:00
|
|
|
DBG_INFO("run in thread_fun.\n");
|
2024-10-30 19:08:46 +08:00
|
|
|
lex_analysis(g_str , strlen(g_str));
|
2024-06-18 19:37:43 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void SystemInit();
|
|
|
|
extern char **environ;
|
|
|
|
int main(int argc,char *argv[]){
|
2024-06-21 15:20:47 +08:00
|
|
|
debug_init(NULL);
|
|
|
|
DBG_INFO("hello world.%ld\n",(size_t)pthread_self());
|
2024-06-18 19:37:43 +08:00
|
|
|
|
2024-10-30 19:08:46 +08:00
|
|
|
myth_create(thread_fun , NULL);
|
2024-06-18 19:37:43 +08:00
|
|
|
|
2024-10-30 19:08:46 +08:00
|
|
|
myth_join( );
|
2024-06-18 19:37:43 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define func_def(...)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define SLOT_FUN_RUN(fun,param) \
|
|
|
|
((slot_fun_def)(fun))(param[0],param[1],param[2],\
|
|
|
|
param[3],param[4],param[5],param[6],param[7])
|
|
|
|
|
|
|
|
typedef void (*slot_fun_def)(size_t a,size_t b,size_t c,size_t d,size_t e,size_t f,size_t g,size_t h);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void funptr_test(){
|
2024-06-21 15:20:47 +08:00
|
|
|
DBG_INFO("print from funptr_test fun.\n");
|
2024-06-18 19:37:43 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void add_test(int a,int b,void (*f)()){
|
2024-06-21 15:20:47 +08:00
|
|
|
DBG_INFO("add_fun:%d+%d=%d\n",a,b,a+b);
|
2024-06-18 19:37:43 +08:00
|
|
|
f();
|
|
|
|
}
|
|
|
|
|
|
|
|
void SystemInit()
|
|
|
|
{
|
|
|
|
func_def(int (int a,int b){
|
|
|
|
int a;
|
|
|
|
return;
|
|
|
|
});
|
|
|
|
size_t pars[8]={4,5,(size_t)funptr_test};
|
|
|
|
SLOT_FUN_RUN(add_test,pars);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|