OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // This file contains types and constants/macros common to different Mojo system | 5 // This file contains types and constants/macros common to different Mojo system |
6 // APIs. | 6 // APIs. |
7 // | 7 // |
8 // Note: This header should be compilable as C. | 8 // Note: This header should be compilable as C. |
9 | 9 |
10 #ifndef MOJO_PUBLIC_C_SYSTEM_TYPES_H_ | 10 #ifndef MOJO_PUBLIC_C_SYSTEM_TYPES_H_ |
(...skipping 11 matching lines...) Expand all Loading... |
22 typedef int64_t MojoTimeTicks; | 22 typedef int64_t MojoTimeTicks; |
23 | 23 |
24 // |MojoHandle|: Handles to Mojo objects. | 24 // |MojoHandle|: Handles to Mojo objects. |
25 // |MOJO_HANDLE_INVALID| - A value that is never a valid handle. | 25 // |MOJO_HANDLE_INVALID| - A value that is never a valid handle. |
26 | 26 |
27 typedef uint32_t MojoHandle; | 27 typedef uint32_t MojoHandle; |
28 | 28 |
29 #ifdef __cplusplus | 29 #ifdef __cplusplus |
30 const MojoHandle MOJO_HANDLE_INVALID = 0; | 30 const MojoHandle MOJO_HANDLE_INVALID = 0; |
31 #else | 31 #else |
32 #define MOJO_HANDLE_INVALID ((MojoHandle) 0) | 32 #define MOJO_HANDLE_INVALID ((MojoHandle)0) |
33 #endif | 33 #endif |
34 | 34 |
35 // |MojoResult|: Result codes for Mojo operations. Non-negative values are | 35 // |MojoResult|: Result codes for Mojo operations. Non-negative values are |
36 // success codes; negative values are error/failure codes. | 36 // success codes; negative values are error/failure codes. |
37 // |MOJO_RESULT_OK| - Not an error; returned on success. Note that positive | 37 // |MOJO_RESULT_OK| - Not an error; returned on success. Note that positive |
38 // |MojoResult|s may also be used to indicate success. | 38 // |MojoResult|s may also be used to indicate success. |
39 // |MOJO_RESULT_CANCELLED| - Operation was cancelled, typically by the caller. | 39 // |MOJO_RESULT_CANCELLED| - Operation was cancelled, typically by the caller. |
40 // |MOJO_RESULT_UNKNOWN| - Unknown error (e.g., if not enough information is | 40 // |MOJO_RESULT_UNKNOWN| - Unknown error (e.g., if not enough information is |
41 // available for a more specific error). | 41 // available for a more specific error). |
42 // |MOJO_RESULT_INVALID_ARGUMENT| - Caller specified an invalid argument. This | 42 // |MOJO_RESULT_INVALID_ARGUMENT| - Caller specified an invalid argument. This |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 const MojoResult MOJO_RESULT_FAILED_PRECONDITION = -9; | 103 const MojoResult MOJO_RESULT_FAILED_PRECONDITION = -9; |
104 const MojoResult MOJO_RESULT_ABORTED = -10; | 104 const MojoResult MOJO_RESULT_ABORTED = -10; |
105 const MojoResult MOJO_RESULT_OUT_OF_RANGE = -11; | 105 const MojoResult MOJO_RESULT_OUT_OF_RANGE = -11; |
106 const MojoResult MOJO_RESULT_UNIMPLEMENTED = -12; | 106 const MojoResult MOJO_RESULT_UNIMPLEMENTED = -12; |
107 const MojoResult MOJO_RESULT_INTERNAL = -13; | 107 const MojoResult MOJO_RESULT_INTERNAL = -13; |
108 const MojoResult MOJO_RESULT_UNAVAILABLE = -14; | 108 const MojoResult MOJO_RESULT_UNAVAILABLE = -14; |
109 const MojoResult MOJO_RESULT_DATA_LOSS = -15; | 109 const MojoResult MOJO_RESULT_DATA_LOSS = -15; |
110 const MojoResult MOJO_RESULT_BUSY = -16; | 110 const MojoResult MOJO_RESULT_BUSY = -16; |
111 const MojoResult MOJO_RESULT_SHOULD_WAIT = -17; | 111 const MojoResult MOJO_RESULT_SHOULD_WAIT = -17; |
112 #else | 112 #else |
113 #define MOJO_RESULT_OK ((MojoResult) 0) | 113 #define MOJO_RESULT_OK ((MojoResult)0) |
114 #define MOJO_RESULT_CANCELLED ((MojoResult) -1) | 114 #define MOJO_RESULT_CANCELLED ((MojoResult) - 1) |
115 #define MOJO_RESULT_UNKNOWN ((MojoResult) -2) | 115 #define MOJO_RESULT_UNKNOWN ((MojoResult) - 2) |
116 #define MOJO_RESULT_INVALID_ARGUMENT ((MojoResult) -3) | 116 #define MOJO_RESULT_INVALID_ARGUMENT ((MojoResult) - 3) |
117 #define MOJO_RESULT_DEADLINE_EXCEEDED ((MojoResult) -4) | 117 #define MOJO_RESULT_DEADLINE_EXCEEDED ((MojoResult) - 4) |
118 #define MOJO_RESULT_NOT_FOUND ((MojoResult) -5) | 118 #define MOJO_RESULT_NOT_FOUND ((MojoResult) - 5) |
119 #define MOJO_RESULT_ALREADY_EXISTS ((MojoResult) -6) | 119 #define MOJO_RESULT_ALREADY_EXISTS ((MojoResult) - 6) |
120 #define MOJO_RESULT_PERMISSION_DENIED ((MojoResult) -7) | 120 #define MOJO_RESULT_PERMISSION_DENIED ((MojoResult) - 7) |
121 #define MOJO_RESULT_RESOURCE_EXHAUSTED ((MojoResult) -8) | 121 #define MOJO_RESULT_RESOURCE_EXHAUSTED ((MojoResult) - 8) |
122 #define MOJO_RESULT_FAILED_PRECONDITION ((MojoResult) -9) | 122 #define MOJO_RESULT_FAILED_PRECONDITION ((MojoResult) - 9) |
123 #define MOJO_RESULT_ABORTED ((MojoResult) -10) | 123 #define MOJO_RESULT_ABORTED ((MojoResult) - 10) |
124 #define MOJO_RESULT_OUT_OF_RANGE ((MojoResult) -11) | 124 #define MOJO_RESULT_OUT_OF_RANGE ((MojoResult) - 11) |
125 #define MOJO_RESULT_UNIMPLEMENTED ((MojoResult) -12) | 125 #define MOJO_RESULT_UNIMPLEMENTED ((MojoResult) - 12) |
126 #define MOJO_RESULT_INTERNAL ((MojoResult) -13) | 126 #define MOJO_RESULT_INTERNAL ((MojoResult) - 13) |
127 #define MOJO_RESULT_UNAVAILABLE ((MojoResult) -14) | 127 #define MOJO_RESULT_UNAVAILABLE ((MojoResult) - 14) |
128 #define MOJO_RESULT_DATA_LOSS ((MojoResult) -15) | 128 #define MOJO_RESULT_DATA_LOSS ((MojoResult) - 15) |
129 #define MOJO_RESULT_BUSY ((MojoResult) -16) | 129 #define MOJO_RESULT_BUSY ((MojoResult) - 16) |
130 #define MOJO_RESULT_SHOULD_WAIT ((MojoResult) -17) | 130 #define MOJO_RESULT_SHOULD_WAIT ((MojoResult) - 17) |
131 #endif | 131 #endif |
132 | 132 |
133 // |MojoDeadline|: Used to specify deadlines (timeouts), in microseconds (except | 133 // |MojoDeadline|: Used to specify deadlines (timeouts), in microseconds (except |
134 // for |MOJO_DEADLINE_INDEFINITE|). | 134 // for |MOJO_DEADLINE_INDEFINITE|). |
135 // |MOJO_DEADLINE_INDEFINITE| - Used to indicate "forever". | 135 // |MOJO_DEADLINE_INDEFINITE| - Used to indicate "forever". |
136 | 136 |
137 typedef uint64_t MojoDeadline; | 137 typedef uint64_t MojoDeadline; |
138 | 138 |
139 #ifdef __cplusplus | 139 #ifdef __cplusplus |
140 const MojoDeadline MOJO_DEADLINE_INDEFINITE = static_cast<MojoDeadline>(-1); | 140 const MojoDeadline MOJO_DEADLINE_INDEFINITE = static_cast<MojoDeadline>(-1); |
141 #else | 141 #else |
142 #define MOJO_DEADLINE_INDEFINITE ((MojoDeadline) -1) | 142 #define MOJO_DEADLINE_INDEFINITE ((MojoDeadline) - 1) |
143 #endif | 143 #endif |
144 | 144 |
145 // |MojoHandleSignals|: Used to specify signals that can be waited on for a | 145 // |MojoHandleSignals|: Used to specify signals that can be waited on for a |
146 // handle (and which can be triggered), e.g., the ability to read or write to | 146 // handle (and which can be triggered), e.g., the ability to read or write to |
147 // the handle. | 147 // the handle. |
148 // |MOJO_HANDLE_SIGNAL_NONE| - No flags. |MojoWait()|, etc. will return | 148 // |MOJO_HANDLE_SIGNAL_NONE| - No flags. |MojoWait()|, etc. will return |
149 // |MOJO_RESULT_FAILED_PRECONDITION| if you attempt to wait on this. | 149 // |MOJO_RESULT_FAILED_PRECONDITION| if you attempt to wait on this. |
150 // |MOJO_HANDLE_SIGNAL_READABLE| - Can read (e.g., a message) from the handle. | 150 // |MOJO_HANDLE_SIGNAL_READABLE| - Can read (e.g., a message) from the handle. |
151 // |MOJO_HANDLE_SIGNAL_WRITABLE| - Can write (e.g., a message) to the handle. | 151 // |MOJO_HANDLE_SIGNAL_WRITABLE| - Can write (e.g., a message) to the handle. |
152 | 152 |
153 typedef uint32_t MojoHandleSignals; | 153 typedef uint32_t MojoHandleSignals; |
154 | 154 |
155 #ifdef __cplusplus | 155 #ifdef __cplusplus |
156 const MojoHandleSignals MOJO_HANDLE_SIGNAL_NONE = 0; | 156 const MojoHandleSignals MOJO_HANDLE_SIGNAL_NONE = 0; |
157 const MojoHandleSignals MOJO_HANDLE_SIGNAL_READABLE = 1 << 0; | 157 const MojoHandleSignals MOJO_HANDLE_SIGNAL_READABLE = 1 << 0; |
158 const MojoHandleSignals MOJO_HANDLE_SIGNAL_WRITABLE = 1 << 1; | 158 const MojoHandleSignals MOJO_HANDLE_SIGNAL_WRITABLE = 1 << 1; |
159 #else | 159 #else |
160 #define MOJO_HANDLE_SIGNAL_NONE ((MojoHandleSignals) 0) | 160 #define MOJO_HANDLE_SIGNAL_NONE ((MojoHandleSignals)0) |
161 #define MOJO_HANDLE_SIGNAL_READABLE ((MojoHandleSignals) 1 << 0) | 161 #define MOJO_HANDLE_SIGNAL_READABLE ((MojoHandleSignals)1 << 0) |
162 #define MOJO_HANDLE_SIGNAL_WRITABLE ((MojoHandleSignals) 1 << 1) | 162 #define MOJO_HANDLE_SIGNAL_WRITABLE ((MojoHandleSignals)1 << 1) |
163 #endif | 163 #endif |
164 | 164 |
165 // TODO(vtl): Add out parameters with this to MojoWait/MojoWaitMany. | 165 // TODO(vtl): Add out parameters with this to MojoWait/MojoWaitMany. |
166 // Note: This struct is not extensible (and only has 32-bit quantities), so it's | 166 // Note: This struct is not extensible (and only has 32-bit quantities), so it's |
167 // 32-bit-aligned. | 167 // 32-bit-aligned. |
168 MOJO_COMPILE_ASSERT(MOJO_ALIGNOF(int32_t) == 4, int32_t_has_weird_alignment); | 168 MOJO_COMPILE_ASSERT(MOJO_ALIGNOF(int32_t) == 4, int32_t_has_weird_alignment); |
169 struct MOJO_ALIGNAS(4) MojoHandleSignalsState { | 169 struct MOJO_ALIGNAS(4) MojoHandleSignalsState { |
170 MojoHandleSignals satisfied_signals; | 170 MojoHandleSignals satisfied_signals; |
171 MojoHandleSignals satisfiable_signals; | 171 MojoHandleSignals satisfiable_signals; |
172 }; | 172 }; |
173 MOJO_COMPILE_ASSERT(sizeof(MojoHandleSignalsState) == 8, | 173 MOJO_COMPILE_ASSERT(sizeof(MojoHandleSignalsState) == 8, |
174 MojoHandleSignalsState_has_wrong_size); | 174 MojoHandleSignalsState_has_wrong_size); |
175 | 175 |
176 #endif // MOJO_PUBLIC_C_SYSTEM_TYPES_H_ | 176 #endif // MOJO_PUBLIC_C_SYSTEM_TYPES_H_ |
OLD | NEW |