101 lines
1.6 KiB
C
101 lines
1.6 KiB
C
#include "stdio.h"
|
|
#include "regex.h"
|
|
#include "stdlib.h"
|
|
#include "stdint.h"
|
|
#include "soft/exception.h"
|
|
#include "soft/mythread.h"
|
|
#include "unistd.h"
|
|
#include "soft/debug.h"
|
|
#include "string.h"
|
|
#include "soft/clexical.h"
|
|
|
|
|
|
|
|
|
|
const char g_str[] =
|
|
"int main() {\n"
|
|
" int index=-1000;\n"
|
|
" while(index--){\n"
|
|
" printf(index>=0);\n"
|
|
" }\n"
|
|
"}";
|
|
|
|
|
|
|
|
|
|
__attribute__((weak)) int thread_fun(void* t) {
|
|
DBG_INFO("run in thread_fun.\n");
|
|
// lex_analysis(g_str , strlen(g_str));
|
|
|
|
return 0;
|
|
}
|
|
|
|
int g_argc;
|
|
// char* g_argv[100];
|
|
char** g_argv;
|
|
|
|
void set_argv(int argc, char* argv[]) {
|
|
g_argc = argc;
|
|
// for (int i = 0;i < argc;i++) {
|
|
// g_argv[i] = argv[i];
|
|
// }
|
|
g_argv = argv;
|
|
}
|
|
|
|
int get_argv(char** argv[]) {
|
|
// *argv = *(char ***)(g_argv);
|
|
*argv = (g_argv);
|
|
return g_argc;
|
|
}
|
|
|
|
void SystemInit();
|
|
extern char **environ;
|
|
int main(int argc, char* argv[]) {
|
|
set_argv(argc, argv);
|
|
debug_init(NULL);
|
|
DBG_INFO("hello world.%ld\n", (size_t)pthread_self());
|
|
|
|
|
|
myth_create(thread_fun, NULL,"main_thread");
|
|
|
|
myth_join( );
|
|
}
|
|
|
|
|
|
|
|
|
|
#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(){
|
|
DBG_INFO("print from funptr_test fun.\n");
|
|
}
|
|
|
|
void add_test(int a,int b,void (*f)()){
|
|
DBG_INFO("add_fun:%d+%d=%d\n",a,b,a+b);
|
|
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);
|
|
}
|
|
|
|
|
|
|