#include #include int myfunc1(void) { return (1); } int myfunc2(void) { return (2); } int myfunc(void) __attribute__((ifunc("myfunc_dispatch"))); /* __asm__ (".type myfunc, @gnu_indirect_function"); */ /* typeof(myfunc) *myfunc_dispatch(void) __asm__("myfunc"); */ typeof(myfunc) * myfunc_dispatch(void) { if (time(0) & 1) { /* If time is odd at first call, use version 1 */ return (&myfunc1); } else { /* else use version 2 */ return (&myfunc2); } } int main(void) { printf("Called function number %i\n", myfunc()); return (0); }