Add rwlock_destroy and mutex_{init,destroy} imports
Silence Valgrind warnings generated by uthash on debug builds

Define uthash_malloc(x) to generate calloc(1,x) on debug builds, and
define a special __HASH_ALLOC(type) macro which expands to calloc(1,
sizeof(type)) on debug builds and malloc(sizeof(type)) on release
builds.  Otherwise, valgrind emits "Conditional jump or move depends on
uninitialised value(s)" warnings.
Add XGLVUnregisterCloseDisplayCallbacks()

This will be called by x11glvnd clients to clean up any installed
callbacks on library teardown.
Remove a duplicate declaration

dispatchStubListGeneration was declared twice in GLdispatch.c,
so delete one of the declarations.
Track number of clients using GLdispatch

Theoretically multiple clients (libGLX and a future libEGL) may call
into __glDispatchInit() to set up dispatching, and we will want to
refcount GLdispatch to determine when dispatch teardown should occur.
So replace the global boolean 'initialized' with a counter
'clientRefcount' which tracks the number of clients using GLdispatch.
Add __glDispatch{Fini,Reset}()

__glDispatchFini() is called by a GLdispatch client to clean up
GLdispatch-internal state when the client is done using GLdispatch
functionality.

__glDispatchReset() is called by a GLdispatch client to determine
whether fork recovery is needed, and handle the fork if necessary.
Add LKDHASH_TEARDOWN() macro to handle hash table cleanup

This macro frees all entries in a locked hash table, and either
re-initializes the table's lock for fork recovery, or destroys the
lock, in which case the hash table is fully torn down and must be
re-initialized before it can be used.
Call into GLdispatch to lose current before a thread is destroyed

Without this, the current context accounting in GLdispatch can get
confused if a thread is destroyed while a context is still current
to that thread.
Fix issues with {Track,Untrack}CurrentContext()

- Don't clear the current TSD entry when UntrackCurrentContext() is
  called.  The TSD entry already contains the correct current context when
  it is set by TrackCurrentContext() prior to the call to
  UntrackCurrentContext().

- In the comment above UntrackCurrentContext(), delete an obsolete TODO.

- If make current fails, re-track the old context before returning.
Don't pass a NULL filename into dlopen(3).
Implement fork-handling and library teardown paths

- Define a function __glXThreadInitialize() which gets called when
entering any GLX entrypoint, or when __glXGetDynDispatch() is called
by a vendor-provided GLX extension entrypoint.  This function detects
if a fork occurred since the last entrypoint was called, and performs
fork recovery if needed.

- Implement __glXFini() so that libGLX cleans up allocated resources
when it is unloaded.

These paths make heavy use of the LKDHASH_TEARDOWN() macro that was
implemented in a previous commit.