| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #ifndef MOJO_PUBLIC_SYSTEM_CORE_H_ | 5 #ifndef MOJO_PUBLIC_SYSTEM_CORE_H_ |
| 6 #define MOJO_PUBLIC_SYSTEM_CORE_H_ | 6 #define MOJO_PUBLIC_SYSTEM_CORE_H_ |
| 7 | 7 |
| 8 // Note: This header should be compilable as C. | 8 // Note: This header should be compilable as C. |
| 9 | 9 |
| 10 #include <stdint.h> | 10 #include <stdint.h> |
| 11 | 11 |
| 12 #include "mojo/public/system/macros.h" |
| 13 |
| 12 // Types ----------------------------------------------------------------------- | 14 // Types ----------------------------------------------------------------------- |
| 13 | 15 |
| 14 // TODO(vtl): Notes: Use of undefined flags will lead to undefined behavior | 16 // TODO(vtl): Notes: Use of undefined flags will lead to undefined behavior |
| 15 // (typically they'll be ignored), not necessarily an error. | 17 // (typically they'll be ignored), not necessarily an error. |
| 16 | 18 |
| 17 // Handles to Mojo objects. | 19 // Handles to Mojo objects. |
| 18 typedef uint32_t MojoHandle; | 20 typedef uint32_t MojoHandle; |
| 19 | 21 |
| 20 // Result codes for Mojo operations. Non-negative values are success codes; | 22 // Result codes for Mojo operations. Non-negative values are success codes; |
| 21 // negative values are error/failure codes. | 23 // negative values are error/failure codes. |
| (...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 246 #ifdef __cplusplus | 248 #ifdef __cplusplus |
| 247 } // extern "C" | 249 } // extern "C" |
| 248 #endif | 250 #endif |
| 249 | 251 |
| 250 // C++ wrapper functions ------------------------------------------------------- | 252 // C++ wrapper functions ------------------------------------------------------- |
| 251 | 253 |
| 252 #ifdef __cplusplus | 254 #ifdef __cplusplus |
| 253 | 255 |
| 254 namespace mojo { | 256 namespace mojo { |
| 255 | 257 |
| 256 // Used to assert things at compile time. (Use our own copy instead of | |
| 257 // Chromium's, since we can't depend on Chromium.) | |
| 258 template <bool> struct CompileAssert {}; | |
| 259 #define MOJO_COMPILE_ASSERT(expr, msg) \ | |
| 260 typedef CompileAssert<(bool(expr))> msg[bool(expr) ? 1 : -1] | |
| 261 | |
| 262 struct Handle { MojoHandle value; }; | 258 struct Handle { MojoHandle value; }; |
| 263 | 259 |
| 264 const Handle kInvalidHandle = { MOJO_HANDLE_INVALID }; | 260 const Handle kInvalidHandle = { MOJO_HANDLE_INVALID }; |
| 265 | 261 |
| 266 // A |mojo::Handle| must take no extra space, since we'll treat arrays of them | 262 // A |mojo::Handle| must take no extra space, since we'll treat arrays of them |
| 267 // as if they were arrays of |MojoHandle|s. | 263 // as if they were arrays of |MojoHandle|s. |
| 268 MOJO_COMPILE_ASSERT(sizeof(Handle) == sizeof(MojoHandle), | 264 MOJO_COMPILE_ASSERT(sizeof(Handle) == sizeof(MojoHandle), |
| 269 bad_size_for_cplusplus_handle); | 265 bad_size_for_cplusplus_handle); |
| 270 | 266 |
| 271 inline MojoResult Close(Handle handle) { | 267 inline MojoResult Close(Handle handle) { |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 306 return MojoReadMessage(handle.value, | 302 return MojoReadMessage(handle.value, |
| 307 bytes, num_bytes, | 303 bytes, num_bytes, |
| 308 &handles[0].value, num_handles, | 304 &handles[0].value, num_handles, |
| 309 flags); | 305 flags); |
| 310 } | 306 } |
| 311 | 307 |
| 312 } // namespace mojo | 308 } // namespace mojo |
| 313 #endif | 309 #endif |
| 314 | 310 |
| 315 #endif // MOJO_PUBLIC_SYSTEM_CORE_H_ | 311 #endif // MOJO_PUBLIC_SYSTEM_CORE_H_ |
| OLD | NEW |