Skip to content

Instantly share code, notes, and snippets.

@stepancheg
Created January 27, 2010 23:54
Show Gist options
  • Save stepancheg/288290 to your computer and use it in GitHub Desktop.
Save stepancheg/288290 to your computer and use it in GitHub Desktop.
#include <stdlib.h>
#include <time.h>
static int __my_func_impl_1() {
return 44;
}
static int __my_func_impl_2() {
return 55;
}
asm(".type my_func,@gnu_indirect_function");
void* my_func() {
srandom(time(0));
if (random() % 2 == 0)
return &__my_func_impl_1;
else
return &__my_func_impl_2;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment