79 lines
1.1 KiB
C
79 lines
1.1 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"
|
||
|
|
||
|
|
||
|
int thread_fun(void *t){
|
||
|
printf("run in thread_fun.\n");
|
||
|
|
||
|
while(1){
|
||
|
sleep(5);
|
||
|
throw_("s");
|
||
|
}
|
||
|
return 0;
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
void SystemInit();
|
||
|
extern char **environ;
|
||
|
int main(int argc,char *argv[]){
|
||
|
int id;
|
||
|
printf("hello world.\n");
|
||
|
|
||
|
|
||
|
|
||
|
// while(p&&(*p)){
|
||
|
|
||
|
// printf("%s\n",*p++);
|
||
|
// }
|
||
|
|
||
|
// printf("a+b=%d",test_add(3,5));
|
||
|
id=myth_create(thread_fun,NULL);
|
||
|
id=myth_create(NULL,NULL);
|
||
|
// sleep(10);
|
||
|
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(){
|
||
|
printf("print from funptr_test fun.\n");
|
||
|
}
|
||
|
|
||
|
void add_test(int a,int b,void (*f)()){
|
||
|
printf("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);
|
||
|
}
|
||
|
|
||
|
|
||
|
|