Doug Horn | 1427b6a | 2018-12-11 13:19:16 -0800 | [diff] [blame] | 1 | // Copyright 2016 The Fuchsia Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #include <lib/zx/channel.h> |
| 6 | |
| 7 | #include <zircon/syscalls.h> |
| 8 | |
| 9 | namespace zx { |
| 10 | |
| 11 | zx_status_t channel::create(uint32_t flags, channel* endpoint0, |
| 12 | channel* endpoint1) { |
| 13 | // Ensure aliasing of both out parameters to the same container |
| 14 | // has a well-defined result, and does not leak. |
| 15 | channel h0; |
| 16 | channel h1; |
| 17 | zx_status_t status = zx_channel_create(flags, |
| 18 | h0.reset_and_get_address(), |
| 19 | h1.reset_and_get_address()); |
| 20 | endpoint0->reset(h0.release()); |
| 21 | endpoint1->reset(h1.release()); |
| 22 | return status; |
| 23 | } |
| 24 | |
| 25 | } // namespace zx |