A ThreadLocal() variable should be accessed through BLI_thread_local_get() and BLI_thread_local_set(). On non-Apple platforms accessing it directly is fine, but on macOS the macros are required.
This patch updates gpu_framebuffer.c to access the thread-local variable g_currentfb using the correct macros rather than directly. Because this uses pthread thread-specific data, we also need to create and destroy the pthread_key_t. And the pthread interface also requires that the variable is a pointer, so the type changes to void* and we add macros to cast the GLuint into and out of the void*.
This fixes assertion failures on macOS particularly in WM_opengl_context_activate() when rendering is happening on multiple threads.