mozilla/r2d2b2g — pull request #820 by brendandahl (2013-08-31 01:30:46+00:00)
Title: Switch to thread local storage from cutils.

Fixes #782

Luckily cutils has a thread local storage implementation already.
Some notes:
- Storing the js_msg function pointer in tls is tricky since data pointer aren't guaranteed to be the same size as function pointers. Casting to void* seems to be fine on osx and windows xp, but I'm not sure about the linux 64 distros.
- To solve the above I use a wrapper structure and store the pointer to the wrapper structure. However, there seems to be something wrong with how the destructor is called when you quit firefox causing a crash. Gdb also won't give me a good backtrace on this crash so I'll leave a small memory leak in for now and hope to address it in the future.
- I moved adb_sysdeps_init() into a initialization function to ensure mutex locks were initialized on windows before anything else is called.

Aside: we need to do some work on the build system, there's way to much to change just to add a file.