Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ridiculousfish/3cff64438154a20765e527be11f7cc76 to your computer and use it in GitHub Desktop.
Save ridiculousfish/3cff64438154a20765e527be11f7cc76 to your computer and use it in GitHub Desktop.
extern "C" void pthread_once(int *, void());
namespace std
{
extern __thread void (*__once_call)();
extern "C" void __once_proxy();
}; // namespace std
static void noop() {}
using voidfunc = void (*)();
static voidfunc *vp;
static void call_vp()
{
(*vp)();
}
int main()
{
using namespace std;
voidfunc vf = noop;
vp = &vf;
__once_call = call_vp;
int once{0};
pthread_once(&once, __once_proxy);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment