OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 package native_cgo | 5 package native_cgo |
6 | 6 |
7 //#include "mojo/public/c/system/buffer.h" | 7 //#include "mojo/public/c/system/buffer.h" |
8 //#include "mojo/public/c/system/data_pipe.h" | 8 //#include "mojo/public/c/system/data_pipe.h" |
9 //#include "mojo/public/c/system/functions.h" | |
10 //#include "mojo/public/c/system/handle.h" | 9 //#include "mojo/public/c/system/handle.h" |
11 //#include "mojo/public/c/system/message_pipe.h" | 10 //#include "mojo/public/c/system/message_pipe.h" |
12 //#include "mojo/public/c/system/result.h" | 11 //#include "mojo/public/c/system/result.h" |
13 //#include "mojo/public/c/system/types.h" | 12 //#include "mojo/public/c/system/time.h" |
| 13 //#include "mojo/public/c/system/wait.h" |
14 // | 14 // |
15 // // These functions are used to 8-byte align C structs. | 15 // // These functions are used to 8-byte align C structs. |
16 // MojoResult CreateSharedBuffer(struct MojoCreateSharedBufferOptions* options, | 16 // MojoResult CreateSharedBuffer(struct MojoCreateSharedBufferOptions* options, |
17 // uint64_t num_bytes, MojoHandle* handle) { | 17 // uint64_t num_bytes, MojoHandle* handle) { |
18 // struct MojoCreateSharedBufferOptions aligned_options; | 18 // struct MojoCreateSharedBufferOptions aligned_options; |
19 // if (options != NULL) { | 19 // if (options != NULL) { |
20 // aligned_options = *options; | 20 // aligned_options = *options; |
21 // return MojoCreateSharedBuffer(&aligned_options, num_bytes, handle); | 21 // return MojoCreateSharedBuffer(&aligned_options, num_bytes, handle); |
22 // } else { | 22 // } else { |
23 // return MojoCreateSharedBuffer(NULL, num_bytes, handle); | 23 // return MojoCreateSharedBuffer(NULL, num_bytes, handle); |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
259 Data: uintptr(ptr), | 259 Data: uintptr(ptr), |
260 Len: length, | 260 Len: length, |
261 Cap: length, | 261 Cap: length, |
262 } | 262 } |
263 return unsafe.Pointer(header) | 263 return unsafe.Pointer(header) |
264 } | 264 } |
265 | 265 |
266 func unsafeByteSlice(ptr unsafe.Pointer, length int) []byte { | 266 func unsafeByteSlice(ptr unsafe.Pointer, length int) []byte { |
267 return *(*[]byte)(newUnsafeSlice(ptr, length)) | 267 return *(*[]byte)(newUnsafeSlice(ptr, length)) |
268 } | 268 } |
OLD | NEW |