diff options
author | viettrungluu@chromium.org <viettrungluu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-05-27 21:35:55 +0000 |
---|---|---|
committer | viettrungluu@chromium.org <viettrungluu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-05-27 21:35:55 +0000 |
commit | a1de80b458b830aed9b70f2d124bcb3e53fbb6bd (patch) | |
tree | 90cfdfde021ab0f531c913143c8a74b744e3ab06 /mojo | |
parent | 8f802b2596f69ecd68ac6496da0e4b661183a777 (diff) | |
download | chromium_src-a1de80b458b830aed9b70f2d124bcb3e53fbb6bd.zip chromium_src-a1de80b458b830aed9b70f2d124bcb3e53fbb6bd.tar.gz chromium_src-a1de80b458b830aed9b70f2d124bcb3e53fbb6bd.tar.bz2 |
Mojo: Move common/basic functions declarations from mojo/public/c/system/core.h to .../functions.h.
R=sky@chromium.org
Review URL: https://codereview.chromium.org/293383007
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@273042 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'mojo')
-rw-r--r-- | mojo/mojo_public.gypi | 1 | ||||
-rw-r--r-- | mojo/public/c/system/core.h | 68 | ||||
-rw-r--r-- | mojo/public/c/system/functions.h | 87 | ||||
-rw-r--r-- | mojo/public/c/system/types.h | 6 |
4 files changed, 95 insertions, 67 deletions
diff --git a/mojo/mojo_public.gypi b/mojo/mojo_public.gypi index 1ccc5240..166d8da 100644 --- a/mojo/mojo_public.gypi +++ b/mojo/mojo_public.gypi @@ -27,6 +27,7 @@ }, 'sources': [ 'public/c/system/core.h', + 'public/c/system/functions.h', 'public/c/system/macros.h', 'public/c/system/system_export.h', 'public/c/system/types.h', diff --git a/mojo/public/c/system/core.h b/mojo/public/c/system/core.h index 97afd70..199d918 100644 --- a/mojo/public/c/system/core.h +++ b/mojo/public/c/system/core.h @@ -2,13 +2,14 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +// Note: This header should be compilable as C. + #ifndef MOJO_PUBLIC_C_SYSTEM_CORE_H_ #define MOJO_PUBLIC_C_SYSTEM_CORE_H_ -// Note: This header should be compilable as C. - #include <stdint.h> +#include "mojo/public/c/system/functions.h" #include "mojo/public/c/system/macros.h" #include "mojo/public/c/system/system_export.h" #include "mojo/public/c/system/types.h" @@ -206,72 +207,13 @@ const MojoMapBufferFlags MOJO_MAP_BUFFER_FLAG_NONE = 0; // Functions ------------------------------------------------------------------- -// Note: Pointer parameters that are labeled "optional" may be null (at least -// under some circumstances). Non-const pointer parameters are also labelled -// "in", "out", or "in/out", to indicate how they are used. (Note that how/if -// such a parameter is used may depend on other parameters or the requested -// operation's success/failure. E.g., a separate |flags| parameter may control -// whether a given "in/out" parameter is used for input, output, or both.) +// Note: See the comment in functions.h about the meaning of the "optional" +// label for pointer parameters. #ifdef __cplusplus extern "C" { #endif -// Platform-dependent monotonically increasing tick count representing "right -// now." The resolution of this clock is ~1-15ms. Resolution varies depending -// on hardware/operating system configuration. -MOJO_SYSTEM_EXPORT MojoTimeTicks MojoGetTimeTicksNow(); - -// Closes the given |handle|. -// -// Returns: -// |MOJO_RESULT_OK| on success. -// |MOJO_RESULT_INVALID_ARGUMENT| if |handle| is not a valid handle. -// -// Concurrent operations on |handle| may succeed (or fail as usual) if they -// happen before the close, be cancelled with result |MOJO_RESULT_CANCELLED| if -// they properly overlap (this is likely the case with |MojoWait()|, etc.), or -// fail with |MOJO_RESULT_INVALID_ARGUMENT| if they happen after. -MOJO_SYSTEM_EXPORT MojoResult MojoClose(MojoHandle handle); - -// Waits on the given handle until the state indicated by |flags| is satisfied -// or until |deadline| has passed. -// -// Returns: -// |MOJO_RESULT_OK| if some flag in |flags| was satisfied (or is already -// satisfied). -// |MOJO_RESULT_INVALID_ARGUMENT| if |handle| is not a valid handle (e.g., if -// it has already been closed). -// |MOJO_RESULT_DEADLINE_EXCEEDED| if the deadline has passed without any of -// the flags being satisfied. -// |MOJO_RESULT_FAILED_PRECONDITION| if it is or becomes impossible that any -// flag in |flags| will ever be satisfied. -// -// If there are multiple waiters (on different threads, obviously) waiting on -// the same handle and flag and that flag becomes set, all waiters will be -// awoken. -MOJO_SYSTEM_EXPORT MojoResult MojoWait(MojoHandle handle, - MojoWaitFlags flags, - MojoDeadline deadline); - -// Waits on |handles[0]|, ..., |handles[num_handles-1]| for at least one of them -// to satisfy the state indicated by |flags[0]|, ..., |flags[num_handles-1]|, -// respectively, or until |deadline| has passed. -// -// Returns: -// The index |i| (from 0 to |num_handles-1|) if |handle[i]| satisfies -// |flags[i]|. -// |MOJO_RESULT_INVALID_ARGUMENT| if some |handle[i]| is not a valid handle -// (e.g., if it has already been closed). -// |MOJO_RESULT_DEADLINE_EXCEEDED| if the deadline has passed without any of -// handles satisfying any of its flags. -// |MOJO_RESULT_FAILED_PRECONDITION| if it is or becomes impossible that SOME -// |handle[i]| will ever satisfy any of its flags |flags[i]|. -MOJO_SYSTEM_EXPORT MojoResult MojoWaitMany(const MojoHandle* handles, - const MojoWaitFlags* flags, - uint32_t num_handles, - MojoDeadline deadline); - // Message pipe: // Creates a message pipe, which is a bidirectional communication channel for diff --git a/mojo/public/c/system/functions.h b/mojo/public/c/system/functions.h new file mode 100644 index 0000000..fa2bd06 --- /dev/null +++ b/mojo/public/c/system/functions.h @@ -0,0 +1,87 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// This file contains basic functions common to different Mojo system APIs. +// +// Note: This header should be compilable as C. + +#ifndef MOJO_PUBLIC_C_SYSTEM_FUNCTIONS_H_ +#define MOJO_PUBLIC_C_SYSTEM_FUNCTIONS_H_ + +// Note: This header should be compilable as C. + +#include "mojo/public/c/system/system_export.h" +#include "mojo/public/c/system/types.h" + +// Note: Pointer parameters that are labelled "optional" may be null (at least +// under some circumstances). Non-const pointer parameters are also labeled +// "in", "out", or "in/out", to indicate how they are used. (Note that how/if +// such a parameter is used may depend on other parameters or the requested +// operation's success/failure. E.g., a separate |flags| parameter may control +// whether a given "in/out" parameter is used for input, output, or both.) + +#ifdef __cplusplus +extern "C" { +#endif + +// Platform-dependent monotonically increasing tick count representing "right +// now." The resolution of this clock is ~1-15ms. Resolution varies depending +// on hardware/operating system configuration. +MOJO_SYSTEM_EXPORT MojoTimeTicks MojoGetTimeTicksNow(); + +// Closes the given |handle|. +// +// Returns: +// |MOJO_RESULT_OK| on success. +// |MOJO_RESULT_INVALID_ARGUMENT| if |handle| is not a valid handle. +// +// Concurrent operations on |handle| may succeed (or fail as usual) if they +// happen before the close, be cancelled with result |MOJO_RESULT_CANCELLED| if +// they properly overlap (this is likely the case with |MojoWait()|, etc.), or +// fail with |MOJO_RESULT_INVALID_ARGUMENT| if they happen after. +MOJO_SYSTEM_EXPORT MojoResult MojoClose(MojoHandle handle); + +// Waits on the given handle until the state indicated by |flags| is satisfied +// or until |deadline| has passed. +// +// Returns: +// |MOJO_RESULT_OK| if some flag in |flags| was satisfied (or is already +// satisfied). +// |MOJO_RESULT_INVALID_ARGUMENT| if |handle| is not a valid handle (e.g., if +// it has already been closed). +// |MOJO_RESULT_DEADLINE_EXCEEDED| if the deadline has passed without any of +// the flags being satisfied. +// |MOJO_RESULT_FAILED_PRECONDITION| if it is or becomes impossible that any +// flag in |flags| will ever be satisfied. +// +// If there are multiple waiters (on different threads, obviously) waiting on +// the same handle and flag and that flag becomes set, all waiters will be +// awoken. +MOJO_SYSTEM_EXPORT MojoResult MojoWait(MojoHandle handle, + MojoWaitFlags flags, + MojoDeadline deadline); + +// Waits on |handles[0]|, ..., |handles[num_handles-1]| for at least one of them +// to satisfy the state indicated by |flags[0]|, ..., |flags[num_handles-1]|, +// respectively, or until |deadline| has passed. +// +// Returns: +// The index |i| (from 0 to |num_handles-1|) if |handle[i]| satisfies +// |flags[i]|. +// |MOJO_RESULT_INVALID_ARGUMENT| if some |handle[i]| is not a valid handle +// (e.g., if it has already been closed). +// |MOJO_RESULT_DEADLINE_EXCEEDED| if the deadline has passed without any of +// handles satisfying any of its flags. +// |MOJO_RESULT_FAILED_PRECONDITION| if it is or becomes impossible that SOME +// |handle[i]| will ever satisfy any of its flags |flags[i]|. +MOJO_SYSTEM_EXPORT MojoResult MojoWaitMany(const MojoHandle* handles, + const MojoWaitFlags* flags, + uint32_t num_handles, + MojoDeadline deadline); + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // MOJO_PUBLIC_C_SYSTEM_FUNCTIONS_H_ diff --git a/mojo/public/c/system/types.h b/mojo/public/c/system/types.h index 03b2c6b..da4577a 100644 --- a/mojo/public/c/system/types.h +++ b/mojo/public/c/system/types.h @@ -4,16 +4,14 @@ // This file contains types and constants/macros common to different Mojo system // APIs. +// +// Note: This header should be compilable as C. #ifndef MOJO_PUBLIC_C_SYSTEM_TYPES_H_ #define MOJO_PUBLIC_C_SYSTEM_TYPES_H_ -// Note: This header should be compilable as C. - #include <stdint.h> -// Types/constants ------------------------------------------------------------- - // TODO(vtl): Notes: Use of undefined flags will lead to undefined behavior // (typically they'll be ignored), not necessarily an error. |