CPU dependent code: how to avoid function pointers?

后端 未结 4 1454
逝去的感伤
逝去的感伤 2021-02-10 15:04

I have performance critical code written for multiple CPUs. I detect CPU at run-time and based on that I use appropriate function for the detected CPU. So, now I have to use fun

4条回答
  •  情话喂你
    2021-02-10 15:37

    Here's the exact answer that I was looking for.

     GCC's __attribute__((ifunc("resolver")))
    

    It requires fairly recent binutils.
    There's a good article that describes this extension: Gnu support for CPU dispatching - sort of...

提交回复
热议问题