aboutsummaryrefslogtreecommitdiffstats
path: root/lib/kernel/src
diff options
context:
space:
mode:
Diffstat (limited to 'lib/kernel/src')
-rw-r--r--lib/kernel/src/Makefile16
-rw-r--r--lib/kernel/src/application.erl5
-rw-r--r--lib/kernel/src/application_controller.erl17
-rw-r--r--lib/kernel/src/code.erl86
-rw-r--r--lib/kernel/src/code_server.erl4
-rw-r--r--lib/kernel/src/disk_log.erl9
-rw-r--r--lib/kernel/src/disk_log.hrl4
-rw-r--r--lib/kernel/src/disk_log_1.erl2
-rw-r--r--lib/kernel/src/erl_ddll.erl92
-rw-r--r--lib/kernel/src/error_handler.erl2
-rw-r--r--lib/kernel/src/error_logger.erl14
-rw-r--r--lib/kernel/src/erts_debug.erl129
-rw-r--r--lib/kernel/src/file.erl20
-rw-r--r--lib/kernel/src/gen_sctp.erl7
-rw-r--r--lib/kernel/src/gen_tcp.erl8
-rw-r--r--lib/kernel/src/gen_udp.erl13
-rw-r--r--lib/kernel/src/global.erl12
-rw-r--r--lib/kernel/src/heart.erl11
-rw-r--r--lib/kernel/src/hipe_unified_loader.erl62
-rw-r--r--lib/kernel/src/inet.erl119
-rw-r--r--lib/kernel/src/inet_config.erl59
-rw-r--r--lib/kernel/src/inet_int.hrl10
-rw-r--r--lib/kernel/src/inet_parse.erl29
-rw-r--r--lib/kernel/src/kernel.appup.src12
-rw-r--r--lib/kernel/src/net_kernel.erl13
-rw-r--r--lib/kernel/src/os.erl79
-rw-r--r--lib/kernel/src/pg2.erl4
-rw-r--r--lib/kernel/src/rpc.erl6
-rw-r--r--lib/kernel/src/wrap_log_reader.erl4
29 files changed, 591 insertions, 257 deletions
diff --git a/lib/kernel/src/Makefile b/lib/kernel/src/Makefile
index 54f21eb2b8..c76ff9e2f0 100644
--- a/lib/kernel/src/Makefile
+++ b/lib/kernel/src/Makefile
@@ -1,7 +1,7 @@
#
# %CopyrightBegin%
#
-# Copyright Ericsson AB 1996-2011. All Rights Reserved.
+# Copyright Ericsson AB 1996-2012. All Rights Reserved.
#
# The contents of this file are subject to the Erlang Public License,
# Version 1.1, (the "License"); you may not use this file except in
@@ -198,13 +198,13 @@ $(EBIN)/erl_epmd.beam: $(ESRC)/erl_epmd.erl
include $(ERL_TOP)/make/otp_release_targets.mk
release_spec: opt
- $(INSTALL_DIR) $(RELSYSDIR)/src
- $(INSTALL_DATA) $(ERL_FILES) $(RELSYSDIR)/src
- $(INSTALL_DATA) $(INTERNAL_HRL_FILES) $(RELSYSDIR)/src
- $(INSTALL_DIR) $(RELSYSDIR)/include
- $(INSTALL_DATA) $(HRL_FILES) $(RELSYSDIR)/include
- $(INSTALL_DIR) $(RELSYSDIR)/ebin
- $(INSTALL_DATA) $(TARGET_FILES) $(RELSYSDIR)/ebin
+ $(INSTALL_DIR) "$(RELSYSDIR)/src"
+ $(INSTALL_DATA) $(ERL_FILES) "$(RELSYSDIR)/src"
+ $(INSTALL_DATA) $(INTERNAL_HRL_FILES) "$(RELSYSDIR)/src"
+ $(INSTALL_DIR) "$(RELSYSDIR)/include"
+ $(INSTALL_DATA) $(HRL_FILES) "$(RELSYSDIR)/include"
+ $(INSTALL_DIR) "$(RELSYSDIR)/ebin"
+ $(INSTALL_DATA) $(TARGET_FILES) "$(RELSYSDIR)/ebin"
release_docs_spec:
diff --git a/lib/kernel/src/application.erl b/lib/kernel/src/application.erl
index c299fb085c..9b7c4aa7b8 100644
--- a/lib/kernel/src/application.erl
+++ b/lib/kernel/src/application.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 1996-2011. All Rights Reserved.
+%% Copyright Ericsson AB 1996-2012. All Rights Reserved.
%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
@@ -37,8 +37,7 @@
-type application_opt() :: {'description', Description :: string()}
| {'vsn', Vsn :: string()}
| {'id', Id :: string()}
- | {'modules', [(Module :: module()) |
- {Module :: module(), Version :: term()}]}
+ | {'modules', [Module :: module()]}
| {'registered', Names :: [Name :: atom()]}
| {'applications', [Application :: atom()]}
| {'included_applications', [Application :: atom()]}
diff --git a/lib/kernel/src/application_controller.erl b/lib/kernel/src/application_controller.erl
index ebfe84463a..68cd26ec10 100644
--- a/lib/kernel/src/application_controller.erl
+++ b/lib/kernel/src/application_controller.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 1996-2011. All Rights Reserved.
+%% Copyright Ericsson AB 1996-2012. All Rights Reserved.
%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
@@ -162,7 +162,7 @@
%% appl_opt() = {description, string()} |
%% {vsn, string()} |
%% {id, string()}, |
-%% {modules, [Module|{Module,Vsn}]} |
+%% {modules, [Module]} |
%% {registered, [atom()]} |
%% {applications, [atom()]} |
%% {included_applications, [atom()]} |
@@ -172,7 +172,6 @@
%% {maxP, integer()|infinity} |
%% {mod, {Module, term()}}
%% Module = atom()
-%% Vsn = term()
%% Purpose: Starts the application_controller. This process starts all
%% application masters for the applications.
%% The kernel application is the only application that is
@@ -446,7 +445,7 @@ get_application_module(Module) ->
get_application_module(Module, AppModules).
get_application_module(Module, [[AppName, Modules]|AppModules]) ->
- case in_modules(Module, Modules) of
+ case lists:member(Module, Modules) of
true ->
{ok, AppName};
false ->
@@ -455,16 +454,6 @@ get_application_module(Module, [[AppName, Modules]|AppModules]) ->
get_application_module(_Module, []) ->
undefined.
-%% 'modules' key in .app is a list of Module or {Module,Vsn}
-in_modules(Module, [Module|_Modules]) ->
- true;
-in_modules(Module, [{Module, _Vsn}|_Modules]) ->
- true;
-in_modules(Module, [_Module|Modules]) ->
- in_modules(Module, Modules);
-in_modules(_Module, []) ->
- false.
-
permit_application(ApplName, Flag) ->
gen_server:call(?AC,
{permit_application, ApplName, Flag},
diff --git a/lib/kernel/src/code.erl b/lib/kernel/src/code.erl
index b7fda69ce0..c808ac7cb7 100644
--- a/lib/kernel/src/code.erl
+++ b/lib/kernel/src/code.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 1996-2011. All Rights Reserved.
+%% Copyright Ericsson AB 1996-2012. All Rights Reserved.
%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
@@ -63,53 +63,13 @@
which/1,
where_is_file/1,
where_is_file/2,
- set_primary_archive/3,
+ set_primary_archive/4,
clash/0]).
-export_type([load_error_rsn/0, load_ret/0]).
-include_lib("kernel/include/file.hrl").
-%% User interface.
-%%
-%% objfile_extension() -> ".beam"
-%% get_path() -> [Dir]
-%% set_path([Dir]) -> true | {error, bad_directory | bad_path}
-%% add_path(Dir) -> true | {error, bad_directory}
-%% add_patha(Dir) -> true | {error, bad_directory}
-%% add_pathz(Dir) -> true | {error, bad_directory}
-%% add_paths([Dir]) -> ok
-%% add_pathsa([Dir]) -> ok
-%% add_pathsz([Dir]) -> ok
-%% del_path(Dir) -> boolean() | {error, bad_name}
-%% replace_path(Name, Dir) -> true | {error, bad_directory | bad_name
-%% | {badarg,_}}
-%% load_file(Module) -> {module, Module} | {error, What :: atom()}
-%% load_abs(File) -> {module, Module} | {error, What :: atom()}
-%% load_abs(File, Module) -> {module, Module} | {error, What :: atom()}
-%% load_binary(Module, File, Bin)-> {module, Module} | {error, What :: atom()}
-%% ensure_loaded(Module) -> {module, Module} | {error, What :: atom()}
-%% delete(Module) -> boolean()
-%% purge(Module) -> boolean() kills all procs running old code
-%% soft_purge(Module) -> boolean()
-%% is_loaded(Module) -> {file, loaded_filename()} | false
-%% all_loaded() -> [{Module, loaded_filename()}]
-%% get_object_code(Module) -> {Module, Bin, Filename} | error
-%% stop() -> no_return()
-%% root_dir() -> Dir
-%% compiler_dir() -> Dir
-%% lib_dir() -> Dir
-%% lib_dir(Application) -> Dir | {error, bad_name}
-%% priv_dir(Application) -> Dir | {error, bad_name}
-%% stick_dir(Dir) -> ok | error
-%% unstick_dir(Dir) -> ok | error
-%% stick_mod(Module) -> true
-%% unstick_mod(Module) -> true
-%% is_sticky(Module) -> boolean()
-%% which(Module) -> Filename | loaded_ret_atoms() | non_existing
-%% set_primary_archive((FileName, Bin, FileInfo) -> ok | {error, Reason}
-%% clash() -> ok prints out number of clashes
-
%%----------------------------------------------------------------------------
%% Some types for basic exported functions of this module
%%----------------------------------------------------------------------------
@@ -125,6 +85,39 @@
-type loaded_ret_atoms() :: 'cover_compiled' | 'preloaded'.
-type loaded_filename() :: (Filename :: file:filename()) | loaded_ret_atoms().
+%%% BIFs
+
+-export([get_chunk/2, is_module_native/1, make_stub_module/3, module_md5/1]).
+
+-spec get_chunk(Bin, Chunk) ->
+ binary() | undefined when
+ Bin :: binary(),
+ Chunk :: string().
+
+get_chunk(_, _) ->
+ erlang:nif_error(undef).
+
+-spec is_module_native(Module) -> true | false | undefined when
+ Module :: module().
+
+is_module_native(_) ->
+ erlang:nif_error(undef).
+
+-spec make_stub_module(Module, Beam, Info) -> Module when
+ Module :: module(),
+ Beam :: binary(),
+ Info :: {list(), list()}.
+
+make_stub_module(_, _, _) ->
+ erlang:nif_error(undef).
+
+-spec module_md5(binary()) -> binary() | undefined.
+
+module_md5(_) ->
+ erlang:nif_error(undef).
+
+%%% End of BIFs
+
%%----------------------------------------------------------------------------
%% User interface
%%----------------------------------------------------------------------------
@@ -481,13 +474,16 @@ where_is_file(Path, File) when is_list(Path), is_list(File) ->
-spec set_primary_archive(ArchiveFile :: file:filename(),
ArchiveBin :: binary(),
- FileInfo :: file:file_info())
+ FileInfo :: file:file_info(),
+ ParserFun :: fun())
-> 'ok' | {'error', atom()}.
-set_primary_archive(ArchiveFile0, ArchiveBin, #file_info{} = FileInfo)
+set_primary_archive(ArchiveFile0, ArchiveBin, #file_info{} = FileInfo,
+ ParserFun)
when is_list(ArchiveFile0), is_binary(ArchiveBin) ->
ArchiveFile = filename:absname(ArchiveFile0),
- case call({set_primary_archive, ArchiveFile, ArchiveBin, FileInfo}) of
+ case call({set_primary_archive, ArchiveFile, ArchiveBin, FileInfo,
+ ParserFun}) of
{ok, []} ->
ok;
{ok, _Mode, Ebins} ->
diff --git a/lib/kernel/src/code_server.erl b/lib/kernel/src/code_server.erl
index a2db7c9790..00ad923466 100644
--- a/lib/kernel/src/code_server.erl
+++ b/lib/kernel/src/code_server.erl
@@ -394,8 +394,8 @@ handle_call(stop,{_From,_Tag}, S) ->
handle_call({is_cached,_File}, {_From,_Tag}, S=#state{cache=no_cache}) ->
{reply, no, S};
-handle_call({set_primary_archive, File, ArchiveBin, FileInfo}, {_From,_Tag}, S=#state{mode=Mode}) ->
- case erl_prim_loader:set_primary_archive(File, ArchiveBin, FileInfo) of
+handle_call({set_primary_archive, File, ArchiveBin, FileInfo, ParserFun}, {_From,_Tag}, S=#state{mode=Mode}) ->
+ case erl_prim_loader:set_primary_archive(File, ArchiveBin, FileInfo, ParserFun) of
{ok, Files} ->
{reply, {ok, Mode, Files}, S};
{error, _Reason} = Error ->
diff --git a/lib/kernel/src/disk_log.erl b/lib/kernel/src/disk_log.erl
index f5f972c112..1513fdaec0 100644
--- a/lib/kernel/src/disk_log.erl
+++ b/lib/kernel/src/disk_log.erl
@@ -44,6 +44,8 @@
%% To be used for debugging only:
-export([pid2name/1]).
+-export_type([continuation/0]).
+
-type dlog_state_error() :: 'ok' | {'error', term()}.
-record(state, {queue = [],
@@ -282,7 +284,8 @@ change_notify(Log, Pid, NewNotify) ->
-spec change_header(Log, Header) -> 'ok' | {'error', Reason} when
Log :: log(),
- Header :: {head, dlog_head_opt()} | {head_func, mfa()},
+ Header :: {head, dlog_head_opt()}
+ | {head_func, MFA :: {atom(), atom(), list()}},
Reason :: no_such_log | nonode | {read_only_mode, Log}
| {blocked_log, Log} | {badarg, head}.
change_header(Log, NewHead) ->
@@ -336,7 +339,9 @@ format_error(Error) ->
ok | {blocked, QueueLogRecords :: boolean()}}
| {node, Node :: node()}
| {distributed, Dist :: local | [node()]}
- | {head, Head :: none | {head, term()} | mfa()}
+ | {head, Head :: none
+ | {head, term()}
+ | (MFA :: {atom(), atom(), list()})}
| {no_written_items, NoWrittenItems ::non_neg_integer()}
| {full, Full :: boolean}
| {no_current_bytes, non_neg_integer()}
diff --git a/lib/kernel/src/disk_log.hrl b/lib/kernel/src/disk_log.hrl
index 259967650f..242a25a7a6 100644
--- a/lib/kernel/src/disk_log.hrl
+++ b/lib/kernel/src/disk_log.hrl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 1997-2011. All Rights Reserved.
+%% Copyright Ericsson AB 1997-2012. All Rights Reserved.
%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
@@ -74,7 +74,7 @@
| {distributed, Nodes :: [node()]}
| {notify, boolean()}
| {head, Head :: dlog_head_opt()}
- | {head_func, mfa()}
+ | {head_func, MFA :: {atom(), atom(), list()}}
| {mode, Mode :: dlog_mode()}.
-type dlog_options() :: [dlog_option()].
-type dlog_repair() :: 'truncate' | boolean().
diff --git a/lib/kernel/src/disk_log_1.erl b/lib/kernel/src/disk_log_1.erl
index 266df84a03..0cb1ed579a 100644
--- a/lib/kernel/src/disk_log_1.erl
+++ b/lib/kernel/src/disk_log_1.erl
@@ -1495,7 +1495,7 @@ fwrite_close2(Fd, FileName, B) ->
pwrite_close2(Fd, FileName, Position, B) ->
case file:pwrite(Fd, Position, B) of
ok -> ok;
- Error -> file_error(FileName, {error, Error})
+ {error,Error} -> file_error(FileName, {error, Error})
end.
position2(Fd, FileName, Pos) ->
diff --git a/lib/kernel/src/erl_ddll.erl b/lib/kernel/src/erl_ddll.erl
index 646cac99c5..e03d280cd8 100644
--- a/lib/kernel/src/erl_ddll.erl
+++ b/lib/kernel/src/erl_ddll.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 1997-2011. All Rights Reserved.
+%% Copyright Ericsson AB 1997-2012. All Rights Reserved.
%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
@@ -30,9 +30,97 @@
%%----------------------------------------------------------------------------
-type path() :: string() | atom().
--type driver() :: string() | atom().
+-type driver() :: iolist() | atom().
%%----------------------------------------------------------------------------
+%%% BIFs
+
+-export([demonitor/1, info/2, format_error_int/1, monitor/2,
+ try_load/3, try_unload/2, loaded_drivers/0]).
+
+-spec demonitor(MonitorRef) -> ok when
+ MonitorRef :: reference().
+
+demonitor(_) ->
+ erlang:nif_error(undef).
+
+-spec info(Name, Tag) -> Value when
+ Name :: driver(),
+ Tag :: processes | driver_options | port_count | linked_in_driver
+ | permanent | awaiting_load | awaiting_unload,
+ Value :: term().
+
+info(_, _) ->
+ erlang:nif_error(undef).
+
+-spec format_error_int(ErrSpec) -> string() when
+ ErrSpec :: term().
+
+format_error_int(_) ->
+ erlang:nif_error(undef).
+
+-spec monitor(Tag, Item) -> MonitorRef when
+ Tag :: driver,
+ Item :: {Name, When},
+ Name :: driver(),
+ When :: loaded | unloaded | unloaded_only,
+ MonitorRef :: reference().
+
+monitor(_, _) ->
+ erlang:nif_error(undef).
+
+-spec try_load(Path, Name, OptionList) ->
+ {ok,Status} |
+ {ok, PendingStatus, Ref} |
+ {error, ErrorDesc} when
+ Path :: path(),
+ Name :: driver(),
+ OptionList :: [Option],
+ Option :: {driver_options, DriverOptionList}
+ | {monitor, MonitorOption}
+ | {reload, ReloadOption},
+ DriverOptionList :: [DriverOption],
+ DriverOption :: kill_ports,
+ MonitorOption :: pending_driver | pending,
+ ReloadOption :: pending_driver | pending,
+ Status :: loaded | already_loaded | PendingStatus,
+ PendingStatus :: pending_driver | pending_process,
+ Ref :: reference(),
+ ErrorDesc :: ErrorAtom | OpaqueError,
+ ErrorAtom :: linked_in_driver | inconsistent | permanent
+ | not_loaded_by_this_process | not_loaded
+ | pending_reload | pending_process,
+ OpaqueError :: term().
+
+try_load(_, _, _) ->
+ erlang:nif_error(undef).
+
+-spec try_unload(Name, OptionList) ->
+ {ok, Status} |
+ {ok, PendingStatus, Ref} |
+ {error, ErrorAtom} when
+ Name :: driver(),
+ OptionList :: [Option],
+ Option :: {monitor, MonitorOption} | kill_ports,
+ MonitorOption :: pending_driver | pending,
+ Status :: unloaded | PendingStatus,
+ PendingStatus :: pending_driver | pending_process,
+ Ref :: reference(),
+ ErrorAtom :: linked_in_driver | not_loaded |
+ not_loaded_by_this_process | permanent.
+
+try_unload(_, _) ->
+ erlang:nif_error(undef).
+
+-spec loaded_drivers() -> {ok, Drivers} when
+ Drivers :: [Driver],
+ Driver :: string().
+
+loaded_drivers() ->
+ erlang:nif_error(undef).
+
+%%% End of BIFs
+
-spec start() -> {'error', {'already_started', 'undefined'}}.
diff --git a/lib/kernel/src/error_handler.erl b/lib/kernel/src/error_handler.erl
index a67b11a888..f8bc5f499c 100644
--- a/lib/kernel/src/error_handler.erl
+++ b/lib/kernel/src/error_handler.erl
@@ -90,7 +90,7 @@ int() -> int.
crash(Fun, Args) ->
crash({Fun,Args,[]}).
--spec crash(atom(), atom(), arity()) -> no_return().
+-spec crash(atom(), atom(), arity() | [term()]) -> no_return().
crash(M, F, A) ->
crash({M,F,A,[]}).
diff --git a/lib/kernel/src/error_logger.erl b/lib/kernel/src/error_logger.erl
index f94cca000f..92c1eb80dc 100644
--- a/lib/kernel/src/error_logger.erl
+++ b/lib/kernel/src/error_logger.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 1996-2011. All Rights Reserved.
+%% Copyright Ericsson AB 1996-2012. All Rights Reserved.
%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
@@ -42,6 +42,18 @@
-type state() :: {non_neg_integer(), non_neg_integer(), [term()]}.
+%%% BIF
+
+-export([warning_map/0]).
+
+-spec warning_map() -> Tag when
+ Tag :: error | warning | info.
+
+warning_map() ->
+ erlang:nif_error(undef).
+
+%%% End of BIF
+
%%-----------------------------------------------------------------
-spec start() -> {'ok', pid()} | {'error', any()}.
diff --git a/lib/kernel/src/erts_debug.erl b/lib/kernel/src/erts_debug.erl
index b8871e0d45..6654cd9ee7 100644
--- a/lib/kernel/src/erts_debug.erl
+++ b/lib/kernel/src/erts_debug.erl
@@ -28,6 +28,135 @@
%% same/2
%% flat_size/1
+%%% BIFs
+
+-export([breakpoint/2, disassemble/1, display/1, dist_ext_to_term/2,
+ dump_monitors/1, dump_links/1, flat_size/1,
+ get_internal_state/1, instructions/0, lock_counters/1,
+ same/2, set_internal_state/2]).
+
+-spec breakpoint(MFA, Flag) -> non_neg_integer() when
+ MFA :: {Module :: module(),
+ Function :: atom(),
+ Arity :: arity() | '_'},
+ Flag :: boolean().
+
+breakpoint(_, _) ->
+ erlang:nif_error(undef).
+
+-spec disassemble(What) -> false | undef | Result when
+ What :: MFA | Address,
+ Result :: {Address, Code, MFA},
+ MFA :: mfa(),
+ Address :: non_neg_integer(),
+ Code :: binary().
+
+disassemble(_) ->
+ erlang:nif_error(undef).
+
+-spec display(Term) -> string() when
+ Term :: term().
+
+display(_) ->
+ erlang:nif_error(undef).
+
+-spec dist_ext_to_term(Tuple, Binary) -> term() when
+ Tuple :: tuple(),
+ Binary :: binary().
+
+dist_ext_to_term(_, _) ->
+ erlang:nif_error(undef).
+
+-spec dump_monitors(Id) -> true when
+ Id :: pid() | atom().
+
+dump_monitors(_) ->
+ erlang:nif_error(undef).
+
+-spec dump_links(Id) -> true when
+ Id :: pid() | port() | atom().
+
+dump_links(_) ->
+ erlang:nif_error(undef).
+
+-spec flat_size(Term) -> non_neg_integer() when
+ Term :: term().
+
+flat_size(_) ->
+ erlang:nif_error(undef).
+
+-spec get_internal_state(W) -> term() when
+ W :: reds_left | node_and_dist_references | monitoring_nodes
+ | next_pid | 'DbTable_words' | check_io_debug
+ | process_info_args | processes | processes_bif_info
+ | max_atom_out_cache_index | nbalance | available_internal_state
+ | force_heap_frags | memory
+ | {process_status, pid()}
+ | {link_list, pid() | port() | node()}
+ | {monitor_list, pid() | node()}
+ | {channel_number, non_neg_integer()}
+ | {have_pending_exit, pid() | port() | atom()}
+ | {binary_info, binary()}
+ | {term_to_binary_no_funs, term()}
+ | {dist_port, port()}
+ | {atom_out_cache_index, atom()}
+ | {fake_scheduler_bindings,
+ default_bind | spread | processor_spread | thread_spread
+ | thread_no_node_processor_spread | no_node_processor_spread
+ | no_node_thread_spread | no_spread | unbound}
+ | {reader_groups_map, non_neg_integer()}.
+
+get_internal_state(_) ->
+ erlang:nif_error(undef).
+
+-spec instructions() -> [string()].
+
+instructions() ->
+ erlang:nif_error(undef).
+
+-spec lock_counters(info) -> term();
+ (clear) -> ok;
+ ({copy_save, boolean()}) -> boolean();
+ ({process_locks, boolean()}) -> boolean().
+
+lock_counters(_) ->
+ erlang:nif_error(undef).
+
+-spec same(Term1, Term2) -> boolean() when
+ Term1 :: term(),
+ Term2 :: term().
+
+same(_, _) ->
+ erlang:nif_error(undef).
+
+-spec set_internal_state(available_internal_state, boolean()) -> boolean();
+ (reds_left, non_neg_integer()) -> true;
+ (block, non_neg_integer()) -> true;
+ (sleep, non_neg_integer()) -> true;
+ (block_scheduler, non_neg_integer()) -> true;
+ (next_pid, non_neg_integer()) -> false | integer();
+ (force_gc, pid() | atom()) -> boolean();
+ (send_fake_exit_signal, {pid() | port(), pid(), term()}) -> dead | message | unaffected | exit;
+ (colliding_names, {atom(), non_neg_integer()}) ->
+ [atom()];
+ (binary_loop_limit, default) -> -1;
+ (binary_loop_limit, non_neg_integer()) -> non_neg_integer();
+ (re_loop_limit, default) -> -1;
+ (re_loop_limit, non_neg_integer()) -> non_neg_integer();
+ (unicode_loop_limit, default) -> -1;
+ (unicode_loop_limit, non_neg_integer()) -> non_neg_integer();
+ (hipe_test_reschedule_suspend, term()) -> nil();
+ (hipe_test_reschedule_resume, pid() | port()) -> boolean();
+ (test_long_gc_sleep, non_neg_integer()) -> true;
+ (kill_dist_connection, port()) -> boolean();
+ (not_running_optimization, boolean()) -> boolean();
+ (wait, deallocations) -> ok.
+
+set_internal_state(_, _) ->
+ erlang:nif_error(undef).
+
+%%% End of BIFs
+
%% size(Term)
%% Returns the size of Term in actual heap words. Shared subterms are
%% counted once. Example: If A = [a,b], B =[A,A] then size(B) returns 8,
diff --git a/lib/kernel/src/file.erl b/lib/kernel/src/file.erl
index d8033ee192..22af38c598 100644
--- a/lib/kernel/src/file.erl
+++ b/lib/kernel/src/file.erl
@@ -111,6 +111,24 @@
-type sendfile_option() :: {chunk_size, non_neg_integer()}.
-type file_info_option() :: {'time', 'local'} | {'time', 'universal'}
| {'time', 'posix'}.
+%%% BIFs
+
+-export([file_info/1, native_name_encoding/0]).
+
+-spec file_info(Filename) -> {ok, FileInfo} | {error, Reason} when
+ Filename :: name(),
+ FileInfo :: file_info(),
+ Reason :: posix() | badarg.
+
+file_info(_) ->
+ erlang:nif_error(undef).
+
+-spec native_name_encoding() -> latin1 | utf8.
+
+native_name_encoding() ->
+ erlang:nif_error(undef).
+
+%%% End of BIFs
%%%-----------------------------------------------------------------
@@ -1258,7 +1276,7 @@ sendfile_fallback_int(File, Sock, Bytes, ChunkSize, BytesSent)
when Bytes > BytesSent; Bytes == 0 ->
Size = if Bytes == 0 ->
ChunkSize;
- (Bytes - BytesSent + ChunkSize) > 0 ->
+ (Bytes - BytesSent) < ChunkSize ->
Bytes - BytesSent;
true ->
ChunkSize
diff --git a/lib/kernel/src/gen_sctp.erl b/lib/kernel/src/gen_sctp.erl
index d8954f0cf7..74ad192802 100644
--- a/lib/kernel/src/gen_sctp.erl
+++ b/lib/kernel/src/gen_sctp.erl
@@ -44,6 +44,7 @@
{priority, non_neg_integer()} |
{recbuf, non_neg_integer()} |
{reuseaddr, boolean()} |
+ {ipv6_v6only, boolean()} |
{sctp_adaptation_layer, #sctp_setadaptation{}} |
{sctp_associnfo, #sctp_assocparams{}} |
{sctp_autoclose, non_neg_integer()} |
@@ -72,6 +73,7 @@
priority |
recbuf |
reuseaddr |
+ ipv6_v6only |
sctp_adaptation_layer |
sctp_associnfo |
sctp_autoclose |
@@ -425,9 +427,10 @@ error_string(X) ->
erlang:error(badarg, [X]).
--spec controlling_process(Socket, Pid) -> ok when
+-spec controlling_process(Socket, Pid) -> ok | {error, Reason} when
Socket :: sctp_socket(),
- Pid :: pid().
+ Pid :: pid(),
+ Reason :: closed | not_owner | inet:posix().
controlling_process(S, Pid) when is_port(S), is_pid(Pid) ->
inet:udp_controlling_process(S, Pid);
diff --git a/lib/kernel/src/gen_tcp.erl b/lib/kernel/src/gen_tcp.erl
index 519c1bb8b4..ec13ab6d2e 100644
--- a/lib/kernel/src/gen_tcp.erl
+++ b/lib/kernel/src/gen_tcp.erl
@@ -31,7 +31,6 @@
-type option() ::
{active, true | false | once} |
- {bit8, clear | set | on | off} |
{buffer, non_neg_integer()} |
{delay_send, boolean()} |
{deliver, port | term} |
@@ -60,10 +59,10 @@
{send_timeout, non_neg_integer() | infinity} |
{send_timeout_close, boolean()} |
{sndbuf, non_neg_integer()} |
- {tos, non_neg_integer()}.
+ {tos, non_neg_integer()} |
+ {ipv6_v6only, boolean()}.
-type option_name() ::
active |
- bit8 |
buffer |
delay_send |
deliver |
@@ -91,7 +90,8 @@
send_timeout |
send_timeout_close |
sndbuf |
- tos.
+ tos |
+ ipv6_v6only.
-type connect_option() ::
{ip, inet:ip_address()} |
{fd, Fd :: non_neg_integer()} |
diff --git a/lib/kernel/src/gen_udp.erl b/lib/kernel/src/gen_udp.erl
index 8688799ae9..c5a1173575 100644
--- a/lib/kernel/src/gen_udp.erl
+++ b/lib/kernel/src/gen_udp.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 1997-2011. All Rights Reserved.
+%% Copyright Ericsson AB 1997-2012. All Rights Reserved.
%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
@@ -47,7 +47,8 @@
{recbuf, non_neg_integer()} |
{reuseaddr, boolean()} |
{sndbuf, non_neg_integer()} |
- {tos, non_neg_integer()}.
+ {tos, non_neg_integer()} |
+ {ipv6_v6only, boolean()}.
-type option_name() ::
active |
broadcast |
@@ -69,7 +70,8 @@
recbuf |
reuseaddr |
sndbuf |
- tos.
+ tos |
+ ipv6_v6only.
-type socket() :: port().
-export_type([option/0, option_name/0]).
@@ -185,9 +187,10 @@ connect(S, Address, Port) when is_port(S) ->
Error
end.
--spec controlling_process(Socket, Pid) -> ok when
+-spec controlling_process(Socket, Pid) -> ok | {error, Reason} when
Socket :: socket(),
- Pid :: pid().
+ Pid :: pid(),
+ Reason :: closed | not_owner | inet:posix().
controlling_process(S, NewOwner) ->
inet:udp_controlling_process(S, NewOwner).
diff --git a/lib/kernel/src/global.erl b/lib/kernel/src/global.erl
index 36cb713ee1..b24a9d5eac 100644
--- a/lib/kernel/src/global.erl
+++ b/lib/kernel/src/global.erl
@@ -232,7 +232,8 @@ register_name(Name, Pid) when is_pid(Pid) ->
Name :: term(),
Pid :: pid(),
Resolve :: method().
-register_name(Name, Pid, Method) when is_pid(Pid) ->
+register_name(Name, Pid, Method0) when is_pid(Pid) ->
+ Method = allow_tuple_fun(Method0),
Fun = fun(Nodes) ->
case (where(Name) =:= undefined) andalso check_dupname(Name, Pid) of
true ->
@@ -290,7 +291,8 @@ re_register_name(Name, Pid) when is_pid(Pid) ->
Name :: term(),
Pid :: pid(),
Resolve :: method().
-re_register_name(Name, Pid, Method) when is_pid(Pid) ->
+re_register_name(Name, Pid, Method0) when is_pid(Pid) ->
+ Method = allow_tuple_fun(Method0),
Fun = fun(Nodes) ->
gen_server:multi_call(Nodes,
global_name_server,
@@ -2218,3 +2220,9 @@ intersection(_, []) ->
[];
intersection(L1, L2) ->
L1 -- (L1 -- L2).
+
+%% Support legacy tuple funs as resolve functions.
+allow_tuple_fun({M, F}) when is_atom(M), is_atom(F) ->
+ fun M:F/3;
+allow_tuple_fun(Fun) when is_function(Fun, 3) ->
+ Fun.
diff --git a/lib/kernel/src/heart.erl b/lib/kernel/src/heart.erl
index 255ae4e51b..87cb9d7f51 100644
--- a/lib/kernel/src/heart.erl
+++ b/lib/kernel/src/heart.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 1996-2011. All Rights Reserved.
+%% Copyright Ericsson AB 1996-2012. All Rights Reserved.
%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
@@ -18,6 +18,10 @@
%%
-module(heart).
+-compile(no_native).
+% 'no_native' as part of a crude fix to make init:restart/0 work by clearing
+% all hipe inter-module information (hipe_mfa_info's in hipe_bif0.c).
+
%%%--------------------------------------------------------------------
%%% This is a rewrite of pre_heart from BS.3.
%%%
@@ -38,9 +42,11 @@
-define(CLEAR_CMD, 5).
-define(GET_CMD, 6).
-define(HEART_CMD, 7).
+-define(PREPARING_CRASH, 8). % Used in beam vm
-define(TIMEOUT, 5000).
-define(CYCLE_TIMEOUT, 10000).
+-define(HEART_PORT_NAME, heart_port).
%%---------------------------------------------------------------------
@@ -126,6 +132,8 @@ start_portprogram() ->
Port when is_port(Port) ->
case wait_ack(Port) of
ok ->
+ %% register port so the vm can find it if need be
+ register(?HEART_PORT_NAME, Port),
{ok, Port};
{error, Reason} ->
report_problem({{port_problem, Reason},
@@ -221,6 +229,7 @@ no_reboot_shutdown(Port) ->
end.
do_cycle_port_program(Caller, Parent, Port, Cmd) ->
+ unregister(?HEART_PORT_NAME),
case catch start_portprogram() of
{ok, NewPort} ->
send_shutdown(Port),
diff --git a/lib/kernel/src/hipe_unified_loader.erl b/lib/kernel/src/hipe_unified_loader.erl
index 8b3aa0286d..06d404905d 100644
--- a/lib/kernel/src/hipe_unified_loader.erl
+++ b/lib/kernel/src/hipe_unified_loader.erl
@@ -34,6 +34,13 @@
-module(hipe_unified_loader).
+-compile(no_native).
+% 'no_native' is a workaround to avoid "The code server called unloaded module"
+% caused by Mod:module_info(exports) in patch_to_emu_step1() called by post_beam_load.
+% Reproducable with hipelibs and asn1_SUITE.
+% I think the real solution would be to let BIF erlang:load_module/2 redirect all
+% hipe calls to the module and thereby remove post_beam_load.
+
-export([chunk_name/1,
%% Only the code and code_server modules may call the entries below!
load_native_code/2,
@@ -330,11 +337,16 @@ exports(ExportMap, BaseAddress) ->
exports(ExportMap, BaseAddress, [], []).
exports([Offset,M,F,A,IsClosure,IsExported|Rest], BaseAddress, MFAs, Addresses) ->
- MFA = {M,F,A},
- Address = BaseAddress + Offset,
- FunDef = #fundef{address=Address, mfa=MFA, is_closure=IsClosure,
- is_exported=IsExported},
- exports(Rest, BaseAddress, [MFA|MFAs], [FunDef|Addresses]);
+ case IsExported andalso erlang:is_builtin(M, F, A) of
+ true ->
+ exports(Rest, BaseAddress, MFAs, Addresses);
+ _false ->
+ MFA = {M,F,A},
+ Address = BaseAddress + Offset,
+ FunDef = #fundef{address=Address, mfa=MFA, is_closure=IsClosure,
+ is_exported=IsExported},
+ exports(Rest, BaseAddress, [MFA|MFAs], [FunDef|Addresses])
+ end;
exports([], _, MFAs, Addresses) ->
{MFAs, Addresses}.
@@ -498,7 +510,7 @@ patch_offset(Type, Data, Address, ConstAndZone, Addresses) ->
Atom = Data,
patch_atom(Address, Atom);
sdesc ->
- patch_sdesc(Data, Address, ConstAndZone);
+ patch_sdesc(Data, Address, ConstAndZone, Addresses);
x86_abs_pcrel ->
patch_instr(Address, Data, x86_abs_pcrel)
%% _ ->
@@ -511,14 +523,16 @@ patch_atom(Address, Atom) ->
patch_instr(Address, hipe_bifs:atom_to_word(Atom), atom).
patch_sdesc(?STACK_DESC(SymExnRA, FSize, Arity, Live),
- Address, {_ConstMap2,CodeAddress}) ->
+ Address, {_ConstMap2,CodeAddress}, _Addresses) ->
ExnRA =
case SymExnRA of
[] -> 0; % No catch
LabelOffset -> CodeAddress + LabelOffset
end,
?ASSERT(assert_local_patch(Address)),
- hipe_bifs:enter_sdesc({Address, ExnRA, FSize, Arity, Live}).
+ DBG_MFA = ?IF_DEBUG(address_to_mfa_lth(Address, _Addresses), {undefined,undefined,0}),
+ hipe_bifs:enter_sdesc({Address, ExnRA, FSize, Arity, Live, DBG_MFA}).
+
%%----------------------------------------------------------------
%% Handle a 'load_address'-type patch.
@@ -725,7 +739,7 @@ find_const(ConstNo, []) ->
%%
add_ref(CalleeMFA, Address, Addresses, RefType, Trampoline, RemoteOrLocal) ->
- CallerMFA = address_to_mfa(Address, Addresses),
+ CallerMFA = address_to_mfa_lth(Address, Addresses),
%% just a sanity assertion below
true = case RemoteOrLocal of
local ->
@@ -738,11 +752,31 @@ add_ref(CalleeMFA, Address, Addresses, RefType, Trampoline, RemoteOrLocal) ->
%% io:format("Adding ref ~w\n",[{CallerMFA, CalleeMFA, Address, RefType}]),
hipe_bifs:add_ref(CalleeMFA, {CallerMFA,Address,RefType,Trampoline,RemoteOrLocal}).
-address_to_mfa(Address, [#fundef{address=Adr, mfa=MFA}|_Rest]) when Address >= Adr -> MFA;
-address_to_mfa(Address, [_ | Rest]) -> address_to_mfa(Address, Rest);
-address_to_mfa(Address, []) ->
- ?error_msg("Local adddress not found ~w\n",[Address]),
- exit({?MODULE, local_address_not_found}).
+% For FunDefs sorted from low to high addresses
+address_to_mfa_lth(Address, FunDefs) ->
+ case address_to_mfa_lth(Address, FunDefs, false) of
+ false ->
+ ?error_msg("Local adddress not found ~w\n",[Address]),
+ exit({?MODULE, local_address_not_found});
+ MFA ->
+ MFA
+ end.
+
+address_to_mfa_lth(Address, [#fundef{address=Adr, mfa=MFA}|Rest], Prev) ->
+ if Address < Adr ->
+ Prev;
+ true ->
+ address_to_mfa_lth(Address, Rest, MFA)
+ end;
+address_to_mfa_lth(_Address, [], Prev) ->
+ Prev.
+
+% For FunDefs sorted from high to low addresses
+%% address_to_mfa_htl(Address, [#fundef{address=Adr, mfa=MFA}|_Rest]) when Address >= Adr -> MFA;
+%% address_to_mfa_htl(Address, [_ | Rest]) -> address_to_mfa_htl(Address, Rest);
+%% address_to_mfa_htl(Address, []) ->
+%% ?error_msg("Local adddress not found ~w\n",[Address]),
+%% exit({?MODULE, local_address_not_found}).
%%----------------------------------------------------------------
%% Change callers of the given module to instead trap to BEAM.
diff --git a/lib/kernel/src/inet.erl b/lib/kernel/src/inet.erl
index e791bb135f..9670271b2e 100644
--- a/lib/kernel/src/inet.erl
+++ b/lib/kernel/src/inet.erl
@@ -30,7 +30,9 @@
ifget/3, ifget/2, ifset/3, ifset/2,
getstat/1, getstat/2,
ip/1, stats/0, options/0,
- pushf/3, popf/1, close/1, gethostname/0, gethostname/1]).
+ pushf/3, popf/1, close/1, gethostname/0, gethostname/1,
+ parse_ipv4_address/1, parse_ipv6_address/1, parse_ipv4strict_address/1,
+ parse_ipv6strict_address/1, parse_address/1, parse_strict_address/1]).
-export([connect_options/2, listen_options/2, udp_options/2, sctp_options/2]).
@@ -527,16 +529,58 @@ getservbyname(Name, Protocol) when is_atom(Name) ->
Error -> Error
end.
+-spec parse_ipv4_address(Address) ->
+ {ok, IPv4Address} | {error, einval} when
+ Address :: string(),
+ IPv4Address :: ip_address().
+parse_ipv4_address(Addr) ->
+ inet_parse:ipv4_address(Addr).
+
+-spec parse_ipv6_address(Address) ->
+ {ok, IPv6Address} | {error, einval} when
+ Address :: string(),
+ IPv6Address :: ip_address().
+parse_ipv6_address(Addr) ->
+ inet_parse:ipv6_address(Addr).
+
+-spec parse_ipv4strict_address(Address) ->
+ {ok, IPv4Address} | {error, einval} when
+ Address :: string(),
+ IPv4Address :: ip_address().
+parse_ipv4strict_address(Addr) ->
+ inet_parse:ipv4strict_address(Addr).
+
+-spec parse_ipv6strict_address(Address) ->
+ {ok, IPv6Address} | {error, einval} when
+ Address :: string(),
+ IPv6Address :: ip_address().
+parse_ipv6strict_address(Addr) ->
+ inet_parse:ipv6strict_address(Addr).
+
+-spec parse_address(Address) ->
+ {ok, IPAddress} | {error, einval} when
+ Address :: string(),
+ IPAddress :: ip_address().
+parse_address(Addr) ->
+ inet_parse:address(Addr).
+
+-spec parse_strict_address(Address) ->
+ {ok, IPAddress} | {error, einval} when
+ Address :: string(),
+ IPAddress :: ip_address().
+parse_strict_address(Addr) ->
+ inet_parse:strict_address(Addr).
+
%% Return a list of available options
options() ->
[
tos, priority, reuseaddr, keepalive, dontroute, linger,
- broadcast, sndbuf, recbuf, nodelay,
+ broadcast, sndbuf, recbuf, nodelay, ipv6_v6only,
buffer, header, active, packet, deliver, mode,
multicast_if, multicast_ttl, multicast_loop,
exit_on_close, high_watermark, low_watermark,
high_msgq_watermark, low_msgq_watermark,
- bit8, send_timeout, send_timeout_close
+ send_timeout, send_timeout_close
].
%% Return a list of statistics options
@@ -554,8 +598,7 @@ connect_options() ->
[tos, priority, reuseaddr, keepalive, linger, sndbuf, recbuf, nodelay,
header, active, packet, packet_size, buffer, mode, deliver,
exit_on_close, high_watermark, low_watermark, high_msgq_watermark,
- low_msgq_watermark, bit8, send_timeout, send_timeout_close,
- delay_send,raw].
+ low_msgq_watermark, send_timeout, send_timeout_close, delay_send, raw].
connect_options(Opts, Family) ->
BaseOpts =
@@ -609,10 +652,10 @@ con_add(Name, Val, R, Opts, AllOpts) ->
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
listen_options() ->
[tos, priority, reuseaddr, keepalive, linger, sndbuf, recbuf, nodelay,
- header, active, packet, buffer, mode, deliver, backlog,
+ header, active, packet, buffer, mode, deliver, backlog, ipv6_v6only,
exit_on_close, high_watermark, low_watermark, high_msgq_watermark,
- low_msgq_watermark, bit8, send_timeout, send_timeout_close,
- delay_send, packet_size,raw].
+ low_msgq_watermark, send_timeout, send_timeout_close, delay_send,
+ packet_size, raw].
listen_options(Opts, Family) ->
BaseOpts =
@@ -667,7 +710,7 @@ list_add(Name, Val, R, Opts, As) ->
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
udp_options() ->
[tos, priority, reuseaddr, sndbuf, recbuf, header, active, buffer, mode,
- deliver,
+ deliver, ipv6_v6only,
broadcast, dontroute, multicast_if, multicast_ttl, multicast_loop,
add_membership, drop_membership, read_packets,raw].
@@ -723,7 +766,7 @@ udp_add(Name, Val, R, Opts, As) ->
sctp_options() ->
[ % The following are generic inet options supported for SCTP sockets:
mode, active, buffer, tos, priority, dontroute, reuseaddr, linger, sndbuf,
- recbuf,
+ recbuf, ipv6_v6only,
% Other options are SCTP-specific (though they may be similar to their
% TCP and UDP counter-parts):
@@ -766,8 +809,12 @@ sctp_opt([Opt|Opts], Mod, R, As) ->
{Name,Val} -> sctp_opt (Opts, Mod, R, As, Name, Val);
_ -> {error,badarg}
end;
-sctp_opt([], _Mod, R, _SockOpts) ->
- {ok, R}.
+sctp_opt([], _Mod, #sctp_opts{ifaddr=IfAddr}=R, _SockOpts) ->
+ if is_list(IfAddr) ->
+ {ok, R#sctp_opts{ifaddr=lists:reverse(IfAddr)}};
+ true ->
+ {ok, R}
+ end.
sctp_opt(Opts, Mod, R, As, Name, Val) ->
case add_opt(Name, Val, R#sctp_opts.opts, As) of
@@ -1018,11 +1065,7 @@ open(Fd, Addr, Port, Opts, Protocol, Family, Type, Module) when Fd < 0 ->
case prim_inet:setopts(S, Opts) of
ok ->
case if is_list(Addr) ->
- prim_inet:bind(S, add,
- [case A of
- {_,_} -> A;
- _ -> {A,Port}
- end || A <- Addr]);
+ bindx(S, Addr, Port);
true ->
prim_inet:bind(S, Addr, Port)
end of
@@ -1043,6 +1086,34 @@ open(Fd, Addr, Port, Opts, Protocol, Family, Type, Module) when Fd < 0 ->
open(Fd, _Addr, _Port, Opts, Protocol, Family, Type, Module) ->
fdopen(Fd, Opts, Protocol, Family, Type, Module).
+bindx(S, [Addr], Port0) ->
+ {IP, Port} = set_bindx_port(Addr, Port0),
+ prim_inet:bind(S, IP, Port);
+bindx(S, Addrs, Port0) ->
+ [{IP, Port} | Rest] = [set_bindx_port(Addr, Port0) || Addr <- Addrs],
+ case prim_inet:bind(S, IP, Port) of
+ {ok, AssignedPort} when Port =:= 0 ->
+ %% On newer Linux kernels, Solaris and FreeBSD, calling
+ %% bindx with port 0 is ok, but on SuSE 10, it results in einval
+ Rest2 = [change_bindx_0_port(Addr, AssignedPort) || Addr <- Rest],
+ prim_inet:bind(S, add, Rest2);
+ {ok, _} ->
+ prim_inet:bind(S, add, Rest);
+ Error ->
+ Error
+ end.
+
+set_bindx_port({_IP, _Port}=Addr, _OtherPort) ->
+ Addr;
+set_bindx_port(IP, Port) ->
+ {IP, Port}.
+
+change_bindx_0_port({IP, 0}, AssignedPort) ->
+ {IP, AssignedPort};
+change_bindx_0_port({_IP, _Port}=Addr, _AssignedPort) ->
+ Addr.
+
+
-spec fdopen(Fd :: non_neg_integer(),
Opts :: [socket_setopt()],
Protocol :: socket_protocol(),
@@ -1249,6 +1320,8 @@ udp_close(S) when is_port(S) ->
%% Set controlling process for TCP socket.
tcp_controlling_process(S, NewOwner) when is_port(S), is_pid(NewOwner) ->
case erlang:port_info(S, connected) of
+ {connected, NewOwner} ->
+ ok;
{connected, Pid} when Pid =/= self() ->
{error, not_owner};
undefined ->
@@ -1256,7 +1329,10 @@ tcp_controlling_process(S, NewOwner) when is_port(S), is_pid(NewOwner) ->
_ ->
case prim_inet:getopt(S, active) of
{ok, A0} ->
- prim_inet:setopt(S, active, false),
+ case A0 of
+ false -> ok;
+ _ -> prim_inet:setopt(S, active, false)
+ end,
case tcp_sync_input(S, NewOwner, false) of
true -> %% socket already closed,
ok;
@@ -1264,7 +1340,10 @@ tcp_controlling_process(S, NewOwner) when is_port(S), is_pid(NewOwner) ->
try erlang:port_connect(S, NewOwner) of
true ->
unlink(S), %% unlink from port
- prim_inet:setopt(S, active, A0),
+ case A0 of
+ false -> ok;
+ _ -> prim_inet:setopt(S, active, A0)
+ end,
ok
catch
error:Reason ->
@@ -1300,6 +1379,8 @@ tcp_sync_input(S, Owner, Flag) ->
%% Set controlling process for UDP or SCTP socket.
udp_controlling_process(S, NewOwner) when is_port(S), is_pid(NewOwner) ->
case erlang:port_info(S, connected) of
+ {connected, NewOwner} ->
+ ok;
{connected, Pid} when Pid =/= self() ->
{error, not_owner};
_ ->
diff --git a/lib/kernel/src/inet_config.erl b/lib/kernel/src/inet_config.erl
index 1ddbdcec25..526baca335 100644
--- a/lib/kernel/src/inet_config.erl
+++ b/lib/kernel/src/inet_config.erl
@@ -197,16 +197,6 @@ do_load_resolv({win32,Type}, longnames) ->
win32_load_from_registry(Type),
inet_db:set_lookup([native]);
-do_load_resolv(vxworks, _) ->
- vxworks_load_hosts(),
- inet_db:set_lookup([file, dns]),
- case os:getenv("ERLRESCONF") of
- false ->
- no_ERLRESCONF;
- Resolv ->
- load_resolv(Resolv, resolv)
- end;
-
do_load_resolv(_, _) ->
inet_db:set_lookup([native]).
@@ -408,55 +398,6 @@ win32_get_strings(Reg, [Name|Rest], Result) ->
win32_get_strings(_, [], Result) ->
lists:reverse(Result).
-%%
-%% Load host data from VxWorks hostShow command
-%%
-
-vxworks_load_hosts() ->
- HostShow = os:cmd("hostShow"),
- case check_hostShow(HostShow) of
- Hosts when is_list(Hosts) ->
- case inet_parse:hosts_vxworks({chars, Hosts}) of
- {ok, Ls} ->
- foreach(
- fun({IP, Name, Aliases}) ->
- inet_db:add_host(IP, [Name|Aliases])
- end,
- Ls);
- {error,Reason} ->
- error("parser error VxWorks hostShow ~s", [Reason])
- end;
- _Error ->
- error("error in VxWorks hostShow~s~n", [HostShow])
- end.
-
-%%
-%% Check if hostShow yields at least two line; the first one
-%% starting with "hostname", the second one starting with
-%% "--------".
-%% Returns: list of hosts in VxWorks notation
-%% rows of 'Name IP [Aliases] \n'
-%% if hostShow yielded these two lines, false otherwise.
-check_hostShow(HostShow) ->
- check_hostShow(["hostname", "--------"], HostShow).
-
-check_hostShow([], HostShow) ->
- HostShow;
-check_hostShow([String_match|Rest], HostShow) ->
- case lists:prefix(String_match, HostShow) of
- true ->
- check_hostShow(Rest, next_line(HostShow));
- false ->
- false
- end.
-
-next_line([]) ->
- [];
-next_line([$\n|Rest]) ->
- Rest;
-next_line([_First|Rest]) ->
- next_line(Rest).
-
read_rc() ->
{RcFile,CfgList} = read_inetrc(),
case extract_cfg_files(CfgList, [], []) of
diff --git a/lib/kernel/src/inet_int.hrl b/lib/kernel/src/inet_int.hrl
index 2dfbf75d25..000119bc74 100644
--- a/lib/kernel/src/inet_int.hrl
+++ b/lib/kernel/src/inet_int.hrl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 1997-2011. All Rights Reserved.
+%% Copyright Ericsson AB 1997-2012. All Rights Reserved.
%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
@@ -124,6 +124,7 @@
-define(UDP_OPT_MULTICAST_LOOP, 13).
-define(UDP_OPT_ADD_MEMBERSHIP, 14).
-define(UDP_OPT_DROP_MEMBERSHIP, 15).
+-define(INET_OPT_IPV6_V6ONLY, 16).
% "Local" options: codes start from 20:
-define(INET_LOPT_BUFFER, 20).
-define(INET_LOPT_HEADER, 21).
@@ -134,7 +135,6 @@
-define(INET_LOPT_EXITONCLOSE, 26).
-define(INET_LOPT_TCP_HIWTRMRK, 27).
-define(INET_LOPT_TCP_LOWTRMRK, 28).
--define(INET_LOPT_BIT8, 29).
-define(INET_LOPT_TCP_SEND_TIMEOUT, 30).
-define(INET_LOPT_TCP_DELAY_SEND, 31).
-define(INET_LOPT_PACKET_SIZE, 32).
@@ -188,12 +188,6 @@
-define(TCP_PB_HTTP_BIN,13).
-define(TCP_PB_HTTPH_BIN,14).
-%% bit options, INET_LOPT_BIT8
--define(INET_BIT8_CLEAR, 0).
--define(INET_BIT8_SET, 1).
--define(INET_BIT8_ON, 2).
--define(INET_BIT8_OFF, 3).
-
%% getstat, INET_REQ_GETSTAT
-define(INET_STAT_RECV_CNT, 1).
diff --git a/lib/kernel/src/inet_parse.erl b/lib/kernel/src/inet_parse.erl
index 65edddcb46..3551e701b6 100644
--- a/lib/kernel/src/inet_parse.erl
+++ b/lib/kernel/src/inet_parse.erl
@@ -23,7 +23,6 @@
%% Avoid warning for local function error/2 clashing with autoimported BIF.
-compile({no_auto_import,[error/2]}).
-export([hosts/1, hosts/2]).
--export([hosts_vxworks/1]).
-export([protocols/1, protocols/2]).
-export([netmasks/1, netmasks/2]).
-export([networks/1, networks/2]).
@@ -37,7 +36,7 @@
-export([ipv4_address/1, ipv6_address/1]).
-export([ipv4strict_address/1, ipv6strict_address/1]).
--export([address/1]).
+-export([address/1, strict_address/1]).
-export([visible_string/1, domain/1]).
-export([ntoa/1, dots/1]).
-export([split_line/1]).
@@ -107,18 +106,6 @@ hosts(Fname,File) ->
parse_file(Fname, File, Fn).
%% --------------------------------------------------------------------------
-%% Parse hostShow vxworks style
-%% Syntax:
-%% Name IP [Aliases] \n
-%% --------------------------------------------------------------------------
-hosts_vxworks(Hosts) ->
- Fn = fun([Name, Address | Aliases]) ->
- {ok,IP} = address(Address),
- {IP, Name, Aliases}
- end,
- parse_file(Hosts, Fn).
-
-%% --------------------------------------------------------------------------
%% Parse resolv file unix style
%% Syntax:
%% domain Domain \n
@@ -291,9 +278,6 @@ networks(Fname, File) ->
%%
%% --------------------------------------------------------------------------
-parse_file(File, Fn) ->
- parse_file(noname, File, Fn).
-
parse_file(Fname, {fd,Fd}, Fn) ->
parse_fd(Fname,Fd, 1, Fn, []);
parse_file(Fname, {chars,Cs}, Fn) when is_list(Cs) ->
@@ -472,6 +456,17 @@ address(Cs) when is_list(Cs) ->
address(_) ->
{error, einval}.
+%%Parse ipv4 strict address or ipv6 strict address
+strict_address(Cs) when is_list(Cs) ->
+ case ipv4strict_address(Cs) of
+ {ok,IP} ->
+ {ok,IP};
+ _ ->
+ ipv6strict_address(Cs)
+ end;
+strict_address(Cs) ->
+ {error, einval}.
+
%%
%% Parse IPv4 address:
%% d1.d2.d3.d4
diff --git a/lib/kernel/src/kernel.appup.src b/lib/kernel/src/kernel.appup.src
index bded2408a7..54628800a8 100644
--- a/lib/kernel/src/kernel.appup.src
+++ b/lib/kernel/src/kernel.appup.src
@@ -17,11 +17,11 @@
%% %CopyrightEnd%
{"%VSN%",
%% Up from - max two major revisions back
- [{<<"2\\.15(\\.[0-9]+)*">>,[restart_new_emulator]}, %% R15
- {<<"2\\.14(\\.[0-9]+)*">>,[restart_new_emulator]}, %% R14
- {<<"2\\.13(\\.[0-9]+)*">>,[restart_new_emulator]}],%% R13
+ [{<<"2\\.16(\\.[0-9]+)*">>,[restart_new_emulator]}, %% R16
+ {<<"2\\.15(\\.[0-9]+)*">>,[restart_new_emulator]}, %% R15
+ {<<"2\\.14(\\.[0-9]+)*">>,[restart_new_emulator]}],%% R14
%% Down to - max two major revisions back
- [{<<"2\\.15(\\.[0-9]+)*">>,[restart_new_emulator]}, %% R15
- {<<"2\\.14(\\.[0-9]+)*">>,[restart_new_emulator]}, %% R14
- {<<"2\\.13(\\.[0-9]+)*">>,[restart_new_emulator]}] %% R13
+ [{<<"2\\.16(\\.[0-9]+)*">>,[restart_new_emulator]}, %% R16
+ {<<"2\\.15(\\.[0-9]+)*">>,[restart_new_emulator]}, %% R15
+ {<<"2\\.14(\\.[0-9]+)*">>,[restart_new_emulator]}] %% R14
}.
diff --git a/lib/kernel/src/net_kernel.erl b/lib/kernel/src/net_kernel.erl
index 9e3d730cee..0d59e7af67 100644
--- a/lib/kernel/src/net_kernel.erl
+++ b/lib/kernel/src/net_kernel.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 1996-2011. All Rights Reserved.
+%% Copyright Ericsson AB 1996-2012. All Rights Reserved.
%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
@@ -142,6 +142,17 @@
-include("net_address.hrl").
+%%% BIF
+
+-export([dflag_unicode_io/1]).
+
+-spec dflag_unicode_io(pid()) -> boolean().
+
+dflag_unicode_io(_) ->
+ erlang:nif_error(undef).
+
+%%% End of BIF
+
%% Interface functions
kernel_apply(M,F,A) -> request({apply,M,F,A}).
diff --git a/lib/kernel/src/os.erl b/lib/kernel/src/os.erl
index f6769df585..e20a2434b4 100644
--- a/lib/kernel/src/os.erl
+++ b/lib/kernel/src/os.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 1997-2011. All Rights Reserved.
+%% Copyright Ericsson AB 1997-2012. All Rights Reserved.
%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
@@ -24,16 +24,48 @@
-include("file.hrl").
--spec type() -> vxworks | {Osfamily, Osname} when
+%%% BIFs
+
+-export([getenv/0, getenv/1, getpid/0, putenv/2, timestamp/0]).
+
+-spec getenv() -> [string()].
+
+getenv() -> erlang:nif_error(undef).
+
+-spec getenv(VarName) -> Value | false when
+ VarName :: string(),
+ Value :: string().
+
+getenv(_) ->
+ erlang:nif_error(undef).
+
+-spec getpid() -> Value when
+ Value :: string().
+
+getpid() ->
+ erlang:nif_error(undef).
+
+-spec putenv(VarName, Value) -> true when
+ VarName :: string(),
+ Value :: string().
+
+putenv(_, _) ->
+ erlang:nif_error(undef).
+
+-spec timestamp() -> Timestamp when
+ Timestamp :: erlang:timestamp().
+
+timestamp() ->
+ erlang:nif_error(undef).
+
+%%% End of BIFs
+
+-spec type() -> {Osfamily, Osname} when
Osfamily :: unix | win32,
Osname :: atom().
type() ->
- case erlang:system_info(os_type) of
- {vxworks, _} ->
- vxworks;
- Else -> Else
- end.
+ erlang:system_info(os_type).
-spec version() -> VersionString | {Major, Minor, Release} when
VersionString :: string(),
@@ -83,25 +115,14 @@ find_executable1(_Name, [], _Extensions) ->
verify_executable(Name0, [Ext|Rest], OrigExtensions) ->
Name1 = Name0 ++ Ext,
- case os:type() of
- vxworks ->
- %% We consider all existing VxWorks files to be executable
- case file:read_file_info(Name1) of
- {ok, _} ->
- {ok, Name1};
- _ ->
- verify_executable(Name0, Rest, OrigExtensions)
- end;
+ case file:read_file_info(Name1) of
+ {ok, #file_info{type=regular,mode=Mode}}
+ when Mode band 8#111 =/= 0 ->
+ %% XXX This test for execution permission is not fool-proof
+ %% on Unix, since we test if any execution bit is set.
+ {ok, Name1};
_ ->
- case file:read_file_info(Name1) of
- {ok, #file_info{type=regular,mode=Mode}}
- when Mode band 8#111 =/= 0 ->
- %% XXX This test for execution permission is not fool-proof
- %% on Unix, since we test if any execution bit is set.
- {ok, Name1};
- _ ->
- verify_executable(Name0, Rest, OrigExtensions)
- end
+ verify_executable(Name0, Rest, OrigExtensions)
end;
verify_executable(Name, [], OrigExtensions) when OrigExtensions =/= [""] -> %% Windows
%% Will only happen on windows, hence case insensitivity
@@ -154,8 +175,7 @@ reverse_element(List) ->
extensions() ->
case type() of
{win32, _} -> [".exe",".com",".cmd",".bat"];
- {unix, _} -> [""];
- vxworks -> [""]
+ {unix, _} -> [""]
end.
%% Executes the given command in the default shell for the operating system.
@@ -173,11 +193,6 @@ cmd(Cmd) ->
{Cspec,_} -> lists:concat([Cspec," /c",Cmd])
end,
Port = open_port({spawn, Command}, [stream, in, eof, hide]),
- get_data(Port, []);
- %% VxWorks uses a 'sh -c hook' in 'vxcall.c' to run os:cmd.
- vxworks ->
- Command = lists:concat(["sh -c '", Cmd, "'"]),
- Port = open_port({spawn, Command}, [stream, in, eof]),
get_data(Port, [])
end.
diff --git a/lib/kernel/src/pg2.erl b/lib/kernel/src/pg2.erl
index 0d5838716e..1ff10eb303 100644
--- a/lib/kernel/src/pg2.erl
+++ b/lib/kernel/src/pg2.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 1997-2011. All Rights Reserved.
+%% Copyright Ericsson AB 1997-2012. All Rights Reserved.
%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
@@ -159,7 +159,7 @@ get_closest_pid(Name) ->
-record(state, {}).
--opaque state() :: #state{}.
+-type state() :: #state{}.
-spec init(Arg :: []) -> {'ok', state()}.
diff --git a/lib/kernel/src/rpc.erl b/lib/kernel/src/rpc.erl
index e214ffa404..7c965ca384 100644
--- a/lib/kernel/src/rpc.erl
+++ b/lib/kernel/src/rpc.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 1996-2011. All Rights Reserved.
+%% Copyright Ericsson AB 1996-2012. All Rights Reserved.
%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
@@ -62,6 +62,8 @@
%% Internals
-export([proxy_user_flush/0]).
+-export_type([key/0]).
+
%%------------------------------------------------------------------------
-type state() :: gb_tree().
@@ -286,7 +288,7 @@ call(N,M,F,A) ->
Reason :: term(),
Timeout :: timeout().
-call(N,M,F,A,_Timeout) when node() =:= N -> %% Optimize local call
+call(N,M,F,A,infinity) when node() =:= N -> %% Optimize local call
local_call(M,F,A);
call(N,M,F,A,infinity) ->
do_call(N, {call,M,F,A,group_leader()}, infinity);
diff --git a/lib/kernel/src/wrap_log_reader.erl b/lib/kernel/src/wrap_log_reader.erl
index c41e0091e4..689269fc28 100644
--- a/lib/kernel/src/wrap_log_reader.erl
+++ b/lib/kernel/src/wrap_log_reader.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 1998-2011. All Rights Reserved.
+%% Copyright Ericsson AB 1998-2012. All Rights Reserved.
%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
@@ -30,6 +30,8 @@
-export([open/1, open/2, chunk/1, chunk/2, close/1]).
+-export_type([continuation/0]).
+
-include("disk_log.hrl").
-record(wrap_reader,