From 4bd8ab6298961d564c34172c0a4d74cd08a08249 Mon Sep 17 00:00:00 2001 From: Hans Bolinder Date: Wed, 8 Jun 2011 09:23:14 +0200 Subject: Add more specs and types An incorrect spec, rpc:yield/1, has been fixed. --- lib/hipe/cerl/erl_bif_types.erl | 12 +- lib/kernel/doc/src/Makefile | 2 + lib/kernel/doc/src/code.xml | 339 +++++++++++++++------------------------- lib/kernel/doc/src/file.xml | 21 +-- lib/kernel/doc/src/os.xml | 3 +- lib/kernel/src/auth.erl | 2 +- lib/kernel/src/code.erl | 135 ++++++++++------ lib/kernel/src/file.erl | 18 +-- lib/kernel/src/inet_config.erl | 52 +----- lib/kernel/src/rpc.erl | 5 +- lib/stdlib/doc/src/calendar.xml | 15 +- lib/stdlib/doc/src/io.xml | 2 +- lib/stdlib/src/calendar.erl | 78 +++++---- lib/stdlib/src/timer.erl | 4 +- 14 files changed, 288 insertions(+), 400 deletions(-) (limited to 'lib') diff --git a/lib/hipe/cerl/erl_bif_types.erl b/lib/hipe/cerl/erl_bif_types.erl index 0b47c7b6e1..f1be658054 100644 --- a/lib/hipe/cerl/erl_bif_types.erl +++ b/lib/hipe/cerl/erl_bif_types.erl @@ -702,7 +702,7 @@ type(erlang, demonitor, 1, Xs) -> type(erlang, demonitor, 2, Xs) -> strict(arg_types(erlang, demonitor, 2), Xs, fun (_) -> t_boolean() end); type(erlang, disconnect_node, 1, Xs) -> - strict(arg_types(erlang, disconnect_node, 1), Xs, fun (_) -> t_boolean() end); + strict(arg_types(erlang, disconnect_node, 1), Xs, fun (_) -> t_sup([t_boolean(), t_atom('ignored')]) end); type(erlang, display, 1, _) -> t_atom('true'); type(erlang, display_string, 1, Xs) -> strict(arg_types(erlang, display_string, 1), Xs, fun(_) -> t_atom('true') end); @@ -1124,7 +1124,7 @@ type(erlang, nodes, 0, _) -> t_list(t_node()); type(erlang, nodes, 1, Xs) -> strict(arg_types(erlang, nodes, 1), Xs, fun (_) -> t_list(t_node()) end); type(erlang, now, 0, _) -> - t_time(); + t_timestamp(); type(erlang, open_port, 2, Xs) -> strict(arg_types(erlang, open_port, 2), Xs, fun (_) -> t_port() end); type(erlang, phash, 2, Xs) -> @@ -1585,8 +1585,7 @@ type(erlang, system_info, 1, Xs) -> ['multi_scheduling_blockers'] -> t_list(t_pid()); ['os_type'] -> - t_tuple([t_sup([t_atom('ose'), % XXX: undocumented - t_atom('unix'), + t_tuple([t_sup([t_atom('unix'), t_atom('vxworks'), t_atom('win32')]), t_atom()]); @@ -2693,7 +2692,7 @@ type(os, getpid, 0, _) -> t_string(); type(os, putenv, 2, Xs) -> strict(arg_types(os, putenv, 2), Xs, fun (_) -> t_atom('true') end); type(os, timestamp, 0, _) -> - t_time(); + t_timestamp(); %%-- re ----------------------------------------------------------------------- type(re, compile, 1, Xs) -> strict(arg_types(re, compile, 1), Xs, @@ -4458,6 +4457,9 @@ t_date() -> t_time() -> t_tuple([t_non_neg_fixnum(), t_non_neg_fixnum(), t_non_neg_fixnum()]). +t_timestamp() -> + t_tuple([t_non_neg_fixnum(), t_non_neg_fixnum(), t_non_neg_fixnum()]). + t_packet() -> t_sup([t_binary(), t_iolist(), t_httppacket()]). diff --git a/lib/kernel/doc/src/Makefile b/lib/kernel/doc/src/Makefile index de10e31d36..214e994889 100644 --- a/lib/kernel/doc/src/Makefile +++ b/lib/kernel/doc/src/Makefile @@ -104,6 +104,8 @@ TOP_SPECS_FILE = specs.xml # ---------------------------------------------------- XML_FLAGS += +SPECS_ESRC = ../../src + SPECS_FLAGS = -I../../include # ---------------------------------------------------- diff --git a/lib/kernel/doc/src/code.xml b/lib/kernel/doc/src/code.xml index 6f85388c22..98cdd416b0 100644 --- a/lib/kernel/doc/src/code.xml +++ b/lib/kernel/doc/src/code.xml @@ -287,6 +287,9 @@ + + + @@ -294,190 +297,147 @@ - set_path(Path) -> true | {error, What} + Set the code server search path - - Path = [Dir] - Dir = string() - What = bad_directory | bad_path - -

Sets the code path to the list of directories Path.

+

Sets the code path to the list of directories Path.

Returns true if successful, or - {error, bad_directory} if any Dir is not + {error, bad_directory} if any Dir is not the name of a directory, or {error, bad_path} if the argument is invalid.

- get_path() -> Path + Return the code server search path - - Path = [Dir] - Dir = string() -

Returns the code path

- add_path(Dir) -> true | {error, What} - add_pathz(Dir) -> true | {error, What} + + Add a directory to the end of the code path - - Dir = string() - What = bad_directory - + -

Adds Dir to the code path. The directory is added as - the last directory in the new path. If Dir already +

Adds Dir to the code path. The directory is added as + the last directory in the new path. If Dir already exists in the path, it is not added.

Returns true if successful, or - {error, bad_directory} if Dir is not the name + {error, bad_directory} if Dir is not the name of a directory.

- add_patha(Dir) -> true | {error, What} + Add a directory to the beginning of the code path - - Dir = string() - What = bad_directory - + -

Adds Dir to the beginning of the code path. If - Dir already exists, it is removed from the old +

Adds Dir to the beginning of the code path. If + Dir already exists, it is removed from the old position in the code path.

Returns true if successful, or - {error, bad_directory} if Dir is not the name + {error, bad_directory} if Dir is not the name of a directory.

- add_paths(Dirs) -> ok - add_pathsz(Dirs) -> ok + + Add directories to the end of the code path - - Dirs = [Dir] - Dir = string() - -

Adds the directories in Dirs to the end of the code - path. If a Dir already exists, it is not added. This +

Adds the directories in Dirs to the end of the code + path. If a Dir already exists, it is not added. This function always returns ok, regardless of the validity - of each individual Dir.

+ of each individual Dir.

- add_pathsa(Dirs) -> ok + Add directories to the beginning of the code path - - Dirs = [Dir] - Dir = string() - -

Adds the directories in Dirs to the beginning of - the code path. If a Dir already exists, it is removed +

Adds the directories in Dirs to the beginning of + the code path. If a Dir already exists, it is removed from the old position in the code path. This function always returns ok, regardless of the validity of each - individual Dir.

+ individual Dir.

- del_path(Name | Dir) -> true | false | {error, What} + Delete a directory from the code path - - Name = atom() - Dir = string() - What = bad_name -

Deletes a directory from the code path. The argument can be - an atom Name, in which case the directory with - the name .../Name[-Vsn][/ebin] is deleted from the code + an atom Name, in which case the directory with + the name .../Name[-Vsn][/ebin] is deleted from the code path. It is also possible to give the complete directory name - Dir as argument.

+ Dir as argument.

Returns true if successful, or false if the directory is not found, or {error, bad_name} if the argument is invalid.

- replace_path(Name, Dir) -> true | {error, What} + Replace a directory with another in the code path - - Name = atom() - Dir = string() - What = bad_name | bad_directory | {badarg, term()} -

This function replaces an old occurrence of a directory - named .../Name[-Vsn][/ebin], in the code path, with - Dir. If Name does not exist, it adds the new - directory Dir last in the code path. The new directory - must also be named .../Name[-Vsn][/ebin]. This function + named .../Name[-Vsn][/ebin], in the code path, with + Dir. If Name does not exist, it adds the new + directory Dir last in the code path. The new directory + must also be named .../Name[-Vsn][/ebin]. This function should be used if a new version of the directory (library) is added to a running system.

Returns true if successful, or - {error, bad_name} if Name is not found, or - {error, bad_directory} if Dir does not exist, or - {error, {badarg, [Name, Dir]}} if Name or - Dir is invalid.

+ {error, bad_name} if Name is not found, or + {error, bad_directory} if Dir does not exist, or + {error, {badarg, [Name, Dir]}} if Name or + Dir is invalid.

- load_file(Module) -> {module, Module} | {error, What} + Load a module - - Module = atom() - What = nofile | sticky_directory | badarg | term() - + -

Tries to load the Erlang module Module, using +

Tries to load the Erlang module Module, using the code path. It looks for the object code file with an extension that corresponds to the Erlang machine used, for - example Module.beam. The loading fails if the module + example Module.beam. The loading fails if the module name found in the object code differs from the name - Module. + Module. load_binary/3 must be used to load object code with a module name that is different from the file name.

-

Returns {module, Module} if successful, or +

Returns {module, Module} if successful, or {error, nofile} if no object code is found, or {error, sticky_directory} if the object code resides in - a sticky directory, or {error, badarg} if the argument - is invalid. Also if the loading fails, an error tuple is + a sticky directory. Also if the loading fails, an error tuple is returned. See erlang:load_module/2 - for possible values of What.

+ for possible values of What.

- load_abs(Filename) -> {module, Module} | {error, What} + Load a module, residing in a given file - - Filename = string() - Module = atom() - What = nofile | sticky_directory | badarg | term() - + + + -

Does the same as load_file(Module), but - Filename is either an absolute file name, or a +

Does the same as load_file(Module), but + Filename is either an absolute file name, or a relative file name. The code path is not searched. It returns a value in the same way as load_file/1. Note - that Filename should not contain the extension (for + that Filename should not contain the extension (for example ".beam"); load_abs/1 adds the correct extension itself.

- ensure_loaded(Module) -> {module, Module} | {error, What} + Ensure that a module is loaded - - Module = atom() - What = nofile | sticky_directory | embedded | badarg | term() -

Tries to to load a module in the same way as load_file/1, @@ -487,54 +447,45 @@ - load_binary(Module, Filename, Binary) -> {module, Module} | {error, What} + Load object code for a module - - Module = atom() - Filename = string() - What = sticky_directory | badarg | term() - + +

This function can be used to load object code on remote - Erlang nodes. The argument Binary must contain - object code for Module. - Filename is only used by the code server to keep a - record of from which file the object code for Module - comes. Accordingly, Filename is not opened and read by + Erlang nodes. The argument Binary must contain + object code for Module. + Filename is only used by the code server to keep a + record of from which file the object code for Module + comes. Accordingly, Filename is not opened and read by the code server.

-

Returns {module, Module} if successful, or +

Returns {module, Module} if successful, or {error, sticky_directory} if the object code resides in a sticky directory, or {error, badarg} if any argument is invalid. Also if the loading fails, an error tuple is returned. See erlang:load_module/2 - for possible values of What.

+ for possible values of What.

- delete(Module) -> true | false + Removes current code for a module - - Module = atom() - -

Removes the current code for Module, that is, - the current code for Module is made old. This means +

Removes the current code for Module, that is, + the current code for Module is made old. This means that processes can continue to execute the code in the module, but that no external function calls can be made to it.

Returns true if successful, or false if there - is old code for Module which must be purged first, or - if Module is not a (loaded) module.

+ is old code for Module which must be purged first, or + if Module is not a (loaded) module.

- purge(Module) -> true | false + Removes old code for a module - - Module = atom() - -

Purges the code for Module, that is, removes code +

Purges the code for Module, that is, removes code marked as old. If some processes still linger in the old code, these processes are killed before the code is removed.

Returns true if successful and any process needed to @@ -542,31 +493,26 @@ - soft_purge(Module) -> true | false + Removes old code for a module, unless no process uses it - - Module = atom() - -

Purges the code for Module, that is, removes code +

Purges the code for Module, that is, removes code marked as old, but only if no processes linger in it.

Returns false if the module could not be purged due to processes lingering in old code, otherwise true.

- is_loaded(Module) -> {file, Loaded} | false + Check if a module is loaded - - Module = atom() - Loaded = Absname | preloaded | cover_compiled - Absname = string() - - -

Checks if Module is loaded. If it is, - {file, Loaded} is returned, otherwise false.

-

Normally, Loaded is the absolute file name - Absname from which the code was obtained. If the module + + + Filename is an absolute filename + +

Checks if Module is loaded. If it is, + {file, Loaded} is returned, otherwise false.

+

Normally, Loaded is the absolute file name + Filename from which the code was obtained. If the module is preloaded (see script(4)), Loaded==preloaded. If the module is Cover compiled (see @@ -575,32 +521,26 @@ - all_loaded() -> [{Module, Loaded}] + Get all loaded modules - - Module = atom() - Loaded = Absname | preloaded | cover_compiled - Absname = string() - + + + Filename is an absolute filename -

Returns a list of tuples {Module, Loaded} for all - loaded modules. Loaded is normally the absolute file +

Returns a list of tuples {Module, Loaded} for all + loaded modules. Loaded is normally the absolute file name, as described for is_loaded/1.

- which(Module) -> Which + The object code file of a module - - Module = atom() - Which = Filename | non_existing | preloaded | cover_compiled - Filename = string() - +

If the module is not loaded, this function searches the code path for the first file which contains object code for - Module and returns the absolute file name. If + Module and returns the absolute file name. If the module is loaded, it returns the name of the file which contained the loaded object code. If the module is pre-loaded, preloaded is returned. If the module is Cover compiled, @@ -609,21 +549,16 @@ - get_object_code(Module) -> {Module, Binary, Filename} | error + Get the object code for a module - - Module = atom() - Binary = binary() - Filename = string() -

Searches the code path for the object code of the module - Module. It returns {Module, Binary, Filename} - if successful, and error if not. Binary is a + Module. It returns {Module, Binary, Filename} + if successful, and error if not. Binary is a binary data object which contains the object code for the module. This can be useful if code is to be loaded on a remote node in a distributed system. For example, loading - module Module on a node Node is done as + module Module on a node Node is done as follows:

... @@ -633,7 +568,7 @@ rpc:call(Node, code, load_binary, [Module, Filename, Binary]),
- root_dir() -> string() + Root directory of Erlang/OTP

Returns the root directory of Erlang/OTP, which is @@ -644,7 +579,7 @@ rpc:call(Node, code, load_binary, [Module, Filename, Binary]), - lib_dir() -> string() + Library directory of Erlang/OTP

Returns the library directory, $OTPROOT/lib, where @@ -655,19 +590,16 @@ rpc:call(Node, code, load_binary, [Module, Filename, Binary]), - lib_dir(Name) -> string() | {error, bad_name} + Library directory for an application - - Name = atom() -

This function is mainly intended for finding out the path for the "library directory", the top directory, for an - application Name located under $OTPROOT/lib or + application Name located under $OTPROOT/lib or on a directory referred to via the ERL_LIBS environment variable.

-

If there is a regular directory called Name or - Name-Vsn in the code path with an ebin +

If there is a regular directory called Name or + Name-Vsn in the code path with an ebin subdirectory, the path to this directory is returned (not the ebin directory). If the directory refers to a directory in an archive, the archive name is stripped away @@ -681,23 +613,19 @@ rpc:call(Node, code, load_binary, [Module, Filename, Binary]),

 > code:lib_dir(mnesia).
 "/usr/local/otp/lib/mnesia-4.2.2"
-

Returns {error, bad_name} if Name +

Returns {error, bad_name} if Name is not the name of an application under $OTPROOT/lib or on a directory referred to via the ERL_LIBS environment variable. Fails with an exception if Name has the wrong type.

-

For backward compatibility, Name is also allowed to +

For backward compatibility, Name is also allowed to be a string. That will probably change in a future release.

- lib_dir(Name, SubDir) -> string() | {error, bad_name} + subdirectory for an application - - Name = atom() - SubDir = atom() -

Returns the path to a subdirectory directly under the top directory of an application. Normally the subdirectories @@ -711,12 +639,12 @@ rpc:call(Node, code, load_binary, [Module, Filename, Binary]), > code:lib_dir(megaco, priv). "/usr/local/otp/lib/megaco-3.9.1.1/priv" -

Fails with an exception if Name or SubDir has +

Fails with an exception if Name or SubDir has the wrong type.

- compiler_dir() -> string() + Library directory for the compiler

Returns the compiler library directory. Equivalent to @@ -724,21 +652,18 @@ rpc:call(Node, code, load_binary, [Module, Filename, Binary]), - priv_dir(Name) -> string() | {error, bad_name} + Priv directory for an application - - Name = atom() -

Returns the path to the priv directory in an - application. Equivalent to code:lib_dir(Name,priv)..

+ application. Equivalent to code:lib_dir(Name, priv)..

-

For backward compatibility, Name is also allowed to +

For backward compatibility, Name is also allowed to be a string. That will probably change in a future release.

- objfile_extension() -> ".beam" + Object code file extension

Returns the object code file extension that corresponds to @@ -746,24 +671,16 @@ rpc:call(Node, code, load_binary, [Module, Filename, Binary]), - stick_dir(Dir) -> ok | error + Mark a directory as sticky - - Dir = string() - What = term() - -

This function marks Dir as sticky.

+

This function marks Dir as sticky.

Returns ok if successful or error if not.

- unstick_dir(Dir) -> ok | error + Remove a sticky directory mark - - Dir = string() - What = term() -

This function unsticks a directory which has been marked as sticky.

@@ -771,45 +688,39 @@ rpc:call(Node, code, load_binary, [Module, Filename, Binary]),
- is_sticky(Module) -> true | false + Test whether a module is sticky - - Module = atom() - -

This function returns true if Module is the +

This function returns true if Module is the name of a module that has been loaded from a sticky directory (or in other words: an attempt to reload the module will fail), - or false if Module is not a loaded module or is + or false if Module is not a loaded module or is not sticky.

- rehash() -> ok + Rehash or create code path cache

This function creates or rehashes the code path cache.

- where_is_file(Filename) -> Absname | non_existing + Full name of a file located in the code path - - Filename = Absname = string() - -

Searches the code path for Filename, a file of +

Searches the code path for Filename, a file of arbitrary type. If found, the full name is returned. non_existing is returned if the file cannot be found. The function can be useful, for example, to locate application resource files. If the code path cache is used, the code server will efficiently read the full name from - the cache, provided that Filename is an object code + the cache, provided that Filename is an object code file or an .app file.

- clash() -> ok + Search for modules with identical names.

Searches the entire code space for module names with @@ -817,10 +728,10 @@ rpc:call(Node, code, load_binary, [Module, Filename, Binary]), - is_module_native(Module) -> true | false | undefined + is_module_native(Module) -> boolean() | undefined Test whether a module has native code - Module = atom() + Module = module()

This function returns true if Module is diff --git a/lib/kernel/doc/src/file.xml b/lib/kernel/doc/src/file.xml index e0feaf6ee7..861c582211 100644 --- a/lib/kernel/doc/src/file.xml +++ b/lib/kernel/doc/src/file.xml @@ -94,9 +94,6 @@ - - - @@ -135,12 +132,6 @@ Unix, and in the runtime libraries of most C compilers.

- - - - - - @@ -1220,15 +1211,15 @@ f.txt: {person, "kalle", 25}.

The current system access to the file.

- atime = time() + atime = date_time()

The last (local) time the file was read.

- mtime = time() + mtime = date_time()

The last (local) time the file was written.

- ctime = time() + ctime = date_time()

The interpretation of this time field depends on the operating system. On Unix, it is the last time @@ -1669,15 +1660,15 @@ f.txt: {person, "kalle", 25}.

The following fields are used from the record, if they are given.

- atime = time() + atime = date_time()

The last (local) time the file was read.

- mtime = time() + mtime = date_time()

The last (local) time the file was written.

- ctime = time() + ctime = date_time()

On Unix, any value give for this field will be ignored (the "ctime" for the file will be set to the current diff --git a/lib/kernel/doc/src/os.xml b/lib/kernel/doc/src/os.xml index 56fc1834ec..e94119845a 100644 --- a/lib/kernel/doc/src/os.xml +++ b/lib/kernel/doc/src/os.xml @@ -126,9 +126,10 @@ DirOut = os:cmd("dir"), % on Win32 platform - timestamp() -> {MegaSecs, Secs, MicroSecs} + timestamp() -> Timestamp Returna a timestamp from the OS in the erlang:now/0 format + Timestamp = {MegaSecs, Secs, MicroSecs} = erlang:timestamp() MegaSecs = Secs = MicroSecs = integer() >= 0 diff --git a/lib/kernel/src/auth.erl b/lib/kernel/src/auth.erl index 25c88a4e1d..ac25ab958c 100644 --- a/lib/kernel/src/auth.erl +++ b/lib/kernel/src/auth.erl @@ -58,7 +58,7 @@ start_link() -> %%--Deprecated interface------------------------------------------------ -spec is_auth(Node) -> 'yes' | 'no' when - Node :: Node :: node(). + Node :: node(). is_auth(Node) -> case net_adm:ping(Node) of diff --git a/lib/kernel/src/code.erl b/lib/kernel/src/code.erl index b0f99305f2..882e9625fe 100644 --- a/lib/kernel/src/code.erl +++ b/lib/kernel/src/code.erl @@ -82,7 +82,8 @@ %% add_pathsa([Dir]) -> ok %% add_pathsz([Dir]) -> ok %% del_path(Dir) -> boolean() | {error, bad_name} -%% replace_path(Name, Dir) -> true | replace_path_error() +%% replace_path(Name, Dir) -> true | {error, bad_directory | bad_name +%% | {badarg,_}} %% load_file(Module) -> {module, Module} | {error, What :: atom()} %% load_abs(File) -> {module, Module} | {error, What :: atom()} %% load_abs(File, Module) -> {module, Module} | {error, What :: atom()} @@ -113,11 +114,16 @@ %% Some types for basic exported functions of this module %%---------------------------------------------------------------------------- --type load_error_rsn() :: 'badfile' | 'native_code' | 'nofile' | 'not_purged' - | 'sticky_directory'. % for some functions only --type load_ret() :: {'error', load_error_rsn()} | {'module', atom()}. +-type load_error_rsn() :: 'badfile' + | 'native_code' + | 'nofile' + | 'not_purged' + | 'on_load' + | 'sticky_directory'. +-type load_ret() :: {'error', What :: load_error_rsn()} + | {'module', Module :: module()}. -type loaded_ret_atoms() :: 'cover_compiled' | 'preloaded'. --type loaded_filename() :: file:filename() | loaded_ret_atoms(). +-type loaded_filename() :: (Filename :: file:filename()) | loaded_ret_atoms(). %%---------------------------------------------------------------------------- %% User interface @@ -127,55 +133,74 @@ objfile_extension() -> init:objfile_extension(). --spec load_file(Module :: atom()) -> load_ret(). +-spec load_file(Module) -> load_ret() when + Module :: module(). load_file(Mod) when is_atom(Mod) -> call({load_file,Mod}). --spec ensure_loaded(Module :: atom()) -> load_ret(). +-spec ensure_loaded(Module) -> {module, Module} | {error, What} when + Module :: module(), + What :: embedded | badfile | native_code | nofile | on_load. ensure_loaded(Mod) when is_atom(Mod) -> call({ensure_loaded,Mod}). %% XXX File as an atom is allowed only for backwards compatibility. --spec load_abs(Filename :: file:filename()) -> load_ret(). +-spec load_abs(Filename) -> load_ret() when + Filename :: file:filename(). load_abs(File) when is_list(File); is_atom(File) -> call({load_abs,File,[]}). %% XXX Filename is also an atom(), e.g. 'cover_compiled' --spec load_abs(Filename :: loaded_filename(), Module :: atom()) -> load_ret(). +-spec load_abs(Filename :: loaded_filename(), Module :: module()) -> load_ret(). load_abs(File, M) when (is_list(File) orelse is_atom(File)), is_atom(M) -> call({load_abs,File,M}). %% XXX Filename is also an atom(), e.g. 'cover_compiled' --spec load_binary(Module :: atom(), Filename :: loaded_filename(), Binary :: binary()) -> load_ret(). +-spec load_binary(Module, Filename, Binary) -> + {module, Module} | {error, What} when + Module :: module(), + Filename :: loaded_filename(), + Binary :: binary(), + What :: badarg | load_error_rsn(). load_binary(Mod, File, Bin) when is_atom(Mod), (is_list(File) orelse is_atom(File)), is_binary(Bin) -> call({load_binary,Mod,File,Bin}). --spec load_native_partial(Module :: atom(), Binary :: binary()) -> load_ret(). +-spec load_native_partial(Module :: module(), Binary :: binary()) -> load_ret(). load_native_partial(Mod, Bin) when is_atom(Mod), is_binary(Bin) -> call({load_native_partial,Mod,Bin}). --spec load_native_sticky(Module :: atom(), Binary :: binary(), WholeModule :: 'false' | binary()) -> load_ret(). +-spec load_native_sticky(Module :: module(), Binary :: binary(), WholeModule :: 'false' | binary()) -> load_ret(). load_native_sticky(Mod, Bin, WholeModule) when is_atom(Mod), is_binary(Bin), (is_binary(WholeModule) orelse WholeModule =:= false) -> call({load_native_sticky,Mod,Bin,WholeModule}). --spec delete(Module :: atom()) -> boolean(). +-spec delete(Module) -> boolean() when + Module :: module(). delete(Mod) when is_atom(Mod) -> call({delete,Mod}). --spec purge(Module :: atom()) -> boolean(). +-spec purge(Module) -> boolean() when + Module :: module(). purge(Mod) when is_atom(Mod) -> call({purge,Mod}). --spec soft_purge(Module :: atom()) -> boolean(). +-spec soft_purge(Module) -> boolean() when + Module :: module(). soft_purge(Mod) when is_atom(Mod) -> call({soft_purge,Mod}). --spec is_loaded(Module :: atom()) -> {'file', loaded_filename()} | 'false'. +-spec is_loaded(Module) -> {'file', Loaded} | false when + Module :: module(), + Loaded :: loaded_filename(). is_loaded(Mod) when is_atom(Mod) -> call({is_loaded,Mod}). --spec get_object_code(Module :: atom()) -> {atom(), binary(), file:filename()} | 'error'. +-spec get_object_code(Module) -> {Module, Binary, Filename} | error when + Module :: module(), + Binary :: binary(), + Filename :: file:filename(). get_object_code(Mod) when is_atom(Mod) -> call({get_object_code, Mod}). --spec all_loaded() -> [{atom(), loaded_filename()}]. +-spec all_loaded() -> [{Module, Loaded}] when + Module :: module(), + Loaded :: loaded_filename(). all_loaded() -> call(all_loaded). -spec stop() -> no_return(). @@ -188,65 +213,86 @@ root_dir() -> call({dir,root_dir}). lib_dir() -> call({dir,lib_dir}). %% XXX is_list() is for backwards compatibility -- take out in future version --spec lib_dir(App :: atom()) -> file:filename() | {'error', 'bad_name'}. +-spec lib_dir(Name) -> file:filename() | {'error', 'bad_name'} when + Name :: atom(). lib_dir(App) when is_atom(App) ; is_list(App) -> call({dir,{lib_dir,App}}). --spec lib_dir(App :: atom(), SubDir :: atom()) -> file:filename() | {'error', 'bad_name'}. +-spec lib_dir(Name, SubDir) -> file:filename() | {'error', 'bad_name'} when + Name :: atom(), + SubDir :: atom(). lib_dir(App, SubDir) when is_atom(App), is_atom(SubDir) -> call({dir,{lib_dir,App,SubDir}}). -spec compiler_dir() -> file:filename(). compiler_dir() -> call({dir,compiler_dir}). %% XXX is_list() is for backwards compatibility -- take out in future version --spec priv_dir(App :: atom()) -> file:filename() | {'error', 'bad_name'}. +-spec priv_dir(Name) -> file:filename() | {'error', 'bad_name'} when + Name :: atom(). priv_dir(App) when is_atom(App) ; is_list(App) -> call({dir,{priv_dir,App}}). --spec stick_dir(Directory :: file:filename()) -> 'ok' | 'error'. +-spec stick_dir(Dir) -> 'ok' | 'error' when + Dir :: file:filename(). stick_dir(Dir) when is_list(Dir) -> call({stick_dir,Dir}). --spec unstick_dir(Directory :: file:filename()) -> 'ok' | 'error'. +-spec unstick_dir(Dir) -> 'ok' | 'error' when + Dir :: file:filename(). unstick_dir(Dir) when is_list(Dir) -> call({unstick_dir,Dir}). --spec stick_mod(Module :: atom()) -> 'true'. +-spec stick_mod(Module :: module()) -> 'true'. stick_mod(Mod) when is_atom(Mod) -> call({stick_mod,Mod}). --spec unstick_mod(Module :: atom()) -> 'true'. +-spec unstick_mod(Module :: module()) -> 'true'. unstick_mod(Mod) when is_atom(Mod) -> call({unstick_mod,Mod}). --spec is_sticky(Module :: atom()) -> boolean(). +-spec is_sticky(Module) -> boolean() when + Module :: module(). is_sticky(Mod) when is_atom(Mod) -> call({is_sticky,Mod}). --spec set_path(Directories :: [file:filename()]) -> - 'true' | {'error', 'bad_directory' | 'bad_path'}. +-spec set_path(Path) -> 'true' | {'error', What} when + Path :: [Dir :: file:filename()], + What :: 'bad_directory' | 'bad_path'. set_path(PathList) when is_list(PathList) -> call({set_path,PathList}). --spec get_path() -> [file:filename()]. +-spec get_path() -> Path when + Path :: [Dir :: file:filename()]. get_path() -> call(get_path). -type add_path_ret() :: 'true' | {'error', 'bad_directory'}. --spec add_path(Directory :: file:filename()) -> add_path_ret(). +-spec add_path(Dir) -> add_path_ret() when + Dir :: file:filename(). add_path(Dir) when is_list(Dir) -> call({add_path,last,Dir}). --spec add_pathz(Directory :: file:filename()) -> add_path_ret(). +-spec add_pathz(Dir) -> add_path_ret() when + Dir :: file:filename(). add_pathz(Dir) when is_list(Dir) -> call({add_path,last,Dir}). --spec add_patha(Directory :: file:filename()) -> add_path_ret(). +-spec add_patha(Dir) -> add_path_ret() when + Dir :: file:filename(). add_patha(Dir) when is_list(Dir) -> call({add_path,first,Dir}). --spec add_paths(Directories :: [file:filename()]) -> 'ok'. +-spec add_paths(Dirs) -> 'ok' when + Dirs :: [Dir :: file:filename()]. add_paths(Dirs) when is_list(Dirs) -> call({add_paths,last,Dirs}). --spec add_pathsz(Directories :: [file:filename()]) -> 'ok'. +-spec add_pathsz(Dirs) -> 'ok' when + Dirs :: [Dir :: file:filename()]. add_pathsz(Dirs) when is_list(Dirs) -> call({add_paths,last,Dirs}). --spec add_pathsa(Directories :: [file:filename()]) -> 'ok'. +-spec add_pathsa(Dirs) -> 'ok' when + Dirs :: [Dir :: file:filename()]. add_pathsa(Dirs) when is_list(Dirs) -> call({add_paths,first,Dirs}). --spec del_path(Name :: file:filename() | atom()) -> boolean() | {'error', 'bad_name'}. +-spec del_path(NameOrDir) -> boolean() | {'error', What} when + NameOrDir :: Name | Dir, + Name :: atom(), + Dir :: file:filename(), + What :: 'bad_name'. del_path(Name) when is_list(Name) ; is_atom(Name) -> call({del_path,Name}). --type replace_path_error() :: {'error', 'bad_directory' | 'bad_name' | {'badarg',_}}. --spec replace_path(Name:: atom(), Dir :: file:filename()) -> 'true' | replace_path_error(). +-spec replace_path(Name, Dir) -> 'true' | {'error', What} when + Name:: atom(), + Dir :: file:filename(), + What :: 'bad_directory' | 'bad_name' | {'badarg',_}. replace_path(Name, Dir) when (is_atom(Name) orelse is_list(Name)), (is_atom(Dir) orelse is_list(Dir)) -> call({replace_path,Name,Dir}). @@ -351,10 +397,9 @@ get_mode(Flags) -> %% In that case return the name of the file which contains %% the loaded object code --type which_ret_atoms() :: loaded_ret_atoms() | 'non_existing'. - --spec which(Module :: atom()) -> file:filename() | which_ret_atoms(). - +-spec which(Module) -> Which when + Module :: module(), + Which :: file:filename() | loaded_ret_atoms() | non_existing. which(Module) when is_atom(Module) -> case is_loaded(Module) of false -> @@ -394,9 +439,9 @@ which(File, Base, [Directory|Tail]) -> %% Search the code path for a specific file. Try to locate %% it in the code path cache if possible. --spec where_is_file(Filename :: file:filename()) -> - 'non_existing' | file:filename(). - +-spec where_is_file(Filename) -> non_existing | Absname when + Filename :: file:filename(), + Absname :: file:filename(). where_is_file(File) when is_list(File) -> case call({is_cached,File}) of no -> diff --git a/lib/kernel/src/file.erl b/lib/kernel/src/file.erl index f1a8aa9f77..5e4e1b0ba8 100644 --- a/lib/kernel/src/file.erl +++ b/lib/kernel/src/file.erl @@ -100,15 +100,7 @@ | 'enotblk' | 'enotdir' | 'enotsup' | 'enxio' | 'eperm' | 'epipe' | 'erofs' | 'espipe' | 'esrch' | 'estale' | 'exdev'. --type bindings() :: erl_eval:binding_struct(). - --type date() :: {Year :: pos_integer(), - Month :: pos_integer(), - Day ::pos_integer()}. --type time() :: {Hour :: non_neg_integer(), - Minute :: non_neg_integer(), - Second :: non_neg_integer()}. --type date_time() :: {date(), time()}. +-type date_time() :: calendar:datetime(). -type posix_file_advise() :: 'normal' | 'sequential' | 'random' | 'no_reuse' | 'will_need' | 'dont_need'. @@ -920,7 +912,7 @@ eval(File) -> -spec eval(Filename, Bindings) -> ok | {error, Reason} when Filename :: name(), - Bindings :: bindings(), + Bindings :: erl_eval:binding_struct(), Reason :: posix() | badarg | terminated | system_limit | {Line :: integer(), Mod :: module(), Term :: term()}. @@ -948,7 +940,7 @@ path_eval(Path, File) -> {ok, FullName} | {error, Reason} when Path :: [Dir :: name()], Filename :: name(), - Bindings :: bindings(), + Bindings :: erl_eval:binding_struct(), FullName :: filename(), Reason :: posix() | badarg | terminated | system_limit | {Line :: integer(), Mod :: module(), Term :: term()}. @@ -979,7 +971,7 @@ script(File) -> -spec script(Filename, Bindings) -> {ok, Value} | {error, Reason} when Filename :: name(), - Bindings :: bindings(), + Bindings :: erl_eval:binding_struct(), Value :: term(), Reason :: posix() | badarg | terminated | system_limit | {Line :: integer(), Mod :: module(), Term :: term()}. @@ -1010,7 +1002,7 @@ path_script(Path, File) -> {ok, Value, FullName} | {error, Reason} when Path :: [Dir :: name()], Filename :: name(), - Bindings :: bindings(), + Bindings :: erl_eval:binding_struct(), Value :: term(), FullName :: filename(), Reason :: posix() | badarg | terminated | system_limit diff --git a/lib/kernel/src/inet_config.erl b/lib/kernel/src/inet_config.erl index 2458876326..1ddbdcec25 100644 --- a/lib/kernel/src/inet_config.erl +++ b/lib/kernel/src/inet_config.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 1997-2010. All Rights Reserved. +%% Copyright Ericsson AB 1997-2011. All Rights Reserved. %% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in @@ -44,26 +44,6 @@ %% -spec init() -> 'ok'. init() -> - OsType = os:type(), - case OsType of - {ose,_} -> - case init:get_argument(loader) of - {ok,[["ose_inet"]]} -> - %% port already started by prim_loader - ok; - _Other -> - %% Setup reserved port for ose_inet driver (only OSE) - case catch erlang:open_port({spawn,"ose_inet"}, [binary]) of - {'EXIT',Why} -> - error("can't open port for ose_inet: ~p", [Why]); - OseInetPort -> - erlang:display({ose_inet_port,OseInetPort}) - end - end; - _ -> - ok - end, - set_hostname(), %% Note: In shortnames (or non-distributed) mode we don't need to know @@ -71,6 +51,7 @@ init() -> %% the user to provide it (by means of inetrc), so we need to look %% for it ourselves. + OsType = os:type(), do_load_resolv(OsType, erl_dist_mode()), case OsType of @@ -226,35 +207,6 @@ do_load_resolv(vxworks, _) -> load_resolv(Resolv, resolv) end; -do_load_resolv({ose,_Type}, _) -> - inet_db:set_lookup([file, dns]), - case os:getenv("NAMESERVER") of - false -> - case os:getenv("RESOLVFILE") of - false -> - erlang:display('Warning: No NAMESERVER or RESOLVFILE specified!'), - no_resolv; - Resolv -> - load_resolv(Resolv, resolv) - end; - Ns -> - {ok,IP} = inet_parse:address(Ns), - inet_db:add_rc_list([{nameserver,IP}]) - end, - case os:getenv("DOMAIN") of - false -> - no_domain; - D -> - ok = inet_db:add_rc_list([{domain,D}]) - end, - case os:getenv("HOSTSFILE") of - false -> - erlang:display('Warning: No HOSTSFILE specified!'), - no_hosts_file; - File -> - load_hosts(File, ose) - end; - do_load_resolv(_, _) -> inet_db:set_lookup([native]). diff --git a/lib/kernel/src/rpc.erl b/lib/kernel/src/rpc.erl index be35f99ed2..e214ffa404 100644 --- a/lib/kernel/src/rpc.erl +++ b/lib/kernel/src/rpc.erl @@ -662,9 +662,10 @@ async_call(Node, Mod, Fun, Args) -> ReplyTo ! {self(), {promise_reply, R}} %% self() is key end). --spec yield(Key) -> {value, Val} | timeout when +-spec yield(Key) -> Res | {badrpc, Reason} when Key :: key(), - Val :: (Res :: term()) | {badrpc, Reason :: term()}. + Res :: term(), + Reason :: term(). yield(Key) when is_pid(Key) -> {value,R} = do_yield(Key, infinity), diff --git a/lib/stdlib/doc/src/calendar.xml b/lib/stdlib/doc/src/calendar.xml index 4876b37127..f8db48e00c 100644 --- a/lib/stdlib/doc/src/calendar.xml +++ b/lib/stdlib/doc/src/calendar.xml @@ -75,13 +75,13 @@ - + - + - + @@ -100,7 +100,7 @@ - + @@ -118,12 +118,7 @@ - -

See erlang:now/0.

- - - - + diff --git a/lib/stdlib/doc/src/io.xml b/lib/stdlib/doc/src/io.xml index af9c75d546..667d758e29 100644 --- a/lib/stdlib/doc/src/io.xml +++ b/lib/stdlib/doc/src/io.xml @@ -439,7 +439,7 @@ ok

Prints the argument with the string syntax. The argument is, if no Unicode translation modifier is present, an - I/O list, a binary, or an atom. If the Unicode translation modifier ('t') is in effect, the argument is unicode:chardata(), meaning that binaries are in UTF-8. The characters + iolist(), a binary, or an atom. If the Unicode translation modifier ('t') is in effect, the argument is unicode:chardata(), meaning that binaries are in UTF-8. The characters are printed without quotes. The string is first truncated by the given precision and then padded and justified to the given field width. The default precision is the field width.

diff --git a/lib/stdlib/src/calendar.erl b/lib/stdlib/src/calendar.erl index 8d1071209e..0320e0cd0e 100644 --- a/lib/stdlib/src/calendar.erl +++ b/lib/stdlib/src/calendar.erl @@ -63,7 +63,7 @@ %% Types %%---------------------------------------------------------------------- --export_type([t_now/0]). +-export_type([date/0, time/0, datetime/0, datetime1970/0]). -type year() :: non_neg_integer(). -type year1970() :: 1970..10000. % should probably be 1970.. @@ -76,15 +76,11 @@ -type ldom() :: 28 | 29 | 30 | 31. % last day of month -type weeknum() :: 1..53. --type t_now() :: {MegaSecs :: non_neg_integer(), - Secs :: non_neg_integer(), - MicroSecs :: non_neg_integer()}. - --type t_date() :: {year(),month(),day()}. --type t_time() :: {hour(),minute(),second()}. --type t_datetime() :: {t_date(),t_time()}. --type t_datetime1970() :: {{year1970(),month(),day()},t_time()}. --type t_yearweeknum() :: {year(),weeknum()}. +-type date() :: {year(),month(),day()}. +-type time() :: {hour(),minute(),second()}. +-type datetime() :: {date(),time()}. +-type datetime1970() :: {{year1970(),month(),day()},time()}. +-type yearweeknum() :: {year(),weeknum()}. %%---------------------------------------------------------------------- @@ -123,7 +119,7 @@ date_to_gregorian_days(Year, Month, Day) when is_integer(Day), Day > 0 -> end. -spec date_to_gregorian_days(Date) -> Days when - Date :: t_date(), + Date :: date(), Days :: non_neg_integer(). date_to_gregorian_days({Year, Month, Day}) -> date_to_gregorian_days(Year, Month, Day). @@ -135,7 +131,7 @@ date_to_gregorian_days({Year, Month, Day}) -> %% January 1st. %% -spec datetime_to_gregorian_seconds(DateTime) -> Seconds when - DateTime :: t_datetime(), + DateTime :: datetime(), Seconds :: non_neg_integer(). datetime_to_gregorian_seconds({Date, Time}) -> ?SECONDS_PER_DAY*date_to_gregorian_days(Date) + @@ -155,14 +151,14 @@ day_of_the_week(Year, Month, Day) -> (date_to_gregorian_days(Year, Month, Day) + 5) rem 7 + 1. -spec day_of_the_week(Date) -> daynum() when - Date:: t_date(). + Date:: date(). day_of_the_week({Year, Month, Day}) -> day_of_the_week(Year, Month, Day). %% gregorian_days_to_date(Days) = {Year, Month, Day} %% --spec gregorian_days_to_date(Days) -> t_date() when +-spec gregorian_days_to_date(Days) -> date() when Days :: non_neg_integer(). gregorian_days_to_date(Days) -> {Year, DayOfYear} = day_to_year(Days), @@ -172,7 +168,7 @@ gregorian_days_to_date(Days) -> %% gregorian_seconds_to_datetime(Secs) %% --spec gregorian_seconds_to_datetime(Seconds) -> t_datetime() when +-spec gregorian_seconds_to_datetime(Seconds) -> datetime() when Seconds :: non_neg_integer(). gregorian_seconds_to_datetime(Secs) when Secs >= 0 -> Days = Secs div ?SECONDS_PER_DAY, @@ -198,7 +194,7 @@ is_leap_year1(_) -> false. %% %% Calculates the iso week number for the current date. %% --spec iso_week_number() -> t_yearweeknum(). +-spec iso_week_number() -> yearweeknum(). iso_week_number() -> {Date, _} = local_time(), iso_week_number(Date). @@ -207,8 +203,8 @@ iso_week_number() -> %% %% Calculates the iso week number for the given date. %% --spec iso_week_number(Date) -> t_yearweeknum() when - Date :: t_date(). +-spec iso_week_number(Date) -> yearweeknum() when + Date :: date(). iso_week_number({Year, Month, Day}) -> D = date_to_gregorian_days({Year, Month, Day}), W01_1_Year = gregorian_days_of_iso_w01_1(Year), @@ -260,7 +256,7 @@ last_day_of_the_month1(_, M) when is_integer(M), M > 0, M < 13 -> %% local_time() %% %% Returns: {date(), time()}, date() = {Y, M, D}, time() = {H, M, S}. --spec local_time() -> t_datetime(). +-spec local_time() -> datetime(). local_time() -> erlang:localtime(). @@ -268,20 +264,20 @@ local_time() -> %% local_time_to_universal_time(DateTime) %% -spec local_time_to_universal_time(DateTime1) -> DateTime2 when - DateTime1 :: t_datetime1970(), - DateTime2 :: t_datetime1970(). + DateTime1 :: datetime1970(), + DateTime2 :: datetime1970(). local_time_to_universal_time(DateTime) -> erlang:localtime_to_universaltime(DateTime). --spec local_time_to_universal_time(t_datetime1970(), +-spec local_time_to_universal_time(datetime1970(), 'true' | 'false' | 'undefined') -> - t_datetime1970(). + datetime1970(). local_time_to_universal_time(DateTime, IsDst) -> erlang:localtime_to_universaltime(DateTime, IsDst). -spec local_time_to_universal_time_dst(DateTime1) -> [DateTime] when - DateTime1 :: t_datetime1970(), - DateTime :: t_datetime1970(). + DateTime1 :: datetime1970(), + DateTime :: datetime1970(). local_time_to_universal_time_dst(DateTime) -> UtDst = erlang:localtime_to_universaltime(DateTime, true), Ut = erlang:localtime_to_universaltime(DateTime, false), @@ -309,14 +305,14 @@ local_time_to_universal_time_dst(DateTime) -> %% = MilliSec = integer() %% Returns: {date(), time()}, date() = {Y, M, D}, time() = {H, M, S}. %% --spec now_to_datetime(Now) -> t_datetime1970() when - Now :: t_now(). +-spec now_to_datetime(Now) -> datetime1970() when + Now :: erlang:timestamp(). now_to_datetime({MSec, Sec, _uSec}) -> Sec0 = MSec*1000000 + Sec + ?DAYS_FROM_0_TO_1970*?SECONDS_PER_DAY, gregorian_seconds_to_datetime(Sec0). --spec now_to_universal_time(Now) -> t_datetime1970() when - Now :: t_now(). +-spec now_to_universal_time(Now) -> datetime1970() when + Now :: erlang:timestamp(). now_to_universal_time(Now) -> now_to_datetime(Now). @@ -325,8 +321,8 @@ now_to_universal_time(Now) -> %% %% Args: Now = now() %% --spec now_to_local_time(Now) -> t_datetime1970() when - Now :: t_now(). +-spec now_to_local_time(Now) -> datetime1970() when + Now :: erlang:timestamp(). now_to_local_time({MSec, Sec, _uSec}) -> erlang:universaltime_to_localtime( now_to_universal_time({MSec, Sec, _uSec})). @@ -338,7 +334,7 @@ now_to_local_time({MSec, Sec, _uSec}) -> -spec seconds_to_daystime(Seconds) -> {Days, Time} when Seconds :: integer(), Days :: integer(), - Time :: t_time(). + Time :: time(). seconds_to_daystime(Secs) -> Days0 = Secs div ?SECONDS_PER_DAY, Secs0 = Secs rem ?SECONDS_PER_DAY, @@ -356,7 +352,7 @@ seconds_to_daystime(Secs) -> %% Wraps. %% -type secs_per_day() :: 0..?SECONDS_PER_DAY. --spec seconds_to_time(Seconds) -> t_time() when +-spec seconds_to_time(Seconds) -> time() when Seconds :: secs_per_day(). seconds_to_time(Secs) when Secs >= 0, Secs < ?SECONDS_PER_DAY -> Secs0 = Secs rem ?SECONDS_PER_DAY, @@ -375,10 +371,10 @@ seconds_to_time(Secs) when Secs >= 0, Secs < ?SECONDS_PER_DAY -> %% Year = Month = Day = Hour = Minute = Sec = integer() %% -spec time_difference(T1, T2) -> {Days, Time} when - T1 :: t_datetime(), - T2 :: t_datetime(), + T1 :: datetime(), + T2 :: datetime(), Days :: integer(), - Time :: t_time(). + Time :: time(). time_difference({{Y1, Mo1, D1}, {H1, Mi1, S1}}, {{Y2, Mo2, D2}, {H2, Mi2, S2}}) -> Secs = datetime_to_gregorian_seconds({{Y2, Mo2, D2}, {H2, Mi2, S2}}) - @@ -390,7 +386,7 @@ time_difference({{Y1, Mo1, D1}, {H1, Mi1, S1}}, %% time_to_seconds(Time) %% -spec time_to_seconds(Time) -> secs_per_day() when - Time :: t_time(). + Time :: time(). time_to_seconds({H, M, S}) when is_integer(H), is_integer(M), is_integer(S) -> H * ?SECONDS_PER_HOUR + M * ?SECONDS_PER_MINUTE + S. @@ -399,15 +395,15 @@ time_to_seconds({H, M, S}) when is_integer(H), is_integer(M), is_integer(S) -> %% universal_time() %% %% Returns: {date(), time()}, date() = {Y, M, D}, time() = {H, M, S}. --spec universal_time() -> t_datetime(). +-spec universal_time() -> datetime(). universal_time() -> erlang:universaltime(). %% universal_time_to_local_time(DateTime) %% --spec universal_time_to_local_time(DateTime) -> t_datetime() when - DateTime :: t_datetime1970(). +-spec universal_time_to_local_time(DateTime) -> datetime() when + DateTime :: datetime1970(). universal_time_to_local_time(DateTime) -> erlang:universaltime_to_localtime(DateTime). @@ -429,7 +425,7 @@ valid_date1(_, _, _) -> false. -spec valid_date(Date) -> boolean() when - Date :: t_date(). + Date :: date(). valid_date({Y, M, D}) -> valid_date(Y, M, D). diff --git a/lib/stdlib/src/timer.erl b/lib/stdlib/src/timer.erl index 89fae05e4f..e3d6c905b6 100644 --- a/lib/stdlib/src/timer.erl +++ b/lib/stdlib/src/timer.erl @@ -200,8 +200,8 @@ tc(M, F, A) -> %% erlang:now() timestamps, T2-T1. %% -spec now_diff(T1, T2) -> Tdiff when - T1 :: calendar:t_now(), - T2 :: calendar:t_now(), + T1 :: erlang:timestamp(), + T2 :: erlang:timestamp(), Tdiff :: integer(). now_diff({A2, B2, C2}, {A1, B1, C1}) -> ((A2-A1)*1000000 + B2-B1)*1000000 + C2-C1. -- cgit v1.2.3