(PUP-2511) Add parser function digest: uses digest_algorithm to hash, not strictly md5

Puppet has an md5 parser function, which returns the MD5 digest of its
argument. On hosts configured for compliance with U.S. Federal
Information Processing Standard (FIPS) 140-2, attempts to use the MD5
algorithm cause errors, because MD5 is no longer FIPS Approved. This
patch adds a parser function called digest, which returns the digest
of its argument using the algorithm named by the digest_algorithm
setting in puppet.conf. Therefore, where md5 may fail on some hosts,
the digest function should always return a value; but the value may
vary if the digest_algorithm setting is changed.
(PUP-2271) Allow yumrepo proxy attribute to be set to _none_

Add fix and test to allow proxy to be set to _none_ to bypass global proxy
configuration for YUM.

See https://tickets.puppetlabs.com/browse/PUP-2271
(PUP-2738) FFI::Pointer#read_win32_local_pointer

 - Create new block style helper that automatically calls LocalFree on
   a returned pointer after it's done being used. Since the ptr is no
   longer valid after the block yields, return nil from the method
 - Move FFI definition for LocalFree into FFI::WIN32 and out of
   Puppet::Util::Windows::Error and Puppet::Util::Windows::SID
 - Ensure that proper wide string is resolved / passed out of
   Puppet::Util::Windows::Error.format_error_code and
   Puppet::Util::Windows::SID.sid_ptr_to_string when resolving string
   inside of a block
 - Refactor Puppet::Util::Windows::SID.valid_sid? to read ptr inside
   block, use closure to store the 'valid' return value
(PUP-2758) Add micro benchmark(s) task

This adds a benchmark that runs a series of puppet manifests that
are measured individually for parse and evaluation time. Each
manifest is measured 100x each for parse and evaluation. The benchmark
total time includes running all of them (including overhead of
measuring the details). Details are output as average of all runs
per detail where parsing and evaluating is output as separate entries.

The sample file written is for the total average.
(PUP-2758) Add passing arguments (warm_up and detail) to Benchmarker.run

Arguments are needed to be able to run one detail of a benchmark.
The evaluations benchmark makes use of this, all others ignore the
arguments.
(maint) Correct typo in loader helper class and add tests

Loading the same function multiple times from modules caused
an error because of a typo in NamedEntry. This adds tests for the
helper classes basic functionality, and adds tests that loaders indeed
can load a function more than once.

This also corrects error handling (yet another typo) when a function was
redefined (the wrong method was called).
(PUP-2758) Add calls to 3x, 4x, and namspace 4x functions to evaluations

This adds additional benchmarks for function calls using 3x calls,
4x calls in global namespace, and name spaced to a module.

A simple assert_type benchmark is also added (one simple type check).
(PUP-2758) Generate tasks with arguments defined by benchmark

This makes it possible for a benchmark scenario that wants
additional details to run a smaller portion of the benchmark to
configure these by defining a class called BenchmarkerTask (currently
only used by the evaluations benchmark). The separation from the
Benchmarker class is that this class is loaded when rake generates a
list of tasks, and it is not wanted to load each full benchmark in turn
to generate this list. (Over time, the BenchmarkerTask can be expanded
on to perform other task generation duties).

It is now possible to run all of the evaluations benchmarks,
profile all, run one particular micro benchmark, or just its parse or
evaluation part by suffixing the name with _parse or _eval. As an
example rake benchmark:evaluations:run[assert_type_eval] runs only the
evaluation part of the assert_type micro benchmark in evaluations. (This
is especially useful when running profiling.

For profiling, the parameter warm_up_runs is always included.
(PUP-2758) Add benchmarks empty catalog, and defined_types for future

This adds benchmark that runs the defined_types benchmark for the future
parser (everything else is the same).
A benchmark is also added to measure the overhead of compiling a
catalog with minimal (almost nothing) content (i.e. a command line
puppet apply scenario).
(PUP-2738) FFI from_string_to_wide_string block

 - MemoryPointer from_string_to_wide_string previously allocated a
   new MemoryPointer instance but didn't force callers to scope / free
   it.  This allowed the Ruby runtime to clean it up on GC, but we
   prefer to force callers to use a block form, to clean up the
   unmanaged memory when the variable is no longer needed.  Refactor
   the method to yield the ptr.
 - Since the ptr is no longer valid after the block yields, return nil
   from the method
(PUP-2738) Puppet::Util::Windows::User refactor

  - Presently `logon_user` raises an exception or returns the error code
    returned by `CloseHandle`.  Change this to return `true` if the
    method executes without error.
  - This also affects the `load_profile` method and the `password_is?`
    method.  `load_profile` previously returned the `logon_user` return
    value from the outer block, so now returns `true` upon success, or
    will raise an error upon failure
(PUP-2738) open_symlink should wide_string once

 - open_symlink is the only caller for create_file, and create_file
   already calls wide_string on the first parameter.  Remove
   unnecessary wide_string call perfomed in open_symlink
(PUP-2738) Puppet::Util::Windows::File FFI cleanup

 - Break resolve_symlink into an additional helper to simplify memory
   usage / cleanup.  Each time an FFI::MemoryPointer is encountered,
   it's cleaned up immediately after use. Structure code to ensure that
   a REPARSE_DATA_BUFFER is returned from resolve_symlink rather than
   a FFI::MemoryPointer
 - Ensure that Puppet::Util::Windows::File.resolve_symlink return value
   is given default, and closed on inside block to prevent incorrect
   return value.
(PUP-2738) Puppet::Util::Windows::Process FFI clean

 - Refactor wait_process so that the FFI::MemoryPointer for the exit
   code is cleaned up immediately after use.  Note that we capture the
   exit_status within the block, and return it outside of the block
 - Fix bug in Puppet::Util::Windows::Process.process_privilege_symlink?
   that could result in the wrong value being returned.
 - Fix bug in Puppet::Util::Windows::Process.elevated_security?
   that could result in the wrong value being returned.
(PUP-2738) Use block form of FFI::MemoryPointer

 - Existing uses of FFI::MemoryPointer rely on Ruby GC to perform
   non-deterministic memory cleanup.  In an effort to reduce memory
   consumption, use the block form of FFI::MemoryPointer to call free
   on pointers as soon as they're no longer needed.
 - Ensure that we don't use non-local return's anywhere, due to their
   potential dangerous / unexpected behavior.  When inside blocks,
   store off return values in a separate variable to be returned
   outside the block.  When values are only used inside yields, and the
   corresponding unmanaged memory has been freed, return nil outside
   the block.
(PUP-2738) Windows utils appropriate return values

 - Puppet::Util::Windows::File.open_symlink was previously returning
   the integer result of CloseHandle, which was undesireable.  Assume
   the token is always used in a block, so return nil from the method.
 - Puppet::Util::Windows::File.readlink was being a bit dangerous, and
   performing a non-local return within a block.  Use a closure instead
   to capture the return value of resolve_symlink, return outside block.
 - Puppet::Util::Windows::Process.open_procss_token had the same issue
   as open_symlink, and has been changed to return nil.
(PUP-2738) Move CloseHandle -> FFI::WIN32

  - CloseHandle is an API used frequently, so move it to a shared
    definition inside FFI::WIN32.  Remove extraneous definitions and
    update call sites.
(PUP-2738) Windows::File use FFI::Pointer helper

 - Remove custom packing of array bytes and replace with use of
   read_wide_string from FFI::Pointer
Merge pull request #2778 from hlindberg/PUP-2758_micro-benchmarks

(PUP-2758) Add micro (and other) benchmarks for future parser/evaluator
Merge branch 'ticket/master/PUP-2738-FFI-Memory-Issues'

* ticket/master/PUP-2738-FFI-Memory-Issues:
  (PUP-2738) Windows::File use FFI::Pointer helper
  (PUP-2738) Move CloseHandle -> FFI::WIN32
  (PUP-2738) Windows utils appropriate return values
  (PUP-2738) Use block form of FFI::MemoryPointer
  (PUP-2738) Puppet::Util::Windows::Process FFI clean
  (PUP-2738) Puppet::Util::Windows::File FFI cleanup
  (PUP-2738) open_symlink should wide_string once
  (PUP-2738) Puppet::Util::Windows::User refactor
  (PUP-2738) FFI from_string_to_wide_string block
  (PUP-2738) FFI::Pointer#read_win32_local_pointer