about summary refs log tree commit diff stats
path: root/tests/test20.c
blob: d80a5f5bd77453313d2ed9d37f52709f7de698e8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <stdio.h>
int myfunc1() { return 1; }
int myfunc2() { return 2; }

// Prototype for the common entry point
/*extern "C" */int myfunc();
__asm__ (".type myfunc, @gnu_indirect_function");
// Make the dispatcher function. This returns a pointer to the desired function version
typeof(myfunc) * myfunc_dispatch (void) __asm__ ("myfunc");
typeof(myfunc) * myfunc_dispatch (void)  {
if (0) 
  return &myfunc1;
else
  return &myfunc2;
}

int main() {
   printf("\nCalled function number %i\n", myfunc());
   return 0;
}