Reset spinlock on global cache when reinitting

Also loop directly in the spinlock so it forces cache flushes so it
seems updated values properly.
FreeBSD needs the same handling as OpenBSD here
Use a more descriptive define to prevent collisions

This caused the build to fail on OpenBSD.
OpenBSD should not link with -lcrypt option
Add system CFLAGS after vendor library paths

This ensures that we pick up vendor paths before any system paths. Fixes
building with for example older libffi version in the path that don't
support certain functions.
Revert "Add system CFLAGS after vendor library paths"

This reverts commit cea15456af6d329f79c67bf608df68a762c22d84.

For some weird reason this seems to break on Linux.
Push vendor libraries on the front of CFLAGS

This makes sure we pickup vendor libraries before system libraries if
they are available as system libraries as well.
Require thread for 1.8 OpenSSL so Mutex is available
Remove unused typedef
Setup all thread names in a single location

This also fixes the naming of systems threads such as the finalizer in
GDB on OS X.
Use per extension C-API locks and setup blacklist mechanism

This allows for using a per extension C-API lock instead of a global
lock. Each time an extension entry point is loaded (the Init_ function),
we setup a new lock index. We store this in the native method frame so
any methods defined will pick up the lock index.

This lock index is then stored for the native method and used when
locking around a C extension call. We use the value of 0 to indicate an
extension doesn't need locking if -Xcapi.lock is not enabled.

If -Xcapi.lock is enabled, each extension gets it's own lock through
this mechanism. Except for this general strategy, we also have a
blacklist which contains known bad extensions that always need a lock
around them. A known example of this is NKF, which tracks all it's
internal state in global C variables.

The blacklist mechanism allows for an easy way to add more troublesome
extensions without having to enabled the C-API lock for everything.
Revert "NKF extension is not thread safe, lock around it"

This reverts commit a39c8d8b0bd1ef8ef81b1ddb83c1c59385ad1002.

Since we now have a blacklist mechanism for bad extensions, we can
remove this locking and depend on the C-API locking mechanism.
Add additional known type annotations

This sets up a known type annotation for the initial self receiver for a
method, since that is stored with the method as well so we can propagate
this.

We also store a known type annotation for an object allocation if that
has a known cached receiver class type that we're instantiating.

Also does an additional cleanup of code no longer used.
Associate class id with literals when pushing

This makes sure we associate the proper class_id for the literals we
have stored. This also improves the locals handling by tracking the type
information as well. This makes sure that for example a set_local /
push_local pair keeps the type information around.
Use faster path for making array on the stack
Remove unused VariableScope#fixup method
Fixes typo in diatribe
Merge pull request #2349 from alindeman/patch-1

Fixes typo in diatribe
Use a spinlock around variable scope retrieval

This is needed because these scopes might be used in different threads,
the simplest example being the following case:

def foo
  a = 1
  Thread.new do
    p a
  end
end

Here the local a is accessed from a different thread. This presents a
problem with flushing the scope to the heap when the foo method returns.
In that case the locals aren't on the stack anymore, but the other
thread might still read the data from the stack due to a race condition.

New threads isn't the only case where this might happen, it can also be
for example the scope capture with a proc or lambda and passed to
another thread for execution. If that accesses the defining scope, this
presents the same problem.

This fixes one cause of crashes of the reproduction in issue #2339.
Explicitly pass in call_frame for going GC dependent

This ensures we always store the last call_frame here as well for proper
GC.