dsh-remote 0.8.91 → 0.8.93

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (181) hide show
  1. package/LICENSE +21 -21
  2. package/README.en.md +369 -368
  3. package/README.md +354 -353
  4. package/cordis.patch.yml +9 -9
  5. package/lib/audit.js +45 -45
  6. package/lib/binding.js +172 -172
  7. package/lib/client.js +4647 -4550
  8. package/lib/credential.js +270 -263
  9. package/lib/errors.js +141 -141
  10. package/lib/exec-job.js +242 -242
  11. package/lib/file-reference.js +457 -457
  12. package/lib/forwards.js +258 -258
  13. package/lib/host-api.js +822 -822
  14. package/lib/hostkey.js +108 -108
  15. package/lib/http-transport.js +201 -201
  16. package/lib/ignore.js +202 -202
  17. package/lib/index.js +4488 -4394
  18. package/lib/instructions-dynamic.js +415 -415
  19. package/lib/instructions.js +288 -288
  20. package/lib/open-folder.js +56 -56
  21. package/lib/openssh.js +940 -881
  22. package/lib/paths.js +292 -292
  23. package/lib/pool.js +1029 -970
  24. package/lib/posix-shell.cjs +34 -0
  25. package/lib/registry.js +296 -296
  26. package/lib/remote-fs.js +173 -173
  27. package/lib/remote-sandbox.js +183 -183
  28. package/lib/remote-shell-child.cjs +397 -400
  29. package/lib/remote-shell.js +697 -697
  30. package/lib/remote-skills.js +312 -0
  31. package/lib/routes-audit.js +58 -58
  32. package/lib/routes-forwards.js +72 -72
  33. package/lib/routes-fs.js +251 -245
  34. package/lib/routes-machines.js +186 -186
  35. package/lib/routes-misc.js +187 -150
  36. package/lib/routes-term.js +169 -169
  37. package/lib/routes-update.js +143 -143
  38. package/lib/routes-web-attach.js +112 -112
  39. package/lib/routes-workspace.js +312 -312
  40. package/lib/search.js +235 -235
  41. package/lib/sftp-surface.js +119 -119
  42. package/lib/sshconfig.js +779 -779
  43. package/lib/sync.js +350 -350
  44. package/lib/tasks.js +95 -95
  45. package/lib/telemetry.js +247 -247
  46. package/lib/terminal.js +205 -205
  47. package/lib/tui/flow.js +130 -130
  48. package/lib/tui/format.js +380 -380
  49. package/lib/tui/i18n.js +350 -350
  50. package/lib/tui/index.js +531 -531
  51. package/lib/tui/provider.js +344 -344
  52. package/lib/tui/scene.js +986 -986
  53. package/lib/update.js +490 -472
  54. package/lib/web-attach.js +860 -850
  55. package/lib/workspace-cleanup.js +337 -337
  56. package/package.json +103 -100
  57. package/node_modules/buildcheck/.eslintrc.js +0 -5
  58. package/node_modules/buildcheck/.github/workflows/ci.yml +0 -88
  59. package/node_modules/buildcheck/.github/workflows/lint.yml +0 -27
  60. package/node_modules/buildcheck/.npmignore +0 -3
  61. package/node_modules/buildcheck/LICENSE +0 -19
  62. package/node_modules/buildcheck/README.md +0 -106
  63. package/node_modules/buildcheck/deps/Find-VisualStudio.cs +0 -250
  64. package/node_modules/buildcheck/lib/findvs.js +0 -361
  65. package/node_modules/buildcheck/lib/index.js +0 -738
  66. package/node_modules/buildcheck/package.json +0 -36
  67. package/node_modules/buildcheck/test/test.js +0 -8
  68. package/node_modules/cpu-features/.eslintrc.js +0 -5
  69. package/node_modules/cpu-features/.github/workflows/ci.yml +0 -74
  70. package/node_modules/cpu-features/.github/workflows/lint.yml +0 -27
  71. package/node_modules/cpu-features/LICENSE +0 -19
  72. package/node_modules/cpu-features/README.md +0 -59
  73. package/node_modules/cpu-features/binding.gyp +0 -16
  74. package/node_modules/cpu-features/buildcheck.js +0 -32
  75. package/node_modules/cpu-features/deps/cpu_features/.clang-format +0 -4
  76. package/node_modules/cpu-features/deps/cpu_features/.dockerignore +0 -31
  77. package/node_modules/cpu-features/deps/cpu_features/.github/workflows/Dockerfile +0 -5
  78. package/node_modules/cpu-features/deps/cpu_features/.github/workflows/aarch64_linux_cmake.yml +0 -30
  79. package/node_modules/cpu-features/deps/cpu_features/.github/workflows/amd64_freebsd_cmake.yml +0 -22
  80. package/node_modules/cpu-features/deps/cpu_features/.github/workflows/amd64_linux_bazel.yml +0 -26
  81. package/node_modules/cpu-features/deps/cpu_features/.github/workflows/amd64_linux_cmake.yml +0 -31
  82. package/node_modules/cpu-features/deps/cpu_features/.github/workflows/amd64_macos_cmake.yml +0 -43
  83. package/node_modules/cpu-features/deps/cpu_features/.github/workflows/amd64_windows_cmake.yml +0 -25
  84. package/node_modules/cpu-features/deps/cpu_features/.github/workflows/arm_linux_cmake.yml +0 -31
  85. package/node_modules/cpu-features/deps/cpu_features/.github/workflows/clang_format.yml +0 -24
  86. package/node_modules/cpu-features/deps/cpu_features/.github/workflows/mips_linux_cmake.yml +0 -30
  87. package/node_modules/cpu-features/deps/cpu_features/.github/workflows/power_linux_cmake.yml +0 -29
  88. package/node_modules/cpu-features/deps/cpu_features/.github/workflows/riscv_linux_cmake.yml +0 -28
  89. package/node_modules/cpu-features/deps/cpu_features/.github/workflows/s390x_linux_cmake.yml +0 -27
  90. package/node_modules/cpu-features/deps/cpu_features/.grenrc.yml +0 -21
  91. package/node_modules/cpu-features/deps/cpu_features/BUILD.bazel +0 -329
  92. package/node_modules/cpu-features/deps/cpu_features/CMakeLists.txt +0 -261
  93. package/node_modules/cpu-features/deps/cpu_features/CONTRIBUTING.md +0 -23
  94. package/node_modules/cpu-features/deps/cpu_features/LICENSE +0 -230
  95. package/node_modules/cpu-features/deps/cpu_features/README.md +0 -272
  96. package/node_modules/cpu-features/deps/cpu_features/WORKSPACE +0 -19
  97. package/node_modules/cpu-features/deps/cpu_features/bazel/ci/README.md +0 -5
  98. package/node_modules/cpu-features/deps/cpu_features/bazel/platforms.bzl +0 -11
  99. package/node_modules/cpu-features/deps/cpu_features/cmake/CpuFeaturesConfig.cmake.in +0 -3
  100. package/node_modules/cpu-features/deps/cpu_features/cmake/CpuFeaturesNdkCompatConfig.cmake.in +0 -3
  101. package/node_modules/cpu-features/deps/cpu_features/cmake/README.md +0 -30
  102. package/node_modules/cpu-features/deps/cpu_features/cmake/ci/Makefile +0 -252
  103. package/node_modules/cpu-features/deps/cpu_features/cmake/ci/README.md +0 -40
  104. package/node_modules/cpu-features/deps/cpu_features/cmake/ci/doc/docker.dot +0 -64
  105. package/node_modules/cpu-features/deps/cpu_features/cmake/ci/doc/docker.svg +0 -312
  106. package/node_modules/cpu-features/deps/cpu_features/cmake/ci/doc/generate_image.sh +0 -7
  107. package/node_modules/cpu-features/deps/cpu_features/cmake/ci/docker/amd64/Dockerfile +0 -48
  108. package/node_modules/cpu-features/deps/cpu_features/cmake/ci/docker/toolchain/Dockerfile +0 -34
  109. package/node_modules/cpu-features/deps/cpu_features/cmake/ci/sample/CMakeLists.txt +0 -22
  110. package/node_modules/cpu-features/deps/cpu_features/cmake/ci/sample/main.cpp +0 -11
  111. package/node_modules/cpu-features/deps/cpu_features/cmake/ci/vagrant/freebsd/Vagrantfile +0 -107
  112. package/node_modules/cpu-features/deps/cpu_features/cmake/googletest.CMakeLists.txt.in +0 -15
  113. package/node_modules/cpu-features/deps/cpu_features/cpu_features.gyp +0 -105
  114. package/node_modules/cpu-features/deps/cpu_features/include/cpu_features_cache_info.h +0 -54
  115. package/node_modules/cpu-features/deps/cpu_features/include/cpu_features_macros.h +0 -384
  116. package/node_modules/cpu-features/deps/cpu_features/include/cpuinfo_aarch64.h +0 -259
  117. package/node_modules/cpu-features/deps/cpu_features/include/cpuinfo_arm.h +0 -121
  118. package/node_modules/cpu-features/deps/cpu_features/include/cpuinfo_mips.h +0 -74
  119. package/node_modules/cpu-features/deps/cpu_features/include/cpuinfo_ppc.h +0 -149
  120. package/node_modules/cpu-features/deps/cpu_features/include/cpuinfo_riscv.h +0 -72
  121. package/node_modules/cpu-features/deps/cpu_features/include/cpuinfo_s390x.h +0 -108
  122. package/node_modules/cpu-features/deps/cpu_features/include/cpuinfo_x86.h +0 -288
  123. package/node_modules/cpu-features/deps/cpu_features/include/internal/bit_utils.h +0 -40
  124. package/node_modules/cpu-features/deps/cpu_features/include/internal/cpuid_x86.h +0 -37
  125. package/node_modules/cpu-features/deps/cpu_features/include/internal/filesystem.h +0 -39
  126. package/node_modules/cpu-features/deps/cpu_features/include/internal/hwcaps.h +0 -240
  127. package/node_modules/cpu-features/deps/cpu_features/include/internal/stack_line_reader.h +0 -49
  128. package/node_modules/cpu-features/deps/cpu_features/include/internal/string_view.h +0 -110
  129. package/node_modules/cpu-features/deps/cpu_features/include/internal/windows_utils.h +0 -70
  130. package/node_modules/cpu-features/deps/cpu_features/ndk_compat/CMakeLists.txt +0 -60
  131. package/node_modules/cpu-features/deps/cpu_features/ndk_compat/README.md +0 -4
  132. package/node_modules/cpu-features/deps/cpu_features/ndk_compat/cpu-features.c +0 -205
  133. package/node_modules/cpu-features/deps/cpu_features/ndk_compat/cpu-features.h +0 -320
  134. package/node_modules/cpu-features/deps/cpu_features/ndk_compat/ndk-compat-test.c +0 -12
  135. package/node_modules/cpu-features/deps/cpu_features/patches/0001-Add-Apple-Silicon-Support.patch +0 -456
  136. package/node_modules/cpu-features/deps/cpu_features/scripts/generate_badges.d +0 -165
  137. package/node_modules/cpu-features/deps/cpu_features/scripts/make_release.sh +0 -75
  138. package/node_modules/cpu-features/deps/cpu_features/scripts/run_integration.sh +0 -490
  139. package/node_modules/cpu-features/deps/cpu_features/scripts/test_integration.sh +0 -79
  140. package/node_modules/cpu-features/deps/cpu_features/src/copy.inl +0 -19
  141. package/node_modules/cpu-features/deps/cpu_features/src/define_introspection.inl +0 -86
  142. package/node_modules/cpu-features/deps/cpu_features/src/define_introspection_and_hwcaps.inl +0 -26
  143. package/node_modules/cpu-features/deps/cpu_features/src/equals.inl +0 -22
  144. package/node_modules/cpu-features/deps/cpu_features/src/filesystem.c +0 -62
  145. package/node_modules/cpu-features/deps/cpu_features/src/hwcaps.c +0 -169
  146. package/node_modules/cpu-features/deps/cpu_features/src/impl_aarch64__base_implementation.inl +0 -88
  147. package/node_modules/cpu-features/deps/cpu_features/src/impl_aarch64_linux_or_android.c +0 -79
  148. package/node_modules/cpu-features/deps/cpu_features/src/impl_aarch64_macos_or_iphone.c +0 -82
  149. package/node_modules/cpu-features/deps/cpu_features/src/impl_aarch64_windows.c +0 -138
  150. package/node_modules/cpu-features/deps/cpu_features/src/impl_arm_linux_or_android.c +0 -212
  151. package/node_modules/cpu-features/deps/cpu_features/src/impl_mips_linux_or_android.c +0 -93
  152. package/node_modules/cpu-features/deps/cpu_features/src/impl_ppc_linux.c +0 -163
  153. package/node_modules/cpu-features/deps/cpu_features/src/impl_riscv_linux.c +0 -111
  154. package/node_modules/cpu-features/deps/cpu_features/src/impl_s390x_linux.c +0 -120
  155. package/node_modules/cpu-features/deps/cpu_features/src/impl_x86__base_implementation.inl +0 -2055
  156. package/node_modules/cpu-features/deps/cpu_features/src/impl_x86_freebsd.c +0 -68
  157. package/node_modules/cpu-features/deps/cpu_features/src/impl_x86_linux_or_android.c +0 -58
  158. package/node_modules/cpu-features/deps/cpu_features/src/impl_x86_macos.c +0 -57
  159. package/node_modules/cpu-features/deps/cpu_features/src/impl_x86_windows.c +0 -58
  160. package/node_modules/cpu-features/deps/cpu_features/src/stack_line_reader.c +0 -132
  161. package/node_modules/cpu-features/deps/cpu_features/src/string_view.c +0 -192
  162. package/node_modules/cpu-features/deps/cpu_features/src/utils/list_cpu_features.c +0 -461
  163. package/node_modules/cpu-features/deps/cpu_features/test/CMakeLists.txt +0 -114
  164. package/node_modules/cpu-features/deps/cpu_features/test/bit_utils_test.cc +0 -53
  165. package/node_modules/cpu-features/deps/cpu_features/test/cpuinfo_aarch64_test.cc +0 -396
  166. package/node_modules/cpu-features/deps/cpu_features/test/cpuinfo_arm_test.cc +0 -384
  167. package/node_modules/cpu-features/deps/cpu_features/test/cpuinfo_mips_test.cc +0 -176
  168. package/node_modules/cpu-features/deps/cpu_features/test/cpuinfo_ppc_test.cc +0 -131
  169. package/node_modules/cpu-features/deps/cpu_features/test/cpuinfo_riscv_test.cc +0 -180
  170. package/node_modules/cpu-features/deps/cpu_features/test/cpuinfo_s390x_test.cc +0 -82
  171. package/node_modules/cpu-features/deps/cpu_features/test/cpuinfo_x86_test.cc +0 -1729
  172. package/node_modules/cpu-features/deps/cpu_features/test/filesystem_for_testing.cc +0 -103
  173. package/node_modules/cpu-features/deps/cpu_features/test/filesystem_for_testing.h +0 -61
  174. package/node_modules/cpu-features/deps/cpu_features/test/hwcaps_for_testing.cc +0 -52
  175. package/node_modules/cpu-features/deps/cpu_features/test/hwcaps_for_testing.h +0 -31
  176. package/node_modules/cpu-features/deps/cpu_features/test/stack_line_reader_test.cc +0 -132
  177. package/node_modules/cpu-features/deps/cpu_features/test/string_view_test.cc +0 -202
  178. package/node_modules/cpu-features/lib/index.js +0 -5
  179. package/node_modules/cpu-features/package.json +0 -40
  180. package/node_modules/cpu-features/src/binding.cc +0 -151
  181. package/node_modules/cpu-features/test/test.js +0 -12
@@ -1,68 +0,0 @@
1
- // Copyright 2017 Google LLC
2
- //
3
- // Licensed under the Apache License, Version 2.0 (the "License");
4
- // you may not use this file except in compliance with the License.
5
- // You may obtain a copy of the License at
6
- //
7
- // http://www.apache.org/licenses/LICENSE-2.0
8
- //
9
- // Unless required by applicable law or agreed to in writing, software
10
- // distributed under the License is distributed on an "AS IS" BASIS,
11
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- // See the License for the specific language governing permissions and
13
- // limitations under the License.
14
-
15
- #include "cpu_features_macros.h"
16
-
17
- #ifdef CPU_FEATURES_ARCH_X86
18
- #ifdef CPU_FEATURES_OS_FREEBSD
19
-
20
- #include "impl_x86__base_implementation.inl"
21
-
22
- static void OverrideOsPreserves(OsPreserves* os_preserves) {
23
- (void)os_preserves;
24
- // No override
25
- }
26
-
27
- #include "internal/filesystem.h"
28
- #include "internal/stack_line_reader.h"
29
- #include "internal/string_view.h"
30
-
31
- static void DetectFeaturesFromOs(X86Info* info, X86Features* features) {
32
- (void)info;
33
- // Handling FreeBSD platform through parsing /var/run/dmesg.boot.
34
- const int fd = CpuFeatures_OpenFile("/var/run/dmesg.boot");
35
- if (fd >= 0) {
36
- StackLineReader reader;
37
- StackLineReader_Initialize(&reader, fd);
38
- for (bool stop = false; !stop;) {
39
- const LineResult result = StackLineReader_NextLine(&reader);
40
- if (result.eof) stop = true;
41
- const StringView line = result.line;
42
- if (!CpuFeatures_StringView_StartsWith(line, str(" Features"))) continue;
43
- // Lines of interests are of the following form:
44
- // " Features=0x1783fbff<PSE36,MMX,FXSR,SSE,SSE2,HTT>"
45
- // We first extract the comma separated values between angle brackets.
46
- StringView csv = result.line;
47
- int index = CpuFeatures_StringView_IndexOfChar(csv, '<');
48
- if (index >= 0) csv = CpuFeatures_StringView_PopFront(csv, index + 1);
49
- if (csv.size > 0 && CpuFeatures_StringView_Back(csv) == '>')
50
- csv = CpuFeatures_StringView_PopBack(csv, 1);
51
- if (CpuFeatures_StringView_HasWord(csv, "SSE", ',')) features->sse = true;
52
- if (CpuFeatures_StringView_HasWord(csv, "SSE2", ','))
53
- features->sse2 = true;
54
- if (CpuFeatures_StringView_HasWord(csv, "SSE3", ','))
55
- features->sse3 = true;
56
- if (CpuFeatures_StringView_HasWord(csv, "SSSE3", ','))
57
- features->ssse3 = true;
58
- if (CpuFeatures_StringView_HasWord(csv, "SSE4.1", ','))
59
- features->sse4_1 = true;
60
- if (CpuFeatures_StringView_HasWord(csv, "SSE4.2", ','))
61
- features->sse4_2 = true;
62
- }
63
- CpuFeatures_CloseFile(fd);
64
- }
65
- }
66
-
67
- #endif // CPU_FEATURES_OS_FREEBSD
68
- #endif // CPU_FEATURES_ARCH_X86
@@ -1,58 +0,0 @@
1
- // Copyright 2017 Google LLC
2
- //
3
- // Licensed under the Apache License, Version 2.0 (the "License");
4
- // you may not use this file except in compliance with the License.
5
- // You may obtain a copy of the License at
6
- //
7
- // http://www.apache.org/licenses/LICENSE-2.0
8
- //
9
- // Unless required by applicable law or agreed to in writing, software
10
- // distributed under the License is distributed on an "AS IS" BASIS,
11
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- // See the License for the specific language governing permissions and
13
- // limitations under the License.
14
-
15
- #include "cpu_features_macros.h"
16
-
17
- #ifdef CPU_FEATURES_ARCH_X86
18
- #if defined(CPU_FEATURES_OS_LINUX) || defined(CPU_FEATURES_OS_ANDROID)
19
-
20
- #include "impl_x86__base_implementation.inl"
21
-
22
- static void OverrideOsPreserves(OsPreserves* os_preserves) {
23
- (void)os_preserves;
24
- // No override
25
- }
26
-
27
- #include "internal/filesystem.h"
28
- #include "internal/stack_line_reader.h"
29
- #include "internal/string_view.h"
30
- static void DetectFeaturesFromOs(X86Info* info, X86Features* features) {
31
- (void)info;
32
- // Handling Linux platform through /proc/cpuinfo.
33
- const int fd = CpuFeatures_OpenFile("/proc/cpuinfo");
34
- if (fd >= 0) {
35
- StackLineReader reader;
36
- StackLineReader_Initialize(&reader, fd);
37
- for (bool stop = false; !stop;) {
38
- const LineResult result = StackLineReader_NextLine(&reader);
39
- if (result.eof) stop = true;
40
- const StringView line = result.line;
41
- StringView key, value;
42
- if (!CpuFeatures_StringView_GetAttributeKeyValue(line, &key, &value))
43
- continue;
44
- if (!CpuFeatures_StringView_IsEquals(key, str("flags"))) continue;
45
- features->sse = CpuFeatures_StringView_HasWord(value, "sse", ' ');
46
- features->sse2 = CpuFeatures_StringView_HasWord(value, "sse2", ' ');
47
- features->sse3 = CpuFeatures_StringView_HasWord(value, "pni", ' ');
48
- features->ssse3 = CpuFeatures_StringView_HasWord(value, "ssse3", ' ');
49
- features->sse4_1 = CpuFeatures_StringView_HasWord(value, "sse4_1", ' ');
50
- features->sse4_2 = CpuFeatures_StringView_HasWord(value, "sse4_2", ' ');
51
- break;
52
- }
53
- CpuFeatures_CloseFile(fd);
54
- }
55
- }
56
-
57
- #endif // defined(CPU_FEATURES_OS_LINUX) || defined(CPU_FEATURES_OS_ANDROID)
58
- #endif // CPU_FEATURES_ARCH_X86
@@ -1,57 +0,0 @@
1
- // Copyright 2017 Google LLC
2
- //
3
- // Licensed under the Apache License, Version 2.0 (the "License");
4
- // you may not use this file except in compliance with the License.
5
- // You may obtain a copy of the License at
6
- //
7
- // http://www.apache.org/licenses/LICENSE-2.0
8
- //
9
- // Unless required by applicable law or agreed to in writing, software
10
- // distributed under the License is distributed on an "AS IS" BASIS,
11
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- // See the License for the specific language governing permissions and
13
- // limitations under the License.
14
-
15
- #include "cpu_features_macros.h"
16
-
17
- #ifdef CPU_FEATURES_ARCH_X86
18
- #ifdef CPU_FEATURES_OS_MACOS
19
-
20
- #include "impl_x86__base_implementation.inl"
21
-
22
- #if !defined(HAVE_SYSCTLBYNAME)
23
- #error "Darwin needs support for sysctlbyname"
24
- #endif
25
- #include <sys/sysctl.h>
26
-
27
- #if defined(CPU_FEATURES_MOCK_CPUID_X86)
28
- extern bool GetDarwinSysCtlByName(const char*);
29
- #else // CPU_FEATURES_MOCK_CPUID_X86
30
- static bool GetDarwinSysCtlByName(const char* name) {
31
- int enabled;
32
- size_t enabled_len = sizeof(enabled);
33
- const int failure = sysctlbyname(name, &enabled, &enabled_len, NULL, 0);
34
- return failure ? false : enabled;
35
- }
36
- #endif
37
-
38
- static void OverrideOsPreserves(OsPreserves* os_preserves) {
39
- // On Darwin AVX512 support is On-demand.
40
- // We have to query the OS instead of querying the Zmm save/restore state.
41
- // https://github.com/apple/darwin-xnu/blob/8f02f2a044b9bb1ad951987ef5bab20ec9486310/osfmk/i386/fpu.c#L173-L199
42
- os_preserves->avx512_registers = GetDarwinSysCtlByName("hw.optional.avx512f");
43
- }
44
-
45
- static void DetectFeaturesFromOs(X86Info* info, X86Features* features) {
46
- (void)info;
47
- // Handling Darwin platform through sysctlbyname.
48
- features->sse = GetDarwinSysCtlByName("hw.optional.sse");
49
- features->sse2 = GetDarwinSysCtlByName("hw.optional.sse2");
50
- features->sse3 = GetDarwinSysCtlByName("hw.optional.sse3");
51
- features->ssse3 = GetDarwinSysCtlByName("hw.optional.supplementalsse3");
52
- features->sse4_1 = GetDarwinSysCtlByName("hw.optional.sse4_1");
53
- features->sse4_2 = GetDarwinSysCtlByName("hw.optional.sse4_2");
54
- }
55
-
56
- #endif // CPU_FEATURES_OS_MACOS
57
- #endif // CPU_FEATURES_ARCH_X86
@@ -1,58 +0,0 @@
1
- // Copyright 2017 Google LLC
2
- //
3
- // Licensed under the Apache License, Version 2.0 (the "License");
4
- // you may not use this file except in compliance with the License.
5
- // You may obtain a copy of the License at
6
- //
7
- // http://www.apache.org/licenses/LICENSE-2.0
8
- //
9
- // Unless required by applicable law or agreed to in writing, software
10
- // distributed under the License is distributed on an "AS IS" BASIS,
11
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- // See the License for the specific language governing permissions and
13
- // limitations under the License.
14
-
15
- #include "cpu_features_macros.h"
16
-
17
- #ifdef CPU_FEATURES_ARCH_X86
18
- #ifdef CPU_FEATURES_OS_WINDOWS
19
-
20
- #include "impl_x86__base_implementation.inl"
21
-
22
- static void OverrideOsPreserves(OsPreserves* os_preserves) {
23
- (void)os_preserves;
24
- // No override
25
- }
26
-
27
- #include "internal/windows_utils.h"
28
-
29
- #if defined(CPU_FEATURES_MOCK_CPUID_X86)
30
- extern bool GetWindowsIsProcessorFeaturePresent(DWORD);
31
- #else // CPU_FEATURES_MOCK_CPUID_X86
32
- static bool GetWindowsIsProcessorFeaturePresent(DWORD ProcessorFeature) {
33
- return IsProcessorFeaturePresent(ProcessorFeature);
34
- }
35
- #endif
36
-
37
- static void DetectFeaturesFromOs(X86Info* info, X86Features* features) {
38
- // Handling Windows platform through IsProcessorFeaturePresent.
39
- // https://docs.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-isprocessorfeaturepresent
40
- features->sse =
41
- GetWindowsIsProcessorFeaturePresent(PF_XMMI_INSTRUCTIONS_AVAILABLE);
42
- features->sse2 =
43
- GetWindowsIsProcessorFeaturePresent(PF_XMMI64_INSTRUCTIONS_AVAILABLE);
44
- features->sse3 =
45
- GetWindowsIsProcessorFeaturePresent(PF_SSE3_INSTRUCTIONS_AVAILABLE);
46
- features->ssse3 =
47
- GetWindowsIsProcessorFeaturePresent(PF_SSSE3_INSTRUCTIONS_AVAILABLE);
48
- features->sse4_1 =
49
- GetWindowsIsProcessorFeaturePresent(PF_SSE4_1_INSTRUCTIONS_AVAILABLE);
50
- features->sse4_2 =
51
- GetWindowsIsProcessorFeaturePresent(PF_SSE4_2_INSTRUCTIONS_AVAILABLE);
52
-
53
- // do not bother checking PF_AVX*
54
- // cause AVX enabled processor will have XCR0 be exposed and this function will be skipped at all
55
- }
56
-
57
- #endif // CPU_FEATURES_OS_WINDOWS
58
- #endif // CPU_FEATURES_ARCH_X86
@@ -1,132 +0,0 @@
1
- // Copyright 2017 Google LLC
2
- //
3
- // Licensed under the Apache License, Version 2.0 (the "License");
4
- // you may not use this file except in compliance with the License.
5
- // You may obtain a copy of the License at
6
- //
7
- // http://www.apache.org/licenses/LICENSE-2.0
8
- //
9
- // Unless required by applicable law or agreed to in writing, software
10
- // distributed under the License is distributed on an "AS IS" BASIS,
11
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- // See the License for the specific language governing permissions and
13
- // limitations under the License.
14
-
15
- #include "internal/stack_line_reader.h"
16
-
17
- #include <assert.h>
18
- #include <errno.h>
19
- #include <stdio.h>
20
-
21
- #include "internal/filesystem.h"
22
-
23
- void StackLineReader_Initialize(StackLineReader* reader, int fd) {
24
- reader->view.ptr = reader->buffer;
25
- reader->view.size = 0;
26
- reader->skip_mode = false;
27
- reader->fd = fd;
28
- }
29
-
30
- // Replaces the content of buffer with bytes from the file.
31
- static int LoadFullBuffer(StackLineReader* reader) {
32
- const int read = CpuFeatures_ReadFile(reader->fd, reader->buffer,
33
- STACK_LINE_READER_BUFFER_SIZE);
34
- assert(read >= 0);
35
- reader->view.ptr = reader->buffer;
36
- reader->view.size = read;
37
- return read;
38
- }
39
-
40
- // Appends with bytes from the file to buffer, filling the remaining space.
41
- static int LoadMore(StackLineReader* reader) {
42
- char* const ptr = reader->buffer + reader->view.size;
43
- const size_t size_to_read = STACK_LINE_READER_BUFFER_SIZE - reader->view.size;
44
- const int read = CpuFeatures_ReadFile(reader->fd, ptr, size_to_read);
45
- assert(read >= 0);
46
- assert(read <= (int)size_to_read);
47
- reader->view.size += read;
48
- return read;
49
- }
50
-
51
- static int IndexOfEol(StackLineReader* reader) {
52
- return CpuFeatures_StringView_IndexOfChar(reader->view, '\n');
53
- }
54
-
55
- // Relocate buffer's pending bytes at the beginning of the array and fills the
56
- // remaining space with bytes from the file.
57
- static int BringToFrontAndLoadMore(StackLineReader* reader) {
58
- if (reader->view.size && reader->view.ptr != reader->buffer) {
59
- memmove(reader->buffer, reader->view.ptr, reader->view.size);
60
- }
61
- reader->view.ptr = reader->buffer;
62
- return LoadMore(reader);
63
- }
64
-
65
- // Loads chunks of buffer size from disks until it contains a newline character
66
- // or end of file.
67
- static void SkipToNextLine(StackLineReader* reader) {
68
- for (;;) {
69
- const int read = LoadFullBuffer(reader);
70
- if (read == 0) {
71
- break;
72
- } else {
73
- const int eol_index = IndexOfEol(reader);
74
- if (eol_index >= 0) {
75
- reader->view =
76
- CpuFeatures_StringView_PopFront(reader->view, eol_index + 1);
77
- break;
78
- }
79
- }
80
- }
81
- }
82
-
83
- static LineResult CreateLineResult(bool eof, bool full_line, StringView view) {
84
- LineResult result;
85
- result.eof = eof;
86
- result.full_line = full_line;
87
- result.line = view;
88
- return result;
89
- }
90
-
91
- // Helper methods to provide clearer semantic in StackLineReader_NextLine.
92
- static LineResult CreateEOFLineResult(StringView view) {
93
- return CreateLineResult(true, true, view);
94
- }
95
-
96
- static LineResult CreateTruncatedLineResult(StringView view) {
97
- return CreateLineResult(false, false, view);
98
- }
99
-
100
- static LineResult CreateValidLineResult(StringView view) {
101
- return CreateLineResult(false, true, view);
102
- }
103
-
104
- LineResult StackLineReader_NextLine(StackLineReader* reader) {
105
- if (reader->skip_mode) {
106
- SkipToNextLine(reader);
107
- reader->skip_mode = false;
108
- }
109
- {
110
- const bool can_load_more =
111
- reader->view.size < STACK_LINE_READER_BUFFER_SIZE;
112
- int eol_index = IndexOfEol(reader);
113
- if (eol_index < 0 && can_load_more) {
114
- const int read = BringToFrontAndLoadMore(reader);
115
- if (read == 0) {
116
- return CreateEOFLineResult(reader->view);
117
- }
118
- eol_index = IndexOfEol(reader);
119
- }
120
- if (eol_index < 0) {
121
- reader->skip_mode = true;
122
- return CreateTruncatedLineResult(reader->view);
123
- }
124
- {
125
- StringView line =
126
- CpuFeatures_StringView_KeepFront(reader->view, eol_index);
127
- reader->view =
128
- CpuFeatures_StringView_PopFront(reader->view, eol_index + 1);
129
- return CreateValidLineResult(line);
130
- }
131
- }
132
- }
@@ -1,192 +0,0 @@
1
- // Copyright 2017 Google LLC
2
- //
3
- // Licensed under the Apache License, Version 2.0 (the "License");
4
- // you may not use this file except in compliance with the License.
5
- // You may obtain a copy of the License at
6
- //
7
- // http://www.apache.org/licenses/LICENSE-2.0
8
- //
9
- // Unless required by applicable law or agreed to in writing, software
10
- // distributed under the License is distributed on an "AS IS" BASIS,
11
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- // See the License for the specific language governing permissions and
13
- // limitations under the License.
14
-
15
- #include "internal/string_view.h"
16
-
17
- #include <assert.h>
18
- #include <ctype.h>
19
-
20
- #include "copy.inl"
21
- #include "equals.inl"
22
-
23
- static const char* CpuFeatures_memchr(const char* const ptr, const size_t size,
24
- const char c) {
25
- for (size_t i = 0; ptr && ptr[i] != '\0' && i < size; ++i)
26
- if (ptr[i] == c) return ptr + i;
27
- return NULL;
28
- }
29
-
30
- int CpuFeatures_StringView_IndexOfChar(const StringView view, char c) {
31
- if (view.ptr && view.size) {
32
- const char* const found = CpuFeatures_memchr(view.ptr, view.size, c);
33
- if (found) {
34
- return (int)(found - view.ptr);
35
- }
36
- }
37
- return -1;
38
- }
39
-
40
- int CpuFeatures_StringView_IndexOf(const StringView view,
41
- const StringView sub_view) {
42
- if (sub_view.size) {
43
- StringView remainder = view;
44
- while (remainder.size >= sub_view.size) {
45
- const int found_index =
46
- CpuFeatures_StringView_IndexOfChar(remainder, sub_view.ptr[0]);
47
- if (found_index < 0) break;
48
- remainder = CpuFeatures_StringView_PopFront(remainder, found_index);
49
- if (CpuFeatures_StringView_StartsWith(remainder, sub_view)) {
50
- return (int)(remainder.ptr - view.ptr);
51
- }
52
- remainder = CpuFeatures_StringView_PopFront(remainder, 1);
53
- }
54
- }
55
- return -1;
56
- }
57
-
58
- bool CpuFeatures_StringView_IsEquals(const StringView a, const StringView b) {
59
- if (a.size == b.size) {
60
- return a.ptr == b.ptr || equals(a.ptr, b.ptr, b.size);
61
- }
62
- return false;
63
- }
64
-
65
- bool CpuFeatures_StringView_StartsWith(const StringView a, const StringView b) {
66
- return a.ptr && b.ptr && b.size && a.size >= b.size
67
- ? equals(a.ptr, b.ptr, b.size)
68
- : false;
69
- }
70
-
71
- StringView CpuFeatures_StringView_PopFront(const StringView str_view,
72
- size_t count) {
73
- if (count > str_view.size) {
74
- return kEmptyStringView;
75
- }
76
- return view(str_view.ptr + count, str_view.size - count);
77
- }
78
-
79
- StringView CpuFeatures_StringView_PopBack(const StringView str_view,
80
- size_t count) {
81
- if (count > str_view.size) {
82
- return kEmptyStringView;
83
- }
84
- return view(str_view.ptr, str_view.size - count);
85
- }
86
-
87
- StringView CpuFeatures_StringView_KeepFront(const StringView str_view,
88
- size_t count) {
89
- return count <= str_view.size ? view(str_view.ptr, count) : str_view;
90
- }
91
-
92
- char CpuFeatures_StringView_Front(const StringView view) {
93
- assert(view.size);
94
- assert(view.ptr);
95
- return view.ptr[0];
96
- }
97
-
98
- char CpuFeatures_StringView_Back(const StringView view) {
99
- assert(view.size);
100
- return view.ptr[view.size - 1];
101
- }
102
-
103
- StringView CpuFeatures_StringView_TrimWhitespace(StringView view) {
104
- while (view.size && isspace(CpuFeatures_StringView_Front(view)))
105
- view = CpuFeatures_StringView_PopFront(view, 1);
106
- while (view.size && isspace(CpuFeatures_StringView_Back(view)))
107
- view = CpuFeatures_StringView_PopBack(view, 1);
108
- return view;
109
- }
110
-
111
- static int HexValue(const char c) {
112
- if (c >= '0' && c <= '9') return c - '0';
113
- if (c >= 'a' && c <= 'f') return c - 'a' + 10;
114
- if (c >= 'A' && c <= 'F') return c - 'A' + 10;
115
- return -1;
116
- }
117
-
118
- // Returns -1 if view contains non digits.
119
- static int ParsePositiveNumberWithBase(const StringView view, int base) {
120
- int result = 0;
121
- StringView remainder = view;
122
- for (; remainder.size;
123
- remainder = CpuFeatures_StringView_PopFront(remainder, 1)) {
124
- const int value = HexValue(CpuFeatures_StringView_Front(remainder));
125
- if (value < 0 || value >= base) return -1;
126
- result = (result * base) + value;
127
- }
128
- return result;
129
- }
130
-
131
- int CpuFeatures_StringView_ParsePositiveNumber(const StringView view) {
132
- if (view.size) {
133
- const StringView hex_prefix = str("0x");
134
- if (CpuFeatures_StringView_StartsWith(view, hex_prefix)) {
135
- const StringView span_no_prefix =
136
- CpuFeatures_StringView_PopFront(view, hex_prefix.size);
137
- return ParsePositiveNumberWithBase(span_no_prefix, 16);
138
- }
139
- return ParsePositiveNumberWithBase(view, 10);
140
- }
141
- return -1;
142
- }
143
-
144
- void CpuFeatures_StringView_CopyString(const StringView src, char* dst,
145
- size_t dst_size) {
146
- if (dst_size > 0) {
147
- const size_t max_copy_size = dst_size - 1;
148
- const size_t copy_size =
149
- src.size > max_copy_size ? max_copy_size : src.size;
150
- copy(dst, src.ptr, copy_size);
151
- dst[copy_size] = '\0';
152
- }
153
- }
154
-
155
- bool CpuFeatures_StringView_HasWord(const StringView line,
156
- const char* const word_str,
157
- const char separator) {
158
- const StringView word = str(word_str);
159
- StringView remainder = line;
160
- for (;;) {
161
- const int index_of_word = CpuFeatures_StringView_IndexOf(remainder, word);
162
- if (index_of_word < 0) {
163
- return false;
164
- } else {
165
- const StringView before =
166
- CpuFeatures_StringView_KeepFront(line, index_of_word);
167
- const StringView after =
168
- CpuFeatures_StringView_PopFront(line, index_of_word + word.size);
169
- const bool valid_before =
170
- before.size == 0 || CpuFeatures_StringView_Back(before) == separator;
171
- const bool valid_after =
172
- after.size == 0 || CpuFeatures_StringView_Front(after) == separator;
173
- if (valid_before && valid_after) return true;
174
- remainder =
175
- CpuFeatures_StringView_PopFront(remainder, index_of_word + word.size);
176
- }
177
- }
178
- return false;
179
- }
180
-
181
- bool CpuFeatures_StringView_GetAttributeKeyValue(const StringView line,
182
- StringView* key,
183
- StringView* value) {
184
- const StringView sep = str(": ");
185
- const int index_of_separator = CpuFeatures_StringView_IndexOf(line, sep);
186
- if (index_of_separator < 0) return false;
187
- *value = CpuFeatures_StringView_TrimWhitespace(
188
- CpuFeatures_StringView_PopFront(line, index_of_separator + sep.size));
189
- *key = CpuFeatures_StringView_TrimWhitespace(
190
- CpuFeatures_StringView_KeepFront(line, index_of_separator));
191
- return true;
192
- }