anchor.diff:      io:format("using port driver~n", []),
       {ok, Path} = load_path(Name ++ ".so"),
       Result = case erl_ddll:load_driver(Path, Name) of
  -        ok -> ok;
  -        {error, already_loaded} -> ok;
  -        % {open_error, -10}, otherwise known as "Unknown dlload error",
  -        % could mean any of the following:
  -        % - driver does not exist in the path specified
  -        % - driver can not be read
  -        % - driver does not have all the required symbols
  -        % etc.
  -        {error, ErrorDesc} -> {error, erl_ddll:format_error(ErrorDesc)}
  +        ok ->
  +            ok;
  +        {error, already_loaded} ->
  +            ok;
  +        {error, ErrorDesc} ->
  +            {error, erl_ddll:format_error(ErrorDesc)}
       end,
  -    case Result of
  -        ok ->
  -            case erlang:open_port({spawn, Name}, []) of
  -                P when is_port(P) ->
  -                    {ok, P};
  -                Error ->
  -                    {error, Error}
  -            end;
  -        {error, Reason} ->
  -            {error, Reason}
  +    if
  +        Result =:= ok ->
  +            {ok, erlang:open_port({spawn, Name}, [])};
  +        true ->
  +            Result
       end.
   transform_data(D) ->
       D.
   %% only a port driver can perform asynchronous function calls
   %% (you might be able to put a thread pool in an Erlang port, but why bother?)
  -call_port_async(Process, Command, Msg)
  -    when is_integer(Command), is_list(Msg) ->
  -    gen_server:cast(Process, {call, Command, Msg}).
  +call_port_async(Process, Command, Message)
  +    when is_integer(Command), is_list(Message) ->
  +    gen_server:cast(Process, {call, Command, Message}).
   -else.
   -ifdef(ERL_PORT_NAME).
   local_port_name() ->
  
positive.code: 
  %% something unexpected happened when sending to the port
  handle_info({'EXIT', Port, PosixCode},
              #state{port = Port} = State)
      when is_port(Port) ->
      catch erlang:port_close(Port),
      Reason = case PosixCode of
          eacces ->
              "permission denied";
          eagain ->
              "resource temporarily unavailable";
          ebadf ->
              "bad file number";
          ebusy ->
              "file busy";
          edquot ->
              "disk quota exceeded";
          eexist ->
              "file already exists";
          efault ->
              "bad address in system call argument";
          efbig ->
              "file too large";
          eintr ->
              "interrupted system call";
          einval ->
              "invalid argument";
          eio ->
              "IO error";
          eisdir ->
              "illegal operation on a directory";
          eloop ->
              "too many levels of symbolic links";
          emfile ->
              "too many open files";
          emlink ->
              "too many links";
          enametoolong ->
              "file name too long";
          enfile ->
              "file table overflow";
          enodev ->
              "no such device";
          enoent ->
              "no such file or directory";
          enomem ->
              "not enough memory";
          enospc ->
              "no space left on device";
          enotblk ->
              "block device required";
          enotdir ->
              "not a directory";
          enotsup ->
              "operation not supported";
          enxio ->
              "no such device or address";
          eperm ->
              "not owner";
          epipe ->
              "broken pipe";
          erofs ->
              "read-only file system";
          espipe ->
              "invalid seek";
          esrch ->
              "no such process";
          estale ->
              "stale remote file handle";
          exdev ->
              "cross-domain link";
          Other when is_atom(Other) ->
              atom_to_list(Other)
      end,
      {stop, Reason, State#state{port = undefined}};
  
  handle_info(Request, State) ->
      io:format("Unknown info \"~p\"~n", [Request]),
      {noreply, State}.
  
  terminate(_, #state{port = Port}) when is_port(Port) ->
      catch erlang:port_close(Port),
      ok;
  
  terminate(_, _) ->
      ok.
  
  % problem mentioned here:
  % http://www.trapexit.org/forum/viewtopic.php?t=14295&sid=5de3c47e32136682080511d8d95d458e
  %code_change({down, Vsn}, State, Extra) ->
  %    code_change(Vsn, State, Extra);
  %code_change(Vsn, #state{last_port_name = Name,
  %                        port = Port} = State, _) when is_port(Port) ->
  %    % XXX Does not work because of the automatic driver_lock_driver() call
  %    % in erts/emulator/beam/erl_async.c at line 143
  %    %
  %    % all driver_async() calls will trigger making the linked in driver
  %    % permanent, probably to avoid the possibility of trying to
  %    % upgrade/downgrade a driver while async threads are still in use.
  %    catch erlang:port_close(Port),
  %    Result = case unload_local_port(Name) of
  %        ok ->
  %            NewName = local_port_name_prefix() ++ Vsn,
  %            case load_local_port(NewName) of
  %                {ok, Port} ->
  %                    {ok, #state{last_port_name = NewName,
  %                                port = Port}};
  %                {error, Reason} ->
  %                    {error, Reason}
  %            end;
  %        {error, Reason} ->
  %            {error, Reason}
  %    end,
  %    case Result of
  %        {ok, NewState} ->
  %            {ok, NewState};
  %        {error, R} ->
  %            io:format("error in code_change/3: ~p~n", [R]),
  %            {ok, State#state{port = undefined}}
  %    end;
  
  code_change(_, State, _) ->
      {ok, State}.
  
negative.code:     {stop, "Unknown call", State}.
  
  %% handle asynchronous function calls on the port driver
  handle_cast({call, _, Message},
              #state{port = Port} = State) ->
      case call_port(Port, Message) of
          ok ->
              ok;
          {error, Reason} ->
  