[util] Add STATIC_ASSERT() and UNUSED macros to utils_misc.h

Also remove a duplicate STATIC_ASSERT() macro from include/compiler.h.
[libglx] Fix usage of incorrect hash key when adding to __glXVendorNameHash
[GLdispatch] entry*.h: Implement function to generate default assembly stubs

- Place the static dispatch stubs in a writable text section so that they can
  be over-written at runtime.
- Add an enum to enumerate each TLS model type, and add constants which
  describe the libglvnd TLS model type in use and the size of each entrypoint.
- Add a function, entry_generate_default_code(), to online-generate default
  dispatch stubs on supported TLS models.
- Rewrite entry_x86_tls.h:entry_patch_public() to use
  entry_generate_default_code().
[OpenGL] Remove redundant TOP and GLAPI definitions from Makefile.am
Rename entry_patch_public() to entry_init_public()

This re-naming should help avoid confusion with the terminology used
to describe vendor library re-writing of entrypoints, also known as
"patching".  This function is called once at initialization time for
certain (e.g. x86_tls) TLS models.
[GLdispatch] Implement code to restore default entrypoint stubs

This makes use of entry_generate_default_code() to generate default
libglvnd dispatch stubs on supported TLS models.

This change also adds #if defined(STATIC_DISPATCH_ONLY) blocks to stub.c
for later use with the libGL and libOpenGL wrapper libraries, which will
make use of this functionality to overwrite their static entrypoints.
[glvnd_pthread] Add GLVNDPthreadFuncs::is_singlethreaded attribute

This will come in handy when a glvnd_pthread client needs to determine
whether the process is single-threaded.

Change the prototype of glvndSetupPthreads() to return void, and fix up
callers to use GLVNDPthreadFuncs::is_singlethreaded instead.
[GLdispatch] Track the number of current contexts

This will be useful when determining whether contexts are current on
threads other than the current thread, for the purposes of determining
whether entrypoint re-writing is safe.
Export pthreads functions from libGLdispatch, rather than libGLX

GLdispatch previously relied on locking primitives retrieved from
libGLX, but it may be loaded and used by other interface libraries (e.g.
libOpenGL) prior to being loaded by libGLX.  Instead, statically link
the glvnd_pthread wrapper library in libGLdispatch and import the
wrapper functions into libGLX when it first initializes libGLdispatch.
Register vendors with GLdispatch

This implements the notion of a "vendor ID" that is unique to each
vendor library instance loaded in a process.  When entrypoint rewriting
is implemented, this will be used by libglvnd to determine whether a
given entrypoint implementation is compatible with a given context, by
comparing the vendor owning the context with the vendor owning the
implementation.

This changes the function prototype of __glDispatchMakeCurrent()
to include the vendorID as an argument, which will be saved off in the
API state, and return a boolean value to indicate whether make current
succeeded.
[GLdispatch] Implement API for registering top-level dispatch stubs

This allows vendor libraries to potentially overwrite the static
entrypoints of wrapper libraries (such as libGL and libOpenGL) at make
current time, in addition to the main GLdispatch entrypoints.
Define driver ABI for patching libglvnd entrypoints

This defines several callbacks to be used by vendor libraries for
rewriting top-level entrypoints defined in libglvnd:

- initiatePatch(): libglvnd calls into this function at make current
  time to determine whether entrypoint patching is possible with the
  given stub type and code size.  The vendor library will notify
  libglvnd whether offsets are needed based on a generation number.
- getOffsetHook(): libglvnd calls into the vendor library with this hook
  for each loaded interface library so the vendor can lookup the stub
  locations for rewriting.
- finalizePatch(): libglvnd calls into this function after the vendor
  library has updated its stub locations to complete the patch.
[GLdispatch] Patch entrypoints on make current

Modify __glDispatchMakeCurrent() to take a pointer to the patch
callbacks for the vendor library whose context is about to be current.

Implement GLdispatch.c:PatchEntrypoints() and helpers.  This contains
the logic for determining whether it is safe to patch entrypoints, and
using the provided vendor callbacks to actually do the entrypoint
patching.  Call this from __glDispatchMakeCurrent() with the provided
patch callbacks.

Also implement GLdispatch.c:CurrentEntrypointsSafeToUse(), which
determines based on the current vendor ID whether the current top-level
code is safe to use with that vendor.  If this check fails, the make
current operation fails.

Allow users to disable entrypoint rewriting functionality by setting the
environment variable __GLVND_DISALLOW_PATCHING=1.

When losing current, also attempt to restore the default libglvnd
entrypoints so other vendors can potentially use them.
[libGL, libOpenGL] Register stub callbacks with GLdispatch

This allows vendor libraries to re-write dispatch stubs in these wrapper
libraries.
Build libGLX_patchentry.so for future entrypoint patching unit test

This test DSO patches glVertex3fv() at runtime to increment a global
variable, __glXSawVertex3fv.  This will be used by a future
"testglxpatchentry" unit test to verify that basic entrypoint patching
works as expected on platforms that support it.
Add testpatchentrypoints unit test

This unit test verifies that entrypoint patching works as expected, by
loading libGLX_patchentry.so, looking up the address of
__glXSawVertex3fv defined in libGLX_patchentry.so, and verifying that
the value at this symbol matches the number of calls to glVertex3fv()
(which is hacked to increment __glXSawVertex3fv via entrypoint
rewriting).
Merge pull request #12 from bnguyen0/master

Implement support for allowing vendor libraries to overwrite libglvnd entrypoints