1 // Copyright 2018 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 "trace_provider.fidl.h"
6
7 // This file was machine generated with:
8 //
9 // bash$ fidlc --c-header trace_provider.fidl.h
10 // --c-client trace_provider.fidl.client.cpp
11 // --tables trace_provider.fidl.tables.cpp
12 // --files system/fidl/fuchsia-tracelink/tracelink.fidl
13 //
14 // and then this header (up to "End of additions ...") manually inserted.
15 //
16 // There are *no* differences with the machine generated version except the
17 // addition of this text WITH TWO EXCEPTIONS:
18 // 1) Commenting out
19 // #include <fuchsia/tracelink/c/fidl.h> below. Our copy of this header lives
20 // in trace_provider.fidl.h.
21 // 2) Workaround FIDL-275.
22 // size_t -> uint32_t conversion errors. Grep for TO_UINT32 below.
23 //
24 // Minimizing differences with generated code is critical to lessening the
25 // maintenance burden until we no longer check in machine generated code.
26 // It is currently checked in to workaround these problems:
27 // - zircon's build system doesn't support transitive dependencies
28 // - duplicate copy of tracelink is generated and compiled in garnet,
29 // leading to duplicate symbol linker errors
30
31 #define TO_UINT32(x) (static_cast<uint32_t>(x))
32
33 // End of additions to machine-generated file.
34 // WARNING: This file is machine generated by fidlc.
35
36 #include <lib/fidl/coding.h>
37 #include <string.h>
38 #include <zircon/syscalls.h>
39 //#include <fuchsia/tracelink/c/fidl.h>
40
fuchsia_tracelink_RegistryRegisterTraceProviderDeprecated(zx_handle_t _channel,zx_handle_t provider)41 zx_status_t fuchsia_tracelink_RegistryRegisterTraceProviderDeprecated(zx_handle_t _channel, zx_handle_t provider) {
42 uint32_t _wr_num_bytes = sizeof(fuchsia_tracelink_RegistryRegisterTraceProviderDeprecatedRequest);
43 FIDL_ALIGNDECL char _wr_bytes[_wr_num_bytes];
44 fuchsia_tracelink_RegistryRegisterTraceProviderDeprecatedRequest* _request = (fuchsia_tracelink_RegistryRegisterTraceProviderDeprecatedRequest*)_wr_bytes;
45 memset(_wr_bytes, 0, sizeof(_wr_bytes));
46 _request->hdr.ordinal = 1;
47 _request->provider = provider;
48 zx_handle_t _handles[ZX_CHANNEL_MAX_MSG_HANDLES];
49 uint32_t _wr_num_handles = 0u;
50 zx_status_t _status = fidl_encode(&fuchsia_tracelink_RegistryRegisterTraceProviderDeprecatedRequestTable, _wr_bytes, _wr_num_bytes, _handles, ZX_CHANNEL_MAX_MSG_HANDLES, &_wr_num_handles, NULL);
51 if (_status != ZX_OK)
52 return _status;
53 return zx_channel_write(_channel, 0u, _wr_bytes, _wr_num_bytes, _handles, _wr_num_handles);
54 }
55
fuchsia_tracelink_RegistryRegisterTraceProvider(zx_handle_t _channel,zx_handle_t provider,uint64_t pid,const char * name_data,size_t name_size)56 zx_status_t fuchsia_tracelink_RegistryRegisterTraceProvider(zx_handle_t _channel, zx_handle_t provider, uint64_t pid, const char* name_data, size_t name_size) {
57 uint32_t _wr_num_bytes = TO_UINT32(sizeof(fuchsia_tracelink_RegistryRegisterTraceProviderRequest) + FIDL_ALIGN(name_size));
58 FIDL_ALIGNDECL char _wr_bytes[_wr_num_bytes];
59 fuchsia_tracelink_RegistryRegisterTraceProviderRequest* _request = (fuchsia_tracelink_RegistryRegisterTraceProviderRequest*)_wr_bytes;
60 memset(_wr_bytes, 0, sizeof(_wr_bytes));
61 _request->hdr.ordinal = 2;
62 uint32_t _next = sizeof(*_request);
63 _request->provider = provider;
64 _request->pid = pid;
65 _request->name.data = &_wr_bytes[_next];
66 _request->name.size = name_size;
67 memcpy(_request->name.data, name_data, name_size);
68 _next += TO_UINT32(FIDL_ALIGN(name_size));
69 zx_handle_t _handles[ZX_CHANNEL_MAX_MSG_HANDLES];
70 uint32_t _wr_num_handles = 0u;
71 zx_status_t _status = fidl_encode(&fuchsia_tracelink_RegistryRegisterTraceProviderRequestTable, _wr_bytes, _wr_num_bytes, _handles, ZX_CHANNEL_MAX_MSG_HANDLES, &_wr_num_handles, NULL);
72 if (_status != ZX_OK)
73 return _status;
74 return zx_channel_write(_channel, 0u, _wr_bytes, _wr_num_bytes, _handles, _wr_num_handles);
75 }
76
fuchsia_tracelink_RegistryRegisterTraceProviderSynchronously(zx_handle_t _channel,zx_handle_t provider,uint64_t pid,const char * name_data,size_t name_size,int32_t * out_s,bool * out_started)77 zx_status_t fuchsia_tracelink_RegistryRegisterTraceProviderSynchronously(zx_handle_t _channel, zx_handle_t provider, uint64_t pid, const char* name_data, size_t name_size, int32_t* out_s, bool* out_started) {
78 uint32_t _wr_num_bytes = TO_UINT32(sizeof(fuchsia_tracelink_RegistryRegisterTraceProviderSynchronouslyRequest) + FIDL_ALIGN(name_size));
79 FIDL_ALIGNDECL char _wr_bytes[_wr_num_bytes];
80 fuchsia_tracelink_RegistryRegisterTraceProviderSynchronouslyRequest* _request = (fuchsia_tracelink_RegistryRegisterTraceProviderSynchronouslyRequest*)_wr_bytes;
81 memset(_wr_bytes, 0, sizeof(_wr_bytes));
82 _request->hdr.ordinal = 3;
83 uint32_t _next = sizeof(*_request);
84 _request->provider = provider;
85 _request->pid = pid;
86 _request->name.data = &_wr_bytes[_next];
87 _request->name.size = name_size;
88 memcpy(_request->name.data, name_data, name_size);
89 _next += TO_UINT32(FIDL_ALIGN(name_size));
90 zx_handle_t _handles[ZX_CHANNEL_MAX_MSG_HANDLES];
91 uint32_t _wr_num_handles = 0u;
92 zx_status_t _status = fidl_encode(&fuchsia_tracelink_RegistryRegisterTraceProviderSynchronouslyRequestTable, _wr_bytes, _wr_num_bytes, _handles, ZX_CHANNEL_MAX_MSG_HANDLES, &_wr_num_handles, NULL);
93 if (_status != ZX_OK)
94 return _status;
95 uint32_t _rd_num_bytes = sizeof(fuchsia_tracelink_RegistryRegisterTraceProviderSynchronouslyResponse);
96 FIDL_ALIGNDECL char _rd_bytes[_rd_num_bytes];
97 fuchsia_tracelink_RegistryRegisterTraceProviderSynchronouslyResponse* _response = (fuchsia_tracelink_RegistryRegisterTraceProviderSynchronouslyResponse*)_rd_bytes;
98 zx_channel_call_args_t _args = {
99 .wr_bytes = _wr_bytes,
100 .wr_handles = _handles,
101 .rd_bytes = _rd_bytes,
102 .rd_handles = _handles,
103 .wr_num_bytes = _wr_num_bytes,
104 .wr_num_handles = _wr_num_handles,
105 .rd_num_bytes = _rd_num_bytes,
106 .rd_num_handles = ZX_CHANNEL_MAX_MSG_HANDLES,
107 };
108 uint32_t _actual_num_bytes = 0u;
109 uint32_t _actual_num_handles = 0u;
110 _status = zx_channel_call(_channel, 0u, ZX_TIME_INFINITE, &_args, &_actual_num_bytes, &_actual_num_handles);
111 if (_status != ZX_OK)
112 return _status;
113 // OPTIMIZED AWAY fidl_decode() of POD-only response
114 if (_actual_num_handles > 0) {
115 zx_handle_close_many(_handles, _actual_num_handles);
116 return ZX_ERR_INTERNAL;
117 }
118 *out_s = _response->s;
119 *out_started = _response->started;
120 return ZX_OK;
121 }
122
123