Flutter Engine
The Flutter Engine
utils_linux.cc
Go to the documentation of this file.
1// Copyright (c) 2012, 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#include "platform/globals.h"
6#if defined(DART_HOST_OS_LINUX)
7
8#include <sys/utsname.h>
9
10#include "platform/utils.h"
12
13namespace dart {
14
15char* Utils::StrNDup(const char* s, intptr_t n) {
16 return strndup(s, n);
17}
18
19char* Utils::StrDup(const char* s) {
20 return strdup(s);
21}
22
23intptr_t Utils::StrNLen(const char* s, intptr_t n) {
24 return strnlen(s, n);
25}
26
27int Utils::SNPrint(char* str, size_t size, const char* format, ...) {
28 va_list args;
30 int retval = VSNPrint(str, size, format, args);
31 va_end(args);
32 return retval;
33}
34
35int Utils::VSNPrint(char* str, size_t size, const char* format, va_list args) {
36 int retval = vsnprintf(str, size, format, args);
37 if (retval < 0) {
38 FATAL("Fatal error in Utils::VSNPrint with format '%s'", format);
39 }
40 return retval;
41}
42
43int Utils::Close(int fildes) {
44 return close(fildes);
45}
46
47size_t Utils::Read(int filedes, void* buf, size_t nbyte) {
48 return read(filedes, buf, nbyte);
49}
50
51int Utils::Unlink(const char* path) {
52 return unlink(path);
53}
54
55bool Utils::IsWindowsSubsystemForLinux() {
56 struct utsname info;
57 if (uname(&info) != 0) {
58 return false; // Not sure.
59 }
60
61 // If info.release contains either Microsoft or microsoft then we are
62 // most likely running under WSL.
63 return strstr(info.release, "icrosoft") != nullptr;
64}
65
66} // namespace dart
67
68#endif // defined(DART_HOST_OS_LINUX)
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition: DM.cpp:213
static bool read(SkStream *stream, void *buffer, size_t amount)
static int SNPrint(char *str, size_t size, const char *format,...) PRINTF_ATTRIBUTE(3
static char * StrDup(const char *s)
static int static int VSNPrint(char *str, size_t size, const char *format, va_list args)
static size_t Read(int filedes, void *buf, size_t nbyte)
static intptr_t StrNLen(const char *s, intptr_t n)
static int Close(int fildes)
static int Unlink(const char *path)
static char * StrNDup(const char *s, intptr_t n)
struct MyStruct s
#define FATAL(error)
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
uint32_t uint32_t * format
va_start(args, format)
va_end(args)
Definition: dart_vm.cc:33
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir path
Definition: switches.h:57
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
Definition: switches.h:259
char * strdup(const char *str1)