Add plugin support for alternative name lookup

OTP behaviour instances (gen_server, gen_fsm, gen_event) can currently
register themselves either locally or globally, and the behaviour
libraries (including gen.erl) support both addressing methods, as well
as the normal Pid and {Name, Node}.

However, there are alternative registry implementations - e.g. gproc -
and one can well imagine other ways of locating a behaviour instance,
e.g. on a node connected only via a TCP tunnel, rather than via
Distributed Erlang. In all these cases, one needs to write extra code
to identify the behaviour instance, even though the instance itself
need not be aware of how it is located.

This patch introduces a new way of locating a behaviour instance:
{via, Module, Name}.

Module is expected to export a subset of the functions in global.erl,
namely:

register_name(Name, Pid) -> yes | no
whereis_name(Name)  -> pid() | undefined
unregister_name(Name) -> ok
send(Name, Msg) -> Pid

Semantics are expected to be the same as for global.erl

This can be used in all places where {global, Name} is accepted.

faulty export in gen_fsm_SUITE.erl

await process death in dummy_via:reset()

fix error in gen_[server|fsm]:enter_loop()

fix documentation
add escript win32 alternative invocation (thanks Pierre Rouleau)

On Windows, escript may be passed different arvg[0] values depending
on how it was started up.

This patch allows for escript to be started as "escript.exe"
(current behaviour) and also "escript" which is more likely when
called from the default Windows cmd.exe shell.
[megaco] Fixed faulty test case (connect)
Fixes value returned by mnesia_loader:do_get_disc_copy2/4

Returns the same value for `mnesia_loader:disc_load_table/2' as
`mnesia_loader:net_load_table/4' if a table copy can not be found.

This patch was stuck as a pull request in GitHub (authored by Uwe
Dauernheim):
	https://github.com/erlang/otp/pull/16
Fix returned error from gen_tcp:accept/1,2 when running out of ports

The {error, enfile} return value is badly misleading and confusing for
this case, since the Posix ENFILE errno value has a well-defined meaning
that has nothing to do with Erlang ports. The fix changes the return
value to {error, system_limit}, which is consistent with e.g. various
file(3) functions. inet:format_error/1 has also been updated to support
system_limit in the same manner as file:format_error/1.
sys_core_fold: Remove duplicate optimization

The second clause in opt_case_in_let_2/3 attempts to do the same
optimization as opt_bool_case_redundant/1; it will never succeed.
sys_core_fold: Simplify opt_bool_not() to cover it completely

In:

   case not Expr of ...

we don't have the information to ascertain that Expr is a boolean
expression. Therefore, add the catch-all clause unconditionally.
sys_core_fold: Fix opt_guard_try/1

opt_guard_try/1 assumed that it was only operating on guards, and
implicitly assumed that any function call was to BIFs without
any side effects.
sys_core_fold: Refactor previous_ctx_to_binary/2 to cover it completely
v3_kernel.erl: Remove unused define of EXPENSIVE_BINARY_LIMIT
v3_kernel.hrl: Remove unused record #k_string{}
v3_kernel: Remove clauses that are never executed in arg_val/1

arg_val/1 will never be called for single-valued types, so there
is no need handle these types.
v3_kernel: Handle sequences in guards

A guard with a sequence will cause a crash in v3_codegen. Currently,
it seems that a sequence in a guard will never happen when compiling
from Erlang code, but there are several reasons to fix this problem
anyway:

* There are other compilers that generate Core Erlang code.

* Changes to sys_core_fold (perhaps additional optimizations) may
  cause sequences to be generated in guards.

* A previously uncovered line in sys_core_fold:opt_guard_try/1 will
  now be covered.
v3_kernel: Don't attempt to share identical literals

It is unlikely that sharing literals will actually save any time.
Literals that can be shared are usually small. It is more likely
that maintaining the dictionary of literals will waste time.
v3_codegen: Eliminate the special case of 'put' without destination

If we let v3_kernel make sure that a 'put' operation always has a
destination register, the special case in v3_codegen is not needed.
v3_kernel: Remove unreached handling of #k_bin_int{} in arg_con/1

arg_con/1 will never be called with #k_bin_int{} argument, since
a #k_bin_int{} is constructed out of #k_bin_seg{} only after
arg_con/1 has been called with a #k_bin_seg{} argument.
v3_kernel: Removed unreached clause for #k_bin_int{} in sub_size_var/1

The size field of a #k_bin_int{} is always a literal integer
(#k_int{}); thus there is no way this clause can match.

While we are at it, remove a duplicated call to
select_assert_match_possible/3 in select_bin_int/1.
v3_kernel: Introduce is_in_guard/1
Avoid creating an undefined start_phases entry when generating a release

When a release is generated and the applications in the release do not
define a value for the start_phases entry of their .app files, reltool
will generate the following entry in the .app files of the release:

{start_phases, undefined}

If this happens, when trying to create a release upgrade systools will
fail because it doesn't allow the start_phases entry to be set to
undefined. This patch avoids this situation by not generating a
start_phases entry when it is set to undefined.
Set PATH correctly when building tests on win32