Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
utils_fuchsia.h
Go to the documentation of this file.
1// Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
2// for details. All rights reserved. Use of this source code is governed by a
3// BSD-style license that can be found in the LICENSE file.
4
5#ifndef RUNTIME_PLATFORM_UTILS_FUCHSIA_H_
6#define RUNTIME_PLATFORM_UTILS_FUCHSIA_H_
7
8#include <endian.h>
9#include <memory>
10
11namespace sys {
12
13// From Fuchsia SDK.
14class ComponentContext;
15
16} // namespace sys
17
18namespace inspect {
19
20// From Fuchsia SDK.
21class Node;
22
23} // namespace inspect
24
25namespace dart {
26
27inline uint16_t Utils::HostToBigEndian16(uint16_t value) {
28 return htobe16(value);
29}
30
31inline uint32_t Utils::HostToBigEndian32(uint32_t value) {
32 return htobe32(value);
33}
34
35inline uint64_t Utils::HostToBigEndian64(uint64_t value) {
36 return htobe64(value);
37}
38
39inline uint16_t Utils::HostToLittleEndian16(uint16_t value) {
40 return htole16(value);
41}
42
43inline uint32_t Utils::HostToLittleEndian32(uint32_t value) {
44 return htole32(value);
45}
46
47inline uint64_t Utils::HostToLittleEndian64(uint64_t value) {
48 return htole64(value);
49}
50
51inline char* Utils::StrError(int err, char* buffer, size_t bufsize) {
52 if (strerror_r(err, buffer, bufsize) != 0) {
53 snprintf(buffer, bufsize, "%s", "strerror_r failed");
54 }
55 return buffer;
56}
57
58// Returns the singleton component context for this process.
59//
60// The returned pointer is never null. The caller must not take ownership of
61// the context.
62//
63// The context is a singleton as it can be meaningfully instantiated only once
64// during the lifetime of the program. If you use this function, you MUST NOT
65// call sys::ComponentContext::Create().
66sys::ComponentContext* ComponentContext();
67
68// Sets the inspect node set to be used in the dart vm
69//
70// This method will take ownership of the node
71void SetDartVmNode(std::unique_ptr<inspect::Node> node);
72
73// Returns the inspect node set in SetDartVmNode().
74//
75// The caller should take ownership of the returned node because
76// the value will be set to null after this call.
77// This call may return null if no node is provided.
78std::unique_ptr<inspect::Node> TakeDartVmNode();
79
80} // namespace dart
81
82#endif // RUNTIME_PLATFORM_UTILS_FUCHSIA_H_
static uint64_t HostToBigEndian64(uint64_t host_value)
static uint64_t HostToLittleEndian64(uint64_t host_value)
static uint16_t HostToLittleEndian16(uint16_t host_value)
static char * StrError(int err, char *buffer, size_t bufsize)
static uint32_t HostToLittleEndian32(uint32_t host_value)
static uint16_t HostToBigEndian16(uint16_t host_value)
static uint32_t HostToBigEndian32(uint32_t host_value)
static const uint8_t buffer[]
Definition dart.idl:29
void SetDartVmNode(std::unique_ptr< inspect::Node > node)
sys::ComponentContext * ComponentContext()
std::unique_ptr< inspect::Node > TakeDartVmNode()