From 2fc37e356b8c17064ad39d0418b62edd28675e19 Mon Sep 17 00:00:00 2001 From: Patrik Nyblom Date: Wed, 25 Jan 2012 17:05:15 +0100 Subject: Make erlang doc use specs from erlang.erl Reintroduced setelement in erlang.erl and erlang.xml Preloaded erlang.beam updated. --- erts/doc/src/erlang.xml | 3716 +++++++++++++++++---------------------- erts/preloaded/ebin/erlang.beam | Bin 41136 -> 84228 bytes erts/preloaded/src/erlang.erl | 369 ++-- 3 files changed, 1795 insertions(+), 2290 deletions(-) diff --git a/erts/doc/src/erlang.xml b/erts/doc/src/erlang.xml index a21021d864..7838cffded 100644 --- a/erts/doc/src/erlang.xml +++ b/erts/doc/src/erlang.xml @@ -4,7 +4,7 @@
- 19962011 + 19962012 Ericsson AB. All Rights Reserved. @@ -65,14 +65,14 @@ - abs(Number) -> integer() | float() + + + + Arithmetical absolute value - - Number = number() -

Returns an integer or float which is the arithmetical - absolute value of Number.

+ absolute value of Float or Int.

 > abs(-3.33).
 3.33
@@ -82,26 +82,19 @@
       
     
     
-      erlang:adler32(Data) -> integer()
+      
       Compute adler32 checksum
-      
-        Data = iodata()
-      
       
-        

Computes and returns the adler32 checksum for Data.

+

Computes and returns the adler32 checksum for Data.

- erlang:adler32(OldAdler, Data) -> integer() + Compute adler32 checksum - - OldAdler = integer() - Data = iodata() -

Continue computing the adler32 checksum by combining - the previous checksum, OldAdler, with the checksum of - Data.

+ the previous checksum, OldAdler, with the checksum of + Data.

The following code:

X = erlang:adler32(Data1), @@ -114,12 +107,8 @@
- erlang:adler32_combine(FirstAdler, SecondAdler, SecondSize) -> integer() + Combine two adler32 checksums - - FirstAdler = SecondAdler = integer() - SecondSize = integer() -

Combines two previously computed adler32 checksums. This computation requires the size of the data object for @@ -138,18 +127,14 @@ - erlang:append_element(Tuple1, Term) -> Tuple2 + Append an extra element to a tuple - - Tuple1 = Tuple2 = tuple() - Term = term() -

Returns a new tuple which has one element more than - Tuple1, and contains the elements in Tuple1 - followed by Term as the last element. Semantically + Tuple1, and contains the elements in Tuple1 + followed by Term as the last element. Semantically equivalent to - list_to_tuple(tuple_to_list(Tuple) ++ [Term]), but much + list_to_tuple(tuple_to_list(Tuple1) ++ [Term]), but much faster.

 > erlang:append_element({one, two}, three).
@@ -204,27 +189,24 @@
       
     
     
-      atom_to_binary(Atom, Encoding) -> binary()
+      
       Return the binary representation of an atom
-      
-        Atom = atom()
-        Encoding = latin1 | utf8 | unicode
-      
       
         

Returns a binary which corresponds to the text - representation of Atom. If Encoding + representation of Atom. If Encoding is latin1, there will be one byte for each character - in the text representation. If Encoding is utf8 or + in the text representation. If Encoding is + utf8 or unicode, the characters will be encoded using UTF-8 (meaning that characters from 16#80 up to 0xFF will be encoded in two bytes).

-

Currently, atom_to_binary(Atom, latin1) can +

Currently, atom_to_binary(Atom, latin1) can never fail because the text representation of an atom can only contain characters from 0 to 16#FF. In a future release, the text representation of atoms might be allowed to contain any Unicode character - and atom_to_binary(Atom, latin1) will fail if the - text representation for the Atom contains a Unicode + and atom_to_binary(Atom, latin1) will fail if the + text representation for the Atom contains a Unicode character greater than 16#FF.

@@ -233,30 +215,21 @@
       
     
     
-      atom_to_list(Atom) -> string()
+      
       Text representation of an atom
-      
-        Atom = atom()
-      
       
         

Returns a string which corresponds to the text - representation of Atom.

+ representation of Atom.

 > atom_to_list('Erlang').
 "Erlang"
- binary_part(Subject, PosLen) -> binary() + Extracts a part of a binary - - Subject = binary() - PosLen = {Start,Length} - Start = integer() >= 0 - Length = integer() >= 0 - - -

Extracts the part of the binary described by PosLen.

+ +

Extracts the part of the binary described by PosLen.

Negative length can be used to extract bytes at the end of a binary:

@@ -266,53 +239,44 @@ <<6,7,8,9,10>>
-

If PosLen in any way references outside the binary, a badarg exception is raised.

+

If PosLen in any way references outside the binary, a badarg exception is raised.

-

Start is zero-based, i.e.:

+

Start is zero-based, i.e.:

1> Bin = <<1,2,3>> 2> binary_part(Bin,{0,2}). <<1,2>> -

See the STDLIB module binary for details about the PosLen semantics.

+

See the STDLIB module binary for details about the PosLen semantics.

Allowed in guard tests.

- binary_part(Subject, Start, Length) -> binary() + Extracts a part of a binary - - Subject = binary() - Start = integer() >= 0 - Length = integer() >= 0 - -

The same as binary_part(Subject, {Pos, Len}).

+

The same as binary_part(Subject, {Start, Length}).

Allowed in guard tests.

- binary_to_atom(Binary, Encoding) -> atom() + Convert from text representation to an atom - - Binary = binary() - Encoding = latin1 | utf8 | unicode -

Returns the atom whose text representation is - Binary. If Encoding is latin1, no - translation of bytes in the binary is done. If Encoding + Binary. If Encoding is latin1, no + translation of bytes in the binary is done. If Encoding is utf8 or unicode, the binary must contain valid UTF-8 sequences; furthermore, only Unicode characters up to 0xFF are allowed.

-

binary_to_atom(Binary, utf8) will fail if +

binary_to_atom(Binary, utf8) will fail if the binary contains Unicode characters greater than 16#FF. In a future release, such Unicode characters might be allowed - and binary_to_atom(Binary, utf8) + and binary_to_atom(Binary, utf8) will not fail in that case.

@@ -325,12 +289,8 @@
       
     
     
-      binary_to_existing_atom(Binary, Encoding) -> atom()
+      
       Convert from text representation to an atom
-      
-        Binary = binary()
-        Encoding = latin1 | utf8 | unicode
-      
       
         

Works like binary_to_atom/2, but the atom must already exist.

@@ -338,27 +298,21 @@
- binary_to_list(Binary) -> [char()] + Convert a binary to a list - - Binary = binary() -

Returns a list of integers which correspond to the bytes of - Binary.

+ Binary.

- binary_to_list(Binary, Start, Stop) -> [char()] + Convert part of a binary to a list - - Binary = binary() - Start = Stop = 1..byte_size(Binary) - + 1..byte_size(Binary)

As binary_to_list/1, but returns a list of integers - corresponding to the bytes from position Start to - position Stop in Binary. Positions in the + corresponding to the bytes from position Start to + position Stop in Binary. Positions in the binary are numbered starting from 1.

This function's indexing style of using one-based indices for @@ -368,27 +322,21 @@ - bitstring_to_list(Bitstring) -> [char()|bitstring()] + Convert a bitstring to a list - - Bitstring = bitstring() -

Returns a list of integers which correspond to the bytes of - Bitstring. If the number of bits in the binary is not + Bitstring. If the number of bits in the binary is not divisible by 8, the last element of the list will be a bitstring containing the remaining bits (1 up to 7 bits).

- binary_to_term(Binary) -> term() + Decode an Erlang external term format binary - - Binary = ext_binary() -

Returns an Erlang term which is the result of decoding - the binary object Binary, which must be encoded + the binary object Binary, which must be encoded according to the Erlang external term format.

When decoding binaries from untrusted sources, consider using @@ -401,12 +349,8 @@ - binary_to_term(Binary, Opts) -> term() + Decode an Erlang external term format binary - - Opts = [safe] - Binary = ext_binary() -

As binary_to_term/1, but takes options that affect decoding of the binary.

@@ -436,13 +380,10 @@
- bit_size(Bitstring) -> integer() >= 0 + Return the size of a bitstring - - Bitstring = bitstring() - -

Returns an integer which is the size in bits of Bitstring.

+

Returns an integer which is the size in bits of Bitstring.

 > bit_size(<<433:16,3:3>>).
 19
@@ -452,11 +393,8 @@
       
     
     
-      erlang:bump_reductions(Reductions) -> void()
+      
       Increment the reduction counter
-      
-        Reductions = integer() >= 0
-      
       
         

This implementation-dependent function increments the reduction counter for the calling process. In the Beam @@ -472,14 +410,11 @@ - byte_size(Bitstring) -> integer() >= 0 + Return the size of a bitstring (or binary) - - Bitstring = bitstring() -

Returns an integer which is the number of bytes needed to contain - Bitstring. (That is, if the number of bits in Bitstring is not + Bitstring. (That is, if the number of bits in Bitstring is not divisible by 8, the resulting number of bytes will be rounded up.)

 > byte_size(<<433:16,3:3>>).
@@ -490,21 +425,17 @@
       
     
     
-      erlang:cancel_timer(TimerRef) -> Time | false
+      
       Cancel a timer
-      
-        TimerRef = reference()
-        Time = integer() >= 0
-      
       
-        

Cancels a timer, where TimerRef was returned by +

Cancels a timer, where TimerRef was returned by either erlang:send_after/3 or erlang:start_timer/3. If the timer is there to be removed, the function returns the time in milliseconds left until the timer would have expired, - otherwise false (which means that TimerRef was + otherwise false (which means that TimerRef was never a timer, that it has already been cancelled, or that it has already delivered its message).

See also @@ -518,27 +449,20 @@ - check_old_code(Module) -> boolean() + Check if a module has old code - - Module = atom() - -

Returns true if the Module has old code, +

Returns true if the Module has old code, and false otherwise.

See also code(3).

- check_process_code(Pid, Module) -> boolean() + Check if a process is executing old code for a module - - Pid = pid() - Module = atom() - -

Returns true if the process Pid is executing - old code for Module. That is, if the current call of +

Returns true if the process Pid is executing + old code for Module. That is, if the current call of the process executes old code for this module, or if the process has references to old code for this module, or if the process contains funs that references old code for this @@ -550,26 +474,19 @@ false

- erlang:crc32(Data) -> integer() >= 0 + Compute crc32 (IEEE 802.3) checksum - - Data = iodata() - -

Computes and returns the crc32 (IEEE 802.3 style) checksum for Data.

+

Computes and returns the crc32 (IEEE 802.3 style) checksum for Data.

- erlang:crc32(OldCrc, Data) -> integer() >= 0 + Compute crc32 (IEEE 802.3) checksum - - OldCrc = integer() >= 0 - Data = iodata() -

Continue computing the crc32 checksum by combining - the previous checksum, OldCrc, with the checksum of - Data.

+ the previous checksum, OldCrc, with the checksum of + Data.

The following code:

X = erlang:crc32(Data1), @@ -582,12 +499,8 @@ false
- erlang:crc32_combine(FirstCrc, SecondCrc, SecondSize) -> integer() >= 0 + Combine two crc32 (IEEE 802.3) checksums - - FirstCrc = SecondCrc = integer() >= 0 - SecondSize = integer() >= 0 -

Combines two previously computed crc32 checksums. This computation requires the size of the data object for @@ -606,11 +519,8 @@ false

- date() -> Date + Current date - - Date = calendar:date() -

Returns the current date as {Year, Month, Day}.

The time zone and daylight saving time correction depend on @@ -621,47 +531,24 @@ false

- erlang:decode_packet(Type,Bin,Options) -> {ok,Packet,Rest} | {more,Length} | {error,Reason} + Extracts a protocol packet from a binary - - Bin = binary() - Options = [Opt] - Packet = binary() | HttpPacket - Rest = binary() - Length = integer() > 0 | undefined - Reason = term() -  Type, Opt -- see below - - HttpPacket = HttpRequest | HttpResponse | HttpHeader | http_eoh | HttpError - HttpRequest = {http_request, HttpMethod, HttpUri, HttpVersion} - HttpResponse = {http_response, HttpVersion, integer(), HttpString} - HttpHeader = {http_header, integer(), HttpField, Reserved=term(), Value=HttpString} - HttpError = {http_error, HttpString} - HttpMethod = HttpMethodAtom | HttpString - HttpMethodAtom = 'OPTIONS' | 'GET' | 'HEAD' | 'POST' | 'PUT' | 'DELETE' | 'TRACE' - HttpUri = '*' | {absoluteURI, http|https, Host=HttpString, Port=integer()|undefined, Path=HttpString} | - {scheme, Scheme=HttpString, HttpString} | {abs_path, HttpString} | HttpString - HttpVersion = {Major=integer(), Minor=integer()} - HttpString = string() | binary() - HttpField = HttpFieldAtom | HttpString - HttpFieldAtom = 'Cache-Control' | 'Connection' | 'Date' | 'Pragma' | 'Transfer-Encoding' | 'Upgrade' | 'Via' | 'Accept' | 'Accept-Charset' | 'Accept-Encoding' | 'Accept-Language' | 'Authorization' | 'From' | 'Host' | 'If-Modified-Since' | 'If-Match' | 'If-None-Match' | 'If-Range' | 'If-Unmodified-Since' | 'Max-Forwards' | 'Proxy-Authorization' | 'Range' | 'Referer' | 'User-Agent' | 'Age' | 'Location' | 'Proxy-Authenticate' | 'Public' | 'Retry-After' | 'Server' | 'Vary' | 'Warning' | 'Www-Authenticate' | 'Allow' | 'Content-Base' | 'Content-Encoding' | 'Content-Language' | 'Content-Length' | 'Content-Location' | 'Content-Md5' | 'Content-Range' | 'Content-Type' | 'Etag' | 'Expires' | 'Last-Modified' | 'Accept-Ranges' | 'Set-Cookie' | 'Set-Cookie2' | 'X-Forwarded-For' | 'Cookie' | 'Keep-Alive' | 'Proxy-Connection' - - - -

Decodes the binary Bin according to the packet - protocol specified by Type. Very similar to the packet - handling done by sockets with the option {packet,Type}.

-

If an entire packet is contained in Bin it is + + +

Decodes the binary Bin according to the packet + protocol specified by Type. Very similar to the packet + handling done by sockets with the option {packet,Type}.

+

If an entire packet is contained in Bin it is returned together with the remainder of the binary as - {ok,Packet,Rest}.

-

If Bin does not contain the entire packet, - {more,Length} is returned. Length is either the + {ok,Packet,Rest}.

+

If Bin does not contain the entire packet, + {more,Length} is returned. Length is either the expected total size of the packet or undefined if the expected packet size is not known. decode_packet can then be called again with more data added.

If the packet does not conform to the protocol format - {error,Reason} is returned.

-

The following values of Type are valid:

+ {error,Reason} is returned.

+

The following values of Type are valid:

raw | 0 @@ -699,15 +586,15 @@ false

The Hypertext Transfer Protocol. The packets are returned with the format according to - HttpPacket described above. A packet is either a + HttpPacket described above. A packet is either a request, a response, a header or an end of header - mark. Invalid lines are returned as HttpError.

+ mark. Invalid lines are returned as HttpError.

Recognized request methods and header fields are returned as atoms. Others are returned as strings.

The protocol type http should only be used for - the first line when a HttpRequest or a - HttpResponse is expected. The following calls - should use httph to get HttpHeader's until + the first line when a HttpRequest or a + HttpResponse is expected. The following calls + should use httph to get HttpHeader's until http_eoh is returned that marks the end of the headers and the beginning of any following message body.

The variants http_bin and httph_bin will return @@ -716,14 +603,14 @@ false

The following options are available:

- {packet_size, integer()} + {packet_size, integer() >= 0}

Sets the max allowed size of the packet body. If the packet header indicates that the length of the packet is longer than the max allowed length, the packet is considered invalid. Default is 0 which means no size limit.

- {line_length, integer()} + {line_length, integer() >= 0}

For packet type line, truncate lines longer than the indicated length.

Option line_length also applies to http* @@ -740,13 +627,10 @@ false - delete_module(Module) -> true | undefined + Make the current code for a module old - - Module = atom() - -

Makes the current code for Module become old code, and +

Makes the current code for Module become old code, and deletes all references for this module from the export table. Returns undefined if the module does not exist, otherwise true.

@@ -760,27 +644,24 @@ false
- demonitor(MonitorRef) -> true + Stop monitoring - - MonitorRef = reference() - -

If MonitorRef is a reference which the calling process +

If MonitorRef is a reference which the calling process obtained by calling monitor/2, this monitoring is turned off. If the monitoring is already turned off, nothing happens.

-

Once demonitor(MonitorRef) has returned it is - guaranteed that no {'DOWN', MonitorRef, _, _, _} message +

Once demonitor(MonitorRef) has returned it is + guaranteed that no {'DOWN', MonitorRef, _, _, _} message due to the monitor will be placed in the caller's message queue - in the future. A {'DOWN', MonitorRef, _, _, _} message + in the future. A {'DOWN', MonitorRef, _, _, _} message might have been placed in the caller's message queue prior to the call, though. Therefore, in most cases, it is advisable to remove such a 'DOWN' message from the message queue after monitoring has been stopped. - demonitor(MonitorRef, [flush]) can be used instead of - demonitor(MonitorRef) if this cleanup is wanted.

+ demonitor(MonitorRef, [flush]) can be used instead of + demonitor(MonitorRef) if this cleanup is wanted.

Prior to OTP release R11B (erts version 5.5) demonitor/1 behaved completely asynchronous, i.e., the monitor was active @@ -792,35 +673,30 @@ false asynchronously send a "demonitor signal" to the monitored entity and ignore any future results of the monitor.

-

Failure: It is an error if MonitorRef refers to a +

Failure: It is an error if MonitorRef refers to a monitoring started by another process. Not all such cases are cheap to check; if checking is cheap, the call fails with - badarg (for example if MonitorRef is a remote + badarg (for example if MonitorRef is a remote reference).

- demonitor(MonitorRef, OptionList) -> boolean() + Stop monitoring - - MonitorRef = reference() - OptionList = [Option] -  Option = flush | info -

The returned value is true unless info is part - of OptionList. + of OptionList.

-

demonitor(MonitorRef, []) is equivalent to - demonitor(MonitorRef).

-

Currently the following Options are valid:

+

demonitor(MonitorRef, []) is equivalent to + demonitor(MonitorRef).

+

Currently the following Options are valid:

flush -

Remove (one) {_, MonitorRef, _, _, _} message, +

Remove (one) {_, MonitorRef, _, _, _} message, if there is one, from the caller's message queue after monitoring has been stopped.

-

Calling demonitor(MonitorRef, [flush]) +

Calling demonitor(MonitorRef, [flush]) is equivalent to the following, but more efficient:

@@ -860,8 +736,8 @@ false

More options may be added in the future.

-

Failure: badarg if OptionList is not a list, or - if Option is not a valid option, or the same failure as for +

Failure: badarg if OptionList is not a list, or + if Option is not a valid option, or the same failure as for demonitor/1

@@ -878,13 +754,10 @@ false - erlang:display(Term) -> true + Print a term on standard output - - Term = term() - -

Prints a text representation of Term on the standard +

Prints a text representation of Term on the standard output.

This BIF is intended for debugging only.

@@ -892,15 +765,12 @@ false
- element(N, Tuple) -> term() + + 1..tuple_size(Tuple) Get Nth element of a tuple - - N = 1..tuple_size(Tuple) - Tuple = tuple() - -

Returns the Nth element (numbering from 1) of - Tuple.

+

Returns the Nth element (numbering from 1) of + Tuple.

 > element(2, {a, b, c}).
 b
@@ -908,11 +778,8 @@ b
- erase() -> [{Key, Val}] + Return and delete the process dictionary - - Key = Val = term() -

Returns the process dictionary and deletes it.

@@ -923,15 +790,12 @@ b
- erase(Key) -> Val | undefined + Return and delete a value from the process dictionary - - Key = Val = term() - -

Returns the value Val associated with Key and +

Returns the value Val associated with Key and deletes it from the process dictionary. Returns - undefined if no value is associated with Key.

+ undefined if no value is associated with Key.

 > put(key1, {merry, lambs, are, playing}),
 X = erase(key1),
@@ -940,15 +804,12 @@ b
- error(Reason) + Stop execution with a given reason - - Reason = term() -

Stops the execution of the calling process with the reason - Reason, where Reason is any term. The actual - exit reason will be {Reason, Where}, where Where + Reason, where Reason is any term. The actual + exit reason will be {Reason, Where}, where Where is a list of the functions most recently called (the current function first). Since evaluating this function causes the process to terminate, it has no return value.

@@ -962,18 +823,14 @@ b
- error(Reason, Args) + Stop execution with a given reason - - Reason = term() - Args = [term()] -

Stops the execution of the calling process with the reason - Reason, where Reason is any term. The actual - exit reason will be {Reason, Where}, where Where + Reason, where Reason is any term. The actual + exit reason will be {Reason, Where}, where Where is a list of the functions most recently called (the current - function first). Args is expected to be the list of + function first). Args is expected to be the list of arguments for the current function; in Beam it will be used to provide the actual arguments for the current function in the Where term. Since evaluating this function causes @@ -981,14 +838,11 @@ b - exit(Reason) + Stop execution with a given reason - - Reason = term() -

Stops the execution of the calling process with the exit - reason Reason, where Reason is any term. Since + reason Reason, where Reason is any term. Since evaluating this function causes the process to terminate, it has no return value.

@@ -999,78 +853,67 @@ b
- exit(Pid, Reason) -> true + Send an exit signal to a process - - Pid = pid() - Reason = term() - - -

Sends an exit signal with exit reason Reason to - the process Pid.

-

The following behavior apply if Reason is any term + +

Sends an exit signal with exit reason Reason to + the process Pid.

+

The following behavior apply if Reason is any term except normal or kill:

-

If Pid is not trapping exits, Pid itself will - exit with exit reason Reason. If Pid is trapping +

If Pid is not trapping exits, Pid itself will + exit with exit reason Reason. If Pid is trapping exits, the exit signal is transformed into a message - {'EXIT', From, Reason} and delivered to the message - queue of Pid. From is the pid of the process + {'EXIT', From, Reason} and delivered to the message + queue of Pid. From is the pid of the process which sent the exit signal. See also process_flag/2.

-

If Reason is the atom normal, Pid will +

If Reason is the atom normal, Pid will not exit. If it is trapping exits, the exit signal is transformed into a message {'EXIT', From, normal} and delivered to its message queue.

-

If Reason is the atom kill, that is if - exit(Pid, kill) is called, an untrappable exit signal - is sent to Pid which will unconditionally exit with +

If Reason is the atom kill, that is if + exit(Pid, kill) is called, an untrappable exit signal + is sent to Pid which will unconditionally exit with exit reason killed.

- erlang:external_size(Term) -> integer() >= 0 + Calculate the maximum size for a term encoded in the Erlang external term format - - Term = term() -

Calculates, without doing the encoding, the maximum byte size for a term encoded in the Erlang external term format. The following condition applies always:

-> Size1 = byte_size(term_to_binary(Term)),
-> Size2 = erlang:external_size(Term),
+> Size1 = byte_size(term_to_binary(Term)),
+> Size2 = erlang:external_size(Term),
 > true = Size1 =< Size2.
 true
           

-

This is equivalent to a call to: erlang:external_size(Term, []) +

This is equivalent to a call to: erlang:external_size(Term, [])

- erlang:external_size(Term, [Option]) -> integer() >= 0 + Calculate the maximum size for a term encoded in the Erlang external term format - - Term = term() - Option = {minor_version, Version} -

Calculates, without doing the encoding, the maximum byte size for a term encoded in the Erlang external term format. The following condition applies always:

-> Size1 = byte_size(term_to_binary(Term, Options)),
-> Size2 = erlang:external_size(Term, Options),
+> Size1 = byte_size(term_to_binary(Term, Options)),
+> Size2 = erlang:external_size(Term, Options),
 > true = Size1 =< Size2.
 true
           

-

The option {minor_version, Version} specifies how floats +

The option {minor_version, Version} specifies how floats are encoded. See term_to_binary/2 for a more detailed description. @@ -1078,13 +921,10 @@ true - float(Number) -> float() + Convert a number to a float - - Number = number() - -

Returns a float by converting Number to a float.

+

Returns a float by converting Number to a float.

 > float(55).
 55.0
@@ -1101,14 +941,11 @@ true
- float_to_list(Float) -> string() + Text representation of a float - - Float = float() -

Returns a string which corresponds to the text - representation of Float.

+ representation of Float.

 > float_to_list(7.0).
 "7.00000000000000000000e+00"
@@ -1213,18 +1050,15 @@ true
- erlang:fun_info(Fun, Item) -> {Item, Info} + + Information about a fun - - Fun = fun() - Item, Info -- see below - - -

Returns information about Fun as specified by - Item, in the form {Item,Info}.

-

For any fun, Item can be any of the atoms + +

Returns information about Fun as specified by + Item, in the form {Item,Info}.

+

For any fun, Item can be any of the atoms module, name, arity, env, or type.

-

For a local fun, Item can also be any of the atoms +

For a local fun, Item can also be any of the atoms index, new_index, new_uniq, uniq, and pid. For an external fun, the value of any of these items is always the atom undefined.

@@ -1233,33 +1067,26 @@ true
- erlang:fun_to_list(Fun) -> string() + Text representation of a fun - - Fun = fun() -

Returns a string which corresponds to the text - representation of Fun.

+ representation of Fun.

- erlang:function_exported(Module, Function, Arity) -> boolean() + Check if a function is exported and loaded - - Module = Function = atom() - Arity = arity() - -

Returns true if the module Module is loaded - and contains an exported function Function/Arity; +

Returns true if the module Module is loaded + and contains an exported function Function/Arity; otherwise false.

Returns false for any BIF (functions implemented in C rather than in Erlang).

- garbage_collect() -> true + Force an immediate garbage collection of the calling process

Forces an immediate garbage collection of the currently @@ -1276,26 +1103,20 @@ true - garbage_collect(Pid) -> boolean() + Force an immediate garbage collection of a process - - Pid = pid() -

Works like erlang:garbage_collect() but on any process. The same caveats apply. Returns false if - Pid refers to a dead process; true otherwise.

+ Pid refers to a dead process; true otherwise.

- get() -> [{Key, Val}] + Return the process dictionary - - Key = Val = term() -

Returns the process dictionary as a list of - {Key, Val} tuples.

+ {Key, Val} tuples.

 > put(key1, merry),
 put(key2, lambs),
@@ -1305,14 +1126,11 @@ true
       
     
     
-      get(Key) -> Val | undefined
+      
       Return a value from the process dictionary
-      
-        Key = Val = term()
-      
       
-        

Returns the value Valassociated with Key in - the process dictionary, or undefined if Key +

Returns the value Valassociated with Key in + the process dictionary, or undefined if Key does not exist.

 > put(key1, merry),
@@ -1331,14 +1149,11 @@ true
       
     
     
-      get_keys(Val) -> [Key]
+      
       Return a list of keys from the process dictionary
-      
-        Val = Key = term()
-      
       
         

Returns a list of keys which are associated with the value - Val in the process dictionary.

+ Val in the process dictionary.

 > put(mary, {1, 2}),
 put(had, {1, 2}),
@@ -1351,28 +1166,23 @@ true
       
     
     
-      erlang:get_stacktrace() -> [{Module, Function, Arity | Args, Location}]
+      
       Get the call stack back-trace of the last exception
-      
-        Module = Function = atom()
-        Arity = arity()
-        Args = [term()]
-	Location = [{atom(),term()}]
-      
+      
       
         

Get the call stack back-trace (stacktrace) of the last exception in the calling process as a list of - {Module,Function,Arity,Location} tuples. - The Arity field in the first tuple may be the argument + {Module,Function,Arity,Location} tuples. + The Arity field in the first tuple may be the argument list of that function call instead of an arity integer, depending on the exception.

If there has not been any exceptions in a process, the - stacktrace is []. After a code change for the process, + stacktrace is []. After a code change for the process, the stacktrace may also be reset to [].

The stacktrace is the same data as the catch operator returns, for example:

{'EXIT',{badarg,Stacktrace}} = catch abs(x)

-

Location is a (possibly empty) list of two-tuples that +

Location is a (possibly empty) list of two-tuples that may indicate the location in the source code of the function. The first element is an atom that describes the type of information in the second element. Currently the following @@ -1397,11 +1207,8 @@ true - group_leader() -> GroupLeader + Get the group leader for the calling process - - GroupLeader = pid() -

Returns the pid of the group leader for the process which evaluates the function.

@@ -1414,13 +1221,10 @@ true
- group_leader(GroupLeader, Pid) -> true + Set the group leader for a process - - GroupLeader = Pid = pid() - -

Sets the group leader of Pid to GroupLeader. +

Sets the group leader of Pid to GroupLeader. Typically, this is used when a processes started from a certain shell should have another group leader than init.

@@ -1429,7 +1233,7 @@ true
- halt() + Halt the Erlang runtime system and indicate normal exit to the calling environment

Halts the Erlang runtime system and indicates normal exit to @@ -1440,29 +1244,26 @@ os_prompt%

- halt(Status) + Halt the Erlang runtime system - - Status = integer() >= 0 | string() - -

Status must be a non-negative integer, or a string. +

Status must be a non-negative integer, or a string. Halts the Erlang runtime system. Has no return value. - If Status is an integer, it is returned as an exit + If Status is an integer, it is returned as an exit status of Erlang to the calling environment. - If Status is a string, produces an Erlang crash dump - with String as slogan, and then exits with a non-zero + If Status is a string, produces an Erlang crash dump + with Status as slogan, and then exits with a non-zero status code.

Note that on many platforms, only the status codes 0-255 are supported by the operating system.

- erlang:hash(Term, Range) -> Hash + Hash function (deprecated) -

Returns a hash value for Term within the range - 1..Range. The allowed range is 1..2^27-1.

+

Returns a hash value for Term within the range + 1..Range. The allowed range is 1..2^27-1.

This BIF is deprecated as the hash value may differ on different architectures. Also the hash values for integer @@ -1475,35 +1276,28 @@ os_prompt%

- hd(List) -> term() + Head of a list - - List = [term()] - -

Returns the head of List, that is, the first element.

+

Returns the head of List, that is, the first element.

 > hd([1,2,3,4,5]).
 1

Allowed in guard tests.

-

Failure: badarg if List is the empty list [].

+

Failure: badarg if List is the empty list [].

- erlang:hibernate(Module, Function, Args) + Hibernate a process until a message is sent to it - - Module = Function = atom() - Args = [term()] -

Puts the calling process into a wait state where its memory allocation has been reduced as much as possible, which is useful if the process does not expect to receive any messages in the near future.

The process will be awaken when a message is sent to it, and - control will resume in Module:Function with - the arguments given by Args with the call stack + control will resume in Module:Function with + the arguments given by Args with the call stack emptied, meaning that the process will terminate when that function returns. Thus erlang:hibernate/3 will never return to its caller.

@@ -1533,14 +1327,11 @@ os_prompt%
- integer_to_list(Integer) -> string() + Text representation of an integer - - Integer = integer() -

Returns a string which corresponds to the text - representation of Integer.

+ representation of Integer.

 > integer_to_list(77).
 "77"
@@ -1558,14 +1349,11 @@ os_prompt%
- iolist_to_binary(IoListOrBinary) -> binary() + Convert an iolist to a binary - - IoListOrBinary = iolist() | binary() -

Returns a binary which is made from the integers and - binaries in IoListOrBinary.

+ binaries in IoListOrBinary.

 > Bin1 = <<1,2,3>>.
 <<1,2,3>>
@@ -1578,22 +1366,19 @@ os_prompt%
- iolist_size(Item) -> integer() >= 0 + Size of an iolist - - Item = iolist() | binary() -

Returns an integer which is the size in bytes of the binary that would be the result of - iolist_to_binary(Item).

+ iolist_to_binary(Item).

 > iolist_size([1,2|<<3,4>>]).
 4
- is_alive() -> boolean() + Check whether the local node is alive

Returns true if the local node is alive; that is, if @@ -1602,25 +1387,19 @@ os_prompt% - is_atom(Term) -> boolean() + Check whether a term is an atom - - Term = term() - -

Returns true if Term is an atom; +

Returns true if Term is an atom; otherwise returns false.

Allowed in guard tests.

- is_binary(Term) -> boolean() + Check whether a term is a binary - - Term = term() - -

Returns true if Term is a binary; +

Returns true if Term is a binary; otherwise returns false.

A binary always contains a complete number of bytes.

@@ -1629,78 +1408,58 @@ os_prompt%
- is_bitstring(Term) -> boolean() + Check whether a term is a bitstring - - Term = term() - -

Returns true if Term is a bitstring (including a binary); +

Returns true if Term is a bitstring (including a binary); otherwise returns false.

Allowed in guard tests.

- is_boolean(Term) -> boolean() + Check whether a term is a boolean - - Term = term() - -

Returns true if Term is +

Returns true if Term is either the atom true or the atom false (i.e. a boolean); otherwise returns false.

Allowed in guard tests.

- erlang:is_builtin(Module, Function, Arity) -> boolean() + Check if a function is a BIF implemented in C - - Module = Function = atom() - Arity = arity() - -

Returns true if Module:Function/Arity is +

Returns true if Module:Function/Arity is a BIF implemented in C; otherwise returns false. This BIF is useful for builders of cross reference tools.

- is_float(Term) -> boolean() + Check whether a term is a float - - Term = term() - -

Returns true if Term is a floating point +

Returns true if Term is a floating point number; otherwise returns false.

Allowed in guard tests.

- is_function(Term) -> boolean() + Check whether a term is a fun - - Term = term() - -

Returns true if Term is a fun; otherwise +

Returns true if Term is a fun; otherwise returns false.

Allowed in guard tests.

- is_function(Term, Arity) -> boolean() + Check whether a term is a fun with a given arity - - Term = term() - Arity = arity() - -

Returns true if Term is a fun that can be - applied with Arity number of arguments; otherwise +

Returns true if Term is a fun that can be + applied with Arity number of arguments; otherwise returns false.

Allowed in guard tests.

@@ -1713,74 +1472,56 @@ os_prompt%
- is_integer(Term) -> boolean() + Check whether a term is an integer - - Term = term() - -

Returns true if Term is an integer; +

Returns true if Term is an integer; otherwise returns false.

Allowed in guard tests.

- is_list(Term) -> boolean() + Check whether a term is a list - - Term = term() - -

Returns true if Term is a list with +

Returns true if Term is a list with zero or more elements; otherwise returns false.

Allowed in guard tests.

- is_number(Term) -> boolean() + Check whether a term is a number - - Term = term() - -

Returns true if Term is either an integer or a +

Returns true if Term is either an integer or a floating point number; otherwise returns false.

Allowed in guard tests.

- is_pid(Term) -> boolean() + Check whether a term is a pid - - Term = term() - -

Returns true if Term is a pid (process +

Returns true if Term is a pid (process identifier); otherwise returns false.

Allowed in guard tests.

- is_port(Term) -> boolean() + Check whether a term is a port - - Term = term() - -

Returns true if Term is a port identifier; +

Returns true if Term is a port identifier; otherwise returns false.

Allowed in guard tests.

- is_process_alive(Pid) -> boolean() + Check whether a process is alive - - Pid = pid() -

- Pid must refer to a process at the local node. + Pid must refer to a process at the local node. Returns true if the process exists and is alive, that is, is not exiting and has not exited. Otherwise, returns false. @@ -1788,41 +1529,32 @@ os_prompt% - is_record(Term, RecordTag) -> boolean() + Check whether a term appears to be a record - - Term = term() - RecordTag = atom() - -

Returns true if Term is a tuple and its first - element is RecordTag. Otherwise, returns false.

+

Returns true if Term is a tuple and its first + element is RecordTag. Otherwise, returns false.

Normally the compiler treats calls to is_record/2 - specially. It emits code to verify that Term is a - tuple, that its first element is RecordTag, and that - the size is correct. However, if the RecordTag is + specially. It emits code to verify that Term is a + tuple, that its first element is RecordTag, and that + the size is correct. However, if the RecordTag is not a literal atom, the is_record/2 BIF will be called instead and the size of the tuple will not be verified.

-

Allowed in guard tests, if RecordTag is a literal +

Allowed in guard tests, if RecordTag is a literal atom.

- is_record(Term, RecordTag, Size) -> boolean() + Check whether a term appears to be a record - - Term = term() - RecordTag = atom() - Size = integer() - - -

RecordTag must be an atom. Returns true if - Term is a tuple, its first element is RecordTag, - and its size is Size. Otherwise, returns false.

-

Allowed in guard tests, provided that RecordTag is + +

RecordTag must be an atom. Returns true if + Term is a tuple, its first element is RecordTag, + and its size is Size. Otherwise, returns false.

+

Allowed in guard tests, provided that RecordTag is a literal atom and Size is a literal integer.

This BIF is documented for completeness. In most cases @@ -1831,37 +1563,28 @@ os_prompt% - is_reference(Term) -> boolean() + Check whether a term is a reference - - Term = term() - -

Returns true if Term is a reference; +

Returns true if Term is a reference; otherwise returns false.

Allowed in guard tests.

- is_tuple(Term) -> boolean() + Check whether a term is a tuple - - Term = term() - -

Returns true if Term is a tuple; +

Returns true if Term is a tuple; otherwise returns false.

Allowed in guard tests.

- length(List) -> integer() >= 0 + Length of a list - - List = [term()] - -

Returns the length of List.

+

Returns the length of List.

 > length([1,2,3,4,5,6,7,8,9]).
 9
@@ -1869,52 +1592,43 @@ os_prompt%
- link(Pid) -> true + Create a link to another process (or port) - - Pid = pid() | port() -

Creates a link between the calling process and another - process (or port) Pid, if there is not such a link + process (or port) PidOrPort, if there is not such a link already. If a process attempts to create a link to itself, nothing is done. Returns true.

-

If Pid does not exist, the behavior of the BIF depends +

If PidOrPort does not exist, the behavior of the BIF depends on if the calling process is trapping exits or not (see process_flag/2):

If the calling process is not trapping exits, and - checking Pid is cheap -- that is, if Pid is + checking PidOrPort is cheap -- that is, if PidOrPort is local -- link/1 fails with reason noproc. Otherwise, if the calling process is trapping exits, - and/or Pid is remote, link/1 returns + and/or PidOrPort is remote, link/1 returns true, but an exit signal with reason noproc is sent to the calling process.
- list_to_atom(String) -> atom() + Convert from text representation to an atom - - String = string() - -

Returns the atom whose text representation is String.

+

Returns the atom whose text representation is String.

 > list_to_atom("Erlang").
 'Erlang'
- list_to_binary(IoList) -> binary() + Convert a list to a binary - - IoList = iolist() -

Returns a binary which is made from the integers and - binaries in IoList.

+ binaries in IoList.

 > Bin1 = <<1,2,3>>.
 <<1,2,3>>
@@ -1927,14 +1641,12 @@ os_prompt%
- list_to_bitstring(BitstringList) -> bitstring() + + Convert a list to a bitstring - - BitstringList = [BitstringList | bitstring() | char()] -

Returns a bitstring which is made from the integers and - bitstrings in BitstringList. (The last tail in BitstringList + bitstrings in BitstringList. (The last tail in BitstringList is allowed to be a bitstring.)

 > Bin1 = <<1,2,3>>.
@@ -1943,51 +1655,42 @@ os_prompt%
<<4,5>> > Bin3 = <<6,7:4,>>. <<6>> -> list_to_binary([Bin1,1,[2,3,Bin2],4|Bin3]). +> list_to_bitstring([Bin1,1,[2,3,Bin2],4|Bin3]). <<1,2,3,1,2,3,4,5,4,6,7:46>>
- list_to_existing_atom(String) -> atom() + Convert from text representation to an atom - - String = string() - -

Returns the atom whose text representation is String, +

Returns the atom whose text representation is String, but only if there already exists such atom.

Failure: badarg if there does not already exist an atom - whose text representation is String.

+ whose text representation is String.

- list_to_float(String) -> float() + Convert from text representation to a float - - String = string() - -

Returns the float whose text representation is String.

+

Returns the float whose text representation is String.

 > list_to_float("2.2017764e+0").
 2.2017764
-

Failure: badarg if String contains a bad +

Failure: badarg if String contains a bad representation of a float.

- list_to_integer(String) -> integer() + Convert from text representation to an integer - - String = string() -

Returns an integer whose text representation is - String.

+ String.

 > list_to_integer("123").
 123
-

Failure: badarg if String contains a bad +

Failure: badarg if String contains a bad representation of an integer.

@@ -2005,13 +1708,10 @@ os_prompt% - list_to_pid(String) -> pid() + Convert from text representation to a pid - - String = string() - -

Returns a pid whose text representation is String.

+

Returns a pid whose text representation is String.

This BIF is intended for debugging and for use in the Erlang operating system. It should not be used in @@ -2020,18 +1720,15 @@ os_prompt%

 > list_to_pid("<0.4.1>").
 <0.4.1>
-

Failure: badarg if String contains a bad +

Failure: badarg if String contains a bad representation of a pid.

- list_to_tuple(List) -> tuple() + Convert a list to a tuple - - List = [term()] - -

Returns a tuple which corresponds to List. List +

Returns a tuple which corresponds to List. List can contain any Erlang terms.

 > list_to_tuple([share, ['Ericsson_B', 163]]).
@@ -2039,38 +1736,30 @@ os_prompt%
- load_module(Module, Binary) -> {module, Module} | {error, Reason} + Load object code for a module - - Module = atom() - Binary = binary() - Reason = badfile | not_purged | badfile - - -

If Binary contains the object code for the module - Module, this BIF loads that object code. Also, if - the code for the module Module already exists, all + +

If Binary contains the object code for the module + Module, this BIF loads that object code. Also, if + the code for the module Module already exists, all export references are replaced so they point to the newly loaded code. The previously loaded code is kept in the system as old code, as there may still be processes which are executing that code. It returns either - {module, Module}, or {error, Reason} if loading - fails. Reason is one of the following:

+ {module, Module}, or {error, Reason} if loading + fails. Reason is one of the following:

badfile -

The object code in Binary has an incorrect format.

+

The object code in Binary has an + incorrect format or the object code contains code + for another module than Module.

not_purged -

Binary contains a module which cannot be loaded +

Binary contains a module which cannot be loaded because old code for this module already exists.

- badfile - -

The object code contains code for another module than - Module

-

This BIF is intended for the code server (see @@ -2080,15 +1769,8 @@ os_prompt% - erlang:load_nif(Path, LoadInfo) -> ok | {error, {Reason, Text}} + Load NIF library - - Path = string() - LoadInfo = term() - Reason = load_failed | bad_lib | load | reload | - upgrade | old_code - Text = string() -

In releases older than OTP R14B, NIFs were an @@ -2099,21 +1781,21 @@ os_prompt% {error,Reason,Text}.

Loads and links a dynamic library containing native - implemented functions (NIFs) for a module. Path is a + implemented functions (NIFs) for a module. Path is a file path to the sharable object/dynamic library file minus the OS-dependent file extension (.so for Unix and .dll for Windows). See erl_nif on how to implement a NIF library.

-

LoadInfo can be any term. It will be passed on to +

LoadInfo can be any term. It will be passed on to the library as part of the initialization. A good practice is to include a module version number to support future code upgrade scenarios.

The call to load_nif/2 must be made directly from the Erlang code of the module that the NIF library belongs to.

-

It returns either ok, or {error,{Reason,Text}} - if loading fails. Reason is one of the atoms below, - while Text is a human readable string that may give +

It returns either ok, or {error,{Reason,Text}} + if loading fails. Reason is one of the atoms below, + while Text is a human readable string that may give some more information about the failure.

load_failed @@ -2139,11 +1821,8 @@ os_prompt%
- erlang:loaded() -> [Module] + List of all loaded modules - - Module = atom() -

Returns a list of all loaded Erlang modules (current and/or old code), including preloaded modules.

@@ -2151,11 +1830,8 @@ os_prompt%
- erlang:localtime() -> DateTime + Current local date and time - - DateTime = calendar:datetime() -

Returns the current local date and time {{Year, Month, Day}, {Hour, Minute, Second}}.

@@ -2172,32 +1848,27 @@ os_prompt%

Converts local date and time to Universal Time Coordinated (UTC), if this is supported by the underlying OS. Otherwise, - no conversion is done and {Date1, Time1} is returned.

+ no conversion is done and Localtime is returned.

 > erlang:localtime_to_universaltime({{1996,11,6},{14,45,17}}).
 {{1996,11,6},{13,45,17}}
-

Failure: badarg if Date1 or Time1 do - not denote a valid date or time.

+

Failure: badarg if Localtime does not denote + a valid date and time.

- erlang:localtime_to_universaltime({Date1, Time1}, IsDst) -> {Date2, Time2} + Convert from local to Universal Time Coordinated (UTC) date and time - - Date1 = Date2 = calendar:date() - Time1 = Time2 = calendar:time() - IsDst = true | false | undefined -

Converts local date and time to Universal Time Coordinated (UTC) just like erlang:localtime_to_universaltime/1, but the caller decides if daylight saving time is active or not.

-

If IsDst == true the {Date1, Time1} is during - daylight saving time, if IsDst == false it is not, - and if IsDst == undefined the underlying OS may +

If IsDst == true the Localtime is during + daylight saving time, if IsDst == false it is not, + and if IsDst == undefined the underlying OS may guess, which is the same as calling - erlang:localtime_to_universaltime({Date1, Time1}).

+ erlang:localtime_to_universaltime(Localtime).

 > erlang:localtime_to_universaltime({{1996,11,6},{14,45,17}}, true).
 {{1996,11,6},{12,45,17}}
@@ -2205,12 +1876,12 @@ os_prompt%
{{1996,11,6},{13,45,17}} > erlang:localtime_to_universaltime({{1996,11,6},{14,45,17}}, undefined). {{1996,11,6},{13,45,17}} -

Failure: badarg if Date1 or Time1 do - not denote a valid date or time.

+

Failure: badarg if Localtime does not denote + a valid date and time.

- make_ref() -> reference() + Return an almost unique reference

Returns an almost unique reference.

@@ -2222,33 +1893,23 @@ os_prompt%
- erlang:make_tuple(Arity, InitialValue) -> tuple() + Create a new tuple of a given arity - - Arity = arity() - InitialValue = term() - -

Returns a new tuple of the given Arity, where all - elements are InitialValue.

+

Returns a new tuple of the given Arity, where all + elements are InitialValue.

 > erlang:make_tuple(4, []).
 {[],[],[],[]}
- erlang:make_tuple(Arity, Default, InitList) -> tuple() + Create a new tuple with given arity and contents - - Arity = arity() - Default = term() - InitList = [{Position,term()}] - Position = integer() - - -

erlang:make_tuple first creates a tuple of size Arity - where each element has the value Default. It then fills - in values from InitList. Each list element in InitList + +

erlang:make_tuple first creates a tuple of size Arity + where each element has the value DefaultValue. It then fills + in values from InitList. Each list element in InitList must be a two-tuple where the first element is a position in the newly created tuple and the second element is any term. If a position occurs more than once in the list, the term corresponding to @@ -2267,15 +1928,11 @@ os_prompt% - erlang:md5(Data) -> Digest + Compute an MD5 message digest - - Data = iodata() - Digest = binary() - -

Computes an MD5 message digest from Data, where - the length of the digest is 128 bits (16 bytes). Data +

Computes an MD5 message digest from Data, where + the length of the digest is 128 bits (16 bytes). Data is a binary or a list of small integers and binaries.

See The MD5 Message Digest Algorithm (RFC 1321) for more information about MD5.

@@ -2284,51 +1941,39 @@ os_prompt%
- erlang:md5_final(Context) -> Digest + Finish the update of an MD5 context and return the computed MD5 message digest - - Context = Digest = binary() - -

Finishes the update of an MD5 Context and returns +

Finishes the update of an MD5 Context and returns the computed MD5 message digest.

- erlang:md5_init() -> Context + Create an MD5 context - - Context = binary() -

Creates an MD5 context, to be used in subsequent calls to md5_update/2.

- erlang:md5_update(Context, Data) -> NewContext + Update an MD5 context with data, and return a new context - - Data = iodata() - Context = NewContext = binary() - -

Updates an MD5 Context with Data, and returns - a NewContext.

+

Updates an MD5 Context with Data, and returns + a NewContext.

- erlang:memory() -> [{Type, Size}] + + Information about dynamically allocated memory - - Type, Size -- see below -

Returns a list containing information about memory dynamically allocated by the Erlang emulator. Each element of the list is a tuple {Type, Size}. The first element - Typeis an atom describing memory type. The second - element Sizeis memory size in bytes. A description of + Typeis an atom describing memory type. The second + element Sizeis memory size in bytes. A description of each memory type follows:

total @@ -2390,6 +2035,14 @@ os_prompt%

This memory is part of the memory presented as system memory.

+ low + +

Only on 64-bit halfword emulator.

+

The total amount of memory allocated in low memory areas + that are restricted to less than 4 Gb even though + the system may have more physical memory.

+

May be removed in future releases of halfword emulator.

+
maximum

The maximum total amount of memory allocated since @@ -2401,14 +2054,6 @@ os_prompt% instrument(3) and/or erl(1).

- low - -

Only on 64-bit halfword emulator.

-

The total amount of memory allocated in low memory areas - that are restricted to less than 4 Gb even though - the system may have more physical memory.

-

May be removed in future releases of halfword emulator.

-

The system value is not complete. Some allocated @@ -2472,16 +2117,15 @@ os_prompt% - erlang:memory(Type | [Type]) -> Size | [{Type, Size}] + + + Information about dynamically allocated memory - - Type, Size -- see below -

Returns the memory size in bytes allocated for memory of - type Type. The argument can also be given as a list - of Type atoms, in which case a corresponding list of - {Type, Size} tuples is returned.

+ type Type. The argument can also be given as a list + of memory_type() atoms, in which case a corresponding list of + {memory_type(), Size :: integer >= 0} tuples is returned.

Since erts version 5.6.4 erlang:memory/1 requires that @@ -2493,13 +2137,13 @@ os_prompt% badarg - If Type is not one of the memory types listed in the + If Type is not one of the memory types listed in the documentation of erlang:memory/0. badarg - If maximum is passed as Type and the emulator + If maximum is passed as Type and the emulator is not run in instrumented mode. notsup @@ -2521,13 +2165,10 @@ os_prompt% - module_loaded(Module) -> boolean() + Check if a module is loaded - - Module = atom() - -

Returns true if the module Module is loaded, +

Returns true if the module Module is loaded, otherwise returns false. It does not attempt to load the module.

@@ -2538,22 +2179,15 @@ os_prompt%
- monitor(Type, Item) -> MonitorRef + Start monitoring - - Type = process - Item = pid() | {RegName, Node} | RegName -  RegName = atom() -  Node = node() - MonitorRef = reference() - - -

The calling process starts monitoring Item which is - an object of type Type.

+ +

The calling process starts monitoring Item which is + an object of type Type.

Currently only processes can be monitored, i.e. the only - allowed Type is process, but other types may be + allowed Type is process, but other types may be allowed in the future.

-

Item can be:

+

Item can be:

pid() @@ -2579,8 +2213,8 @@ os_prompt% unregistered.

A 'DOWN' message will be sent to the monitoring - process if Item dies, if Item does not exist, - or if the connection is lost to the node which Item + process if Item dies, if Item does not exist, + or if the connection is lost to the node which Item resides on. A 'DOWN' message has the following pattern:

{'DOWN', MonitorRef, Type, Object, Info} @@ -2591,11 +2225,11 @@ os_prompt%

A reference to the monitored object:

- the pid of the monitored process, if Item was + the pid of the monitored process, if Item was specified as a pid. - {RegName, Node}, if Item was specified as + {RegName, Node}, if Item was specified as {RegName, Node}. - {RegName, Node}, if Item was specified as + {RegName, Node}, if Item was specified as RegName. Node will in this case be the name of the local node (node()). @@ -2604,7 +2238,7 @@ os_prompt%

Either the exit reason of the process, noproc (non-existing process), or noconnection (no - connection to Node).

+ connection to Node).

@@ -2622,7 +2256,7 @@ os_prompt% where remote process monitoring by registered name is not implemented), the call fails with badarg.

Making several calls to monitor/2 for the same - Item is not an error; it results in as many, completely + Item is not an error; it results in as many, completely independent, monitorings.

The format of the 'DOWN' message changed in the 5.2 @@ -2640,25 +2274,21 @@ os_prompt% - monitor_node(Node, Flag) -> true + Monitor the status of a node - - Node = node() - Flag = boolean() - -

Monitors the status of the node Node. If Flag - is true, monitoring is turned on; if Flag is +

Monitors the status of the node Node. If Flag + is true, monitoring is turned on; if Flag is false, monitoring is turned off.

Making several calls to monitor_node(Node, true) for - the same Node is not an error; it results in as many, + the same Node is not an error; it results in as many, completely independent, monitorings.

-

If Node fails or does not exist, the message +

If Node fails or does not exist, the message {nodedown, Node} is delivered to the process. If a process has made two calls to monitor_node(Node, true) - and Node terminates, two nodedown messages are + and Node terminates, two nodedown messages are delivered to the process. If there is no connection to - Node, there will be an attempt to create one. If this + Node, there will be an attempt to create one. If this fails, a nodedown message is delivered.

Nodes connected through hidden connections can be monitored as any other node.

@@ -2666,14 +2296,8 @@ os_prompt%
- erlang:monitor_node(Node, Flag, Options) -> true + Monitor the status of a node - - Node = node() - Flag = boolean() - Options = [Option] - Option = allow_passive_connect -

Behaves as monitor_node/2 except that it allows an extra option to be given, namely allow_passive_connect. @@ -2696,11 +2320,8 @@ os_prompt% - erlang:nif_error(Reason) + Stop execution with a given reason - - Reason = term() -

Works exactly like erlang:error/1, @@ -2711,12 +2332,8 @@ os_prompt% - erlang:nif_error(Reason, Args) + Stop execution with a given reason - - Reason = term() - Args = [term()] -

Works exactly like erlang:error/2, @@ -2727,11 +2344,8 @@ os_prompt% - node() -> Node + Name of the local node - - Node = node() -

Returns the name of the local node. If the node is not alive, nonode@nohost is returned instead.

@@ -2739,14 +2353,10 @@ os_prompt%
- node(Arg) -> Node + At which node is a pid, port or reference located - - Arg = pid() | port() | reference() - Node = node() - -

Returns the node where Arg is located. Arg can +

Returns the node where Arg is located. Arg can be a pid, a reference, or a port. If the local node is not alive, nonode@nohost is returned.

Allowed in guard tests.

@@ -2761,17 +2371,13 @@ os_prompt%
- nodes(Arg | [Arg]) -> Nodes + All nodes of a certain type in the system - - Arg = visible | hidden | connected | this | known - Nodes = [node()] -

Returns a list of nodes according to argument given. The result returned when the argument is a list, is the list of nodes satisfying the disjunction(s) of the list elements.

-

Arg can be any of the following:

+

NodeType can be any of the following:

visible @@ -2800,15 +2406,12 @@ os_prompt% nodes() = nodes(visible).

If the local node is not alive, nodes(this) == nodes(known) == [nonode@nohost], for - any other Arg the empty list [] is returned.

+ any other Arg the empty list [] is returned.

- now() -> timestamp() - - timestamp() = {MegaSecs, Secs, MicroSecs} - MegaSecs = Secs = MicroSecs = integer() >= 0 - + + Elapsed time since 00:00 GMT

Returns the tuple {MegaSecs, Secs, MicroSecs} which is @@ -2826,35 +2429,19 @@ os_prompt% - open_port(PortName, PortSettings) -> port() + Open a port - - PortName = {spawn, Command} | {spawn_driver, Command} | {spawn_executable, FileName} | {fd, In, Out} -  Command = string() -  FileName = [ FileNameChar ] | binary() -  FileNameChar = integer() (1..255 or any Unicode codepoint, see description) -  In = Out = integer() - PortSettings = [Opt] -  Opt = {packet, N} | stream | {line, L} | {cd, Dir} | {env, Env} | {args, [ ArgString ]} | {arg0, ArgString} | exit_status | use_stdio | nouse_stdio | stderr_to_stdout | in | out | binary | eof -   N = 1 | 2 | 4 -   L = integer() -   Dir = string() -   ArgString = [ FileNameChar ] | binary() -   Env = [{Name, Val}] -    Name = string() -    Val = string() | false -

Returns a port identifier as the result of opening a new Erlang port. A port can be seen as an external Erlang - process. PortName is one of the following:

+ process. PortName is one of the following:

- {spawn, Command} + {spawn, Command} -

Starts an external program. Command is the name - of the external program which will be run. Command +

Starts an external program. Command is the name + of the external program which will be run. Command runs outside the Erlang work space unless an Erlang - driver with the name Command is found. If found, + driver with the name Command is found. If found, that driver will be started. A driver runs in the Erlang workspace, which means that it is linked with the Erlang runtime system.

@@ -2874,24 +2461,24 @@ os_prompt% name of the executable (or driver). This (among other things) makes this option unsuitable for running programs having spaces in file or directory names. Use - {spawn_executable, Command} instead if spaces in executable + {spawn_executable, Command} instead if spaces in executable file names is desired.

- {spawn_driver, Command} + {spawn_driver, Command} -

Works like {spawn, Command}, but demands the +

Works like {spawn, Command}, but demands the first (space separated) token of the command to be the name of a loaded driver. If no driver with that name is loaded, a badarg error is raised.

- {spawn_executable, Command} + {spawn_executable, FileName} -

Works like {spawn, Command}, but only runs - external executables. The Command in its whole +

Works like {spawn, FileName}, but only runs + external executables. The FileName in its whole is used as the name of the executable, including any spaces. If arguments are to be passed, the - args and arg0 PortSettings can be used.

+ args and arg0 PortSettings can be used.

The shell is not usually invoked to start the program, it's executed directly. Neither is the @@ -2922,7 +2509,7 @@ os_prompt% of the executable is limited to the ISO-latin-1 character set.

-

If the Command cannot be run, an error +

If the FileName cannot be run, an error exception, with the posix error code as the reason, is raised. The error reason may differ between operating systems. Typically the error enoent is raised @@ -2930,23 +2517,23 @@ os_prompt% eaccess is raised when the given file is not executable.

- {fd, In, Out} + {fd, In, Out}

Allows an Erlang process to access any currently opened file descriptors used by Erlang. The file descriptor - In can be used for standard input, and the file - descriptor Out for standard output. It is only + In can be used for standard input, and the file + descriptor Out for standard output. It is only used for various servers in the Erlang operating system (shell and user). Hence, its use is very limited.

-

PortSettings is a list of settings for the port. +

PortSettings is a list of settings for the port. Valid settings are:

- {packet, N} + {packet, N} -

Messages are preceded by their length, sent in N +

Messages are preceded by their length, sent in N bytes, with the most significant byte first. Valid values for N are 1, 2, or 4.

@@ -2956,7 +2543,7 @@ os_prompt% user-defined protocol must be used between the Erlang process and the external object.

- {line, L} + {line, L}

Messages are delivered on a per line basis. Each line (delimited by the OS-dependent newline sequence) is @@ -2964,7 +2551,7 @@ os_prompt% is {Flag, Line}, where Flag is either eol or noeol and Line is the actual data delivered (without the newline sequence).

-

L specifies the maximum line length in bytes. +

L specifies the maximum line length in bytes. Lines longer than this will be delivered in more than one message, with the Flag set to noeol for all but the last message. If end of file is encountered @@ -2972,36 +2559,36 @@ os_prompt% sequence, the last line will also be delivered with the Flag set to noeol. In all other cases, lines are delivered with Flag set to eol.

-

The {packet, N} and {line, L} settings are +

The {packet, N} and {line, L} settings are mutually exclusive.

- {cd, Dir} + {cd, Dir} -

This is only valid for {spawn, Command} and - {spawn_executable, Command}. - The external program starts using Dir as its - working directory. Dir must be a string. Not +

This is only valid for {spawn, Command} and + {spawn_executable, FileName}. + The external program starts using Dir as its + working directory. Dir must be a string. Not available on VxWorks.

- {env, Env} + {env, Env} -

This is only valid for {spawn, Command} and - {spawn_executable, Command}. +

This is only valid for {spawn, Command} and + {spawn_executable, FileName}. The environment of the started process is extended using - the environment specifications in Env.

-

Env should be a list of tuples {Name, Val}, - where Name is the name of an environment variable, - and Val is the value it is to have in the spawned - port process. Both Name and Val must be - strings. The one exception is Val being the atom + the environment specifications in Env.

+

Env should be a list of tuples {Name, Val}, + where Name is the name of an environment variable, + and Val is the value it is to have in the spawned + port process. Both Name and Val must be + strings. The one exception is Val being the atom false (in analogy with os:getenv/1), which removes the environment variable. Not available on VxWorks.

- {args, [ string() ]} + {args, [ string() | binary() ]} -

This option is only valid for {spawn_executable, Command} +

This option is only valid for {spawn_executable, FileName} and specifies arguments to the executable. Each argument is given as a separate string and (on Unix) eventually ends up as one element each in the argument vector. On @@ -3044,10 +2631,10 @@ os_prompt% option can be used.

- {arg0, string()} + {arg0, string() | binary()} -

This option is only valid for {spawn_executable, Command} +

This option is only valid for {spawn_executable, FileName} and explicitly specifies the program name argument when running an executable. This might in some circumstances, on some operating systems, be desirable. How the program @@ -3061,9 +2648,9 @@ os_prompt% exit_status -

This is only valid for {spawn, Command} where - Command refers to an external program, and for - {spawn_executable, Command}.

+

This is only valid for {spawn, Command} where + Command refers to an external program, and for + {spawn_executable, FileName}.

When the external process connected to the port exits, a message of the form {Port,{exit_status,Status}} is sent to the connected process, where Status is the @@ -3078,8 +2665,8 @@ os_prompt% use_stdio -

This is only valid for {spawn, Command} and - {spawn_executable, Command}. It +

This is only valid for {spawn, Command} and + {spawn_executable, FileName}. It allows the standard input and output (file descriptors 0 and 1) of the spawned (UNIX) process for communication with Erlang.

@@ -3176,7 +2763,7 @@ os_prompt%
enoent -

The Command given in {spawn_executable, Command} does not point out an existing file.

+

The FileName given in {spawn_executable, FileName} does not point out an existing file.

During use of a port opened using {spawn, Name}, @@ -3192,56 +2779,47 @@ os_prompt% - erlang:phash(Term, Range) -> Hash + + Range = 1..2^32, Hash = 1..Range Portable hash function - - Term = term() - Range = 1..2^32 - Hash = 1..Range -

Portable hash function that will give the same hash for the same Erlang term regardless of machine architecture and ERTS version (the BIF was introduced in ERTS 4.9.1.1). Range can be between 1 and 2^32, the function returns a hash value - for Term within the range 1..Range.

+ for Term within the range 1..Range.

This BIF could be used instead of the old deprecated erlang:hash/2 BIF, as it calculates better hashes for all data-types, but consider using phash2/1,2 instead.

- erlang:phash2(Term [, Range]) -> Hash + + + 1..2^32 + 0..Range-1 Portable hash function - - Term = term() - Range = 1..2^32 - Hash = 0..Range-1 -

Portable hash function that will give the same hash for the same Erlang term regardless of machine architecture and ERTS version (the BIF was introduced in ERTS 5.2). Range can be between 1 and 2^32, the function returns a hash value for - Term within the range 0..Range-1. When called - without the Range argument, a value in the range + Term within the range 0..Range-1. When called + without the Range argument, a value in the range 0..2^27-1 is returned.

This BIF should always be used for hashing terms. It distributes small integers better than phash/2, and it is faster for bignums and binaries.

-

Note that the range 0..Range-1 is different from - the range of phash/2 (1..Range).

+

Note that the range 0..Range-1 is different from + the range of phash/2 (1..Range).

- pid_to_list(Pid) -> string() + Text representation of a pid - - Pid = pid() -

Returns a string which corresponds to the text - representation of Pid.

+ representation of Pid.

This BIF is intended for debugging and for use in the Erlang operating system. It should not be used in @@ -3250,88 +2828,74 @@ os_prompt% - port_close(Port) -> true + Close an open port - - Port = port() | atom() -

Closes an open port. Roughly the same as - Port ! {self(), close} except for the error behaviour + Port ! {self(), close} except for the error behaviour (see below), and that the port does not reply with {Port, closed}. Any process may close a port with port_close/1, not only the port owner (the connected process).

-

For comparison: Port ! {self(), close} fails with - badarg if Port cannot be sent to (i.e., - Port refers neither to a port nor to a process). If - Port is a closed port nothing happens. If Port +

For comparison: Port ! {self(), close} fails with + badarg if Port cannot be sent to (i.e., + Port refers neither to a port nor to a process). If + Port is a closed port nothing happens. If Port is an open port and the calling process is the port owner, the port replies with {Port, closed} when all buffers have been flushed and the port really closes, but if the calling process is not the port owner the port owner fails with badsig.

Note that any process can close a port using - Port ! {PortOwner, close} just as if it itself was + Port ! {PortOwner, close} just as if it itself was the port owner, but the reply always goes to the port owner.

In short: port_close(Port) has a cleaner and more - logical behaviour than Port ! {self(), close}.

-

Failure: badarg if Port is not an open port or + logical behaviour than Port ! {self(), close}.

+

Failure: badarg if Port is not an open port or the registered name of an open port.

- port_command(Port, Data) -> true + Send data to a port - - Port = port() | atom() - Data = iodata() -

Sends data to a port. Same as - Port ! {self(), {command, Data}} except for the error + Port ! {self(), {command, Data}} except for the error behaviour (see below). Any process may send data to a port with port_command/2, not only the port owner (the connected process).

-

For comparison: Port ! {self(), {command, Data}} - fails with badarg if Port cannot be sent to - (i.e., Port refers neither to a port nor to a process). - If Port is a closed port the data message disappears - without a sound. If Port is open and the calling +

For comparison: Port ! {self(), {command, Data}} + fails with badarg if Port cannot be sent to + (i.e., Port refers neither to a port nor to a process). + If Port is a closed port the data message disappears + without a sound. If Port is open and the calling process is not the port owner, the port owner fails with badsig. The port owner fails with badsig - also if Data is not a valid IO list.

+ also if Data is not a valid IO list.

Note that any process can send to a port using - Port ! {PortOwner, {command, Data}} just as if it + Port ! {PortOwner, {command, Data}} just as if it itself was the port owner.

-

In short: port_command(Port, Data) has a cleaner and +

In short: port_command(Port, Data) has a cleaner and more logical behaviour than - Port ! {self(), {command, Data}}.

+ Port ! {self(), {command, Data}}.

If the port is busy, the calling process will be suspended until the port is not busy anymore.

Failures:

badarg - If Port is not an open port or the registered name + If Port is not an open port or the registered name of an open port. badarg - If Data is not a valid io list. + If Data is not a valid io list.
- port_command(Port, Data, OptionList) -> boolean() + Send data to a port - - Port = port() | atom() - Data = iodata() - OptionList = [Option] - Option = force - Option = nosuspend -

Sends data to a port. port_command(Port, Data, []) equals port_command(Port, Data).

@@ -3339,7 +2903,7 @@ os_prompt% otherwise, true is returned.

If the port is busy, the calling process will be suspended until the port is not busy anymore.

-

Currently the following Options are valid:

+

Currently the following Options are valid:

force The calling process will not be suspended if the port is @@ -3363,16 +2927,16 @@ os_prompt% badarg - If Port is not an open port or the registered name + If Port is not an open port or the registered name of an open port. badarg - If Data is not a valid io list. + If Data is not a valid io list. badarg - If OptionList is not a valid option list. + If OptionList is not a valid option list. notsup @@ -3384,15 +2948,11 @@ os_prompt%
- port_connect(Port, Pid) -> true + Set the owner of a port - - Port = port() | atom() - Pid = pid() - -

Sets the port owner (the connected port) to Pid. - Roughly the same as Port ! {self(), {connect, Pid}} +

Sets the port owner (the connected port) to Pid. + Roughly the same as Port ! {self(), {connect, Pid}} except for the following:

@@ -3410,160 +2970,142 @@ os_prompt% unlink(Port) if this is not desired. Any process may set the port owner to be any process with port_connect/2.

-

For comparison: Port ! {self(), {connect, Pid}} fails - with badarg if Port cannot be sent to (i.e., - Port refers neither to a port nor to a process). If - Port is a closed port nothing happens. If Port +

For comparison: Port ! {self(), {connect, Pid}} fails + with badarg if Port cannot be sent to (i.e., + Port refers neither to a port nor to a process). If + Port is a closed port nothing happens. If Port is an open port and the calling process is the port owner, the port replies with {Port, connected} to the old port owner. Note that the old port owner is still linked to - the port, and that the new is not. If Port is an open + the port, and that the new is not. If Port is an open port and the calling process is not the port owner, the port owner fails with badsig. The port - owner fails with badsig also if Pid is not an + owner fails with badsig also if Pid is not an existing local pid.

Note that any process can set the port owner using - Port ! {PortOwner, {connect, Pid}} just as if it + Port ! {PortOwner, {connect, Pid}} just as if it itself was the port owner, but the reply always goes to the port owner.

-

In short: port_connect(Port, Pid) has a cleaner and +

In short: port_connect(Port, Pid) has a cleaner and more logical behaviour than - Port ! {self(),{connect,Pid}}.

-

Failure: badarg if Port is not an open port - or the registered name of an open port, or if Pid is + Port ! {self(),{connect,Pid}}.

+

Failure: badarg if Port is not an open port + or the registered name of an open port, or if Pid is not an existing local pid.

- port_control(Port, Operation, Data) -> Res + Perform a synchronous control operation on a port - - Port = port() | atom() - Operation = integer() - Data = Res = iodata() -

Performs a synchronous control operation on a port. - The meaning of Operation and Data depends on + The meaning of Operation and Data depends on the port, i.e., on the port driver. Not all port drivers support this control feature.

Returns: a list of integers in the range 0 through 255, or a binary, depending on the port driver. The meaning of the returned data also depends on the port driver.

-

Failure: badarg if Port is not an open port or - the registered name of an open port, if Operation +

Failure: badarg if Port is not an open port or + the registered name of an open port, if Operation cannot fit in a 32-bit integer, if the port driver does not support synchronous control operations, or if the port driver so decides for any reason (probably something wrong with - Operation or Data).

+ Operation or Data).

- erlang:port_call(Port, Operation, Data) -> term() + Synchronous call to a port with term data - - Port = port() | atom() - Operation = integer() - Data = term() -

Performs a synchronous call to a port. The meaning of - Operation and Data depends on the port, i.e., + Operation and Data depends on the port, i.e., on the port driver. Not all port drivers support this feature.

-

Port is a port identifier, referring to a driver.

-

Operation is an integer, which is passed on to +

Port is a port identifier, referring to a driver.

+

Operation is an integer, which is passed on to the driver.

-

Data is any Erlang term. This data is converted to +

Data is any Erlang term. This data is converted to binary term format and sent to the port.

Returns: a term from the driver. The meaning of the returned data also depends on the port driver.

-

Failure: badarg if Port is not an open port or - the registered name of an open port, if Operation +

Failure: badarg if Port is not an open port or + the registered name of an open port, if Operation cannot fit in a 32-bit integer, if the port driver does not support synchronous control operations, or if the port driver so decides for any reason (probably something wrong with - Operation or Data).

+ Operation or Data).

- erlang:port_info(Port) -> [{Item, Info}] | undefined + + Information about a port - - Port = port() | atom() - Item, Info -- see below -

Returns a list containing tuples with information about - the Port, or undefined if the port is not open. + the Port, or undefined if the port is not open. The order of the tuples is not defined, nor are all the tuples mandatory.

- {registered_name, RegName} + {registered_name, RegName} -

RegName (an atom) is the registered name of +

RegName (an atom) is the registered name of the port. If the port has no registered name, this tuple is not present in the list.

- {id, Index} + {id, Index} -

Index (an integer) is the internal index of the +

Index (an integer) is the internal index of the port. This index may be used to separate ports.

- {connected, Pid} + {connected, Pid} -

Pid is the process connected to the port.

+

Pid is the process connected to the port.

- {links, Pids} + {links, Pids} -

Pids is a list of pids to which processes the +

Pids is a list of pids to which processes the port is linked.

- {name, String} + {name, String} -

String is the command name set by +

String is the command name set by open_port.

- {input, Bytes} + {input, Bytes} -

Bytes is the total number of bytes read from +

Bytes is the total number of bytes read from the port.

- {output, Bytes} + {output, Bytes} -

Bytes is the total number of bytes written to +

Bytes is the total number of bytes written to the port.

-

Failure: badarg if Port is not a local port.

+

Failure: badarg if Port is not a local port.

- erlang:port_info(Port, Item) -> {Item, Info} | undefined | [] + + + Information about a port - - Port = port() | atom() - Item, Info -- see below - - -

Returns information about Port as specified - by Item, or undefined if the port is not open. - Also, if Item == registered_name and the port has no - registered name, [] is returned.

-

For valid values of Item, and corresponding - values of Info, see + +

Returns information about Port as specified + by Item, or undefined if the port is not open. + Also, if Item =:= registered_name and the port has no + registered name, [] is returned.

+

For valid values of Item, and corresponding + values of Result, see erlang:port_info/1.

-

Failure: badarg if Port is not a local port.

+

Failure: badarg if Port is not a local port.

- erlang:port_to_list(Port) -> string() + Text representation of a port identifier - - Port = port() -

Returns a string which corresponds to the text - representation of the port identifier Port.

+ representation of the port identifier Port.

This BIF is intended for debugging and for use in the Erlang operating system. It should not be used in @@ -3572,18 +3114,15 @@ os_prompt% - erlang:ports() -> [port()] + All open ports

Returns a list of all ports on the local node.

- pre_loaded() -> [Module] + List of all pre-loaded modules - - Module = atom() -

Returns a list of Erlang modules which are pre-loaded in the system. As all loading of code is done through the file @@ -3592,220 +3131,219 @@ os_prompt% - erlang:process_display(Pid, Type) -> void() + Write information about a local process on standard error - - Pid = pid() - Type = backtrace - -

Writes information about the local process Pid on +

Writes information about the local process Pid on standard error. The currently allowed value for the atom - Type is backtrace, which shows the contents of + Type is backtrace, which shows the contents of the call stack, including information about the call chain, with the current function printed first. The format of the output is not further defined.

- process_flag(Flag, Value) -> OldValue - Set process flags for the calling process - - Flag, Value, OldValue -- see below - + + Set process flag trap_exit for the calling process -

Sets certain flags for the process which calls this - function. Returns the old value of the flag.

- - process_flag(trap_exit, Boolean) - -

When trap_exit is set to true, exit signals - arriving to a process are converted to {'EXIT', From, Reason} messages, which can be received as ordinary - messages. If trap_exit is set to false, the - process exits if it receives an exit signal other than - normal and the exit signal is propagated to its - linked processes. Application processes should normally - not trap exits.

-

See also exit/2.

-
- process_flag(error_handler, Module) - -

This is used by a process to redefine the error handler - for undefined function calls and undefined registered - processes. Inexperienced users should not use this flag - since code auto-loading is dependent on the correct - operation of the error handling module.

-
- process_flag(min_heap_size, MinHeapSize) - -

This changes the minimum heap size for the calling - process.

-
- process_flag(min_bin_vheap_size, MinBinVHeapSize) - -

This changes the minimum binary virtual heap size for the calling - process.

-
- process_flag(priority, Level) - -

This sets the process priority. Level is an atom. - There are currently four priority levels: low, - normal, high, and max. The default - priority level is normal. NOTE: The - max priority level is reserved for internal use in - the Erlang runtime system, and should not be used - by others. -

-

Internally in each priority level processes are scheduled - in a round robin fashion. -

-

Execution of processes on priority normal and - priority low will be interleaved. Processes on - priority low will be selected for execution less - frequently than processes on priority normal. -

-

When there are runnable processes on priority high - no processes on priority low, or normal will - be selected for execution. Note, however, that this does - not mean that no processes on priority low, - or normal will be able to run when there are - processes on priority high running. On the runtime - system with SMP support there might be more processes running - in parallel than processes on priority high, i.e., - a low, and a high priority process might - execute at the same time. -

-

When there are runnable processes on priority max - no processes on priority low, normal, or - high will be selected for execution. As with the - high priority, processes on lower priorities might - execute in parallel with processes on priority max. -

-

Scheduling is preemptive. Regardless of priority, a process - is preempted when it has consumed more than a certain amount - of reductions since the last time it was selected for - execution. -

-

NOTE: You should not depend on the scheduling - to remain exactly as it is today. Scheduling, at least on - the runtime system with SMP support, is very likely to be - modified in the future in order to better utilize available - processor cores. -

-

There is currently no automatic mechanism for - avoiding priority inversion, such as priority inheritance, - or priority ceilings. When using priorities you have - to take this into account and handle such scenarios by - yourself. -

-

Making calls from a high priority process into code - that you don't have control over may cause the high - priority process to wait for a processes with lower - priority, i.e., effectively decreasing the priority of the - high priority process during the call. Even if this - isn't the case with one version of the code that you don't - have under your control, it might be the case in a future - version of it. This might, for example, happen if a - high priority process triggers code loading, since - the code server runs on priority normal. -

-

Other priorities than normal are normally not needed. - When other priorities are used, they need to be used - with care, especially the high priority must - be used with care. A process on high priority should - only perform work for short periods of time. Busy looping for - long periods of time in a high priority process will - most likely cause problems, since there are important servers - in OTP running on priority normal. -

-
- - process_flag(save_calls, N) - -

N must be an integer in the interval 0..10000. - If N > 0, call saving is made active for the - process, which means that information about the N - most recent global function calls, BIF calls, sends and - receives made by the process are saved in a list, which - can be retrieved with - process_info(Pid, last_calls). A global function - call is one in which the module of the function is - explicitly mentioned. Only a fixed amount of information - is saved: a tuple {Module, Function, Arity} for - function calls, and the mere atoms send, - 'receive' and timeout for sends and receives - ('receive' when a message is received and - timeout when a receive times out). If N = 0, - call saving is disabled for the process, which is the - default. Whenever the size of the call saving list is set, - its contents are reset.

-
- process_flag(sensitive, Boolean) - -

Set or clear the sensitive flag for the current process. - When a process has been marked as sensitive by calling - process_flag(sensitive, true), features in the run-time - system that can be used for examining the data and/or inner working - of the process are silently disabled.

-

Features that are disabled include (but are not limited to) - the following:

-

Tracing: Trace flags can still be set for the process, but no - trace messages of any kind will be generated. - (If the sensitive flag is turned off, trace messages will - again be generated if there are any trace flags set.)

-

Sequential tracing: The sequential trace token will be propagated - as usual, but no sequential trace messages will be generated.

-

process_info/1,2 cannot be used to read out the message - queue or the process dictionary (both will be returned as empty lists).

-

Stack back-traces cannot be displayed for the process.

-

In crash dumps, the stack, messages, and the process dictionary - will be omitted.

-

If {save_calls,N} has been set for the process, no - function calls will be saved to the call saving list. - (The call saving list will not be cleared; furthermore, send, receive, - and timeout events will still be added to the list.)

-
-
+

When trap_exit is set to true, exit signals + arriving to a process are converted to {'EXIT', From, Reason} messages, which can be received as ordinary + messages. If trap_exit is set to false, the + process exits if it receives an exit signal other than + normal and the exit signal is propagated to its + linked processes. Application processes should normally + not trap exits.

+

Returns the old value of the flag.

+

See also exit/2.

+
+
+ + + Set process flag error_handler for the calling process + +

This is used by a process to redefine the error handler + for undefined function calls and undefined registered + processes. Inexperienced users should not use this flag + since code auto-loading is dependent on the correct + operation of the error handling module.

+

Returns the old value of the flag.

+
+
+ + + Set process flag min_heap_size for the calling process + +

This changes the minimum heap size for the calling + process.

+

Returns the old value of the flag.

- process_flag(Pid, Flag, Value) -> OldValue + + Set process flag min_bin_vheap_size for the calling process + +

This changes the minimum binary virtual heap size for the calling + process.

+

Returns the old value of the flag.

+
+ + + + Set process flag priority for the calling process + +

This sets the process priority. Level is an atom. + There are currently four priority levels: low, + normal, high, and max. The default + priority level is normal. NOTE: The + max priority level is reserved for internal use in + the Erlang runtime system, and should not be used + by others. +

+

Internally in each priority level processes are scheduled + in a round robin fashion. +

+

Execution of processes on priority normal and + priority low will be interleaved. Processes on + priority low will be selected for execution less + frequently than processes on priority normal. +

+

When there are runnable processes on priority high + no processes on priority low, or normal will + be selected for execution. Note, however, that this does + not mean that no processes on priority low, + or normal will be able to run when there are + processes on priority high running. On the runtime + system with SMP support there might be more processes running + in parallel than processes on priority high, i.e., + a low, and a high priority process might + execute at the same time. +

+

When there are runnable processes on priority max + no processes on priority low, normal, or + high will be selected for execution. As with the + high priority, processes on lower priorities might + execute in parallel with processes on priority max. +

+

Scheduling is preemptive. Regardless of priority, a process + is preempted when it has consumed more than a certain amount + of reductions since the last time it was selected for + execution. +

+

NOTE: You should not depend on the scheduling + to remain exactly as it is today. Scheduling, at least on + the runtime system with SMP support, is very likely to be + modified in the future in order to better utilize available + processor cores. +

+

There is currently no automatic mechanism for + avoiding priority inversion, such as priority inheritance, + or priority ceilings. When using priorities you have + to take this into account and handle such scenarios by + yourself. +

+

Making calls from a high priority process into code + that you don't have control over may cause the high + priority process to wait for a processes with lower + priority, i.e., effectively decreasing the priority of the + high priority process during the call. Even if this + isn't the case with one version of the code that you don't + have under your control, it might be the case in a future + version of it. This might, for example, happen if a + high priority process triggers code loading, since + the code server runs on priority normal. +

+

Other priorities than normal are normally not needed. + When other priorities are used, they need to be used + with care, especially the high priority must + be used with care. A process on high priority should + only perform work for short periods of time. Busy looping for + long periods of time in a high priority process will + most likely cause problems, since there are important servers + in OTP running on priority normal. +

+

Returns the old value of the flag.

+
+
+ + + Set process flag save_calls for the calling process + +

N must be an integer in the interval 0..10000. + If N > 0, call saving is made active for the + process, which means that information about the N + most recent global function calls, BIF calls, sends and + receives made by the process are saved in a list, which + can be retrieved with + process_info(Pid, last_calls). A global function + call is one in which the module of the function is + explicitly mentioned. Only a fixed amount of information + is saved: a tuple {Module, Function, Arity} for + function calls, and the mere atoms send, + 'receive' and timeout for sends and receives + ('receive' when a message is received and + timeout when a receive times out). If N = 0, + call saving is disabled for the process, which is the + default. Whenever the size of the call saving list is set, + its contents are reset.

+

Returns the old value of the flag.

+
+
+ + + Set process flag sensitive for the calling process + +

Set or clear the sensitive flag for the current process. + When a process has been marked as sensitive by calling + process_flag(sensitive, true), features in the run-time + system that can be used for examining the data and/or inner working + of the process are silently disabled.

+

Features that are disabled include (but are not limited to) + the following:

+

Tracing: Trace flags can still be set for the process, but no + trace messages of any kind will be generated. + (If the sensitive flag is turned off, trace messages will + again be generated if there are any trace flags set.)

+

Sequential tracing: The sequential trace token will be propagated + as usual, but no sequential trace messages will be generated.

+

process_info/1,2 cannot be used to read out the message + queue or the process dictionary (both will be returned as empty lists).

+

Stack back-traces cannot be displayed for the process.

+

In crash dumps, the stack, messages, and the process dictionary + will be omitted.

+

If {save_calls,N} has been set for the process, no + function calls will be saved to the call saving list. + (The call saving list will not be cleared; furthermore, send, receive, + and timeout events will still be added to the list.)

+

Returns the old value of the flag.

+
+
+ + Set process flags for a process - - Pid = pid() - Flag, Value, OldValue -- see below - -

Sets certain flags for the process Pid, in the same +

Sets certain flags for the process Pid, in the same manner as process_flag/2. Returns the old value of the flag. The allowed values for - Flag are only a subset of those allowed in + Flag are only a subset of those allowed in process_flag/2, namely: save_calls.

-

Failure: badarg if Pid is not a local process.

+

Failure: badarg if Pid is not a local process.

- process_info(Pid) -> InfoResult + + Information about a process - - Pid = pid() - Item = atom() - Info = term() - InfoTuple = {Item, Info} - InfoTupleList = [InfoTuple] - InfoResult = InfoTupleList | undefined - - -

Returns a list containing InfoTuples with + +

Returns a list containing InfoTuples with miscellaneous information about the process identified by Pid, or undefined if the process is not alive.

- The order of the InfoTuples is not defined, nor - are all the InfoTuples mandatory. The InfoTuples + The order of the InfoTuples is not defined, nor + are all the InfoTuples mandatory. The InfoTuples part of the result may be changed without prior notice. - Currently InfoTuples with the following Items + Currently InfoTuples with the following items are part of the result: current_function, initial_call, status, message_queue_len, messages, links, @@ -3813,12 +3351,12 @@ os_prompt% priority, group_leader, total_heap_size, heap_size, stack_size, reductions, and garbage_collection. - If the process identified by Pid has a registered name - also an InfoTuple with Item == registered_name + If the process identified by Pid has a registered name + also an InfoTuple with the item registered_name will appear.

See process_info/2 - for information about specific InfoTuples.

+ for information about specific InfoTuples.

This BIF is intended for debugging only, use process_info/2 @@ -3829,113 +3367,108 @@ os_prompt% - process_info(Pid, ItemSpec) -> InfoResult + + + + + + Information about a process - - Pid = pid() - Item = atom() - Info = term() - ItemList = [Item] - ItemSpec = Item | ItemList - InfoTuple = {Item, Info} - InfoTupleList = [InfoTuple] - InfoResult = InfoTuple | InfoTupleList | undefined | [] - - -

Returns information about the process identified by Pid - as specified by the ItemSpec, or undefined if the + +

Returns information about the process identified by Pid + as specified by the Item or the ItemList, or undefined if the process is not alive.

-

If the process is alive and ItemSpec is a single - Item, the returned value is the corresponding - InfoTuple unless ItemSpec == registered_name +

If the process is alive and a single Item is given, + the returned value is the corresponding + InfoTuple unless Item =:= registered_name and the process has no registered name. In this case [] is returned. This strange behavior is due to historical reasons, and is kept for backward compatibility.

-

If ItemSpec is an ItemList, the result is an - InfoTupleList. The InfoTuples in the - InfoTupleList will appear with the corresponding - Items in the same order as the Items appeared - in the ItemList. Valid Items may appear multiple - times in the ItemList. +

If an ItemList is given, the result is an + InfoTupleList. The InfoTuples in the + InfoTupleList will appear with the corresponding + Items in the same order as the Items appeared + in the ItemList. Valid Items may appear multiple + times in the ItemList.

-

If registered_name is part of an ItemList +

If registered_name is part of an ItemList and the process has no name registered a - {registered_name, []} InfoTuple will - appear in the resulting InfoTupleList. This - behavior is different than when - ItemSpec == registered_name, and than when + {registered_name, []} InfoTuple will + appear in the resulting InfoTupleList. This + behavior is different than when a single + Item =:= registered_name is given, and than when process_info/1 is used.

-

Currently the following InfoTuples with corresponding - Items are valid:

+

Currently the following InfoTuples with corresponding + Items are valid:

- {backtrace, Bin} + {backtrace, Bin} -

The binary Bin contains the same information as +

The binary Bin contains the same information as the output from - erlang:process_display(Pid, backtrace). Use + erlang:process_display(Pid, backtrace). Use binary_to_list/1 to obtain the string of characters from the binary.

- {binary, BinInfo} + {binary, BinInfo} -

BinInfo is a list containing miscellaneous information +

BinInfo is a list containing miscellaneous information about binaries currently being referred to by this process. - This InfoTuple may be changed or removed without prior + This InfoTuple may be changed or removed without prior notice.

- {catchlevel, CatchLevel} + {catchlevel, CatchLevel} -

CatchLevel is the number of currently active - catches in this process. This InfoTuple may be +

CatchLevel is the number of currently active + catches in this process. This InfoTuple may be changed or removed without prior notice.

- {current_function, {Module, Function, Arity}} + {current_function, {Module, Function, Arity}} -

Module, Function, Arity is +

Module, Function, Arity is the current function call of the process.

- {current_location, {Module, Function, Arity, Location}} + {current_location, {Module, Function, Arity, Location}} -

Module, Function, Arity is +

Module, Function, Arity is the current function call of the process. - Location is a list of two-tuples that describes the + Location is a list of two-tuples that describes the location in the source code.

- {current_stacktrace, Stack} + {current_stacktrace, Stack}

Return the current call stack back-trace (stacktrace) of the process. The stack has the same format as returned by erlang:get_stacktrace/0.

- {dictionary, Dictionary} + {dictionary, Dictionary} -

Dictionary is the dictionary of the process.

+

Dictionary is the dictionary of the process.

- {error_handler, Module} + {error_handler, Module} -

Module is the error handler module used by +

Module is the error handler module used by the process (for undefined function calls, for example).

- {garbage_collection, GCInfo} + {garbage_collection, GCInfo} -

GCInfo is a list which contains miscellaneous +

GCInfo is a list which contains miscellaneous information about garbage collection for this process. - The content of GCInfo may be changed without + The content of GCInfo may be changed without prior notice.

- {group_leader, GroupLeader} + {group_leader, GroupLeader} -

GroupLeader is group leader for the IO of +

GroupLeader is group leader for the IO of the process.

- {heap_size, Size} + {heap_size, Size} -

Size is the size in words of youngest heap generation +

Size is the size in words of youngest heap generation of the process. This generation currently include the stack of the process. This information is highly implementation dependent, and may change if the implementation change. @@ -3947,9 +3480,9 @@ os_prompt% the initial function call with which the process was spawned.

- {links, Pids} + {links, Pids} -

Pids is a list of pids, with processes to +

Pids is a list of pids, with processes to which the process has a link.

{last_calls, false|Calls} @@ -3960,139 +3493,139 @@ os_prompt% If call saving is active, a list is returned, in which the last element is the most recent called.

- {memory, Size} + {memory, Size} -

Size is the size in bytes of the process. This +

Size is the size in bytes of the process. This includes call stack, heap and internal structures.

- {message_binary, BinInfo} + {message_binary, BinInfo} -

BinInfo is a list containing miscellaneous information +

BinInfo is a list containing miscellaneous information about binaries currently being referred to by the message - area. This InfoTuple is only valid on an emulator - using the hybrid heap type. This InfoTuple may be + area. This InfoTuple is only valid on an emulator + using the hybrid heap type. This InfoTuple may be changed or removed without prior notice.

- {message_queue_len, MessageQueueLen} + {message_queue_len, MessageQueueLen} -

MessageQueueLen is the number of messages +

MessageQueueLen is the number of messages currently in the message queue of the process. This is - the length of the list MessageQueue returned as + the length of the list MessageQueue returned as the info item messages (see below).

- {messages, MessageQueue} + {messages, MessageQueue} -

MessageQueue is a list of the messages to +

MessageQueue is a list of the messages to the process, which have not yet been processed.

- {min_heap_size, MinHeapSize} + {min_heap_size, MinHeapSize} -

MinHeapSize is the minimum heap size for the process.

+

MinHeapSize is the minimum heap size for the process.

- {min_bin_vheap_size, MinBinVHeapSize} + {min_bin_vheap_size, MinBinVHeapSize} -

MinBinVHeapSize is the minimum binary virtual heap size for the process.

+

MinBinVHeapSize is the minimum binary virtual heap size for the process.

- {monitored_by, Pids} + {monitored_by, Pids}

A list of pids that are monitoring the process (with monitor/2).

- {monitors, Monitors} + {monitors, Monitors}

A list of monitors (started by monitor/2) that are active for the process. For a local process monitor or a remote process monitor by pid, the list item - is {process, Pid}, and for a remote process + is {process, Pid}, and for a remote process monitor by name, the list item is - {process, {RegName, Node}}.

+ {process, {RegName, Node}}.

{priority, Level} -

Level is the current priority level for +

Level is the current priority level for the process. For more information on priorities see process_flag(priority, Level).

- {reductions, Number} + {reductions, Number} -

Number is the number of reductions executed by +

Number is the number of reductions executed by the process.

- {registered_name, Atom} + {registered_name, Atom} -

Atom is the registered name of the process. If +

Atom is the registered name of the process. If the process has no registered name, this tuple is not present in the list.

- {sequential_trace_token, [] | SequentialTraceToken} + {sequential_trace_token, [] | SequentialTraceToken} -

SequentialTraceToken the sequential trace token for - the process. This InfoTuple may be changed or removed +

SequentialTraceToken the sequential trace token for + the process. This InfoTuple may be changed or removed without prior notice.

- {stack_size, Size} + {stack_size, Size} -

Size is the stack size of the process in words.

+

Size is the stack size of the process in words.

- {status, Status} + {status, Status} -

Status is the status of the process. Status +

Status is the status of the process. Status is exiting, garbage_collecting, waiting (for a message), running, runnable (ready to run, but another process is running), or suspended (suspended on a "busy" port or by the erlang:suspend_process/[1,2] BIF).

- {suspending, SuspendeeList} + {suspending, SuspendeeList} -

SuspendeeList is a list of {Suspendee, - ActiveSuspendCount, OutstandingSuspendCount} tuples. - Suspendee is the pid of a process that have been or is to - be suspended by the process identified by Pid via the +

SuspendeeList is a list of {Suspendee, + ActiveSuspendCount, OutstandingSuspendCount} tuples. + Suspendee is the pid of a process that have been or is to + be suspended by the process identified by Pid via the erlang:suspend_process/2 BIF, or the erlang:suspend_process/1 - BIF. ActiveSuspendCount is the number of times the - Suspendee has been suspended by Pid. - OutstandingSuspendCount is the number of not yet - completed suspend requests sent by Pid. That is, - if ActiveSuspendCount /= 0, Suspendee is + BIF. ActiveSuspendCount is the number of times the + Suspendee has been suspended by Pid. + OutstandingSuspendCount is the number of not yet + completed suspend requests sent by Pid. That is, + if ActiveSuspendCount =/= 0, Suspendee is currently in the suspended state, and if - OutstandingSuspendCount /= 0 the asynchronous + OutstandingSuspendCount =/= 0 the asynchronous option of erlang:suspend_process/2 has been used and - the suspendee has not yet been suspended by Pid. - Note that the ActiveSuspendCount and - OutstandingSuspendCount are not the total suspend count - on Suspendee, only the parts contributed by Pid. + the suspendee has not yet been suspended by Pid. + Note that the ActiveSuspendCount and + OutstandingSuspendCount are not the total suspend count + on Suspendee, only the parts contributed by Pid.

- {total_heap_size, Size} + {total_heap_size, Size} -

Size is the total size in words of all heap +

Size is the total size in words of all heap fragments of the process. This currently include the stack of the process.

- {trace, InternalTraceFlags} + {trace, InternalTraceFlags} -

InternalTraceFlags is an integer representing - internal trace flag for this process. This InfoTuple +

InternalTraceFlags is an integer representing + internal trace flag for this process. This InfoTuple may be changed or removed without prior notice.

- {trap_exit, Boolean} + {trap_exit, Boolean} -

Boolean is true if the process is trapping +

Boolean is true if the process is trapping exits, otherwise it is false.

Note however, that not all implementations support every one - of the above Items.

-

Failure: badarg if Pid is not a local process, - or if Item is not a valid Item.

+ of the above Items.

+

Failure: badarg if Pid is not a local process, + or if Item is not a valid Item.

- processes() -> [pid()] + All processes

Returns a list of process identifiers corresponding to @@ -4109,13 +3642,10 @@ os_prompt% - purge_module(Module) -> void() + Remove old code for a module - - Module = atom() - -

Removes old code for Module. Before this BIF is used, +

Removes old code for Module. Before this BIF is used, erlang:check_process_code/2 should be called to check that no processes are executing old code in the module.

@@ -4124,20 +3654,17 @@ os_prompt% used elsewhere.

Failure: badarg if there is no old code for - Module.

+ Module.

- put(Key, Val) -> OldVal | undefined + Add a new value to the process dictionary - - Key = Val = OldVal = term() - - -

Adds a new Key to the process dictionary, associated - with the value Val, and returns undefined. If - Key already exists, the old value is deleted and - replaced by Val and the function returns the old value.

+ +

Adds a new Key to the process dictionary, associated + with the value Val, and returns undefined. If + Key already exists, the old value is deleted and + replaced by Val and the function returns the old value.

The values stored when put is evaluated within the scope of a catch will not be retracted if a @@ -4151,17 +3678,9 @@ os_prompt% - erlang:raise(Class, Reason, Stacktrace) + + Stop execution with an exception of given class, reason and call stack backtrace - - Class = error | exit | throw - Reason = term() - Stacktrace = [{Module, Function, Arity | Args} | {Fun, Args}] -  Module = Function = atom() -  Arity = arity() -  Args = [term()] -  Fun = [fun()] -

Stops the execution of the calling process with an exception of given class, reason and call stack backtrace @@ -4172,11 +3691,11 @@ os_prompt% be avoided in applications, unless you know very well what you are doing.

-

Class is one of error, exit or +

Class is one of error, exit or throw, so if it were not for the stacktrace - erlang:raise(Class, Reason, Stacktrace) is - equivalent to erlang:Class(Reason). - Reason is any term and Stacktrace is a list as + erlang:raise(Class, Reason, Stacktrace) is + equivalent to erlang:Class(Reason). + Reason is any term and Stacktrace is a list as returned from get_stacktrace(), that is a list of 4-tuples {Module, Function, Arity | Args, Location} where Module and Function @@ -4193,24 +3712,21 @@ os_prompt% terminate, it has no return value - unless the arguments are invalid, in which case the function returns the error reason, that is badarg. If you want to be really sure not to return you can call - error(erlang:raise(Class, Reason, Stacktrace)) + error(erlang:raise(Class, Reason, Stacktrace)) and hope to distinguish exceptions later.

- erlang:read_timer(TimerRef) -> integer() >= 0 | false + Number of milliseconds remaining for a timer - - TimerRef = reference() - -

TimerRef is a timer reference returned by +

TimerRef is a timer reference returned by erlang:send_after/3 or erlang:start_timer/3. If the timer is active, the function returns the time in milliseconds left until the timer will expire, otherwise - false (which means that TimerRef was never a + false (which means that TimerRef was never a timer, that it has been cancelled, or that it has already delivered its message).

See also @@ -4221,14 +3737,11 @@ os_prompt% - erlang:ref_to_list(Ref) -> string() + Text representation of a reference - - Ref = reference() -

Returns a string which corresponds to the text - representation of Ref.

+ representation of Ref.

This BIF is intended for debugging and for use in the Erlang operating system. It should not be used in @@ -4237,33 +3750,25 @@ os_prompt% - register(RegName, Pid | Port) -> true + Register a name for a pid (or port) - - RegName = atom() - Pid = pid() - Port = port() - - -

Associates the name RegName with a pid or a port - identifier. RegName, which must be an atom, can be used + +

Associates the name RegName with a pid or a port + identifier. RegName, which must be an atom, can be used instead of the pid / port identifier in the send operator - (RegName ! Message).

+ (RegName ! Message).

 > register(db, Pid).
 true
-

Failure: badarg if Pid is not an existing, - local process or port, if RegName is already in use, +

Failure: badarg if PidOrPort is not an existing, + local process or port, if RegName is already in use, if the process or port is already registered (already has a - name), or if RegName is the atom undefined.

+ name), or if RegName is the atom undefined.

- registered() -> [RegName] + All registered names - - RegName = atom() -

Returns a list of names which have been registered using register/2.

@@ -4273,22 +3778,19 @@ true
- erlang:resume_process(Suspendee) -> true + Resume a suspended process - - Suspendee = pid() -

Decreases the suspend count on the process identified by - Suspendee. Suspendee should previously have been + Suspendee. Suspendee should previously have been suspended via erlang:suspend_process/2, or erlang:suspend_process/1 - by the process calling erlang:resume_process(Suspendee). When - the suspend count on Suspendee reach zero, Suspendee + by the process calling erlang:resume_process(Suspendee). When + the suspend count on Suspendee reach zero, Suspendee will be resumed, i.e., the state of the Suspendee is changed - from suspended into the state Suspendee was in before it was + from suspended into the state Suspendee was in before it was suspended.

@@ -4298,29 +3800,26 @@ true badarg - If Suspendee isn't a process identifier. + If Suspendee isn't a process identifier. badarg If the process calling erlang:resume_process/1 had not previously increased the suspend count on the process - identified by Suspendee. + identified by Suspendee. badarg - If the process identified by Suspendee is not alive. + If the process identified by Suspendee is not alive.
- round(Number) -> integer() + Return an integer by rounding a number - - Number = number() - -

Returns an integer by rounding Number.

+

Returns an integer by rounding Number.

 > round(5.5).
 6
@@ -4328,7 +3827,7 @@ true
- self() -> pid() + Pid of the calling process

Returns the pid (process identifier) of the calling process.

@@ -4339,33 +3838,21 @@ true
- erlang:send(Dest, Msg) -> Msg + Send a message - - Dest = pid() | port() | RegName | {RegName, Node} - Msg = term() -  RegName = atom() -  Node = node() - - -

Sends a message and returns Msg. This is the same as - Dest ! Msg.

-

Dest may be a remote or local pid, a (local) port, a - locally registered name, or a tuple {RegName, Node} + + +

Sends a message and returns Msg. This is the same as + Dest ! Msg.

+

Dest may be a remote or local pid, a (local) port, a + locally registered name, or a tuple {RegName, Node} for a registered name at another node.

- erlang:send(Dest, Msg, [Option]) -> Res + + Send a message conditionally - - Dest = pid() | port() | RegName | {RegName, Node} -  RegName = atom() -  Node = node() - Msg = term() - Option = nosuspend | noconnect - Res = ok | nosuspend | noconnect -

Sends a message and returns ok, or does not send the message but returns something else (see below). Otherwise @@ -4395,28 +3882,24 @@ true - erlang:send_after(Time, Dest, Msg) -> TimerRef + + 0 <= Time <= 4294967295 Start a timer - - Time = integer() >= 0 -  0 <= Time <= 4294967295 - Dest = pid() | RegName -  LocalPid = pid() (of a process, alive or dead, on the local node) - Msg = term() - TimerRef = reference() -

Starts a timer which will send the message Msg - to Dest after Time milliseconds.

-

If Dest is an atom, it is supposed to be the name of + to Dest after Time milliseconds.

+

If Dest is a pid() it has to be a pid() of a local process, dead or alive.

+

The Time value can, in the current implementation, not be grater than 4294967295.

+

If Dest is an atom(), it is supposed to be the name of a registered process. The process referred to by the name is looked up at the time of delivery. No error is given if the name does not refer to a process.

-

If Dest is a pid, the timer will be automatically - canceled if the process referred to by the pid is not alive, + +

If Dest is a pid(), the timer will be automatically + canceled if the process referred to by the pid() is not alive, or when the process exits. This feature was introduced in erts version 5.4.11. Note that timers will not be - automatically canceled when Dest is an atom.

+ automatically canceled when Dest is an atom.

See also erlang:start_timer/3, erlang:cancel_timer/1, @@ -4516,32 +3999,25 @@ true - setelement(Index, Tuple1, Value) -> Tuple2 + + 1..tuple_size(Tuple1) Set Nth element of a tuple - - Index = 1..tuple_size(Tuple1) - Tuple1 = Tuple2 = tuple() - Value = term() - - -

Returns a tuple which is a copy of the argument Tuple1 - with the element given by the integer argument Index + +

Returns a tuple which is a copy of the argument Tuple1 + with the element given by the integer argument Index (the first element is the element with index 1) replaced by - the argument Value.

+ the argument Value.

 > setelement(2, {10, green, bottles}, red).
 {10,red,bottles}
- size(Item) -> integer() >= 0 + Size of a tuple or binary - - Item = tuple() | binary() -

Returns an integer which is the size of the argument - Item, which must be either a tuple or a binary.

+ Item, which must be either a tuple or a binary.

 > size({morni, mulle, bwange}).
 3
@@ -4569,20 +4045,16 @@ true
- spawn(Module, Function, Args) -> pid() + Create a new process with a function as entry point - - Module = Function = atom() - Args = [term()] -

Returns the pid of a new process started by the application - of Module:Function to Args. The new process + of Module:Function to Args. The new process created will be placed in the system scheduler queue and be run some time later.

-

error_handler:undefined_function(Module, Function, Args) is evaluated by the new process if - Module:Function/Arity does not exist (where - Arity is the length of Args). The error handler +

error_handler:undefined_function(Module, Function, Args) is evaluated by the new process if + Module:Function/Arity does not exist (where + Arity is the length of Args). The error handler can be redefined (see process_flag/2). If error_handler is undefined, or the user has @@ -4629,15 +4101,11 @@ true - spawn_link(Module, Function, Args) -> pid() + Create and link to a new process with a function as entry point - - Module = Function = atom() - Args = [term()] -

Returns the pid of a new process started by the application - of Module:Function to Args. A link is created + of Module:Function to Args. A link is created between the calling process and the new process, atomically. Otherwise works like spawn/3.

@@ -4816,15 +4284,12 @@ true
- split_binary(Bin, Pos) -> {Bin1, Bin2} + + 0..byte_size(Bin) Split a binary into two - - Bin = Bin1 = Bin2 = binary() - Pos = 0..byte_size(Bin) -

Returns a tuple containing the binaries which are the result - of splitting Bin into two parts at position Pos. + of splitting Bin into two parts at position Pos. This is not a destructive operation. After the operation, there will be three binaries altogether.

@@ -4841,30 +4306,24 @@ true
- erlang:start_timer(Time, Dest, Msg) -> TimerRef + + 0 <= Time <= 4294967295 Start a timer - - Time = integer() >= 0 -  0 <= Time <= 4294967295 - Dest = LocalPid | RegName -  LocalPid = pid() (of a process, alive or dead, on the local node) -  RegName = atom() - Msg = term() - TimerRef = reference() -

Starts a timer which will send the message - {timeout, TimerRef, Msg} to Dest - after Time milliseconds.

-

If Dest is an atom, it is supposed to be the name of + {timeout, TimerRef, Msg} to Dest + after Time milliseconds.

+

If Dest is a pid() it has to be a pid() of a local process, dead or alive.

+

The Time value can, in the current implementation, not be grater than 4294967295.

+

If Dest is an atom(), it is supposed to be the name of a registered process. The process referred to by the name is looked up at the time of delivery. No error is given if the name does not refer to a process.

-

If Dest is a pid, the timer will be automatically - canceled if the process referred to by the pid is not alive, +

If Dest is a pid(), the timer will be automatically + canceled if the process referred to by the pid() is not alive, or when the process exits. This feature was introduced in erts version 5.4.11. Note that timers will not be - automatically canceled when Dest is an atom.

+ automatically canceled when Dest is an atom().

See also erlang:send_after/3, erlang:cancel_timer/1, @@ -4875,94 +4334,82 @@ true - statistics(Type) -> Res - Information about the system - - Type, Res -- see below - + + Information about context switches -

Returns information about the system as specified by - Type:

- - context_switches - -

Returns {ContextSwitches, 0}, where - ContextSwitches is the total number of context - switches since the system started.

-
- exact_reductions - -

Returns - {Total_Exact_Reductions, Exact_Reductions_Since_Last_Call}.

-

NOTE:statistics(exact_reductions) is - a more expensive operation than - statistics(reductions) - especially on an Erlang machine with SMP support.

-
- garbage_collection - -

Returns {Number_of_GCs, Words_Reclaimed, 0}. This - information may not be valid for all implementations.

-
- io - -

Returns {{input, Input}, {output, Output}}, - where Input is the total number of bytes received - through ports, and Output is the total number of - bytes output to ports.

-
- reductions - -

Returns - {Total_Reductions, Reductions_Since_Last_Call}.

-

NOTE: From erts version 5.5 (OTP release R11B) - this value does not include reductions performed in current - time slices of currently scheduled processes. If an - exact value is wanted, use - statistics(exact_reductions).

-
- run_queue - -

Returns the length of the run queue, that is, the number - of processes that are ready to run.

-
- runtime - -

Returns {Total_Run_Time, Time_Since_Last_Call}. - Note that the run-time is the sum of the run-time for all - threads in the Erlang run-time system and may therefore be greater - than the wall-clock time.

-
- wall_clock - -

Returns - {Total_Wallclock_Time, Wallclock_Time_Since_Last_Call}. - wall_clock can be used in the same manner as - runtime, except that real time is measured as - opposed to runtime or CPU time.

-
-
-

All times are in milliseconds.

-
-> statistics(runtime).
-{1690,1620}
-> statistics(reductions).
-{2046,11}
-> statistics(garbage_collection).
-{85,23961,0}
+

ContextSwitches is the total number of context + switches since the system started.

+
+
+ + + Information about exact reductions + +

NOTE: statistics(exact_reductions) is + a more expensive operation than + statistics(reductions) + especially on an Erlang machine with SMP support.

+
+
+ + + Information about garbage collection + +

This information may not be valid for all implementations.

+
+
+ + + Information about io + +

Input is the total number of bytes received + through ports, and Output is the total number of + bytes output to ports.

+
+
+ + + Information about reductions + +

NOTE: From erts version 5.5 (OTP release R11B) + this value does not include reductions performed in current + time slices of currently scheduled processes. If an + exact value is wanted, use + statistics(exact_reductions).

- erlang:suspend_process(Suspendee, OptList) -> boolean() + + Information about the run-queue + +

Returns the length of the run queue, that is, the number + of processes that are ready to run.

+
+
+ + + Information about run-time + +

Note that the run-time is the sum of the run-time for all + threads in the Erlang run-time system and may therefore be greater + than the wall-clock time.

+
+
+ + + Information about wall-clock + +

wall_clock can be used in the same manner as + runtime, except that real time is measured as + opposed to runtime or CPU time.

+
+
+ + Suspend a process - - Suspendee = pid() - OptList = [Opt] - Opt = atom() -

Increases the suspend count on the process identified by - Suspendee and puts it in the suspended state if it isn't + Suspendee and puts it in the suspended state if it isn't already in the suspended state. A suspended process will not be scheduled for execution until the process has been resumed.

@@ -4970,49 +4417,49 @@ true

A process can be suspended by multiple processes and can be suspended multiple times by a single process. A suspended process will not leave the suspended state until its suspend - count reach zero. The suspend count of Suspendee is + count reach zero. The suspend count of Suspendee is decreased when - erlang:resume_process(Suspendee) + erlang:resume_process(Suspendee) is called by the same process that called - erlang:suspend_process(Suspendee). All increased suspend + erlang:suspend_process(Suspendee). All increased suspend counts on other processes acquired by a process will automatically be decreased when the process terminates.

-

Currently the following options (Opts) are available:

+

Currently the following options (Opts) are available:

asynchronous A suspend request is sent to the process identified by - Suspendee. Suspendee will eventually suspend + Suspendee. Suspendee will eventually suspend unless it is resumed before it was able to suspend. The caller of erlang:suspend_process/2 will return immediately, - regardless of whether the Suspendee has suspended yet - or not. Note that the point in time when the Suspendee + regardless of whether the Suspendee has suspended yet + or not. Note that the point in time when the Suspendee will actually suspend cannot be deduced from other events in the system. The only guarantee given is that the - Suspendee will eventually suspend (unless it + Suspendee will eventually suspend (unless it is resumed). If the asynchronous option has not been passed, the caller of erlang:suspend_process/2 will - be blocked until the Suspendee has actually suspended. + be blocked until the Suspendee has actually suspended. unless_suspending - The process identified by Suspendee will be suspended + The process identified by Suspendee will be suspended unless the calling process already is suspending the - Suspendee. If unless_suspending is combined + Suspendee. If unless_suspending is combined with the asynchronous option, a suspend request will be sent unless the calling process already is suspending the - Suspendee or if a suspend request already has been sent + Suspendee or if a suspend request already has been sent and is in transit. If the calling process already is suspending - the Suspendee, or if combined with the asynchronous + the Suspendee, or if combined with the asynchronous option and a send request already is in transit, - false is returned and the suspend count on Suspendee + false is returned and the suspend count on Suspendee will remain unchanged.

If the suspend count on the process identified by - Suspendee was increased, true is returned; otherwise, + Suspendee was increased, true is returned; otherwise, false is returned.

@@ -5022,28 +4469,28 @@ true badarg - If Suspendee isn't a process identifier. + If Suspendee isn't a process identifier. badarg - If the process identified by Suspendee is same the process as + If the process identified by Suspendee is same the process as the process calling erlang:suspend_process/2. badarg - If the process identified by Suspendee is not alive. + If the process identified by Suspendee is not alive. badarg - If the process identified by Suspendee resides on another node. + If the process identified by Suspendee resides on another node. badarg - If OptList isn't a proper list of valid Opts. + If OptList isn't a proper list of valid Opts. system_limit - If the process identified by Suspendee has been suspended more + If the process identified by Suspendee has been suspended more times by the calling process than can be represented by the currently used internal data structures. The current system limit is larger than 2 000 000 000 suspends, and it will never be less @@ -5066,283 +4513,307 @@ true
- erlang:system_flag(Flag, Value) -> OldValue - Set system flags - - Flag, Value, OldValue -- see below - + + Set system flag backtrace_depth + +

Sets the maximum depth of call stack back-traces in the + exit reason element of 'EXIT' tuples.

+

Returns the old value of the flag.

+
+
+ + + + + + + Set system flag cpu_topology + + +

This argument is deprecated and + scheduled for removal in erts-5.10/OTP-R16. Instead of using + this argument you are advised to use the erl command + line argument +sct. + When this argument has been removed a final CPU topology to use + will be determined at emulator boot time.

+
+

Sets the user defined CpuTopology. The user defined + CPU topology will override any automatically detected + CPU topology. By passing undefined as CpuTopology + the system will revert back to the CPU topology automatically + detected. The returned value equals the value returned + from erlang:system_info(cpu_topology) before the + change was made. +

+

Returns the old value of the flag.

+

The CPU topology is used when binding schedulers to logical + processors. If schedulers are already bound when the CPU + topology is changed, the schedulers will be sent a request + to rebind according to the new CPU topology. +

+

The user defined CPU topology can also be set by passing + the +sct command + line argument to erl. +

+

For information on the CpuTopology type + and more, see the documentation of + erlang:system_info(cpu_topology), + and the erl +sct + and +sbt + command line flags. +

+
+
+ + + Set system flag fullsweep_after + +

Number is a non-negative integer which indicates + how many times generational garbage collections can be + done without forcing a fullsweep collection. The value + applies to new processes; processes already running are + not affected.

+

Returns the old value of the flag.

+

In low-memory systems (especially without virtual + memory), setting the value to 0 can help to conserve + memory.

+

An alternative way to set this value is through the + (operating system) environment variable + ERL_FULLSWEEP_AFTER.

+
+
+ + + Set system flag min_heap_size + +

Sets the default minimum heap size for processes. The + size is given in words. The new min_heap_size only + effects processes spawned after the change of + min_heap_size has been made. + The min_heap_size can be set for individual + processes by use of + spawn_opt/N or + process_flag/2.

+

Returns the old value of the flag.

+
+
+ + + Set system flag min_bin_vheap_size + +

Sets the default minimum binary virtual heap size for processes. The + size is given in words. The new min_bin_vhheap_size only + effects processes spawned after the change of + min_bin_vhheap_size has been made. + The min_bin_vheap_size can be set for individual + processes by use of + spawn_opt/N or + process_flag/2.

+

Returns the old value of the flag.

+
+
+ + + Set system flag multi_scheduling + +

If multi-scheduling is enabled, more than one scheduler + thread is used by the emulator. Multi-scheduling can be + blocked. When multi-scheduling has been blocked, only + one scheduler thread will schedule Erlang processes.

+

If BlockState =:= block, multi-scheduling will + be blocked. If BlockState =:= unblock and no-one + else is blocking multi-scheduling and this process has + only blocked one time, multi-scheduling will be unblocked. + One process can block multi-scheduling multiple times. + If a process has blocked multiple times, it has to + unblock exactly as many times as it has blocked before it + has released its multi-scheduling block. If a process that + has blocked multi-scheduling exits, it will release its + blocking of multi-scheduling.

+

The return values are disabled, blocked, + or enabled. The returned value describes the + state just after the call to + erlang:system_flag(multi_scheduling, BlockState) + has been made. The return values are described in the + documentation of erlang:system_info(multi_scheduling).

+

NOTE: Blocking of multi-scheduling should normally + not be needed. If you feel that you need to + block multi-scheduling, think through the + problem at least a couple of times again. + Blocking multi-scheduling should only be used + as a last resort since it will most likely be + a very inefficient way to solve the + problem.

+

See also erlang:system_info(multi_scheduling), + erlang:system_info(multi_scheduling_blockers), and + erlang:system_info(schedulers).

+
+
+ + + + Set system flag scheduler_bind_type -

The - cpu_topology, - and - scheduler_bind_type - Flags are deprecated and have been scheduled for - removal in erts-5.10/OTP-R16.

+

This argument is deprecated and + scheduled for removal in erts-5.10/OTP-R16. Instead of using + this argument you are advised to use the erl command + line argument +sbt. + When this argument has been removed a final scheduler bind type + to use will be determined at emulator boot time.

-

Sets various system properties of the Erlang node. Returns - the old value of the flag.

+

Controls if and how schedulers are bound to logical + processors.

+

When erlang:system_flag(scheduler_bind_type, How) is + called, an asynchronous signal is sent to all schedulers + online which causes them to try to bind or unbind as requested. + NOTE: If a scheduler fails to bind, this + will often be silently ignored. This since it isn't always + possible to verify valid logical processor identifiers. If + an error is reported, it will be reported to the + error_logger. If you want to verify that the + schedulers actually have bound as requested, call + erlang:system_info(scheduler_bindings). +

+

Schedulers can currently only be bound on newer Linux, + Solaris, FreeBSD, and Windows systems, but more systems will be + supported in the future. +

+

In order for the runtime system to be able to bind schedulers, + the CPU topology needs to be known. If the runtime system fails + to automatically detect the CPU topology, it can be defined. + For more information on how to define the CPU topology, see + the erl +sct command + line flag. +

+

The runtime system will by default not bind schedulers + to logical processors. +

+

NOTE: If the Erlang runtime system is the only + operating system process that binds threads to logical processors, + this improves the performance of the runtime system. However, + if other operating system processes (as for example another Erlang + runtime system) also bind threads to logical processors, there + might be a performance penalty instead. In some cases this + performance penalty might be severe. If this is the case, you + are advised to not bind the schedulers.

+

Schedulers can be bound in different ways. The How + argument determines how schedulers are bound. How can + currently be one of:

- erlang:system_flag(backtrace_depth, Depth) - -

Sets the maximum depth of call stack back-traces in the - exit reason element of 'EXIT' tuples.

-
- erlang:system_flag(cpu_topology, CpuTopology) - -

NOTE: This argument is deprecated and - scheduled for removal in erts-5.10/OTP-R16. Instead of using - this argument you are advised to use the erl command - line argument +sct. - When this argument has been removed a final CPU topology to use - will be determined at emulator boot time.

-

Sets the user defined CpuTopology. The user defined - CPU topology will override any automatically detected - CPU topology. By passing undefined as CpuTopology - the system will revert back to the CPU topology automatically - detected. The returned value equals the value returned - from erlang:system_info(cpu_topology) before the - change was made. -

-

The CPU topology is used when binding schedulers to logical - processors. If schedulers are already bound when the CPU - topology is changed, the schedulers will be sent a request - to rebind according to the new CPU topology. -

-

The user defined CPU topology can also be set by passing - the +sct command - line argument to erl. -

-

For information on the CpuTopology type - and more, see the documentation of - erlang:system_info(cpu_topology), - and the erl +sct - and +sbt - command line flags. -

-
- erlang:system_flag(fullsweep_after, Number) - -

Number is a non-negative integer which indicates - how many times generational garbage collections can be - done without forcing a fullsweep collection. The value - applies to new processes; processes already running are - not affected.

-

In low-memory systems (especially without virtual - memory), setting the value to 0 can help to conserve - memory.

-

An alternative way to set this value is through the - (operating system) environment variable - ERL_FULLSWEEP_AFTER.

-
- erlang:system_flag(min_heap_size, MinHeapSize) - -

Sets the default minimum heap size for processes. The - size is given in words. The new min_heap_size only - effects processes spawned after the change of - min_heap_size has been made. - The min_heap_size can be set for individual - processes by use of - spawn_opt/N or - process_flag/2.

-
- erlang:system_flag(min_bin_vheap_size, MinBinVHeapSize) - -

Sets the default minimum binary virtual heap size for processes. The - size is given in words. The new min_bin_vhheap_size only - effects processes spawned after the change of - min_bin_vhheap_size has been made. - The min_bin_vheap_size can be set for individual - processes by use of - spawn_opt/N or - process_flag/2.

-
- erlang:system_flag(multi_scheduling, BlockState) - -

BlockState = block | unblock

-

If multi-scheduling is enabled, more than one scheduler - thread is used by the emulator. Multi-scheduling can be - blocked. When multi-scheduling has been blocked, only - one scheduler thread will schedule Erlang processes.

-

If BlockState =:= block, multi-scheduling will - be blocked. If BlockState =:= unblock and no-one - else is blocking multi-scheduling and this process has - only blocked one time, multi-scheduling will be unblocked. - One process can block multi-scheduling multiple times. - If a process has blocked multiple times, it has to - unblock exactly as many times as it has blocked before it - has released its multi-scheduling block. If a process that - has blocked multi-scheduling exits, it will release its - blocking of multi-scheduling.

-

The return values are disabled, blocked, - or enabled. The returned value describes the - state just after the call to - erlang:system_flag(multi_scheduling, BlockState) - has been made. The return values are described in the - documentation of erlang:system_info(multi_scheduling).

-

NOTE: Blocking of multi-scheduling should normally - not be needed. If you feel that you need to - block multi-scheduling, think through the - problem at least a couple of times again. - Blocking multi-scheduling should only be used - as a last resort since it will most likely be - a very inefficient way to solve the - problem.

-

See also erlang:system_info(multi_scheduling), - erlang:system_info(multi_scheduling_blockers), and - erlang:system_info(schedulers).

-
- erlang:system_flag(scheduler_bind_type, How) + unbound +

Same as the erl command line argument + +sbt u. +

+ no_spread +

Same as the erl command line argument + +sbt ns. +

+ thread_spread +

Same as the erl command line argument + +sbt ts. +

+ processor_spread +

Same as the erl command line argument + +sbt ps. +

+ spread +

Same as the erl command line argument + +sbt s. +

+ no_node_thread_spread +

Same as the erl command line argument + +sbt nnts. +

+ no_node_processor_spread +

Same as the erl command line argument + +sbt nnps. +

+ thread_no_node_processor_spread +

Same as the erl command line argument + +sbt tnnps. +

+ default_bind +

Same as the erl command line argument + +sbt db. +

+
+

The value returned equals How before the + scheduler_bind_type flag was changed.

+

Failure:

+ + notsup -

NOTE: This argument is deprecated and - scheduled for removal in erts-5.10/OTP-R16. Instead of using - this argument you are advised to use the erl command - line argument +sbt. - When this argument has been removed a final scheduler bind type - to use will be determined at emulator boot time.

-

Controls if and how schedulers are bound to logical - processors.

-

When erlang:system_flag(scheduler_bind_type, How) is - called, an asynchronous signal is sent to all schedulers - online which causes them to try to bind or unbind as requested. - NOTE: If a scheduler fails to bind, this - will often be silently ignored. This since it isn't always - possible to verify valid logical processor identifiers. If - an error is reported, it will be reported to the - error_logger. If you want to verify that the - schedulers actually have bound as requested, call - erlang:system_info(scheduler_bindings). -

-

Schedulers can currently only be bound on newer Linux, - Solaris, FreeBSD, and Windows systems, but more systems will be - supported in the future. -

-

In order for the runtime system to be able to bind schedulers, - the CPU topology needs to be known. If the runtime system fails - to automatically detect the CPU topology, it can be defined. - For more information on how to define the CPU topology, see - the erl +sct command - line flag. -

-

The runtime system will by default not bind schedulers - to logical processors. -

-

NOTE: If the Erlang runtime system is the only - operating system process that binds threads to logical processors, - this improves the performance of the runtime system. However, - if other operating system processes (as for example another Erlang - runtime system) also bind threads to logical processors, there - might be a performance penalty instead. In some cases this - performance penalty might be severe. If this is the case, you - are advised to not bind the schedulers.

-

Schedulers can be bound in different ways. The How - argument determines how schedulers are bound. How can - currently be one of:

- - unbound -

Same as the erl command line argument - +sbt u. -

- no_spread -

Same as the erl command line argument - +sbt ns. -

- thread_spread -

Same as the erl command line argument - +sbt ts. -

- processor_spread -

Same as the erl command line argument - +sbt ps. -

- spread -

Same as the erl command line argument - +sbt s. -

- no_node_thread_spread -

Same as the erl command line argument - +sbt nnts. -

- no_node_processor_spread -

Same as the erl command line argument - +sbt nnps. -

- thread_no_node_processor_spread -

Same as the erl command line argument - +sbt tnnps. -

- default_bind -

Same as the erl command line argument - +sbt db. -

-
-

The value returned equals How before the - scheduler_bind_type flag was changed.

-

Failure:

- - notsup - -

If binding of schedulers is not supported.

-
- badarg - -

If How isn't one of the documented alternatives.

-
- badarg - -

If no CPU topology information is available.

-
-
-

The scheduler bind type can also be set by passing - the +sbt command - line argument to erl. -

-

For more information, see - erlang:system_info(scheduler_bind_type), - erlang:system_info(scheduler_bindings), - the erl +sbt - and +sct command line - flags. -

+

If binding of schedulers is not supported.

- erlang:system_flag(schedulers_online, SchedulersOnline) + badarg -

Sets the amount of schedulers online. Valid range is - . -

-

For more information see, - erlang:system_info(schedulers), - and - erlang:system_info(schedulers_online). -

+

If How isn't one of the documented alternatives.

- erlang:system_flag(trace_control_word, TCW) + badarg -

Sets the value of the node's trace control word to - TCW. TCW should be an unsigned integer. For - more information see documentation of the - set_tcw - function in the match specification documentation in the - ERTS User's Guide.

+

If no CPU topology information is available.

- -

The schedulers option has been removed as - of erts version 5.5.3. The number of scheduler - threads is determined at emulator boot time, and - cannot be changed after that.

-
+

The scheduler bind type can also be set by passing + the +sbt command + line argument to erl. +

+

For more information, see + erlang:system_info(scheduler_bind_type), + erlang:system_info(scheduler_bindings), + the erl +sbt + and +sct command line + flags. +

- erlang:system_info(Type) -> Res - Information about the system - - Type, Res -- see below - + + Set system flag schedulers_online -

Returns various information about the current system - (emulator) as specified by Type:

+

Sets the amount of schedulers online. Valid range is + . +

+

Returns the old value of the flag.

+

For more information see, + erlang:system_info(schedulers), + and + erlang:system_info(schedulers_online). +

+
+
+ + + Set system flag trace_control_word + +

Sets the value of the node's trace control word to + TCW. TCW should be an unsigned integer. For + more information see documentation of the + set_tcw + function in the match specification documentation in the + ERTS User's Guide.

+

Returns the old value of the flag.

+
+
+ + + + + + + + + + + + Information about the allocators of the system + +

+ Returns various information about the + allocators of the + current system (emulator) as specified by + Item:

allocated_areas @@ -5367,37 +4838,27 @@ true allocator -

Returns {Allocator, Version, Features, Settings}.

-

Types:

- - Allocator = undefined | glibc - Version = [integer()] - Features = [atom()] - Settings = [{Subsystem, [{Parameter, Value}]}] - Subsystem = atom() - Parameter = atom() - Value = term() - +

Returns {Allocator, Version, Features, Settings}.

Explanation:

-

Allocator corresponds to the malloc() - implementation used. If Allocator equals +

Allocator corresponds to the malloc() + implementation used. If Allocator equals undefined, the malloc() implementation used could not be identified. Currently glibc can be identified.

-

Version is a list of integers (but not a +

Version is a list of integers (but not a string) representing the version of the malloc() implementation used.

-

Features is a list of atoms representing +

Features is a list of atoms representing allocation features used.

-

Settings is a list of subsystems, their +

Settings is a list of subsystems, their configurable parameters, and used values. Settings may differ between different combinations of platforms, allocators, and allocation features. @@ -5417,15 +4878,15 @@ true erts_alloc(3) documentation.

- {allocator, Alloc} + {allocator, Alloc}

Returns information about the specified allocator. As of erts version 5.6.1 the return value is a list of {instance, InstanceNo, InstanceInfo} tuples where InstanceInfo contains information about a specific instance of the allocator. - If Alloc is not a recognized allocator, - undefined is returned. If Alloc is disabled, + If Alloc is not a recognized allocator, + undefined is returned. If Alloc is disabled, false is returned.

Note: The information returned is highly implementation dependent and may be changed, or removed @@ -5454,54 +4915,50 @@ true values. The first value is memory pool size and the second value used memory size.

- {allocator_sizes, Alloc} + {allocator_sizes, Alloc}

Returns various size information for the specified allocator. The information returned is a subset of the information returned by - erlang:system_info({allocator, Alloc}). + erlang:system_info({allocator, Alloc}).

- build_type - -

Returns an atom describing the build type of the runtime - system. This is normally the atom opt for optimized. - Other possible return values are debug, purify, - quantify, purecov, gcov, valgrind, - gprof, and lcnt. Possible return values - may be added and/or removed at any time without prior notice. -

-
- c_compiler_used - -

Returns a two-tuple describing the C compiler used when - compiling the runtime system. The first element is an - atom describing the name of the compiler, or undefined - if unknown. The second element is a term describing the - version of the compiler, or undefined if unknown. -

-
- check_io - -

Returns a list containing miscellaneous information - regarding the emulators internal I/O checking. Note, - the content of the returned list may vary between - platforms and over time. The only thing guaranteed is - that a list is returned.

-
- compat_rel - -

Returns the compatibility mode of the local node as - an integer. The integer returned represents the - Erlang/OTP release which the current emulator has been - set to be backward compatible with. The compatibility - mode can be configured at startup by using the command - line flag +R, see - erl(1).

-
+
+
+
+ + + + + + + All LevelEntrys of a list + must contain the same LevelTag, except + on the top level where both node and + processor LevelTags may co-exist. + + + {LevelTag, SubLevel} == {LevelTag, [], SubLevel} + + + + More LevelTags may be introduced in the future. + + + + + The info_list() may be extended in the future. + + Information about the CPU topology of the system + +

Returns various information about the + CPU topology + of the current system + (emulator) as specified by Item:

+ cpu_topology -

Returns the CpuTopology which currently is used by the +

Returns the CpuTopology which currently is used by the emulator. The CPU topology is used when binding schedulers to logical processors. The CPU topology used is the user @@ -5509,31 +4966,11 @@ true automatically detected CPU topology if such exists. If no CPU topology exists, undefined is returned.

-

Types:

- - CpuTopology = LevelEntryList | undefined - LevelEntryList = [LevelEntry] (all - LevelEntrys of a LevelEntryList - must contain the same LevelTag, except - on the top level where both node and - processor LevelTags may co-exist) - LevelEntry = {LevelTag, SubLevel} - | {LevelTag, InfoList, SubLevel} - ({LevelTag, SubLevel} - == {LevelTag, [], SubLevel}) - LevelTag = node|processor|core|thread - (more LevelTags may be introduced in - the future) - SubLevel = [LevelEntry] | LogicalCpuId - LogicalCpuId = {logical, integer()} - InfoList = [] (the InfoList - may be extended in the future) -

node refers to NUMA (non-uniform memory access) nodes, and thread refers to hardware threads (e.g. Intels hyper-threads).

-

A level in the CpuTopology term can be omitted if - only one entry exists and the InfoList is empty. +

A level in the CpuTopology term can be omitted if + only one entry exists and the InfoList is empty.

thread can only be a sub level to core. core can be a sub level to either processor @@ -5545,15 +4982,15 @@ true consist of a mix of processor internal and external NUMA nodes, as long as each logical CPU belongs to one and only one NUMA node. Cache hierarchy is not part of - the CpuTopology type yet, but will be in the + the CpuTopology type yet, but will be in the future. Other things may also make it into the CPU topology in the future. In other words, expect the - CpuTopology type to change. + CpuTopology type to change.

{cpu_topology, defined} -

Returns the user defined CpuTopology. For more +

Returns the user defined CpuTopology. For more information see the documentation of the erl +sct command line flag, and the documentation of the @@ -5563,7 +5000,7 @@ true {cpu_topology, detected} -

Returns the automatically detected CpuTopology. The +

Returns the automatically detected CpuTopology. The emulator currently only detects the CPU topology on some newer Linux, Solaris, FreeBSD, and Windows systems. On Windows system with more than 32 logical processors the CPU topology is not detected. @@ -5575,13 +5012,111 @@ true {cpu_topology, used} -

Returns the CpuTopology which is used by the +

Returns the CpuTopology which is used by the emulator. For more information see the documentation of the cpu_topology argument.

+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Information about the system + +

Returns various information about the current system + (emulator) as specified by Item:

+ + allocated_areas, allocator, + alloc_util_allocators, allocator_sizes + +

See above.

+
+ build_type + +

Returns an atom describing the build type of the runtime + system. This is normally the atom opt for optimized. + Other possible return values are debug, purify, + quantify, purecov, gcov, valgrind, + gprof, and lcnt. Possible return values + may be added and/or removed at any time without prior notice. +

+
+ c_compiler_used + +

Returns a two-tuple describing the C compiler used when + compiling the runtime system. The first element is an + atom describing the name of the compiler, or undefined + if unknown. The second element is a term describing the + version of the compiler, or undefined if unknown. +

+
+ check_io + +

Returns a list containing miscellaneous information + regarding the emulators internal I/O checking. Note, + the content of the returned list may vary between + platforms and over time. The only thing guaranteed is + that a list is returned.

+
+ compat_rel + +

Returns the compatibility mode of the local node as + an integer. The integer returned represents the + Erlang/OTP release which the current emulator has been + set to be backward compatible with. The compatibility + mode can be configured at startup by using the command + line flag +R, see + erl(1).

+
+ cpu_topology + +

See above.

+
creation

Returns the creation of the local node as an integer. @@ -5611,10 +5146,10 @@ true

Returns a list of tuples {Node, ControllingEntity}, one entry for each - connected remote node. The Node is the name of the - node and the ControllingEntity is the port or pid + connected remote node. The Node is the name of the + node and the ControllingEntity is the port or pid responsible for the communication to that node. More - specifically, the ControllingEntity for nodes + specifically, the ControllingEntity for nodes connected via TCP/IP (the normal case) is the socket actually used in communication with the specific node.

@@ -5639,7 +5174,7 @@ true fullsweep_after -

Returns {fullsweep_after, integer()} which is the +

Returns {fullsweep_after, integer() >= 0} which is the fullsweep_after garbage collection setting used by default. For more information see garbage_collection described below.

@@ -5747,12 +5282,12 @@ true
min_heap_size -

Returns {min_heap_size, MinHeapSize} where MinHeapSize is the current system wide +

Returns {min_heap_size, MinHeapSize} where MinHeapSize is the current system wide minimum heap size for spawned processes.

min_bin_vheap_size -

Returns {min_bin_vheap_size, MinBinVHeapSize} where MinBinVHeapSize is the current system wide +

Returns {min_bin_vheap_size, MinBinVHeapSize} where MinBinVHeapSize is the current system wide minimum binary virtual heap size for spawned processes.

modified_timing_level @@ -5796,10 +5331,10 @@ true multi_scheduling_blockers -

Returns a list of PIDs when multi-scheduling - is blocked; otherwise, the empty list. The PIDs - in the list is PIDs of the processes currently - blocking multi-scheduling. A PID will only be +

Returns a list of PIDs when multi-scheduling + is blocked; otherwise, the empty list. The PIDs + in the list is PIDs of the processes currently + blocking multi-scheduling. A PID will only be present once in the list, even if the corresponding process has blocked multiple times.

See also erlang:system_flag(multi_scheduling, BlockState), @@ -5874,7 +5409,7 @@ true

Returns the scheduler id (SchedulerId) of the scheduler thread that the calling process is executing - on. SchedulerId is a positive integer; where + on. SchedulerId is a positive integer; where . See also erlang:system_info(schedulers).

@@ -6000,53 +5535,39 @@ true
- erlang:system_monitor() -> MonSettings + + Current system performance monitoring settings - - MonSettings -> {MonitorPid, Options} | undefined -  MonitorPid = pid() -  Options = [Option] -   Option = {long_gc, Time} | {large_heap, Size} | busy_port | busy_dist_port -    Time = Size = integer() -

Returns the current system monitoring settings set by erlang:system_monitor/2 - as {MonitorPid, Options}, or undefined if there + as {MonitorPid, Options}, or undefined if there are no settings. The order of the options may be different from the one that was set.

- erlang:system_monitor(undefined | {MonitorPid, Options}) -> MonSettings + + Set or clear system performance monitoring options - - MonitorPid, Options, MonSettings -- see below -

When called with the argument undefined, all system performance monitoring settings are cleared.

-

Calling the function with {MonitorPid, Options} as +

Calling the function with {MonitorPid, Options} as argument, is the same as calling - erlang:system_monitor(MonitorPid, Options).

+ erlang:system_monitor(MonitorPid, Options).

Returns the previous system monitor settings just like erlang:system_monitor/0.

- erlang:system_monitor(MonitorPid, [Option]) -> MonSettings + + Set system performance monitoring options - - MonitorPid = pid() - Option = {long_gc, Time} | {large_heap, Size} | busy_port | busy_dist_port -  Time = Size = integer() - MonSettings = {OldMonitorPid, [Option]} -  OldMonitorPid = pid() - - -

Sets system performance monitoring options. MonitorPid + +

Sets system performance monitoring options. MonitorPid is a local pid that will receive system monitor messages, and the second argument is a list of monitoring options:

@@ -6055,7 +5576,7 @@ true

If a garbage collection in the system takes at least Time wallclock milliseconds, a message {monitor, GcPid, long_gc, Info} is sent to - MonitorPid. GcPid is the pid that was + MonitorPid. GcPid is the pid that was garbage collected and Info is a list of two-element tuples describing the result of the garbage collection. One of the tuples is {timeout, GcTime} where @@ -6078,7 +5599,7 @@ true

If a garbage collection in the system results in the allocated size of a heap being at least Size words, a message {monitor, GcPid, large_heap, Info} - is sent to MonitorPid. GcPid and Info + is sent to MonitorPid. GcPid and Info are the same as for long_gc above, except that the tuple tagged with timeout is not present. Note: As of erts version 5.6 the monitor message @@ -6094,7 +5615,7 @@ true

If a process in the system gets suspended because it sends to a busy port, a message {monitor, SusPid, busy_port, Port} is sent to - MonitorPid. SusPid is the pid that got + MonitorPid. SusPid is the pid that got suspended when sending to Port.

busy_dist_port @@ -6103,7 +5624,7 @@ true sends to a process on a remote node whose inter-node communication was handled by a busy port, a message {monitor, SusPid, busy_dist_port, Port} is sent to - MonitorPid. SusPid is the pid that got + MonitorPid. SusPid is the pid that got suspended when sending through the inter-node communication port Port.

@@ -6118,48 +5639,48 @@ true

Keep the monitoring process neat and do not set the system monitor limits too tight.

-

Failure: badarg if MonitorPid does not exist.

+

Failure: badarg if MonitorPid does not exist or is not a local process.

- erlang:system_profile() -> ProfilerSettings + + Current system profiling settings - - ProfilerSettings -> {ProfilerPid, Options} | undefined -  ProfilerPid = pid() | port() -  Options = [Option] -   Option = runnable_procs | runnable_ports | scheduler | exclusive -

Returns the current system profiling settings set by erlang:system_profile/2 - as {ProfilerPid, Options}, or undefined if there + as {ProfilerPid, Options}, or undefined if there are no settings. The order of the options may be different from the one that was set.

- erlang:system_profile(ProfilerPid, Options) -> ProfilerSettings + + Current system profiling settings - - ProfilerSettings -> {ProfilerPid, Options} | undefined -  ProfilerPid = pid() | port() -  Options = [Option] -   Option = runnable_procs | runnable_ports | scheduler | exclusive - - -

Sets system profiler options. ProfilerPid + +

Sets system profiler options. ProfilerPid is a local pid or port that will receive profiling messages. The receiver is excluded from all profiling. The second argument is a list of profiling options:

+ exclusive + +

+ If a synchronous call to a port from a process is done, the + calling process is considered not runnable during the call + runtime to the port. The calling process is notified as + inactive and subsequently active when the port + callback returns. +

+
runnable_procs

If a process is put into or removed from the run queue a message, {profile, Pid, State, Mfa, Ts}, is sent to - ProfilerPid. Running processes that is reinserted into the + ProfilerPid. Running processes that is reinserted into the run queue after having been preemptively scheduled out will not trigger this message.

@@ -6168,24 +5689,14 @@ true

If a port is put into or removed from the run queue a message, {profile, Port, State, 0, Ts}, is sent to - ProfilerPid. + ProfilerPid.

scheduler

If a scheduler is put to sleep or awoken a message, {profile, scheduler, Id, State, NoScheds, Ts}, is sent - to ProfilerPid. -

-
- exclusive - -

- If a synchronous call to a port from a process is done, the - calling process is considered not runnable during the call - runtime to the port. The calling process is notified as - inactive and subsequently active when the port - callback returns. + to ProfilerPid.

@@ -6196,14 +5707,11 @@ true
- term_to_binary(Term) -> ext_binary() + Encode a term to an Erlang external term format binary - - Term = term() -

Returns a binary data object which is the result of encoding - Term according to the Erlang external term format.

+ Term according to the Erlang external term format.

This can be used for a variety of purposes, for example writing a term to a file in an efficient way, or sending an Erlang term to some type of communications channel not @@ -6213,20 +5721,16 @@ true - term_to_binary(Term, [Option]) -> ext_binary() + Encode a term to en Erlang external term format binary - - Term = term() - Option = compressed | {compressed,Level} | {minor_version,Version} -

Returns a binary data object which is the result of encoding - Term according to the Erlang external term format.

+ Term according to the Erlang external term format.

If the option compressed is provided, the external term format will be compressed. The compressed format is automatically recognized by binary_to_term/1 in R7B and later.

It is also possible to specify a compression level by giving - the option {compressed,Level}, where Level is an + the option {compressed, Level}, where Level is an integer from 0 through 9. 0 means that no compression will be done (it is the same as not giving any compressed option); 1 will take the least time but may not compress as well as @@ -6235,16 +5739,16 @@ true on the input term, level 9 compression may or may not produce a smaller result than level 1 compression.

Currently, compressed gives the same result as - {compressed,6}.

-

The option {minor_version,Version} can be use to control + {compressed, 6}.

+

The option {minor_version, Version} can be use to control some details of the encoding. This option was - introduced in R11B-4. Currently, the allowed values for Version + introduced in R11B-4. Currently, the allowed values for Version are 0 and 1.

-

{minor_version,1} forces any floats in the term to be encoded +

{minor_version, 1} forces any floats in the term to be encoded in a more space-efficient and exact way (namely in the 64-bit IEEE format, rather than converted to a textual representation). binary_to_term/1 in R11B-4 and later is able decode the new representation.

-

{minor_version,0} is currently the default, meaning that floats +

{minor_version, 0} is currently the default, meaning that floats will be encoded using a textual representation; this option is useful if you want to ensure that releases prior to R11B-4 can decode resulting binary.

@@ -6253,14 +5757,11 @@ true
- throw(Any) + Throw an exception - - Any = term() -

A non-local return from a function. If evaluated within a - catch, catch will return the value Any.

+ catch, catch will return the value Any.

 > catch throw({hello, there}).
 {hello,there}
@@ -6268,11 +5769,8 @@ true
- time() -> {Hour, Minute, Second} + Current time - - Hour = Minute = Second = integer() >= 0 -

Returns the current time as {Hour, Minute, Second}.

The time zone and daylight saving time correction depend on @@ -6283,35 +5781,27 @@ true - tl(List1) -> List2 + Tail of a list - - List1 = List2 = [term()] - -

Returns the tail of List1, that is, the list minus +

Returns the tail of List, that is, the list minus the first element.

 > tl([geesties, guilies, beasties]).
 [guilies, beasties]

Allowed in guard tests.

-

Failure: badarg if List is the empty list [].

+

Failure: badarg if List is the empty list [].

- erlang:trace(PidSpec, How, FlagList) -> integer() >= 0 + + Set trace flags for a process or processes - - PidSpec = pid() | existing | new | all - How = boolean() - FlagList = [Flag] -  Flag -- see below - - -

Turns on (if How == true) or off (if - How == false) the trace flags in FlagList for - the process or processes represented by PidSpec.

-

PidSpec is either a pid for a local process, or one of + +

Turns on (if How == true) or off (if + How == false) the trace flags in FlagList for + the process or processes represented by PidSpec.

+

PidSpec is either a pid for a local process, or one of the following atoms:

existing @@ -6328,7 +5818,7 @@ true will be created in the future.

-

FlagList can contain any number of the following +

FlagList can contain any number of the following flags (the "message tags" refers to the list of messages following below):

@@ -6643,11 +6133,11 @@ true

Only one process can trace a particular process. For this reason, attempts to trace an already traced process will fail.

Returns: A number indicating the number of processes that - matched PidSpec. If PidSpec is a pid, - the return value will be 1. If PidSpec is + matched PidSpec. If PidSpec is a pid, + the return value will be 1. If PidSpec is all or existing the return value will be the number of processes running, excluding tracer processes. - If PidSpec is new, the return value will be + If PidSpec is new, the return value will be 0.

Failure: If specified arguments are not supported. For example cpu_timestamp is not supported on all @@ -6655,64 +6145,56 @@ true - erlang:trace_delivered(Tracee) -> Ref + Notification when trace has been delivered - - Tracee = pid() | all - Ref = reference() -

The delivery of trace messages is dislocated on the time-line compared to other events in the system. If you know that the - Tracee has passed some specific point in its execution, + Tracee has passed some specific point in its execution, and you want to know when at least all trace messages corresponding to events up to this point have reached the tracer - you can use erlang:trace_delivered(Tracee). A - {trace_delivered, Tracee, Ref} message is sent to - the caller of erlang:trace_delivered(Tracee) when it + you can use erlang:trace_delivered(Tracee). A + {trace_delivered, Tracee, Ref} message is sent to + the caller of erlang:trace_delivered(Tracee) when it is guaranteed that all trace messages have been delivered to - the tracer up to the point that the Tracee had reached + the tracer up to the point that the Tracee had reached at the time of the call to - erlang:trace_delivered(Tracee).

+ erlang:trace_delivered(Tracee).

Note that the trace_delivered message does not imply that trace messages have been delivered; instead, it implies that all trace messages that should be delivered have - been delivered. It is not an error if Tracee isn't, and + been delivered. It is not an error if Tracee isn't, and hasn't been traced by someone, but if this is the case, no trace messages will have been delivered when the trace_delivered message arrives.

-

Note that Tracee has to refer to a process currently, +

Note that Tracee has to refer to a process currently, or previously existing on the same node as the caller of - erlang:trace_delivered(Tracee) resides on. - The special Tracee atom all denotes all processes + erlang:trace_delivered(Tracee) resides on. + The special Tracee atom all denotes all processes that currently are traced in the node.

-

An example: Process A is tracee, port B is +

An example: Process A is Tracee, port B is tracer, and process C is the port owner of B. C wants to close B when A exits. C can ensure that the trace isn't truncated by calling erlang:trace_delivered(A) when A exits and wait - for the {trace_delivered, A, Ref} message before closing + for the {trace_delivered, A, Ref} message before closing B.

-

Failure: badarg if Tracee does not refer to a +

Failure: badarg if Tracee does not refer to a process (dead or alive) on the same node as the caller of - erlang:trace_delivered(Tracee) resides on.

+ erlang:trace_delivered(Tracee) resides on.

- erlang:trace_info(PidOrFunc, Item) -> Res + + + Trace information about a process or function - - PidOrFunc = pid() | new | {Module, Function, Arity} | on_load -  Module = Function = atom() -  Arity = arity() - Item, Res -- see below -

Returns trace information about a process or function.

-

To get information about a process, PidOrFunc should +

To get information about a process, PidOrFunc should be a pid or the atom new. The atom new means that the default trace state for processes to be created will - be returned. Item must have one of the following + be returned. Item must have one of the following values:

flags @@ -6792,22 +6274,24 @@ true all -

Return a list containing the {Item, Value} tuples +

Return a list containing the {Item, Value} tuples for all other items, or return false if no tracing is active for this function.

-

The actual return value will be {Item, Value}, where +

The actual return value will be {Item, Value}, where Value is the requested information as described above. If a pid for a dead process was given, or the name of a non-existing function, Value will be undefined.

-

If PidOrFunc is the on_load, the information +

If PidOrFunc is the on_load, the information returned refers to the default value for code that will be loaded.

- erlang:trace_pattern(MFA, MatchSpec) -> integer() >= 0 + + + Set trace patterns for global call tracing

The same as @@ -6816,11 +6300,11 @@ true - erlang:trace_pattern(MFA, MatchSpec, FlagList) -> integer() >= 0 + + + + Set trace patterns for tracing of function calls - - MFA, MatchSpec, FlagList -- see below -

This BIF is used to enable or disable call tracing for exported functions. It must be combined with @@ -6845,7 +6329,7 @@ true and an action to be performed. The default action is to send a trace message. If the pattern does not match or the guard fails, the action will not be executed.

-

The MFA argument should be a tuple like +

The MFA argument should be a tuple like {Module, Function, Arity} or the atom on_load (described below). It can be the module, function, and arity for an exported function (or a BIF in any module). @@ -6868,11 +6352,11 @@ true

Other combinations, such as {Module,'_',Arity}, are not allowed. Local functions will match wildcards only if - the local option is in the FlagList.

-

If the MFA argument is the atom on_load, + the local option is in the FlagList.

+

If the MFA argument is the atom on_load, the match specification and flag list will be used on all modules that are newly loaded.

-

The MatchSpec argument can take any of the following +

The MatchSpec argument can take any of the following forms:

false @@ -6884,7 +6368,7 @@ true

Enable tracing for the matching function(s).

- MatchSpecList + MatchSpecList

A list of match specifications. An empty list is equivalent to true. See the ERTS User's Guide @@ -6892,18 +6376,18 @@ true restart -

For the FlagList option call_count and call_time: +

For the FlagList option call_count and call_time: restart the existing counters. The behaviour is undefined - for other FlagList options.

+ for other FlagList options.

pause -

For the FlagList option call_count and call_time: pause +

For the FlagList option call_count and call_time: pause the existing counters. The behaviour is undefined for other FlagList options.

-

The FlagList parameter is a list of options. +

The FlagList parameter is a list of options. The following options are allowed:

global @@ -6922,13 +6406,13 @@ true the process, a return_to message will also be sent when this function returns to its caller.

- meta | {meta, Pid} + meta | {meta, Pid}

Turn on or off meta tracing for all types of function calls. Trace messages will be sent to the tracer process - or port Pid whenever any of the specified + or port Pid whenever any of the specified functions are called, regardless of how they are called. - If no Pid is specified, self() is used as a + If no Pid is specified, self() is used as a default tracer process.

Meta tracing traces all processes and does not care about the process trace flags set by trace/3, @@ -6940,32 +6424,32 @@ true call_count -

Starts (MatchSpec == true) or stops - (MatchSpec == false) call count tracing for all +

Starts (MatchSpec == true) or stops + (MatchSpec == false) call count tracing for all types of function calls. For every function a counter is incremented when the function is called, in any process. No process trace flags need to be activated.

If call count tracing is started while already running, the count is restarted from zero. Running counters can be - paused with MatchSpec == pause. Paused and running + paused with MatchSpec == pause. Paused and running counters can be restarted from zero with - MatchSpec == restart.

+ MatchSpec == restart.

The counter value can be read with erlang:trace_info/2.

call_time -

Starts (MatchSpec == true) or stops - (MatchSpec == false) call time tracing for all +

Starts (MatchSpec == true) or stops + (MatchSpec == false) call time tracing for all types of function calls. For every function a counter is incremented when the function is called. Time spent in the function is accumulated in two other counters, seconds and micro-seconds. The counters are stored for each call traced process.

If call time tracing is started while already running, the count and time is restarted from zero. Running counters can be - paused with MatchSpec == pause. Paused and running + paused with MatchSpec == pause. Paused and running counters can be restarted from zero with - MatchSpec == restart.

+ MatchSpec == restart.

The counter value can be read with erlang:trace_info/2.

@@ -6991,18 +6475,15 @@ true erlang:trace_info/2 BIF to retrieve the existing match specification.

Returns the number of exported functions that matched - the MFA argument. This will be zero if none matched at + the MFA argument. This will be zero if none matched at all.

- trunc(Number) -> integer() + Return an integer by the truncating a number - - Number = number() - -

Returns an integer by the truncating Number.

+

Returns an integer by the truncating Number.

 > trunc(5.5).
 5
@@ -7010,13 +6491,10 @@ true
- tuple_size(Tuple) -> integer() >= 0 + Return the size of a tuple - - Tuple = tuple() - -

Returns an integer which is the number of elements in Tuple.

+

Returns an integer which is the number of elements in Tuple.

 > tuple_size({morni, mulle, bwange}).
 3
@@ -7024,25 +6502,19 @@ true
- tuple_to_list(Tuple) -> [term()] + Convert a tuple to a list - - Tuple = tuple() - -

Returns a list which corresponds to Tuple. - Tuple may contain any Erlang terms.

+

Returns a list which corresponds to Tuple. + Tuple may contain any Erlang terms.

 > tuple_to_list({share, {'Ericsson_B', 163}}).
 [share,{'Ericsson_B',163}]
- erlang:universaltime() -> DateTime + Current date and time according to Universal Time Coordinated (UTC) - - DateTime = calendar:datetime() -

Returns the current date and time according to Universal Time Coordinated (UTC), also called GMT, in the form @@ -7056,46 +6528,39 @@ true - erlang:universaltime_to_localtime({Date1, Time1}) -> {Date2, Time2} + Convert from Universal Time Coordinated (UTC) to local date and time - - Date1 = Date2 = calendar:date() - Time1 = Time2 = calendar:time() -

Converts Universal Time Coordinated (UTC) date and time to local date and time, if this is supported by the underlying OS. Otherwise, no conversion is done, and - {Date1, Time1} is returned.

+ Universaltime is returned.

 > erlang:universaltime_to_localtime({{1996,11,6},{14,18,43}}).
 {{1996,11,7},{15,18,43}}
-

Failure: badarg if Date1 or Time1 do - not denote a valid date or time.

+

Failure: badarg if Universaltime does not denote + a valid date and time.

- unlink(Id) -> true + Remove a link, if there is one, to another process or port - - Id = pid() | port() -

Removes the link, if there is one, between the calling - process and the process or port referred to by Id.

+ process and the process or port referred to by Id.

Returns true and does not fail, even if there is no - link to Id, or if Id does not exist.

-

Once unlink(Id) has returned it is guaranteed that + link to Id, or if Id does not exist.

+

Once unlink(Id) has returned it is guaranteed that the link between the caller and the entity referred to by - Id has no effect on the caller in the future (unless + Id has no effect on the caller in the future (unless the link is setup again). If caller is trapping exits, an - {'EXIT', Id, _} message due to the link might have + {'EXIT', Id, _} message due to the link might have been placed in the caller's message queue prior to the call, - though. Note, the {'EXIT', Id, _} message can be the - result of the link, but can also be the result of Id + though. Note, the {'EXIT', Id, _} message can be the + result of the link, but can also be the result of Id calling exit/2. Therefore, it may be appropriate to cleanup the message queue when trapping exits - after the call to unlink(Id), as follow:

+ after the call to unlink(Id), as follow:

unlink(Id), @@ -7118,13 +6583,10 @@ true
- unregister(RegName) -> true + Remove the registered name for a process (or port) - - RegName = atom() - -

Removes the registered name RegName, associated with a +

Removes the registered name RegName, associated with a pid or a port identifier.

 > unregister(db).
@@ -7135,7 +6597,7 @@ true
- whereis(RegName) -> pid() | port() | undefined + Get the pid (or port) with a given registered name

Returns the pid or port identifier with the registered name diff --git a/erts/preloaded/ebin/erlang.beam b/erts/preloaded/ebin/erlang.beam index 9e369d5348..8c8c48e338 100644 Binary files a/erts/preloaded/ebin/erlang.beam and b/erts/preloaded/ebin/erlang.beam differ diff --git a/erts/preloaded/src/erlang.erl b/erts/preloaded/src/erlang.erl index 7191713cf4..c64c2dbb4f 100644 --- a/erts/preloaded/src/erlang.erl +++ b/erts/preloaded/src/erlang.erl @@ -118,7 +118,7 @@ make_tuple/2, make_tuple/3, nodes/1, open_port/2, port_call/3, port_info/1, port_info/2, process_flag/2, process_info/2, send/2, send/3, seq_trace_info/1, - %setelement/3, %% Does not work (yet) + setelement/3, statistics/1, subtract/2, system_flag/2, term_to_binary/1, term_to_binary/2, tl/1, trace_pattern/2, trace_pattern/3, tuple_to_list/1, system_info/1, @@ -157,7 +157,7 @@ -type seq_trace_info_returns() :: { seq_trace_info(), non_neg_integer() | - boolean() | + boolean() | { non_neg_integer(), non_neg_integer() } } | []. @@ -175,91 +175,11 @@ -type raise_stacktrace() :: - [{atom(), atom(), arity() | [term()]} | + [{module(), atom(), arity() | [term()]} | {function(), [term()]}] | - [{atom(), atom(), arity() | [term()], [{atom(),term()}]} | + [{module(), atom(), arity() | [term()], [{atom(),term()}]} | {function(), [term()], [{atom(),term()}]}]. --type decode_packet_type() :: - 'raw' | 0..4 | 'asn1' | 'cdr' | 'sunrm' | 'fcgi' | 'tpkt' | - 'line' | 'http' | 'http_bin' | 'httph' | 'httph_bin'. --type http_packet() :: - http_request() | http_response() | http_header() | 'http_eoh' | http_error(). --type http_request() :: - {'http_request', http_method(), http_uri(), http_version()}. --type http_response() :: - {'http_response', http_version(), integer(), binary() | string()}. --type http_header() :: - {'http_header', integer(), http_field(), any(), binary() | string()}. --type http_error() :: - {'http_error', binary() | string()}. --type http_method() :: - 'OPTIONS' | 'GET' | 'HEAD' | 'POST' | 'PUT' | 'DELETE' | 'TRACE' | binary() | string(). --type http_uri() :: - '*' | - { 'http' | 'https', binary() | string(), non_neg_integer() | 'undefined', binary() | string()} | - {'scheme', binary() | string(), binary() | string()} | - {'abs_path', binary() | string()} | - binary() | - string(). --type http_version() :: - {non_neg_integer(), non_neg_integer()}. --type http_field() :: - 'Cache-Control' | - 'Connection' | - 'Date' | - 'Pragma' | - 'Transfer-Encoding' | - 'Upgrade' | - 'Via' | - 'Accept' | - 'Accept-Charset' | - 'Accept-Encoding' | - 'Accept-Language' | - 'Authorization' | - 'From' | - 'Host' | - 'If-Modified-Since' | - 'If-Match' | - 'If-None-Match' | - 'If-Range' | - 'If-Unmodified-Since' | - 'Max-Forwards' | - 'Proxy-Authorization' | - 'Range' | - 'Referer' | - 'User-Agent' | - 'Age' | - 'Location' | - 'Proxy-Authenticate' | - 'Public' | - 'Retry-After' | - 'Server' | - 'Vary' | - 'Warning' | - 'Www-Authenticate' | - 'Allow' | - 'Content-Base' | - 'Content-Encoding' | - 'Content-Language' | - 'Content-Length' | - 'Content-Location' | - 'Content-Md5' | - 'Content-Range' | - 'Content-Type' | - 'Etag' | - 'Expires' | - 'Last-Modified' | - 'Accept-Ranges' | - 'Set-Cookie' | - 'Set-Cookie2' | - 'X-Forwarded-For' | - 'Cookie' | - 'Keep-Alive' | - 'Proxy-Connection' | - binary() | - string(). - -type bitstring_list() :: maybe_improper_list(byte() | bitstring() | bitstring_list(), bitstring() | []). @@ -336,11 +256,11 @@ adler32_combine(_FirstAdler, _SecondAdler, _SecondSize) -> erlang:nif_error(undefined). % append_element/2 --spec erlang:append_element(Tuple, Term) -> ResTuple when - Tuple :: tuple(), - Term :: term(), - ResTuple :: tuple(). -append_element(_Tuple, _Term) -> +-spec erlang:append_element(Tuple1, Term) -> Tuple2 when + Tuple1 :: tuple(), + Tuple2 :: tuple(), + Term :: term(). +append_element(_Tuple1, _Term) -> erlang:nif_error(undefined). % atom_to_binary/2 @@ -359,7 +279,7 @@ atom_to_list(_Atom) -> % binary_part/2 -spec binary_part(Subject, PosLen) -> binary() when Subject :: binary(), - PosLen :: {non_neg_integer(), integer()}. + PosLen :: {Start :: non_neg_integer(), Length :: integer()}. binary_part(_Subject, _PosLen) -> erlang:nif_error(undefined). @@ -455,22 +375,22 @@ call_on_load_function(_P1) -> erlang:nif_error(undefined). % cancel_timer/1 --spec erlang:cancel_timer(TimerRef) -> Remains when +-spec erlang:cancel_timer(TimerRef) -> Time | false when TimerRef :: reference(), - Remains :: integer() | false. + Time :: non_neg_integer(). cancel_timer(_TimerRef) -> erlang:nif_error(undefined). % check_old_code/1 --spec erlang:check_old_code(Module) -> boolean() when - Module :: atom(). +-spec check_old_code(Module) -> boolean() when + Module :: module(). check_old_code(_Module) -> erlang:nif_error(undefined). % check_process_code/2 -spec check_process_code(Pid, Module) -> boolean() when Pid :: pid(), - Module :: atom(). + Module :: module(). check_process_code(_Pid, _Module) -> erlang:nif_error(undefined). @@ -502,16 +422,105 @@ date() -> erlang:nif_error(undefined). % decode_packet/3 --spec erlang:decode_packet(Type, Bin, Options) -> {ok, binary() | http_packet(), binary()} | {more, non_neg_integer() | undefined} | {error, term()} when - Type :: decode_packet_type(), +-spec erlang:decode_packet(Type, Bin, Options) -> + {ok, Packet, Rest} | + {more, Length} | + {error, Reason} when + Type :: 'raw' | 0 | 1 | 2 | 4 | 'asn1' | 'cdr' | 'sunrm' | 'fcgi' + | 'tpkt' | 'line' | 'http' | 'http_bin' | 'httph' | 'httph_bin', Bin :: binary(), - Options :: [{packet_size, non_neg_integer()} | {line_length, non_neg_integer()}]. + Options :: [Opt], + Opt :: {packet_size, non_neg_integer()} + | {line_length, non_neg_integer()}, + Packet :: binary() | HttpPacket, + Rest :: binary(), + Length :: non_neg_integer() | undefined, + Reason :: term(), + HttpPacket :: HttpRequest + | HttpResponse + | HttpHeader + | 'http_eoh' + | HttpError, + HttpRequest :: {'http_request', HttpMethod, HttpUri, HttpVersion}, + HttpResponse :: {'http_response', HttpVersion, integer(), HttpString}, + HttpHeader :: {'http_header', + integer(), + HttpField, + Reserved :: term(), + Value :: HttpString}, + HttpError :: {'http_error', HttpString}, + HttpMethod :: 'OPTIONS' | 'GET' | 'HEAD' | 'POST' | 'PUT' | 'DELETE' + | 'TRACE' | HttpString, + HttpUri :: '*' + | { 'absoluteURI', + 'http' | 'https', + Host :: HttpString, + Port :: inet:port_number() | 'undefined', + Path :: HttpString} + | {'scheme', Scheme :: HttpString, HttpString} + | {'abs_path', HttpString} + | HttpString, + HttpVersion :: {Major :: non_neg_integer(), Minor :: non_neg_integer()}, + HttpField :: 'Cache-Control' + | 'Connection' + | 'Date' + | 'Pragma' + | 'Transfer-Encoding' + | 'Upgrade' + | 'Via' + | 'Accept' + | 'Accept-Charset' + | 'Accept-Encoding' + | 'Accept-Language' + | 'Authorization' + | 'From' + | 'Host' + | 'If-Modified-Since' + | 'If-Match' + | 'If-None-Match' + | 'If-Range' + | 'If-Unmodified-Since' + | 'Max-Forwards' + | 'Proxy-Authorization' + | 'Range' + | 'Referer' + | 'User-Agent' + | 'Age' + | 'Location' + | 'Proxy-Authenticate' + | 'Public' + | 'Retry-After' + | 'Server' + | 'Vary' + | 'Warning' + |'Www-Authenticate' + | 'Allow' + | 'Content-Base' + | 'Content-Encoding' + | 'Content-Language' + | 'Content-Length' + | 'Content-Location' + | 'Content-Md5' + | 'Content-Range' + | 'Content-Type' + | 'Etag' + | 'Expires' + | 'Last-Modified' + | 'Accept-Ranges' + | 'Set-Cookie' + | 'Set-Cookie2' + | 'X-Forwarded-For' + | 'Cookie' + | 'Keep-Alive' + | 'Proxy-Connection' + | HttpString, + HttpString :: string() | binary(). decode_packet(_Type, _Bin, _Options) -> erlang:nif_error(undefined). % delete_module/1 -spec delete_module(Module) -> true | undefined when - Module :: atom(). + Module :: module(). delete_module(_Module) -> erlang:nif_error(undefined). @@ -524,7 +533,8 @@ demonitor(_MonitorRef) -> % demonitor/2 -spec demonitor(MonitorRef, OptionList) -> boolean() when MonitorRef :: reference(), - OptionList :: manual. + OptionList :: [Option], + Option :: flush | info. demonitor(_MonitorRef, _OptionList) -> erlang:nif_error(undefined). @@ -554,31 +564,34 @@ dist_exit(_P1, _P2, _P3) -> erlang:nif_error(undefined). % erase/0 --spec erase() -> [{term(), term()}]. +-spec erase() -> [{Key, Val}] when + Key :: term(), + Val :: term(). erase() -> erlang:nif_error(undefined). % erase/1 --spec erase(Key) -> undefined | term() when - Key :: term(). +-spec erase(Key) -> Val | undefined when + Key :: term(), + Val :: term(). erase(_Key) -> erlang:nif_error(undefined). % error/1 --spec error(Reason) -> none() when +-spec error(Reason) -> no_return() when Reason :: term(). error(_Reason) -> erlang:nif_error(undefined). % error/2 --spec error(Reason, Args) -> none() when +-spec error(Reason, Args) -> no_return() when Reason :: term(), Args :: [term()]. error(_Reason, _Args) -> erlang:nif_error(undefined). % exit/1 --spec exit(Reason) -> none() when +-spec exit(Reason) -> no_return() when Reason :: term(). exit(_Reason) -> erlang:nif_error(undefined). @@ -599,7 +612,7 @@ external_size(_Term) -> % external_size/2 -spec erlang:external_size(Term, Options) -> non_neg_integer() when Term :: term(), - Options :: [{minor_version, non_neg_integer()}]. + Options :: [{minor_version, Version :: non_neg_integer()}]. external_size(_Term, _Options) -> erlang:nif_error(undefined). @@ -623,9 +636,10 @@ float_to_list(_Float) -> erlang:nif_error(undefined). % fun_info/2 --spec erlang:fun_info(Fun, Item) -> {fun_info_item(), term()} when +-spec erlang:fun_info(Fun, Item) -> {Item, Info} when Fun :: function(), - Item :: fun_info_item(). + Item :: fun_info_item(), + Info :: term(). fun_info(_Fun, _Item) -> erlang:nif_error(undefined). @@ -637,7 +651,7 @@ fun_to_list(_Fun) -> % function_exported/3 -spec erlang:function_exported(Module, Function, Arity) -> boolean() when - Module :: atom(), + Module :: module(), Function :: atom(), Arity :: arity(). function_exported(_Module, _Function, _Arity) -> @@ -660,19 +674,23 @@ garbage_collect_message_area() -> erlang:nif_error(undefined). % get/0 --spec get() -> [{term(), term()}]. +-spec get() -> [{Key, Val}] when + Key :: term(), + Val :: term(). get() -> erlang:nif_error(undefined). % get/1 --spec get(Key) -> term() when - Key :: term(). +-spec get(Key) -> Val | undefined when + Key :: term(), + Val :: term(). get(_Key) -> erlang:nif_error(undefined). % get_keys/1 --spec get_keys(Val) -> [term()] when - Val :: term(). +-spec get_keys(Val) -> [Key] when + Val :: term(), + Key :: term(). get_keys(_Val) -> erlang:nif_error(undefined). @@ -700,26 +718,26 @@ group_leader(_GroupLeader, _Pid) -> erlang:nif_error(undefined). % halt/0 --spec halt() -> none(). +-spec halt() -> no_return(). halt() -> erlang:nif_error(undefined). % halt/1 --spec halt(Status) -> none() when - Status :: term(). +-spec halt(Status) -> no_return() when + Status :: non_neg_integer() | string(). halt(_Status) -> erlang:nif_error(undefined). % hash/2 --spec erlang:hash(Term, Range) -> integer() when +-spec erlang:hash(Term, Range) -> pos_integer() when Term :: term(), - Range :: integer(). + Range :: pos_integer(). hash(_Term, _Range) -> erlang:nif_error(undefined). % hibernate/3 -spec erlang:hibernate(Module, Function, Args) -> none() when - Module :: atom(), + Module :: module(), Function :: atom(), Args :: [term()]. hibernate(_Module, _Function, _Args) -> @@ -750,7 +768,7 @@ is_alive() -> % is_builtin/3 -spec erlang:is_builtin(Module, Function, Arity) -> boolean() when - Module :: atom(), + Module :: module(), Function :: atom(), Arity :: arity(). is_builtin(_Module, _Function, _Arity) -> @@ -764,7 +782,7 @@ is_process_alive(_Pid) -> % length/1 -spec length(List) -> non_neg_integer() when - List :: list(). + List :: [term()]. length(_List) -> erlang:nif_error(undefined). @@ -824,12 +842,13 @@ list_to_pid(_String) -> % list_to_tuple/1 -spec list_to_tuple(List) -> tuple() when - List :: list(). + List :: [term()]. list_to_tuple(_List) -> erlang:nif_error(undefined). % loaded/0 --spec erlang:loaded() -> [atom()]. +-spec erlang:loaded() -> [Module] when + Module :: module(). loaded() -> erlang:nif_error(undefined). @@ -846,7 +865,7 @@ make_ref() -> % match_spec_test/3 -spec erlang:match_spec_test(P1, P2, P3) -> TestResult when - P1 :: list() | tuple(), + P1 :: [term()] | tuple(), P2 :: term(), P3 :: table | trace, TestResult :: {ok, term(), [return_trace], [ {error | warning, string()} ]} | {error, [ {error | warning, string()} ]}. @@ -855,7 +874,7 @@ match_spec_test(_P1, _P2, _P3) -> % md5/1 -spec erlang:md5(Data) -> Digest when - Data :: iolist() | binary(), + Data :: iodata(), Digest :: binary(). md5(_Data) -> erlang:nif_error(undefined). @@ -876,21 +895,23 @@ md5_init() -> % md5_update/2 -spec erlang:md5_update(Context, Data) -> NewContext when Context :: binary(), - Data :: iolist() | binary(), + Data :: iodata(), NewContext :: binary(). md5_update(_Context, _Data) -> erlang:nif_error(undefined). % module_loaded/1 -spec module_loaded(Module) -> boolean() when - Module :: atom(). + Module :: module(). module_loaded(_Module) -> erlang:nif_error(undefined). % monitor/2 -spec monitor(Type, Item) -> MonitorRef when Type :: process, - Item :: pid() | atom() | {atom(), node()}, + Item :: pid() | Module | {Module, Node}, + Module :: module(), + Node :: node(), MonitorRef :: reference(). monitor(_Type, _Item) -> erlang:nif_error(undefined). @@ -906,20 +927,21 @@ monitor_node(_Node, _Flag) -> -spec erlang:monitor_node(Node, Flag, Options) -> true when Node :: node(), Flag :: boolean(), - Options :: [allow_passive_connect]. + Options :: [Option], + Option :: allow_passive_connect. monitor_node(_Node, _Flag, _Options) -> erlang:nif_error(undefined). % nif_error/1 --spec erlang:nif_error(Reason) -> none() when +-spec erlang:nif_error(Reason) -> no_return() when Reason :: term(). nif_error(_Reason) -> erlang:nif_error(undefined). % nif_error/2 --spec erlang:nif_error(Reason, Args) -> none() when +-spec erlang:nif_error(Reason, Args) -> no_return() when Reason :: term(), - Args :: list(). + Args :: [term()]. nif_error(_Reason, _Args) -> erlang:nif_error(undefined). @@ -938,7 +960,7 @@ node(_Arg) -> % now/0 -spec now() -> Timestamp when - Timestamp :: {non_neg_integer(),non_neg_integer(),non_neg_integer()}. + Timestamp :: timestamp(). now() -> erlang:nif_error(undefined). @@ -988,7 +1010,8 @@ port_command(_Port, _Data) -> -spec port_command(Port, Data, OptionList) -> boolean() when Port :: port() | atom(), Data :: iodata(), - OptionList :: [force | nosuspend]. + OptionList :: [Option], + Option :: force | nosuspend. port_command(_Port, _Data, _OptionList) -> erlang:nif_error(undefined). @@ -1039,7 +1062,7 @@ posixtime_to_universaltime(_P1) -> erlang:nif_error(undefined). % pre_loaded/0 --spec pre_loaded() -> [atom()]. +-spec pre_loaded() -> [module()]. pre_loaded() -> erlang:nif_error(undefined). @@ -1062,7 +1085,8 @@ process_flag(_Pid, _Flag, _Value) -> % process_info/1 -spec process_info(Pid) -> Info when Pid :: pid(), - Info :: [process_info_result_item()]. + Info :: [InfoTuple], + InfoTuple :: process_info_result_item(). process_info(_Pid) -> erlang:nif_error(undefined). @@ -1085,7 +1109,7 @@ put(_Key, _Val) -> erlang:nif_error(undefined). % raise/3 --spec erlang:raise(Class, Reason, Stacktrace) -> none() when +-spec erlang:raise(Class, Reason, Stacktrace) -> no_return() when Class :: error | exit | throw, Reason :: term(), Stacktrace :: raise_stacktrace(). @@ -1112,7 +1136,8 @@ register(_RegName, _PidOrPort) -> erlang:nif_error(undefined). % registered/0 --spec registered() -> [atom()]. +-spec registered() -> [RegName] when + RegName :: atom(). registered() -> erlang:nif_error(undefined). @@ -1185,7 +1210,7 @@ size(_Item) -> % spawn/3 -spec spawn(Module, Function, Args) -> pid() when - Module :: atom(), + Module :: module(), Function :: atom(), Args :: [term()]. spawn(_Module, _Function, _Args) -> @@ -1193,7 +1218,7 @@ spawn(_Module, _Function, _Args) -> % spawn_link/3 -spec spawn_link(Module, Function, Args) -> pid() when - Module :: atom(), + Module :: module(), Function :: atom(), Args :: [term()]. spawn_link(_Module, _Function, _Args) -> @@ -1218,20 +1243,25 @@ start_timer(_Time, _Dest, _Msg) -> % suspend_process/2 -spec erlang:suspend_process(Suspendee, OptList) -> boolean() when Suspendee :: pid(), - OptList :: [unless_suspending | asynchronous]. + OptList :: [Opt], + Opt :: unless_suspending | asynchronous. suspend_process(_Suspendee, _OptList) -> erlang:nif_error(undefined). % system_monitor/0 -spec erlang:system_monitor() -> MonSettings when - MonSettings :: undefined | { pid(), [ system_monitor_option() ] }. + MonSettings :: undefined | { MonitorPid, Options }, + MonitorPid :: pid(), + Options :: [ system_monitor_option() ]. system_monitor() -> erlang:nif_error(undefined). % system_monitor/1 -spec erlang:system_monitor(Arg) -> MonSettings when - Arg :: undefined | { pid(), [ system_monitor_option() ] }, - MonSettings :: undefined | { pid(), [ system_monitor_option() ] }. + Arg :: undefined | { MonitorPid, Options }, + MonSettings :: undefined | { MonitorPid, Options }, + MonitorPid :: pid(), + Options :: [ system_monitor_option() ]. system_monitor(_Arg) -> erlang:nif_error(undefined). @@ -1239,26 +1269,30 @@ system_monitor(_Arg) -> -spec erlang:system_monitor(MonitorPid, Options) -> MonSettings when MonitorPid :: pid(), Options :: [ system_monitor_option() ], - MonSettings :: undefined | { pid(), [ system_monitor_option() ] }. + MonSettings :: undefined | { OldMonitorPid, OldOptions }, + OldMonitorPid :: pid(), + OldOptions :: [ system_monitor_option() ]. system_monitor(_MonitorPid, _Options) -> erlang:nif_error(undefined). % system_profile/0 -spec erlang:system_profile() -> ProfilerSettings when - ProfilerSettings :: undefined | { pid() | port(), [ system_profile_option() ]}. + ProfilerSettings :: undefined | { ProfilerPid, Options}, + ProfilerPid :: pid() | port(), + Options :: [ system_profile_option() ]. system_profile() -> erlang:nif_error(undefined). % system_profile/2 -spec erlang:system_profile(ProfilerPid, Options) -> ProfilerSettings when - ProfilerPid :: pid() | port() | undefined, + ProfilerPid :: pid() | port(), Options :: [ system_profile_option() ], ProfilerSettings :: undefined | { pid() | port(), [ system_profile_option() ]}. system_profile(_ProfilerPid, _Options) -> erlang:nif_error(undefined). % throw/1 --spec throw(Any) -> none() when +-spec throw(Any) -> no_return() when Any :: term(). throw(_Any) -> erlang:nif_error(undefined). @@ -1286,7 +1320,10 @@ trace_delivered(_Tracee) -> % trace_info/2 -spec erlang:trace_info(PidOrFunc, Item) -> Res when - PidOrFunc :: pid() | new | mfa() | on_load, + PidOrFunc :: pid() | new | {Module, Function, Arity} | on_load, + Module :: module(), + Function :: atom(), + Arity :: arity(), Item :: flags | tracer | traced | match_spec | meta | meta_match_spec | call_count | call_time | all, Res :: trace_info_return(). trace_info(_PidOrFunc, _Item) -> @@ -1351,7 +1388,7 @@ abs(_Number) -> %% Not documented -spec erlang:append(List,Tail) -> maybe_improper_list() when - List :: list(), + List :: [term()], Tail :: term(). append(_List,_Tail) -> erlang:nif_error(undefined). @@ -1682,7 +1719,11 @@ process_flag(_Flag, _Value) -> {trap_exit, Boolean :: boolean()}. -type stack_item() :: - {atom(), atom(), arity() | [term()], [{file, string()} | {line, integer()}]}. + {Module :: module(), + Function :: atom(), + Arity :: arity() | (Args :: [term()]), + Location :: [{file, Filename :: string()} | + {line, Line :: integer()}]}. -spec process_info(Pid, Item) -> InfoTuple | [] | undefined when @@ -1722,13 +1763,13 @@ send(_Dest,_Msg,_Options) -> seq_trace_info(_What) -> erlang:nif_error(undefined). -%% -spec setelement(Index, Tuple1, Value) -> Tuple2 when -%% Index :: pos_integer(), -%% Tuple1 :: tuple(), -%% Tuple2 :: tuple(), -%% Value :: term(). -%% setelement(_Index, _Tuple1, _Value) -> -%% erlang:nif_error(undefined). +-spec setelement(Index, Tuple1, Value) -> Tuple2 when + Index :: pos_integer(), + Tuple1 :: tuple(), + Tuple2 :: tuple(), + Value :: term(). +setelement(_Index, _Tuple1, _Value) -> + erlang:nif_error(undefined). -spec statistics(context_switches) -> {ContextSwitches,0} when ContextSwitches :: non_neg_integer(); @@ -2748,7 +2789,9 @@ max(A, _) -> A. low = 0, maximum = 0}). --spec memory() -> [{memory_type(), non_neg_integer()}]. +-spec memory() -> [{Type, Size}] when + Type :: memory_type(), + Size :: non_neg_integer(). memory() -> case aa_mem_data(au_mem_data(?ALL_NEEDED_ALLOCS)) of notsup -> @@ -2773,8 +2816,8 @@ memory() -> {ets, Mem#memory.ets} | Tail] end. --spec erlang:memory(memory_type()) -> non_neg_integer(); - ([memory_type()]) -> [{memory_type(), non_neg_integer()}]. +-spec erlang:memory(Type :: memory_type()) -> non_neg_integer(); + (TypeList :: [memory_type()]) -> [{memory_type(), non_neg_integer()}]. memory(Type) when erlang:is_atom(Type) -> {AA, ALCU, ChkSup, BadArgZero} = need_mem_info(Type), case get_mem_data(ChkSup, ALCU, AA) of -- cgit v1.2.3