小编Arm*_*ian的帖子

如何使用包装函数传入函数的参数指针函数?

我有这个功能:

void boot(uint ncores, uint nterm, Task boot_task, int argl, void* args)
{

 for(int i=0; i<MAX_PROC;i++) {
    PT[i].ppid = NOPROC;
 }
 nextproc = 0;

 curproc = NOPROC;
 Exec(boot_task, argl, args);
}
Run Code Online (Sandbox Code Playgroud)

而且我想要而不是Exec()使用pthread,所以我必须调用cpu_boot:

void cpu_boot(uint cores, interrupt_handler bootfunc, uint serialno)
{
 //I cannot change this function 
}
Run Code Online (Sandbox Code Playgroud)

这些是参数的类型

typedef void interrupt_handler();
typedef int (* Task)(int, void*);
Run Code Online (Sandbox Code Playgroud)

我试过了:

void boot(uint ncores, uint nterm, Task boot_task, int argl, void* args)
{
    void my_wrapper()
    {

        int y;
        y= boot_task(argl, args); …
Run Code Online (Sandbox Code Playgroud)

c pthreads wrapper

5
推荐指数
1
解决办法
183
查看次数

标签 统计

c ×1

pthreads ×1

wrapper ×1