authorgravatar for Auguste.rame@gmail.comAuguste Rame <Auguste.rame@gmail.com> 2020-04-10 11:49:50-04:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2020-04-10 11:49:50-04:00
logdf14578c9d3c7f455c7710ecc9bafe56eb0ec826
tree2501b90c7263cf662f64190e43aa66ba307eb15f
parent116c76cf82cd9e7ea3018e36dd9756f2f063143d
parent4871345545ec9655a14d0bfe32668eda210953f7
signaturebadge-question-mark Signed by PGP key 4AEE18F83AFDEB23

Merge branch 'master' into nameless-fields


129 files changed, 5871 insertions(+), 1168 deletions(-)

.gitattributes+11-9
...@@ -1,9 +1,11 @@...@@ -1,9 +1,11 @@
1*.zig text eol=lf 1*.zig text eol=lf
2*.txt text eol=lf 2*.txt text eol=lf
3langref.html.in text eol=lf 3langref.html.in text eol=lf
4 4deps/SoftFloat-3e/*.txt text eol=crlf
5deps/* linguist-vendored 5
6lib/include/* linguist-vendored 6deps/* linguist-vendored
7lib/libc/* linguist-vendored 7lib/include/* linguist-vendored
8lib/libcxx/* linguist-vendored 8lib/libc/* linguist-vendored
9lib/libunwind/* linguist-vendored 9lib/libcxx/* linguist-vendored
10lib/libcxxabi/* linguist-vendored
11lib/libunwind/* linguist-vendored
CMakeLists.txt+7-9
...@@ -46,6 +46,7 @@ message("Configuring zig version ${ZIG_VERSION}")...@@ -46,6 +46,7 @@ message("Configuring zig version ${ZIG_VERSION}")
46set(ZIG_STATIC off CACHE BOOL "Attempt to build a static zig executable (not compatible with glibc)")46set(ZIG_STATIC off CACHE BOOL "Attempt to build a static zig executable (not compatible with glibc)")
47set(ZIG_STATIC_LLVM off CACHE BOOL "Prefer linking against static LLVM libraries")47set(ZIG_STATIC_LLVM off CACHE BOOL "Prefer linking against static LLVM libraries")
48set(ZIG_ENABLE_MEM_PROFILE off CACHE BOOL "Activate memory usage instrumentation")48set(ZIG_ENABLE_MEM_PROFILE off CACHE BOOL "Activate memory usage instrumentation")
49set(ZIG_PREFER_CLANG_CPP_DYLIB off CACHE BOOL "Try to link against -lclang-cpp")
4950
50if(ZIG_STATIC)51if(ZIG_STATIC)
51 set(ZIG_STATIC_LLVM "on")52 set(ZIG_STATIC_LLVM "on")
...@@ -63,6 +64,7 @@ option(ZIG_TEST_COVERAGE "Build Zig with test coverage instrumentation" OFF)...@@ -63,6 +64,7 @@ option(ZIG_TEST_COVERAGE "Build Zig with test coverage instrumentation" OFF)
63option(ZIG_FORCE_EXTERNAL_LLD "does nothing" OFF)64option(ZIG_FORCE_EXTERNAL_LLD "does nothing" OFF)
6465
65set(ZIG_TARGET_TRIPLE "native" CACHE STRING "arch-os-abi to output binaries for")66set(ZIG_TARGET_TRIPLE "native" CACHE STRING "arch-os-abi to output binaries for")
67set(ZIG_TARGET_MCPU "baseline" CACHE STRING "-mcpu parameter to output binaries for")
66set(ZIG_EXECUTABLE "" CACHE STRING "(when cross compiling) path to already-built zig binary")68set(ZIG_EXECUTABLE "" CACHE STRING "(when cross compiling) path to already-built zig binary")
6769
68find_package(llvm)70find_package(llvm)
...@@ -303,9 +305,10 @@ set(LIBC_FILES_DEST "${ZIG_LIB_DIR}/libc")...@@ -303,9 +305,10 @@ set(LIBC_FILES_DEST "${ZIG_LIB_DIR}/libc")
303set(LIBUNWIND_FILES_DEST "${ZIG_LIB_DIR}/libunwind")305set(LIBUNWIND_FILES_DEST "${ZIG_LIB_DIR}/libunwind")
304set(LIBCXX_FILES_DEST "${ZIG_LIB_DIR}/libcxx")306set(LIBCXX_FILES_DEST "${ZIG_LIB_DIR}/libcxx")
305set(ZIG_STD_DEST "${ZIG_LIB_DIR}/std")307set(ZIG_STD_DEST "${ZIG_LIB_DIR}/std")
308set(ZIG_CONFIG_H_OUT "${CMAKE_BINARY_DIR}/config.h")
306configure_file (309configure_file (
307 "${CMAKE_SOURCE_DIR}/src/config.h.in"310 "${CMAKE_SOURCE_DIR}/src/config.h.in"
308 "${CMAKE_BINARY_DIR}/config.h"311 "${ZIG_CONFIG_H_OUT}"
309)312)
310313
311include_directories(314include_directories(
...@@ -364,7 +367,7 @@ if(ZIG_STATIC)...@@ -364,7 +367,7 @@ if(ZIG_STATIC)
364 endif()367 endif()
365else()368else()
366 if(MINGW)369 if(MINGW)
367 set(EXE_LDFLAGS "${EXE_LDFLAGS} -lz3")370 set(EXE_LDFLAGS "${EXE_LDFLAGS}")
368 endif()371 endif()
369endif()372endif()
370373
...@@ -428,16 +431,11 @@ if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")...@@ -428,16 +431,11 @@ if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
428else()431else()
429 set(LIBSTAGE2_RELEASE_ARG --release-fast --strip)432 set(LIBSTAGE2_RELEASE_ARG --release-fast --strip)
430endif()433endif()
431if(WIN32)
432 set(LIBSTAGE2_WINDOWS_ARGS "-lntdll")
433else()
434 set(LIBSTAGE2_WINDOWS_ARGS "")
435endif()
436434
437set(BUILD_LIBSTAGE2_ARGS "build-lib"435set(BUILD_LIBSTAGE2_ARGS "build-lib"
438 "src-self-hosted/stage2.zig"436 "src-self-hosted/stage2.zig"
439 -target "${ZIG_TARGET_TRIPLE}"437 -target "${ZIG_TARGET_TRIPLE}"
440 -mcpu=baseline438 "-mcpu=${ZIG_TARGET_MCPU}"
441 --name zigstage2439 --name zigstage2
442 --override-lib-dir "${CMAKE_SOURCE_DIR}/lib"440 --override-lib-dir "${CMAKE_SOURCE_DIR}/lib"
443 --cache on441 --cache on
...@@ -446,7 +444,6 @@ set(BUILD_LIBSTAGE2_ARGS "build-lib"...@@ -446,7 +444,6 @@ set(BUILD_LIBSTAGE2_ARGS "build-lib"
446 --bundle-compiler-rt444 --bundle-compiler-rt
447 -fPIC445 -fPIC
448 -lc446 -lc
449 ${LIBSTAGE2_WINDOWS_ARGS}
450)447)
451448
452if("${ZIG_TARGET_TRIPLE}" STREQUAL "native")449if("${ZIG_TARGET_TRIPLE}" STREQUAL "native")
...@@ -485,6 +482,7 @@ set(ZIG_INSTALL_ARGS "build"...@@ -485,6 +482,7 @@ set(ZIG_INSTALL_ARGS "build"
485 --override-lib-dir "${CMAKE_SOURCE_DIR}/lib"482 --override-lib-dir "${CMAKE_SOURCE_DIR}/lib"
486 "-Dlib-files-only"483 "-Dlib-files-only"
487 --prefix "${CMAKE_INSTALL_PREFIX}"484 --prefix "${CMAKE_INSTALL_PREFIX}"
485 "-Dconfig_h=${ZIG_CONFIG_H_OUT}"
488 install486 install
489)487)
490488
README.md+1-1
...@@ -58,7 +58,7 @@ brew install cmake llvm...@@ -58,7 +58,7 @@ brew install cmake llvm
58brew outdated llvm || brew upgrade llvm58brew outdated llvm || brew upgrade llvm
59mkdir build59mkdir build
60cd build60cd build
61cmake .. -DCMAKE_PREFIX_PATH=$(brew --prefix llvm)61cmake .. -DCMAKE_PREFIX_PATH=$(brew --prefix llvm) -DZIG_PREFER_CLANG_CPP_DYLIB=ON
62make install62make install
63```63```
6464
build.zig+108-41
...@@ -34,23 +34,14 @@ pub fn build(b: *Builder) !void {...@@ -34,23 +34,14 @@ pub fn build(b: *Builder) !void {
3434
35 const test_step = b.step("test", "Run all the tests");35 const test_step = b.step("test", "Run all the tests");
3636
37 // find the stage0 build artifacts because we're going to re-use config.h and zig_cpp library37 const config_h_text = if (b.option(
38 const build_info = try b.exec(&[_][]const u8{38 []const u8,
39 b.zig_exe,39 "config_h",
40 "BUILD_INFO",40 "Path to the generated config.h",
41 });41 )) |config_h_path|
42 var index: usize = 0;42 try std.fs.cwd().readFileAlloc(b.allocator, toNativePathSep(b, config_h_path), max_config_h_bytes)
43 var ctx = Context{43 else
44 .cmake_binary_dir = nextValue(&index, build_info),44 try findAndReadConfigH(b);
45 .cxx_compiler = nextValue(&index, build_info),
46 .llvm_config_exe = nextValue(&index, build_info),
47 .lld_include_dir = nextValue(&index, build_info),
48 .lld_libraries = nextValue(&index, build_info),
49 .clang_libraries = nextValue(&index, build_info),
50 .dia_guids_lib = nextValue(&index, build_info),
51 .llvm = undefined,
52 };
53 ctx.llvm = try findLLVM(b, ctx.llvm_config_exe);
5445
55 var test_stage2 = b.addTest("src-self-hosted/test.zig");46 var test_stage2 = b.addTest("src-self-hosted/test.zig");
56 test_stage2.setBuildMode(builtin.Mode.Debug);47 test_stage2.setBuildMode(builtin.Mode.Debug);
...@@ -61,9 +52,6 @@ pub fn build(b: *Builder) !void {...@@ -61,9 +52,6 @@ pub fn build(b: *Builder) !void {
61 var exe = b.addExecutable("zig", "src-self-hosted/main.zig");52 var exe = b.addExecutable("zig", "src-self-hosted/main.zig");
62 exe.setBuildMode(mode);53 exe.setBuildMode(mode);
6354
64 try configureStage2(b, test_stage2, ctx);
65 try configureStage2(b, exe, ctx);
66
67 const skip_release = b.option(bool, "skip-release", "Main test suite skips release builds") orelse false;55 const skip_release = b.option(bool, "skip-release", "Main test suite skips release builds") orelse false;
68 const skip_release_small = b.option(bool, "skip-release-small", "Main test suite skips release-small builds") orelse skip_release;56 const skip_release_small = b.option(bool, "skip-release-small", "Main test suite skips release-small builds") orelse skip_release;
69 const skip_release_fast = b.option(bool, "skip-release-fast", "Main test suite skips release-fast builds") orelse skip_release;57 const skip_release_fast = b.option(bool, "skip-release-fast", "Main test suite skips release-fast builds") orelse skip_release;
...@@ -77,6 +65,12 @@ pub fn build(b: *Builder) !void {...@@ -77,6 +65,12 @@ pub fn build(b: *Builder) !void {
7765
78 const only_install_lib_files = b.option(bool, "lib-files-only", "Only install library files") orelse false;66 const only_install_lib_files = b.option(bool, "lib-files-only", "Only install library files") orelse false;
79 if (!only_install_lib_files and !skip_self_hosted) {67 if (!only_install_lib_files and !skip_self_hosted) {
68 var ctx = parseConfigH(b, config_h_text);
69 ctx.llvm = try findLLVM(b, ctx.llvm_config_exe);
70
71 try configureStage2(b, test_stage2, ctx);
72 try configureStage2(b, exe, ctx);
73
80 b.default_step.dependOn(&exe.step);74 b.default_step.dependOn(&exe.step);
81 exe.install();75 exe.install();
82 }76 }
...@@ -231,10 +225,11 @@ fn findLLVM(b: *Builder, llvm_config_exe: []const u8) !LibraryDep {...@@ -231,10 +225,11 @@ fn findLLVM(b: *Builder, llvm_config_exe: []const u8) !LibraryDep {
231 if (fs.path.isAbsolute(lib_arg)) {225 if (fs.path.isAbsolute(lib_arg)) {
232 try result.libs.append(lib_arg);226 try result.libs.append(lib_arg);
233 } else {227 } else {
228 var lib_arg_copy = lib_arg;
234 if (mem.endsWith(u8, lib_arg, ".lib")) {229 if (mem.endsWith(u8, lib_arg, ".lib")) {
235 lib_arg = lib_arg[0 .. lib_arg.len - 4];230 lib_arg_copy = lib_arg[0 .. lib_arg.len - 4];
236 }231 }
237 try result.system_libs.append(lib_arg);232 try result.system_libs.append(lib_arg_copy);
238 }233 }
239 }234 }
240 }235 }
...@@ -262,25 +257,6 @@ fn findLLVM(b: *Builder, llvm_config_exe: []const u8) !LibraryDep {...@@ -262,25 +257,6 @@ fn findLLVM(b: *Builder, llvm_config_exe: []const u8) !LibraryDep {
262 return result;257 return result;
263}258}
264259
265fn nextValue(index: *usize, build_info: []const u8) []const u8 {
266 const start = index.*;
267 while (true) : (index.* += 1) {
268 switch (build_info[index.*]) {
269 '\n' => {
270 const result = build_info[start..index.*];
271 index.* += 1;
272 return result;
273 },
274 '\r' => {
275 const result = build_info[start..index.*];
276 index.* += 2;
277 return result;
278 },
279 else => continue,
280 }
281 }
282}
283
284fn configureStage2(b: *Builder, exe: var, ctx: Context) !void {260fn configureStage2(b: *Builder, exe: var, ctx: Context) !void {
285 exe.addIncludeDir("src");261 exe.addIncludeDir("src");
286 exe.addIncludeDir(ctx.cmake_binary_dir);262 exe.addIncludeDir(ctx.cmake_binary_dir);
...@@ -376,3 +352,94 @@ const Context = struct {...@@ -376,3 +352,94 @@ const Context = struct {
376 dia_guids_lib: []const u8,352 dia_guids_lib: []const u8,
377 llvm: LibraryDep,353 llvm: LibraryDep,
378};354};
355
356const max_config_h_bytes = 1 * 1024 * 1024;
357
358fn findAndReadConfigH(b: *Builder) ![]const u8 {
359 var check_dir = fs.path.dirname(b.zig_exe).?;
360 while (true) {
361 var dir = try fs.cwd().openDir(check_dir, .{});
362 defer dir.close();
363
364 const config_h_text = dir.readFileAlloc(b.allocator, "config.h", max_config_h_bytes) catch |err| switch (err) {
365 error.FileNotFound => {
366 const new_check_dir = fs.path.dirname(check_dir);
367 if (new_check_dir == null or mem.eql(u8, new_check_dir.?, check_dir)) {
368 std.debug.warn("Unable to find config.h file relative to Zig executable.\n", .{});
369 std.debug.warn("`zig build` must be run using a Zig executable within the source tree.\n", .{});
370 std.process.exit(1);
371 }
372 check_dir = new_check_dir.?;
373 continue;
374 },
375 else => |e| return e,
376 };
377 return config_h_text;
378 } else unreachable; // TODO should not need `else unreachable`.
379}
380
381fn parseConfigH(b: *Builder, config_h_text: []const u8) Context {
382 var ctx: Context = .{
383 .cmake_binary_dir = undefined,
384 .cxx_compiler = undefined,
385 .llvm_config_exe = undefined,
386 .lld_include_dir = undefined,
387 .lld_libraries = undefined,
388 .clang_libraries = undefined,
389 .dia_guids_lib = undefined,
390 .llvm = undefined,
391 };
392
393 const mappings = [_]struct { prefix: []const u8, field: []const u8 }{
394 .{
395 .prefix = "#define ZIG_CMAKE_BINARY_DIR ",
396 .field = "cmake_binary_dir",
397 },
398 .{
399 .prefix = "#define ZIG_CXX_COMPILER ",
400 .field = "cxx_compiler",
401 },
402 .{
403 .prefix = "#define ZIG_LLD_INCLUDE_PATH ",
404 .field = "lld_include_dir",
405 },
406 .{
407 .prefix = "#define ZIG_LLD_LIBRARIES ",
408 .field = "lld_libraries",
409 },
410 .{
411 .prefix = "#define ZIG_CLANG_LIBRARIES ",
412 .field = "clang_libraries",
413 },
414 .{
415 .prefix = "#define ZIG_LLVM_CONFIG_EXE ",
416 .field = "llvm_config_exe",
417 },
418 .{
419 .prefix = "#define ZIG_DIA_GUIDS_LIB ",
420 .field = "dia_guids_lib",
421 },
422 };
423
424 var lines_it = mem.tokenize(config_h_text, "\r\n");
425 while (lines_it.next()) |line| {
426 inline for (mappings) |mapping| {
427 if (mem.startsWith(u8, line, mapping.prefix)) {
428 var it = mem.split(line, "\"");
429 _ = it.next().?; // skip the stuff before the quote
430 const quoted = it.next().?; // the stuff inside the quote
431 @field(ctx, mapping.field) = toNativePathSep(b, quoted);
432 }
433 }
434 }
435 return ctx;
436}
437
438fn toNativePathSep(b: *Builder, s: []const u8) []u8 {
439 const duplicated = mem.dupe(b.allocator, u8, s) catch unreachable;
440 for (duplicated) |*byte| switch (byte.*) {
441 '/' => byte.* = fs.path.sep,
442 else => {},
443 };
444 return duplicated;
445}
ci/azure/linux_script+3-3
...@@ -14,9 +14,9 @@ sudo apt-get remove -y llvm-*...@@ -14,9 +14,9 @@ sudo apt-get remove -y llvm-*
14sudo rm -rf /usr/local/*14sudo rm -rf /usr/local/*
15sudo apt-get install -y libxml2-dev libclang-10-dev llvm-10 llvm-10-dev liblld-10-dev cmake s3cmd gcc-7 g++-715sudo apt-get install -y libxml2-dev libclang-10-dev llvm-10 llvm-10-dev liblld-10-dev cmake s3cmd gcc-7 g++-7
1616
17wget https://ziglang.org/deps/qemu-5.0.0-rc1-x86_64-alpinelinux.tar.xz17wget https://ziglang.org/deps/qemu-5.0.0-rc2-x86_64-alpinelinux.tar.xz
18tar xf qemu-5.0.0-rc1-x86_64-alpinelinux.tar.xz18tar xf qemu-5.0.0-rc2-x86_64-alpinelinux.tar.xz
19PATH=$PWD/qemu-5.0.0-rc1/bin:$PATH19PATH=$PWD/qemu-5.0.0-rc2/bin:$PATH
2020
21# Make the `zig version` number consistent.21# Make the `zig version` number consistent.
22# This will affect the cmake command below.22# This will affect the cmake command below.
cmake/Findclang.cmake+61-41
...@@ -8,52 +8,72 @@...@@ -8,52 +8,72 @@
8# CLANG_LIBDIRS8# CLANG_LIBDIRS
99
10find_path(CLANG_INCLUDE_DIRS NAMES clang/Frontend/ASTUnit.h10find_path(CLANG_INCLUDE_DIRS NAMES clang/Frontend/ASTUnit.h
11 PATHS
12 /usr/lib/llvm/10/include
13 /usr/lib/llvm-10/include
14 /usr/lib/llvm-10.0/include
15 /usr/local/llvm100/include
16 /usr/local/llvm10/include
17 /mingw64/include
18)
19
20if(ZIG_PREFER_CLANG_CPP_DYLIB)
21 find_library(CLANG_CPP_DYLIB
22 NAMES
23 clang-cpp-10.0
24 clang-cpp100
25 clang-cpp
11 PATHS26 PATHS
12 /usr/lib/llvm/10/include27 ${CLANG_LIBDIRS}
13 /usr/lib/llvm-10/include28 /usr/lib/llvm-10/lib
14 /usr/lib/llvm-10.0/include29 /usr/local/llvm100/lib
15 /usr/local/llvm100/include30 /usr/local/llvm10/lib
16 /mingw64/include)31 )
32endif()
1733
18macro(FIND_AND_ADD_CLANG_LIB _libname_)34if(CLANG_CPP_DYLIB)
35 set(CLANG_LIBRARIES ${CLANG_CPP_DYLIB})
36else()
37 macro(FIND_AND_ADD_CLANG_LIB _libname_)
19 string(TOUPPER ${_libname_} _prettylibname_)38 string(TOUPPER ${_libname_} _prettylibname_)
20 find_library(CLANG_${_prettylibname_}_LIB NAMES ${_libname_}39 find_library(CLANG_${_prettylibname_}_LIB NAMES ${_libname_}
21 PATHS40 PATHS
22 ${CLANG_LIBDIRS}41 ${CLANG_LIBDIRS}
23 /usr/lib/llvm/10/lib42 /usr/lib/llvm/10/lib
24 /usr/lib/llvm-10/lib43 /usr/lib/llvm-10/lib
25 /usr/lib/llvm-10.0/lib44 /usr/lib/llvm-10.0/lib
26 /usr/local/llvm100/lib45 /usr/local/llvm100/lib
27 /mingw64/lib46 /usr/local/llvm10/lib
28 /c/msys64/mingw64/lib47 /mingw64/lib
29 c:\\msys64\\mingw64\\lib)48 /c/msys64/mingw64/lib
30 if(CLANG_${_prettylibname_}_LIB)49 c:\\msys64\\mingw64\\lib
31 set(CLANG_LIBRARIES ${CLANG_LIBRARIES} ${CLANG_${_prettylibname_}_LIB})50 )
32 endif()51 set(CLANG_LIBRARIES ${CLANG_LIBRARIES} ${CLANG_${_prettylibname_}_LIB})
33endmacro(FIND_AND_ADD_CLANG_LIB)52 endmacro(FIND_AND_ADD_CLANG_LIB)
3453
35FIND_AND_ADD_CLANG_LIB(clangFrontendTool)54 FIND_AND_ADD_CLANG_LIB(clangFrontendTool)
36FIND_AND_ADD_CLANG_LIB(clangCodeGen)55 FIND_AND_ADD_CLANG_LIB(clangCodeGen)
37FIND_AND_ADD_CLANG_LIB(clangFrontend)56 FIND_AND_ADD_CLANG_LIB(clangFrontend)
38FIND_AND_ADD_CLANG_LIB(clangDriver)57 FIND_AND_ADD_CLANG_LIB(clangDriver)
39FIND_AND_ADD_CLANG_LIB(clangSerialization)58 FIND_AND_ADD_CLANG_LIB(clangSerialization)
40FIND_AND_ADD_CLANG_LIB(clangSema)59 FIND_AND_ADD_CLANG_LIB(clangSema)
41FIND_AND_ADD_CLANG_LIB(clangStaticAnalyzerFrontend)60 FIND_AND_ADD_CLANG_LIB(clangStaticAnalyzerFrontend)
42FIND_AND_ADD_CLANG_LIB(clangStaticAnalyzerCheckers)61 FIND_AND_ADD_CLANG_LIB(clangStaticAnalyzerCheckers)
43FIND_AND_ADD_CLANG_LIB(clangStaticAnalyzerCore)62 FIND_AND_ADD_CLANG_LIB(clangStaticAnalyzerCore)
44FIND_AND_ADD_CLANG_LIB(clangAnalysis)63 FIND_AND_ADD_CLANG_LIB(clangAnalysis)
45FIND_AND_ADD_CLANG_LIB(clangASTMatchers)64 FIND_AND_ADD_CLANG_LIB(clangASTMatchers)
46FIND_AND_ADD_CLANG_LIB(clangAST)65 FIND_AND_ADD_CLANG_LIB(clangAST)
47FIND_AND_ADD_CLANG_LIB(clangParse)66 FIND_AND_ADD_CLANG_LIB(clangParse)
48FIND_AND_ADD_CLANG_LIB(clangSema)67 FIND_AND_ADD_CLANG_LIB(clangSema)
49FIND_AND_ADD_CLANG_LIB(clangBasic)68 FIND_AND_ADD_CLANG_LIB(clangBasic)
50FIND_AND_ADD_CLANG_LIB(clangEdit)69 FIND_AND_ADD_CLANG_LIB(clangEdit)
51FIND_AND_ADD_CLANG_LIB(clangLex)70 FIND_AND_ADD_CLANG_LIB(clangLex)
52FIND_AND_ADD_CLANG_LIB(clangARCMigrate)71 FIND_AND_ADD_CLANG_LIB(clangARCMigrate)
53FIND_AND_ADD_CLANG_LIB(clangRewriteFrontend)72 FIND_AND_ADD_CLANG_LIB(clangRewriteFrontend)
54FIND_AND_ADD_CLANG_LIB(clangRewrite)73 FIND_AND_ADD_CLANG_LIB(clangRewrite)
55FIND_AND_ADD_CLANG_LIB(clangCrossTU)74 FIND_AND_ADD_CLANG_LIB(clangCrossTU)
56FIND_AND_ADD_CLANG_LIB(clangIndex)75 FIND_AND_ADD_CLANG_LIB(clangIndex)
76endif()
5777
58include(FindPackageHandleStandardArgs)78include(FindPackageHandleStandardArgs)
59find_package_handle_standard_args(clang DEFAULT_MSG CLANG_LIBRARIES CLANG_INCLUDE_DIRS)79find_package_handle_standard_args(clang DEFAULT_MSG CLANG_LIBRARIES CLANG_INCLUDE_DIRS)
cmake/Findlld.cmake+3
...@@ -10,12 +10,14 @@ find_path(LLD_INCLUDE_DIRS NAMES lld/Common/Driver.h...@@ -10,12 +10,14 @@ find_path(LLD_INCLUDE_DIRS NAMES lld/Common/Driver.h
10 PATHS10 PATHS
11 /usr/lib/llvm-10/include11 /usr/lib/llvm-10/include
12 /usr/local/llvm100/include12 /usr/local/llvm100/include
13 /usr/local/llvm10/include
13 /mingw64/include)14 /mingw64/include)
1415
15find_library(LLD_LIBRARY NAMES lld-10.0 lld100 lld16find_library(LLD_LIBRARY NAMES lld-10.0 lld100 lld
16 PATHS17 PATHS
17 /usr/lib/llvm-10/lib18 /usr/lib/llvm-10/lib
18 /usr/local/llvm100/lib19 /usr/local/llvm100/lib
20 /usr/local/llvm10/lib
19)21)
20if(EXISTS ${LLD_LIBRARY})22if(EXISTS ${LLD_LIBRARY})
21 set(LLD_LIBRARIES ${LLD_LIBRARY})23 set(LLD_LIBRARIES ${LLD_LIBRARY})
...@@ -27,6 +29,7 @@ else()...@@ -27,6 +29,7 @@ else()
27 ${LLD_LIBDIRS}29 ${LLD_LIBDIRS}
28 /usr/lib/llvm-10/lib30 /usr/lib/llvm-10/lib
29 /usr/local/llvm100/lib31 /usr/local/llvm100/lib
32 /usr/local/llvm10/lib
30 /mingw64/lib33 /mingw64/lib
31 /c/msys64/mingw64/lib34 /c/msys64/mingw64/lib
32 c:/msys64/mingw64/lib)35 c:/msys64/mingw64/lib)
cmake/Findllvm.cmake+4-5
...@@ -9,7 +9,7 @@...@@ -9,7 +9,7 @@
99
10if("${ZIG_TARGET_TRIPLE}" STREQUAL "native")10if("${ZIG_TARGET_TRIPLE}" STREQUAL "native")
11 find_program(LLVM_CONFIG_EXE11 find_program(LLVM_CONFIG_EXE
12 NAMES llvm-config-10 llvm-config-10.0 llvm-config100 llvm-config12 NAMES llvm-config-10 llvm-config-10.0 llvm-config100 llvm-config10 llvm-config
13 PATHS13 PATHS
14 "/mingw64/bin"14 "/mingw64/bin"
15 "/c/msys64/mingw64/bin"15 "/c/msys64/mingw64/bin"
...@@ -130,6 +130,7 @@ else()...@@ -130,6 +130,7 @@ else()
130 /usr/lib/llvm-10/include130 /usr/lib/llvm-10/include
131 /usr/lib/llvm-10.0/include131 /usr/lib/llvm-10.0/include
132 /usr/local/llvm100/include132 /usr/local/llvm100/include
133 /usr/local/llvm10/include
133 /mingw64/include)134 /mingw64/include)
134135
135 macro(FIND_AND_ADD_LLVM_LIB _libname_)136 macro(FIND_AND_ADD_LLVM_LIB _libname_)
...@@ -141,12 +142,11 @@ else()...@@ -141,12 +142,11 @@ else()
141 /usr/lib/llvm-10/lib142 /usr/lib/llvm-10/lib
142 /usr/lib/llvm-10.0/lib143 /usr/lib/llvm-10.0/lib
143 /usr/local/llvm100/lib144 /usr/local/llvm100/lib
145 /usr/local/llvm10/lib
144 /mingw64/lib146 /mingw64/lib
145 /c/msys64/mingw64/lib147 /c/msys64/mingw64/lib
146 c:\\msys64\\mingw64\\lib)148 c:\\msys64\\mingw64\\lib)
147 if(LLVM_${_prettylibname_}_LIB)149 set(LLVM_LIBRARIES ${LLVM_LIBRARIES} ${LLVM_${_prettylibname_}_LIB})
148 set(LLVM_LIBRARIES ${LLVM_LIBRARIES} ${LLVM_${_prettylibname_}_LIB})
149 endif()
150 endmacro(FIND_AND_ADD_LLVM_LIB)150 endmacro(FIND_AND_ADD_LLVM_LIB)
151151
152 # This list can be re-generated with `llvm-config --libfiles` and then152 # This list can be re-generated with `llvm-config --libfiles` and then
...@@ -154,7 +154,6 @@ else()...@@ -154,7 +154,6 @@ else()
154 # `llvm-config` here because we are cross compiling.154 # `llvm-config` here because we are cross compiling.
155 FIND_AND_ADD_LLVM_LIB(LLVMXRay)155 FIND_AND_ADD_LLVM_LIB(LLVMXRay)
156 FIND_AND_ADD_LLVM_LIB(LLVMWindowsManifest)156 FIND_AND_ADD_LLVM_LIB(LLVMWindowsManifest)
157 FIND_AND_ADD_LLVM_LIB(LLVMTableGen)
158 FIND_AND_ADD_LLVM_LIB(LLVMSymbolize)157 FIND_AND_ADD_LLVM_LIB(LLVMSymbolize)
159 FIND_AND_ADD_LLVM_LIB(LLVMDebugInfoPDB)158 FIND_AND_ADD_LLVM_LIB(LLVMDebugInfoPDB)
160 FIND_AND_ADD_LLVM_LIB(LLVMOrcJIT)159 FIND_AND_ADD_LLVM_LIB(LLVMOrcJIT)
doc/docgen.zig+16-16
...@@ -1108,7 +1108,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var...@@ -1108,7 +1108,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var
1108 if (expected_outcome == .BuildFail) {1108 if (expected_outcome == .BuildFail) {
1109 const result = try ChildProcess.exec(.{1109 const result = try ChildProcess.exec(.{
1110 .allocator = allocator,1110 .allocator = allocator,
1111 .argv = build_args.span(),1111 .argv = build_args.items,
1112 .env_map = &env_map,1112 .env_map = &env_map,
1113 .max_output_bytes = max_doc_file_size,1113 .max_output_bytes = max_doc_file_size,
1114 });1114 });
...@@ -1116,7 +1116,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var...@@ -1116,7 +1116,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var
1116 .Exited => |exit_code| {1116 .Exited => |exit_code| {
1117 if (exit_code == 0) {1117 if (exit_code == 0) {
1118 warn("{}\nThe following command incorrectly succeeded:\n", .{result.stderr});1118 warn("{}\nThe following command incorrectly succeeded:\n", .{result.stderr});
1119 for (build_args.span()) |arg|1119 for (build_args.items) |arg|
1120 warn("{} ", .{arg})1120 warn("{} ", .{arg})
1121 else1121 else
1122 warn("\n", .{});1122 warn("\n", .{});
...@@ -1125,7 +1125,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var...@@ -1125,7 +1125,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var
1125 },1125 },
1126 else => {1126 else => {
1127 warn("{}\nThe following command crashed:\n", .{result.stderr});1127 warn("{}\nThe following command crashed:\n", .{result.stderr});
1128 for (build_args.span()) |arg|1128 for (build_args.items) |arg|
1129 warn("{} ", .{arg})1129 warn("{} ", .{arg})
1130 else1130 else
1131 warn("\n", .{});1131 warn("\n", .{});
...@@ -1137,7 +1137,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var...@@ -1137,7 +1137,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var
1137 try out.print("\n{}</code></pre>\n", .{colored_stderr});1137 try out.print("\n{}</code></pre>\n", .{colored_stderr});
1138 break :code_block;1138 break :code_block;
1139 }1139 }
1140 const exec_result = exec(allocator, &env_map, build_args.span()) catch1140 const exec_result = exec(allocator, &env_map, build_args.items) catch
1141 return parseError(tokenizer, code.source_token, "example failed to compile", .{});1141 return parseError(tokenizer, code.source_token, "example failed to compile", .{});
11421142
1143 if (code.target_str) |triple| {1143 if (code.target_str) |triple| {
...@@ -1238,7 +1238,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var...@@ -1238,7 +1238,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var
1238 try test_args.appendSlice(&[_][]const u8{ "-target", triple });1238 try test_args.appendSlice(&[_][]const u8{ "-target", triple });
1239 try out.print(" -target {}", .{triple});1239 try out.print(" -target {}", .{triple});
1240 }1240 }
1241 const result = exec(allocator, &env_map, test_args.span()) catch return parseError(tokenizer, code.source_token, "test failed", .{});1241 const result = exec(allocator, &env_map, test_args.items) catch return parseError(tokenizer, code.source_token, "test failed", .{});
1242 const escaped_stderr = try escapeHtml(allocator, result.stderr);1242 const escaped_stderr = try escapeHtml(allocator, result.stderr);
1243 const escaped_stdout = try escapeHtml(allocator, result.stdout);1243 const escaped_stdout = try escapeHtml(allocator, result.stdout);
1244 try out.print("\n{}{}</code></pre>\n", .{ escaped_stderr, escaped_stdout });1244 try out.print("\n{}{}</code></pre>\n", .{ escaped_stderr, escaped_stdout });
...@@ -1274,7 +1274,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var...@@ -1274,7 +1274,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var
1274 }1274 }
1275 const result = try ChildProcess.exec(.{1275 const result = try ChildProcess.exec(.{
1276 .allocator = allocator,1276 .allocator = allocator,
1277 .argv = test_args.span(),1277 .argv = test_args.items,
1278 .env_map = &env_map,1278 .env_map = &env_map,
1279 .max_output_bytes = max_doc_file_size,1279 .max_output_bytes = max_doc_file_size,
1280 });1280 });
...@@ -1282,7 +1282,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var...@@ -1282,7 +1282,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var
1282 .Exited => |exit_code| {1282 .Exited => |exit_code| {
1283 if (exit_code == 0) {1283 if (exit_code == 0) {
1284 warn("{}\nThe following command incorrectly succeeded:\n", .{result.stderr});1284 warn("{}\nThe following command incorrectly succeeded:\n", .{result.stderr});
1285 for (test_args.span()) |arg|1285 for (test_args.items) |arg|
1286 warn("{} ", .{arg})1286 warn("{} ", .{arg})
1287 else1287 else
1288 warn("\n", .{});1288 warn("\n", .{});
...@@ -1291,7 +1291,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var...@@ -1291,7 +1291,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var
1291 },1291 },
1292 else => {1292 else => {
1293 warn("{}\nThe following command crashed:\n", .{result.stderr});1293 warn("{}\nThe following command crashed:\n", .{result.stderr});
1294 for (test_args.span()) |arg|1294 for (test_args.items) |arg|
1295 warn("{} ", .{arg})1295 warn("{} ", .{arg})
1296 else1296 else
1297 warn("\n", .{});1297 warn("\n", .{});
...@@ -1337,7 +1337,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var...@@ -1337,7 +1337,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var
13371337
1338 const result = try ChildProcess.exec(.{1338 const result = try ChildProcess.exec(.{
1339 .allocator = allocator,1339 .allocator = allocator,
1340 .argv = test_args.span(),1340 .argv = test_args.items,
1341 .env_map = &env_map,1341 .env_map = &env_map,
1342 .max_output_bytes = max_doc_file_size,1342 .max_output_bytes = max_doc_file_size,
1343 });1343 });
...@@ -1345,7 +1345,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var...@@ -1345,7 +1345,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var
1345 .Exited => |exit_code| {1345 .Exited => |exit_code| {
1346 if (exit_code == 0) {1346 if (exit_code == 0) {
1347 warn("{}\nThe following command incorrectly succeeded:\n", .{result.stderr});1347 warn("{}\nThe following command incorrectly succeeded:\n", .{result.stderr});
1348 for (test_args.span()) |arg|1348 for (test_args.items) |arg|
1349 warn("{} ", .{arg})1349 warn("{} ", .{arg})
1350 else1350 else
1351 warn("\n", .{});1351 warn("\n", .{});
...@@ -1354,7 +1354,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var...@@ -1354,7 +1354,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var
1354 },1354 },
1355 else => {1355 else => {
1356 warn("{}\nThe following command crashed:\n", .{result.stderr});1356 warn("{}\nThe following command crashed:\n", .{result.stderr});
1357 for (test_args.span()) |arg|1357 for (test_args.items) |arg|
1358 warn("{} ", .{arg})1358 warn("{} ", .{arg})
1359 else1359 else
1360 warn("\n", .{});1360 warn("\n", .{});
...@@ -1434,7 +1434,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var...@@ -1434,7 +1434,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var
1434 if (maybe_error_match) |error_match| {1434 if (maybe_error_match) |error_match| {
1435 const result = try ChildProcess.exec(.{1435 const result = try ChildProcess.exec(.{
1436 .allocator = allocator,1436 .allocator = allocator,
1437 .argv = build_args.span(),1437 .argv = build_args.items,
1438 .env_map = &env_map,1438 .env_map = &env_map,
1439 .max_output_bytes = max_doc_file_size,1439 .max_output_bytes = max_doc_file_size,
1440 });1440 });
...@@ -1442,7 +1442,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var...@@ -1442,7 +1442,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var
1442 .Exited => |exit_code| {1442 .Exited => |exit_code| {
1443 if (exit_code == 0) {1443 if (exit_code == 0) {
1444 warn("{}\nThe following command incorrectly succeeded:\n", .{result.stderr});1444 warn("{}\nThe following command incorrectly succeeded:\n", .{result.stderr});
1445 for (build_args.span()) |arg|1445 for (build_args.items) |arg|
1446 warn("{} ", .{arg})1446 warn("{} ", .{arg})
1447 else1447 else
1448 warn("\n", .{});1448 warn("\n", .{});
...@@ -1451,7 +1451,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var...@@ -1451,7 +1451,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var
1451 },1451 },
1452 else => {1452 else => {
1453 warn("{}\nThe following command crashed:\n", .{result.stderr});1453 warn("{}\nThe following command crashed:\n", .{result.stderr});
1454 for (build_args.span()) |arg|1454 for (build_args.items) |arg|
1455 warn("{} ", .{arg})1455 warn("{} ", .{arg})
1456 else1456 else
1457 warn("\n", .{});1457 warn("\n", .{});
...@@ -1466,7 +1466,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var...@@ -1466,7 +1466,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var
1466 const colored_stderr = try termColor(allocator, escaped_stderr);1466 const colored_stderr = try termColor(allocator, escaped_stderr);
1467 try out.print("\n{}", .{colored_stderr});1467 try out.print("\n{}", .{colored_stderr});
1468 } else {1468 } else {
1469 _ = exec(allocator, &env_map, build_args.span()) catch return parseError(tokenizer, code.source_token, "example failed to compile", .{});1469 _ = exec(allocator, &env_map, build_args.items) catch return parseError(tokenizer, code.source_token, "example failed to compile", .{});
1470 }1470 }
1471 if (!code.is_inline) {1471 if (!code.is_inline) {
1472 try out.print("</code></pre>\n", .{});1472 try out.print("</code></pre>\n", .{});
...@@ -1503,7 +1503,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var...@@ -1503,7 +1503,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var
1503 try test_args.appendSlice(&[_][]const u8{ "-target", triple });1503 try test_args.appendSlice(&[_][]const u8{ "-target", triple });
1504 try out.print(" -target {}", .{triple});1504 try out.print(" -target {}", .{triple});
1505 }1505 }
1506 const result = exec(allocator, &env_map, test_args.span()) catch return parseError(tokenizer, code.source_token, "test failed", .{});1506 const result = exec(allocator, &env_map, test_args.items) catch return parseError(tokenizer, code.source_token, "test failed", .{});
1507 const escaped_stderr = try escapeHtml(allocator, result.stderr);1507 const escaped_stderr = try escapeHtml(allocator, result.stderr);
1508 const escaped_stdout = try escapeHtml(allocator, result.stdout);1508 const escaped_stdout = try escapeHtml(allocator, result.stdout);
1509 try out.print("\n{}{}</code></pre>\n", .{ escaped_stderr, escaped_stdout });1509 try out.print("\n{}{}</code></pre>\n", .{ escaped_stderr, escaped_stdout });
doc/langref.html.in+5-9
...@@ -247,8 +247,7 @@ pub fn main() void {...@@ -247,8 +247,7 @@ pub fn main() void {
247}247}
248 {#code_end#}248 {#code_end#}
249 <p>249 <p>
250 Note that we also left off the {#syntax#}!{#endsyntax#} from the return type.250 Note that you can leave off the {#syntax#}!{#endsyntax#} from the return type because {#syntax#}warn{#endsyntax#} cannot fail.
251 In Zig, if your main function cannot fail, you must use the {#syntax#}void{#endsyntax#} return type.
252 </p>251 </p>
253 {#see_also|Values|@import|Errors|Root Source File#}252 {#see_also|Values|@import|Errors|Root Source File#}
254 {#header_close#}253 {#header_close#}
...@@ -985,7 +984,7 @@ export fn foo_strict(x: f64) f64 {...@@ -985,7 +984,7 @@ export fn foo_strict(x: f64) f64 {
985}984}
986985
987export fn foo_optimized(x: f64) f64 {986export fn foo_optimized(x: f64) f64 {
988 @setFloatMode(builtin.FloatMode.Optimized);987 @setFloatMode(.Optimized);
989 return x + big - big;988 return x + big - big;
990}989}
991 {#code_end#}990 {#code_end#}
...@@ -1644,9 +1643,7 @@ x{} x.* x.?...@@ -1644,9 +1643,7 @@ x{} x.* x.?
1644! * / % ** *% ||1643! * / % ** *% ||
1645+ - ++ +% -%1644+ - ++ +% -%
1646<< >>1645<< >>
1647&1646& ^ |
1648^
1649|
1650== != < > <= >=1647== != < > <= >=
1651and1648and
1652or1649or
...@@ -2992,7 +2989,7 @@ test "simple union" {...@@ -2992,7 +2989,7 @@ test "simple union" {
2992 This turns the union into a <em>tagged</em> union, which makes it eligible2989 This turns the union into a <em>tagged</em> union, which makes it eligible
2993 to use with {#link|switch#} expressions. One can use {#link|@TagType#} to2990 to use with {#link|switch#} expressions. One can use {#link|@TagType#} to
2994 obtain the enum type from the union type.2991 obtain the enum type from the union type.
2995 Tagged unions coerce to their enum {#link|Type Coercion: unions and enums#}2992 Tagged unions coerce to their tag type: {#link|Type Coercion: unions and enums#}.
2996 </p>2993 </p>
2997 {#code_begin|test#}2994 {#code_begin|test#}
2998const std = @import("std");2995const std = @import("std");
...@@ -9479,7 +9476,7 @@ pub fn main() void {...@@ -9479,7 +9476,7 @@ pub fn main() void {
9479const builtin = @import("builtin");9476const builtin = @import("builtin");
94809477
9481const c = @cImport({9478const c = @cImport({
9482 @cDefine("NDEBUG", builtin.mode == builtin.Mode.ReleaseFast);9479 @cDefine("NDEBUG", builtin.mode == .ReleaseFast);
9483 if (something) {9480 if (something) {
9484 @cDefine("_GNU_SOURCE", {});9481 @cDefine("_GNU_SOURCE", {});
9485 }9482 }
...@@ -10077,7 +10074,6 @@ fn readU32Be() u32 {}...@@ -10077,7 +10074,6 @@ fn readU32Be() u32 {}
10077 {#header_open|Keyword: pub#}10074 {#header_open|Keyword: pub#}
10078 <p>The {#syntax#}pub{#endsyntax#} in front of a top level declaration makes the10075 <p>The {#syntax#}pub{#endsyntax#} in front of a top level declaration makes the
10079 declaration available to reference from a different file than the one it is declared in.</p>10076 declaration available to reference from a different file than the one it is declared in.</p>
10080 <p><a href="https://github.com/ziglang/zig/issues/2059">TODO delete pub syntax for fields, or make it do something.</a></p>
10081 {#see_also|@import#}10077 {#see_also|@import#}
10082 {#header_close#}10078 {#header_close#}
10083 {#header_close#}10079 {#header_close#}
lib/libc/glibc/abi.txt+90
...@@ -1856,6 +1856,7 @@ aarch64-linux-gnu aarch64_be-linux-gnu...@@ -1856,6 +1856,7 @@ aarch64-linux-gnu aarch64_be-linux-gnu
185629185629
185729185729
185829185829
185929
185937186037
186037186137
186137186237
...@@ -2422,6 +2423,10 @@ aarch64-linux-gnu aarch64_be-linux-gnu...@@ -2422,6 +2423,10 @@ aarch64-linux-gnu aarch64_be-linux-gnu
242229242329
242329242429
242429242529
242629
242729
242829
242929
242537243037
242637243137
242737243237
...@@ -2625,6 +2630,7 @@ aarch64-linux-gnu aarch64_be-linux-gnu...@@ -2625,6 +2630,7 @@ aarch64-linux-gnu aarch64_be-linux-gnu
262529263029
262629263129
262729263229
263329
26282634
26292635
26302636
...@@ -5572,6 +5578,7 @@ s390x-linux-gnu...@@ -5572,6 +5578,7 @@ s390x-linux-gnu
5572555785
5573555795
5574555805
55815
55755 1655825 16
5576555835
5577555845
...@@ -6151,7 +6158,11 @@ s390x-linux-gnu...@@ -6151,7 +6158,11 @@ s390x-linux-gnu
615137615837
615237615937
615337616037
61615
61625
61545 1661635 16
61645
61655
615531 5616631 5
6156561675
6157561685
...@@ -6361,6 +6372,7 @@ s390x-linux-gnu...@@ -6361,6 +6372,7 @@ s390x-linux-gnu
6361563725
6362563735
6363563745
63755
63646376
63656377
63666378
...@@ -9328,6 +9340,7 @@ arm-linux-gnueabi armeb-linux-gnueabi arm-linux-gnueabihf armeb-linux-gnueabihf...@@ -9328,6 +9340,7 @@ arm-linux-gnueabi armeb-linux-gnueabi arm-linux-gnueabihf armeb-linux-gnueabihf
932816934016
932916934116
933016934216
934316
93319344
933237934537
933337934637
...@@ -9894,6 +9907,10 @@ arm-linux-gnueabi armeb-linux-gnueabi arm-linux-gnueabihf armeb-linux-gnueabihf...@@ -9894,6 +9907,10 @@ arm-linux-gnueabi armeb-linux-gnueabi arm-linux-gnueabihf armeb-linux-gnueabihf
989416990716
989516990816
989616990916
991016
991116
991216
991316
98979914
989837991537
989937991637
...@@ -10108,6 +10125,7 @@ arm-linux-gnueabi armeb-linux-gnueabi arm-linux-gnueabihf armeb-linux-gnueabihf...@@ -10108,6 +10125,7 @@ arm-linux-gnueabi armeb-linux-gnueabi arm-linux-gnueabihf armeb-linux-gnueabihf
10108161012516
10109161012616
10110161012716
1012816
10111211012921
10112161013016
10113371013137
...@@ -13044,6 +13062,7 @@ sparc-linux-gnu sparcel-linux-gnu...@@ -13044,6 +13062,7 @@ sparc-linux-gnu sparcel-linux-gnu
130440 5130620 5
130450130630
130460130640
130650
130470 16130660 16
130480130670
130490130680
...@@ -13623,10 +13642,14 @@ sparc-linux-gnu sparcel-linux-gnu...@@ -13623,10 +13642,14 @@ sparc-linux-gnu sparcel-linux-gnu
13623371364237
13624371364337
13625371364437
136450
136460
136260 16136470 16
136270136480
136280136490
136290136500
136510
136520
13630121365312
136311136541
136321136551
...@@ -13833,6 +13856,7 @@ sparc-linux-gnu sparcel-linux-gnu...@@ -13833,6 +13856,7 @@ sparc-linux-gnu sparcel-linux-gnu
138330138560
138340138570
138350138580
138590
1383613860
1383713861
1383813862
...@@ -16779,6 +16803,7 @@ sparcv9-linux-gnu...@@ -16779,6 +16803,7 @@ sparcv9-linux-gnu
167795168035
167805168045
167815168055
168060
167825168075
167835168085
167845168095
...@@ -17359,7 +17384,11 @@ sparcv9-linux-gnu...@@ -17359,7 +17384,11 @@ sparcv9-linux-gnu
17359371738437
17360371738537
17361371738637
173870
173880
173625173895
173900
173910
173635173925
173645173935
173655173945
...@@ -17565,6 +17594,7 @@ sparcv9-linux-gnu...@@ -17565,6 +17594,7 @@ sparcv9-linux-gnu
17565161759416
175665175955
175675175965
175970
175685175985
175695175995
175705176005
...@@ -20520,6 +20550,7 @@ mips64el-linux-gnuabi64 mips64-linux-gnuabi64...@@ -20520,6 +20550,7 @@ mips64el-linux-gnuabi64 mips64-linux-gnuabi64
205200205500
205210205510
205220205520
205530
205235205545
205245205555
205255205565
...@@ -21099,6 +21130,10 @@ mips64el-linux-gnuabi64 mips64-linux-gnuabi64...@@ -21099,6 +21130,10 @@ mips64el-linux-gnuabi64 mips64-linux-gnuabi64
210990211300
211000211310
211010211320
211330
211340
211350
211360
21102122113712
211035211385
211045211395
...@@ -21305,6 +21340,7 @@ mips64el-linux-gnuabi64 mips64-linux-gnuabi64...@@ -21305,6 +21340,7 @@ mips64el-linux-gnuabi64 mips64-linux-gnuabi64
213050213400
213060213410
213070213420
213430
2130821344
2130921345
2131021346
...@@ -24256,6 +24292,7 @@ mips64el-linux-gnuabin32 mips64-linux-gnuabin32...@@ -24256,6 +24292,7 @@ mips64el-linux-gnuabin32 mips64-linux-gnuabin32
242560242920
242570242930
242580242940
242950
242595242965
242605242975
242615242985
...@@ -24835,6 +24872,10 @@ mips64el-linux-gnuabin32 mips64-linux-gnuabin32...@@ -24835,6 +24872,10 @@ mips64el-linux-gnuabin32 mips64-linux-gnuabin32
248350248720
248360248730
248370248740
248750
248760
248770
248780
24838122487912
248395248805
248405248815
...@@ -25041,6 +25082,7 @@ mips64el-linux-gnuabin32 mips64-linux-gnuabin32...@@ -25041,6 +25082,7 @@ mips64el-linux-gnuabin32 mips64-linux-gnuabin32
250410250820
250420250830
250430250840
250850
2504425086
2504525087
2504625088
...@@ -27992,6 +28034,7 @@ mipsel-linux-gnueabihf mips-linux-gnueabihf...@@ -27992,6 +28034,7 @@ mipsel-linux-gnueabihf mips-linux-gnueabihf
279920280340
279930280350
279940280360
280370
279955280385
279965280395
279975280405
...@@ -28567,6 +28610,10 @@ mipsel-linux-gnueabihf mips-linux-gnueabihf...@@ -28567,6 +28610,10 @@ mipsel-linux-gnueabihf mips-linux-gnueabihf
28567372861037
28568372861137
2856928612
286130
286140
286150
286160
285700286170
285710286180
285720286190
...@@ -28777,6 +28824,7 @@ mipsel-linux-gnueabihf mips-linux-gnueabihf...@@ -28777,6 +28824,7 @@ mipsel-linux-gnueabihf mips-linux-gnueabihf
287770288240
287780288250
287790288260
288270
2878028828
2878128829
2878228830
...@@ -31728,6 +31776,7 @@ mipsel-linux-gnueabi mips-linux-gnueabi...@@ -31728,6 +31776,7 @@ mipsel-linux-gnueabi mips-linux-gnueabi
317280317760
317290317770
317300317780
317790
317315317805
317325317815
317335317825
...@@ -32303,6 +32352,10 @@ mipsel-linux-gnueabi mips-linux-gnueabi...@@ -32303,6 +32352,10 @@ mipsel-linux-gnueabi mips-linux-gnueabi
32303373235237
32304373235337
3230532354
323550
323560
323570
323580
323060323590
323070323600
323080323610
...@@ -32513,6 +32566,7 @@ mipsel-linux-gnueabi mips-linux-gnueabi...@@ -32513,6 +32566,7 @@ mipsel-linux-gnueabi mips-linux-gnueabi
325130325660
325140325670
325150325680
325690
3251632570
3251732571
3251832572
...@@ -35473,6 +35527,7 @@ x86_64-linux-gnu...@@ -35473,6 +35527,7 @@ x86_64-linux-gnu
35473103552710
35474103552810
35475103552910
3553010
35476123553112
35477123553212
35478123553312
...@@ -36043,6 +36098,10 @@ x86_64-linux-gnu...@@ -36043,6 +36098,10 @@ x86_64-linux-gnu
36043103609810
36044103609910
36045103610010
3610110
3610210
3610310
3610410
36046123610512
36047103610610
36048103610710
...@@ -36249,6 +36308,7 @@ x86_64-linux-gnu...@@ -36249,6 +36308,7 @@ x86_64-linux-gnu
36249103630810
36250103630910
36251103631010
3631110
3625236312
3625336313
3625436314
...@@ -39216,6 +39276,7 @@ x86_64-linux-gnux32...@@ -39216,6 +39276,7 @@ x86_64-linux-gnux32
39216283927628
39217283927728
39218283927828
3927928
39219363928036
39220373928137
39221373928237
...@@ -39782,6 +39843,10 @@ x86_64-linux-gnux32...@@ -39782,6 +39843,10 @@ x86_64-linux-gnux32
39782283984328
39783283984428
39784283984528
3984628
3984728
3984828
3984928
39785363985036
39786373985137
39787373985237
...@@ -39985,6 +40050,7 @@ x86_64-linux-gnux32...@@ -39985,6 +40050,7 @@ x86_64-linux-gnux32
39985284005028
39986284005128
39987284005228
4005328
3998840054
3998940055
3999040056
...@@ -42936,6 +43002,7 @@ i386-linux-gnu...@@ -42936,6 +43002,7 @@ i386-linux-gnu
429360430020
429370430030
429380430040
430050
429391430061
429405430075
429415430085
...@@ -43515,6 +43582,10 @@ i386-linux-gnu...@@ -43515,6 +43582,10 @@ i386-linux-gnu
435150435820
435160435830
435170435840
435850
435860
435870
435880
43518124358912
435191435901
435201435911
...@@ -43721,6 +43792,7 @@ i386-linux-gnu...@@ -43721,6 +43792,7 @@ i386-linux-gnu
437210437920
437220437930
437230437940
437950
4372443796
4372543797
4372643798
...@@ -46688,6 +46760,7 @@ powerpc64le-linux-gnu...@@ -46688,6 +46760,7 @@ powerpc64le-linux-gnu
46688294676029
46689294676129
46690294676229
4676329
46691364676436
46692374676537
46693374676637
...@@ -47254,6 +47327,10 @@ powerpc64le-linux-gnu...@@ -47254,6 +47327,10 @@ powerpc64le-linux-gnu
47254294732729
47255294732829
47256294732929
4733029
4733129
4733229
4733329
47257364733436
47258374733537
47259374733637
...@@ -47457,6 +47534,7 @@ powerpc64le-linux-gnu...@@ -47457,6 +47534,7 @@ powerpc64le-linux-gnu
47457294753429
47458294753529
47459294753629
4753729
4746047538
4746147539
4746247540
...@@ -50404,6 +50482,7 @@ powerpc64-linux-gnu...@@ -50404,6 +50482,7 @@ powerpc64-linux-gnu
50404125048212
50405125048312
50406125048412
5048512
5040712 165048612 16
50408125048712
50409125048812
...@@ -50983,7 +51062,11 @@ powerpc64-linux-gnu...@@ -50983,7 +51062,11 @@ powerpc64-linux-gnu
50983375106237
50984375106337
5098551064
5106512
5106612
5098612 165106712 16
5106812
5106912
5098712 155107012 15
50988125107112
50989125107212
...@@ -51193,6 +51276,7 @@ powerpc64-linux-gnu...@@ -51193,6 +51276,7 @@ powerpc64-linux-gnu
51193125127612
51194125127712
51195125127812
5127912
5119651280
5119751281
5119851282
...@@ -54140,6 +54224,7 @@ powerpc-linux-gnueabi powerpc-linux-gnueabihf...@@ -54140,6 +54224,7 @@ powerpc-linux-gnueabi powerpc-linux-gnueabihf
541400 5542240 5
541410542250
541420542260
542270
541430 16542280 16
541440542290
541450542300
...@@ -54719,7 +54804,11 @@ powerpc-linux-gnueabi powerpc-linux-gnueabihf...@@ -54719,7 +54804,11 @@ powerpc-linux-gnueabi powerpc-linux-gnueabihf
54719375480437
54720375480537
5472154806
548070
548080
547220 16548090 16
548100
548110
547230 15548120 15
547240548130
547250548140
...@@ -54929,6 +55018,7 @@ powerpc-linux-gnueabi powerpc-linux-gnueabihf...@@ -54929,6 +55018,7 @@ powerpc-linux-gnueabi powerpc-linux-gnueabihf
549290550180
549300550190
549310550200
550210
5493255022
5493355023
5493455024
lib/libc/glibc/fns.txt+6
...@@ -1834,6 +1834,7 @@ fopen c...@@ -1834,6 +1834,7 @@ fopen c
1834fopen64 c1834fopen64 c
1835fopencookie c1835fopencookie c
1836fork c1836fork c
1837forkpty util
1837fpathconf c1838fpathconf c
1838fprintf c1839fprintf c
1839fputc c1840fputc c
...@@ -2414,7 +2415,11 @@ logf32 m...@@ -2414,7 +2415,11 @@ logf32 m
2414logf32x m2415logf32x m
2415logf64 m2416logf64 m
2416logf64x m2417logf64x m
2418login util
2419login_tty util
2417logl m2420logl m
2421logout util
2422logwtmp util
2418longjmp c2423longjmp c
2419lrand48 c2424lrand48 c
2420lrand48_r c2425lrand48_r c
...@@ -2620,6 +2625,7 @@ openat c...@@ -2620,6 +2625,7 @@ openat c
2620openat64 c2625openat64 c
2621opendir c2626opendir c
2622openlog c2627openlog c
2628openpty util
2623optarg c2629optarg c
2624opterr c2630opterr c
2625optind c2631optind c
lib/libc/mingw/lib-common/shlwapi.def created+386
...@@ -0,0 +1,386 @@
1;
2; Definition file of SHLWAPI.dll
3; Automatic generated by gendef
4; written by Kai Tietz 2008-2014
5;
6LIBRARY "SHLWAPI.dll"
7EXPORTS
8ParseURLA
9ParseURLW
10SHAllocShared
11SHLockShared
12SHUnlockShared
13SHFreeShared
14SHCreateMemStream
15GetAcceptLanguagesA
16GetAcceptLanguagesW
17SHCreateThread
18IsCharSpaceW
19StrCmpNCA
20StrCmpNCW
21StrCmpNICA
22StrCmpNICW
23StrCmpCA
24StrCmpCW
25StrCmpICA
26StrCmpICW
27IUnknown_QueryStatus
28IUnknown_Exec
29ConnectToConnectionPoint
30IUnknown_AtomicRelease
31IUnknown_GetWindow
32IUnknown_SetSite
33IUnknown_QueryService
34IStream_Read
35SHMessageBoxCheckA
36SHMessageBoxCheckW
37IUnknown_Set
38SHStripMneumonicA
39SHIsChildOrSelf
40IStream_Write
41IStream_Reset
42IStream_Size
43SHAnsiToUnicode
44SHUnicodeToAnsi
45SHUnicodeToAnsiCP
46QISearch
47SHStripMneumonicW
48SHPinDllOfCLSID
49IUnknown_GetSite
50GUIDFromStringW
51WhichPlatform
52SHCreateWorkerWindowW
53SHRegGetIntW
54SHPackDispParamsV
55SHAnsiToAnsi
56SHUnicodeToUnicode
57SHFormatDateTimeA
58SHFormatDateTimeW
59MLLoadLibraryA
60MLLoadLibraryW
61ShellMessageBoxW
62MLFreeLibrary
63SHSendMessageBroadcastA
64SHSendMessageBroadcastW
65IsOS
66PathFileExistsAndAttributesW
67UrlFixupW
68SHRunIndirectRegClientCommand
69SHLoadIndirectString
70IStream_ReadPidl
71IStream_WritePidl
72SHGetViewStatePropertyBag
73IsInternetESCEnabled
74SHPropertyBag_ReadStrAlloc
75IStream_Copy
76DelayLoadFailureHook
77SHPropertyBag_WriteBSTR
78AssocCreate
79AssocGetPerceivedType
80AssocIsDangerous
81AssocQueryKeyA
82AssocQueryKeyW
83AssocQueryStringA
84AssocQueryStringByKeyA
85AssocQueryStringByKeyW
86AssocQueryStringW
87ChrCmpIA
88ChrCmpIW
89ColorAdjustLuma
90ColorHLSToRGB
91IStream_ReadStr
92IStream_WriteStr
93ColorRGBToHLS
94DllGetVersion
95GetMenuPosFromID
96HashData
97SHCreateThreadWithHandle
98IntlStrEqWorkerA
99IntlStrEqWorkerW
100IsCharSpaceA
101PathAddBackslashA
102PathAddBackslashW
103SHRegGetValueFromHKCUHKLM
104SHRegGetBoolValueFromHKCUHKLM
105PathAddExtensionA
106PathAddExtensionW
107PathAppendA
108PathAppendW
109PathBuildRootA
110PathBuildRootW
111PathCanonicalizeA
112PathCanonicalizeW
113PathCombineA
114PathCombineW
115PathCommonPrefixA
116PathCommonPrefixW
117PathCompactPathA
118PathCompactPathExA
119PathCompactPathExW
120PathCompactPathW
121PathCreateFromUrlA
122PathCreateFromUrlAlloc
123PathCreateFromUrlW
124PathFileExistsA
125PathFileExistsW
126PathFindExtensionA
127PathFindExtensionW
128PathFindFileNameA
129PathFindFileNameW
130PathFindNextComponentA
131PathFindNextComponentW
132PathFindOnPathA
133PathFindOnPathW
134PathFindSuffixArrayA
135PathFindSuffixArrayW
136PathGetArgsA
137PathGetArgsW
138PathGetCharTypeA
139PathGetCharTypeW
140PathGetDriveNumberA
141PathGetDriveNumberW
142PathIsContentTypeA
143PathIsContentTypeW
144PathIsDirectoryA
145PathIsDirectoryEmptyA
146PathIsDirectoryEmptyW
147PathIsDirectoryW
148PathIsFileSpecA
149PathIsFileSpecW
150PathIsLFNFileSpecA
151PathIsLFNFileSpecW
152PathIsNetworkPathA
153PathIsNetworkPathW
154PathIsPrefixA
155PathIsPrefixW
156PathIsRelativeA
157PathIsRelativeW
158PathIsRootA
159PathIsRootW
160PathIsSameRootA
161PathIsSameRootW
162PathIsSystemFolderA
163PathIsSystemFolderW
164PathIsUNCA
165PathIsUNCServerA
166PathIsUNCServerShareA
167PathIsUNCServerShareW
168PathIsUNCServerW
169PathIsUNCW
170PathIsURLA
171PathIsURLW
172PathMakePrettyA
173PathMakePrettyW
174PathMakeSystemFolderA
175PathMakeSystemFolderW
176PathMatchSpecA
177PathMatchSpecExA
178PathMatchSpecExW
179PathMatchSpecW
180PathParseIconLocationA
181PathParseIconLocationW
182PathQuoteSpacesA
183PathQuoteSpacesW
184PathRelativePathToA
185PathRelativePathToW
186PathRemoveArgsA
187PathRemoveArgsW
188PathRemoveBackslashA
189PathRemoveBackslashW
190PathRemoveBlanksA
191PathRemoveBlanksW
192PathRemoveExtensionA
193PathRemoveExtensionW
194PathRemoveFileSpecA
195PathRemoveFileSpecW
196PathRenameExtensionA
197PathRenameExtensionW
198PathSearchAndQualifyA
199PathSearchAndQualifyW
200PathSetDlgItemPathA
201PathSetDlgItemPathW
202PathSkipRootA
203PathSkipRootW
204PathStripPathA
205PathStripPathW
206PathStripToRootA
207PathStripToRootW
208PathUnExpandEnvStringsA
209PathUnExpandEnvStringsW
210PathUndecorateA
211PathUndecorateW
212PathUnmakeSystemFolderA
213PathUnmakeSystemFolderW
214PathUnquoteSpacesA
215PathUnquoteSpacesW
216SHAutoComplete
217SHCopyKeyA
218SHCopyKeyW
219SHCreateShellPalette
220SHCreateStreamOnFileA
221SHCreateStreamOnFileEx
222SHCreateStreamOnFileW
223SHCreateStreamWrapper
224SHCreateThreadRef
225SHDeleteEmptyKeyA
226SHDeleteEmptyKeyW
227SHDeleteKeyA
228SHDeleteKeyW
229SHDeleteOrphanKeyA
230SHDeleteOrphanKeyW
231SHDeleteValueA
232SHDeleteValueW
233SHEnumKeyExA
234SHEnumKeyExW
235SHEnumValueA
236SHEnumValueW
237SHGetInverseCMAP
238SHGetThreadRef
239SHGetValueA
240SHGetValueW
241SHIsLowMemoryMachine
242SHOpenRegStream2A
243SHOpenRegStream2W
244SHOpenRegStreamA
245SHOpenRegStreamW
246SHQueryInfoKeyA
247SHQueryInfoKeyW
248SHQueryValueExA
249SHQueryValueExW
250SHRegCloseUSKey
251SHRegCreateUSKeyA
252SHRegCreateUSKeyW
253SHRegDeleteEmptyUSKeyA
254SHRegDeleteEmptyUSKeyW
255SHRegDeleteUSValueA
256SHRegDeleteUSValueW
257SHRegDuplicateHKey
258SHRegEnumUSKeyA
259SHRegEnumUSKeyW
260SHRegEnumUSValueA
261SHRegEnumUSValueW
262SHRegGetBoolUSValueA
263SHRegGetBoolUSValueW
264SHRegGetPathA
265SHRegGetPathW
266SHRegGetUSValueA
267SHRegGetUSValueW
268SHRegGetValueA
269SHRegGetValueW
270SHRegOpenUSKeyA
271SHRegOpenUSKeyW
272SHRegQueryInfoUSKeyA
273SHRegQueryInfoUSKeyW
274SHRegQueryUSValueA
275SHRegQueryUSValueW
276SHRegSetPathA
277SHRegSetPathW
278SHRegSetUSValueA
279SHRegSetUSValueW
280SHRegWriteUSValueA
281SHRegWriteUSValueW
282SHRegisterValidateTemplate
283SHReleaseThreadRef
284SHSetThreadRef
285SHSetValueA
286SHSetValueW
287SHSkipJunction
288SHStrDupA
289SHStrDupW
290ShellMessageBoxA
291StrCSpnA
292StrCSpnIA
293StrCSpnIW
294StrCSpnW
295StrCatBuffA
296StrCatBuffW
297StrCatChainW
298StrCatW
299StrChrA
300StrChrIA
301StrChrIW
302StrChrNIW
303StrChrNW
304StrChrW
305StrCmpIW
306StrCmpLogicalW
307StrCmpNA
308StrCmpNIA
309StrCmpNIW
310StrCmpNW
311StrCmpW
312StrCpyNW
313StrCpyW
314StrDupA
315StrDupW
316StrFormatByteSize64A
317StrFormatByteSizeA
318StrFormatByteSizeEx
319StrFormatByteSizeW
320StrFormatKBSizeA
321StrFormatKBSizeW
322StrFromTimeIntervalA
323StrFromTimeIntervalW
324StrIsIntlEqualA
325StrIsIntlEqualW
326StrNCatA
327StrNCatW
328StrPBrkA
329StrPBrkW
330StrRChrA
331StrRChrIA
332StrRChrIW
333StrRChrW
334StrRStrIA
335StrRStrIW
336StrRetToBSTR
337StrRetToBufA
338StrRetToBufW
339StrRetToStrA
340StrRetToStrW
341StrSpnA
342StrSpnW
343StrStrA
344StrStrIA
345StrStrIW
346StrStrNIW
347StrStrNW
348StrStrW
349StrToInt64ExA
350StrToInt64ExW
351StrToIntA
352StrToIntExA
353StrToIntExW
354StrToIntW
355StrTrimA
356StrTrimW
357UrlApplySchemeA
358UrlApplySchemeW
359UrlCanonicalizeA
360UrlCanonicalizeW
361UrlCombineA
362UrlCombineW
363UrlCompareA
364UrlCompareW
365UrlCreateFromPathA
366UrlCreateFromPathW
367UrlEscapeA
368UrlEscapeW
369UrlGetLocationA
370UrlGetLocationW
371UrlGetPartA
372UrlGetPartW
373UrlHashA
374UrlHashW
375UrlIsA
376UrlIsNoHistoryA
377UrlIsNoHistoryW
378UrlIsOpaqueA
379UrlIsOpaqueW
380UrlIsW
381UrlUnescapeA
382UrlUnescapeW
383wnsprintfA
384wnsprintfW
385wvnsprintfA
386wvnsprintfW
lib/libc/mingw/lib32/shlwapi.def created+376
...@@ -0,0 +1,376 @@
1;
2; Definition file of SHLWAPI.dll
3; Automatic generated by gendef
4; written by Kai Tietz 2008
5;
6LIBRARY "SHLWAPI.dll"
7EXPORTS
8ParseURLA@8
9ParseURLW@8
10SHAllocShared@12
11SHLockShared@8
12SHUnlockShared@4
13SHFreeShared@8
14SHCreateMemStream@8
15GetAcceptLanguagesA@8
16GetAcceptLanguagesW@8
17SHCreateThread@16
18IsCharSpaceW@4
19StrCmpNCA@12
20StrCmpNCW@12
21StrCmpNICA@12
22StrCmpNICW@12
23StrCmpCA@8
24StrCmpCW@8
25StrCmpICA@8
26StrCmpICW@8
27ConnectToConnectionPoint@24
28IUnknown_AtomicRelease@4
29IUnknown_GetWindow@8
30IUnknown_SetSite@8
31IUnknown_QueryService@16
32IStream_Read@12
33SHMessageBoxCheckA@24
34SHMessageBoxCheckW@24
35IUnknown_Set@8
36SHStripMneumonicA@4
37SHIsChildOrSelf@8
38IStream_Write@12
39IStream_Reset@4
40IStream_Size@8
41SHAnsiToUnicode@12
42SHUnicodeToAnsi@12
43QISearch@16
44SHStripMneumonicW@4
45IUnknown_GetSite@12
46WhichPlatform@0
47SHRegGetIntW@12
48SHAnsiToAnsi@12
49SHUnicodeToUnicode@12
50SHFormatDateTimeA@16
51SHFormatDateTimeW@16
52MLLoadLibraryA@12
53MLLoadLibraryW@12
54ShellMessageBoxW@0
55MLFreeLibrary@0
56SHSendMessageBroadcastA@12
57SHSendMessageBroadcastW@12
58IsOS@4
59UrlFixupW@12
60SHRunIndirectRegClientCommand@8
61SHLoadIndirectString@16
62AssocCreate@24
63AssocGetPerceivedType@16
64AssocIsDangerous@4
65AssocQueryKeyA@20
66AssocQueryKeyW@20
67IStream_ReadPidl@8
68IStream_WritePidl@8
69SHGetViewStatePropertyBag@20
70IsInternetESCEnabled@0
71SHPropertyBag_ReadStrAlloc@12
72IStream_Copy@12
73DelayLoadFailureHook@8
74SHPropertyBag_WriteBSTR@12
75AssocQueryStringA@24
76AssocQueryStringByKeyA@24
77AssocQueryStringByKeyW@24
78AssocQueryStringW@24
79ChrCmpIA@8
80ChrCmpIW@8
81ColorAdjustLuma@12
82ColorHLSToRGB@12
83ColorRGBToHLS@16
84DllGetVersion@4
85GetMenuPosFromID@8
86HashData@16
87IntlStrEqWorkerA@16
88IStream_ReadStr@8
89IStream_WriteStr@8
90IntlStrEqWorkerW@16
91IsCharSpaceA@4
92PathAddBackslashA@4
93PathAddBackslashW@4
94PathAddExtensionA@8
95SHCreateThreadWithHandle@20
96PathAddExtensionW@8
97PathAppendA@8
98PathAppendW@8
99PathBuildRootA@8
100PathBuildRootW@8
101PathCanonicalizeA@8
102PathCanonicalizeW@8
103PathCombineA@12
104PathCombineW@12
105PathCommonPrefixA@12
106PathCommonPrefixW@12
107PathCompactPathA@12
108PathCompactPathExA@16
109PathCompactPathExW@16
110PathCompactPathW@12
111PathCreateFromUrlA@16
112PathCreateFromUrlAlloc@12
113PathCreateFromUrlW@16
114PathFileExistsA@4
115PathFileExistsW@4
116PathFindExtensionA@4
117PathFindExtensionW@4
118PathFindFileNameA@4
119PathFindFileNameW@4
120PathFindNextComponentA@4
121PathFindNextComponentW@4
122PathFindOnPathA@8
123PathFindOnPathW@8
124PathFindSuffixArrayA@12
125PathFindSuffixArrayW@12
126PathGetArgsA@4
127PathGetArgsW@4
128PathGetCharTypeA@4
129PathGetCharTypeW@4
130PathGetDriveNumberA@4
131PathGetDriveNumberW@4
132PathIsContentTypeA@8
133PathIsContentTypeW@8
134PathIsDirectoryA@4
135PathIsDirectoryEmptyA@4
136PathIsDirectoryEmptyW@4
137PathIsDirectoryW@4
138PathIsFileSpecA@4
139PathIsFileSpecW@4
140PathIsLFNFileSpecA@4
141PathIsLFNFileSpecW@4
142PathIsNetworkPathA@4
143PathIsNetworkPathW@4
144PathIsPrefixA@8
145PathIsPrefixW@8
146PathIsRelativeA@4
147PathIsRelativeW@4
148PathIsRootA@4
149PathIsRootW@4
150PathIsSameRootA@8
151PathIsSameRootW@8
152PathIsSystemFolderA@8
153PathIsSystemFolderW@8
154PathIsUNCA@4
155PathIsUNCServerA@4
156PathIsUNCServerShareA@4
157PathIsUNCServerShareW@4
158PathIsUNCServerW@4
159PathIsUNCW@4
160PathIsURLA@4
161PathIsURLW@4
162PathMakePrettyA@4
163PathMakePrettyW@4
164PathMakeSystemFolderA@4
165PathMakeSystemFolderW@4
166PathMatchSpecA@8
167PathMatchSpecExA@12
168PathMatchSpecExW@12
169PathMatchSpecW@8
170PathParseIconLocationA@4
171PathParseIconLocationW@4
172PathQuoteSpacesA@4
173PathQuoteSpacesW@4
174PathRelativePathToA@20
175PathRelativePathToW@20
176PathRemoveArgsA@4
177PathRemoveArgsW@4
178PathRemoveBackslashA@4
179PathRemoveBackslashW@4
180PathRemoveBlanksA@4
181PathRemoveBlanksW@4
182PathRemoveExtensionA@4
183PathRemoveExtensionW@4
184PathRemoveFileSpecA@4
185PathRemoveFileSpecW@4
186PathRenameExtensionA@8
187PathRenameExtensionW@8
188PathSearchAndQualifyA@12
189PathSearchAndQualifyW@12
190PathSetDlgItemPathA@12
191PathSetDlgItemPathW@12
192PathSkipRootA@4
193PathSkipRootW@4
194PathStripPathA@4
195PathStripPathW@4
196PathStripToRootA@4
197PathStripToRootW@4
198PathUnExpandEnvStringsA@12
199PathUnExpandEnvStringsW@12
200PathUndecorateA@4
201PathUndecorateW@4
202PathUnmakeSystemFolderA@4
203PathUnmakeSystemFolderW@4
204PathUnquoteSpacesA@4
205PathUnquoteSpacesW@4
206SHAutoComplete@8
207SHCopyKeyA@16
208SHCopyKeyW@16
209SHCreateShellPalette@4
210SHCreateStreamOnFileA@12
211SHCreateStreamOnFileEx@24
212SHCreateStreamOnFileW@12
213SHCreateStreamWrapper@16
214SHCreateThreadRef@8
215SHDeleteEmptyKeyA@8
216SHDeleteEmptyKeyW@8
217SHDeleteKeyA@8
218SHDeleteKeyW@8
219SHDeleteOrphanKeyA@8
220SHDeleteOrphanKeyW@8
221SHDeleteValueA@12
222SHDeleteValueW@12
223SHEnumKeyExA@16
224SHEnumKeyExW@16
225SHEnumValueA@28
226SHEnumValueW@28
227SHGetInverseCMAP@8
228SHGetThreadRef@4
229SHGetValueA@24
230SHGetValueW@24
231SHIsLowMemoryMachine@4
232SHOpenRegStream2A@16
233SHOpenRegStream2W@16
234SHOpenRegStreamA@16
235SHOpenRegStreamW@16
236SHQueryInfoKeyA@20
237SHQueryInfoKeyW@20
238SHQueryValueExA@24
239SHQueryValueExW@24
240SHRegCloseUSKey@4
241SHRegCreateUSKeyA@20
242SHRegCreateUSKeyW@20
243SHRegDeleteEmptyUSKeyA@12
244SHRegDeleteEmptyUSKeyW@12
245SHRegDeleteUSValueA@12
246SHRegDeleteUSValueW@12
247SHRegDuplicateHKey@4
248SHRegEnumUSKeyA@20
249SHRegEnumUSKeyW@20
250SHRegEnumUSValueA@32
251SHRegEnumUSValueW@32
252SHRegGetBoolUSValueA@16
253SHRegGetBoolUSValueW@16
254SHRegGetPathA@20
255SHRegGetPathW@20
256SHRegGetUSValueA@32
257SHRegGetUSValueW@32
258SHRegGetValueA@28
259SHRegGetValueW@28
260SHRegOpenUSKeyA@20
261SHRegOpenUSKeyW@20
262SHRegQueryInfoUSKeyA@24
263SHRegQueryInfoUSKeyW@24
264SHRegQueryUSValueA@32
265SHRegQueryUSValueW@32
266SHRegSetPathA@20
267SHRegSetPathW@20
268SHRegSetUSValueA@24
269SHRegSetUSValueW@24
270SHRegWriteUSValueA@24
271SHRegWriteUSValueW@24
272SHRegisterValidateTemplate@8
273SHReleaseThreadRef@0
274SHSetThreadRef@4
275SHSetValueA@24
276SHSetValueW@24
277SHSkipJunction@8
278SHStrDupA@8
279SHStrDupW@8
280ShellMessageBoxA@0
281StrCSpnA@8
282StrCSpnIA@8
283StrCSpnIW@8
284StrCSpnW@8
285StrCatBuffA@12
286StrCatBuffW@12
287StrCatChainW@16
288StrCatW@8
289StrChrA@8
290StrChrIA@8
291StrChrIW@8
292StrChrNIW@12
293StrChrNW@12
294StrChrW@8
295StrCmpIW@8
296StrCmpLogicalW@8
297StrCmpNA@12
298StrCmpNIA@12
299StrCmpNIW@12
300StrCmpNW@12
301StrCmpW@8
302StrCpyNW@12
303StrCpyW@8
304StrDupA@4
305StrDupW@4
306StrFormatByteSize64A@16
307StrFormatByteSizeA@12
308StrFormatByteSizeEx@20
309StrFormatByteSizeW@16
310StrFormatKBSizeA@16
311StrFormatKBSizeW@16
312StrFromTimeIntervalA@16
313StrFromTimeIntervalW@16
314StrIsIntlEqualA@16
315StrIsIntlEqualW@16
316StrNCatA@12
317StrNCatW@12
318StrPBrkA@8
319StrPBrkW@8
320StrRChrA@12
321StrRChrIA@12
322StrRChrIW@12
323StrRChrW@12
324StrRStrIA@12
325StrRStrIW@12
326StrRetToBSTR@12
327StrRetToBufA@16
328StrRetToBufW@16
329StrRetToStrA@12
330StrRetToStrW@12
331StrSpnA@8
332StrSpnW@8
333StrStrA@8
334StrStrIA@8
335StrStrIW@8
336StrStrNIW@12
337StrStrNW@12
338StrStrW@8
339StrToInt64ExA@12
340StrToInt64ExW@12
341StrToIntA@4
342StrToIntExA@12
343StrToIntExW@12
344StrToIntW@4
345StrTrimA@8
346StrTrimW@8
347UrlApplySchemeA@16
348UrlApplySchemeW@16
349UrlCanonicalizeA@16
350UrlCanonicalizeW@16
351UrlCombineA@20
352UrlCombineW@20
353UrlCompareA@12
354UrlCompareW@12
355UrlCreateFromPathA@16
356UrlCreateFromPathW@16
357UrlEscapeA@16
358UrlEscapeW@16
359UrlGetLocationA@4
360UrlGetLocationW@4
361UrlGetPartA@20
362UrlGetPartW@20
363UrlHashA@12
364UrlHashW@12
365UrlIsA@8
366UrlIsNoHistoryA@4
367UrlIsNoHistoryW@4
368UrlIsOpaqueA@4
369UrlIsOpaqueW@4
370UrlIsW@8
371UrlUnescapeA@16
372UrlUnescapeW@16
373wnsprintfA
374wnsprintfW
375wvnsprintfA@16
376wvnsprintfW@16
lib/libc/mingw/lib32/version.def created+16
...@@ -0,0 +1,16 @@
1LIBRARY "VERSION.dll"
2EXPORTS
3GetFileVersionInfoA@16
4GetFileVersionInfoSizeA@8
5GetFileVersionInfoSizeW@8
6GetFileVersionInfoW@16
7VerFindFileA@32
8VerFindFileW@32
9VerInstallFileA@32
10VerInstallFileW@32
11VerLanguageNameA@12
12VerLanguageNameW@12
13VerQueryValueA@16
14VerQueryValueIndexA@24
15VerQueryValueIndexW@24
16VerQueryValueW@16
lib/libc/mingw/libsrc/ativscp-uuid.c created+16
...@@ -0,0 +1,16 @@
1/* ativscp-uuid.c */
2/* Generate GUIDs for ActiveScript interfaces */
3
4/* All IIDs defined in this file were extracted from
5 * HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Interface\ */
6
7/* All CLSIDs defined in this file were extracted from
8 * HKEY_CLASSES_ROOT\CLSID\ */
9
10#define INITGUID
11#include <basetyps.h>
12DEFINE_GUID(IID_IActiveScript,0xbb1a2ae1,0xa4f9,0x11cf,0x8f,0x20,0,0x80,0x5f,0x2c,0xd0,0x64);
13DEFINE_GUID(IID_IActiveScriptError,0xeae1ba61,0xa4ed,0x11cf,0x8f,0x20,0,0x80,0x5f,0x2c,0xd0,0x64);
14DEFINE_GUID(IID_IActiveScriptParse,0xbb1a2ae2,0xa4f9,0x11cf,0x8f,0x20,0,0x80,0x5f,0x2c,0xd0,0x64);
15DEFINE_GUID(IID_IActiveScriptSite,0xdb01a1e3,0xa42b,0x11cf,0x8f,0x20,0,0x80,0x5f,0x2c,0xd0,0x64);
16DEFINE_GUID(IID_IActiveScriptSiteWindow,0xd10f6761,0x83e9,0x11cf,0x8f,0x20,0,0x80,0x5f,0x2c,0xd0,0x64);
lib/libc/mingw/libsrc/atsmedia-uuid.c created+7
...@@ -0,0 +1,7 @@
1/* from atsmedia.h */
2
3#define INITGUID
4#include <basetyps.h>
5
6DEFINE_GUID(BDANETWORKTYPE_ATSC, 0x71985F51, 0x1CA1, 0x11D3, 0x9C, 0xC8, 0x0, 0xC0, 0x4F, 0x79, 0x71, 0xE0);
7
lib/libc/mingw/libsrc/bth-uuid.c created+84
...@@ -0,0 +1,84 @@
1#define INITGUID
2#include <basetyps.h>
3
4DEFINE_GUID(GUID_BTHPORT_DEVICE_INTERFACE,0x0850302A,0xB344,0x4fda,0x9B,0xE9,0x90,0x57,0x6B,0x8D,0x46,0xF0);
5DEFINE_GUID(GUID_BLUETOOTH_RADIO_IN_RANGE,0xEA3B5B82,0x26EE,0x450E,0xB0,0xD8,0xD2,0x6F,0xE3,0x0A,0x38,0x69);
6DEFINE_GUID(GUID_BLUETOOTH_RADIO_OUT_OF_RANGE,0xE28867C9,0xC2AA,0x4CED,0xB9,0x69,0x45,0x70,0x86,0x60,0x37,0xC4);
7DEFINE_GUID(GUID_BLUETOOTH_PIN_REQUEST,0xBD198B7C,0x24AB,0x4B9A,0x8C,0x0D,0xA8,0xEA,0x83,0x49,0xAA,0x16);
8DEFINE_GUID(GUID_BLUETOOTH_L2CAP_EVENT,0x7EAE4030,0xB709,0x4AA8,0xAC,0x55,0xE9,0x53,0x82,0x9C,0x9D,0xAA);
9DEFINE_GUID(GUID_BLUETOOTH_HCI_EVENT,0xFC240062,0x1541,0x49BE,0xB4,0x63,0x84,0xC4,0xDC,0xD7,0xBF,0x7F);
10DEFINE_GUID(BLUETOOTH_BASE_UUID,0x00000000,0x0000,0x1000,0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB);
11DEFINE_GUID(SDP_PROTOCOL_UUID,0x00000001,0x0000,0x1000,0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB);
12DEFINE_GUID(UDP_PROTOCOL_UUID,0x00000002,0x0000,0x1000,0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB);
13DEFINE_GUID(RFCOMM_PROTOCOL_UUID,0x00000003,0x0000,0x1000,0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB);
14DEFINE_GUID(TCP_PROTOCOL_UUID,0x00000004,0x0000,0x1000,0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB);
15DEFINE_GUID(TCSBIN_PROTOCOL_UUID,0x00000005,0x0000,0x1000,0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB);
16DEFINE_GUID(TCSAT_PROTOCOL_UUID,0x00000006,0x0000,0x1000,0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB);
17DEFINE_GUID(OBEX_PROTOCOL_UUID,0x00000008,0x0000,0x1000,0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB);
18DEFINE_GUID(IP_PROTOCOL_UUID,0x00000009,0x0000,0x1000,0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB);
19DEFINE_GUID(FTP_PROTOCOL_UUID,0x0000000A,0x0000,0x1000,0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB);
20DEFINE_GUID(HTTP_PROTOCOL_UUID,0x0000000C,0x0000,0x1000,0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB);
21DEFINE_GUID(WSP_PROTOCOL_UUID,0x0000000E,0x0000,0x1000,0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB);
22DEFINE_GUID(BNEP_PROTOCOL_UUID,0x0000000F,0x0000,0x1000,0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB);
23DEFINE_GUID(UPNP_PROTOCOL_UUID,0x00000010,0x0000,0x1000,0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB);
24DEFINE_GUID(HCCC_PROTOCOL_UUID,0x00000012,0x0000,0x1000,0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB);
25DEFINE_GUID(HCDC_PROTOCOL_UUID,0x00000014,0x0000,0x1000,0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB);
26DEFINE_GUID(HN_PROTOCOL_UUID,0x00000016,0x0000,0x1000,0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB);
27DEFINE_GUID(AVCTP_PROTOCOL_UUID,0x00000017,0x0000,0x1000,0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB);
28DEFINE_GUID(AVDTP_PROTOCOL_UUID,0x00000019,0x0000,0x1000,0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB);
29DEFINE_GUID(CMPT_PROTOCOL_UUID,0x0000001B,0x0000,0x1000,0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB);
30DEFINE_GUID(UDI_C_PLANE_PROTOCOL_UUID,0x0000001D,0x0000,0x1000,0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB);
31DEFINE_GUID(L2CAP_PROTOCOL_UUID,0x00000100,0x0000,0x1000,0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB);
32
33DEFINE_GUID(ServiceDiscoveryServerServiceClassID_UUID,0x00001000,0x0000,0x1000,0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB);
34DEFINE_GUID(BrowseGroupDescriptorServiceClassID_UUID,0x00001001,0x0000,0x1000,0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB);
35DEFINE_GUID(PublicBrowseGroupServiceClass_UUID,0x00001002,0x0000,0x1000,0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB);
36DEFINE_GUID(SerialPortServiceClass_UUID,0x00001101,0x0000,0x1000,0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB);
37DEFINE_GUID(LANAccessUsingPPPServiceClass_UUID,0x00001102,0x0000,0x1000,0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB);
38DEFINE_GUID(DialupNetworkingServiceClass_UUID,0x00001103,0x0000,0x1000,0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB);
39DEFINE_GUID(IrMCSyncServiceClass_UUID,0x00001104,0x0000,0x1000,0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB);
40DEFINE_GUID(OBEXObjectPushServiceClass_UUID,0x00001105,0x0000,0x1000,0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB);
41DEFINE_GUID(OBEXFileTransferServiceClass_UUID,0x00001106,0x0000,0x1000,0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB);
42DEFINE_GUID(IrMCSyncCommandServiceClass_UUID,0x00001107,0x0000,0x1000,0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB);
43DEFINE_GUID(HeadsetServiceClass_UUID,0x00001108,0x0000,0x1000,0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB);
44DEFINE_GUID(CordlessTelephonyServiceClass_UUID,0x00001109,0x0000,0x1000,0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB);
45DEFINE_GUID(AudioSourceServiceClass_UUID,0x0000110A,0x0000,0x1000,0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB);
46DEFINE_GUID(AudioSinkServiceClass_UUID,0x0000110B,0x0000,0x1000,0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB);
47DEFINE_GUID(AVRemoteControlTargetServiceClass_UUID,0x0000110C,0x0000,0x1000,0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB);
48DEFINE_GUID(AdvancedAudioDistributionServiceClass_UUID,0x0000110D,0x0000,0x1000,0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB);
49DEFINE_GUID(AVRemoteControlServiceClass_UUID,0x0000110E,0x0000,0x1000,0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB);
50DEFINE_GUID(VideoConferencingServiceClass_UUID,0x0000110F,0x0000,0x1000,0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB);
51DEFINE_GUID(IntercomServiceClass_UUID,0x00001110,0x0000,0x1000,0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB);
52DEFINE_GUID(FaxServiceClass_UUID,0x00001111,0x0000,0x1000,0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB);
53DEFINE_GUID(HeadsetAudioGatewayServiceClass_UUID,0x00001112,0x0000,0x1000,0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB);
54DEFINE_GUID(WAPServiceClass_UUID,0x00001113,0x0000,0x1000,0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB);
55DEFINE_GUID(WAPClientServiceClass_UUID,0x00001114,0x0000,0x1000,0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB);
56DEFINE_GUID(PANUServiceClass_UUID,0x00001115,0x0000,0x1000,0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB);
57DEFINE_GUID(NAPServiceClass_UUID,0x00001116,0x0000,0x1000,0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB);
58DEFINE_GUID(GNServiceClass_UUID,0x00001117,0x0000,0x1000,0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB);
59DEFINE_GUID(DirectPrintingServiceClass_UUID,0x00001118,0x0000,0x1000,0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB);
60DEFINE_GUID(ReferencePrintingServiceClass_UUID,0x00001119,0x0000,0x1000,0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB);
61DEFINE_GUID(ImagingServiceClass_UUID,0x0000111A,0x0000,0x1000,0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB);
62DEFINE_GUID(ImagingResponderServiceClass_UUID,0x0000111B,0x0000,0x1000,0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB);
63DEFINE_GUID(ImagingAutomaticArchiveServiceClass_UUID,0x0000111C,0x0000,0x1000,0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB);
64DEFINE_GUID(ImagingReferenceObjectsServiceClass_UUID,0x0000111D,0x0000,0x1000,0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB);
65DEFINE_GUID(HandsfreeServiceClass_UUID,0x0000111E,0x0000,0x1000,0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB);
66DEFINE_GUID(HandsfreeAudioGatewayServiceClass_UUID,0x0000111F,0x0000,0x1000,0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB);
67DEFINE_GUID(DirectPrintingReferenceObjectsServiceClass_UUID,0x00001120,0x0000,0x1000,0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB);
68DEFINE_GUID(ReflectedUIServiceClass_UUID,0x00001121,0x0000,0x1000,0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB);
69DEFINE_GUID(BasicPringingServiceClass_UUID,0x00001122,0x0000,0x1000,0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB);
70DEFINE_GUID(PrintingStatusServiceClass_UUID,0x00001123,0x0000,0x1000,0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB);
71DEFINE_GUID(HumanInterfaceDeviceServiceClass_UUID,0x00001124,0x0000,0x1000,0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB);
72DEFINE_GUID(HardcopyCableReplacementServiceClass_UUID,0x00001125,0x0000,0x1000,0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB);
73DEFINE_GUID(HCRPrintServiceClass_UUID,0x00001126,0x0000,0x1000,0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB);
74DEFINE_GUID(HCRScanServiceClass_UUID,0x00001127,0x0000,0x1000,0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB);
75DEFINE_GUID(CommonISDNAccessServiceClass_UUID,0x00001128,0x0000,0x1000,0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB);
76DEFINE_GUID(VideoConferencingGWServiceClass_UUID,0x00001129,0x0000,0x1000,0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB);
77DEFINE_GUID(UDIMTServiceClass_UUID,0x0000112A,0x0000,0x1000,0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB);
78DEFINE_GUID(UDITAServiceClass_UUID,0x0000112B,0x0000,0x1000,0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB);
79DEFINE_GUID(AudioVideoServiceClass_UUID,0x0000112C,0x0000,0x1000,0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB);
80DEFINE_GUID(PnPInformationServiceClass_UUID,0x00001200,0x0000,0x1000,0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB);
81DEFINE_GUID(GenericNetworkingServiceClass_UUID,0x00001201,0x0000,0x1000,0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB);
82DEFINE_GUID(GenericFileTransferServiceClass_UUID,0x00001202,0x0000,0x1000,0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB);
83DEFINE_GUID(GenericAudioServiceClass_UUID,0x00001203,0x0000,0x1000,0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB);
84DEFINE_GUID(GenericTelephonyServiceClass_UUID,0x00001204,0x0000,0x1000,0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB);
lib/libc/mingw/libsrc/cguid-uuid.c created+19
...@@ -0,0 +1,19 @@
1/* cguid-uuid.c */
2/* Generate GUIDs for CGUID interfaces */
3
4/* All IIDs defined in this file were extracted from
5 * HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Interface\ */
6
7/* All CLSIDs defined in this file were extracted from
8 * HKEY_CLASSES_ROOT\CLSID\ */
9
10#define INITGUID
11#include <basetyps.h>
12DEFINE_OLEGUID(IID_IRpcChannel,0x4,0,0);
13DEFINE_OLEGUID(IID_IRpcStub,0x5,0,0);
14DEFINE_OLEGUID(IID_IRpcProxy,0x7,0,0);
15DEFINE_OLEGUID(IID_IPSFactory,0x9,0,0);
16// Picture (Device Independant Bitmap) CLSID
17DEFINE_OLEGUID(CLSID_StaticDib,0x316,0,0);
18// Picture (Metafile) CLSID
19DEFINE_OLEGUID(CLSID_StaticMetafile,0x315,0,0);
lib/libc/mingw/libsrc/comcat-uuid.c created+30
...@@ -0,0 +1,30 @@
1/* comcat-uuid.c */
2/* Generate GUIDs for COMCAT interfaces */
3
4/* All IIDs defined in this file were extracted from
5 * HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Interface\ */
6
7/* All CLSIDs defined in this file were extracted from
8 * HKEY_CLASSES_ROOT\CLSID\ */
9
10#define INITGUID
11#include <basetyps.h>
12DEFINE_OLEGUID(IID_IEnumGUID,0x2e000,0,0);
13DEFINE_OLEGUID(IID_ICatInformation,0x2e013,0,0);
14DEFINE_OLEGUID(IID_ICatRegister,0x2e012,0,0);
15DEFINE_OLEGUID(IID_IEnumCATEGORYINFO,0x2e011,0,0);
16// Component Catagories Manager CLSID
17DEFINE_OLEGUID(CLSID_StdComponentCategoriesMgr,0x2e005,0,0);
18// Implemented Categories under Outlook Express MsgTable Object CLSID
19DEFINE_GUID(CATID_Insertable,0x40fc6ed3,0x2438,0x11cf,0xa3,0xdb,0x8,0,0x36,0xf1,0x25,0x2);
20DEFINE_GUID(CATID_Control,0x40fc6ed4,0x2438,0x11cf,0xa3,0xdb,0x8,0,0x36,0xf1,0x25,0x2);
21// Implemented Categories under Microsoft PowerPoint Slide CLSID
22DEFINE_GUID(CATID_DocObject,0x40fc6ed8,0x2438,0x11cf,0xa3,0xdb,0x8,0,0x36,0xf1,0x25,0x2);
23// Implemented Categories under Microsoft Toolbar Control CLSID
24DEFINE_GUID(CATID_Programmable,0x40fc6ed5,0x2438,0x11cf,0xa3,0xdb,0x8,0,0x36,0xf1,0x25,0x2);
25// Implemented Categories under SSCommand Control CLSID
26DEFINE_GUID(CATID_Printable,0x40fc6ed9,0x2438,0x11cf,0xa3,0xdb,0x8,0,0x36,0xf1,0x25,0x2);
27DEFINE_GUID(CATID_PersistsToStorage,0xde86a52,0x2baa,0x11cf,0xa2,0x29,0,0xaa,0,0x3d,0x73,0x52);
28DEFINE_GUID(CATID_PersistsToPropertyBag,0xde86a57,0x2baa,0x11cf,0xa2,0x29,0,0xaa,0,0x3d,0x73,0x52);
29DEFINE_GUID(CATID_PersistsToStream,0xde86a54,0x2baa,0x11cf,0xa2,0x29,0,0xaa,0,0x3d,0x73,0x52);
30DEFINE_GUID(CATID_PersistsToStreamInit,0xde86a53,0x2baa,0x11cf,0xa2,0x29,0,0xaa,0,0x3d,0x73,0x52);
lib/libc/mingw/libsrc/devguid.c created+61
...@@ -0,0 +1,61 @@
1/*
2 Generate GUIDs for device classes for PnP and SetupAPI
3
4 This file was generated by extracting the UUIDs from the registry at
5 \\SYSTEM\\CurrentControlSet\\Control\\Class and pairing them with
6 the class name in the registry value "Class" with GUID_DEVCLASS_ prepended
7 */
8
9#define INITGUID
10#include <basetyps.h>
11DEFINE_GUID(GUID_DEVCLASS_WCEUSBS, 0x25DBCE51, 0x6C8F, 0x4A72, 0x8A, 0x6D, 0xB5, 0x4C, 0x2B, 0x4F, 0xC8, 0x35);
12DEFINE_GUID(GUID_DEVCLASS_USB, 0x36FC9E60, 0xC465, 0x11CF, 0x80, 0x56, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00);
13DEFINE_GUID(GUID_DEVCLASS_PNPPRINTERS, 0x4658EE7E, 0xF050, 0x11D1, 0xB6, 0xBD, 0x00, 0xC0, 0x4F, 0xA3, 0x72, 0xA7);
14DEFINE_GUID(GUID_DEVCLASS_DOT4, 0x48721B56, 0x6795, 0x11D2, 0xB1, 0xA8, 0x00, 0x80, 0xC7, 0x2E, 0x74, 0xA2);
15DEFINE_GUID(GUID_DEVCLASS_DOT4PRINT, 0x49CE6AC8, 0x6F86, 0x11D2, 0xB1, 0xE5, 0x00, 0x80, 0xC7, 0x2E, 0x74, 0xA2);
16DEFINE_GUID(GUID_DEVCLASS_CDROM, 0x4D36E965, 0xE325, 0x11CE, 0xBF, 0xC1, 0x08, 0x00, 0x2B, 0xE1, 0x03, 0x18);
17DEFINE_GUID(GUID_DEVCLASS_COMPUTER, 0x4D36E966, 0xE325, 0x11CE, 0xBF, 0xC1, 0x08, 0x00, 0x2B, 0xE1, 0x03, 0x18);
18DEFINE_GUID(GUID_DEVCLASS_DISKDRIVE, 0x4D36E967, 0xE325, 0x11CE, 0xBF, 0xC1, 0x08, 0x00, 0x2B, 0xE1, 0x03, 0x18);
19DEFINE_GUID(GUID_DEVCLASS_DISPLAY, 0x4D36E968, 0xE325, 0x11CE, 0xBF, 0xC1, 0x08, 0x00, 0x2B, 0xE1, 0x03, 0x18);
20DEFINE_GUID(GUID_DEVCLASS_FDC, 0x4D36E969, 0xE325, 0x11CE, 0xBF, 0xC1, 0x08, 0x00, 0x2B, 0xE1, 0x03, 0x18);
21DEFINE_GUID(GUID_DEVCLASS_HDC, 0x4D36E96A, 0xE325, 0x11CE, 0xBF, 0xC1, 0x08, 0x00, 0x2B, 0xE1, 0x03, 0x18);
22DEFINE_GUID(GUID_DEVCLASS_KEYBOARD, 0x4D36E96B, 0xE325, 0x11CE, 0xBF, 0xC1, 0x08, 0x00, 0x2B, 0xE1, 0x03, 0x18);
23DEFINE_GUID(GUID_DEVCLASS_MEDIA, 0x4D36E96C, 0xE325, 0x11CE, 0xBF, 0xC1, 0x08, 0x00, 0x2B, 0xE1, 0x03, 0x18);
24DEFINE_GUID(GUID_DEVCLASS_MODEM, 0x4D36E96D, 0xE325, 0x11CE, 0xBF, 0xC1, 0x08, 0x00, 0x2B, 0xE1, 0x03, 0x18);
25DEFINE_GUID(GUID_DEVCLASS_MONITOR, 0x4D36E96E, 0xE325, 0x11CE, 0xBF, 0xC1, 0x08, 0x00, 0x2B, 0xE1, 0x03, 0x18);
26DEFINE_GUID(GUID_DEVCLASS_MOUSE, 0x4D36E96F, 0xE325, 0x11CE, 0xBF, 0xC1, 0x08, 0x00, 0x2B, 0xE1, 0x03, 0x18);
27DEFINE_GUID(GUID_DEVCLASS_MTD, 0x4D36E970, 0xE325, 0x11CE, 0xBF, 0xC1, 0x08, 0x00, 0x2B, 0xE1, 0x03, 0x18);
28DEFINE_GUID(GUID_DEVCLASS_MULTIFUNCTION, 0x4D36E971, 0xE325, 0x11CE, 0xBF, 0xC1, 0x08, 0x00, 0x2B, 0xE1, 0x03, 0x18);
29DEFINE_GUID(GUID_DEVCLASS_NET, 0x4D36E972, 0xE325, 0x11CE, 0xBF, 0xC1, 0x08, 0x00, 0x2b, 0xE1, 0x03, 0x18);
30DEFINE_GUID(GUID_DEVCLASS_NETCLIENT, 0x4D36E973, 0xE325, 0x11CE, 0xBF, 0xC1, 0x08, 0x00, 0x2B, 0xE1, 0x03, 0x18);
31DEFINE_GUID(GUID_DEVCLASS_NETSERVICE, 0x4D36E974, 0xE325, 0x11CE, 0xBF, 0xC1, 0x08, 0x00, 0x2B, 0xE1, 0x03, 0x18);
32DEFINE_GUID(GUID_DEVCLASS_NETTRANS, 0x4D36E975, 0xE325, 0x11CE, 0xBF, 0xC1, 0x08, 0x00, 0x2B, 0xE1, 0x03, 0x18);
33DEFINE_GUID(GUID_DEVCLASS_PCMCIA, 0x4D36E977, 0xE325, 0x11CE, 0xBF, 0xC1, 0x08, 0x00, 0x2B, 0xE1, 0x03, 0x18);
34DEFINE_GUID(GUID_DEVCLASS_PORTS, 0x4D36E978, 0xE325, 0x11CE, 0xBF, 0xC1, 0x08, 0x00, 0x2B, 0xE1, 0x03, 0x18);
35DEFINE_GUID(GUID_DEVCLASS_PRINTER, 0x4D36E979, 0xE325, 0x11CE, 0xBF, 0xC1, 0x08, 0x00, 0x2B, 0xE1, 0x03, 0x18);
36DEFINE_GUID(GUID_DEVCLASS_SCSIADAPTER, 0x4D36E97B, 0xE325, 0x11CE, 0xBF, 0xC1, 0x08, 0x00, 0x2B, 0xE1, 0x03, 0x18);
37DEFINE_GUID(GUID_DEVCLASS_SYSTEM, 0x4D36E97D, 0xE325, 0x11CE, 0xBF, 0xC1, 0x08, 0x00, 0x2B, 0xE1, 0x03, 0x18);
38DEFINE_GUID(GUID_DEVCLASS_UNKNOWN, 0x4D36E97E, 0xE325, 0x11CE, 0xBF, 0xC1, 0x08, 0x00, 0x2B, 0xE1, 0x03, 0x18);
39DEFINE_GUID(GUID_DEVCLASS_FLOPPYDISK, 0x4D36E980, 0xE325, 0x11CE, 0xBF, 0xC1, 0x08, 0x00, 0x2B, 0xE1, 0x03, 0x18);
40DEFINE_GUID(GUID_DEVCLASS_PROCESSOR, 0x50127DC3, 0x0F36, 0x415E, 0xA6, 0xCC, 0x4C, 0xB3, 0xBE, 0x91, 0x0B, 0x65);
41DEFINE_GUID(GUID_DEVCLASS_MULTIPORTSERIAL, 0x50906CB8, 0xBA12, 0x11D1, 0xBF, 0x5D, 0x00, 0x00, 0xF8, 0x05, 0xF5, 0x30);
42DEFINE_GUID(GUID_DEVCLASS_SMARTCARDREADER, 0x50DD5230, 0xBA8A, 0x11D1, 0xBF, 0x5D, 0x00, 0x00, 0xF8, 0x05, 0xF5, 0x30);
43DEFINE_GUID(GUID_DEVCLASS_VOLUMESNAPSHOT, 0x533C5B84, 0xEC70, 0x11D2, 0x95, 0x05, 0x00, 0xC0, 0x4F, 0x79, 0xDE, 0xAF);
44DEFINE_GUID(GUID_DEVCLASS_1394DEBUG, 0x66F250D6, 0x7801, 0x4A64, 0xB1, 0x39, 0xEE, 0xA8, 0x0A, 0x45, 0x0B, 0x24);
45DEFINE_GUID(GUID_DEVCLASS_1394, 0x6BDD1FC1, 0x810F, 0x11D0, 0xBE, 0xC7, 0x08, 0x00, 0x2B, 0xE2, 0x09, 0x2F);
46DEFINE_GUID(GUID_DEVCLASS_INFRARED, 0x6BDD1FC5, 0x810F, 0x11D0, 0xBE, 0xC7, 0x08, 0x00, 0x2B, 0xE2, 0x09, 0x2F);
47DEFINE_GUID(GUID_DEVCLASS_IMAGE, 0x6BDD1FC6, 0x810F, 0x11D0, 0xBE, 0xC7, 0x08, 0x00, 0x2B, 0xE2, 0x09, 0x2F);
48DEFINE_GUID(GUID_DEVCLASS_TAPEDRIVE, 0x6D807884, 0x7D21, 0x11CF, 0x80, 0x1C, 0x08, 0x00, 0x2B, 0xE1, 0x03, 0x18);
49DEFINE_GUID(GUID_DEVCLASS_VOLUME, 0x71A27CDD, 0x812A, 0x11D0, 0xBE, 0xC7, 0x08, 0x00, 0x2B, 0xE2, 0x09, 0x2F);
50DEFINE_GUID(GUID_DEVCLASS_BATTERY, 0x72631E54, 0x78A4, 0x11D0, 0xBC, 0xF7, 0x00, 0xAA, 0x00, 0xB7, 0xB3, 0x2A);
51DEFINE_GUID(GUID_DEVCLASS_HIDCLASS, 0x745A17A0, 0x74D3, 0x11D0, 0xB6, 0xFE, 0x00, 0xA0, 0xC9, 0x0F, 0x57, 0xDA);
52DEFINE_GUID(GUID_DEVCLASS_61883, 0x7EBEFBC0, 0x3200, 0x11D2, 0xB4, 0xC2, 0x00, 0xA0, 0xC9, 0x69, 0x7D, 0x07);
53DEFINE_GUID(GUID_DEVCLASS_LEGACYDRIVER, 0x8ECC055D, 0x047F, 0x11D1, 0xA5, 0x37, 0x00, 0x00, 0xF8, 0x75, 0x3E, 0xD1);
54DEFINE_GUID(GUID_DEVCLASS_SDHOST, 0xA0A588A4, 0xC46F, 0x4B37, 0xB7, 0xEA, 0xC8, 0x2F, 0xE8, 0x98, 0x70, 0xC6);
55DEFINE_GUID(GUID_DEVCLASS_AVC, 0xC06FF265, 0xAE09, 0x48F0, 0x81, 0x2C, 0x16, 0x75, 0x3D, 0x7C, 0xBA, 0x83);
56DEFINE_GUID(GUID_DEVCLASS_ENUM1394, 0xC459DF55, 0xDB08, 0x11D1, 0xB0, 0x09, 0x00, 0xA0, 0xC9, 0x08, 0x1F, 0xF6);
57DEFINE_GUID(GUID_DEVCLASS_MEDIUMCHANGER, 0xCE5939AE, 0xEBDE, 0x11D0, 0xB1, 0x81, 0x00, 0x00, 0xF8, 0x75, 0x3E, 0xC4);
58DEFINE_GUID(GUID_DEVCLASS_NTAPM, 0xD45B1C18, 0xC8FA, 0x11D1, 0x9F, 0x77, 0x00, 0x00, 0xF8, 0x05, 0xF5, 0x30);
59DEFINE_GUID(GUID_DEVCLASS_SBP2, 0xD48179BE, 0xEC20, 0x11D1, 0xB6, 0xB8, 0x00, 0xC0, 0x4F, 0xA3, 0x72, 0xA7);
60DEFINE_GUID(GUID_DEVCLASS_BLUETOOTH, 0xE0CBF06C, 0xCD8B, 0x4647, 0xBB, 0x8A, 0x26, 0x3B, 0x43, 0xF0, 0xF9, 0x74);
61DEFINE_GUID(GUID_DEVCLASS_PROBES, 0xFD02DFAC, 0x6A7C, 0x4391, 0x97, 0xDA, 0xF8, 0x1F, 0xEF, 0x1F, 0xC9, 0xD3);
lib/libc/mingw/libsrc/docobj-uuid.c created+15
...@@ -0,0 +1,15 @@
1/* docobj-uuid.c */
2/* Generate GUIDs for Document Object interfaces */
3
4/* All IIDs defined in this file were extracted from
5 * HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Interface\ */
6
7#define INITGUID
8#include <basetyps.h>
9DEFINE_GUID(IID_IContinueCallback,0xb722bcca,0x4e68,0x101b,0xa2,0xbc,0,0xaa,0,0x40,0x47,0x70);
10DEFINE_GUID(IID_IEnumOleDocumentViews,0xb722bcc8,0x4e68,0x101b,0xa2,0xbc,0,0xaa,0,0x40,0x47,0x70);
11DEFINE_GUID(IID_IPrint,0xb722bcc9,0x4e68,0x101b,0xa2,0xbc,0,0xaa,0,0x40,0x47,0x70);
12DEFINE_GUID(IID_IOleDocument,0xb722bcc5,0x4e68,0x101b,0xa2,0xbc,0,0xaa,0,0x40,0x47,0x70);
13DEFINE_GUID(IID_IOleDocumentView,0xb722bcc6,0x4e68,0x101b,0xa2,0xbc,0,0xaa,0,0x40,0x47,0x70);
14DEFINE_GUID(IID_IOleDocumentSite,0xb722bcc7,0x4e68,0x101b,0xa2,0xbc,0,0xaa,0,0x40,0x47,0x70);
15DEFINE_GUID(IID_IOleCommandTarget,0xb722bccb,0x4e68,0x101b,0xa2,0xbc,0,0xaa,0,0x40,0x47,0x70);
lib/libc/mingw/libsrc/dxva-uuid.c created+40
...@@ -0,0 +1,40 @@
1/**
2 * DISCLAIMER
3 * This file has no copyright assigned and is placed in the Public Domain.
4 * This file is part of the mingw-w64 runtime package.
5 *
6 * The mingw-w64 runtime package and its code is distributed in the hope that it
7 * will be useful but WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESSED OR
8 * IMPLIED ARE HEREBY DISCLAIMED. This includes but is not limited to
9 * warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10 */
11
12#if defined(__LCC__) || defined(__GNUC__)
13#define INITGUID 1
14#include <windows.h>
15#else
16#include <basetyps.h>
17#endif
18
19DEFINE_GUID(IID_IDirectXVideoDecoderService, 0xfc51a551, 0xd5e7, 0x11d9, 0xaf,0x55,0x00,0x05,0x4e,0x43,0xff,0x02);
20DEFINE_GUID(IID_IDirectXVideoAccelerationService, 0xfc51a550, 0xd5e7, 0x11d9, 0xaf,0x55,0x00,0x05,0x4e,0x43,0xff,0x02);
21
22DEFINE_GUID(DXVA2_ModeMPEG2_MoComp, 0xe6a9f44b, 0x61b0,0x4563, 0x9e,0xa4,0x63,0xd2,0xa3,0xc6,0xfe,0x66);
23DEFINE_GUID(DXVA2_ModeMPEG2_IDCT, 0xbf22ad00, 0x03ea,0x4690, 0x80,0x77,0x47,0x33,0x46,0x20,0x9b,0x7e);
24DEFINE_GUID(DXVA2_ModeMPEG2_VLD, 0xee27417f, 0x5e28,0x4e65, 0xbe,0xea,0x1d,0x26,0xb5,0x08,0xad,0xc9);
25DEFINE_GUID(DXVA2_ModeH264_A, 0x1b81be64, 0xa0c7,0x11d3, 0xb9,0x84,0x00,0xc0,0x4f,0x2e,0x73,0xc5);
26DEFINE_GUID(DXVA2_ModeH264_B, 0x1b81be65, 0xa0c7,0x11d3, 0xb9,0x84,0x00,0xc0,0x4f,0x2e,0x73,0xc5);
27DEFINE_GUID(DXVA2_ModeH264_C, 0x1b81be66, 0xa0c7,0x11d3, 0xb9,0x84,0x00,0xc0,0x4f,0x2e,0x73,0xc5);
28DEFINE_GUID(DXVA2_ModeH264_D, 0x1b81be67, 0xa0c7,0x11d3, 0xb9,0x84,0x00,0xc0,0x4f,0x2e,0x73,0xc5);
29DEFINE_GUID(DXVA2_ModeH264_E, 0x1b81be68, 0xa0c7,0x11d3, 0xb9,0x84,0x00,0xc0,0x4f,0x2e,0x73,0xc5);
30DEFINE_GUID(DXVA2_ModeH264_F, 0x1b81be69, 0xa0c7,0x11d3, 0xb9,0x84,0x00,0xc0,0x4f,0x2e,0x73,0xc5);
31DEFINE_GUID(DXVA2_ModeWMV8_A, 0x1b81be80, 0xa0c7,0x11d3, 0xb9,0x84,0x00,0xc0,0x4f,0x2e,0x73,0xc5);
32DEFINE_GUID(DXVA2_ModeWMV8_B, 0x1b81be81, 0xa0c7,0x11d3, 0xb9,0x84,0x00,0xc0,0x4f,0x2e,0x73,0xc5);
33DEFINE_GUID(DXVA2_ModeWMV9_A, 0x1b81be90, 0xa0c7,0x11d3, 0xb9,0x84,0x00,0xc0,0x4f,0x2e,0x73,0xc5);
34DEFINE_GUID(DXVA2_ModeWMV9_B, 0x1b81be91, 0xa0c7,0x11d3, 0xb9,0x84,0x00,0xc0,0x4f,0x2e,0x73,0xc5);
35DEFINE_GUID(DXVA2_ModeWMV9_C, 0x1b81be94, 0xa0c7,0x11d3, 0xb9,0x84,0x00,0xc0,0x4f,0x2e,0x73,0xc5);
36DEFINE_GUID(DXVA2_ModeVC1_A, 0x1b81beA0, 0xa0c7,0x11d3, 0xb9,0x84,0x00,0xc0,0x4f,0x2e,0x73,0xc5);
37DEFINE_GUID(DXVA2_ModeVC1_B, 0x1b81beA1, 0xa0c7,0x11d3, 0xb9,0x84,0x00,0xc0,0x4f,0x2e,0x73,0xc5);
38DEFINE_GUID(DXVA2_ModeVC1_C, 0x1b81beA2, 0xa0c7,0x11d3, 0xb9,0x84,0x00,0xc0,0x4f,0x2e,0x73,0xc5);
39DEFINE_GUID(DXVA2_ModeVC1_D, 0x1b81beA3, 0xa0c7,0x11d3, 0xb9,0x84,0x00,0xc0,0x4f,0x2e,0x73,0xc5);
40DEFINE_GUID(DXVA_NoEncrypt, 0x1b81bed0, 0xa0c7,0x11d3, 0xb9,0x84,0x00,0xc0,0x4f,0x2e,0x73,0xc5);
lib/libc/mingw/libsrc/exdisp-uuid.c created+18
...@@ -0,0 +1,18 @@
1/* exdisp-uuid.c */
2/* Generate GUIDs for Object EXDISP interfaces */
3
4/* All IIDs defined in this file were extracted from
5 * HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Interface\ */
6
7/* All CLSIDs defined in this file were extracted from
8 * HKEY_CLASSES_ROOT\CLSID\ */
9
10#define INITGUID
11#include <basetyps.h>
12// Microsoft Web Browser CLSID
13DEFINE_GUID(CLSID_WebBrowser,0x8856f961,0x340a,0x11d0,0xa9,0x6b,0x0,0xc0,0x4f,0xd7,0x5,0xa2);
14DEFINE_GUID(DIID_DWebBrowserEvents,0xeab22ac2,0x30c1,0x11cf,0xa7,0xeb,0x0,0x0,0xc0,0x5b,0xae,0x0b);
15DEFINE_GUID(DIID_DWebBrowserEvents2,0x34a715a0,0x6587,0x11d0,0x92,0x4a,0x0,0x20,0xaf,0xc7,0xac,0x4d);
16DEFINE_GUID(IID_IWebBrowser,0xeab22ac1,0x30c1,0x11cf,0xa7,0xeb,0x0,0x0,0xc0,0x5b,0xae,0x0b);
17DEFINE_GUID(IID_IWebBrowser2,0xd30c1661,0xcdaf,0x11d0,0x8a,0x3e,0x0,0xc0,0x4f,0xc9,0xe2,0x6e);
18DEFINE_GUID(IID_IWebBrowserApp,0x2df05,0x0,0x0,0xc0,0x0,0x0,0x0,0x0,0x0,0x0,0x46);
lib/libc/mingw/libsrc/extras-uuid.c created+42
...@@ -0,0 +1,42 @@
1/* extras-uuid.c */
2/* Generate GUIDs for interfaces not defined in any headers*/
3
4/* All IIDs defined in this file were extracted from
5 * HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Interface\ */
6
7/* All CLSIDs defined in this file were extracted from
8 * HKEY_CLASSES_ROOT\CLSID\ */
9
10#define INITGUID
11#include <basetyps.h>
12// Microsoft Web Browser CLSID
13DEFINE_GUID(IID_IClientSiteHandler,0xf4f569d1,0x593b,0x101a,0xb5,0x69,0x8,0,0x2b,0x2d,0xbf,0x7a);
14DEFINE_OLEGUID(IID_IContinue,0x12a,0,0);
15DEFINE_GUID(IID_IHttpNegotiate,0x79eac9d2,0xbaf9,0x11ce,0x8c,0x82,0,0xaa,0,0x4b,0xa9,0xb);
16DEFINE_GUID(IID_IPersistMoniker,0x79eac9c9,0xbaf9,0x11ce,0x8c,0x82,0,0xaa,0,0x4b,0xa9,0x0b);
17DEFINE_GUID(IID_IServerHandler,0xf4f569d0,0x593b,0x101a,0xb5,0x69,0x8,0,0x2b,0x2d,0xbf,0x7a);
18DEFINE_GUID(IID_ITargetEmbedding,0x548793c0,0x9e74,0x11cf,0x96,0x55,0,0xa0,0xc9,0x3,0x49,0x23);
19DEFINE_GUID(IID_ITargetFrame,0xd5f78c80,0x5252,0x11cf,0x90,0xfa,0,0xaa,0,0x42,0x10,0x6e);
20DEFINE_OLEGUID(IID_ITypeComp,0x20403,0,0);
21DEFINE_GUID(IID_IUrlHistoryStg,0x3c374a41,0xbae4,0x11cf,0xbf,0x7d,0,0xaa,0,0x69,0x46,0xee);
22DEFINE_GUID(IID_IWinInetHttpInfo,0x79eac9d8,0xbafa,0x11ce,0x8c,0x82,0,0xaa,0,0x4b,0xa9,0xb);
23DEFINE_GUID(IID_IWinInetInfo,0x79eac9d6,0xbafa,0x11ce,0x8c,0x82,0,0xaa,0,0x4b,0xa9,0xb);
24DEFINE_OLEGUID(IID_IEnumSTATPROPSETSTG,0x13b,0,0);
25DEFINE_OLEGUID(IID_IEnumSTATPROPSTG,0x139,0,0);
26DEFINE_GUID(IID_IEnumSTATURL,0x3c374a42,0xbae4,0x11cf,0xbf,0x7d,0,0xaa,0,0x69,0x46,0xee);
27// file:, local: Asychronous Pluggable Protocol Handler CLSID
28DEFINE_GUID(CLSID_FileProtocol,0x79eac9e7,0xbaf9,0x11ce,0x8c,0x82,0,0xaa,0,0x4b,0xa9,0xb);
29// ftp: Asychronous Pluggable Protocol Handler CLSID
30DEFINE_GUID(CLSID_FtpProtocol,0x79eac9e3,0xbaf9,0x11ce,0x8c,0x82,0,0xaa,0,0x4b,0xa9,0xb);
31// gopher: Asychronous Pluggable Protocol Handler CLSID
32DEFINE_GUID(CLSID_GopherProtocol,0x79eac9e4,0xbaf9,0x11ce,0x8c,0x82,0,0xaa,0,0x4b,0xa9,0xb);
33// http: Asychronous Pluggable Protocol Handler CLSID
34DEFINE_GUID(CLSID_HttpProtocol,0x79eac9e2,0xbaf9,0x11ce,0x8c,0x82,0,0xaa,0,0x4b,0xa9,0xb);
35// https: Asychronous Pluggable Protocol Handler CLSID
36DEFINE_GUID(CLSID_HttpSProtocol,0x79eac9e5,0xbaf9,0x11ce,0x8c,0x82,0,0xaa,0,0x4b,0xa9,0xb);
37// mk: Asychronous Pluggable Protocol Handler CLSID
38DEFINE_GUID(CLSID_MkProtocol,0x79eac9e6,0xbaf9,0x11ce,0x8c,0x82,0,0xaa,0,0x4b,0xa9,0xb);
39// URLMoniker ProxyStub Factory CLSID
40DEFINE_GUID(CLSID_PSUrlMonProxy,0x79eac9f1,0xbaf9,0x11ce,0x8c,0x82,0,0xaa,0,0x4b,0xa9,0xb);
41// URL Moniker CLSID
42DEFINE_GUID(CLSID_StdURLMoniker,0x79eac9e0,0xbaf9,0x11ce,0x8c,0x82,0,0xaa,0,0x4b,0xa9,0xb);
lib/libc/mingw/libsrc/fwp-uuid.c created+7
...@@ -0,0 +1,7 @@
1/* http://msdn.microsoft.com/en-us/library/bb427366%28v=VS.85%29.aspx */
2#define INITGUID
3#include <basetyps.h>
4
5DEFINE_GUID(FWPM_PROVIDER_IKEEXT,0x10AD9216L,0xCCDE,0x456C,0x8B,0x16,0xE9,0xF0,0x4E,0x60,0xA9,0x0B);
6DEFINE_GUID(FWPM_PROVIDER_IPSEC_DOS_CONFIG,0x3C6C0519L,0xC05C,0x4BB9,0x83,0x38,0x23,0x27,0x81,0x4C,0xE8,0xBF);
7DEFINE_GUID(FWPM_PROVIDER_TCP_CHIMNEY_OFFLOAD,0x896AA19EL,0x9A34,0x4BCB,0xAE,0x79,0xBE,0xB9,0x12,0x7C,0x84,0xB9);
lib/libc/mingw/libsrc/guid_nul.c created+4
...@@ -0,0 +1,4 @@
1#define INITGUID
2#include <basetyps.h>
3
4DEFINE_GUID(GUID_NULL,0,0,0,0,0,0,0,0,0,0,0);
lib/libc/mingw/libsrc/hlguids-uuid.c created+15
...@@ -0,0 +1,15 @@
1/* hlguids-uuid.c */
2/* Generate GUIDs for HyperLink GUID interfaces */
3
4/* All IIDs defined in this file were extracted from
5 * HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Interface\ */
6
7/* All CLSIDs defined in this file were extracted from
8 * HKEY_CLASSES_ROOT\CLSID\ */
9
10#define INITGUID
11#include <basetyps.h>
12// StdHlink CLSID
13DEFINE_GUID(CLSID_StdHlink,0x79eac9d0,0xbaf9,0x11ce,0x8c,0x82,0,0xaa,0,0x4b,0xa9,0xb);
14// StdHlinkBrowseContext CLSID
15DEFINE_GUID(CLSID_StdHlinkBrowseContext,0x79eac9d1,0xbaf9,0x11ce,0x8c,0x82,0,0xaa,0,0x4b,0xa9,0xb);
lib/libc/mingw/libsrc/hlink-uuid.c created+13
...@@ -0,0 +1,13 @@
1/* hlink-uuid.c */
2/* Generate GUIDs for HyperLink interfaces */
3
4/* All IIDs defined in this file were extracted from
5 * HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Interface\ */
6
7#define INITGUID
8#include <basetyps.h>
9DEFINE_GUID(IID_IHlink,0x79eac9c3,0xbaf9,0x11ce,0x8c,0x82,0,0xaa,0,0x4b,0xa9,0xb);
10DEFINE_GUID(IID_IHlinkBrowseContext,0x79eac9c7,0xbaf9,0x11ce,0x8c,0x82,0,0xaa,0,0x4b,0xa9,0xb);
11DEFINE_GUID(IID_IHlinkFrame,0x79eac9c5,0xbaf9,0x11ce,0x8c,0x82,0,0xaa,0,0x4b,0xa9,0xb);
12DEFINE_GUID(IID_IHlinkSite,0x79eac9c2,0xbaf9,0x11ce,0x8c,0x82,0,0xaa,0,0x4b,0xa9,0xb);
13DEFINE_GUID(IID_IHlinkTarget,0x79eac9c4,0xbaf9,0x11ce,0x8c,0x82,0,0xaa,0,0x4b,0xa9,0xb);
lib/libc/mingw/libsrc/mlang-uuid.c created+13
...@@ -0,0 +1,13 @@
1/* mlang-uuid.c */
2/* Generate GUIDs for Object Multi Language interfaces */
3
4/* All IIDs defined in this file were extracted from
5 * HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Interface\ */
6
7/* All CLSIDs defined in this file were extracted from
8 * HKEY_CLASSES_ROOT\CLSID\ */
9
10#define INITGUID
11#include <basetyps.h>
12// Multi Language Support CLSID
13DEFINE_GUID(CLSID_CMultiLanguage,0x275c23e2,0x3747,0x11d0,0x9f,0xea,0,0xaa,0,0x3f,0x86,0x46);
lib/libc/mingw/libsrc/msctf-uuid.c created+31
...@@ -0,0 +1,31 @@
1/* msctf-uuid.c */
2/* Generate GUIDs for Text Services interfaces */
3
4#include <windows.h>
5#include <oaidl.h>
6#include <comcat.h>
7#include <textstor.h>
8
9#include <initguid.h>
10#include <msctf.h>
11
12DEFINE_GUID(CLSID_TF_ThreadMgr,0x529a9e6b,0x6587,0x4f23,0xab,0x9e,0x9c,0x7d,0x68,0x3e,0x3c,0x50);
13DEFINE_GUID(CLSID_TF_InputProcessorProfiles,0x33c53a50,0xf456,0x4884,0xb0,0x49,0x85,0xfd,0x64,0x3e,0xcf,0xed);
14DEFINE_GUID(CLSID_TF_CategoryMgr,0xA4B544A1,0x438D,0x4B41,0x93,0x25,0x86,0x95,0x23,0xE2,0xD6,0xC7);
15DEFINE_GUID(CLSID_TF_LangBarMgr,0xebb08c45,0x6c4a,0x4fdc,0xae,0x53,0x4e,0xb8,0xc4,0xc7,0xdb,0x8e);
16DEFINE_GUID(CLSID_TF_DisplayAttributeMgr,0x3ce74de4,0x53d3,0x4d74,0x8b,0x83,0x43,0x1b,0x38,0x28,0xba,0x53);
17
18DEFINE_GUID(GUID_TFCAT_TIP_KEYBOARD,0x34745c63,0xb2f0,0x4784,0x8b,0x67,0x5e,0x12,0xc8,0x70,0x1a,0x31);
19DEFINE_GUID(GUID_TFCAT_TIP_SPEECH,0xB5A73CD1,0x8355,0x426B,0xA1,0x61,0x25,0x98,0x08,0xF2,0x6B,0x14);
20DEFINE_GUID(GUID_TFCAT_TIP_HANDWRITING,0x246ecb87,0xc2f2,0x4abe,0x90,0x5b,0xc8,0xb3,0x8a,0xdd,0x2c,0x43);
21DEFINE_GUID(GUID_TFCAT_DISPLAYATTRIBUTEPROVIDER,0x046B8C80,0x1647,0x40F7,0x9B,0x21,0xB9,0x3B,0x81,0xAA,0xBC,0x1B);
22DEFINE_GUID(GUID_COMPARTMENT_KEYBOARD_DISABLED,0x71a5b253,0x1951,0x466b,0x9f,0xbc,0x9c,0x88,0x08,0xfa,0x84,0xf2);
23DEFINE_GUID(GUID_COMPARTMENT_KEYBOARD_OPENCLOSE,0x58273aad,0x01bb,0x4164,0x95,0xc6,0x75,0x5b,0xa0,0xb5,0x16,0x2d);
24DEFINE_GUID(GUID_COMPARTMENT_HANDWRITING_OPENCLOSE,0xf9ae2c6b,0x1866,0x4361,0xaf,0x72,0x7a,0xa3,0x09,0x48,0x89,0x0e);
25DEFINE_GUID(GUID_COMPARTMENT_SPEECH_DISABLED,0x56c5c607,0x0703,0x4e59,0x8e,0x52,0xcb,0xc8,0x4e,0x8b,0xbe,0x35);
26DEFINE_GUID(GUID_COMPARTMENT_SPEECH_OPENCLOSE,0x544d6a63,0xe2e8,0x4752,0xbb,0xd1,0x00,0x09,0x60,0xbc,0xa0,0x83);
27DEFINE_GUID(GUID_COMPARTMENT_SPEECH_GLOBALSTATE,0x2a54fe8e,0x0d08,0x460c,0xa7,0x5d,0x87,0x03,0x5f,0xf4,0x36,0xc5);
28DEFINE_GUID(GUID_COMPARTMENT_PERSISTMENUENABLED,0x575f3783,0x70c8,0x47c8,0xae,0x5d,0x91,0xa0,0x1a,0x1f,0x75,0x92);
29DEFINE_GUID(GUID_COMPARTMENT_EMPTYCONTEXT,0xd7487dbf,0x804e,0x41c5,0x89,0x4d,0xad,0x96,0xfd,0x4e,0xea,0x13);
30DEFINE_GUID(GUID_COMPARTMENT_TIPUISTATUS,0x148ca3ec,0x0366,0x401c,0x8d,0x75,0xed,0x97,0x8d,0x85,0xfb,0xc9);
31
lib/libc/mingw/libsrc/mshtmhst-uuid.c created+3
...@@ -0,0 +1,3 @@
1#define INITGUID
2#include <basetyps.h>
3DEFINE_GUID(IID_IDocHostUIHandler,0xbd3f23c0,0xd43e,0x11cf,0x89,0x3b,0x00,0xaa,0x00,0xbd,0xce,0x1a);
lib/libc/mingw/libsrc/mshtml-uuid.c created+147
...@@ -0,0 +1,147 @@
1/* mshtml-uuid.c */
2/* Generate GUIDs for MSHTML interfaces */
3
4#define INITGUID
5#include <basetyps.h>
6DEFINE_GUID(IID_IHTMLDocument,0x626fc520,0xa41e,0x11cf,0xa7,0x31,0x0,0xa0,0xc9,0x8,0x26,0x37);
7DEFINE_GUID(IID_IHTMLDocument2,0x332c4425,0x26cb,0x11d0,0xb4,0x83,0x0,0xc0,0x4f,0xd9,0x1,0x19);
8DEFINE_GUID(IID_IHTMLElement,0x3050f1ff,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0xb);
9DEFINE_GUID(IID_IHTMLSelectionObject,0x3050f25a,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0xb);
10DEFINE_GUID(IID_IHTMLTxtRange,0x3050f220,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b);
11DEFINE_GUID(IID_IHTMLImgElement,0x3050f240,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b);
12DEFINE_GUID(IID_IHTMLBodyElement,0x3050f1d8,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b);
13DEFINE_GUID(IID_IHTMLFontElement,0x3050f1d9,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b);
14DEFINE_GUID(IID_IHTMLAnchorElement,0x3050f1da,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b);
15DEFINE_GUID(IID_IHTMLUListElement,0x3050f1dd,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b);
16DEFINE_GUID(IID_IHTMLOListElement,0x3050f1de,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b);
17DEFINE_GUID(IID_IHTMLLIElement,0x3050f1e0,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b);
18DEFINE_GUID(IID_IHTMLBRElement,0x3050f1f0,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b);
19DEFINE_GUID(IID_IHTMLDListElement,0x3050f1f1,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b);
20DEFINE_GUID(IID_IHTMLDDElement,0x3050f1f2,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b);
21DEFINE_GUID(IID_IHTMLDTElement,0x3050f1f3,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b);
22DEFINE_GUID(IID_IHTMLHRElement,0x3050f1f4,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b);
23DEFINE_GUID(IID_IHTMLParaElement,0x3050f1f5,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b);
24DEFINE_GUID(IID_IHTMLHeaderElement,0x3050f1f6,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b);
25DEFINE_GUID(IID_IHTMLFormElement,0x3050f1f7,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b);
26DEFINE_GUID(IID_IHTMLDivElement,0x3050f200,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b);
27DEFINE_GUID(IID_IHTMLBaseFontElement,0x3050f202,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b);
28DEFINE_GUID(IID_IHTMLMetaElement,0x3050f203,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b);
29DEFINE_GUID(IID_IHTMLBaseElement,0x3050f204,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b);
30DEFINE_GUID(IID_IHTMLLinkElement,0x3050f205,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b);
31DEFINE_GUID(IID_IHTMLIsIndexElement,0x3050f206,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b);
32DEFINE_GUID(IID_IHTMLNextIdElement,0x3050f207,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b);
33DEFINE_GUID(IID_IHTMLBlockElement,0x3050f208,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b);
34DEFINE_GUID(IID_IHTMLUnknownElement,0x3050f209,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b);
35DEFINE_GUID(IID_IHTMLPhraseElement,0x3050f20a,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b);
36DEFINE_GUID(IID_IHTMLCommentElement,0x3050f20c,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b);
37DEFINE_GUID(IID_IHTMLListElement,0x3050f20e,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b);
38DEFINE_GUID(IID_IHTMLOptionElement,0x3050f211,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b);
39DEFINE_GUID(IID_IHTMLDivPosition,0x3050f212,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b);
40DEFINE_GUID(IID_IHTMLDialog,0x3050f216,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b);
41DEFINE_GUID(IID_IHTMLTextElement,0x3050f218,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b);
42DEFINE_GUID(IID_IHTMLTable,0x3050f21e,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b);
43DEFINE_GUID(IID_IHTMLElementCollection,0x3050f21f,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b);
44DEFINE_GUID(IID_IHTMLTextContainer,0x3050f230,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b);
45DEFINE_GUID(IID_IHTMLTableCol,0x3050f23a,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b);
46DEFINE_GUID(IID_IHTMLTableSection,0x3050f23b,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b);
47DEFINE_GUID(IID_IHTMLTableRow,0x3050f23c,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b);
48DEFINE_GUID(IID_IHTMLTableCell,0x3050f23d,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b);
49DEFINE_GUID(IID_IHTMLSelectElement,0x3050f244,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b);
50DEFINE_GUID(IID_IHTMLObjectElement,0x3050f24f,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b);
51DEFINE_GUID(IID_IHTMLStyle,0x3050f25e,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b);
52DEFINE_GUID(IID_IHTMLEmbedElement,0x3050f25f,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b);
53DEFINE_GUID(IID_IHTMLAreaElement,0x3050f265,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b);
54DEFINE_GUID(IID_IHTMLMapElement,0x3050f266,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b);
55DEFINE_GUID(IID_IHTMLScriptElement,0x3050f28b,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b);
56DEFINE_GUID(IID_IHTMLControlRange,0x3050f29c,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b);
57DEFINE_GUID(IID_IHTMLInputHiddenElement,0x3050f2a4,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b);
58DEFINE_GUID(IID_IHTMLInputTextElement,0x3050f2a6,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b);
59DEFINE_GUID(IID_IHTMLTextAreaElement,0x3050f2aa,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b);
60DEFINE_GUID(IID_IHTMLInputFileElement,0x3050f2ad,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b);
61DEFINE_GUID(IID_IHTMLInputButtonElement,0x3050f2b2,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b);
62DEFINE_GUID(IID_IHTMLMarqueeElement,0x3050f2b5,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b);
63DEFINE_GUID(IID_IHTMLButtonElement,0x3050f2bb,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b);
64DEFINE_GUID(IID_IHTMLOptionButtonElement,0x3050f2bc,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b);
65DEFINE_GUID(IID_IHTMLInputImage,0x3050f2c2,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b);
66DEFINE_GUID(IID_IHTMLStyleSheet,0x3050f2e3,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b);
67DEFINE_GUID(IID_IHTMLStyleSheetRulesCollection,0x3050f2e5,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b);
68DEFINE_GUID(IID_IHTMLTableCaption,0x3050f2eb,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b);
69DEFINE_GUID(IID_IHTMLFrameBase,0x3050f311,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b);
70DEFINE_GUID(IID_IHTMLFrameElement,0x3050f313,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b);
71DEFINE_GUID(IID_IHTMLIFrameElement,0x3050f315,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b);
72DEFINE_GUID(IID_IHTMLFrameSetElement,0x3050f319,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b);
73DEFINE_GUID(IID_IHTMLTitleElement,0x3050f322,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b);
74DEFINE_GUID(IID_IHTMLLabelElement,0x3050f32a,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b);
75DEFINE_GUID(IID_IHTMLEventObj,0x3050f32d,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b);
76DEFINE_GUID(IID_IHTMLStyleSheetRule,0x3050f357,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b);
77DEFINE_GUID(IID_IHTMLScreen,0x3050f35c,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b);
78DEFINE_GUID(IID_IHTMLBGsound,0x3050f369,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b);
79DEFINE_GUID(IID_IHTMLStyleElement,0x3050f375,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b);
80DEFINE_GUID(IID_IHTMLFontNamesCollection,0x3050f376,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b);
81DEFINE_GUID(IID_IHTMLFontSizesCollection,0x3050f377,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b);
82DEFINE_GUID(IID_IHTMLOptionsHolder,0x3050f378,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b);
83DEFINE_GUID(IID_IHTMLStyleSheetsCollection,0x3050f37e,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b);
84DEFINE_GUID(IID_IHTMLAreasCollection,0x3050f383,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b);
85DEFINE_GUID(IID_IHTMLNoShowElement,0x3050f38a,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b);
86DEFINE_GUID(IID_IHTMLOptionElementFactory,0x3050f38c,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b);
87DEFINE_GUID(IID_IHTMLImageElementFactory,0x3050f38e,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b);
88DEFINE_GUID(IID_IHTMLRuleStyle,0x3050f3cf,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b);
89DEFINE_GUID(IID_IHTMLStyleFontFace,0x3050f3d5,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b);
90DEFINE_GUID(IID_IHTMLCurrentStyle,0x3050f3db,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b);
91DEFINE_GUID(IID_IHTMLSpanFlow,0x3050f3e5,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b);
92DEFINE_GUID(IID_IHTMLFieldSetElement,0x3050f3e7,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b);
93DEFINE_GUID(IID_IHTMLLegendElement,0x3050f3ea,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b);
94DEFINE_GUID(IID_IHTMLFiltersCollection,0x3050f3ee,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b);
95DEFINE_GUID(IID_IHTMLDatabinding,0x3050f3f2,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b);
96DEFINE_GUID(IID_IHTMLSpanElement,0x3050f3f3,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b);
97DEFINE_GUID(IID_IHTMLMimeTypesCollection,0x3050f3fc,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b);
98DEFINE_GUID(IID_IHTMLPluginsCollection,0x3050f3fd,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b);
99DEFINE_GUID(IID_IHTMLOpsProfile,0x3050f401,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b);
100DEFINE_GUID(IID_IHTMLTextRangeMetrics,0x3050f40b,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b);
101DEFINE_GUID(IID_IHTMLTableRowMetrics,0x3050f413,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b);
102DEFINE_GUID(IID_IHTMLElement2,0x3050f434,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b);
103DEFINE_GUID(IID_IHTMLDocument3,0x3050f485,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b);
104DEFINE_GUID(IID_IHTMLEventObj2,0x3050f48b,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b);
105DEFINE_GUID(IID_IHTMLUserDataOM,0x3050f48f,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b);
106DEFINE_GUID(IID_IHTMLTableRow2,0x3050f4a1,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b);
107DEFINE_GUID(IID_IHTMLStyle2,0x3050f4a2,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b);
108DEFINE_GUID(IID_IHTMLRect,0x3050f4a3,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b);
109DEFINE_GUID(IID_IHTMLRectCollection,0x3050f4a4,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b);
110DEFINE_GUID(IID_IHTMLTextRangeMetrics2,0x3050f4a6,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b);
111DEFINE_GUID(IID_IHTMLRuleStyle2,0x3050f4ac,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b);
112DEFINE_GUID(IID_IHTMLTable2,0x3050f4ad,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b);
113DEFINE_GUID(IID_IHTMLWindow3,0x3050f4ae,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b);
114DEFINE_GUID(IID_IHTMLDOMAttribute,0x3050f4b0,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b);
115DEFINE_GUID(IID_IHTMLDOMTextNode,0x3050f4b1,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b);
116DEFINE_GUID(IID_IHTMLDataTransfer,0x3050f4b3,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b);
117DEFINE_GUID(IID_IHTMLGenericElement,0x3050f4b7,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b);
118DEFINE_GUID(IID_IHTMLPersistDataOM,0x3050f4c0,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b);
119DEFINE_GUID(IID_IHTMLAttributeCollection,0x3050f4c3,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b);
120DEFINE_GUID(IID_IHTMLPersistData,0x3050f4c5,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b);
121DEFINE_GUID(IID_IHTMLObjectElement2,0x3050f4cd,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b);
122DEFINE_GUID(IID_IHTMLBookmarkCollection,0x3050f4ce,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b);
123DEFINE_GUID(IID_IHTMLUniqueName,0x3050f4d0,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b);
124DEFINE_GUID(IID_IHTMLLinkElement2,0x3050f4e5,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b);
125DEFINE_GUID(IID_IHTMLIFrameElement2,0x3050f4e6,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b);
126DEFINE_GUID(IID_IHTMLControlElement,0x3050f4e9,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b);
127DEFINE_GUID(IID_IHTMLFormElement2,0x3050f4f6,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b);
128DEFINE_GUID(IID_IHTMLDOMChildrenCollection,0x3050f5ab,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b);
129DEFINE_GUID(IID_IHTMLBodyElement2,0x3050f5c5,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b);
130DEFINE_GUID(IID_IHTMLFrameSetElement2,0x3050f5c6,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b);
131DEFINE_GUID(IID_IHTMLTableSection2,0x3050f5c7,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b);
132DEFINE_GUID(IID_IHTMLAppBehavior2,0x3050f5c9,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b);
133DEFINE_GUID(IID_IHTMLAppBehavior,0x3050f5ca,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b);
134DEFINE_GUID(IID_IHTMLInputElement,0x3050f5d2,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b);
135DEFINE_GUID(IID_IHTMLDOMNode,0x3050f5da,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b);
136DEFINE_GUID(IID_IHTMLDialog2,0x3050f5e0,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b);
137DEFINE_GUID(IID_IHTMLUrnCollection,0x3050f5e2,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b);
138DEFINE_GUID(IID_IHTMLModelessInit,0x3050f5e4,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b);
139DEFINE_GUID(IID_IHTMLDocumentFragment,0x3050f5e5,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b);
140DEFINE_GUID(IID_IHTMLAreasCollection2,0x3050f5ec,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b);
141DEFINE_GUID(IID_IHTMLSelectElement2,0x3050f5ed,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b);
142DEFINE_GUID(IID_IHTMLElementCollection2,0x3050f5ee,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b);
143DEFINE_GUID(IID_IHTMLFramesCollection2,0x332c4426,0x26cb,0x11d0,0xb4,0x83,0x0,0xc0,0x4f,0xd9,0x01,0x19);
144DEFINE_GUID(IID_IHTMLWindow2,0x332c4427,0x26cb,0x11d0,0xb4,0x83,0x0,0xc0,0x4f,0xd9,0x01,0x19);
145DEFINE_GUID(IID_IHTMLLocation,0x163bb1e0,0x6e00,0x11cf,0x83,0x7a,0x48,0xdc,0x04,0xc1,0x0,0x0);
146DEFINE_GUID(IID_IHTMLFrameBase2,0x3050f6db,0x98b5,0x11cf,0xbb,0x82,0x00,0xaa,0x00,0xbd,0xce,0x0b);
147DEFINE_GUID(IID_IHTMLFrameBase3,0x3050f82e,0x98b5,0x11cf,0xbb,0x82,0x00,0xaa,0x00,0xbd,0xce,0x0b);
lib/libc/mingw/libsrc/msxml-uuid.c created+29
...@@ -0,0 +1,29 @@
1/* msxml-uuid.c */
2/* Generate GUIDs for MSXML interfaces */
3
4#define INITGUID
5#include <basetyps.h>
6DEFINE_GUID(CLSID_DOMDocument,0x2933bf90,0x7b36,0x11d2,0xb2,0x0e,0x00,0xc0,0x4f,0x98,0x3e,0x60);
7DEFINE_GUID(CLSID_DOMFreeThreadedDocument,0x2933bf91,0x7b36,0x11d2,0xb2,0x0e,0x00,0xc0,0x4f,0x98,0x3e,0x60);
8DEFINE_GUID(CLSID_XMLHTTPRequest,0xed8c108e,0x4349,0x11d2,0x91,0xa4,0x00,0xc0,0x4f,0x79,0x69,0xe8);
9DEFINE_GUID(DIID_XMLDOMDocumentEvents,0x3efaa427,0x272f,0x11d2,0x83,0x6f,0x00,0x00,0xf8,0x7a,0x77,0x82);
10DEFINE_GUID(IID_IXMLDOMAttribute,0x2933bf85,0x7b36,0x11d2,0xb2,0x0e,0x00,0xc0,0x4f,0x98,0x3e,0x60);
11DEFINE_GUID(IID_IXMLDOMCharacterData,0x2933bf84,0x7b36,0x11d2,0xb2,0x0e,0x00,0xc0,0x4f,0x98,0x3e,0x60);
12DEFINE_GUID(IID_IXMLDOMCDATASection,0x2933bf8a,0x7b36,0x11d2,0xb2,0x0e,0x00,0xc0,0x4f,0x98,0x3e,0x60);
13DEFINE_GUID(IID_IXMLDOMComment,0x2933bf88,0x7b36,0x11d2,0xb2,0x0e,0x00,0xc0,0x4f,0x98,0x3e,0x60);
14DEFINE_GUID(IID_IXMLDOMDocument,0x2933bf81,0x7b36,0x11d2,0xb2,0x0e,0x00,0xc0,0x4f,0x98,0x3e,0x60);
15DEFINE_GUID(IID_IXMLDOMDocumentFragment,0x3efaa413,0x272f,0x11d2,0x83,0x6f,0x00,0x00,0xf8,0x7a,0x77,0x82);
16DEFINE_GUID(IID_IXMLDOMDocumentType,0x2933bf8b,0x7b36,0x11d2,0xb2,0x0e,0x00,0xc0,0x4f,0x98,0x3e,0x60);
17DEFINE_GUID(IID_IXMLDOMElement,0x2933bf86,0x7b36,0x11d2,0xb2,0x0e,0x00,0xc0,0x4f,0x98,0x3e,0x60);
18DEFINE_GUID(IID_IXMLDOMEntity,0x2933bf8d,0x7b36,0x11d2,0xb2,0x0e,0x00,0xc0,0x4f,0x98,0x3e,0x60);
19DEFINE_GUID(IID_IXMLDOMEntityReference,0x2933bf8e,0x7b36,0x11d2,0xb2,0x0e,0x00,0xc0,0x4f,0x98,0x3e,0x60);
20DEFINE_GUID(IID_IXMLDOMImplementation,0x2933bf8e,0x7b36,0x11d2,0xb2,0x0e,0x00,0xc0,0x4f,0x98,0x3e,0x60);
21DEFINE_GUID(IID_IXMLDOMNamedNodeMap,0x2933bf83,0x7b36,0x11d2,0xb2,0x0e,0x00,0xc0,0x4f,0x98,0x3e,0x60);
22DEFINE_GUID(IID_IXMLDOMNode,0x2933bf80,0x7b36,0x11d2,0xb2,0x0e,0x00,0xc0,0x4f,0x98,0x3e,0x60);
23DEFINE_GUID(IID_IXMLDOMNodeList,0x2933bf82,0x7b36,0x11d2,0xb2,0x0e,0x00,0xc0,0x4f,0x98,0x3e,0x60);
24DEFINE_GUID(IID_IXMLDOMNotation,0x2933bf8c,0x7b36,0x11d2,0xb2,0x0e,0x00,0xc0,0x4f,0x98,0x3e,0x60);
25DEFINE_GUID(IID_IXMLDOMParseError,0x3efaa426,0x272f,0x11d2,0x83,0x6f,0x00,0x00,0xf8,0x7a,0x77,0x82);
26DEFINE_GUID(IID_IXMLDOMProcessingInstruction,0x2933bf89,0x7b36,0x11d2,0xb2,0x0e,0x00,0xc0,0x4f,0x98,0x3e,0x60);
27DEFINE_GUID(IID_IXMLDOMText,0x2933bf87,0x7b36,0x11d2,0xb2,0x0e,0x00,0xc0,0x4f,0x98,0x3e,0x60);
28DEFINE_GUID(IID_IXMLHttpRequest,0xed8c108d,0x4349,0x11d2,0x91,0xa4,0x00,0xc0,0x4f,0x79,0x69,0xe8);
29DEFINE_GUID(IID_IXTLRuntime,0x3efaa425,0x272f,0x11d2,0x83,0x6f,0x00,0x00,0xf8,0x7a,0x77,0x82);
lib/libc/mingw/libsrc/netcon-uuid.c created+19
...@@ -0,0 +1,19 @@
1/* netcon-uuid.c */
2/* Generate GUIDs for network connection management interfaces */
3
4#define INITGUID
5#include <basetyps.h>
6DEFINE_GUID(CLSID_NetSharingManager,0x5c63c1ad,0x3956,0x4ff8,0x84,0x86,0x40,0x03,0x47,0x58,0x31,0x5b);
7DEFINE_GUID(IID_INetConnection,0xc08956a1,0x1cd3,0x11d1,0xb1,0xc5,0x00,0x80,0x5f,0xc1,0x27,0x0e);
8DEFINE_GUID(IID_INetSharingPortMappingProps,0x24b7e9b5,0xe38f,0x4685,0x85,0x1b,0x00,0x89,0x2c,0xf5,0xf9,0x40);
9DEFINE_GUID(IID_INetSharingPortMapping,0xc08956b1,0x1cd3,0x11d1,0xb1,0xc5,0x00,0x80,0x5f,0xc1,0x27,0x0e);
10DEFINE_GUID(IID_INetSharingPortMappingCollection,0x02e4a2de,0xda20,0x4e34,0x89,0xc8,0xac,0x22,0x27,0x5a,0x01,0x0b);
11DEFINE_GUID(IID_INetSharingConfiguration,0xc08956b6,0x1cd3,0x11d1,0xb1,0xc5,0x00,0x80,0x5f,0xc1,0x27,0x0e);
12DEFINE_GUID(IID_IEnumNetSharingPublicConnection,0xc08956b4,0x1cd3,0x11d1,0xb1,0xc5,0x00,0x80,0x5f,0xc1,0x27,0x0e);
13DEFINE_GUID(IID_IEnumNetSharingPrivateConnection,0xc08956b5,0x1cd3,0x11d1,0xb1,0xc5,0x00,0x80,0x5f,0xc1,0x27,0x0e);
14DEFINE_GUID(IID_INetConnectionProps,0xf4277c95,0xce5b,0x463d,0x81,0x67,0x56,0x62,0xd9,0xbc,0xaa,0x72);
15DEFINE_GUID(IID_INetSharingPublicConnectionCollection,0x7d7a6355,0xf372,0x4971,0xa1,0x49,0xbf,0xc9,0x27,0xbe,0x76,0x2a);
16DEFINE_GUID(IID_INetSharingEveryConnectionCollection,0x33c4643c,0x7811,0x46fa,0xa8,0x9a,0x76,0x85,0x97,0xbd,0x72,0x23);
17DEFINE_GUID(IID_INetSharingPrivateConnectionCollection,0x38ae69e0,0x4409,0x402a,0xa2,0xcb,0xe9,0x65,0xc7,0x27,0xf8,0x40);
18DEFINE_GUID(IID_INetSharingManager,0xc08956b7,0x1cd3,0x11d1,0xb1,0xc5,0x00,0x80,0x5f,0xc1,0x27,0x0e);
19
lib/libc/mingw/libsrc/ntddkbd-uuid.c created+7
...@@ -0,0 +1,7 @@
1/* from ntddkbd.h */
2
3#define INITGUID
4#include <basetyps.h>
5
6DEFINE_GUID(GUID_DEVINTERFACE_KEYBOARD, 0x884b96c3, 0x56ef, 0x11d1, 0xbc, 0x8c, 0x00, 0xa0, 0xc9, 0x14, 0x05, 0xdd);
7
lib/libc/mingw/libsrc/ntddmou-uuid.c created+7
...@@ -0,0 +1,7 @@
1/* from ntddmou.h */
2
3#define INITGUID
4#include <basetyps.h>
5
6DEFINE_GUID(GUID_DEVINTERFACE_MOUSE, 0x378de44c, 0x56ef, 0x11d1, 0xbc, 0x8c, 0x00, 0xa0, 0xc9, 0x14, 0x05, 0xdd);
7
lib/libc/mingw/libsrc/ntddpar-uuid.c created+12
...@@ -0,0 +1,12 @@
1/* Parallel port device GUIDs */
2/* from ntddpar.h */
3
4#define INITGUID
5#include <basetyps.h>
6
7#define GUID_PARALLEL_DEVICE GUID_DEVINTERFACE_PARALLEL
8#define GUID_PARCLASS_DEVICE GUID_DEVINTERFACE_PARCLASS
9
10DEFINE_GUID (GUID_DEVINTERFACE_PARALLEL, 0x97F76EF0, 0xF883, 0x11D0, 0xAF, 0x1F, 0x00, 0x00, 0xF8, 0x00, 0x84, 0x5C);
11DEFINE_GUID (GUID_DEVINTERFACE_PARCLASS, 0x811FC6A5, 0xF728, 0x11D0, 0xA5, 0x37, 0x00, 0x00, 0xF8, 0x75, 0x3E, 0xD1);
12
lib/libc/mingw/libsrc/ntddscsi-uuid.c created+8
...@@ -0,0 +1,8 @@
1/* from ntddscsi.h */
2
3#define INITGUID
4#include <basetyps.h>
5
6DEFINE_GUID(ScsiRawInterfaceGuid,0x53f56309L,0xb6bf,0x11d0,0x94,0xf2,0x00,0xa0,0xc9,0x1e,0xfb,0x8b);
7DEFINE_GUID(WmiScsiAddressGuid,0x53f5630fL,0xb6bf,0x11d0,0x94,0xf2,0x00,0xa0,0xc9,0x1e,0xfb,0x8b);
8
lib/libc/mingw/libsrc/ntddser-uuid.c created+11
...@@ -0,0 +1,11 @@
1/* from ntddser.h */
2
3#define INITGUID
4#include <basetyps.h>
5
6#define GUID_CLASS_COMPORT GUID_DEVINTERFACE_COMPORT
7#define GUID_SERENUM_BUS_ENUMERATOR GUID_DEVINTERFACE_SERENUM_BUS_ENUMERATOR
8
9DEFINE_GUID(GUID_DEVINTERFACE_COMPORT, 0x86e0d1e0L, 0x8089, 0x11d0, 0x9c, 0xe4, 0x08, 0x00, 0x3e, 0x30, 0x1f, 0x73);
10DEFINE_GUID(GUID_DEVINTERFACE_SERENUM_BUS_ENUMERATOR, 0x4D36E978L, 0xE325, 0x11CE, 0xBF, 0xC1, 0x08, 0x00, 0x2B, 0xE1, 0x03, 0x18);
11
lib/libc/mingw/libsrc/ntddstor-uuid.c created+41
...@@ -0,0 +1,41 @@
1/* from ntddstor.h */
2
3#define INITGUID
4#include <basetyps.h>
5
6DEFINE_GUID(GUID_DEVINTERFACE_DISK,
7 0x53f56307L, 0xb6bf, 0x11d0, 0x94, 0xf2, 0x00, 0xa0, 0xc9, 0x1e, 0xfb, 0x8b);
8
9DEFINE_GUID(GUID_DEVINTERFACE_CDROM,
10 0x53f56308L, 0xb6bf, 0x11d0, 0x94, 0xf2, 0x00, 0xa0, 0xc9, 0x1e, 0xfb, 0x8b);
11
12DEFINE_GUID(GUID_DEVINTERFACE_PARTITION,
13 0x53f5630aL, 0xb6bf, 0x11d0, 0x94, 0xf2, 0x00, 0xa0, 0xc9, 0x1e, 0xfb, 0x8b);
14
15DEFINE_GUID(GUID_DEVINTERFACE_TAPE,
16 0x53f5630bL, 0xb6bf, 0x11d0, 0x94, 0xf2, 0x00, 0xa0, 0xc9, 0x1e, 0xfb, 0x8b);
17
18DEFINE_GUID(GUID_DEVINTERFACE_WRITEONCEDISK,
19 0x53f5630cL, 0xb6bf, 0x11d0, 0x94, 0xf2, 0x00, 0xa0, 0xc9, 0x1e, 0xfb, 0x8b);
20
21DEFINE_GUID(GUID_DEVINTERFACE_VOLUME,
22 0x53f5630dL, 0xb6bf, 0x11d0, 0x94, 0xf2, 0x00, 0xa0, 0xc9, 0x1e, 0xfb, 0x8b);
23
24DEFINE_GUID(GUID_DEVINTERFACE_MEDIUMCHANGER,
25 0x53f56310L, 0xb6bf, 0x11d0, 0x94, 0xf2, 0x00, 0xa0, 0xc9, 0x1e, 0xfb, 0x8b);
26
27DEFINE_GUID(GUID_DEVINTERFACE_FLOPPY,
28 0x53f56311L, 0xb6bf, 0x11d0, 0x94, 0xf2, 0x00, 0xa0, 0xc9, 0x1e, 0xfb, 0x8b);
29
30DEFINE_GUID(GUID_DEVINTERFACE_CDCHANGER,
31 0x53f56312L, 0xb6bf, 0x11d0, 0x94, 0xf2, 0x00, 0xa0, 0xc9, 0x1e, 0xfb, 0x8b);
32
33DEFINE_GUID(GUID_DEVINTERFACE_STORAGEPORT,
34 0x2accfe60L, 0xc130, 0x11d2, 0xb0, 0x82, 0x00, 0xa0, 0xc9, 0x1e, 0xfb, 0x8b);
35
36DEFINE_GUID(GUID_DEVINTERFACE_HIDDEN_VOLUME,
37 0x7f108a28L, 0x9833, 0x4b3b, 0xb7, 0x80, 0x2c, 0x6b, 0x5f, 0xa5, 0xc0, 0x62);
38
39#define WDI_STORAGE_PREDICT_FAILURE_DPS_GUID \
40 {0xe9f2d03aL, 0x747c, 0x41c2, {0xbb, 0x9a, 0x02, 0xc6, 0x2b, 0x6d, 0x5f, 0xcb}};
41
lib/libc/mingw/libsrc/ntddvdeo-uuid.c created+7
...@@ -0,0 +1,7 @@
1/* from ntddvdeo.h */
2
3#define INITGUID
4#include <basetyps.h>
5
6DEFINE_GUID(GUID_DEVINTERFACE_DISPLAY_ADAPTER, 0x5b45201d, 0xf2f2, 0x4f3b, 0x85, 0xbb, 0x30, 0xff, 0x1f, 0x95, 0x35, 0x99);
7
lib/libc/mingw/libsrc/oaidl-uuid.c created+20
...@@ -0,0 +1,20 @@
1/* oaidl-uuid.c */
2/* Generate GUIDs for OA IDL interfaces */
3
4/* All IIDs defined in this file were extracted from
5 * HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Interface\ */
6
7#define INITGUID
8#include <basetyps.h>
9DEFINE_GUID(IID_IErrorInfo,0x1cf2b120,0x547d,0x101b,0x8e,0x65,0x8,0,0x2b,0x2b,0xd1,0x19);
10DEFINE_GUID(IID_ICreateErrorInfo,0x22f03340,0x547d,0x101b,0x8e,0x65,0x8,0,0x2b,0x2b,0xd1,0x19);
11DEFINE_GUID(IID_ISupportErrorInfo,0xdf0b3d60,0x548f,0x101b,0x8e,0x65,0x8,0,0x2b,0x2b,0xd1,0x19);
12DEFINE_OLEGUID(IID_ICreateTypeInfo,0x20405,0,0);
13DEFINE_OLEGUID(IID_ICreateTypeInfo2,0x2040e,0,0);
14DEFINE_OLEGUID(IID_ICreateTypeLib,0x20406,0,0);
15DEFINE_OLEGUID(IID_ICreateTypeLib2,0x2040F,0,0);
16DEFINE_OLEGUID(IID_ITypeInfo,0x20401,0,0);
17DEFINE_OLEGUID(IID_ITypeInfo2,0x20412,0,0);
18DEFINE_OLEGUID(IID_ITypeLib,0x20402,0,0);
19DEFINE_OLEGUID(IID_ITypeLib2,0x20411,0,0);
20DEFINE_OLEGUID(IID_IEnumVARIANT,0x20404,0,0);
lib/libc/mingw/libsrc/objidl-uuid.c created+43
...@@ -0,0 +1,43 @@
1/* objidl-uuid.c */
2/* Generate GUIDs for Object IDL interfaces */
3
4/* All IIDs defined in this file were extracted from
5 * HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Interface\ */
6
7#define INITGUID
8#include <basetyps.h>
9DEFINE_OLEGUID(IID_IMarshal,0x3,0,0);
10DEFINE_OLEGUID(IID_IStream,0xc,0,0);
11DEFINE_OLEGUID(IID_IMalloc,0x2,0,0);
12DEFINE_OLEGUID(IID_IMessageFilter,0x16,0,0);
13DEFINE_OLEGUID(IID_IPersist,0x10c,0,0);
14DEFINE_OLEGUID(IID_IPersistFile,0x10b,0,0);
15DEFINE_OLEGUID(IID_IPersistStorage,0x10a,0,0);
16DEFINE_OLEGUID(IID_IPersistStream,0x109,0,0);
17DEFINE_OLEGUID(IID_IMoniker,0xf,0,0);
18DEFINE_OLEGUID(IID_IAdviseSink,0x10f,0,0);
19/*DEFINE_OLEGUID(IID_IAdviseSink2,0x125,0,0);*/
20DEFINE_OLEGUID(IID_IDataObject,0x10e,0,0);
21DEFINE_OLEGUID(IID_IDataAdviseHolder,0x110,0,0);
22DEFINE_OLEGUID(IID_IStorage,0xb,0,0);
23DEFINE_OLEGUID(IID_IRootStorage,0x12,0,0);
24DEFINE_GUID(IID_IRpcChannelBuffer,0xd5f56b60,0x593b,0x101a,0xb5,0x69,0x8,0,0x2b,0x2d,0xbf,0x7a);
25DEFINE_GUID(IID_IRpcProxyBuffer,0xd5f56a34,0x593b,0x101a,0xb5,0x69,8,0,0x2b,0x2d,0xbf,0x7a);
26DEFINE_GUID(IID_IRpcStubBuffer,0xd5f56afc,0x593b,0x101a,0xb5,0x69,0x8,0,0x2b,0x2d,0xbf,0x7a);
27DEFINE_GUID(IID_ISequentialStream,0xc733a30,0x2a1c,0x11ce,0xad,0xe5,0,0xaa,0,0x44,0x77,0x3d);
28DEFINE_OLEGUID(IID_IStdMarshalInfo,0x18,0,0);
29DEFINE_OLEGUID(IID_IRunningObjectTable,0x10,0,0);
30DEFINE_OLEGUID(IID_IBindCtx,0xe,0,0);
31DEFINE_GUID(IID_IPSFactoryBuffer,0xd5f569d0,0x593b,0x101a,0xb5,0x69,0x8,0,0x2b,0x2d,0xbf,0x7a);
32DEFINE_OLEGUID(IID_ILockBytes,0xa,0,0);
33DEFINE_OLEGUID(IID_IExternalConnection,0x19,0,0);
34DEFINE_OLEGUID(IID_IRunnableObject,0x126,0,0);
35DEFINE_GUID(IID_IROTData,0xf29f6bc0,0x5021,0x11ce,0xaa,0x15,0,0,0x69,0x1,0x29,0x3f);
36DEFINE_OLEGUID(IID_IPropertySetStorage,0x13a,0,0);
37DEFINE_OLEGUID(IID_IPropertyStorage,0x138,0,0);
38DEFINE_OLEGUID(IID_IClassActivator,0x140,0,0);
39DEFINE_GUID(IID_IFillLockBytes,0x99caf010,0x415e,0x11cf,0x88,0x14,0,0xaa,0,0xb5,0x69,0xf5);
40DEFINE_GUID(IID_IProgressNotify,0xa9d758a0,0x4617,0x11cf,0x95,0xfc,0,0xaa,0,0x68,0xd,0xb4);
41DEFINE_OLEGUID(IID_IClientSecurity,0x13D,0,0);
42DEFINE_OLEGUID(IID_IMallocSpy,0x1d,0,0);
43DEFINE_OLEGUID(IID_IServerSecurity,0x13E,0,0);
lib/libc/mingw/libsrc/objsafe-uuid.c created+9
...@@ -0,0 +1,9 @@
1/* objsafe-uuid.c */
2/* Generate GUIDs for Object Safe interfaces */
3
4/* All IIDs defined in this file were extracted from
5 * HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Interface\ */
6
7#define INITGUID
8#include <basetyps.h>
9DEFINE_GUID(IID_IObjectSafety,0xcb5bdc81,0x93c1,0x11cf,0x8f,0x20,0,0x80,0x5f,0x2c,0xd0,0x64);
lib/libc/mingw/libsrc/ocidl-uuid.c created+46
...@@ -0,0 +1,46 @@
1/* ocidl-uuid.c */
2/* Generate GUIDs for OCIDL interfaces */
3
4/* All IIDs defined in this file were extracted from
5 * HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Interface\ */
6
7#define INITGUID
8#include <basetyps.h>
9DEFINE_GUID(IID_IQuickActivate,0xcf51ed10,0x62fe,0x11cf,0xbf,0x86,0,0xa0,0xc9,0x3,0x48,0x36);
10DEFINE_GUID(IID_IOleUndoManager,0xd001f200,0xef97,0x11ce,0x9b,0xc9,0,0xaa,0,0x60,0x8e,0x1);
11DEFINE_GUID(IID_IOleParentUndoUnit,0xa1faf330,0xef97,0x11ce,0x9b,0xc9,0,0xaa,0,0x60,0x8e,0x1);
12DEFINE_GUID(IID_IOleUndoUnit,0x894ad3b0,0xef97,0x11ce,0x9b,0xc9,0,0xaa,0,0x60,0x8e,0x1);
13DEFINE_GUID(IID_IEnumOleUndoUnits,0xb3e7c340,0xef97,0x11ce,0x9b,0xc9,0,0xaa,0,0x60,0x8e,0x1);
14DEFINE_GUID(IID_IPointerInactive,0x55980ba0,0x35aa,0x11cf,0xb6,0x71,0,0xaa,0,0x4c,0xd6,0xd8);
15/*DEFINE_GUID(IID_IAdviseSinkEx,0x3af24290,0xc96,0x11ce,0xa0,0xcf,0,0xaa,0,0x60,0xa,0xb8);*/
16DEFINE_GUID(IID_IOleInPlaceSiteEx,0x9c2cad80,0x3424,0x11cf,0xb6,0x70,0,0xaa,0,0x4c,0xd6,0xd8);
17DEFINE_GUID(IID_IOleControl,0xb196b288,0xbab4,0x101a,0xb6,0x9c,0,0xaa,0,0x34,0x1d,0x7);
18DEFINE_GUID(IID_IOleControlSite,0xB196B289,0xBAB4,0x101A,0xB6,0x9C,0x00,0xAA,0x00,0x34,0x1D,0x07);
19DEFINE_GUID(IID_IPersistPropertyBag,0x37d84f60,0x42cb,0x11ce,0x81,0x35,0,0xaa,0,0x4b,0xb8,0x51);
20DEFINE_GUID(IID_IPersistPropertyBag2,0x22f55881,0x280b,0x11d0,0xa8,0xa9,0,0xa0,0xc9,0xc,0x20,4);
21DEFINE_GUID(IID_IPersistStreamInit,0x7fd52380,0x4e07,0x101b,0xae,0x2d,0x8,0,0x2b,0x2e,0xc7,0x13);
22DEFINE_GUID(IID_IPersistMemory,0xbd1ae5e0,0xa6ae,0x11ce,0xbd,0x37,0x50,0x42,0,0xc1,0,0);
23DEFINE_GUID(IID_IPropertyBag,0x55272a00,0x42cb,0x11ce,0x81,0x35,0,0xaa,0,0x4b,0xb8,0x51);
24DEFINE_GUID(IID_IPropertyBag2,0x22f55882,0x280b,0x11d0,0xa8,0xa9,0,0xa0,0xc9,0xc,0x20,0x4);
25DEFINE_GUID(IID_IPropertyNotifySink,0x9bfbbc02,0xeff1,0x101a,0x84,0xed,0,0xaa,0,0x34,0x1d,0x7);
26DEFINE_GUID(IID_IPropertyPage,0xb196b28d,0xbab4,0x101a,0xb6,0x9c,0,0xaa,0,0x34,0x1d,0x7);
27DEFINE_GUID(IID_IPropertyPage2,0x1e44665,0x24ac,0x101b,0x84,0xed,0x8,0,0x2b,0x2e,0xc7,0x13);
28DEFINE_GUID(IID_IPropertyPageSite,0xb196b28c,0xbab4,0x101a,0xb6,0x9c,0,0xaa,0,0x34,0x1d,0x7);
29DEFINE_GUID(IID_IFont,0xbef6e002,0xa874,0x101a,0x8b,0xba,0,0xaa,0,0x30,0xc,0xab);
30// Font
31DEFINE_GUID(IID_IFontDisp,0xbef6e003,0xa874,0x101a,0x8b,0xba,0,0xaa,0,0x30,0xc,0xab);
32DEFINE_GUID(IID_IPicture,0x7bf80980,0xbf32,0x101a,0x8b,0xbb,0,0xaa,0,0x30,0xc,0xab);
33// Picture
34DEFINE_GUID(IID_IPictureDisp,0x7bf80981,0xbf32,0x101a,0x8b,0xbb,0,0xaa,0,0x30,0xc,0xab);
35DEFINE_GUID(IID_IProvideClassInfo,0xb196b283,0xbab4,0x101a,0xb6,0x9c,0,0xaa,0,0x34,0x1d,0x7);
36DEFINE_GUID(IID_IProvideClassInfo2,0xa6bc3ac0,0xdbaa,0x11ce,0x9d,0xe3,0,0xaa,0,0x4b,0xb8,0x51);
37DEFINE_GUID(IID_IEnumConnectionPoints,0xb196b285,0xbab4,0x101a,0xb6,0x9c,0,0xaa,0,0x34,0x1d,0x7);
38DEFINE_GUID(IID_IEnumConnections,0xb196b287,0xbab4,0x101a,0xb6,0x9c,0,0xaa,0,0x34,0x1d,0x7);
39DEFINE_GUID(IID_IConnectionPoint,0xb196b286,0xbab4,0x101a,0xb6,0x9c,0,0xaa,0,0x34,0x1d,0x7);
40DEFINE_GUID(IID_IConnectionPointContainer,0xb196b284,0xbab4,0x101a,0xb6,0x9c,0,0xaa,0,0x34,0x1d,0x7);
41DEFINE_GUID(IID_IClassFactory2,0xb196b28f,0xbab4,0x101a,0xb6,0x9c,0,0xaa,0,0x34,0x1d,0x7);
42DEFINE_GUID(IID_IErrorLog,0x3127ca40,0x446e,0x11ce,0x81,0x35,0,0xaa,0,0x4b,0xb8,0x51);
43DEFINE_GUID(IID_IObjectWithSite,0xfc4801a3,0x2ba9,0x11cf,0xa2,0x29,0,0xaa,0,0x3d,0x73,0x52);
44DEFINE_GUID(IID_IPerPropertyBrowsing,0x376bd3aa,0x3845,0x101b,0x84,0xed,0x8,0,0x2b,0x2e,0xc7,0x13);
45DEFINE_GUID(IID_ISimpleFrameSite,0x742b0e01,0x14e6,0x101b,0x91,0x4e,0,0xaa,0,0x30,0xc,0xab);
46DEFINE_GUID(IID_ISpecifyPropertyPages,0xb196b28b,0xbab4,0x101a,0xb6,0x9c,0,0xaa,0,0x34,0x1d,0x7);
lib/libc/mingw/libsrc/oleacc-uuid.c created+12
...@@ -0,0 +1,12 @@
1/* oleacc-uuid.c */
2/* Generate GUIDs for OLE Accessibility interfaces */
3
4/* All IIDs defined in this file were extracted from
5 * HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Interface\ */
6
7#define INITGUID
8#include <basetyps.h>
9DEFINE_GUID(IID_IAccessible,0x618736e0,0x3c3d,0x11cf,0x81,0x0c,0x00,0xaa,0x00,0x38,0x9b,0x71);
10// IAccessibleHandler TypeLib
11DEFINE_GUID(LIBID_Accessibility, 0x1ea4dbf0, 0x3c3b,0x11cf, 0x81, 0x0c, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);
12DEFINE_GUID(IID_IAccessibleHandler, 0x03022430, 0xABC4, 0x11d0, 0xBD, 0xE2, 0x00, 0xAA, 0x00, 0x1A, 0x19, 0x53);
lib/libc/mingw/libsrc/olectlid-uuid.c created+36
...@@ -0,0 +1,36 @@
1/* olectlid-uuid.c */
2/* Generate GUIDs for OLECTLID interfaces */
3
4/* All IIDs defined in this file were extracted from
5 * HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Interface\ */
6
7/* All CLSIDs defined in this file were extracted from
8 * HKEY_CLASSES_ROOT\CLSID\ */
9
10#define INITGUID
11#include <basetyps.h>
12DEFINE_OLEGUID(IID_IDispatch,0x20400,0,0);
13DEFINE_OLEGUID(IID_IEnumUnknown,0x100,0,0);
14DEFINE_OLEGUID(IID_IEnumString,0x101,0,0);
15DEFINE_OLEGUID(IID_IEnumMoniker,0x102,0,0);
16DEFINE_OLEGUID(IID_IEnumFORMATETC,0x103,0,0);
17DEFINE_OLEGUID(IID_IEnumOLEVERB,0x104,0,0);
18DEFINE_OLEGUID(IID_IEnumSTATDATA,0x105,0,0);
19DEFINE_OLEGUID(IID_IEnumSTATSTG,0xd,0,0);
20DEFINE_OLEGUID(IID_IOleLink,0x11d,0,0);
21DEFINE_OLEGUID(IID_IDebug,0x123,0,0);
22DEFINE_OLEGUID(IID_IDebugStream,0x124,0,0);
23// Font Property Page CLSID
24DEFINE_GUID(CLSID_CFontPropPage, 0x0be35200,0x8f91,0x11ce,0x9d,0xe3,0x00,0xaa,0x00,0x4b,0xb8,0x51);
25// Color Property Page CLSID
26DEFINE_GUID(CLSID_CColorPropPage,0xbe35201,0x8f91,0x11ce,0x9d,0xe3,0,0xaa,0,0x4b,0xb8,0x51);
27// Picture Property Page CLSID
28DEFINE_GUID(CLSID_CPicturePropPage,0xbe35202,0x8f91,0x11ce,0x9d,0xe3,0,0xaa,0,0x4b,0xb8,0x51);
29// Standard Font CLSID
30DEFINE_GUID(CLSID_StdFont,0xbe35203,0x8f91,0x11ce,0x9d,0xe3,0,0xaa,0,0x4b,0xb8,0x51);
31// Standard Picture CLSID
32DEFINE_GUID(CLSID_StdPicture,0xbe35204,0x8f91,0x11ce,0x9d,0xe3,0,0xaa,0,0x4b,0xb8,0x51);
33// Picture (Metafile) CLSID
34DEFINE_OLEGUID(CLSID_Picture_Metafile,0x315,0,0);
35// Picture (Device Independent Bitmap) CLSID
36DEFINE_OLEGUID(CLSID_Picture_Dib,0x316,0,0);
lib/libc/mingw/libsrc/oleidl-uuid.c created+27
...@@ -0,0 +1,27 @@
1/* oleidl-uuid.c */
2/* Generate GUIDs for OLE IDL interfaces */
3
4/* All IIDs defined in this file were extracted from
5 * HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Interface\ */
6
7#define INITGUID
8#include <basetyps.h>
9DEFINE_OLEGUID(IID_IOleCache,0x11e,0,0);
10DEFINE_OLEGUID(IID_IOleCache2,0x128,0,0);
11DEFINE_OLEGUID(IID_IOleCacheControl,0x129,0,0);
12DEFINE_OLEGUID(IID_IViewObject,0x10d,0,0);
13DEFINE_OLEGUID(IID_IViewObject2,0x127,0,0);
14DEFINE_OLEGUID(IID_IDropSource,0x121,0,0);
15DEFINE_OLEGUID(IID_IDropTarget,0x122,0,0);
16DEFINE_OLEGUID(IID_IOleAdviseHolder,0x111,0,0);
17DEFINE_OLEGUID(IID_IOleInPlaceUIWindow,0x115,0,0);
18DEFINE_OLEGUID(IID_IOleInPlaceObject,0x113,0,0);
19DEFINE_OLEGUID(IID_IOleInPlaceActiveObject,0x117,0,0);
20DEFINE_OLEGUID(IID_IOleInPlaceFrame,0x116,0,0);
21DEFINE_OLEGUID(IID_IOleInPlaceSite,0x119,0,0);
22DEFINE_OLEGUID(IID_IOleContainer,0x11b,0,0);
23DEFINE_OLEGUID(IID_IOleItemContainer,0x11c,0,0);
24DEFINE_OLEGUID(IID_IOleClientSite,0x118,0,0);
25DEFINE_OLEGUID(IID_IOleObject,0x112,0,0);
26DEFINE_OLEGUID(IID_IOleWindow,0x114,0,0);
27DEFINE_OLEGUID(IID_IParseDisplayName,0x11a,0,0);
lib/libc/mingw/libsrc/power-uuid.c created+18
...@@ -0,0 +1,18 @@
1/* power-uuid.c */
2/* Generate GUIDs for OLE Accessibility interfaces */
3
4/* All IIDs defined in this file were found at "Registering for Power Events" on MSDN here:
5 * http://msdn2.microsoft.com/en-us/library/aa373195.aspx
6 */
7
8#define INITGUID
9#include <basetyps.h>
10DEFINE_GUID(GUID_POWERSCHEME_PERSONALITY, 0x245d8541, 0x3943, 0x4422, 0xb0, 0x25, 0x13, 0xA7, 0x84, 0xF6, 0x79, 0xB7);
11DEFINE_GUID(GUID_MIN_POWER_SAVINGS, 0x8c5e7fda, 0xe8bf, 0x4a96, 0x9a, 0x85, 0xa6, 0xe2, 0x3a, 0x8c, 0x63, 0x5c);
12DEFINE_GUID(GUID_MAX_POWER_SAVINGS, 0xa1841308, 0x3541, 0x4fab, 0xbc, 0x81, 0xf7, 0x15, 0x56, 0xf2, 0x0b, 0x4a);
13DEFINE_GUID(GUID_TYPICAL_POWER_SAVINGS, 0x381b4222, 0xf694, 0x41f0, 0x96, 0x85, 0xff, 0x5b, 0xb2, 0x60, 0xdf, 0x2e);
14DEFINE_GUID(GUID_ACDC_POWER_SOURCE, 0x5d3e9a59, 0xe9D5, 0x4b00, 0xa6, 0xbd, 0xff, 0x34, 0xff, 0x51, 0x65, 0x48);
15DEFINE_GUID(GUID_BATTERY_PERCENTAGE_REMAINING, 0xa7ad8041, 0xb45a, 0x4cae, 0x87, 0xa3, 0xee, 0xcb, 0xb4, 0x68, 0xa9, 0xe1);
16DEFINE_GUID(GUID_IDLE_BACKGROUND_TASK, 0x515c31d8, 0xf734, 0x163d, 0xa0, 0xfd, 0x11, 0xa0, 0x8c, 0x91, 0xe8, 0xf1);
17DEFINE_GUID(GUID_SYSTEM_AWAYMODE, 0x98a7f580, 0x01f7, 0x48aa, 0x9c, 0x0f, 0x44, 0x35, 0x2c, 0x29, 0xe5, 0xC0);
18DEFINE_GUID(GUID_MONITOR_POWER_ON, 0x02731015, 0x4510, 0x4526, 0x99, 0xe6, 0xe5, 0xa1, 0x7e, 0xbd, 0x1a, 0xea);
lib/libc/mingw/libsrc/powrprof-uuid.c created+15
...@@ -0,0 +1,15 @@
1/*
2http://msdn.microsoft.com/en-us/library/aa372725%28v=VS.85%29.aspx
3PowerCreatePossibleSetting GUIDs
4*/
5
6#define INITGUID
7#include <basetyps.h>
8DEFINE_GUID(NO_SUBGROUP_GUID,0xfea3413e,0x7e05,0x4911,0x9a,0x71,0x70,0x03,0x31,0xf1,0xc2,0x94);
9DEFINE_GUID(GUID_DISK_SUBGROUP,0x0012ee47,0x9041,0x4b5d,0x9b,0x77,0x53,0x5f,0xba,0x8b,0x14,0x42);
10DEFINE_GUID(GUID_SYSTEM_BUTTON_SUBGROUP,0x4f971e89,0xeebd,0x4455,0xa8,0xde,0x9e,0x59,0x04,0x0e,0x73,0x47);
11DEFINE_GUID(GUID_PROCESSOR_SETTINGS_SUBGROUP,0x54533251,0x82be,0x4824,0x96,0xc1,0x47,0xb6,0x0b,0x74,0x0d,0x00);
12DEFINE_GUID(GUID_VIDEO_SUBGROUP,0x7516b95f,0xf776,0x4464,0x8c,0x53,0x06,0x16,0x7f,0x40,0xcc,0x99);
13DEFINE_GUID(GUID_BATTERY_SUBGROUP,0xe73a048d,0xbf27,0x4f12,0x97,0x31,0x8b,0x20,0x76,0xe8,0x89,0x1f);
14DEFINE_GUID(GUID_SLEEP_SUBGROUP,0x238C9FA8,0x0AAD,0x41ED,0x83,0xF4,0x97,0xBE,0x24,0x2C,0x8F,0x20);
15DEFINE_GUID(GUID_PCIEXPRESS_SETTINGS_SUBGROUP,0x501a4d13,0x42af,0x4429,0x9f,0xd1,0xa8,0x21,0x8c,0x26,0x8e,0x20);
lib/libc/mingw/libsrc/uianimation-uuid.c created+44
...@@ -0,0 +1,44 @@
1/* uianimation-uuid.c */
2/* Generate GUIDs for Microsoft Windows Animation Manager interfaces */
3#define INITGUID
4#include <basetyps.h>
5
6DEFINE_GUID(CLSID_UIAnimationManager, 0x4c1fc63a, 0x695c, 0x47e8, 0xa3,0x39, 0x1a,0x19,0x4b,0xe3,0xd0,0xb8);
7DEFINE_GUID(CLSID_UIAnimationManager2, 0xd25d8842, 0x8884, 0x4a4a, 0xb3,0x21, 0x09,0x13,0x14,0x37,0x9b,0xdd);
8DEFINE_GUID(CLSID_UIAnimationTransitionLibrary, 0x1d6322ad, 0xaa85, 0x4ef5, 0xa8,0x28, 0x86,0xd7,0x10,0x67,0xd1,0x45);
9DEFINE_GUID(CLSID_UIAnimationTransitionLibrary2, 0x812f944a, 0xc5c8, 0x4cd9, 0xb0,0xa6, 0xb3,0xda,0x80,0x2f,0x22,0x8d);
10DEFINE_GUID(CLSID_UIAnimationTransitionFactory, 0x8a9b1cdd, 0xfcd7, 0x419c, 0x8b,0x44, 0x42,0xfd,0x17,0xdb,0x18,0x87);
11DEFINE_GUID(CLSID_UIAnimationTransitionFactory2, 0x84302f97, 0x7f7b, 0x4040, 0xb1,0x90, 0x72,0xac,0x9d,0x18,0xe4,0x20);
12DEFINE_GUID(CLSID_UIAnimationTimer, 0xbfcd4a0c, 0x06b6, 0x4384, 0xb7,0x68, 0x0d,0xaa,0x79,0x2c,0x38,0x0e);
13DEFINE_GUID(IID_IUIAnimationManager, 0x9169896c, 0xac8d, 0x4e7d, 0x94,0xe5, 0x67,0xfa,0x4d,0xc2,0xf2,0xe8);
14DEFINE_GUID(IID_IUIAnimationVariable, 0x8ceeb155, 0x2849, 0x4ce5, 0x94,0x48, 0x91,0xff,0x70,0xe1,0xe4,0xd9);
15DEFINE_GUID(IID_IUIAnimationStoryboard, 0xa8ff128f, 0x9bf9, 0x4af1, 0x9e,0x67, 0xe5,0xe4,0x10,0xde,0xfb,0x84);
16DEFINE_GUID(IID_IUIAnimationTransition, 0xdc6ce252, 0xf731, 0x41cf, 0xb6,0x10, 0x61,0x4b,0x6c,0xa0,0x49,0xad);
17DEFINE_GUID(IID_IUIAnimationStoryboardEventHandler, 0x3d5c9008, 0xec7c, 0x4364, 0x9f,0x8a, 0x9a,0xf3,0xc5,0x8c,0xba,0xe6);
18DEFINE_GUID(IID_IUIAnimationVariableChangeHandler, 0x6358b7ba, 0x87d2, 0x42d5, 0xbf,0x71, 0x82,0xe9,0x19,0xdd,0x58,0x62);
19DEFINE_GUID(IID_IUIAnimationVariableIntegerChangeHandler, 0xbb3e1550, 0x356e, 0x44b0, 0x99,0xda, 0x85,0xac,0x60,0x17,0x86,0x5e);
20DEFINE_GUID(IID_IUIAnimationManagerEventHandler, 0x783321ed, 0x78a3, 0x4366, 0xb5,0x74, 0x6a,0xf6,0x07,0xa6,0x47,0x88);
21DEFINE_GUID(IID_IUIAnimationPriorityComparison, 0x83fa9b74, 0x5f86, 0x4618, 0xbc,0x6a, 0xa2,0xfa,0xc1,0x9b,0x3f,0x44);
22DEFINE_GUID(IID_IUIAnimationManager2, 0xd8b6f7d4, 0x4109, 0x4d3f, 0xac,0xee, 0x87,0x99,0x26,0x96,0x8c,0xb1);
23DEFINE_GUID(IID_IUIAnimationVariable2, 0x4914b304, 0x96ab, 0x44d9, 0x9e,0x77, 0xd5,0x10,0x9b,0x7e,0x74,0x66);
24DEFINE_GUID(IID_IDCompositionAnimation, 0xcbfd91d9, 0x51b2, 0x45e4, 0xb3,0xde, 0xd1,0x9c,0xcf,0xb8,0x63,0xc5);
25DEFINE_GUID(IID_IUIAnimationStoryboard2, 0xae289cd2, 0x12d4, 0x4945, 0x94,0x19, 0x9e,0x41,0xbe,0x03,0x4d,0xf2);
26DEFINE_GUID(IID_IUIAnimationTransition2, 0x62ff9123, 0xa85a, 0x4e9b, 0xa2,0x18, 0x43,0x5a,0x93,0xe2,0x68,0xfd);
27DEFINE_GUID(IID_IUIAnimationLoopIterationChangeHandler2, 0x2d3b15a4, 0x4762, 0x47ab, 0xa0,0x30, 0xb2,0x32,0x21,0xdf,0x3a,0xe0);
28DEFINE_GUID(IID_IUIAnimationStoryboardEventHandler2, 0xbac5f55a, 0xba7c, 0x414c, 0xb5,0x99, 0xfb,0xf8,0x50,0xf5,0x53,0xc6);
29DEFINE_GUID(IID_IUIAnimationVariableChangeHandler2, 0x63acc8d2, 0x6eae, 0x4bb0, 0xb8,0x79, 0x58,0x6d,0xd8,0xcf,0xbe,0x42);
30DEFINE_GUID(IID_IUIAnimationVariableIntegerChangeHandler2, 0x829b6cf1, 0x4f3a, 0x4412, 0xae,0x09, 0xb2,0x43,0xeb,0x4c,0x6b,0x58);
31DEFINE_GUID(IID_IUIAnimationVariableCurveChangeHandler2, 0x72895e91, 0x0145, 0x4c21, 0x91,0x92, 0x5a,0xab,0x40,0xed,0xdf,0x80);
32DEFINE_GUID(IID_IUIAnimationManagerEventHandler2, 0xf6e022ba, 0xbff3, 0x42ec, 0x90,0x33, 0xe0,0x73,0xf3,0x3e,0x83,0xc3);
33DEFINE_GUID(IID_IUIAnimationPriorityComparison2, 0x5b6d7a37, 0x4621, 0x467c, 0x8b,0x05, 0x70,0x13,0x1d,0xe6,0x2d,0xdb);
34DEFINE_GUID(IID_IUIAnimationTransitionLibrary, 0xca5a14b1, 0xd24f, 0x48b8, 0x8f,0xe4, 0xc7,0x81,0x69,0xba,0x95,0x4e);
35DEFINE_GUID(IID_IUIAnimationTransitionLibrary2, 0x03cfae53, 0x9580, 0x4ee3, 0xb3,0x63, 0x2e,0xce,0x51,0xb4,0xaf,0x6a);
36DEFINE_GUID(IID_IUIAnimationTransitionFactory, 0xfcd91e03, 0x3e3b, 0x45ad, 0xbb,0xb1, 0x6d,0xfc,0x81,0x53,0x74,0x3d);
37DEFINE_GUID(IID_IUIAnimationInterpolator, 0x7815cbba, 0xddf7, 0x478c, 0xa4,0x6c, 0x7b,0x6c,0x73,0x8b,0x79,0x78);
38DEFINE_GUID(IID_IUIAnimationTransitionFactory2, 0x937d4916, 0xc1a6, 0x42d5, 0x88,0xd8, 0x30,0x34,0x4d,0x6e,0xfe,0x31);
39DEFINE_GUID(IID_IUIAnimationInterpolator2, 0xea76aff8, 0xea22, 0x4a23, 0xa0,0xef, 0xa6,0xa9,0x66,0x70,0x35,0x18);
40DEFINE_GUID(IID_IUIAnimationPrimitiveInterpolation, 0xbab20d63, 0x4361, 0x45da, 0xa2,0x4f, 0xab,0x85,0x08,0x84,0x6b,0x5b);
41DEFINE_GUID(IID_IUIAnimationTimer, 0x6b0efad1, 0xa053, 0x41d6, 0x90,0x85, 0x33,0xa6,0x89,0x14,0x46,0x65);
42DEFINE_GUID(IID_IUIAnimationTimerUpdateHandler, 0x195509b7, 0x5d5e, 0x4e3e, 0xb2,0x78, 0xee,0x37,0x59,0xb3,0x67,0xad);
43DEFINE_GUID(IID_IUIAnimationTimerClientEventHandler, 0xbedb4db6, 0x94fa, 0x4bfb, 0xa4,0x7f, 0xef,0x2d,0x9e,0x40,0x8c,0x25);
44DEFINE_GUID(IID_IUIAnimationTimerEventHandler, 0x274a7dea, 0xd771, 0x4095, 0xab,0xbd, 0x8d,0xf7,0xab,0xd2,0x3c,0xe3);
lib/libc/mingw/libsrc/usbcamdi-uuid.c created+7
...@@ -0,0 +1,7 @@
1/* from usbcamdi.h */
2
3#define INITGUID
4#include <basetyps.h>
5
6DEFINE_GUID(GUID_USBCAMD_INTERFACE, 0x2bcb75c0, 0xb27f, 0x11d1, 0xba, 0x41, 0x0, 0xa0, 0xc9, 0xd, 0x2b, 0x5);
7
lib/libc/mingw/libsrc/usbiodef-uuid.c created+18
...@@ -0,0 +1,18 @@
1/* from usbiodef.h */
2
3#define INITGUID
4#include <basetyps.h>
5
6DEFINE_GUID(GUID_DEVINTERFACE_USB_HUB, 0xF18A0E88, 0xc30C, 0x11D0, 0x88, 0x15, 0x00, 0xA0, 0xC9, 0x06, 0xBE, 0xD8);
7DEFINE_GUID(GUID_DEVINTERFACE_USB_DEVICE, 0xA5DCBF10L, 0x6530, 0x11D2, 0x90, 0x1F, 0x00, 0xC0, 0x4F, 0xB9, 0x51, 0xED);
8DEFINE_GUID(GUID_DEVINTERFACE_USB_HOST_CONTROLLER, 0x3ABF6F2D, 0x71C4, 0x462A, 0x8A, 0x92, 0x1E, 0x68, 0x61, 0xE6, 0xAF, 0x27);
9DEFINE_GUID(GUID_USB_WMI_STD_DATA, 0x4E623B20L, 0xCB14, 0x11D1, 0xB3, 0x31, 0x00, 0xA0, 0xC9, 0x59, 0xBB, 0xD2);
10DEFINE_GUID(GUID_USB_WMI_STD_NOTIFICATION, 0x4E623B20L, 0xCB14, 0x11D1, 0xB3, 0x31, 0x00, 0xA0, 0xC9, 0x59, 0xBB, 0xD2);
11
12DEFINE_GUID(GUID_USB_WMI_DEVICE_PERF_INFO, 0x66c1aa3c, 0x499f, 0x49a0, 0xa9, 0xa5, 0x61, 0xe2, 0x35, 0x9f, 0x64, 0x7);
13DEFINE_GUID(GUID_USB_WMI_NODE_INFO, 0x9c179357, 0xdc7a, 0x4f41, 0xb6, 0x6b, 0x32, 0x3b, 0x9d, 0xdc, 0xb5, 0xb1);
14DEFINE_GUID(GUID_USB_WMI_HUB_DIAGNOSTICS, 0xad0379e4, 0x72db, 0x42ed, 0xba, 0x6e, 0x67, 0x57, 0x4, 0x79, 0x7, 0xd);
15DEFINE_GUID(GUID_USB_WMI_TRACING, 0x3a61881b, 0xb4e6, 0x4bf9, 0xae, 0xf, 0x3c, 0xd8, 0xf3, 0x94, 0xe5, 0x2f);
16DEFINE_GUID(GUID_USB_TRANSFER_TRACING, 0x681eb8aa, 0x403d, 0x452c, 0x9f, 0x8a, 0xf0, 0x61, 0x6f, 0xac, 0x95, 0x40);
17DEFINE_GUID(GUID_USB_PERFORMANCE_TRACING, 0xd5de77a6, 0x6ae9, 0x425c, 0xb1, 0xe2, 0xf5, 0x61, 0x5f, 0xd3, 0x48, 0xa9);
18
lib/libc/mingw/libsrc/uuid.c created+397
...@@ -0,0 +1,397 @@
1/*
2 Generate GUIDs for OLE and other interfaces.
3
4 This file was generated by extracting the names of all GUIDs
5 from uuid.lib. The names were in turn processed by a script
6 to build a C program that when run generated this file.
7 Some definitions were added by hand afterwards.
8*/
9
10/*
11 TODO: Break up into smaller units, based on declarations in headers.
12*/
13
14#define INITGUID
15#include <basetyps.h>
16
17#include <textstor.h>
18#include <shobjidl.h>
19#include <propkey.h>
20#include <isguids.h>
21#include <shlguid.h>
22#include <urlhist.h>
23#include <oleacc.h>
24#include <oledb.h>
25#include <uiautomation.h>
26#include <urlmon.h>
27#include <d2d1_1.h>
28#include <d3d11_1.h>
29#include <netlistmgr.h>
30
31DEFINE_GUID(ARRAYID_PathProperties,0x7ecbba04,0x2d97,0x11cf,0xa2,0x29,0,0xaa,0,0x3d,0x73,0x52);
32DEFINE_GUID(CATID_InternetAware,0xde86a58,0x2baa,0x11cf,0xa2,0x29,0,0xaa,0,0x3d,0x73,0x52);
33DEFINE_GUID(CATID_IsShortcut,0x40fc6ed6,0x2438,0x11cf,0xa3,0xdb,0x8,0,0x36,0xf1,0x25,0x2);
34DEFINE_GUID(CATID_NeverShowExt,0x40fc6ed7,0x2438,0x11cf,0xa3,0xdb,0x8,0,0x36,0xf1,0x25,0x2);
35DEFINE_GUID(CATID_PersistsToFile,0xde86a56,0x2baa,0x11cf,0xa2,0x29,0,0xaa,0,0x3d,0x73,0x52);
36DEFINE_GUID(CATID_PersistsToMemory,0xde86a55,0x2baa,0x11cf,0xa2,0x29,0,0xaa,0,0x3d,0x73,0x52);
37DEFINE_GUID(CATID_PersistsToMoniker,0xde86a51,0x2baa,0x11cf,0xa2,0x29,0,0xaa,0,0x3d,0x73,0x52);
38DEFINE_GUID(CATID_RequiresDataPathHost,0xde86a50,0x2baa,0x11cf,0xa2,0x29,0,0xaa,0,0x3d,0x73,0x52);
39DEFINE_GUID(CATID_SafeForInitializing,0x7dd95802,0x9882,0x11cf,0x9f,0xa9,0,0xaa,0,0x6c,0x42,0xc4);
40DEFINE_GUID(CATID_SafeForScripting,0x7dd95801,0x9882,0x11cf,0x9f,0xa9,0,0xaa,0,0x6c,0x42,0xc4);
41DEFINE_GUID(CLSID_AllClasses,0x330,0,0,0xc0,0,0,0,0,0,0,0x46);
42DEFINE_GUID(CLSID_CColorPropPage,0xbe35201,0x8f91,0x11ce,0x9d,0xe3,0,0xaa,0,0x4b,0xb8,0x51);
43DEFINE_GUID(CLSID_CFontPropPage, 0x0be35200,0x8f91,0x11ce,0x9d,0xe3,0x00,0xaa,0x00,0x4b,0xb8,0x51);
44DEFINE_GUID(CLSID_CPicturePropPage,0xbe35202,0x8f91,0x11ce,0x9d,0xe3,0,0xaa,0,0x4b,0xb8,0x51);
45DEFINE_GUID(CLSID_ConvertVBX,0xfb8f0822,0x164,0x101b,0x84,0xed,0x8,0,0x2b,0x2e,0xc7,0x13);
46DEFINE_GUID(CLSID_CurrentUserClasses,0x332,0,0,0xc0,0,0,0,0,0,0,0x46);
47DEFINE_GUID(CLSID_IdentityUnmarshal,0x1b,0,0,0xc0,0,0,0,0,0,0,0x46);
48DEFINE_GUID(CLSID_InProcFreeMarshaler,0x1c,0,0,0xc0,0,0,0,0,0,0,0x46);
49DEFINE_GUID(CLSID_LocalMachineClasses,0x331,0,0,0xc0,0,0,0,0,0,0,0x46);
50DEFINE_GUID(CLSID_PSBindCtx,0x312,0,0,0xc0,0,0,0,0,0,0,0x46);
51DEFINE_GUID(CLSID_PSClassObject,0x30E,0,0,0xc0,0,0,0,0,0,0,0x46);
52DEFINE_GUID(CLSID_PSClientSite,0x30d,0,0,0xc0,0,0,0,0,0,0,0x46);
53DEFINE_GUID(CLSID_PSDragDrop,0x311,0,0,0xc0,0,0,0,0,0,0,0x46);
54DEFINE_GUID(CLSID_PSEnumerators,0x313,0,0,0xc0,0,0,0,0,0,0,0x46);
55DEFINE_GUID(CLSID_PSGenObject,0x30c,0,0,0xc0,0,0,0,0,0,0,0x46);
56DEFINE_GUID(CLSID_PSInPlaceActive,0x30f,0,0,0xc0,0,0,0,0,0,0,0x46);
57DEFINE_GUID(CLSID_PSInPlaceFrame,0x310,0,0,0xc0,0,0,0,0,0,0,0x46);
58DEFINE_GUID(CLSID_PersistPropset,0xfb8f0821,0x164,0x101b,0x84,0xed,0x8,0,0x2b,0x2e,0xc7,0x13);
59DEFINE_GUID(CLSID_Picture_Dib,0x316,0,0,0xc0,0,0,0,0,0,0,0x46);
60DEFINE_GUID(CLSID_Picture_EnhMetafile,0x319,0,0,0xc0,0,0,0,0,0,0,0x46);
61DEFINE_GUID(CLSID_Picture_Metafile,0x315,0,0,0xc0,0,0,0,0,0,0,0x46);
62DEFINE_GUID(CLSID_DCOMAccessControl,0x0000031d,0x0000,0x0000,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x46);
63DEFINE_GUID(CLSID_StaticDib,0x316,0,0,0xc0,0,0,0,0,0,0,0x46);
64DEFINE_GUID(CLSID_StaticMetafile,0x315,0,0,0xc0,0,0,0,0,0,0,0x46);
65DEFINE_GUID(CLSID_StdFont,0xbe35203,0x8f91,0x11ce,0x9d,0xe3,0,0xaa,0,0x4b,0xb8,0x51);
66DEFINE_GUID(CLSID_StdHlink,0x79eac9d0,0xbaf9,0x11ce,0x8c,0x82,0,0xaa,0,0x4b,0xa9,0xb);
67DEFINE_GUID(CLSID_StdHlinkBrowseContext,0x79eac9d1,0xbaf9,0x11ce,0x8c,0x82,0,0xaa,0,0x4b,0xa9,0xb);
68DEFINE_GUID(CLSID_StdMarshal,0x17,0,0,0xc0,0,0,0,0,0,0,0x46);
69DEFINE_GUID(CLSID_StdPicture,0xbe35204,0x8f91,0x11ce,0x9d,0xe3,0,0xaa,0,0x4b,0xb8,0x51);
70DEFINE_GUID(CLSID_StdURLProtocol,0x79eac9e1,0xbaf9,0x11ce,0x8c,0x82,0,0xaa,0,0x4b,0xa9,0xb);
71DEFINE_GUID(CLSID_CTask, 0x148BD520, 0xA2AB, 0x11CE, 0xB1, 0x1F, 0x00, 0xAA, 0x00, 0x53, 0x05, 0x03);
72DEFINE_GUID(CLSID_CTaskScheduler, 0x148BD52A, 0xA2AB, 0x11CE, 0xB1, 0x1F, 0x00, 0xAA, 0x00, 0x53, 0x05, 0x03);
73DEFINE_GUID(FLAGID_Internet,0x96300da0,0x2bab,0x11cf,0xa2,0x29,0,0xaa,0,0x3d,0x73,0x52);
74DEFINE_GUID(FMTID_DocSummaryInformation,0xd5cdd502,0x2e9c,0x101b,0x93,0x97,0x8,0,0x2b,0x2c,0xf9,0xae);
75DEFINE_GUID(FMTID_SummaryInformation,0xf29f85e0,0x4ff9,0x1068,0xab,0x91,0x8,0,0x2b,0x27,0xb3,0xd9);
76DEFINE_GUID(FMTID_UserDefinedProperties,0xd5cdd505,0x2e9c,0x101b,0x93,0x97,0x8,0,0x2b,0x2c,0xf9,0xae);
77DEFINE_GUID(GUID_CHECKVALUEEXCLUSIVE,0x6650430c,0xbe0f,0x101a,0x8b,0xbb,0,0xaa,0,0x30,0xc,0xab);
78DEFINE_GUID(GUID_COLOR,0x66504301,0xbe0f,0x101a,0x8b,0xbb,0,0xaa,0,0x30,0xc,0xab);
79DEFINE_GUID(GUID_FONTBOLD,0x6650430f,0xbe0f,0x101a,0x8b,0xbb,0,0xaa,0,0x30,0xc,0xab);
80DEFINE_GUID(GUID_FONTITALIC,0x66504310,0xbe0f,0x101a,0x8b,0xbb,0,0xaa,0,0x30,0xc,0xab);
81DEFINE_GUID(GUID_FONTNAME,0x6650430d,0xbe0f,0x101a,0x8b,0xbb,0,0xaa,0,0x30,0xc,0xab);
82DEFINE_GUID(GUID_FONTSIZE,0x6650430e,0xbe0f,0x101a,0x8b,0xbb,0,0xaa,0,0x30,0xc,0xab);
83DEFINE_GUID(GUID_FONTSTRIKETHROUGH,0x66504312,0xbe0f,0x101a,0x8b,0xbb,0,0xaa,0,0x30,0xc,0xab);
84DEFINE_GUID(GUID_FONTUNDERSCORE,0x66504311,0xBE0F,0x101A,0x8B,0xBB,0x00,0xAA,0x00,0x30,0x0C,0xAB);
85DEFINE_GUID(GUID_HANDLE,0x66504313,0xbe0f,0x101a,0x8b,0xbb,0,0xaa,0,0x30,0xc,0xab);
86DEFINE_GUID(GUID_HIMETRIC,0x66504300,0xbe0f,0x101a,0x8b,0xbb,0,0xaa,0,0x30,0xc,0xab);
87DEFINE_GUID(GUID_HasPathProperties,0x2de81,0,0,0xc0,0,0,0,0,0,0,0x46);
88DEFINE_GUID(GUID_OPTIONVALUEEXCLUSIVE,0x6650430b,0xbe0f,0x101a,0x8b,0xbb,0,0xaa,0,0x30,0xc,0xab);
89DEFINE_GUID(GUID_PathProperty,0x2de80,0,0,0xc0,0,0,0,0,0,0,0x46);
90DEFINE_GUID(GUID_TRISTATE,0x6650430a,0xbe0f,0x101a,0x8b,0xbb,0,0xaa,0,0x30,0xc,0xab);
91DEFINE_GUID(GUID_XPOS,0x66504306,0xbe0f,0x101a,0x8b,0xbb,0,0xaa,0,0x30,0xc,0xab);
92DEFINE_GUID(GUID_XPOSPIXEL,0x66504302,0xbe0f,0x101a,0x8b,0xbb,0,0xaa,0,0x30,0xc,0xab);
93DEFINE_GUID(GUID_XSIZE,0x66504308,0xbe0f,0x101a,0x8b,0xbb,0,0xaa,0,0x30,0xc,0xab);
94DEFINE_GUID(GUID_XSIZEPIXEL,0x66504304,0xbe0f,0x101a,0x8b,0xbb,0,0xaa,0,0x30,0xc,0xab);
95DEFINE_GUID(GUID_YPOS,0x66504307,0xbe0f,0x101a,0x8b,0xbb,0,0xaa,0,0x30,0xc,0xab);
96DEFINE_GUID(GUID_YPOSPIXEL,0x66504303,0xbe0f,0x101a,0x8b,0xbb,0,0xaa,0,0x30,0xc,0xab);
97DEFINE_GUID(GUID_YSIZE,0x66504309,0xbe0f,0x101a,0x8b,0xbb,0,0xaa,0,0x30,0xc,0xab);
98DEFINE_GUID(GUID_YSIZEPIXEL,0x66504305,0xbe0f,0x101a,0x8b,0xbb,0,0xaa,0,0x30,0xc,0xab);
99/*DEFINE_GUID(IID_IAdviseSink2,0x125,0,0,0xc0,0,0,0,0,0,0,0x46);
100DEFINE_GUID(IID_IAdviseSinkEx,0x3af24290,0xc96,0x11ce,0xa0,0xcf,0,0xaa,0,0x60,0xa,0xb8);*/
101DEFINE_GUID(IID_IAccessControl,0xeedd23e0,0x8410,0x11CE,0xA1,0xC3,0x08,0x00,0x2B,0x2B,0x8D,0x8F);
102DEFINE_GUID(IID_IAsyncMoniker,0x79eac9d3,0xbaf9,0x11ce,0x8c,0x82,0,0xaa,0,0x4b,0xa9,0xb);
103DEFINE_GUID(IID_IAsyncOperation,0x3d8b0590,0xf691,0x11d2,0x8e,0xa9,0x00,0x60,0x97,0xdf,0x5b,0xd4);
104/*DEFINE_GUID(IID_IAuthenticate,0x79eac9d0,0xbaf9,0x11ce,0x8c,0x82,0,0xaa,0,0x4b,0xa9,0xb);*/
105/*DEFINE_GUID(IID_IBindHost,0xfc4801a1,0x2ba9,0x11cf,0xa2,0x29,0,0xaa,0,0x3d,0x73,0x52);
106DEFINE_GUID(IID_IBindProtocol,0x79eac9cd,0xbaf9,0x11ce,0x8c,0x82,0,0xaa,0,0x4b,0xa9,0xb);*/
107DEFINE_GUID(IID_IBindStatusCallbackMsg,0x79eac9cb,0xbaf9,0x11ce,0x8c,0x82,0,0xaa,0,0x4b,0xa9,0xb);
108DEFINE_GUID(CLSID_InternetSecurityManager, 0x7b8a2d94,0x0ac9,0x11d1,0x89,0x6c,0x00,0xc0,0x4f,0xb6,0xbf,0xc4);
109DEFINE_GUID(CLSID_InternetZoneManager, 0x7B8A2D95,0x0AC9,0x11D1,0x89,0x6C,0x00,0xC0,0x4F,0xB6,0xBF,0xC4);
110/*DEFINE_GUID(IID_IChannelHook,0x1008c4a0,0x7613,0x11cf,0x9a,0xf1,0,0x20,0xaf,0x6e,0x72,0xf4);
111DEFINE_GUID(IID_IClassActivator,0x140,0,0,0xc0,0,0,0,0,0,0,0x46);
112DEFINE_GUID(IID_IClassFactory2,0xb196b28f,0xbab4,0x101a,0xb6,0x9c,0,0xaa,0,0x34,0x1d,0x7);
113DEFINE_GUID(IID_IClientSecurity,0x13D,0,0,0xc0,0,0,0,0,0,0,0x46);*/
114DEFINE_GUID(IID_IContext, 0x000001c0, 0x0000, 0x0000, 0xc0,0x00, 0x00,0x00,0x00,0x00,0x00,0x46);
115/*DEFINE_GUID(IID_ICodeInstall,0x79eac9d1,0xbaf9,0x11ce,0x8c,0x82,0,0xaa,0,0x4b,0xa9,0xb);
116DEFINE_GUID(IID_IConnectionPoint,0xb196b286,0xbab4,0x101a,0xb6,0x9c,0,0xaa,0,0x34,0x1d,0x7);
117DEFINE_GUID(IID_IConnectionPointContainer,0xb196b284,0xbab4,0x101a,0xb6,0x9c,0,0xaa,0,0x34,0x1d,0x7);
118DEFINE_GUID(IID_IContinue,0x12a,0,0,0xc0,0,0,0,0,0,0,0x46);*/
119/*DEFINE_GUID(IID_IContinueCallback,0xb722bcca,0x4e68,0x101b,0xa2,0xbc,0,0xaa,0,0x40,0x47,0x70);*/
120/*DEFINE_GUID(IID_ICreateErrorInfo,0x22f03340,0x547d,0x101b,0x8e,0x65,0x8,0,0x2b,0x2b,0xd1,0x19);*/
121/*DEFINE_GUID(IID_ICreateTypeInfo2,0x2040e,0,0,0xc0,0,0,0,0,0,0,0x46);*/
122/*DEFINE_GUID(IID_ICreateTypeLib,0x20406,0,0,0xc0,0,0,0,0,0,0,0x46);*/
123/*DEFINE_GUID(IID_ICreateTypeLib2,0x2040F,0,0,0xc0,0,0,0,0,0,0,0x46);*/
124/*DEFINE_GUID(IID_IDataAdviseHolder,0x110,0,0,0xc0,0,0,0,0,0,0,0x46);*/
125DEFINE_GUID(IID_IDebug,0x123,0,0,0xc0,0,0,0,0,0,0,0x46);
126DEFINE_GUID(IID_IDebugStream,0x124,0,0,0xc0,0,0,0,0,0,0,0x46);
127DEFINE_GUID(IID_IDfReserved1,0x13,0,0,0xc0,0,0,0,0,0,0,0x46);
128DEFINE_GUID(IID_IDfReserved2,0x14,0,0,0xc0,0,0,0,0,0,0,0x46);
129DEFINE_GUID(IID_IDfReserved3,0x15,0,0,0xc0,0,0,0,0,0,0,0x46);
130/*DEFINE_GUID(IID_IDropSource,0x121,0,0,0xc0,0,0,0,0,0,0,0x46);
131DEFINE_GUID(IID_IDropTarget,0x122,0,0,0xc0,0,0,0,0,0,0,0x46);*/
132DEFINE_GUID(IID_IEmptyVolumeCacheCallBack, 0x6E793361, 0x73C6, 0x11D0, 0x84, 0x69, 0, 0xAA, 0, 0x44, 0x29, 0x1);
133DEFINE_GUID(IID_IEmptyVolumeCache2, 0x02B7E3BA, 0x4DB3, 0x11D2, 0xB2, 0xD9, 0, 0xC0, 0x4F, 0x8E, 0xEC, 0x8C);
134DEFINE_GUID(IID_IEmptyVolumeCache, 0x8FCE5227, 0x04DA, 0x11D1, 0xA0, 0x4, 0, 0x80, 0x5F, 0x8A, 0xBE, 0x6);
135DEFINE_GUID(IID_IEnumCallback,0x108,0,0,0xc0,0,0,0,0,0,0,0x46);
136DEFINE_GUID(IID_IEnumContextProps, 0x000001c1, 0x0000, 0x0000, 0xc0,0x00, 0x00,0x00,0x00,0x00,0x00,0x46);
137/*DEFINE_GUID(IID_IEnumConnectionPoints,0xb196b285,0xbab4,0x101a,0xb6,0x9c,0,0xaa,0,0x34,0x1d,0x7);
138DEFINE_GUID(IID_IEnumConnections,0xb196b287,0xbab4,0x101a,0xb6,0x9c,0,0xaa,0,0x34,0x1d,0x7);*/
139DEFINE_GUID(IID_IEnumGeneric,0x106,0,0,0xc0,0,0,0,0,0,0,0x46);
140DEFINE_GUID(IID_IEnumHLITEM,0x79eac9c6,0xbaf9,0x11ce,0x8c,0x82,0,0xaa,0,0x4b,0xa9,0xb);
141DEFINE_GUID(IID_IEnumHolder,0x107,0,0,0xc0,0,0,0,0,0,0,0x46);
142/*DEFINE_GUID(IID_IEnumOLEVERB,0x104,0,0,0xc0,0,0,0,0,0,0,0x46);*/
143/*DEFINE_GUID(IID_IEnumOleDocumentViews,0xb722bcc8,0x4e68,0x101b,0xa2,0xbc,0,0xaa,0,0x40,0x47,0x70);*/
144/*DEFINE_GUID(IID_IEnumOleUndoUnits,0xb3e7c340,0xef97,0x11ce,0x9b,0xc9,0,0xaa,0,0x60,0x8e,0x1);*/
145/*DEFINE_GUID(IID_IEnumSTATPROPSETSTG,0x13b,0,0,0xc0,0,0,0,0,0,0,0x46);*/
146/*DEFINE_GUID(IID_IEnumSTATPROPSTG,0x139,0,0,0xc0,0,0,0,0,0,0,0x46);*/
147/*DEFINE_GUID(IID_IErrorInfo,0x1cf2b120,0x547d,0x101b,0x8e,0x65,0x8,0,0x2b,0x2b,0xd1,0x19);*/
148/*DEFINE_GUID(IID_IExternalConnection,0x19,0,0,0xc0,0,0,0,0,0,0,0x46);
149DEFINE_GUID(IID_IFillLockBytes,0x99caf010,0x415e,0x11cf,0x88,0x14,0,0xaa,0,0xb5,0x69,0xf5);*/
150DEFINE_GUID(IID_IFilter,0x89bcb740,0x6119,0x101a,0xbc,0xb7,0,0xdd,0x1,0x6,0x55,0xaf);
151/*DEFINE_GUID(IID_IFont,0xbef6e002,0xa874,0x101a,0x8b,0xba,0,0xaa,0,0x30,0xc,0xab);
152DEFINE_GUID(IID_IFontDisp,0xbef6e003,0xa874,0x101a,0x8b,0xba,0,0xaa,0,0x30,0xc,0xab);
153DEFINE_GUID(IID_IGlobalInterfaceTable,0x146,0,0,0xc0,0,0,0,0,0,0,0x46);*/
154DEFINE_GUID(IID_IHlink,0x79eac9c3,0xbaf9,0x11ce,0x8c,0x82,0,0xaa,0,0x4b,0xa9,0xb);
155DEFINE_GUID(IID_IHlinkBrowseContext,0x79eac9c7,0xbaf9,0x11ce,0x8c,0x82,0,0xaa,0,0x4b,0xa9,0xb);
156DEFINE_GUID(IID_IHlinkFrame,0x79eac9c5,0xbaf9,0x11ce,0x8c,0x82,0,0xaa,0,0x4b,0xa9,0xb);
157DEFINE_GUID(IID_IHlinkSite,0x79eac9c2,0xbaf9,0x11ce,0x8c,0x82,0,0xaa,0,0x4b,0xa9,0xb);
158DEFINE_GUID(IID_IHlinkTarget,0x79eac9c4,0xbaf9,0x11ce,0x8c,0x82,0,0xaa,0,0x4b,0xa9,0xb);
159DEFINE_GUID(IID_IHTMLOMWindowServices, 0x3050F5FC, 0x98B5, 0x11CF, 0xBB, 0x82, 0, 0xAA, 0, 0xBD, 0xCE, 0xB);
160/*DEFINE_GUID(IID_IHttpNegotiate,0x79eac9d2,0xbaf9,0x11ce,0x8c,0x82,0,0xaa,0,0x4b,0xa9,0xb);
161DEFINE_GUID(IID_IHttpSecurity,0x79eac9d7,0xbafa,0x11ce,0x8c,0x82,0,0xaa,0,0x4b,0xa9,0xb);*/
162DEFINE_GUID(IID_IInternalMoniker,0x11,0,0,0xc0,0,0,0,0,0,0,0x46);
163/*DEFINE_GUID(IID_ILayoutStorage,0xe6d4d90,0x6738,0x11cf,0x96,0x8,0,0xaa,0,0x68,0xd,0xb4);
164DEFINE_GUID(IID_ILockBytes,0xa,0,0,0xc0,0,0,0,0,0,0,0x46);
165DEFINE_GUID(IID_IMalloc,0x2,0,0,0xc0,0,0,0,0,0,0,0x46);
166DEFINE_GUID(IID_IMallocSpy,0x1d,0,0,0xc0,0,0,0,0,0,0,0x46);
167DEFINE_GUID(IID_IMarshal,0x3,0,0,0xc0,0,0,0,0,0,0,0x46);
168DEFINE_GUID(IID_IMessageFilter,0x16,0,0,0xc0,0,0,0,0,0,0,0x46);*/
169DEFINE_GUID(IID_IMimeInfo,0xf77459a0,0xbf9a,0x11cf,0xba,0x4e,0,0xc0,0x4f,0xd7,0x8,0x16);
170/*DEFINE_GUID(IID_IMultiQI,0x20,0,0,0xc0,0,0,0,0,0,0,0x46);*/
171DEFINE_GUID(IID_IObjectSafety,0xcb5bdc81,0x93c1,0x11cf,0x8f,0x20,0,0x80,0x5f,0x2c,0xd0,0x64);
172/*DEFINE_GUID(IID_IObjectWithSite,0xfc4801a3,0x2ba9,0x11cf,0xa2,0x29,0,0xaa,0,0x3d,0x73,0x52);
173DEFINE_GUID(IID_IOleAdviseHolder,0x111,0,0,0xc0,0,0,0,0,0,0,0x46);
174DEFINE_GUID(IID_IOleCache,0x11e,0,0,0xc0,0,0,0,0,0,0,0x46);
175DEFINE_GUID(IID_IOleCache2,0x128,0,0,0xc0,0,0,0,0,0,0,0x46);
176DEFINE_GUID(IID_IOleCacheControl,0x129,0,0,0xc0,0,0,0,0,0,0,0x46);
177DEFINE_GUID(IID_IOleClientSite,0x118,0,0,0xc0,0,0,0,0,0,0,0x46);
178DEFINE_GUID(IID_IOleContainer,0x11b,0,0,0xc0,0,0,0,0,0,0,0x46);
179DEFINE_GUID(IID_IOleControl,0xb196b288,0xbab4,0x101a,0xb6,0x9c,0,0xaa,0,0x34,0x1d,0x7);
180DEFINE_GUID(IID_IOleControlSite,0xB196B289,0xBAB4,0x101A,0xB6,0x9C,0x00,0xAA,0x00,0x34,0x1D,0x07);*/
181/*DEFINE_GUID(IID_IOleDocument,0xb722bcc5,0x4e68,0x101b,0xa2,0xbc,0,0xaa,0,0x40,0x47,0x70);*/
182/*DEFINE_GUID(IID_IOleDocumentSite,0xb722bcc7,0x4e68,0x101b,0xa2,0xbc,0,0xaa,0,0x40,0x47,0x70);*/
183/*DEFINE_GUID(IID_IOleDocumentView,0xb722bcc6,0x4e68,0x101b,0xa2,0xbc,0,0xaa,0,0x40,0x47,0x70);*/
184/*DEFINE_GUID(IID_IOleInPlaceActiveObject,0x117,0,0,0xc0,0,0,0,0,0,0,0x46);
185DEFINE_GUID(IID_IOleInPlaceFrame,0x116,0,0,0xc0,0,0,0,0,0,0,0x46);
186DEFINE_GUID(IID_IOleInPlaceObject,0x113,0,0,0xc0,0,0,0,0,0,0,0x46);
187DEFINE_GUID(IID_IOleInPlaceObjectWindowless,0x1c2056cc,0x5ef4,0x101b,0x8b,0xc8,0,0xaa,0,0x3e,0x3b,0x29);
188DEFINE_OLEGUID(IID_IOleInPlaceSite,0x00000119,0,0);
189DEFINE_GUID(IID_IOleInPlaceSiteEx,0x9c2cad80,0x3424,0x11cf,0xb6,0x70,0,0xaa,0,0x4c,0xd6,0xd8);
190DEFINE_GUID(IID_IOleInPlaceSiteWindowless,0x922eada0,0x3424,0x11cf,0xb6,0x70,0,0xaa,0,0x4c,0xd6,0xd8);
191DEFINE_GUID(IID_IOleInPlaceUIWindow,0x115,0,0,0xc0,0,0,0,0,0,0,0x46);
192DEFINE_GUID(IID_IOleItemContainer,0x11c,0,0,0xc0,0,0,0,0,0,0,0x46);
193DEFINE_GUID(IID_IOleLink,0x11d,0,0,0xc0,0,0,0,0,0,0,0x46);*/
194DEFINE_GUID(IID_IOleManager,0x11f,0,0,0xc0,0,0,0,0,0,0,0x46);
195/*DEFINE_GUID(IID_IOleObject,0x112,0,0,0xc0,0,0,0,0,0,0,0x46);
196DEFINE_GUID(IID_IOleParentUndoUnit,0xa1faf330,0xef97,0x11ce,0x9b,0xc9,0,0xaa,0,0x60,0x8e,0x1);*/
197DEFINE_GUID(IID_IOlePresObj,0x120,0,0,0xc0,0,0,0,0,0,0,0x46);
198DEFINE_GUID(IID_IOleUndoManager00,0x97d001f2,0xceef,0x9b11,0xc9,0,0xaa,0,0x60,0x8e,0x1,0);
199/*DEFINE_GUID(IID_IOleUndoManager,0xd001f200,0xef97,0x11ce,0x9b,0xc9,0,0xaa,0,0x60,0x8e,0x1);
200DEFINE_GUID(IID_IOleUndoUnit,0x894ad3b0,0xef97,0x11ce,0x9b,0xc9,0,0xaa,0,0x60,0x8e,0x1);
201DEFINE_GUID(IID_IOleWindow,0x114,0,0,0xc0,0,0,0,0,0,0,0x46);*/
202DEFINE_GUID(IID_IOverlappedCompletion,0x521a28f0,0xe40b,0x11ce,0xb2,0xc9,0,0xaa,0,0x68,0x9,0x37);
203DEFINE_GUID(IID_IOverlappedStream,0x49384070,0xe40a,0x11ce,0xb2,0xc9,0,0xaa,0,0x68,0x9,0x37);
204DEFINE_GUID(IID_IPSFactory,0x9,0,0,0xc0,0,0,0,0,0,0,0x46);
205/*DEFINE_GUID(IID_IPSFactoryBuffer,0xd5f569d0,0x593b,0x101a,0xb5,0x69,0x8,0,0x2b,0x2d,0xbf,0x7a);
206DEFINE_GUID(IID_IParseDisplayName,0x11a,0,0,0xc0,0,0,0,0,0,0,0x46);
207DEFINE_GUID(IID_IPerPropertyBrowsing,0x376bd3aa,0x3845,0x101b,0x84,0xed,0x8,0,0x2b,0x2e,0xc7,0x13);
208DEFINE_GUID(IID_IPersistFile,0x10b,0,0,0xc0,0,0,0,0,0,0,0x46);
209DEFINE_GUID(IID_IPersistMemory,0xbd1ae5e0,0xa6ae,0x11ce,0xbd,0x37,0x50,0x42,0,0xc1,0,0);
210DEFINE_GUID(IID_IPersistMoniker,0x79eac9c9,0xbaf9,0x11ce,0x8c,0x82,0,0xaa,0,0x4b,0xa9,0x0b);
211DEFINE_GUID(IID_IPersistPropertyBag,0x37d84f60,0x42cb,0x11ce,0x81,0x35,0,0xaa,0,0x4b,0xb8,0x51);
212DEFINE_GUID(IID_IPersistPropertyBag2,0x22f55881,0x280b,0x11d0,0xa8,0xa9,0,0xa0,0xc9,0xc,0x20,4);
213DEFINE_OLEGUID(IID_IPersistStorage,0x0000010a,0,0);
214DEFINE_GUID(IID_IPersistStreamInit,0x7fd52380,0x4e07,0x101b,0xae,0x2d,0x8,0,0x2b,0x2e,0xc7,0x13);
215DEFINE_GUID(IID_IPicture,0x7bf80980,0xbf32,0x101a,0x8b,0xbb,0,0xaa,0,0x30,0xc,0xab);
216DEFINE_GUID(IID_IPictureDisp,0x7bf80981,0xbf32,0x101a,0x8b,0xbb,0,0xaa,0,0x30,0xc,0xab);
217DEFINE_GUID(IID_IPointerInactive,0x55980ba0,0x35aa,0x11cf,0xb6,0x71,0,0xaa,0,0x4c,0xd6,0xd8);*/
218/*DEFINE_GUID(IID_IPrint,0xb722bcc9,0x4e68,0x101b,0xa2,0xbc,0,0xaa,0,0x40,0x47,0x70);*/
219/*DEFINE_GUID(IID_IProgressNotify,0xa9d758a0,0x4617,0x11cf,0x95,0xfc,0,0xaa,0,0x68,0xd,0xb4);*/
220DEFINE_GUID(IID_IPropertyFrame,0xb196b28a,0xbab4,0x101a,0xb6,0x9c,0,0xaa,0,0x34,0x1d,0x7);
221/*DEFINE_GUID(IID_IPropertyNotifySink,0x9bfbbc02,0xeff1,0x101a,0x84,0xed,0,0xaa,0,0x34,0x1d,0x7);
222DEFINE_GUID(IID_IPropertyPage,0xb196b28d,0xbab4,0x101a,0xb6,0x9c,0,0xaa,0,0x34,0x1d,0x7);
223DEFINE_GUID(IID_IPropertyPage2,0x1e44665,0x24ac,0x101b,0x84,0xed,0x8,0,0x2b,0x2e,0xc7,0x13);
224DEFINE_GUID(IID_IPropertyPageSite,0xb196b28c,0xbab4,0x101a,0xb6,0x9c,0,0xaa,0,0x34,0x1d,0x7);*/
225/*DEFINE_GUID(IID_IPropertySetStorage,0x13a,0,0,0xc0,0,0,0,0,0,0,0x46);*/
226/*DEFINE_GUID(IID_IPropertyStorage,0x138,0,0,0xc0,0,0,0,0,0,0,0x46);*/
227/*DEFINE_GUID(IID_IProvideClassInfo,0xb196b283,0xbab4,0x101a,0xb6,0x9c,0,0xaa,0,0x34,0x1d,0x7);
228DEFINE_GUID(IID_IProvideClassInfo2,0xa6bc3ac0,0xdbaa,0x11ce,0x9d,0xe3,0,0xaa,0,0x4b,0xb8,0x51);*/
229DEFINE_GUID(IID_IProvideTaskPage, 0x4086658A, 0xCBBB, 0x11CF, 0xB6, 0x4, 0, 0xC0, 0x4F, 0xD8, 0xD5, 0x65);
230DEFINE_GUID(IID_IProxy,0x27,0,0,0xc0,0,0,0,0,0,0,0x46);
231DEFINE_GUID(IID_IProxyManager,0x8,0,0,0xc0,0,0,0,0,0,0,0x46);
232/*DEFINE_GUID(IID_IQuickActivate,0xcf51ed10,0x62fe,0x11cf,0xbf,0x86,0,0xa0,0xc9,0x3,0x48,0x36);*/
233/*DEFINE_GUID(IID_IROTData,0xf29f6bc0,0x5021,0x11ce,0xaa,0x15,0,0,0x69,0x1,0x29,0x3f);*/
234DEFINE_GUID(IID_IRichEditOle,0x20d00,0,0,0xc0,0,0,0,0,0,0,0x46);
235DEFINE_GUID(IID_IRichEditOleCallback,0x20d03,0,0,0xc0,0,0,0,0,0,0,0x46);
236/*DEFINE_GUID(IID_IRootStorage,0x12,0,0,0xc0,0,0,0,0,0,0,0x46);*/
237DEFINE_GUID(IID_IRpcChannel,0x4,0,0,0xc0,0,0,0,0,0,0,0x46);
238/*DEFINE_GUID(IID_IRpcChannelBuffer,0xd5f56b60,0x593b,0x101a,0xb5,0x69,0x8,0,0x2b,0x2d,0xbf,0x7a);*/
239DEFINE_GUID(IID_IRpcProxy,0x7,0,0,0xc0,0,0,0,0,0,0,0x46);
240/*DEFINE_GUID(IID_IRpcProxyBuffer,0xd5f56a34,0x593b,0x101a,0xb5,0x69,8,0,0x2b,0x2d,0xbf,0x7a);*/
241DEFINE_GUID(IID_IRpcProxyBuffer34,0x3bd5f56a,0x1a59,0xb510,0x69,0x8,0,0x2b,0x2d,0xbf,0x7a,0);
242DEFINE_GUID(IID_IRpcStub,0x5,0,0,0xc0,0,0,0,0,0,0,0x46);
243/*DEFINE_GUID(IID_IRpcStubBuffer,0xd5f56afc,0x593b,0x101a,0xb5,0x69,0x8,0,0x2b,0x2d,0xbf,0x7a);*/
244/*DEFINE_OLEGUID(IID_IRunnableObject,0x00000126,0,0);*/
245DEFINE_GUID(IID_IScheduledWorkItem, 0xA6B952F0, 0xA4B1, 0x11D0, 0x99, 0x7D, 0, 0xAA, 0, 0x68, 0x87, 0xEC);
246/*DEFINE_GUID(IID_IServerSecurity,0x13E,0,0,0xc0,0,0,0,0,0,0,0x46);*/
247/*DEFINE_GUID(IID_ISimpleFrameSite,0x742b0e01,0x14e6,0x101b,0x91,0x4e,0,0xaa,0,0x30,0xc,0xab);*/
248/*DEFINE_GUID(IID_ISpecifyPropertyPages,0xb196b28b,0xbab4,0x101a,0xb6,0x9c,0,0xaa,0,0x34,0x1d,0x7);*/
249/*DEFINE_OLEGUID(IID_IStdMarshalInfo,24,0,0);*/
250DEFINE_GUID(IID_IStub,0x26,0,0,0xc0,0,0,0,0,0,0,0x46);
251DEFINE_GUID(IID_IStubManager,0x6,0,0,0xc0,0,0,0,0,0,0,0x46);
252/*DEFINE_GUID(IID_ISupportErrorInfo,0xdf0b3d60,0x548f,0x101b,0x8e,0x65,0x8,0,0x2b,0x2b,0xd1,0x19);*/
253DEFINE_GUID(IID_ITask, 0x148BD524, 0xA2AB, 0x11CE, 0xB1, 0x1F, 0, 0xAA, 0, 0x53, 0x5, 0x3);
254DEFINE_GUID(IID_ITaskScheduler, 0x148BD527, 0xA2AB, 0x11CE, 0xB1, 0x1F, 0, 0xAA, 0, 0x53, 0x5, 0x3);
255DEFINE_GUID(IID_ITaskTrigger, 0x148BD52B, 0xA2AB, 0x11CE, 0xB1, 0x1F, 0, 0xAA, 0, 0x53, 0x5, 0x3);
256/*DEFINE_GUID(IID_ITypeChangeEvents,0x20410,0,0,0xc0,0,0,0,0,0,0,0x46);*/
257/*DEFINE_GUID(IID_ITypeInfo2,0x20412,0,0,0xc0,0,0,0,0,0,0,0x46); */
258/*DEFINE_GUID(IID_ITypeLib2,0x20411,0,0,0xc0,0,0,0,0,0,0,0x46); */
259/*DEFINE_GUID(IID_IViewObject,0x10d,0,0,0xc0,0,0,0,0,0,0,0x46); */
260/*DEFINE_GUID(IID_IViewObject2,0x127,0,0,0xc0,0,0,0,0,0,0,0x46);*/
261/*DEFINE_GUID(IID_IViewObjectEx,0x3af24292,0xc96,0x11ce,0xa0,0xcf,0,0xaa,0,0x60,0xa,0xb8);*/
262/*DEFINE_GUID(IID_IWinInetHttpInfo,0x79eac9d8,0xbafa,0x11ce,0x8c,0x82,0,0xaa,0,0x4b,0xa9,0xb);*/
263/*DEFINE_GUID(IID_IWinInetInfo,0x79eac9d6,0xbafa,0x11ce,0x8c,0x82,0,0xaa,0,0x4b,0xa9,0xb);*/
264/*DEFINE_GUID(IID_IWindowForBindingUI,0x79eac9d5,0xbafa,0x11ce,0x8c,0x82,0,0xaa,0,0x4b,0xa9,0xb);*/
265DEFINE_GUID(IID_StdOle,0x20430,0,0,0xc0,0,0,0,0,0,0,0x46);
266DEFINE_GUID(OLE_DATAPATH_ALLIMAGE,0x2de0e,0,0,0xc0,0,0,0,0,0,0,0x46);
267DEFINE_GUID(OLE_DATAPATH_ALLMM,0x2de18,0,0,0xc0,0,0,0,0,0,0,0x46);
268DEFINE_GUID(OLE_DATAPATH_ALLTEXT,0x2de1e,0,0,0xc0,0,0,0,0,0,0,0x46);
269DEFINE_GUID(OLE_DATAPATH_ANSITEXT,0x2de19,0,0,0xc0,0,0,0,0,0,0,0x46);
270DEFINE_GUID(OLE_DATAPATH_AVI,0x2de0f,0,0,0xc0,0,0,0,0,0,0,0x46);
271DEFINE_GUID(OLE_DATAPATH_BASICAUDIO,0x2de12,0,0,0xc0,0,0,0,0,0,0,0x46);
272DEFINE_GUID(OLE_DATAPATH_BIFF,0x2de21,0,0,0xc0,0,0,0,0,0,0,0x46);
273DEFINE_GUID(OLE_DATAPATH_BMP,0x2de01,0,0,0xc0,0,0,0,0,0,0,0x46);
274DEFINE_GUID(OLE_DATAPATH_CGM,0x2de0b,0,0,0xc0,0,0,0,0,0,0,0x46);
275DEFINE_GUID(OLE_DATAPATH_COMMONIMAGE,0x2de0d,0,0,0xc0,0,0,0,0,0,0,0x46);
276DEFINE_GUID(OLE_DATAPATH_DIB,0x2de02,0,0,0xc0,0,0,0,0,0,0,0x46);
277DEFINE_GUID(OLE_DATAPATH_DIF,0x2de1f,0,0,0xc0,0,0,0,0,0,0,0x46);
278DEFINE_GUID(OLE_DATAPATH_ENHMF,0x2de04,0,0,0xc0,0,0,0,0,0,0,0x46);
279DEFINE_GUID(OLE_DATAPATH_EPS,0x2de0c,0,0,0xc0,0,0,0,0,0,0,0x46);
280DEFINE_GUID(OLE_DATAPATH_GIF,0x2de05,0,0,0xc0,0,0,0,0,0,0,0x46);
281DEFINE_GUID(OLE_DATAPATH_HTML,0x2de1c,0,0,0xc0,0,0,0,0,0,0,0x46);
282DEFINE_GUID(OLE_DATAPATH_JPEG,0x2de06,0,0,0xc0,0,0,0,0,0,0,0x46);
283DEFINE_GUID(OLE_DATAPATH_MIDI,0x2de13,0,0,0xc0,0,0,0,0,0,0,0x46);
284DEFINE_GUID(OLE_DATAPATH_MPEG,0x2de10,0,0,0xc0,0,0,0,0,0,0,0x46);
285DEFINE_GUID(OLE_DATAPATH_PALETTE,0x2de22,0,0,0xc0,0,0,0,0,0,0,0x46);
286DEFINE_GUID(OLE_DATAPATH_PCX,0x2de09,0,0,0xc0,0,0,0,0,0,0,0x46);
287DEFINE_GUID(OLE_DATAPATH_PENDATA,0x2de23,0,0,0xc0,0,0,0,0,0,0,0x46);
288DEFINE_GUID(OLE_DATAPATH_PICT,0x2de0a,0,0,0xc0,0,0,0,0,0,0,0x46);
289DEFINE_GUID(OLE_DATAPATH_POSTSCRIPT,0x2de1d,0,0,0xc0,0,0,0,0,0,0,0x46);
290DEFINE_GUID(OLE_DATAPATH_QUICKTIME,0x2de11,0,0,0xc0,0,0,0,0,0,0,0x46);
291DEFINE_GUID(OLE_DATAPATH_RIFF,0x2de15,0,0,0xc0,0,0,0,0,0,0,0x46);
292DEFINE_GUID(OLE_DATAPATH_RTF,0x2de1b,0,0,0xc0,0,0,0,0,0,0,0x46);
293DEFINE_GUID(OLE_DATAPATH_SOUND,0x2de16,0,0,0xc0,0,0,0,0,0,0,0x46);
294DEFINE_GUID(OLE_DATAPATH_SYLK,0x2de20,0,0,0xc0,0,0,0,0,0,0,0x46);
295DEFINE_GUID(OLE_DATAPATH_TIFF,0x2de07,0,0,0xc0,0,0,0,0,0,0,0x46);
296DEFINE_GUID(OLE_DATAPATH_UNICODE,0x2de1a,0,0,0xc0,0,0,0,0,0,0,0x46);
297DEFINE_GUID(OLE_DATAPATH_VIDEO,0x2de17,0,0,0xc0,0,0,0,0,0,0,0x46);
298DEFINE_GUID(OLE_DATAPATH_WAV,0x2de14,0,0,0xc0,0,0,0,0,0,0,0x46);
299DEFINE_GUID(OLE_DATAPATH_WMF,0x2de03,0,0,0xc0,0,0,0,0,0,0,0x46);
300DEFINE_GUID(OLE_DATAPATH_XBM,0x2de08,0,0,0xc0,0,0,0,0,0,0,0x46);
301DEFINE_GUID(SID_SContainerDispatch,0xb722be00,0x4e68,0x101b,0xa2,0xbc,0,0xaa,0,0x40,0x47,0x70);
302DEFINE_GUID(SID_SDataPathBrowser,0xfc4801a5,0x2ba9,0x11cf,0xa2,0x29,0,0xaa,0,0x3d,0x73,0x52);
303DEFINE_GUID(CLSID_GlobalOptions,0x0000034b,0x0000,0x0000,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x46);
304DEFINE_GUID(CLSID_StdGlobalInterfaceTable,0x00000323,0x0000,0x0000,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x46);
305DEFINE_GUID(IID_ICallFrameEvents,0xfd5e0843,0xfc91,0x11d0,0x97,0xd7,0x00,0xc0,0x4f,0xb9,0x61,0x8a);
306DEFINE_GUID(IID_ICallFrameWalker,0x08b23919,0x392d,0x11d2,0xb8,0xa4,0x00,0xc0,0x4f,0xb9,0x61,0x8a);
307DEFINE_GUID(IID_ICallInterceptor,0x60c7ca75,0x896d,0x11d2,0xb8,0xb6,0x00,0xc0,0x4f,0xb9,0x61,0x8a);
308DEFINE_GUID(CLSID_MSDAINITIALIZE,0x2206cdb0,0x19c1,0x11d1,0x89,0xe0,0x00,0xc0,0x4f,0xd7,0xa8,0x29);
309DEFINE_GUID(CLSID_DataLinks,0x2206cdb2,0x19c1,0x11d1,0x89,0xe0,0x00,0xc0,0x4f,0xd7,0xa8,0x29);
310DEFINE_GUID(CLSID_RootBinder,0xff151822,0xb0bf,0x11d1,0xa8,0x0d,0x00,0x00,0x00,0x00,0x00,0x00);
311DEFINE_GUID(IID_IDataInitialize,0x2206ccb1,0x19c1,0x11d1,0x89,0xe0,0x00,0xc0,0x4f,0xd7,0xa8,0x29);
312DEFINE_GUID(IID_IDBInitialize,0x0c733a8b,0x2a1c,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d);
313DEFINE_GUID(IID_IAccessor,0x0c733a8c,0x2a1c,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d);
314DEFINE_GUID(IID_IRowset,0x0c733a7c,0x2a1c,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d);
315DEFINE_GUID(IID_IRowsetInfo,0x0c733a55,0x2a1c,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d);
316DEFINE_GUID(IID_IRowsetLocate,0x0c733a7d,0x2a1c,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d);
317DEFINE_GUID(IID_IRowsetResynch,0x0c733a84,0x2a1c,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d);
318DEFINE_GUID(IID_IRowsetScroll,0x0c733a7e,0x2a1c,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d);
319DEFINE_GUID(IID_IRowsetChange,0x0c733a05,0x2a1c,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d);
320DEFINE_GUID(IID_IRowsetUpdate,0x0c733a6d,0x2a1c,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d);
321DEFINE_GUID(IID_IRowsetIdentity,0x0c733a09,0x2a1c,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d);
322DEFINE_GUID(IID_IRowsetNotify,0x0c733a83,0x2a1c,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d);
323DEFINE_GUID(IID_IRowsetIndex,0x0c733a82,0x2a1c,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d);
324DEFINE_GUID(IID_ICommand,0x0c733a63,0x2a1c,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d);
325DEFINE_GUID(IID_IMultipleResults,0x0c733a90,0x2a1c,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d);
326DEFINE_GUID(IID_IConvertType,0x0c733a88,0x2a1c,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d);
327DEFINE_GUID(IID_ICommandPrepare,0x0c733a26,0x2a1c,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d);
328DEFINE_GUID(IID_ICommandProperties,0x0c733a79,0x2a1c,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d);
329DEFINE_GUID(IID_ICommandText,0x0c733a27,0x2a1c,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d);
330DEFINE_GUID(IID_ICommandWithParameters,0x0c733a64,0x2a1c,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d);
331DEFINE_GUID(IID_IColumnsRowset,0x0c733a10,0x2a1c,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d);
332DEFINE_GUID(IID_IColumnsInfo,0x0c733a11,0x2a1c,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d);
333DEFINE_GUID(IID_IDBCreateCommand,0x0c733a1d,0x2a1c,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d);
334DEFINE_GUID(IID_IDBCreateSession,0x0c733a5d,0x2a1c,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d);
335DEFINE_GUID(IID_ISourcesRowset,0x0c733a1e,0x2a1c,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d);
336DEFINE_GUID(IID_IDBProperties,0x0c733a8a,0x2a1c,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d);
337DEFINE_GUID(IID_IDBInfo,0x0c733a89,0x2a1c,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d);
338DEFINE_GUID(IID_IDBDataSourceAdmin,0x0c733a7a,0x2a1c,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d);
339DEFINE_GUID(IID_ISessionProperties,0x0c733a85,0x2a1c,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d);
340DEFINE_GUID(IID_IIndexDefinition,0x0c733a68,0x2a1c,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d);
341DEFINE_GUID(IID_ITableDefinition,0x0c733a86,0x2a1c,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d);
342DEFINE_GUID(IID_IOpenRowset,0x0c733a69,0x2a1c,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d);
343DEFINE_GUID(IID_IDBSchemaRowset,0x0c733a7b,0x2a1c,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d);
344DEFINE_GUID(IID_IErrorRecords,0x0c733a67,0x2a1c,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d);
345DEFINE_GUID(IID_IErrorLookup,0x0c733a66,0x2a1c,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d);
346DEFINE_GUID(IID_ISQLErrorInfo,0x0c733a74,0x2a1c,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d);
347DEFINE_GUID(IID_IGetDataSource,0x0c733a75,0x2a1c,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d);
348DEFINE_GUID(IID_ITransactionLocal,0x0c733a5f,0x2a1c,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d);
349DEFINE_GUID(IID_ITransactionJoin,0x0c733a5e,0x2a1c,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d);
350DEFINE_GUID(IID_ITransactionObject,0x0c733a60,0x2a1c,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d);
351/* OLE DB v1.5 */
352DEFINE_GUID(IID_IChapteredRowset,0x0c733a93,0x2a1c,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d);
353DEFINE_GUID(IID_IDBAsynchNotify,0x0c733a96,0x2a1c,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d);
354DEFINE_GUID(IID_IDBAsynchStatus,0x0c733a95,0x2a1c,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d);
355DEFINE_GUID(IID_IRowsetFind,0x0c733a9d,0x2a1c,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d);
356DEFINE_GUID(IID_IRowPosition,0x0c733a94,0x2a1c,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d);
357DEFINE_GUID(IID_IRowPositionChange,0x0997a571,0x126e,0x11d0,0x9f,0x8a,0x00,0xa0,0xc9,0xa0,0x63,0x1e);
358DEFINE_GUID(IID_IViewRowset,0x0c733a97,0x2a1c,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d);
359DEFINE_GUID(IID_IViewChapter,0x0c733a98,0x2a1c,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d);
360DEFINE_GUID(IID_IViewSort,0x0c733a9a,0x2a1c,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d);
361DEFINE_GUID(IID_IViewFilter,0x0c733a9b,0x2a1c,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d);
362DEFINE_GUID(IID_IRowsetView,0x0c733a99,0x2a1c,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d);
363/* OLE DB v2.0 */
364DEFINE_GUID(IID_IMDDataset,0xa07cccd1,0x8148,0x11d0,0x87,0xbb,0x00,0xc0,0x4f,0xc3,0x39,0x42);
365DEFINE_GUID(IID_IMDFind,0xa07cccd2,0x8148,0x11d0,0x87,0xbb,0x00,0xc0,0x4f,0xc3,0x39,0x42);
366DEFINE_GUID(IID_IMDRangeRowset,0x0c733aa0,0x2a1c,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d);
367DEFINE_GUID(IID_IAlterTable,0x0c733aa5,0x2a1c,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d);
368DEFINE_GUID(IID_IAlterIndex,0x0c733aa6,0x2a1c,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d);
369DEFINE_GUID(IID_ICommandPersist,0x0c733aa7,0x2a1c,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d);
370DEFINE_GUID(IID_IRowsetChapterMember,0x0c733aa8,0x2a1c,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d);
371DEFINE_GUID(IID_IRowsetRefresh,0x0c733aa9,0x2a1c,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d);
372DEFINE_GUID(IID_IParentRowset,0x0c733aaa,0x2a1c,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d);
373/* OLE DB v2.1 */
374DEFINE_GUID(IID_ITrusteeAdmin,0x0c733aa1,0x2a1c,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d);
375DEFINE_GUID(IID_ITrusteeGroupAdmin,0x0c733aa2,0x2a1c,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d);
376DEFINE_GUID(IID_IObjectAccessControl,0x0c733aa3,0x2a1c,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d);
377DEFINE_GUID(IID_ISecurityInfo,0x0c733aa4,0x2a1c,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d);
378DEFINE_GUID(IID_IRow,0x0c733ab4,0x2a1c,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d);
379DEFINE_GUID(IID_IRowChange,0x0c733ab5,0x2a1c,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d);
380DEFINE_GUID(IID_IRowSchemaChange,0x0c733aae,0x2a1c,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d);
381DEFINE_GUID(IID_IGetRow,0x0c733aaf,0x2a1c,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d);
382DEFINE_GUID(IID_IScopedOperations,0x0c733ab0,0x2a1c,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d);
383DEFINE_GUID(IID_IBindResource,0x0c733ab1,0x2a1c,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d);
384DEFINE_GUID(IID_ICreateRow,0x0c733ab2,0x2a1c,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d);
385DEFINE_GUID(IID_IColumnsInfo2,0x0c733ab8,0x2a1c,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d);
386DEFINE_GUID(IID_IRegisterProvider,0x0c733ab9,0x2a1c,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d);
387DEFINE_GUID(IID_IGetSession,0x0c733aba,0x2a1c,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d);
388DEFINE_GUID(IID_IGetSourceRow,0x0c733abb,0x2a1c,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d);
389DEFINE_GUID(IID_ITableCreation,0x0c733abc,0x2a1c,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d);
390DEFINE_GUID(IID_IRowsetCurrentIndex,0x0c733abd,0x2a1c,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d);
391/* OLE DB v2.6 */
392/*
393 * The `IID_ICommandStream` may be defined in <sqloledb.h> (when the
394 * `DBINITCONSTANTS` is defned).
395DEFINE_GUID(IID_ICommandStream,0x0c733ac0,0x2a1c,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d);
396*/
397DEFINE_GUID(IID_IRowsetBookmark,0x0c733ac2,0x2a1c,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d);
lib/libc/mingw/libsrc/vds-uuid.c created+12
...@@ -0,0 +1,12 @@
1#define INITGUID
2#include <basetyps.h>
3
4/*http://msdn.microsoft.com/en-us/library/aa381635%28VS.85%29.aspx*/
5
6DEFINE_GUID(PARTITION_ENTRY_UNUSED_GUID,0x00000000,0x0000,0x0000,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00);
7DEFINE_GUID(PARTITION_SYSTEM_GUID,0xc12a7328,0xf81f,0x11d2,0xba,0x4b,0x00,0xa0,0xc9,0x3e,0xc9,0x3b);
8DEFINE_GUID(PARTITION_MSFT_RESERVED_GUID,0xe3c9e316,0x0b5c,0x4db8,0x81,0x7d,0xf9,0x2d,0xf0,0x02,0x15,0xae);
9DEFINE_GUID(PARTITION_BASIC_DATA_GUID,0xebd0a0a2,0xb9e5,0x4433,0x87,0xc0,0x68,0xb6,0xb7,0x26,0x99,0xc7);
10DEFINE_GUID(PARTITION_LDM_METADATA_GUID,0x5808c8aa,0x7e8f,0x42e0,0x85,0xd2,0xe1,0xe9,0x04,0x34,0xcf,0xb3);
11DEFINE_GUID(PARTITION_LDM_DATA_GUID,0xaf9b60a0,0x1431,0x4f62,0xbc,0x68,0x33,0x11,0x71,0x4a,0x69,0xad);
12DEFINE_GUID(PARTITION_MSFT_RECOVERY_GUID,0xde94bba4,0x06d1,0x4d40,0xa1,0x6a,0xbf,0xd5,0x01,0x79,0xd6,0xac);
lib/libc/mingw/libsrc/virtdisk-uuid.c created+4
...@@ -0,0 +1,4 @@
1#define INITGUID
2#include <basetyps.h>
3
4DEFINE_GUID(VIRTUAL_STORAGE_TYPE_VENDOR_MICROSOFT,0xEC984AEC,0xA0F9,0x47e9,0x90,0x1F,0x71,0x41,0x5A,0x66,0x34,0x5B);
lib/libc/mingw/libsrc/wia-uuid.c created+106
...@@ -0,0 +1,106 @@
1/* unknwn-uuid.c */
2/* Generate GUIDs for WIA interfaces */
3
4/* All IIDs defined in this file were extracted from
5 * HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Interface\ */
6
7#define INITGUID
8#include <basetyps.h>
9
10// Image types
11DEFINE_GUID(WiaImgFmt_UNDEFINED,0xb96b3ca9,0x0728,0x11d3,0x9d,0x7b,0x00,0x00,0xf8,0x1e,0xf3,0x2e);
12DEFINE_GUID(WiaImgFmt_RAWRGB,0xbca48b55,0xf272,0x4371,0xb0,0xf1,0x4a,0x15,0x0d,0x05,0x7b,0xb4);
13DEFINE_GUID(WiaImgFmt_MEMORYBMP,0xb96b3caa,0x0728,0x11d3,0x9d,0x7b,0x00,0x00,0xf8,0x1e,0xf3,0x2e);
14DEFINE_GUID(WiaImgFmt_BMP,0xb96b3cab,0x0728,0x11d3,0x9d,0x7b,0x00,0x00,0xf8,0x1e,0xf3,0x2e);
15DEFINE_GUID(WiaImgFmt_EMF,0xb96b3cac,0x0728,0x11d3,0x9d,0x7b,0x00,0x00,0xf8,0x1e,0xf3,0x2e);
16DEFINE_GUID(WiaImgFmt_WMF,0xb96b3cad,0x0728,0x11d3,0x9d,0x7b,0x00,0x00,0xf8,0x1e,0xf3,0x2e);
17DEFINE_GUID(WiaImgFmt_JPEG,0xb96b3cae,0x0728,0x11d3,0x9d,0x7b,0x00,0x00,0xf8,0x1e,0xf3,0x2e);
18DEFINE_GUID(WiaImgFmt_PNG,0xb96b3caf,0x0728,0x11d3,0x9d,0x7b,0x00,0x00,0xf8,0x1e,0xf3,0x2e);
19DEFINE_GUID(WiaImgFmt_GIF,0xb96b3cb0,0x0728,0x11d3,0x9d,0x7b,0x00,0x00,0xf8,0x1e,0xf3,0x2e);
20DEFINE_GUID(WiaImgFmt_TIFF,0xb96b3cb1,0x0728,0x11d3,0x9d,0x7b,0x00,0x00,0xf8,0x1e,0xf3,0x2e);
21DEFINE_GUID(WiaImgFmt_EXIF,0xb96b3cb2,0x0728,0x11d3,0x9d,0x7b,0x00,0x00,0xf8,0x1e,0xf3,0x2e);
22DEFINE_GUID(WiaImgFmt_PHOTOCD,0xb96b3cb3,0x0728,0x11d3,0x9d,0x7b,0x00,0x00,0xf8,0x1e,0xf3,0x2e);
23DEFINE_GUID(WiaImgFmt_FLASHPIX,0xb96b3cb4,0x0728,0x11d3,0x9d,0x7b,0x00,0x00,0xf8,0x1e,0xf3,0x2e);
24DEFINE_GUID(WiaImgFmt_ICO,0xb96b3cb5,0x0728,0x11d3,0x9d,0x7b,0x00,0x00,0xf8,0x1e,0xf3,0x2e);
25DEFINE_GUID(WiaImgFmt_CIFF,0x9821a8ab,0x3a7e,0x4215,0x94,0xe0,0xd2,0x7a,0x46,0x0c,0x03,0xb2);
26DEFINE_GUID(WiaImgFmt_PICT,0xa6bc85d8,0x6b3e,0x40ee,0xa9,0x5c,0x25,0xd4,0x82,0xe4,0x1a,0xdc);
27DEFINE_GUID(WiaImgFmt_JPEG2K,0x344ee2b2,0x39db,0x4dde,0x81,0x73,0xc4,0xb7,0x5f,0x8f,0x1e,0x49);
28DEFINE_GUID(WiaImgFmt_JPEG2KX,0x43e14614,0xc80a,0x4850,0xba,0xf3,0x4b,0x15,0x2d,0xc8,0xda,0x27);
29
30// Document and other types
31DEFINE_GUID(WiaImgFmt_RTF,0x573dd6a3,0x4834,0x432d,0xa9,0xb5,0xe1,0x98,0xdd,0x9e,0x89,0x0d);
32DEFINE_GUID(WiaImgFmt_XML,0xb9171457,0xdac8,0x4884,0xb3,0x93,0x15,0xb4,0x71,0xd5,0xf0,0x7e);
33DEFINE_GUID(WiaImgFmt_HTML,0xc99a4e62,0x99de,0x4a94,0xac,0xca,0x71,0x95,0x6a,0xc2,0x97,0x7d);
34DEFINE_GUID(WiaImgFmt_TXT,0xfafd4d82,0x723f,0x421f,0x93,0x18,0x30,0x50,0x1a,0xc4,0x4b,0x59);
35DEFINE_GUID(WiaImgFmt_MPG,0xecd757e4,0xd2ec,0x4f57,0x95,0x5d,0xbc,0xf8,0xa9,0x7c,0x4e,0x52);
36DEFINE_GUID(WiaImgFmt_AVI,0x32f8ca14,0x087c,0x4908,0xb7,0xc4,0x67,0x57,0xfe,0x7e,0x90,0xab);
37DEFINE_GUID(WiaImgFmt_ASF,0x8d948ee9,0xd0aa,0x4a12,0x9d,0x9a,0x9c,0xc5,0xde,0x36,0x19,0x9b);
38DEFINE_GUID(WiaImgFmt_SCRIPT,0xfe7d6c53,0x2dac,0x446a,0xb0,0xbd,0xd7,0x3e,0x21,0xe9,0x24,0xc9);
39DEFINE_GUID(WiaImgFmt_EXEC,0x485da097,0x141e,0x4aa5,0xbb,0x3b,0xa5,0x61,0x8d,0x95,0xd0,0x2b);
40DEFINE_GUID(WiaImgFmt_UNICODE16,0x1b7639b6,0x6357,0x47d1,0x9a,0x07,0x12,0x45,0x2d,0xc0,0x73,0xe9);
41DEFINE_GUID(WiaImgFmt_DPOF,0x369eeeab,0xa0e8,0x45ca,0x86,0xa6,0xa8,0x3c,0xe5,0x69,0x7e,0x28);
42
43// Audio types
44DEFINE_GUID(WiaAudFmt_WAV,0xf818e146,0x07af,0x40ff,0xae,0x55,0xbe,0x8f,0x2c,0x06,0x5d,0xbe);
45DEFINE_GUID(WiaAudFmt_MP3,0x0fbc71fb,0x43bf,0x49f2,0x91,0x90,0xe6,0xfe,0xcf,0xf3,0x7e,0x54);
46DEFINE_GUID(WiaAudFmt_AIFF,0x66e2bf4f,0xb6fc,0x443f,0x94,0xc8,0x2f,0x33,0xc8,0xa6,0x5a,0xaf);
47DEFINE_GUID(WiaAudFmt_WMA,0xd61d6413,0x8bc2,0x438f,0x93,0xad,0x21,0xbd,0x48,0x4d,0xb6,0xa1);
48
49// Event GUIDs
50DEFINE_GUID(WIA_EVENT_DEVICE_DISCONNECTED,0x143e4e83,0x6497,0x11d2,0xa2,0x31,0x00,0xc0,0x4f,0xa3,0x18,0x09);
51DEFINE_GUID(WIA_EVENT_DEVICE_CONNECTED,0xa28bbade,0x64b6,0x11d2,0xa2,0x31,0x00,0xc0,0x4f,0xa3,0x18,0x09);
52DEFINE_GUID(WIA_EVENT_ITEM_DELETED,0x1d22a559,0xe14f,0x11d2,0xb3,0x26,0x00,0xc0,0x4f,0x68,0xce,0x61);
53DEFINE_GUID(WIA_EVENT_ITEM_CREATED,0x4c8f4ef5,0xe14f,0x11d2,0xb3,0x26,0x00,0xc0,0x4f,0x68,0xce,0x61);
54DEFINE_GUID(WIA_EVENT_TREE_UPDATED,0xc9859b91,0x4ab2,0x4cd6,0xa1,0xfc,0x58,0x2e,0xec,0x55,0xe5,0x85);
55DEFINE_GUID(WIA_EVENT_VOLUME_INSERT,0x9638bbfd,0xd1bd,0x11d2,0xb3,0x1f,0x00,0xc0,0x4f,0x68,0xce,0x61);
56DEFINE_GUID(WIA_EVENT_SCAN_IMAGE,0xa6c5a715,0x8c6e,0x11d2,0x97,0x7a,0x00,0x00,0xf8,0x7a,0x92,0x6f);
57DEFINE_GUID(WIA_EVENT_SCAN_PRINT_IMAGE,0xb441f425,0x8c6e,0x11d2,0x97,0x7a,0x00,0x00,0xf8,0x7a,0x92,0x6f);
58DEFINE_GUID(WIA_EVENT_SCAN_FAX_IMAGE,0xc00eb793,0x8c6e,0x11d2,0x97,0x7a,0x00,0x00,0xf8,0x7a,0x92,0x6f);
59DEFINE_GUID(WIA_EVENT_SCAN_OCR_IMAGE,0x9d095b89,0x37d6,0x4877,0xaf,0xed,0x62,0xa2,0x97,0xdc,0x6d,0xbe);
60DEFINE_GUID(WIA_EVENT_SCAN_EMAIL_IMAGE,0xc686dcee,0x54f2,0x419e,0x9a,0x27,0x2f,0xc7,0xf2,0xe9,0x8f,0x9e);
61DEFINE_GUID(WIA_EVENT_SCAN_FILM_IMAGE,0x9b2b662c,0x6185,0x438c,0xb6,0x8b,0xe3,0x9e,0xe2,0x5e,0x71,0xcb);
62DEFINE_GUID(WIA_EVENT_SCAN_IMAGE2,0xfc4767c1,0xc8b3,0x48a2,0x9c,0xfa,0x2e,0x90,0xcb,0x3d,0x35,0x90);
63DEFINE_GUID(WIA_EVENT_SCAN_IMAGE3,0x154e27be,0xb617,0x4653,0xac,0xc5,0x0f,0xd7,0xbd,0x4c,0x65,0xce);
64DEFINE_GUID(WIA_EVENT_SCAN_IMAGE4,0xa65b704a,0x7f3c,0x4447,0xa7,0x5d,0x8a,0x26,0xdf,0xca,0x1f,0xdf);
65DEFINE_GUID(WIA_EVENT_STORAGE_CREATED,0x353308b2,0xfe73,0x46c8,0x89,0x5e,0xfa,0x45,0x51,0xcc,0xc8,0x5a);
66DEFINE_GUID(WIA_EVENT_STORAGE_DELETED,0x5e41e75e,0x9390,0x44c5,0x9a,0x51,0xe4,0x70,0x19,0xe3,0x90,0xcf);
67DEFINE_GUID(WIA_EVENT_STI_PROXY,0xd711f81f,0x1f0d,0x422d,0x86,0x41,0x92,0x7d,0x1b,0x93,0xe5,0xe5);
68DEFINE_GUID(WIA_EVENT_CANCEL_IO,0xc860f7b8,0x9ccd,0x41ea,0xbb,0xbf,0x4d,0xd0,0x9c,0x5b,0x17,0x95);
69
70// Power management event GUIDs,sent by the WIA service to drivers
71DEFINE_GUID(WIA_EVENT_POWER_SUSPEND,0xa0922ff9,0xc3b4,0x411c,0x9e,0x29,0x03,0xa6,0x69,0x93,0xd2,0xbe);
72DEFINE_GUID(WIA_EVENT_POWER_RESUME,0x618f153e,0xf686,0x4350,0x96,0x34,0x41,0x15,0xa3,0x04,0x83,0x0c);
73
74// No action handler and prompt handler
75DEFINE_GUID(WIA_EVENT_HANDLER_NO_ACTION,0xe0372b7d,0xe115,0x4525,0xbc,0x55,0xb6,0x29,0xe6,0x8c,0x74,0x5a);
76DEFINE_GUID(WIA_EVENT_HANDLER_PROMPT,0x5f4baad0,0x4d59,0x4fcd,0xb2,0x13,0x78,0x3c,0xe7,0xa9,0x2f,0x22);
77
78// WIA Commands
79DEFINE_GUID(WIA_CMD_SYNCHRONIZE,0x9b26b7b2,0xacad,0x11d2,0xa0,0x93,0x00,0xc0,0x4f,0x72,0xdc,0x3c);
80DEFINE_GUID(WIA_CMD_TAKE_PICTURE,0xaf933cac,0xacad,0x11d2,0xa0,0x93,0x00,0xc0,0x4f,0x72,0xdc,0x3c);
81DEFINE_GUID(WIA_CMD_DELETE_ALL_ITEMS,0xe208c170,0xacad,0x11d2,0xa0,0x93,0x00,0xc0,0x4f,0x72,0xdc,0x3c);
82DEFINE_GUID(WIA_CMD_CHANGE_DOCUMENT,0x04e725b0,0xacae,0x11d2,0xa0,0x93,0x00,0xc0,0x4f,0x72,0xdc,0x3c);
83DEFINE_GUID(WIA_CMD_UNLOAD_DOCUMENT,0x1f3b3d8e,0xacae,0x11d2,0xa0,0x93,0x00,0xc0,0x4f,0x72,0xdc,0x3c);
84DEFINE_GUID(WIA_CMD_DIAGNOSTIC,0x10ff52f5,0xde04,0x4cf0,0xa5,0xad,0x69,0x1f,0x8d,0xce,0x01,0x41);
85
86DEFINE_GUID(WIA_CMD_DELETE_DEVICE_TREE,0x73815942,0xdbea,0x11d2,0x84,0x16,0x00,0xc0,0x4f,0xa3,0x61,0x45);
87DEFINE_GUID(WIA_CMD_BUILD_DEVICE_TREE,0x9cba5ce0,0xdbea,0x11d2,0x84,0x16,0x00,0xc0,0x4f,0xa3,0x61,0x45);
88
89DEFINE_GUID(IID_IWiaUIExtension,0xDA319113,0x50EE,0x4C80,0xB4,0x60,0x57,0xD0,0x05,0xD4,0x4A,0x2C);
90
91DEFINE_GUID(IID_IWiaDevMgr,0x5eb2502a,0x8cf1,0x11d1,0xbf,0x92,0x00,0x60,0x08,0x1e,0xd8,0x11);
92DEFINE_GUID(IID_IEnumWIA_DEV_INFO,0x5e38b83c,0x8cf1,0x11d1,0xbf,0x92,0x00,0x60,0x08,0x1e,0xd8,0x11);
93DEFINE_GUID(IID_IWiaEventCallback,0xae6287b0,0x0084,0x11d2,0x97,0x3b,0x00,0xa0,0xc9,0x06,0x8f,0x2e);
94DEFINE_GUID(IID_IWiaDataCallback,0xa558a866,0xa5b0,0x11d2,0xa0,0x8f,0x00,0xc0,0x4f,0x72,0xdc,0x3c);
95DEFINE_GUID(IID_IWiaDataTransfer,0xa6cef998,0xa5b0,0x11d2,0xa0,0x8f,0x00,0xc0,0x4f,0x72,0xdc,0x3c);
96DEFINE_GUID(IID_IWiaItem,0x4db1ad10,0x3391,0x11d2,0x9a,0x33,0x00,0xc0,0x4f,0xa3,0x61,0x45);
97DEFINE_GUID(IID_IWiaPropertyStorage,0x98B5E8A0,0x29CC,0x491a,0xAA,0xC0,0xE6,0xDB,0x4F,0xDC,0xCE,0xB6);
98DEFINE_GUID(IID_IEnumWiaItem,0x5e8383fc,0x3391,0x11d2,0x9a,0x33,0x00,0xc0,0x4f,0xa3,0x61,0x45);
99DEFINE_GUID(IID_IEnumWIA_DEV_CAPS,0x1fcc4287,0xaca6,0x11d2,0xa0,0x93,0x00,0xc0,0x4f,0x72,0xdc,0x3c);
100DEFINE_GUID(IID_IEnumWIA_FORMAT_INFO,0x81BEFC5B,0x656D,0x44f1,0xB2,0x4C,0xD4,0x1D,0x51,0xB4,0xDC,0x81);
101DEFINE_GUID(IID_IWiaLog,0xA00C10B6,0x82A1,0x452f,0x8B,0x6C,0x86,0x06,0x2A,0xAD,0x68,0x90);
102DEFINE_GUID(IID_IWiaLogEx,0xAF1F22AC,0x7A40,0x4787,0xB4,0x21,0xAE,0xb4,0x7A,0x1F,0xBD,0x0B);
103DEFINE_GUID(IID_IWiaNotifyDevMgr,0x70681EA0,0xE7BF,0x4291,0x9F,0xB1,0x4E,0x88,0x13,0xA3,0xF7,0x8E);
104DEFINE_GUID(IID_IWiaItemExtras,0x6291ef2c,0x36ef,0x4532,0x87,0x6a,0x8e,0x13,0x25,0x93,0x77,0x8d);
105DEFINE_GUID(CLSID_WiaDevMgr,0xa1f4e726,0x8cf1,0x11d1,0xbf,0x92,0x00,0x60,0x08,0x1e,0xd8,0x11);
106DEFINE_GUID(CLSID_WiaLog,0xA1E75357,0x881A,0x419e,0x83,0xE2,0xBB,0x16,0xDB,0x19,0x7C,0x68);
lib/libc/mingw/misc/___mb_cur_max_func.c created+18
...@@ -0,0 +1,18 @@
1/**
2 * This file has no copyright assigned and is placed in the Public Domain.
3 * This file is part of the mingw-w64 runtime package.
4 * No warranty is given; refer to the file DISCLAIMER.PD within this package.
5 */
6
7#include <_mingw.h>
8
9extern int* __MINGW_IMP_SYMBOL(__mb_cur_max);
10
11int __cdecl ___mb_cur_max_func(void);
12int __cdecl ___mb_cur_max_func(void)
13{
14 return *__MINGW_IMP_SYMBOL(__mb_cur_max);
15}
16
17typedef int __cdecl (*_f___mb_cur_max_func)(void);
18_f___mb_cur_max_func __MINGW_IMP_SYMBOL(___mb_cur_max_func) = ___mb_cur_max_func;
lib/std/array_list.zig+114-89
...@@ -20,11 +20,9 @@ pub fn AlignedArrayList(comptime T: type, comptime alignment: ?u29) type {...@@ -20,11 +20,9 @@ pub fn AlignedArrayList(comptime T: type, comptime alignment: ?u29) type {
20 return struct {20 return struct {
21 const Self = @This();21 const Self = @This();
2222
23 /// Use `span` instead of slicing this directly, because if you don't23 /// Content of the ArrayList
24 /// specify the end position of the slice, this will potentially give
25 /// you uninitialized memory.
26 items: Slice,24 items: Slice,
27 len: usize,25 capacity: usize,
28 allocator: *Allocator,26 allocator: *Allocator,
2927
30 pub const Slice = if (alignment) |a| ([]align(a) T) else []T;28 pub const Slice = if (alignment) |a| ([]align(a) T) else []T;
...@@ -34,7 +32,7 @@ pub fn AlignedArrayList(comptime T: type, comptime alignment: ?u29) type {...@@ -34,7 +32,7 @@ pub fn AlignedArrayList(comptime T: type, comptime alignment: ?u29) type {
34 pub fn init(allocator: *Allocator) Self {32 pub fn init(allocator: *Allocator) Self {
35 return Self{33 return Self{
36 .items = &[_]T{},34 .items = &[_]T{},
37 .len = 0,35 .capacity = 0,
38 .allocator = allocator,36 .allocator = allocator,
39 };37 };
40 }38 }
...@@ -49,60 +47,55 @@ pub fn AlignedArrayList(comptime T: type, comptime alignment: ?u29) type {...@@ -49,60 +47,55 @@ pub fn AlignedArrayList(comptime T: type, comptime alignment: ?u29) type {
4947
50 /// Release all allocated memory.48 /// Release all allocated memory.
51 pub fn deinit(self: Self) void {49 pub fn deinit(self: Self) void {
52 self.allocator.free(self.items);50 self.allocator.free(self.allocatedSlice());
53 }51 }
5452
53 /// Deprecated: use `items` field directly.
55 /// Return contents as a slice. Only valid while the list54 /// Return contents as a slice. Only valid while the list
56 /// doesn't change size.55 /// doesn't change size.
57 pub fn span(self: var) @TypeOf(self.items[0..self.len]) {56 pub fn span(self: var) @TypeOf(self.items) {
58 return self.items[0..self.len];57 return self.items;
59 }58 }
6059
61 /// Deprecated: use `span`.60 /// Deprecated: use `items` field directly.
62 pub fn toSlice(self: Self) Slice {61 pub fn toSlice(self: Self) Slice {
63 return self.span();62 return self.items;
64 }63 }
6564
66 /// Deprecated: use `span`.65 /// Deprecated: use `items` field directly.
67 pub fn toSliceConst(self: Self) SliceConst {66 pub fn toSliceConst(self: Self) SliceConst {
68 return self.span();67 return self.items;
69 }68 }
7069
71 /// Deprecated: use `span()[i]`.70 /// Deprecated: use `list.items[i]`.
72 pub fn at(self: Self, i: usize) T {71 pub fn at(self: Self, i: usize) T {
73 return self.span()[i];72 return self.items[i];
74 }73 }
7574
76 /// Deprecated: use `&span()[i]`.75 /// Deprecated: use `&list.items[i]`.
77 pub fn ptrAt(self: Self, i: usize) *T {76 pub fn ptrAt(self: Self, i: usize) *T {
78 return &self.span()[i];77 return &self.items[i];
79 }78 }
8079
81 /// Deprecated: use `if (i >= list.len) return error.OutOfBounds else span()[i] = item`.80 /// Deprecated: use `if (i >= list.items.len) return error.OutOfBounds else list.items[i] = item`.
82 pub fn setOrError(self: Self, i: usize, item: T) !void {81 pub fn setOrError(self: Self, i: usize, item: T) !void {
83 if (i >= self.len) return error.OutOfBounds;82 if (i >= self.items.len) return error.OutOfBounds;
84 self.items[i] = item;83 self.items[i] = item;
85 }84 }
8685
87 /// Deprecated: use `list.span()[i] = item`.86 /// Deprecated: use `list.items[i] = item`.
88 pub fn set(self: *Self, i: usize, item: T) void {87 pub fn set(self: *Self, i: usize, item: T) void {
89 assert(i < self.len);88 assert(i < self.items.len);
90 self.items[i] = item;89 self.items[i] = item;
91 }90 }
9291
93 /// Return the maximum number of items the list can hold
94 /// without allocating more memory.
95 pub fn capacity(self: Self) usize {
96 return self.items.len;
97 }
98
99 /// ArrayList takes ownership of the passed in slice. The slice must have been92 /// ArrayList takes ownership of the passed in slice. The slice must have been
100 /// allocated with `allocator`.93 /// allocated with `allocator`.
101 /// Deinitialize with `deinit` or use `toOwnedSlice`.94 /// Deinitialize with `deinit` or use `toOwnedSlice`.
102 pub fn fromOwnedSlice(allocator: *Allocator, slice: Slice) Self {95 pub fn fromOwnedSlice(allocator: *Allocator, slice: Slice) Self {
103 return Self{96 return Self{
104 .items = slice,97 .items = slice,
105 .len = slice.len,98 .capacity = slice.len,
106 .allocator = allocator,99 .allocator = allocator,
107 };100 };
108 }101 }
...@@ -110,7 +103,7 @@ pub fn AlignedArrayList(comptime T: type, comptime alignment: ?u29) type {...@@ -110,7 +103,7 @@ pub fn AlignedArrayList(comptime T: type, comptime alignment: ?u29) type {
110 /// The caller owns the returned memory. ArrayList becomes empty.103 /// The caller owns the returned memory. ArrayList becomes empty.
111 pub fn toOwnedSlice(self: *Self) Slice {104 pub fn toOwnedSlice(self: *Self) Slice {
112 const allocator = self.allocator;105 const allocator = self.allocator;
113 const result = allocator.shrink(self.items, self.len);106 const result = allocator.shrink(self.allocatedSlice(), self.items.len);
114 self.* = init(allocator);107 self.* = init(allocator);
115 return result;108 return result;
116 }109 }
...@@ -118,10 +111,10 @@ pub fn AlignedArrayList(comptime T: type, comptime alignment: ?u29) type {...@@ -118,10 +111,10 @@ pub fn AlignedArrayList(comptime T: type, comptime alignment: ?u29) type {
118 /// Insert `item` at index `n`. Moves `list[n .. list.len]`111 /// Insert `item` at index `n`. Moves `list[n .. list.len]`
119 /// to make room.112 /// to make room.
120 pub fn insert(self: *Self, n: usize, item: T) !void {113 pub fn insert(self: *Self, n: usize, item: T) !void {
121 try self.ensureCapacity(self.len + 1);114 try self.ensureCapacity(self.items.len + 1);
122 self.len += 1;115 self.items.len += 1;
123116
124 mem.copyBackwards(T, self.items[n + 1 .. self.len], self.items[n .. self.len - 1]);117 mem.copyBackwards(T, self.items[n + 1 .. self.items.len], self.items[n .. self.items.len - 1]);
125 self.items[n] = item;118 self.items[n] = item;
126 }119 }
127120
...@@ -129,10 +122,10 @@ pub fn AlignedArrayList(comptime T: type, comptime alignment: ?u29) type {...@@ -129,10 +122,10 @@ pub fn AlignedArrayList(comptime T: type, comptime alignment: ?u29) type {
129 /// `list[i .. list.len]` to make room.122 /// `list[i .. list.len]` to make room.
130 /// This operation is O(N).123 /// This operation is O(N).
131 pub fn insertSlice(self: *Self, i: usize, items: SliceConst) !void {124 pub fn insertSlice(self: *Self, i: usize, items: SliceConst) !void {
132 try self.ensureCapacity(self.len + items.len);125 try self.ensureCapacity(self.items.len + items.len);
133 self.len += items.len;126 self.items.len += items.len;
134127
135 mem.copyBackwards(T, self.items[i + items.len .. self.len], self.items[i .. self.len - items.len]);128 mem.copyBackwards(T, self.items[i + items.len .. self.items.len], self.items[i .. self.items.len - items.len]);
136 mem.copy(T, self.items[i .. i + items.len], items);129 mem.copy(T, self.items[i .. i + items.len], items);
137 }130 }
138131
...@@ -153,13 +146,13 @@ pub fn AlignedArrayList(comptime T: type, comptime alignment: ?u29) type {...@@ -153,13 +146,13 @@ pub fn AlignedArrayList(comptime T: type, comptime alignment: ?u29) type {
153 /// Asserts the array has at least one item.146 /// Asserts the array has at least one item.
154 /// This operation is O(N).147 /// This operation is O(N).
155 pub fn orderedRemove(self: *Self, i: usize) T {148 pub fn orderedRemove(self: *Self, i: usize) T {
156 const newlen = self.len - 1;149 const newlen = self.items.len - 1;
157 if (newlen == i) return self.pop();150 if (newlen == i) return self.pop();
158151
159 const old_item = self.at(i);152 const old_item = self.items[i];
160 for (self.items[i..newlen]) |*b, j| b.* = self.items[i + 1 + j];153 for (self.items[i..newlen]) |*b, j| b.* = self.items[i + 1 + j];
161 self.items[newlen] = undefined;154 self.items[newlen] = undefined;
162 self.len = newlen;155 self.items.len = newlen;
163 return old_item;156 return old_item;
164 }157 }
165158
...@@ -167,26 +160,28 @@ pub fn AlignedArrayList(comptime T: type, comptime alignment: ?u29) type {...@@ -167,26 +160,28 @@ pub fn AlignedArrayList(comptime T: type, comptime alignment: ?u29) type {
167 /// The empty slot is filled from the end of the list.160 /// The empty slot is filled from the end of the list.
168 /// This operation is O(1).161 /// This operation is O(1).
169 pub fn swapRemove(self: *Self, i: usize) T {162 pub fn swapRemove(self: *Self, i: usize) T {
170 if (self.len - 1 == i) return self.pop();163 if (self.items.len - 1 == i) return self.pop();
171164
172 const slice = self.span();165 const old_item = self.items[i];
173 const old_item = slice[i];166 self.items[i] = self.pop();
174 slice[i] = self.pop();
175 return old_item;167 return old_item;
176 }168 }
177169
178 /// Deprecated: use `if (i >= list.len) return error.OutOfBounds else list.swapRemove(i)`.170 /// Deprecated: use `if (i >= list.items.len) return error.OutOfBounds else list.swapRemove(i)`.
179 pub fn swapRemoveOrError(self: *Self, i: usize) !T {171 pub fn swapRemoveOrError(self: *Self, i: usize) !T {
180 if (i >= self.len) return error.OutOfBounds;172 if (i >= self.items.len) return error.OutOfBounds;
181 return self.swapRemove(i);173 return self.swapRemove(i);
182 }174 }
183175
184 /// Append the slice of items to the list. Allocates more176 /// Append the slice of items to the list. Allocates more
185 /// memory as necessary.177 /// memory as necessary.
186 pub fn appendSlice(self: *Self, items: SliceConst) !void {178 pub fn appendSlice(self: *Self, items: SliceConst) !void {
187 try self.ensureCapacity(self.len + items.len);179 const oldlen = self.items.len;
188 mem.copy(T, self.items[self.len..], items);180 const newlen = self.items.len + items.len;
189 self.len += items.len;181
182 try self.ensureCapacity(newlen);
183 self.items.len = newlen;
184 mem.copy(T, self.items[oldlen..], items);
190 }185 }
191186
192 /// Same as `append` except it returns the number of bytes written, which is always the same187 /// Same as `append` except it returns the number of bytes written, which is always the same
...@@ -206,50 +201,58 @@ pub fn AlignedArrayList(comptime T: type, comptime alignment: ?u29) type {...@@ -206,50 +201,58 @@ pub fn AlignedArrayList(comptime T: type, comptime alignment: ?u29) type {
206 /// Append a value to the list `n` times.201 /// Append a value to the list `n` times.
207 /// Allocates more memory as necessary.202 /// Allocates more memory as necessary.
208 pub fn appendNTimes(self: *Self, value: T, n: usize) !void {203 pub fn appendNTimes(self: *Self, value: T, n: usize) !void {
209 const old_len = self.len;204 const old_len = self.items.len;
210 try self.resize(self.len + n);205 try self.resize(self.items.len + n);
211 mem.set(T, self.items[old_len..self.len], value);206 mem.set(T, self.items[old_len..self.items.len], value);
212 }207 }
213208
214 /// Adjust the list's length to `new_len`.209 /// Adjust the list's length to `new_len`.
215 /// Does not initialize added items if any.210 /// Does not initialize added items if any.
216 pub fn resize(self: *Self, new_len: usize) !void {211 pub fn resize(self: *Self, new_len: usize) !void {
217 try self.ensureCapacity(new_len);212 try self.ensureCapacity(new_len);
218 self.len = new_len;213 self.items.len = new_len;
219 }214 }
220215
221 /// Reduce allocated capacity to `new_len`.216 /// Reduce allocated capacity to `new_len`.
222 /// Invalidates element pointers.217 /// Invalidates element pointers.
223 pub fn shrink(self: *Self, new_len: usize) void {218 pub fn shrink(self: *Self, new_len: usize) void {
224 assert(new_len <= self.len);219 assert(new_len <= self.items.len);
225 self.len = new_len;220
226 self.items = self.allocator.realloc(self.items, new_len) catch |e| switch (e) {221 self.items = self.allocator.realloc(self.allocatedSlice(), new_len) catch |e| switch (e) {
227 error.OutOfMemory => return, // no problem, capacity is still correct then.222 error.OutOfMemory => { // no problem, capacity is still correct then.
223 self.items.len = new_len;
224 return;
225 },
228 };226 };
227 self.capacity = new_len;
229 }228 }
230229
231 pub fn ensureCapacity(self: *Self, new_capacity: usize) !void {230 pub fn ensureCapacity(self: *Self, new_capacity: usize) !void {
232 var better_capacity = self.capacity();231 var better_capacity = self.capacity;
233 if (better_capacity >= new_capacity) return;232 if (better_capacity >= new_capacity) return;
233
234 while (true) {234 while (true) {
235 better_capacity += better_capacity / 2 + 8;235 better_capacity += better_capacity / 2 + 8;
236 if (better_capacity >= new_capacity) break;236 if (better_capacity >= new_capacity) break;
237 }237 }
238 self.items = try self.allocator.realloc(self.items, better_capacity);238
239 const new_memory = try self.allocator.realloc(self.allocatedSlice(), better_capacity);
240 self.items.ptr = new_memory.ptr;
241 self.capacity = new_memory.len;
239 }242 }
240243
241 /// Increases the array's length to match the full capacity that is already allocated.244 /// Increases the array's length to match the full capacity that is already allocated.
242 /// The new elements have `undefined` values. This operation does not invalidate any245 /// The new elements have `undefined` values. This operation does not invalidate any
243 /// element pointers.246 /// element pointers.
244 pub fn expandToCapacity(self: *Self) void {247 pub fn expandToCapacity(self: *Self) void {
245 self.len = self.items.len;248 self.items.len = self.capacity;
246 }249 }
247250
248 /// Increase length by 1, returning pointer to the new item.251 /// Increase length by 1, returning pointer to the new item.
249 /// The returned pointer becomes invalid when the list is resized.252 /// The returned pointer becomes invalid when the list is resized.
250 pub fn addOne(self: *Self) !*T {253 pub fn addOne(self: *Self) !*T {
251 const new_length = self.len + 1;254 const newlen = self.items.len + 1;
252 try self.ensureCapacity(new_length);255 try self.ensureCapacity(newlen);
253 return self.addOneAssumeCapacity();256 return self.addOneAssumeCapacity();
254 }257 }
255258
...@@ -257,25 +260,32 @@ pub fn AlignedArrayList(comptime T: type, comptime alignment: ?u29) type {...@@ -257,25 +260,32 @@ pub fn AlignedArrayList(comptime T: type, comptime alignment: ?u29) type {
257 /// Asserts that there is already space for the new item without allocating more.260 /// Asserts that there is already space for the new item without allocating more.
258 /// The returned pointer becomes invalid when the list is resized.261 /// The returned pointer becomes invalid when the list is resized.
259 pub fn addOneAssumeCapacity(self: *Self) *T {262 pub fn addOneAssumeCapacity(self: *Self) *T {
260 assert(self.len < self.capacity());263 assert(self.items.len < self.capacity);
261 const result = &self.items[self.len];264
262 self.len += 1;265 self.items.len += 1;
263 return result;266 return &self.items[self.items.len - 1];
264 }267 }
265268
266 /// Remove and return the last element from the list.269 /// Remove and return the last element from the list.
267 /// Asserts the list has at least one item.270 /// Asserts the list has at least one item.
268 pub fn pop(self: *Self) T {271 pub fn pop(self: *Self) T {
269 self.len -= 1;272 const val = self.items[self.items.len - 1];
270 return self.items[self.len];273 self.items.len -= 1;
274 return val;
271 }275 }
272276
273 /// Remove and return the last element from the list.277 /// Remove and return the last element from the list.
274 /// If the list is empty, returns `null`.278 /// If the list is empty, returns `null`.
275 pub fn popOrNull(self: *Self) ?T {279 pub fn popOrNull(self: *Self) ?T {
276 if (self.len == 0) return null;280 if (self.items.len == 0) return null;
277 return self.pop();281 return self.pop();
278 }282 }
283
284 // For a nicer API, `items.len` is the length, not the capacity.
285 // This requires "unsafe" slicing.
286 fn allocatedSlice(self: Self) Slice {
287 return self.items.ptr[0..self.capacity];
288 }
279 };289 };
280}290}
281291
...@@ -283,15 +293,15 @@ test "std.ArrayList.init" {...@@ -283,15 +293,15 @@ test "std.ArrayList.init" {
283 var list = ArrayList(i32).init(testing.allocator);293 var list = ArrayList(i32).init(testing.allocator);
284 defer list.deinit();294 defer list.deinit();
285295
286 testing.expect(list.len == 0);296 testing.expect(list.items.len == 0);
287 testing.expect(list.capacity() == 0);297 testing.expect(list.capacity == 0);
288}298}
289299
290test "std.ArrayList.initCapacity" {300test "std.ArrayList.initCapacity" {
291 var list = try ArrayList(i8).initCapacity(testing.allocator, 200);301 var list = try ArrayList(i8).initCapacity(testing.allocator, 200);
292 defer list.deinit();302 defer list.deinit();
293 testing.expect(list.len == 0);303 testing.expect(list.items.len == 0);
294 testing.expect(list.capacity() >= 200);304 testing.expect(list.capacity >= 200);
295}305}
296306
297test "std.ArrayList.basic" {307test "std.ArrayList.basic" {
...@@ -315,7 +325,7 @@ test "std.ArrayList.basic" {...@@ -315,7 +325,7 @@ test "std.ArrayList.basic" {
315 }325 }
316 }326 }
317327
318 for (list.span()) |v, i| {328 for (list.items) |v, i| {
319 testing.expect(v == @intCast(i32, i + 1));329 testing.expect(v == @intCast(i32, i + 1));
320 }330 }
321331
...@@ -324,19 +334,19 @@ test "std.ArrayList.basic" {...@@ -324,19 +334,19 @@ test "std.ArrayList.basic" {
324 }334 }
325335
326 testing.expect(list.pop() == 10);336 testing.expect(list.pop() == 10);
327 testing.expect(list.len == 9);337 testing.expect(list.items.len == 9);
328338
329 list.appendSlice(&[_]i32{ 1, 2, 3 }) catch unreachable;339 list.appendSlice(&[_]i32{ 1, 2, 3 }) catch unreachable;
330 testing.expect(list.len == 12);340 testing.expect(list.items.len == 12);
331 testing.expect(list.pop() == 3);341 testing.expect(list.pop() == 3);
332 testing.expect(list.pop() == 2);342 testing.expect(list.pop() == 2);
333 testing.expect(list.pop() == 1);343 testing.expect(list.pop() == 1);
334 testing.expect(list.len == 9);344 testing.expect(list.items.len == 9);
335345
336 list.appendSlice(&[_]i32{}) catch unreachable;346 list.appendSlice(&[_]i32{}) catch unreachable;
337 testing.expect(list.len == 9);347 testing.expect(list.items.len == 9);
338348
339 // can only set on indices < self.len349 // can only set on indices < self.items.len
340 list.set(7, 33);350 list.set(7, 33);
341 list.set(8, 42);351 list.set(8, 42);
342352
...@@ -352,8 +362,8 @@ test "std.ArrayList.appendNTimes" {...@@ -352,8 +362,8 @@ test "std.ArrayList.appendNTimes" {
352 defer list.deinit();362 defer list.deinit();
353363
354 try list.appendNTimes(2, 10);364 try list.appendNTimes(2, 10);
355 testing.expectEqual(@as(usize, 10), list.len);365 testing.expectEqual(@as(usize, 10), list.items.len);
356 for (list.span()) |element| {366 for (list.items) |element| {
357 testing.expectEqual(@as(i32, 2), element);367 testing.expectEqual(@as(i32, 2), element);
358 }368 }
359}369}
...@@ -378,17 +388,17 @@ test "std.ArrayList.orderedRemove" {...@@ -378,17 +388,17 @@ test "std.ArrayList.orderedRemove" {
378388
379 //remove from middle389 //remove from middle
380 testing.expectEqual(@as(i32, 4), list.orderedRemove(3));390 testing.expectEqual(@as(i32, 4), list.orderedRemove(3));
381 testing.expectEqual(@as(i32, 5), list.at(3));391 testing.expectEqual(@as(i32, 5), list.items[3]);
382 testing.expectEqual(@as(usize, 6), list.len);392 testing.expectEqual(@as(usize, 6), list.items.len);
383393
384 //remove from end394 //remove from end
385 testing.expectEqual(@as(i32, 7), list.orderedRemove(5));395 testing.expectEqual(@as(i32, 7), list.orderedRemove(5));
386 testing.expectEqual(@as(usize, 5), list.len);396 testing.expectEqual(@as(usize, 5), list.items.len);
387397
388 //remove from front398 //remove from front
389 testing.expectEqual(@as(i32, 1), list.orderedRemove(0));399 testing.expectEqual(@as(i32, 1), list.orderedRemove(0));
390 testing.expectEqual(@as(i32, 2), list.at(0));400 testing.expectEqual(@as(i32, 2), list.items[0]);
391 testing.expectEqual(@as(usize, 4), list.len);401 testing.expectEqual(@as(usize, 4), list.items.len);
392}402}
393403
394test "std.ArrayList.swapRemove" {404test "std.ArrayList.swapRemove" {
...@@ -405,17 +415,17 @@ test "std.ArrayList.swapRemove" {...@@ -405,17 +415,17 @@ test "std.ArrayList.swapRemove" {
405415
406 //remove from middle416 //remove from middle
407 testing.expect(list.swapRemove(3) == 4);417 testing.expect(list.swapRemove(3) == 4);
408 testing.expect(list.at(3) == 7);418 testing.expect(list.items[3] == 7);
409 testing.expect(list.len == 6);419 testing.expect(list.items.len == 6);
410420
411 //remove from end421 //remove from end
412 testing.expect(list.swapRemove(5) == 6);422 testing.expect(list.swapRemove(5) == 6);
413 testing.expect(list.len == 5);423 testing.expect(list.items.len == 5);
414424
415 //remove from front425 //remove from front
416 testing.expect(list.swapRemove(0) == 1);426 testing.expect(list.swapRemove(0) == 1);
417 testing.expect(list.at(0) == 5);427 testing.expect(list.items[0] == 5);
418 testing.expect(list.len == 4);428 testing.expect(list.items.len == 4);
419}429}
420430
421test "std.ArrayList.swapRemoveOrError" {431test "std.ArrayList.swapRemoveOrError" {
...@@ -478,7 +488,7 @@ test "std.ArrayList.insertSlice" {...@@ -478,7 +488,7 @@ test "std.ArrayList.insertSlice" {
478488
479 const items = [_]i32{1};489 const items = [_]i32{1};
480 try list.insertSlice(0, items[0..0]);490 try list.insertSlice(0, items[0..0]);
481 testing.expect(list.len == 6);491 testing.expect(list.items.len == 6);
482 testing.expect(list.items[0] == 1);492 testing.expect(list.items[0] == 1);
483}493}
484494
...@@ -504,3 +514,18 @@ test "std.ArrayList(u8) implements outStream" {...@@ -504,3 +514,18 @@ test "std.ArrayList(u8) implements outStream" {
504514
505 testing.expectEqualSlices(u8, "x: 42\ny: 1234\n", buffer.span());515 testing.expectEqualSlices(u8, "x: 42\ny: 1234\n", buffer.span());
506}516}
517
518test "std.ArrayList.shrink still sets length on error.OutOfMemory" {
519 // use an arena allocator to make sure realloc returns error.OutOfMemory
520 var arena = std.heap.ArenaAllocator.init(testing.allocator);
521 defer arena.deinit();
522
523 var list = ArrayList(i32).init(&arena.allocator);
524
525 try list.append(1);
526 try list.append(2);
527 try list.append(3);
528
529 list.shrink(1);
530 testing.expect(list.items.len == 1);
531}
lib/std/array_list_sentineled.zig+8-8
...@@ -82,8 +82,8 @@ pub fn ArrayListSentineled(comptime T: type, comptime sentinel: T) type {...@@ -82,8 +82,8 @@ pub fn ArrayListSentineled(comptime T: type, comptime sentinel: T) type {
82 self.list.deinit();82 self.list.deinit();
83 }83 }
8484
85 pub fn span(self: var) @TypeOf(self.list.items[0 .. self.list.len - 1 :sentinel]) {85 pub fn span(self: var) @TypeOf(self.list.items[0..:sentinel]) {
86 return self.list.span()[0..self.len() :sentinel];86 return self.list.items[0..self.len() :sentinel];
87 }87 }
8888
89 pub fn shrink(self: *Self, new_len: usize) void {89 pub fn shrink(self: *Self, new_len: usize) void {
...@@ -98,16 +98,16 @@ pub fn ArrayListSentineled(comptime T: type, comptime sentinel: T) type {...@@ -98,16 +98,16 @@ pub fn ArrayListSentineled(comptime T: type, comptime sentinel: T) type {
98 }98 }
9999
100 pub fn isNull(self: Self) bool {100 pub fn isNull(self: Self) bool {
101 return self.list.len == 0;101 return self.list.items.len == 0;
102 }102 }
103103
104 pub fn len(self: Self) usize {104 pub fn len(self: Self) usize {
105 return self.list.len - 1;105 return self.list.items.len - 1;
106 }106 }
107107
108 pub fn capacity(self: Self) usize {108 pub fn capacity(self: Self) usize {
109 return if (self.list.items.len > 0)109 return if (self.list.capacity > 0)
110 self.list.items.len - 1110 self.list.capacity - 1
111 else111 else
112 0;112 0;
113 }113 }
...@@ -115,13 +115,13 @@ pub fn ArrayListSentineled(comptime T: type, comptime sentinel: T) type {...@@ -115,13 +115,13 @@ pub fn ArrayListSentineled(comptime T: type, comptime sentinel: T) type {
115 pub fn appendSlice(self: *Self, m: []const T) !void {115 pub fn appendSlice(self: *Self, m: []const T) !void {
116 const old_len = self.len();116 const old_len = self.len();
117 try self.resize(old_len + m.len);117 try self.resize(old_len + m.len);
118 mem.copy(T, self.list.span()[old_len..], m);118 mem.copy(T, self.list.items[old_len..], m);
119 }119 }
120120
121 pub fn append(self: *Self, byte: T) !void {121 pub fn append(self: *Self, byte: T) !void {
122 const old_len = self.len();122 const old_len = self.len();
123 try self.resize(old_len + 1);123 try self.resize(old_len + 1);
124 self.list.span()[old_len] = byte;124 self.list.items[old_len] = byte;
125 }125 }
126126
127 pub fn eql(self: Self, m: []const T) bool {127 pub fn eql(self: Self, m: []const T) bool {
lib/std/atomic/queue.zig+19-1
...@@ -5,6 +5,8 @@ const expect = std.testing.expect;...@@ -5,6 +5,8 @@ const expect = std.testing.expect;
55
6/// Many producer, many consumer, non-allocating, thread-safe.6/// Many producer, many consumer, non-allocating, thread-safe.
7/// Uses a mutex to protect access.7/// Uses a mutex to protect access.
8/// The queue does not manage ownership and the user is responsible to
9/// manage the storage of the nodes.
8pub fn Queue(comptime T: type) type {10pub fn Queue(comptime T: type) type {
9 return struct {11 return struct {
10 head: ?*Node,12 head: ?*Node,
...@@ -14,6 +16,8 @@ pub fn Queue(comptime T: type) type {...@@ -14,6 +16,8 @@ pub fn Queue(comptime T: type) type {
14 pub const Self = @This();16 pub const Self = @This();
15 pub const Node = std.TailQueue(T).Node;17 pub const Node = std.TailQueue(T).Node;
1618
19 /// Initializes a new queue. The queue does not provide a `deinit()`
20 /// function, so the user must take care of cleaning up the queue elements.
17 pub fn init() Self {21 pub fn init() Self {
18 return Self{22 return Self{
19 .head = null,23 .head = null,
...@@ -22,6 +26,8 @@ pub fn Queue(comptime T: type) type {...@@ -22,6 +26,8 @@ pub fn Queue(comptime T: type) type {
22 };26 };
23 }27 }
2428
29 /// Appends `node` to the queue.
30 /// The lifetime of `node` must be longer than lifetime of queue.
25 pub fn put(self: *Self, node: *Node) void {31 pub fn put(self: *Self, node: *Node) void {
26 node.next = null;32 node.next = null;
2733
...@@ -38,6 +44,9 @@ pub fn Queue(comptime T: type) type {...@@ -38,6 +44,9 @@ pub fn Queue(comptime T: type) type {
38 }44 }
39 }45 }
4046
47 /// Gets a previously inserted node or returns `null` if there is none.
48 /// It is safe to `get()` a node from the queue while another thread tries
49 /// to `remove()` the same node at the same time.
41 pub fn get(self: *Self) ?*Node {50 pub fn get(self: *Self) ?*Node {
42 const held = self.mutex.acquire();51 const held = self.mutex.acquire();
43 defer held.release();52 defer held.release();
...@@ -71,7 +80,9 @@ pub fn Queue(comptime T: type) type {...@@ -71,7 +80,9 @@ pub fn Queue(comptime T: type) type {
71 }80 }
72 }81 }
7382
74 /// Thread-safe with get() and remove(). Returns whether node was actually removed.83 /// Removes a node from the queue, returns whether node was actually removed.
84 /// It is safe to `remove()` a node from the queue while another thread tries
85 /// to `get()` the same node at the same time.
75 pub fn remove(self: *Self, node: *Node) bool {86 pub fn remove(self: *Self, node: *Node) bool {
76 const held = self.mutex.acquire();87 const held = self.mutex.acquire();
77 defer held.release();88 defer held.release();
...@@ -95,16 +106,23 @@ pub fn Queue(comptime T: type) type {...@@ -95,16 +106,23 @@ pub fn Queue(comptime T: type) type {
95 return true;106 return true;
96 }107 }
97108
109 /// Returns `true` if the queue is currently empty.
110 /// Note that in a multi-consumer environment a return value of `false`
111 /// does not mean that `get` will yield a non-`null` value!
98 pub fn isEmpty(self: *Self) bool {112 pub fn isEmpty(self: *Self) bool {
99 const held = self.mutex.acquire();113 const held = self.mutex.acquire();
100 defer held.release();114 defer held.release();
101 return self.head == null;115 return self.head == null;
102 }116 }
103117
118 /// Dumps the contents of the queue to `stderr`.
104 pub fn dump(self: *Self) void {119 pub fn dump(self: *Self) void {
105 self.dumpToStream(std.io.getStdErr().outStream()) catch return;120 self.dumpToStream(std.io.getStdErr().outStream()) catch return;
106 }121 }
107122
123 /// Dumps the contents of the queue to `stream`.
124 /// Up to 4 elements from the head are dumped and the tail of the queue is
125 /// dumped as well.
108 pub fn dumpToStream(self: *Self, stream: var) !void {126 pub fn dumpToStream(self: *Self, stream: var) !void {
109 const S = struct {127 const S = struct {
110 fn dumpRecursive(128 fn dumpRecursive(
lib/std/build.zig+2-2
...@@ -1779,7 +1779,7 @@ pub const LibExeObjStep = struct {...@@ -1779,7 +1779,7 @@ pub const LibExeObjStep = struct {
1779 const self = @fieldParentPtr(LibExeObjStep, "step", step);1779 const self = @fieldParentPtr(LibExeObjStep, "step", step);
1780 const builder = self.builder;1780 const builder = self.builder;
17811781
1782 if (self.root_src == null and self.link_objects.len == 0) {1782 if (self.root_src == null and self.link_objects.items.len == 0) {
1783 warn("{}: linker needs 1 or more objects to link\n", .{self.step.name});1783 warn("{}: linker needs 1 or more objects to link\n", .{self.step.name});
1784 return error.NeedAnObject;1784 return error.NeedAnObject;
1785 }1785 }
...@@ -1847,7 +1847,7 @@ pub const LibExeObjStep = struct {...@@ -1847,7 +1847,7 @@ pub const LibExeObjStep = struct {
1847 }1847 }
1848 }1848 }
18491849
1850 if (self.build_options_contents.len > 0) {1850 if (self.build_options_contents.items.len > 0) {
1851 const build_options_file = try fs.path.join(1851 const build_options_file = try fs.path.join(
1852 builder.allocator,1852 builder.allocator,
1853 &[_][]const u8{ builder.cache_root, builder.fmt("{}_build_options.zig", .{self.name}) },1853 &[_][]const u8{ builder.cache_root, builder.fmt("{}_build_options.zig", .{self.name}) },
lib/std/build/emit_raw.zig+1-1
...@@ -94,7 +94,7 @@ const BinaryElfOutput = struct {...@@ -94,7 +94,7 @@ const BinaryElfOutput = struct {
9494
95 sort.sort(*BinaryElfSegment, self.segments.span(), segmentSortCompare);95 sort.sort(*BinaryElfSegment, self.segments.span(), segmentSortCompare);
9696
97 if (self.segments.len > 0) {97 if (self.segments.items.len > 0) {
98 const firstSegment = self.segments.at(0);98 const firstSegment = self.segments.at(0);
99 if (firstSegment.firstSection) |firstSection| {99 if (firstSegment.firstSection) |firstSection| {
100 const diff = firstSection.elfOffset - firstSegment.elfOffset;100 const diff = firstSection.elfOffset - firstSegment.elfOffset;
lib/std/builtin.zig+1-1
...@@ -424,7 +424,7 @@ pub const Version = struct {...@@ -424,7 +424,7 @@ pub const Version = struct {
424 }424 }
425425
426 pub fn parse(text: []const u8) !Version {426 pub fn parse(text: []const u8) !Version {
427 var it = std.mem.separate(text, ".");427 var it = std.mem.split(text, ".");
428 return Version{428 return Version{
429 .major = try std.fmt.parseInt(u32, it.next() orelse return error.InvalidVersion, 10),429 .major = try std.fmt.parseInt(u32, it.next() orelse return error.InvalidVersion, 10),
430 .minor = try std.fmt.parseInt(u32, it.next() orelse "0", 10),430 .minor = try std.fmt.parseInt(u32, it.next() orelse "0", 10),
lib/std/coff.zig+1-1
...@@ -181,7 +181,7 @@ pub const Coff = struct {...@@ -181,7 +181,7 @@ pub const Coff = struct {
181 }181 }
182182
183 pub fn loadSections(self: *Coff) !void {183 pub fn loadSections(self: *Coff) !void {
184 if (self.sections.len == self.coff_header.number_of_sections)184 if (self.sections.items.len == self.coff_header.number_of_sections)
185 return;185 return;
186186
187 try self.sections.ensureCapacity(self.coff_header.number_of_sections);187 try self.sections.ensureCapacity(self.coff_header.number_of_sections);
lib/std/crypto/benchmark.zig+1-1
...@@ -133,7 +133,7 @@ fn printPad(stdout: var, s: []const u8) !void {...@@ -133,7 +133,7 @@ fn printPad(stdout: var, s: []const u8) !void {
133}133}
134134
135pub fn main() !void {135pub fn main() !void {
136 const stdout = &std.io.getStdOut().outStream().stream;136 const stdout = std.io.getStdOut().outStream();
137137
138 var buffer: [1024]u8 = undefined;138 var buffer: [1024]u8 = undefined;
139 var fixed = std.heap.FixedBufferAllocator.init(buffer[0..]);139 var fixed = std.heap.FixedBufferAllocator.init(buffer[0..]);
lib/std/debug.zig+2-2
...@@ -1213,7 +1213,7 @@ pub const DebugInfo = struct {...@@ -1213,7 +1213,7 @@ pub const DebugInfo = struct {
1213 const obj_di = try self.allocator.create(ModuleDebugInfo);1213 const obj_di = try self.allocator.create(ModuleDebugInfo);
1214 errdefer self.allocator.destroy(obj_di);1214 errdefer self.allocator.destroy(obj_di);
12151215
1216 obj_di.* = openCoffDebugInfo(self.allocator, name_buffer[0..:0]) catch |err| switch (err) {1216 obj_di.* = openCoffDebugInfo(self.allocator, name_buffer[0 .. len + 4 :0]) catch |err| switch (err) {
1217 error.FileNotFound => return error.MissingDebugInfo,1217 error.FileNotFound => return error.MissingDebugInfo,
1218 else => return err,1218 else => return err,
1219 };1219 };
...@@ -1478,7 +1478,7 @@ pub const ModuleDebugInfo = switch (builtin.os.tag) {...@@ -1478,7 +1478,7 @@ pub const ModuleDebugInfo = switch (builtin.os.tag) {
14781478
1479 var coff_section: *coff.Section = undefined;1479 var coff_section: *coff.Section = undefined;
1480 const mod_index = for (self.sect_contribs) |sect_contrib| {1480 const mod_index = for (self.sect_contribs) |sect_contrib| {
1481 if (sect_contrib.Section > self.coff.sections.len) continue;1481 if (sect_contrib.Section > self.coff.sections.items.len) continue;
1482 // Remember that SectionContribEntry.Section is 1-based.1482 // Remember that SectionContribEntry.Section is 1-based.
1483 coff_section = &self.coff.sections.span()[sect_contrib.Section - 1];1483 coff_section = &self.coff.sections.span()[sect_contrib.Section - 1];
14841484
lib/std/dwarf.zig+4-4
...@@ -206,7 +206,7 @@ const LineNumberProgram = struct {...@@ -206,7 +206,7 @@ const LineNumberProgram = struct {
206 if (self.target_address >= self.prev_address and self.target_address < self.address) {206 if (self.target_address >= self.prev_address and self.target_address < self.address) {
207 const file_entry = if (self.prev_file == 0) {207 const file_entry = if (self.prev_file == 0) {
208 return error.MissingDebugInfo;208 return error.MissingDebugInfo;
209 } else if (self.prev_file - 1 >= self.file_entries.len) {209 } else if (self.prev_file - 1 >= self.file_entries.items.len) {
210 return error.InvalidDebugInfo;210 return error.InvalidDebugInfo;
211 } else211 } else
212 &self.file_entries.items[self.prev_file - 1];212 &self.file_entries.items[self.prev_file - 1];
...@@ -645,7 +645,7 @@ pub const DwarfInfo = struct {...@@ -645,7 +645,7 @@ pub const DwarfInfo = struct {
645 .offset = abbrev_offset,645 .offset = abbrev_offset,
646 .table = try di.parseAbbrevTable(abbrev_offset),646 .table = try di.parseAbbrevTable(abbrev_offset),
647 });647 });
648 return &di.abbrev_table_list.items[di.abbrev_table_list.len - 1].table;648 return &di.abbrev_table_list.items[di.abbrev_table_list.items.len - 1].table;
649 }649 }
650650
651 fn parseAbbrevTable(di: *DwarfInfo, offset: u64) !AbbrevTable {651 fn parseAbbrevTable(di: *DwarfInfo, offset: u64) !AbbrevTable {
...@@ -665,7 +665,7 @@ pub const DwarfInfo = struct {...@@ -665,7 +665,7 @@ pub const DwarfInfo = struct {
665 .has_children = (try in.readByte()) == CHILDREN_yes,665 .has_children = (try in.readByte()) == CHILDREN_yes,
666 .attrs = ArrayList(AbbrevAttr).init(di.allocator()),666 .attrs = ArrayList(AbbrevAttr).init(di.allocator()),
667 });667 });
668 const attrs = &result.items[result.len - 1].attrs;668 const attrs = &result.items[result.items.len - 1].attrs;
669669
670 while (true) {670 while (true) {
671 const attr_id = try leb.readULEB128(u64, in);671 const attr_id = try leb.readULEB128(u64, in);
...@@ -689,7 +689,7 @@ pub const DwarfInfo = struct {...@@ -689,7 +689,7 @@ pub const DwarfInfo = struct {
689 .has_children = table_entry.has_children,689 .has_children = table_entry.has_children,
690 .attrs = ArrayList(Die.Attr).init(di.allocator()),690 .attrs = ArrayList(Die.Attr).init(di.allocator()),
691 };691 };
692 try result.attrs.resize(table_entry.attrs.len);692 try result.attrs.resize(table_entry.attrs.items.len);
693 for (table_entry.attrs.span()) |attr, i| {693 for (table_entry.attrs.span()) |attr, i| {
694 result.attrs.items[i] = Die.Attr{694 result.attrs.items[i] = Die.Attr{
695 .id = attr.attr_id,695 .id = attr.attr_id,
lib/std/fmt.zig+1-1
...@@ -69,7 +69,7 @@ fn peekIsAlign(comptime fmt: []const u8) bool {...@@ -69,7 +69,7 @@ fn peekIsAlign(comptime fmt: []const u8) bool {
69///69///
70/// If a formatted user type contains a function of the type70/// If a formatted user type contains a function of the type
71/// ```71/// ```
72/// fn format(value: ?, comptime fmt: []const u8, options: std.fmt.FormatOptions, out_stream: var) !void72/// pub fn format(value: ?, comptime fmt: []const u8, options: std.fmt.FormatOptions, out_stream: var) !void
73/// ```73/// ```
74/// with `?` being the type formatted, this function will be called instead of the default implementation.74/// with `?` being the type formatted, this function will be called instead of the default implementation.
75/// This allows user types to be formatted in a logical manner instead of dumping all fields of the type.75/// This allows user types to be formatted in a logical manner instead of dumping all fields of the type.
lib/std/fs.zig+4-4
...@@ -1440,9 +1440,9 @@ pub const Walker = struct {...@@ -1440,9 +1440,9 @@ pub const Walker = struct {
1440 /// a reference to the path.1440 /// a reference to the path.
1441 pub fn next(self: *Walker) !?Entry {1441 pub fn next(self: *Walker) !?Entry {
1442 while (true) {1442 while (true) {
1443 if (self.stack.len == 0) return null;1443 if (self.stack.items.len == 0) return null;
1444 // `top` becomes invalid after appending to `self.stack`.1444 // `top` becomes invalid after appending to `self.stack`.
1445 const top = &self.stack.span()[self.stack.len - 1];1445 const top = &self.stack.span()[self.stack.items.len - 1];
1446 const dirname_len = top.dirname_len;1446 const dirname_len = top.dirname_len;
1447 if (try top.dir_it.next()) |base| {1447 if (try top.dir_it.next()) |base| {
1448 self.name_buffer.shrink(dirname_len);1448 self.name_buffer.shrink(dirname_len);
...@@ -1457,7 +1457,7 @@ pub const Walker = struct {...@@ -1457,7 +1457,7 @@ pub const Walker = struct {
1457 errdefer new_dir.close();1457 errdefer new_dir.close();
1458 try self.stack.append(StackItem{1458 try self.stack.append(StackItem{
1459 .dir_it = new_dir.iterate(),1459 .dir_it = new_dir.iterate(),
1460 .dirname_len = self.name_buffer.len,1460 .dirname_len = self.name_buffer.items.len,
1461 });1461 });
1462 }1462 }
1463 }1463 }
...@@ -1522,7 +1522,7 @@ pub fn openSelfExe() OpenSelfExeError!File {...@@ -1522,7 +1522,7 @@ pub fn openSelfExe() OpenSelfExeError!File {
1522 var buf: [MAX_PATH_BYTES]u8 = undefined;1522 var buf: [MAX_PATH_BYTES]u8 = undefined;
1523 const self_exe_path = try selfExePath(&buf);1523 const self_exe_path = try selfExePath(&buf);
1524 buf[self_exe_path.len] = 0;1524 buf[self_exe_path.len] = 0;
1525 return openFileAbsoluteZ(self_exe_path[0..self_exe_path.len :0].ptr, .{});1525 return openFileAbsoluteZ(buf[0..self_exe_path.len :0].ptr, .{});
1526}1526}
15271527
1528test "openSelfExe" {1528test "openSelfExe" {
lib/std/hash/benchmark.zig+1-3
...@@ -172,9 +172,7 @@ fn mode(comptime x: comptime_int) comptime_int {...@@ -172,9 +172,7 @@ fn mode(comptime x: comptime_int) comptime_int {
172}172}
173173
174pub fn main() !void {174pub fn main() !void {
175 var stdout_file = std.io.getStdOut();175 const stdout = std.io.getStdOut().outStream();
176 var stdout_out_stream = stdout_file.outStream();
177 const stdout = &stdout_out_stream.stream;
178176
179 var buffer: [1024]u8 = undefined;177 var buffer: [1024]u8 = undefined;
180 var fixed = std.heap.FixedBufferAllocator.init(buffer[0..]);178 var fixed = std.heap.FixedBufferAllocator.init(buffer[0..]);
lib/std/http/headers.zig+12-12
...@@ -139,7 +139,7 @@ pub const Headers = struct {...@@ -139,7 +139,7 @@ pub const Headers = struct {
139 pub fn clone(self: Self, allocator: *Allocator) !Self {139 pub fn clone(self: Self, allocator: *Allocator) !Self {
140 var other = Headers.init(allocator);140 var other = Headers.init(allocator);
141 errdefer other.deinit();141 errdefer other.deinit();
142 try other.data.ensureCapacity(self.data.len);142 try other.data.ensureCapacity(self.data.items.len);
143 try other.index.initCapacity(self.index.entries.len);143 try other.index.initCapacity(self.index.entries.len);
144 for (self.data.span()) |entry| {144 for (self.data.span()) |entry| {
145 try other.append(entry.name, entry.value, entry.never_index);145 try other.append(entry.name, entry.value, entry.never_index);
...@@ -152,7 +152,7 @@ pub const Headers = struct {...@@ -152,7 +152,7 @@ pub const Headers = struct {
152 }152 }
153153
154 pub fn append(self: *Self, name: []const u8, value: []const u8, never_index: ?bool) !void {154 pub fn append(self: *Self, name: []const u8, value: []const u8, never_index: ?bool) !void {
155 const n = self.data.len + 1;155 const n = self.data.items.len + 1;
156 try self.data.ensureCapacity(n);156 try self.data.ensureCapacity(n);
157 var entry: HeaderEntry = undefined;157 var entry: HeaderEntry = undefined;
158 if (self.index.get(name)) |kv| {158 if (self.index.get(name)) |kv| {
...@@ -197,7 +197,7 @@ pub const Headers = struct {...@@ -197,7 +197,7 @@ pub const Headers = struct {
197 if (self.index.remove(name)) |kv| {197 if (self.index.remove(name)) |kv| {
198 var dex = &kv.value;198 var dex = &kv.value;
199 // iterate backwards199 // iterate backwards
200 var i = dex.len;200 var i = dex.items.len;
201 while (i > 0) {201 while (i > 0) {
202 i -= 1;202 i -= 1;
203 const data_index = dex.at(i);203 const data_index = dex.at(i);
...@@ -220,18 +220,18 @@ pub const Headers = struct {...@@ -220,18 +220,18 @@ pub const Headers = struct {
220 const removed = self.data.orderedRemove(i);220 const removed = self.data.orderedRemove(i);
221 const kv = self.index.get(removed.name).?;221 const kv = self.index.get(removed.name).?;
222 var dex = &kv.value;222 var dex = &kv.value;
223 if (dex.len == 1) {223 if (dex.items.len == 1) {
224 // was last item; delete the index224 // was last item; delete the index
225 _ = self.index.remove(kv.key);225 _ = self.index.remove(kv.key);
226 dex.deinit();226 dex.deinit();
227 removed.deinit();227 removed.deinit();
228 self.allocator.free(kv.key);228 self.allocator.free(kv.key);
229 } else {229 } else {
230 dex.shrink(dex.len - 1);230 dex.shrink(dex.items.len - 1);
231 removed.deinit();231 removed.deinit();
232 }232 }
233 // if it was the last item; no need to rebuild index233 // if it was the last item; no need to rebuild index
234 if (i != self.data.len) {234 if (i != self.data.items.len) {
235 self.rebuild_index();235 self.rebuild_index();
236 }236 }
237 }237 }
...@@ -242,18 +242,18 @@ pub const Headers = struct {...@@ -242,18 +242,18 @@ pub const Headers = struct {
242 const removed = self.data.swapRemove(i);242 const removed = self.data.swapRemove(i);
243 const kv = self.index.get(removed.name).?;243 const kv = self.index.get(removed.name).?;
244 var dex = &kv.value;244 var dex = &kv.value;
245 if (dex.len == 1) {245 if (dex.items.len == 1) {
246 // was last item; delete the index246 // was last item; delete the index
247 _ = self.index.remove(kv.key);247 _ = self.index.remove(kv.key);
248 dex.deinit();248 dex.deinit();
249 removed.deinit();249 removed.deinit();
250 self.allocator.free(kv.key);250 self.allocator.free(kv.key);
251 } else {251 } else {
252 dex.shrink(dex.len - 1);252 dex.shrink(dex.items.len - 1);
253 removed.deinit();253 removed.deinit();
254 }254 }
255 // if it was the last item; no need to rebuild index255 // if it was the last item; no need to rebuild index
256 if (i != self.data.len) {256 if (i != self.data.items.len) {
257 self.rebuild_index();257 self.rebuild_index();
258 }258 }
259 }259 }
...@@ -277,7 +277,7 @@ pub const Headers = struct {...@@ -277,7 +277,7 @@ pub const Headers = struct {
277 pub fn get(self: Self, allocator: *Allocator, name: []const u8) !?[]const HeaderEntry {277 pub fn get(self: Self, allocator: *Allocator, name: []const u8) !?[]const HeaderEntry {
278 const dex = self.getIndices(name) orelse return null;278 const dex = self.getIndices(name) orelse return null;
279279
280 const buf = try allocator.alloc(HeaderEntry, dex.len);280 const buf = try allocator.alloc(HeaderEntry, dex.items.len);
281 var n: usize = 0;281 var n: usize = 0;
282 for (dex.span()) |idx| {282 for (dex.span()) |idx| {
283 buf[n] = self.data.at(idx);283 buf[n] = self.data.at(idx);
...@@ -301,7 +301,7 @@ pub const Headers = struct {...@@ -301,7 +301,7 @@ pub const Headers = struct {
301301
302 // adapted from mem.join302 // adapted from mem.join
303 const total_len = blk: {303 const total_len = blk: {
304 var sum: usize = dex.len - 1; // space for separator(s)304 var sum: usize = dex.items.len - 1; // space for separator(s)
305 for (dex.span()) |idx|305 for (dex.span()) |idx|
306 sum += self.data.at(idx).value.len;306 sum += self.data.at(idx).value.len;
307 break :blk sum;307 break :blk sum;
...@@ -330,7 +330,7 @@ pub const Headers = struct {...@@ -330,7 +330,7 @@ pub const Headers = struct {
330 var it = self.index.iterator();330 var it = self.index.iterator();
331 while (it.next()) |kv| {331 while (it.next()) |kv| {
332 var dex = &kv.value;332 var dex = &kv.value;
333 dex.len = 0; // keeps capacity available333 dex.items.len = 0; // keeps capacity available
334 }334 }
335 }335 }
336 { // fill up indexes again; we know capacity is fine from before336 { // fill up indexes again; we know capacity is fine from before
lib/std/io/in_stream.zig+2-2
...@@ -54,7 +54,7 @@ pub fn InStream(...@@ -54,7 +54,7 @@ pub fn InStream(
54 /// and the `std.ArrayList` has exactly `max_append_size` bytes appended.54 /// and the `std.ArrayList` has exactly `max_append_size` bytes appended.
55 pub fn readAllArrayList(self: Self, array_list: *std.ArrayList(u8), max_append_size: usize) !void {55 pub fn readAllArrayList(self: Self, array_list: *std.ArrayList(u8), max_append_size: usize) !void {
56 try array_list.ensureCapacity(math.min(max_append_size, 4096));56 try array_list.ensureCapacity(math.min(max_append_size, 4096));
57 const original_len = array_list.len;57 const original_len = array_list.items.len;
58 var start_index: usize = original_len;58 var start_index: usize = original_len;
59 while (true) {59 while (true) {
60 array_list.expandToCapacity();60 array_list.expandToCapacity();
...@@ -106,7 +106,7 @@ pub fn InStream(...@@ -106,7 +106,7 @@ pub fn InStream(
106 return;106 return;
107 }107 }
108108
109 if (array_list.len == max_size) {109 if (array_list.items.len == max_size) {
110 return error.StreamTooLong;110 return error.StreamTooLong;
111 }111 }
112112
lib/std/json.zig+16-15
...@@ -1327,12 +1327,13 @@ test "Value.jsonStringify" {...@@ -1327,12 +1327,13 @@ test "Value.jsonStringify" {
1327 {1327 {
1328 var buffer: [10]u8 = undefined;1328 var buffer: [10]u8 = undefined;
1329 var fbs = std.io.fixedBufferStream(&buffer);1329 var fbs = std.io.fixedBufferStream(&buffer);
1330 var vals = [_]Value{
1331 .{ .Integer = 1 },
1332 .{ .Integer = 2 },
1333 .{ .Integer = 3 },
1334 };
1330 try (Value{1335 try (Value{
1331 .Array = Array.fromOwnedSlice(undefined, &[_]Value{1336 .Array = Array.fromOwnedSlice(undefined, &vals),
1332 .{ .Integer = 1 },
1333 .{ .Integer = 2 },
1334 .{ .Integer = 3 },
1335 }),
1336 }).jsonStringify(.{}, fbs.outStream());1337 }).jsonStringify(.{}, fbs.outStream());
1337 testing.expectEqualSlices(u8, fbs.getWritten(), "[1,2,3]");1338 testing.expectEqualSlices(u8, fbs.getWritten(), "[1,2,3]");
1338 }1339 }
...@@ -1556,7 +1557,7 @@ fn parseInternal(comptime T: type, token: Token, tokens: *TokenStream, options:...@@ -1556,7 +1557,7 @@ fn parseInternal(comptime T: type, token: Token, tokens: *TokenStream, options:
1556 else => {},1557 else => {},
1557 }1558 }
15581559
1559 try arraylist.ensureCapacity(arraylist.len + 1);1560 try arraylist.ensureCapacity(arraylist.items.len + 1);
1560 const v = try parseInternal(ptrInfo.child, tok, tokens, options);1561 const v = try parseInternal(ptrInfo.child, tok, tokens, options);
1561 arraylist.appendAssumeCapacity(v);1562 arraylist.appendAssumeCapacity(v);
1562 }1563 }
...@@ -1874,7 +1875,7 @@ pub const Parser = struct {...@@ -1874,7 +1875,7 @@ pub const Parser = struct {
1874 try p.transition(&arena.allocator, input, s.i - 1, token);1875 try p.transition(&arena.allocator, input, s.i - 1, token);
1875 }1876 }
18761877
1877 debug.assert(p.stack.len == 1);1878 debug.assert(p.stack.items.len == 1);
18781879
1879 return ValueTree{1880 return ValueTree{
1880 .arena = arena,1881 .arena = arena,
...@@ -1888,7 +1889,7 @@ pub const Parser = struct {...@@ -1888,7 +1889,7 @@ pub const Parser = struct {
1888 switch (p.state) {1889 switch (p.state) {
1889 .ObjectKey => switch (token) {1890 .ObjectKey => switch (token) {
1890 .ObjectEnd => {1891 .ObjectEnd => {
1891 if (p.stack.len == 1) {1892 if (p.stack.items.len == 1) {
1892 return;1893 return;
1893 }1894 }
18941895
...@@ -1907,8 +1908,8 @@ pub const Parser = struct {...@@ -1907,8 +1908,8 @@ pub const Parser = struct {
1907 },1908 },
1908 },1909 },
1909 .ObjectValue => {1910 .ObjectValue => {
1910 var object = &p.stack.items[p.stack.len - 2].Object;1911 var object = &p.stack.items[p.stack.items.len - 2].Object;
1911 var key = p.stack.items[p.stack.len - 1].String;1912 var key = p.stack.items[p.stack.items.len - 1].String;
19121913
1913 switch (token) {1914 switch (token) {
1914 .ObjectBegin => {1915 .ObjectBegin => {
...@@ -1950,11 +1951,11 @@ pub const Parser = struct {...@@ -1950,11 +1951,11 @@ pub const Parser = struct {
1950 }1951 }
1951 },1952 },
1952 .ArrayValue => {1953 .ArrayValue => {
1953 var array = &p.stack.items[p.stack.len - 1].Array;1954 var array = &p.stack.items[p.stack.items.len - 1].Array;
19541955
1955 switch (token) {1956 switch (token) {
1956 .ArrayEnd => {1957 .ArrayEnd => {
1957 if (p.stack.len == 1) {1958 if (p.stack.items.len == 1) {
1958 return;1959 return;
1959 }1960 }
19601961
...@@ -2021,12 +2022,12 @@ pub const Parser = struct {...@@ -2021,12 +2022,12 @@ pub const Parser = struct {
2021 }2022 }
20222023
2023 fn pushToParent(p: *Parser, value: *const Value) !void {2024 fn pushToParent(p: *Parser, value: *const Value) !void {
2024 switch (p.stack.span()[p.stack.len - 1]) {2025 switch (p.stack.span()[p.stack.items.len - 1]) {
2025 // Object Parent -> [ ..., object, <key>, value ]2026 // Object Parent -> [ ..., object, <key>, value ]
2026 Value.String => |key| {2027 Value.String => |key| {
2027 _ = p.stack.pop();2028 _ = p.stack.pop();
20282029
2029 var object = &p.stack.items[p.stack.len - 1].Object;2030 var object = &p.stack.items[p.stack.items.len - 1].Object;
2030 _ = try object.put(key, value.*);2031 _ = try object.put(key, value.*);
2031 p.state = .ObjectKey;2032 p.state = .ObjectKey;
2032 },2033 },
...@@ -2165,7 +2166,7 @@ test "json.parser.dynamic" {...@@ -2165,7 +2166,7 @@ test "json.parser.dynamic" {
2165 testing.expect(animated.Bool == false);2166 testing.expect(animated.Bool == false);
21662167
2167 const array_of_object = image.Object.get("ArrayOfObject").?.value;2168 const array_of_object = image.Object.get("ArrayOfObject").?.value;
2168 testing.expect(array_of_object.Array.len == 1);2169 testing.expect(array_of_object.Array.items.len == 1);
21692170
2170 const obj0 = array_of_object.Array.at(0).Object.get("n").?.value;2171 const obj0 = array_of_object.Array.at(0).Object.get("n").?.value;
2171 testing.expect(mem.eql(u8, obj0.String, "m"));2172 testing.expect(mem.eql(u8, obj0.String, "m"));
lib/std/math/big/int.zig+187
...@@ -10,6 +10,7 @@ const minInt = std.math.minInt;...@@ -10,6 +10,7 @@ const minInt = std.math.minInt;
1010
11pub const Limb = usize;11pub const Limb = usize;
12pub const DoubleLimb = std.meta.IntType(false, 2 * Limb.bit_count);12pub const DoubleLimb = std.meta.IntType(false, 2 * Limb.bit_count);
13pub const SignedDoubleLimb = std.meta.IntType(true, DoubleLimb.bit_count);
13pub const Log2Limb = math.Log2Int(Limb);14pub const Log2Limb = math.Log2Int(Limb);
1415
15comptime {16comptime {
...@@ -1359,8 +1360,129 @@ pub const Int = struct {...@@ -1359,8 +1360,129 @@ pub const Int = struct {
1359 r[i] = a[i];1360 r[i] = a[i];
1360 }1361 }
1361 }1362 }
1363
1364 pub fn gcd(rma: *Int, x: Int, y: Int) !void {
1365 rma.assertWritable();
1366 var r = rma;
1367 var aliased = rma.limbs.ptr == x.limbs.ptr or rma.limbs.ptr == y.limbs.ptr;
1368
1369 var sr: Int = undefined;
1370 if (aliased) {
1371 sr = try Int.initCapacity(rma.allocator.?, math.max(x.len(), y.len()));
1372 r = &sr;
1373 aliased = true;
1374 }
1375 defer if (aliased) {
1376 rma.swap(r);
1377 r.deinit();
1378 };
1379
1380 try gcdLehmer(r, x, y);
1381 }
1382
1383 fn gcdLehmer(r: *Int, xa: Int, ya: Int) !void {
1384 var x = try xa.clone();
1385 x.abs();
1386 defer x.deinit();
1387
1388 var y = try ya.clone();
1389 y.abs();
1390 defer y.deinit();
1391
1392 if (x.cmp(y) == .lt) {
1393 x.swap(&y);
1394 }
1395
1396 var T = try Int.init(r.allocator.?);
1397 defer T.deinit();
1398
1399 while (y.len() > 1) {
1400 debug.assert(x.isPositive() and y.isPositive());
1401 debug.assert(x.len() >= y.len());
1402
1403 var xh: SignedDoubleLimb = x.limbs[x.len() - 1];
1404 var yh: SignedDoubleLimb = if (x.len() > y.len()) 0 else y.limbs[x.len() - 1];
1405
1406 var A: SignedDoubleLimb = 1;
1407 var B: SignedDoubleLimb = 0;
1408 var C: SignedDoubleLimb = 0;
1409 var D: SignedDoubleLimb = 1;
1410
1411 while (yh + C != 0 and yh + D != 0) {
1412 const q = @divFloor(xh + A, yh + C);
1413 const qp = @divFloor(xh + B, yh + D);
1414 if (q != qp) {
1415 break;
1416 }
1417
1418 var t = A - q * C;
1419 A = C;
1420 C = t;
1421 t = B - q * D;
1422 B = D;
1423 D = t;
1424
1425 t = xh - q * yh;
1426 xh = yh;
1427 yh = t;
1428 }
1429
1430 if (B == 0) {
1431 // T = x % y, r is unused
1432 try Int.divTrunc(r, &T, x, y);
1433 debug.assert(T.isPositive());
1434
1435 x.swap(&y);
1436 y.swap(&T);
1437 } else {
1438 var storage: [8]Limb = undefined;
1439 const Ap = FixedIntFromSignedDoubleLimb(A, storage[0..2]);
1440 const Bp = FixedIntFromSignedDoubleLimb(B, storage[2..4]);
1441 const Cp = FixedIntFromSignedDoubleLimb(C, storage[4..6]);
1442 const Dp = FixedIntFromSignedDoubleLimb(D, storage[6..8]);
1443
1444 // T = Ax + By
1445 try r.mul(x, Ap);
1446 try T.mul(y, Bp);
1447 try T.add(r.*, T);
1448
1449 // u = Cx + Dy, r as u
1450 try x.mul(x, Cp);
1451 try r.mul(y, Dp);
1452 try r.add(x, r.*);
1453
1454 x.swap(&T);
1455 y.swap(r);
1456 }
1457 }
1458
1459 // euclidean algorithm
1460 debug.assert(x.cmp(y) != .lt);
1461
1462 while (!y.eqZero()) {
1463 try Int.divTrunc(&T, r, x, y);
1464 x.swap(&y);
1465 y.swap(r);
1466 }
1467
1468 r.swap(&x);
1469 }
1470
1362};1471};
13631472
1473// Storage must live for the lifetime of the returned value
1474fn FixedIntFromSignedDoubleLimb(A: SignedDoubleLimb, storage: []Limb) Int {
1475 std.debug.assert(storage.len >= 2);
1476
1477 var A_is_positive = A >= 0;
1478 const Au = @intCast(DoubleLimb, if (A < 0) -A else A);
1479 storage[0] = @truncate(Limb, Au);
1480 storage[1] = @truncate(Limb, Au >> Limb.bit_count);
1481 var Ap = Int.initFixed(storage[0..2]);
1482 Ap.setSign(A_is_positive);
1483 return Ap;
1484}
1485
1364// NOTE: All the following tests assume the max machine-word will be 64-bit.1486// NOTE: All the following tests assume the max machine-word will be 64-bit.
1365//1487//
1366// They will still run on larger than this and should pass, but the multi-limb code-paths1488// They will still run on larger than this and should pass, but the multi-limb code-paths
...@@ -2738,3 +2860,68 @@ test "big.int var args" {...@@ -2738,3 +2860,68 @@ test "big.int var args" {
2738 defer d.deinit();2860 defer d.deinit();
2739 testing.expect(a.cmp(d) != .gt);2861 testing.expect(a.cmp(d) != .gt);
2740}2862}
2863
2864test "big.int gcd non-one small" {
2865 var a = try Int.initSet(testing.allocator, 17);
2866 defer a.deinit();
2867 var b = try Int.initSet(testing.allocator, 97);
2868 defer b.deinit();
2869 var r = try Int.init(testing.allocator);
2870 defer r.deinit();
2871
2872 try r.gcd(a, b);
2873
2874 testing.expect((try r.to(u32)) == 1);
2875}
2876
2877test "big.int gcd non-one small" {
2878 var a = try Int.initSet(testing.allocator, 4864);
2879 defer a.deinit();
2880 var b = try Int.initSet(testing.allocator, 3458);
2881 defer b.deinit();
2882 var r = try Int.init(testing.allocator);
2883 defer r.deinit();
2884
2885 try r.gcd(a, b);
2886
2887 testing.expect((try r.to(u32)) == 38);
2888}
2889
2890test "big.int gcd non-one large" {
2891 var a = try Int.initSet(testing.allocator, 0xffffffffffffffff);
2892 defer a.deinit();
2893 var b = try Int.initSet(testing.allocator, 0xffffffffffffffff7777);
2894 defer b.deinit();
2895 var r = try Int.init(testing.allocator);
2896 defer r.deinit();
2897
2898 try r.gcd(a, b);
2899
2900 testing.expect((try r.to(u32)) == 4369);
2901}
2902
2903test "big.int gcd large multi-limb result" {
2904 var a = try Int.initSet(testing.allocator, 0x12345678123456781234567812345678123456781234567812345678);
2905 defer a.deinit();
2906 var b = try Int.initSet(testing.allocator, 0x12345671234567123456712345671234567123456712345671234567);
2907 defer b.deinit();
2908 var r = try Int.init(testing.allocator);
2909 defer r.deinit();
2910
2911 try r.gcd(a, b);
2912
2913 testing.expect((try r.to(u256)) == 0xf000000ff00000fff0000ffff000fffff00ffffff1);
2914}
2915
2916test "big.int gcd one large" {
2917 var a = try Int.initSet(testing.allocator, 1897056385327307);
2918 defer a.deinit();
2919 var b = try Int.initSet(testing.allocator, 2251799813685248);
2920 defer b.deinit();
2921 var r = try Int.init(testing.allocator);
2922 defer r.deinit();
2923
2924 try r.gcd(a, b);
2925
2926 testing.expect((try r.to(u64)) == 1);
2927}
lib/std/math/big/rational.zig+1-189
...@@ -4,7 +4,6 @@ const math = std.math;...@@ -4,7 +4,6 @@ const math = std.math;
4const mem = std.mem;4const mem = std.mem;
5const testing = std.testing;5const testing = std.testing;
6const Allocator = mem.Allocator;6const Allocator = mem.Allocator;
7const ArrayList = std.ArrayList;
87
9const bn = @import("int.zig");8const bn = @import("int.zig");
10const Limb = bn.Limb;9const Limb = bn.Limb;
...@@ -448,7 +447,7 @@ pub const Rational = struct {...@@ -448,7 +447,7 @@ pub const Rational = struct {
448447
449 const sign = r.p.isPositive();448 const sign = r.p.isPositive();
450 r.p.abs();449 r.p.abs();
451 try gcd(&a, r.p, r.q);450 try a.gcd(r.p, r.q);
452 r.p.setSign(sign);451 r.p.setSign(sign);
453452
454 const one = Int.initFixed(([_]Limb{1})[0..]);453 const one = Int.initFixed(([_]Limb{1})[0..]);
...@@ -464,193 +463,6 @@ pub const Rational = struct {...@@ -464,193 +463,6 @@ pub const Rational = struct {
464 }463 }
465};464};
466465
467const SignedDoubleLimb = std.meta.IntType(true, DoubleLimb.bit_count);
468
469fn gcd(rma: *Int, x: Int, y: Int) !void {
470 rma.assertWritable();
471 var r = rma;
472 var aliased = rma.limbs.ptr == x.limbs.ptr or rma.limbs.ptr == y.limbs.ptr;
473
474 var sr: Int = undefined;
475 if (aliased) {
476 sr = try Int.initCapacity(rma.allocator.?, math.max(x.len(), y.len()));
477 r = &sr;
478 aliased = true;
479 }
480 defer if (aliased) {
481 rma.swap(r);
482 r.deinit();
483 };
484
485 try gcdLehmer(r, x, y);
486}
487
488// Storage must live for the lifetime of the returned value
489fn FixedIntFromSignedDoubleLimb(A: SignedDoubleLimb, storage: []Limb) Int {
490 std.debug.assert(storage.len >= 2);
491
492 var A_is_positive = A >= 0;
493 const Au = @intCast(DoubleLimb, if (A < 0) -A else A);
494 storage[0] = @truncate(Limb, Au);
495 storage[1] = @truncate(Limb, Au >> Limb.bit_count);
496 var Ap = Int.initFixed(storage[0..2]);
497 Ap.setSign(A_is_positive);
498 return Ap;
499}
500
501fn gcdLehmer(r: *Int, xa: Int, ya: Int) !void {
502 var x = try xa.clone();
503 x.abs();
504 defer x.deinit();
505
506 var y = try ya.clone();
507 y.abs();
508 defer y.deinit();
509
510 if (x.cmp(y) == .lt) {
511 x.swap(&y);
512 }
513
514 var T = try Int.init(r.allocator.?);
515 defer T.deinit();
516
517 while (y.len() > 1) {
518 debug.assert(x.isPositive() and y.isPositive());
519 debug.assert(x.len() >= y.len());
520
521 var xh: SignedDoubleLimb = x.limbs[x.len() - 1];
522 var yh: SignedDoubleLimb = if (x.len() > y.len()) 0 else y.limbs[x.len() - 1];
523
524 var A: SignedDoubleLimb = 1;
525 var B: SignedDoubleLimb = 0;
526 var C: SignedDoubleLimb = 0;
527 var D: SignedDoubleLimb = 1;
528
529 while (yh + C != 0 and yh + D != 0) {
530 const q = @divFloor(xh + A, yh + C);
531 const qp = @divFloor(xh + B, yh + D);
532 if (q != qp) {
533 break;
534 }
535
536 var t = A - q * C;
537 A = C;
538 C = t;
539 t = B - q * D;
540 B = D;
541 D = t;
542
543 t = xh - q * yh;
544 xh = yh;
545 yh = t;
546 }
547
548 if (B == 0) {
549 // T = x % y, r is unused
550 try Int.divTrunc(r, &T, x, y);
551 debug.assert(T.isPositive());
552
553 x.swap(&y);
554 y.swap(&T);
555 } else {
556 var storage: [8]Limb = undefined;
557 const Ap = FixedIntFromSignedDoubleLimb(A, storage[0..2]);
558 const Bp = FixedIntFromSignedDoubleLimb(B, storage[2..4]);
559 const Cp = FixedIntFromSignedDoubleLimb(C, storage[4..6]);
560 const Dp = FixedIntFromSignedDoubleLimb(D, storage[6..8]);
561
562 // T = Ax + By
563 try r.mul(x, Ap);
564 try T.mul(y, Bp);
565 try T.add(r.*, T);
566
567 // u = Cx + Dy, r as u
568 try x.mul(x, Cp);
569 try r.mul(y, Dp);
570 try r.add(x, r.*);
571
572 x.swap(&T);
573 y.swap(r);
574 }
575 }
576
577 // euclidean algorithm
578 debug.assert(x.cmp(y) != .lt);
579
580 while (!y.eqZero()) {
581 try Int.divTrunc(&T, r, x, y);
582 x.swap(&y);
583 y.swap(r);
584 }
585
586 r.swap(&x);
587}
588
589test "big.rational gcd non-one small" {
590 var a = try Int.initSet(testing.allocator, 17);
591 defer a.deinit();
592 var b = try Int.initSet(testing.allocator, 97);
593 defer b.deinit();
594 var r = try Int.init(testing.allocator);
595 defer r.deinit();
596
597 try gcd(&r, a, b);
598
599 testing.expect((try r.to(u32)) == 1);
600}
601
602test "big.rational gcd non-one small" {
603 var a = try Int.initSet(testing.allocator, 4864);
604 defer a.deinit();
605 var b = try Int.initSet(testing.allocator, 3458);
606 defer b.deinit();
607 var r = try Int.init(testing.allocator);
608 defer r.deinit();
609
610 try gcd(&r, a, b);
611
612 testing.expect((try r.to(u32)) == 38);
613}
614
615test "big.rational gcd non-one large" {
616 var a = try Int.initSet(testing.allocator, 0xffffffffffffffff);
617 defer a.deinit();
618 var b = try Int.initSet(testing.allocator, 0xffffffffffffffff7777);
619 defer b.deinit();
620 var r = try Int.init(testing.allocator);
621 defer r.deinit();
622
623 try gcd(&r, a, b);
624
625 testing.expect((try r.to(u32)) == 4369);
626}
627
628test "big.rational gcd large multi-limb result" {
629 var a = try Int.initSet(testing.allocator, 0x12345678123456781234567812345678123456781234567812345678);
630 defer a.deinit();
631 var b = try Int.initSet(testing.allocator, 0x12345671234567123456712345671234567123456712345671234567);
632 defer b.deinit();
633 var r = try Int.init(testing.allocator);
634 defer r.deinit();
635
636 try gcd(&r, a, b);
637
638 testing.expect((try r.to(u256)) == 0xf000000ff00000fff0000ffff000fffff00ffffff1);
639}
640
641test "big.rational gcd one large" {
642 var a = try Int.initSet(testing.allocator, 1897056385327307);
643 defer a.deinit();
644 var b = try Int.initSet(testing.allocator, 2251799813685248);
645 defer b.deinit();
646 var r = try Int.init(testing.allocator);
647 defer r.deinit();
648
649 try gcd(&r, a, b);
650
651 testing.expect((try r.to(u64)) == 1);
652}
653
654fn extractLowBits(a: Int, comptime T: type) T {466fn extractLowBits(a: Int, comptime T: type) T {
655 testing.expect(@typeInfo(T) == .Int);467 testing.expect(@typeInfo(T) == .Int);
656468
lib/std/mem.zig+15-14
...@@ -501,7 +501,7 @@ pub const toSlice = @compileError("deprecated; use std.mem.spanZ");...@@ -501,7 +501,7 @@ pub const toSlice = @compileError("deprecated; use std.mem.spanZ");
501/// the constness of the input type. `[*c]` pointers are assumed to be 0-terminated,501/// the constness of the input type. `[*c]` pointers are assumed to be 0-terminated,
502/// and assumed to not allow null.502/// and assumed to not allow null.
503pub fn Span(comptime T: type) type {503pub fn Span(comptime T: type) type {
504 switch(@typeInfo(T)) {504 switch (@typeInfo(T)) {
505 .Optional => |optional_info| {505 .Optional => |optional_info| {
506 return ?Span(optional_info.child);506 return ?Span(optional_info.child);
507 },507 },
...@@ -1141,7 +1141,7 @@ test "writeIntBig and writeIntLittle" {...@@ -1141,7 +1141,7 @@ test "writeIntBig and writeIntLittle" {
1141/// If `buffer` is empty, the iterator will return null.1141/// If `buffer` is empty, the iterator will return null.
1142/// If `delimiter_bytes` does not exist in buffer,1142/// If `delimiter_bytes` does not exist in buffer,
1143/// the iterator will return `buffer`, null, in that order.1143/// the iterator will return `buffer`, null, in that order.
1144/// See also the related function `separate`.1144/// See also the related function `split`.
1145pub fn tokenize(buffer: []const u8, delimiter_bytes: []const u8) TokenIterator {1145pub fn tokenize(buffer: []const u8, delimiter_bytes: []const u8) TokenIterator {
1146 return TokenIterator{1146 return TokenIterator{
1147 .index = 0,1147 .index = 0,
...@@ -1196,15 +1196,13 @@ test "mem.tokenize (multibyte)" {...@@ -1196,15 +1196,13 @@ test "mem.tokenize (multibyte)" {
11961196
1197/// Returns an iterator that iterates over the slices of `buffer` that1197/// Returns an iterator that iterates over the slices of `buffer` that
1198/// are separated by bytes in `delimiter`.1198/// are separated by bytes in `delimiter`.
1199/// separate("abc|def||ghi", "|")1199/// split("abc|def||ghi", "|")
1200/// will return slices for "abc", "def", "", "ghi", null, in that order.1200/// will return slices for "abc", "def", "", "ghi", null, in that order.
1201/// If `delimiter` does not exist in buffer,1201/// If `delimiter` does not exist in buffer,
1202/// the iterator will return `buffer`, null, in that order.1202/// the iterator will return `buffer`, null, in that order.
1203/// The delimiter length must not be zero.1203/// The delimiter length must not be zero.
1204/// See also the related function `tokenize`.1204/// See also the related function `tokenize`.
1205/// It is planned to rename this function to `split` before 1.0.0, like this:1205pub fn split(buffer: []const u8, delimiter: []const u8) SplitIterator {
1206/// pub fn split(buffer: []const u8, delimiter: []const u8) SplitIterator {
1207pub fn separate(buffer: []const u8, delimiter: []const u8) SplitIterator {
1208 assert(delimiter.len != 0);1206 assert(delimiter.len != 0);
1209 return SplitIterator{1207 return SplitIterator{
1210 .index = 0,1208 .index = 0,
...@@ -1213,30 +1211,32 @@ pub fn separate(buffer: []const u8, delimiter: []const u8) SplitIterator {...@@ -1213,30 +1211,32 @@ pub fn separate(buffer: []const u8, delimiter: []const u8) SplitIterator {
1213 };1211 };
1214}1212}
12151213
1216test "mem.separate" {1214pub const separate = @compileError("deprecated: renamed to split (behavior remains unchanged)");
1217 var it = separate("abc|def||ghi", "|");1215
1216test "mem.split" {
1217 var it = split("abc|def||ghi", "|");
1218 testing.expect(eql(u8, it.next().?, "abc"));1218 testing.expect(eql(u8, it.next().?, "abc"));
1219 testing.expect(eql(u8, it.next().?, "def"));1219 testing.expect(eql(u8, it.next().?, "def"));
1220 testing.expect(eql(u8, it.next().?, ""));1220 testing.expect(eql(u8, it.next().?, ""));
1221 testing.expect(eql(u8, it.next().?, "ghi"));1221 testing.expect(eql(u8, it.next().?, "ghi"));
1222 testing.expect(it.next() == null);1222 testing.expect(it.next() == null);
12231223
1224 it = separate("", "|");1224 it = split("", "|");
1225 testing.expect(eql(u8, it.next().?, ""));1225 testing.expect(eql(u8, it.next().?, ""));
1226 testing.expect(it.next() == null);1226 testing.expect(it.next() == null);
12271227
1228 it = separate("|", "|");1228 it = split("|", "|");
1229 testing.expect(eql(u8, it.next().?, ""));1229 testing.expect(eql(u8, it.next().?, ""));
1230 testing.expect(eql(u8, it.next().?, ""));1230 testing.expect(eql(u8, it.next().?, ""));
1231 testing.expect(it.next() == null);1231 testing.expect(it.next() == null);
12321232
1233 it = separate("hello", " ");1233 it = split("hello", " ");
1234 testing.expect(eql(u8, it.next().?, "hello"));1234 testing.expect(eql(u8, it.next().?, "hello"));
1235 testing.expect(it.next() == null);1235 testing.expect(it.next() == null);
1236}1236}
12371237
1238test "mem.separate (multibyte)" {1238test "mem.split (multibyte)" {
1239 var it = separate("a, b ,, c, d, e", ", ");1239 var it = split("a, b ,, c, d, e", ", ");
1240 testing.expect(eql(u8, it.next().?, "a"));1240 testing.expect(eql(u8, it.next().?, "a"));
1241 testing.expect(eql(u8, it.next().?, "b ,"));1241 testing.expect(eql(u8, it.next().?, "b ,"));
1242 testing.expect(eql(u8, it.next().?, "c"));1242 testing.expect(eql(u8, it.next().?, "c"));
...@@ -1758,7 +1758,8 @@ fn BytesAsValueReturnType(comptime T: type, comptime B: type) type {...@@ -1758,7 +1758,8 @@ fn BytesAsValueReturnType(comptime T: type, comptime B: type) type {
1758 if (comptime !trait.is(.Pointer)(B) or1758 if (comptime !trait.is(.Pointer)(B) or
1759 (meta.Child(B) != [size]u8 and meta.Child(B) != [size:0]u8))1759 (meta.Child(B) != [size]u8 and meta.Child(B) != [size:0]u8))
1760 {1760 {
1761 @compileError("expected *[N]u8 " ++ ", passed " ++ @typeName(B));1761 comptime var buf: [100]u8 = undefined;
1762 @compileError(std.fmt.bufPrint(&buf, "expected *[{}]u8, passed " ++ @typeName(B), .{size}) catch unreachable);
1762 }1763 }
17631764
1764 const alignment = comptime meta.alignment(B);1765 const alignment = comptime meta.alignment(B);
lib/std/net.zig+11-11
...@@ -509,7 +509,7 @@ pub fn getAddressList(allocator: *mem.Allocator, name: []const u8, port: u16) !*...@@ -509,7 +509,7 @@ pub fn getAddressList(allocator: *mem.Allocator, name: []const u8, port: u16) !*
509509
510 try linuxLookupName(&lookup_addrs, &canon, name, family, flags, port);510 try linuxLookupName(&lookup_addrs, &canon, name, family, flags, port);
511511
512 result.addrs = try arena.alloc(Address, lookup_addrs.len);512 result.addrs = try arena.alloc(Address, lookup_addrs.items.len);
513 if (!canon.isNull()) {513 if (!canon.isNull()) {
514 result.canon_name = canon.toOwnedSlice();514 result.canon_name = canon.toOwnedSlice();
515 }515 }
...@@ -554,7 +554,7 @@ fn linuxLookupName(...@@ -554,7 +554,7 @@ fn linuxLookupName(
554 return name_err;554 return name_err;
555 } else {555 } else {
556 try linuxLookupNameFromHosts(addrs, canon, name, family, port);556 try linuxLookupNameFromHosts(addrs, canon, name, family, port);
557 if (addrs.len == 0) {557 if (addrs.items.len == 0) {
558 try linuxLookupNameFromDnsSearch(addrs, canon, name, family, port);558 try linuxLookupNameFromDnsSearch(addrs, canon, name, family, port);
559 }559 }
560 }560 }
...@@ -562,11 +562,11 @@ fn linuxLookupName(...@@ -562,11 +562,11 @@ fn linuxLookupName(
562 try canon.resize(0);562 try canon.resize(0);
563 try linuxLookupNameFromNull(addrs, family, flags, port);563 try linuxLookupNameFromNull(addrs, family, flags, port);
564 }564 }
565 if (addrs.len == 0) return error.UnknownHostName;565 if (addrs.items.len == 0) return error.UnknownHostName;
566566
567 // No further processing is needed if there are fewer than 2567 // No further processing is needed if there are fewer than 2
568 // results or if there are only IPv4 results.568 // results or if there are only IPv4 results.
569 if (addrs.len == 1 or family == os.AF_INET) return;569 if (addrs.items.len == 1 or family == os.AF_INET) return;
570 const all_ip4 = for (addrs.span()) |addr| {570 const all_ip4 = for (addrs.span()) |addr| {
571 if (addr.addr.any.family != os.AF_INET) break false;571 if (addr.addr.any.family != os.AF_INET) break false;
572 } else true;572 } else true;
...@@ -823,7 +823,7 @@ fn linuxLookupNameFromHosts(...@@ -823,7 +823,7 @@ fn linuxLookupNameFromHosts(
823 },823 },
824 else => |e| return e,824 else => |e| return e,
825 }) |line| {825 }) |line| {
826 const no_comment_line = mem.separate(line, "#").next().?;826 const no_comment_line = mem.split(line, "#").next().?;
827827
828 var line_it = mem.tokenize(no_comment_line, " \t");828 var line_it = mem.tokenize(no_comment_line, " \t");
829 const ip_text = line_it.next() orelse continue;829 const ip_text = line_it.next() orelse continue;
...@@ -908,7 +908,7 @@ fn linuxLookupNameFromDnsSearch(...@@ -908,7 +908,7 @@ fn linuxLookupNameFromDnsSearch(
908 canon.shrink(canon_name.len + 1);908 canon.shrink(canon_name.len + 1);
909 try canon.appendSlice(tok);909 try canon.appendSlice(tok);
910 try linuxLookupNameFromDns(addrs, canon, canon.span(), family, rc, port);910 try linuxLookupNameFromDns(addrs, canon, canon.span(), family, rc, port);
911 if (addrs.len != 0) return;911 if (addrs.items.len != 0) return;
912 }912 }
913913
914 canon.shrink(canon_name.len);914 canon.shrink(canon_name.len);
...@@ -967,7 +967,7 @@ fn linuxLookupNameFromDns(...@@ -967,7 +967,7 @@ fn linuxLookupNameFromDns(
967 dnsParse(ap[i], ctx, dnsParseCallback) catch {};967 dnsParse(ap[i], ctx, dnsParseCallback) catch {};
968 }968 }
969969
970 if (addrs.len != 0) return;970 if (addrs.items.len != 0) return;
971 if (ap[0].len < 4 or (ap[0][3] & 15) == 2) return error.TemporaryNameServerFailure;971 if (ap[0].len < 4 or (ap[0][3] & 15) == 2) return error.TemporaryNameServerFailure;
972 if ((ap[0][3] & 15) == 0) return error.UnknownHostName;972 if ((ap[0][3] & 15) == 0) return error.UnknownHostName;
973 if ((ap[0][3] & 15) == 3) return;973 if ((ap[0][3] & 15) == 3) return;
...@@ -1020,13 +1020,13 @@ fn getResolvConf(allocator: *mem.Allocator, rc: *ResolvConf) !void {...@@ -1020,13 +1020,13 @@ fn getResolvConf(allocator: *mem.Allocator, rc: *ResolvConf) !void {
1020 },1020 },
1021 else => |e| return e,1021 else => |e| return e,
1022 }) |line| {1022 }) |line| {
1023 const no_comment_line = mem.separate(line, "#").next().?;1023 const no_comment_line = mem.split(line, "#").next().?;
1024 var line_it = mem.tokenize(no_comment_line, " \t");1024 var line_it = mem.tokenize(no_comment_line, " \t");
10251025
1026 const token = line_it.next() orelse continue;1026 const token = line_it.next() orelse continue;
1027 if (mem.eql(u8, token, "options")) {1027 if (mem.eql(u8, token, "options")) {
1028 while (line_it.next()) |sub_tok| {1028 while (line_it.next()) |sub_tok| {
1029 var colon_it = mem.separate(sub_tok, ":");1029 var colon_it = mem.split(sub_tok, ":");
1030 const name = colon_it.next().?;1030 const name = colon_it.next().?;
1031 const value_txt = colon_it.next() orelse continue;1031 const value_txt = colon_it.next() orelse continue;
1032 const value = std.fmt.parseInt(u8, value_txt, 10) catch |err| switch (err) {1032 const value = std.fmt.parseInt(u8, value_txt, 10) catch |err| switch (err) {
...@@ -1049,7 +1049,7 @@ fn getResolvConf(allocator: *mem.Allocator, rc: *ResolvConf) !void {...@@ -1049,7 +1049,7 @@ fn getResolvConf(allocator: *mem.Allocator, rc: *ResolvConf) !void {
1049 }1049 }
1050 }1050 }
10511051
1052 if (rc.ns.len == 0) {1052 if (rc.ns.items.len == 0) {
1053 return linuxLookupNameFromNumericUnspec(&rc.ns, "127.0.0.1", 53);1053 return linuxLookupNameFromNumericUnspec(&rc.ns, "127.0.0.1", 53);
1054 }1054 }
1055}1055}
...@@ -1078,7 +1078,7 @@ fn resMSendRc(...@@ -1078,7 +1078,7 @@ fn resMSendRc(
1078 var ns_list = std.ArrayList(Address).init(rc.ns.allocator);1078 var ns_list = std.ArrayList(Address).init(rc.ns.allocator);
1079 defer ns_list.deinit();1079 defer ns_list.deinit();
10801080
1081 try ns_list.resize(rc.ns.len);1081 try ns_list.resize(rc.ns.items.len);
1082 const ns = ns_list.span();1082 const ns = ns_list.span();
10831083
1084 for (rc.ns.span()) |iplit, i| {1084 for (rc.ns.span()) |iplit, i| {
lib/std/os/bits/dragonfly.zig+6-1
...@@ -244,6 +244,12 @@ pub const KERN_MAXID = 37;...@@ -244,6 +244,12 @@ pub const KERN_MAXID = 37;
244244
245pub const HOST_NAME_MAX = 255;245pub const HOST_NAME_MAX = 255;
246246
247// access function
248pub const F_OK = 0; // test for existence of file
249pub const X_OK = 1; // test for execute or search permission
250pub const W_OK = 2; // test for write permission
251pub const R_OK = 4; // test for read permission
252
247pub const O_RDONLY = 0;253pub const O_RDONLY = 0;
248pub const O_NDELAY = O_NONBLOCK;254pub const O_NDELAY = O_NONBLOCK;
249pub const O_WRONLY = 1;255pub const O_WRONLY = 1;
...@@ -277,7 +283,6 @@ pub const SEEK_END = 2;...@@ -277,7 +283,6 @@ pub const SEEK_END = 2;
277pub const SEEK_DATA = 3;283pub const SEEK_DATA = 3;
278pub const SEEK_HOLE = 4;284pub const SEEK_HOLE = 4;
279285
280pub const F_OK = 0;
281pub const F_ULOCK = 0;286pub const F_ULOCK = 0;
282pub const F_LOCK = 1;287pub const F_LOCK = 1;
283pub const F_TLOCK = 2;288pub const F_TLOCK = 2;
lib/std/process.zig+1-1
...@@ -84,7 +84,7 @@ pub fn getEnvMap(allocator: *Allocator) !BufMap {...@@ -84,7 +84,7 @@ pub fn getEnvMap(allocator: *Allocator) !BufMap {
84 for (environ) |env| {84 for (environ) |env| {
85 if (env) |ptr| {85 if (env) |ptr| {
86 const pair = mem.spanZ(ptr);86 const pair = mem.spanZ(ptr);
87 var parts = mem.separate(pair, "=");87 var parts = mem.split(pair, "=");
88 const key = parts.next().?;88 const key = parts.next().?;
89 const value = parts.next().?;89 const value = parts.next().?;
90 try result.set(key, value);90 try result.set(key, value);
lib/std/sort.zig+7-6
...@@ -6,20 +6,17 @@ const math = std.math;...@@ -6,20 +6,17 @@ const math = std.math;
6const builtin = @import("builtin");6const builtin = @import("builtin");
77
8pub fn binarySearch(comptime T: type, key: T, items: []const T, comptime compareFn: fn (lhs: T, rhs: T) math.Order) ?usize {8pub fn binarySearch(comptime T: type, key: T, items: []const T, comptime compareFn: fn (lhs: T, rhs: T) math.Order) ?usize {
9 if (items.len < 1)
10 return null;
11
12 var left: usize = 0;9 var left: usize = 0;
13 var right: usize = items.len - 1;10 var right: usize = items.len;
1411
15 while (left <= right) {12 while (left < right) {
16 // Avoid overflowing in the midpoint calculation13 // Avoid overflowing in the midpoint calculation
17 const mid = left + (right - left) / 2;14 const mid = left + (right - left) / 2;
18 // Compare the key with the midpoint element15 // Compare the key with the midpoint element
19 switch (compareFn(key, items[mid])) {16 switch (compareFn(key, items[mid])) {
20 .eq => return mid,17 .eq => return mid,
21 .gt => left = mid + 1,18 .gt => left = mid + 1,
22 .lt => right = mid - 1,19 .lt => right = mid,
23 }20 }
24 }21 }
2522
...@@ -47,6 +44,10 @@ test "std.sort.binarySearch" {...@@ -47,6 +44,10 @@ test "std.sort.binarySearch" {
47 @as(?usize, null),44 @as(?usize, null),
48 binarySearch(u32, 1, &[_]u32{0}, S.order_u32),45 binarySearch(u32, 1, &[_]u32{0}, S.order_u32),
49 );46 );
47 testing.expectEqual(
48 @as(?usize, null),
49 binarySearch(u32, 0, &[_]u32{1}, S.order_u32),
50 );
50 testing.expectEqual(51 testing.expectEqual(
51 @as(?usize, 4),52 @as(?usize, 4),
52 binarySearch(u32, 5, &[_]u32{ 1, 2, 3, 4, 5 }, S.order_u32),53 binarySearch(u32, 5, &[_]u32{ 1, 2, 3, 4, 5 }, S.order_u32),
lib/std/special/build_runner.zig+1-1
...@@ -171,7 +171,7 @@ fn usage(builder: *Builder, already_ran_build: bool, out_stream: var) !void {...@@ -171,7 +171,7 @@ fn usage(builder: *Builder, already_ran_build: bool, out_stream: var) !void {
171 \\171 \\
172 );172 );
173173
174 if (builder.available_options_list.len == 0) {174 if (builder.available_options_list.items.len == 0) {
175 try out_stream.print(" (none)\n", .{});175 try out_stream.print(" (none)\n", .{});
176 } else {176 } else {
177 for (builder.available_options_list.span()) |option| {177 for (builder.available_options_list.span()) |option| {
lib/std/special/compiler_rt.zig+2
...@@ -317,6 +317,8 @@ comptime {...@@ -317,6 +317,8 @@ comptime {
317 @export(@import("compiler_rt/mulodi4.zig").__mulodi4, .{ .name = "__mulodi4", .linkage = linkage });317 @export(@import("compiler_rt/mulodi4.zig").__mulodi4, .{ .name = "__mulodi4", .linkage = linkage });
318}318}
319319
320pub usingnamespace @import("compiler_rt/atomics.zig");
321
320// Avoid dragging in the runtime safety mechanisms into this .o file,322// Avoid dragging in the runtime safety mechanisms into this .o file,
321// unless we're trying to test this file.323// unless we're trying to test this file.
322pub fn panic(msg: []const u8, error_return_trace: ?*builtin.StackTrace) noreturn {324pub fn panic(msg: []const u8, error_return_trace: ?*builtin.StackTrace) noreturn {
lib/std/special/compiler_rt/atomics.zig created+278
...@@ -0,0 +1,278 @@
1const std = @import("std");
2const builtin = std.builtin;
3
4const linkage: builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak;
5
6const cache_line_size = 64;
7
8const SpinlockTable = struct {
9 // Allocate ~4096 bytes of memory for the spinlock table
10 const max_spinlocks = 64;
11
12 const Spinlock = struct {
13 // Prevent false sharing by providing enough padding between two
14 // consecutive spinlock elements
15 v: enum(usize) { Unlocked = 0, Locked } align(cache_line_size) = .Unlocked,
16
17 fn acquire(self: *@This()) void {
18 while (true) {
19 switch (@atomicRmw(@TypeOf(self.v), &self.v, .Xchg, .Locked, .Acquire)) {
20 .Unlocked => break,
21 .Locked => {},
22 }
23 }
24 }
25 fn release(self: *@This()) void {
26 @atomicStore(@TypeOf(self.v), &self.v, .Unlocked, .Release);
27 }
28 };
29
30 list: [max_spinlocks]Spinlock = [_]Spinlock{.{}} ** max_spinlocks,
31
32 // The spinlock table behaves as a really simple hash table, mapping
33 // addresses to spinlocks. The mapping is not unique but that's only a
34 // performance problem as the lock will be contended by more than a pair of
35 // threads.
36 fn get(self: *@This(), address: usize) *Spinlock {
37 var sl = &self.list[(address >> 3) % max_spinlocks];
38 sl.acquire();
39 return sl;
40 }
41};
42
43var spinlocks: SpinlockTable = SpinlockTable{};
44
45// The following builtins do not respect the specified memory model and instead
46// uses seq_cst, the strongest one, for simplicity sake.
47
48// Generic version of GCC atomic builtin functions.
49// Those work on any object no matter the pointer alignment nor its size.
50
51fn __atomic_load(size: u32, src: [*]u8, dest: [*]u8, model: i32) callconv(.C) void {
52 var sl = spinlocks.get(@ptrToInt(src));
53 defer sl.release();
54 @memcpy(dest, src, size);
55}
56
57fn __atomic_store(size: u32, dest: [*]u8, src: [*]u8, model: i32) callconv(.C) void {
58 var sl = spinlocks.get(@ptrToInt(dest));
59 defer sl.release();
60 @memcpy(dest, src, size);
61}
62
63fn __atomic_exchange(size: u32, ptr: [*]u8, val: [*]u8, old: [*]u8, model: i32) callconv(.C) void {
64 var sl = spinlocks.get(@ptrToInt(ptr));
65 defer sl.release();
66 @memcpy(old, ptr, size);
67 @memcpy(ptr, val, size);
68}
69
70fn __atomic_compare_exchange(
71 size: u32,
72 ptr: [*]u8,
73 expected: [*]u8,
74 desired: [*]u8,
75 success: i32,
76 failure: i32,
77) callconv(.C) i32 {
78 var sl = spinlocks.get(@ptrToInt(ptr));
79 defer sl.release();
80 for (ptr[0..size]) |b, i| {
81 if (expected[i] != b) break;
82 } else {
83 // The two objects, ptr and expected, are equal
84 @memcpy(ptr, desired, size);
85 return 1;
86 }
87 @memcpy(expected, ptr, size);
88 return 0;
89}
90
91comptime {
92 @export(__atomic_load, .{ .name = "__atomic_load", .linkage = linkage });
93 @export(__atomic_store, .{ .name = "__atomic_store", .linkage = linkage });
94 @export(__atomic_exchange, .{ .name = "__atomic_exchange", .linkage = linkage });
95 @export(__atomic_compare_exchange, .{ .name = "__atomic_compare_exchange", .linkage = linkage });
96}
97
98// Specialized versions of the GCC atomic builtin functions.
99// LLVM emits those iff the object size is known and the pointers are correctly
100// aligned.
101
102// The size (in bytes) of the biggest object that the architecture can
103// load/store atomically.
104// Objects bigger than this threshold require the use of a lock.
105const largest_atomic_size = switch (builtin.arch) {
106 .x86_64 => 16,
107 else => @sizeOf(usize),
108};
109
110// The size (in bytes) of the biggest object that the architecture can perform
111// an atomic CAS operation with.
112// Objects bigger than this threshold require the use of a lock.
113const largest_atomic_cas_size = switch (builtin.arch) {
114 .arm, .armeb, .thumb, .thumbeb =>
115 // The ARM v6m ISA has no ldrex/strex and so it's impossible to do CAS
116 // operations unless we're targeting Linux or the user provides the missing
117 // builtin functions.
118 if (std.Target.arm.featureSetHas(std.Target.current.cpu.features, .has_v6m) and
119 std.Target.current.os.tag != .linux)
120 0
121 else
122 @sizeOf(usize),
123 else => @sizeOf(usize),
124};
125
126fn atomicLoadFn(comptime T: type) fn (*T, i32) callconv(.C) T {
127 return struct {
128 fn atomic_load_N(src: *T, model: i32) callconv(.C) T {
129 if (@sizeOf(T) > largest_atomic_size) {
130 var sl = spinlocks.get(@ptrToInt(src));
131 defer sl.release();
132 return src.*;
133 } else {
134 return @atomicLoad(T, src, .SeqCst);
135 }
136 }
137 }.atomic_load_N;
138}
139
140comptime {
141 @export(atomicLoadFn(u8), .{ .name = "__atomic_load_1", .linkage = linkage });
142 @export(atomicLoadFn(u16), .{ .name = "__atomic_load_2", .linkage = linkage });
143 @export(atomicLoadFn(u32), .{ .name = "__atomic_load_4", .linkage = linkage });
144 @export(atomicLoadFn(u64), .{ .name = "__atomic_load_8", .linkage = linkage });
145}
146
147fn atomicStoreFn(comptime T: type) fn (*T, T, i32) callconv(.C) void {
148 return struct {
149 fn atomic_store_N(dst: *T, value: T, model: i32) callconv(.C) void {
150 if (@sizeOf(T) > largest_atomic_size) {
151 var sl = spinlocks.get(@ptrToInt(dst));
152 defer sl.release();
153 dst.* = value;
154 } else {
155 @atomicStore(T, dst, value, .SeqCst);
156 }
157 }
158 }.atomic_store_N;
159}
160
161comptime {
162 @export(atomicStoreFn(u8), .{ .name = "__atomic_store_1", .linkage = linkage });
163 @export(atomicStoreFn(u16), .{ .name = "__atomic_store_2", .linkage = linkage });
164 @export(atomicStoreFn(u32), .{ .name = "__atomic_store_4", .linkage = linkage });
165 @export(atomicStoreFn(u64), .{ .name = "__atomic_store_8", .linkage = linkage });
166}
167
168fn atomicExchangeFn(comptime T: type) fn (*T, T, i32) callconv(.C) T {
169 return struct {
170 fn atomic_exchange_N(ptr: *T, val: T, model: i32) callconv(.C) T {
171 if (@sizeOf(T) > largest_atomic_cas_size) {
172 var sl = spinlocks.get(@ptrToInt(ptr));
173 defer sl.release();
174 const value = ptr.*;
175 ptr.* = val;
176 return value;
177 } else {
178 return @atomicRmw(T, ptr, .Xchg, val, .SeqCst);
179 }
180 }
181 }.atomic_exchange_N;
182}
183
184comptime {
185 @export(atomicExchangeFn(u8), .{ .name = "__atomic_exchange_1", .linkage = linkage });
186 @export(atomicExchangeFn(u16), .{ .name = "__atomic_exchange_2", .linkage = linkage });
187 @export(atomicExchangeFn(u32), .{ .name = "__atomic_exchange_4", .linkage = linkage });
188 @export(atomicExchangeFn(u64), .{ .name = "__atomic_exchange_8", .linkage = linkage });
189}
190
191fn atomicCompareExchangeFn(comptime T: type) fn (*T, *T, T, i32, i32) callconv(.C) i32 {
192 return struct {
193 fn atomic_compare_exchange_N(ptr: *T, expected: *T, desired: T, success: i32, failure: i32) callconv(.C) i32 {
194 if (@sizeOf(T) > largest_atomic_cas_size) {
195 var sl = spinlocks.get(@ptrToInt(ptr));
196 defer sl.release();
197 const value = ptr.*;
198 if (value == expected.*) {
199 ptr.* = desired;
200 return 1;
201 }
202 expected.* = value;
203 return 0;
204 } else {
205 if (@cmpxchgStrong(T, ptr, expected.*, desired, .SeqCst, .SeqCst)) |old_value| {
206 expected.* = old_value;
207 return 0;
208 }
209 return 1;
210 }
211 }
212 }.atomic_compare_exchange_N;
213}
214
215comptime {
216 @export(atomicCompareExchangeFn(u8), .{ .name = "__atomic_compare_exchange_1", .linkage = linkage });
217 @export(atomicCompareExchangeFn(u16), .{ .name = "__atomic_compare_exchange_2", .linkage = linkage });
218 @export(atomicCompareExchangeFn(u32), .{ .name = "__atomic_compare_exchange_4", .linkage = linkage });
219 @export(atomicCompareExchangeFn(u64), .{ .name = "__atomic_compare_exchange_8", .linkage = linkage });
220}
221
222fn fetchFn(comptime T: type, comptime op: builtin.AtomicRmwOp) fn (*T, T, i32) callconv(.C) T {
223 return struct {
224 pub fn fetch_op_N(ptr: *T, val: T, model: i32) callconv(.C) T {
225 if (@sizeOf(T) > largest_atomic_cas_size) {
226 var sl = spinlocks.get(@ptrToInt(ptr));
227 defer sl.release();
228
229 const value = ptr.*;
230 ptr.* = switch (op) {
231 .Add => value +% val,
232 .Sub => value -% val,
233 .And => value & val,
234 .Nand => ~(value & val),
235 .Or => value | val,
236 .Xor => value ^ val,
237 else => @compileError("unsupported atomic op"),
238 };
239
240 return value;
241 }
242
243 return @atomicRmw(T, ptr, op, val, .SeqCst);
244 }
245 }.fetch_op_N;
246}
247
248comptime {
249 @export(fetchFn(u8, .Add), .{ .name = "__atomic_fetch_add_1", .linkage = linkage });
250 @export(fetchFn(u16, .Add), .{ .name = "__atomic_fetch_add_2", .linkage = linkage });
251 @export(fetchFn(u32, .Add), .{ .name = "__atomic_fetch_add_4", .linkage = linkage });
252 @export(fetchFn(u64, .Add), .{ .name = "__atomic_fetch_add_8", .linkage = linkage });
253
254 @export(fetchFn(u8, .Sub), .{ .name = "__atomic_fetch_sub_1", .linkage = linkage });
255 @export(fetchFn(u16, .Sub), .{ .name = "__atomic_fetch_sub_2", .linkage = linkage });
256 @export(fetchFn(u32, .Sub), .{ .name = "__atomic_fetch_sub_4", .linkage = linkage });
257 @export(fetchFn(u64, .Sub), .{ .name = "__atomic_fetch_sub_8", .linkage = linkage });
258
259 @export(fetchFn(u8, .And), .{ .name = "__atomic_fetch_and_1", .linkage = linkage });
260 @export(fetchFn(u16, .And), .{ .name = "__atomic_fetch_and_2", .linkage = linkage });
261 @export(fetchFn(u32, .And), .{ .name = "__atomic_fetch_and_4", .linkage = linkage });
262 @export(fetchFn(u64, .And), .{ .name = "__atomic_fetch_and_8", .linkage = linkage });
263
264 @export(fetchFn(u8, .Or), .{ .name = "__atomic_fetch_or_1", .linkage = linkage });
265 @export(fetchFn(u16, .Or), .{ .name = "__atomic_fetch_or_2", .linkage = linkage });
266 @export(fetchFn(u32, .Or), .{ .name = "__atomic_fetch_or_4", .linkage = linkage });
267 @export(fetchFn(u64, .Or), .{ .name = "__atomic_fetch_or_8", .linkage = linkage });
268
269 @export(fetchFn(u8, .Xor), .{ .name = "__atomic_fetch_xor_1", .linkage = linkage });
270 @export(fetchFn(u16, .Xor), .{ .name = "__atomic_fetch_xor_2", .linkage = linkage });
271 @export(fetchFn(u32, .Xor), .{ .name = "__atomic_fetch_xor_4", .linkage = linkage });
272 @export(fetchFn(u64, .Xor), .{ .name = "__atomic_fetch_xor_8", .linkage = linkage });
273
274 @export(fetchFn(u8, .Nand), .{ .name = "__atomic_fetch_nand_1", .linkage = linkage });
275 @export(fetchFn(u16, .Nand), .{ .name = "__atomic_fetch_nand_2", .linkage = linkage });
276 @export(fetchFn(u32, .Nand), .{ .name = "__atomic_fetch_nand_4", .linkage = linkage });
277 @export(fetchFn(u64, .Nand), .{ .name = "__atomic_fetch_nand_8", .linkage = linkage });
278}
lib/std/target.zig+8-5
...@@ -501,11 +501,8 @@ pub const Target = struct {...@@ -501,11 +501,8 @@ pub const Target = struct {
501501
502 /// Removes the specified feature but not its dependents.502 /// Removes the specified feature but not its dependents.
503 pub fn removeFeatureSet(set: *Set, other_set: Set) void {503 pub fn removeFeatureSet(set: *Set, other_set: Set) void {
504 // TODO should be able to use binary not on @Vector type.504 set.ints = @as(@Vector(usize_count, usize), set.ints) &
505 // https://github.com/ziglang/zig/issues/903505 ~@as(@Vector(usize_count, usize), other_set.ints);
506 for (set.ints) |*int, i| {
507 int.* &= ~other_set.ints[i];
508 }
509 }506 }
510507
511 pub fn populateDependencies(set: *Set, all_features_list: []const Cpu.Feature) void {508 pub fn populateDependencies(set: *Set, all_features_list: []const Cpu.Feature) void {
...@@ -701,6 +698,7 @@ pub const Target = struct {...@@ -701,6 +698,7 @@ pub const Target = struct {
701 .bpfeb => ._BPF,698 .bpfeb => ._BPF,
702 .sparcv9 => ._SPARCV9,699 .sparcv9 => ._SPARCV9,
703 .s390x => ._S390,700 .s390x => ._S390,
701 .ve => ._NONE,
704 };702 };
705 }703 }
706704
...@@ -742,6 +740,7 @@ pub const Target = struct {...@@ -742,6 +740,7 @@ pub const Target = struct {
742 .renderscript32,740 .renderscript32,
743 .renderscript64,741 .renderscript64,
744 .shave,742 .shave,
743 .ve,
745 => .Little,744 => .Little,
746745
747 .arc,746 .arc,
...@@ -1320,3 +1319,7 @@ pub const Target = struct {...@@ -1320,3 +1319,7 @@ pub const Target = struct {
1320 }1319 }
1321 }1320 }
1322};1321};
1322
1323test "" {
1324 std.meta.refAllDecls(Target.Cpu.Arch);
1325}
lib/std/testing.zig+2-1
...@@ -7,7 +7,8 @@ pub const FailingAllocator = @import("testing/failing_allocator.zig").FailingAll...@@ -7,7 +7,8 @@ pub const FailingAllocator = @import("testing/failing_allocator.zig").FailingAll
7pub const allocator = &allocator_instance.allocator;7pub const allocator = &allocator_instance.allocator;
8pub var allocator_instance = LeakCountAllocator.init(&base_allocator_instance.allocator);8pub var allocator_instance = LeakCountAllocator.init(&base_allocator_instance.allocator);
99
10pub const failing_allocator = &FailingAllocator.init(&base_allocator_instance.allocator, 0).allocator;10pub const failing_allocator = &failing_allocator_instance.allocator;
11pub var failing_allocator_instance = FailingAllocator.init(&base_allocator_instance.allocator, 0);
1112
12pub var base_allocator_instance = std.heap.ThreadSafeFixedBufferAllocator.init(allocator_mem[0..]);13pub var base_allocator_instance = std.heap.ThreadSafeFixedBufferAllocator.init(allocator_mem[0..]);
13var allocator_mem: [1024 * 1024]u8 = undefined;14var allocator_mem: [1024 * 1024]u8 = undefined;
lib/std/unicode.zig+2-2
...@@ -475,7 +475,7 @@ pub fn utf16leToUtf8Alloc(allocator: *mem.Allocator, utf16le: []const u16) ![]u8...@@ -475,7 +475,7 @@ pub fn utf16leToUtf8Alloc(allocator: *mem.Allocator, utf16le: []const u16) ![]u8
475 var it = Utf16LeIterator.init(utf16le);475 var it = Utf16LeIterator.init(utf16le);
476 while (try it.nextCodepoint()) |codepoint| {476 while (try it.nextCodepoint()) |codepoint| {
477 const utf8_len = utf8CodepointSequenceLength(codepoint) catch unreachable;477 const utf8_len = utf8CodepointSequenceLength(codepoint) catch unreachable;
478 try result.resize(result.len + utf8_len);478 try result.resize(result.items.len + utf8_len);
479 assert((utf8Encode(codepoint, result.items[out_index..]) catch unreachable) == utf8_len);479 assert((utf8Encode(codepoint, result.items[out_index..]) catch unreachable) == utf8_len);
480 out_index += utf8_len;480 out_index += utf8_len;
481 }481 }
...@@ -571,7 +571,7 @@ pub fn utf8ToUtf16LeWithNull(allocator: *mem.Allocator, utf8: []const u8) ![:0]u...@@ -571,7 +571,7 @@ pub fn utf8ToUtf16LeWithNull(allocator: *mem.Allocator, utf8: []const u8) ![:0]u
571 }571 }
572 }572 }
573573
574 const len = result.len;574 const len = result.items.len;
575 try result.append(0);575 try result.append(0);
576 return result.toOwnedSlice()[0..len :0];576 return result.toOwnedSlice()[0..len :0];
577}577}
lib/std/unicode/throughput_test.zig+1-1
...@@ -2,7 +2,7 @@ const builtin = @import("builtin");...@@ -2,7 +2,7 @@ const builtin = @import("builtin");
2const std = @import("std");2const std = @import("std");
33
4pub fn main() !void {4pub fn main() !void {
5 const stdout = &std.io.getStdOut().outStream().stream;5 const stdout = std.io.getStdOut().outStream();
66
7 const args = try std.process.argsAlloc(std.heap.page_allocator);7 const args = try std.process.argsAlloc(std.heap.page_allocator);
88
lib/std/zig/cross_target.zig+5-5
...@@ -224,7 +224,7 @@ pub const CrossTarget = struct {...@@ -224,7 +224,7 @@ pub const CrossTarget = struct {
224 .dynamic_linker = DynamicLinker.init(args.dynamic_linker),224 .dynamic_linker = DynamicLinker.init(args.dynamic_linker),
225 };225 };
226226
227 var it = mem.separate(args.arch_os_abi, "-");227 var it = mem.split(args.arch_os_abi, "-");
228 const arch_name = it.next().?;228 const arch_name = it.next().?;
229 const arch_is_native = mem.eql(u8, arch_name, "native");229 const arch_is_native = mem.eql(u8, arch_name, "native");
230 if (!arch_is_native) {230 if (!arch_is_native) {
...@@ -242,7 +242,7 @@ pub const CrossTarget = struct {...@@ -242,7 +242,7 @@ pub const CrossTarget = struct {
242242
243 const opt_abi_text = it.next();243 const opt_abi_text = it.next();
244 if (opt_abi_text) |abi_text| {244 if (opt_abi_text) |abi_text| {
245 var abi_it = mem.separate(abi_text, ".");245 var abi_it = mem.split(abi_text, ".");
246 const abi = std.meta.stringToEnum(Target.Abi, abi_it.next().?) orelse246 const abi = std.meta.stringToEnum(Target.Abi, abi_it.next().?) orelse
247 return error.UnknownApplicationBinaryInterface;247 return error.UnknownApplicationBinaryInterface;
248 result.abi = abi;248 result.abi = abi;
...@@ -668,7 +668,7 @@ pub const CrossTarget = struct {...@@ -668,7 +668,7 @@ pub const CrossTarget = struct {
668 }668 }
669669
670 fn parseOs(result: *CrossTarget, diags: *ParseOptions.Diagnostics, text: []const u8) !void {670 fn parseOs(result: *CrossTarget, diags: *ParseOptions.Diagnostics, text: []const u8) !void {
671 var it = mem.separate(text, ".");671 var it = mem.split(text, ".");
672 const os_name = it.next().?;672 const os_name = it.next().?;
673 diags.os_name = os_name;673 diags.os_name = os_name;
674 const os_is_native = mem.eql(u8, os_name, "native");674 const os_is_native = mem.eql(u8, os_name, "native");
...@@ -722,7 +722,7 @@ pub const CrossTarget = struct {...@@ -722,7 +722,7 @@ pub const CrossTarget = struct {
722 .linux,722 .linux,
723 .dragonfly,723 .dragonfly,
724 => {724 => {
725 var range_it = mem.separate(version_text, "...");725 var range_it = mem.split(version_text, "...");
726726
727 const min_text = range_it.next().?;727 const min_text = range_it.next().?;
728 const min_ver = SemVer.parse(min_text) catch |err| switch (err) {728 const min_ver = SemVer.parse(min_text) catch |err| switch (err) {
...@@ -742,7 +742,7 @@ pub const CrossTarget = struct {...@@ -742,7 +742,7 @@ pub const CrossTarget = struct {
742 },742 },
743743
744 .windows => {744 .windows => {
745 var range_it = mem.separate(version_text, "...");745 var range_it = mem.split(version_text, "...");
746746
747 const min_text = range_it.next().?;747 const min_text = range_it.next().?;
748 const min_ver = std.meta.stringToEnum(Target.Os.WindowsVersion, min_text) orelse748 const min_ver = std.meta.stringToEnum(Target.Os.WindowsVersion, min_text) orelse
lib/std/zig/parse_string_literal.zig+56-7
...@@ -19,17 +19,19 @@ pub fn parseStringLiteral(...@@ -19,17 +19,19 @@ pub fn parseStringLiteral(
19 bytes: []const u8,19 bytes: []const u8,
20 bad_index: *usize, // populated if error.InvalidCharacter is returned20 bad_index: *usize, // populated if error.InvalidCharacter is returned
21) ParseStringLiteralError![]u8 {21) ParseStringLiteralError![]u8 {
22 const first_index = if (bytes[0] == 'c') @as(usize, 2) else @as(usize, 1);22 assert(bytes.len >= 2 and bytes[0] == '"' and bytes[bytes.len - 1] == '"');
23 assert(bytes[bytes.len - 1] == '"');
2423
25 var list = std.ArrayList(u8).init(allocator);24 var list = std.ArrayList(u8).init(allocator);
26 errdefer list.deinit();25 errdefer list.deinit();
2726
28 const slice = bytes[first_index..];27 const slice = bytes[1..];
29 try list.ensureCapacity(slice.len - 1);28 try list.ensureCapacity(slice.len - 1);
3029
31 var state = State.Start;30 var state = State.Start;
32 for (slice) |b, index| {31 var index: usize = 0;
32 while (index < slice.len) : (index += 1) {
33 const b = slice[index];
34
33 switch (state) {35 switch (state) {
34 State.Start => switch (b) {36 State.Start => switch (b) {
35 '\\' => state = State.Backslash,37 '\\' => state = State.Backslash,
...@@ -41,9 +43,6 @@ pub fn parseStringLiteral(...@@ -41,9 +43,6 @@ pub fn parseStringLiteral(
41 else => try list.append(b),43 else => try list.append(b),
42 },44 },
43 State.Backslash => switch (b) {45 State.Backslash => switch (b) {
44 'x' => @panic("TODO"),
45 'u' => @panic("TODO"),
46 'U' => @panic("TODO"),
47 'n' => {46 'n' => {
48 try list.append('\n');47 try list.append('\n');
49 state = State.Start;48 state = State.Start;
...@@ -60,10 +59,46 @@ pub fn parseStringLiteral(...@@ -60,10 +59,46 @@ pub fn parseStringLiteral(
60 try list.append('\t');59 try list.append('\t');
61 state = State.Start;60 state = State.Start;
62 },61 },
62 '\'' => {
63 try list.append('\'');
64 state = State.Start;
65 },
63 '"' => {66 '"' => {
64 try list.append('"');67 try list.append('"');
65 state = State.Start;68 state = State.Start;
66 },69 },
70 'x' => {
71 // TODO: add more/better/broader tests for this.
72 const index_continue = index + 3;
73 if (slice.len >= index_continue)
74 if (std.fmt.parseUnsigned(u8, slice[index + 1 .. index_continue], 16)) |char| {
75 try list.append(char);
76 state = State.Start;
77 index = index_continue - 1; // loop-header increments again
78 continue;
79 } else |_| {};
80
81 bad_index.* = index;
82 return error.InvalidCharacter;
83 },
84 'u' => {
85 // TODO: add more/better/broader tests for this.
86 if (slice.len > index + 2 and slice[index + 1] == '{')
87 if (std.mem.indexOfScalarPos(u8, slice[0..std.math.min(index + 9, slice.len)], index + 3, '}')) |index_end| {
88 const hex_str = slice[index + 2 .. index_end];
89 if (std.fmt.parseUnsigned(u32, hex_str, 16)) |uint| {
90 if (uint <= 0x10ffff) {
91 try list.appendSlice(std.mem.toBytes(uint)[0..]);
92 state = State.Start;
93 index = index_end; // loop-header increments
94 continue;
95 }
96 } else |_| {}
97 };
98
99 bad_index.* = index;
100 return error.InvalidCharacter;
101 },
67 else => {102 else => {
68 bad_index.* = index;103 bad_index.* = index;
69 return error.InvalidCharacter;104 return error.InvalidCharacter;
...@@ -74,3 +109,17 @@ pub fn parseStringLiteral(...@@ -74,3 +109,17 @@ pub fn parseStringLiteral(
74 }109 }
75 unreachable;110 unreachable;
76}111}
112
113test "parseStringLiteral" {
114 const expect = std.testing.expect;
115 const eql = std.mem.eql;
116
117 var fixed_buf_mem: [32]u8 = undefined;
118 var fixed_buf_alloc = std.heap.FixedBufferAllocator.init(fixed_buf_mem[0..]);
119 var alloc = &fixed_buf_alloc.allocator;
120 var bad_index: usize = undefined;
121
122 expect(eql(u8, "foo", try parseStringLiteral(alloc, "\"foo\"", &bad_index)));
123 expect(eql(u8, "foo", try parseStringLiteral(alloc, "\"f\x6f\x6f\"", &bad_index)));
124 expect(eql(u8, "f💯", try parseStringLiteral(alloc, "\"f\u{1f4af}\"", &bad_index)));
125}
lib/std/zig/perf_test.zig+1-1
...@@ -24,7 +24,7 @@ pub fn main() !void {...@@ -24,7 +24,7 @@ pub fn main() !void {
24 const mb_per_sec = bytes_per_sec / (1024 * 1024);24 const mb_per_sec = bytes_per_sec / (1024 * 1024);
2525
26 var stdout_file = std.io.getStdOut();26 var stdout_file = std.io.getStdOut();
27 const stdout = &stdout_file.outStream().stream;27 const stdout = stdout_file.outStream();
28 try stdout.print("{:.3} MiB/s, {} KiB used \n", .{ mb_per_sec, memory_used / 1024 });28 try stdout.print("{:.3} MiB/s, {} KiB used \n", .{ mb_per_sec, memory_used / 1024 });
29}29}
3030
src-self-hosted/clang_options.zig+10
...@@ -95,6 +95,16 @@ pub fn flagpd1(name: []const u8) CliArg {...@@ -95,6 +95,16 @@ pub fn flagpd1(name: []const u8) CliArg {
95 };95 };
96}96}
9797
98/// Shortcut function for initializing a `CliArg`
99pub fn flagpsl(name: []const u8) CliArg {
100 return .{
101 .name = name,
102 .syntax = .flag,
103 .zig_equivalent = .other,
104 .psl = true,
105 };
106}
107
98/// Shortcut function for initializing a `CliArg`108/// Shortcut function for initializing a `CliArg`
99pub fn joinpd1(name: []const u8) CliArg {109pub fn joinpd1(name: []const u8) CliArg {
100 return .{110 return .{
src-self-hosted/clang_options_data.zig+91-21
...@@ -34,10 +34,38 @@ flagpd1("M"),...@@ -34,10 +34,38 @@ flagpd1("M"),
34 .pd2 = false,34 .pd2 = false,
35 .psl = false,35 .psl = false,
36},36},
37flagpd1("MG"),37.{
38flagpd1("MM"),38 .name = "MG",
39flagpd1("MMD"),39 .syntax = .flag,
40flagpd1("MP"),40 .zig_equivalent = .dep_file,
41 .pd1 = true,
42 .pd2 = false,
43 .psl = false,
44},
45.{
46 .name = "MM",
47 .syntax = .flag,
48 .zig_equivalent = .dep_file,
49 .pd1 = true,
50 .pd2 = false,
51 .psl = false,
52},
53.{
54 .name = "MMD",
55 .syntax = .flag,
56 .zig_equivalent = .dep_file,
57 .pd1 = true,
58 .pd2 = false,
59 .psl = false,
60},
61.{
62 .name = "MP",
63 .syntax = .flag,
64 .zig_equivalent = .dep_file,
65 .pd1 = true,
66 .pd2 = false,
67 .psl = false,
68},
41.{69.{
42 .name = "MV",70 .name = "MV",
43 .syntax = .flag,71 .syntax = .flag,
...@@ -517,14 +545,7 @@ sepd1("Zlinker-input"),...@@ -517,14 +545,7 @@ sepd1("Zlinker-input"),
517 .pd2 = false,545 .pd2 = false,
518 .psl = true,546 .psl = true,
519},547},
520.{548flagpsl("MT"),
521 .name = "MT",
522 .syntax = .flag,
523 .zig_equivalent = .other,
524 .pd1 = true,
525 .pd2 = false,
526 .psl = true,
527},
528.{549.{
529 .name = "MTd",550 .name = "MTd",
530 .syntax = .flag,551 .syntax = .flag,
...@@ -1704,7 +1725,7 @@ sepd1("Zlinker-input"),...@@ -1704,7 +1725,7 @@ sepd1("Zlinker-input"),
1704.{1725.{
1705 .name = "no-standard-includes",1726 .name = "no-standard-includes",
1706 .syntax = .flag,1727 .syntax = .flag,
1707 .zig_equivalent = .other,1728 .zig_equivalent = .nostdlibinc,
1708 .pd1 = false,1729 .pd1 = false,
1709 .pd2 = true,1730 .pd2 = true,
1710 .psl = false,1731 .psl = false,
...@@ -3760,7 +3781,14 @@ flagpd1("nocudainc"),...@@ -3760,7 +3781,14 @@ flagpd1("nocudainc"),
3760flagpd1("nodefaultlibs"),3781flagpd1("nodefaultlibs"),
3761flagpd1("nofixprebinding"),3782flagpd1("nofixprebinding"),
3762flagpd1("nogpulib"),3783flagpd1("nogpulib"),
3763flagpd1("nolibc"),3784.{
3785 .name = "nolibc",
3786 .syntax = .flag,
3787 .zig_equivalent = .nostdlib,
3788 .pd1 = true,
3789 .pd2 = false,
3790 .psl = false,
3791},
3764flagpd1("nomultidefs"),3792flagpd1("nomultidefs"),
3765flagpd1("fnon-call-exceptions"),3793flagpd1("fnon-call-exceptions"),
3766flagpd1("fno-non-call-exceptions"),3794flagpd1("fno-non-call-exceptions"),
...@@ -3769,8 +3797,22 @@ flagpd1("noprebind"),...@@ -3769,8 +3797,22 @@ flagpd1("noprebind"),
3769flagpd1("noprofilelib"),3797flagpd1("noprofilelib"),
3770flagpd1("noseglinkedit"),3798flagpd1("noseglinkedit"),
3771flagpd1("nostartfiles"),3799flagpd1("nostartfiles"),
3772flagpd1("nostdinc"),3800.{
3773flagpd1("nostdinc++"),3801 .name = "nostdinc",
3802 .syntax = .flag,
3803 .zig_equivalent = .nostdlibinc,
3804 .pd1 = true,
3805 .pd2 = false,
3806 .psl = false,
3807},
3808.{
3809 .name = "nostdinc++",
3810 .syntax = .flag,
3811 .zig_equivalent = .nostdlib_cpp,
3812 .pd1 = true,
3813 .pd2 = false,
3814 .psl = false,
3815},
3774.{3816.{
3775 .name = "nostdlib",3817 .name = "nostdlib",
3776 .syntax = .flag,3818 .syntax = .flag,
...@@ -3779,7 +3821,14 @@ flagpd1("nostdinc++"),...@@ -3779,7 +3821,14 @@ flagpd1("nostdinc++"),
3779 .pd2 = false,3821 .pd2 = false,
3780 .psl = false,3822 .psl = false,
3781},3823},
3782flagpd1("nostdlibinc"),3824.{
3825 .name = "nostdlibinc",
3826 .syntax = .flag,
3827 .zig_equivalent = .nostdlibinc,
3828 .pd1 = true,
3829 .pd2 = false,
3830 .psl = false,
3831},
3783.{3832.{
3784 .name = "nostdlib++",3833 .name = "nostdlib++",
3785 .syntax = .flag,3834 .syntax = .flag,
...@@ -5463,9 +5512,30 @@ joinpd1("G="),...@@ -5463,9 +5512,30 @@ joinpd1("G="),
5463 .pd2 = false,5512 .pd2 = false,
5464 .psl = false,5513 .psl = false,
5465},5514},
5466jspd1("MJ"),5515.{
5467jspd1("MQ"),5516 .name = "MJ",
5468jspd1("MT"),5517 .syntax = .joined_or_separate,
5518 .zig_equivalent = .dep_file,
5519 .pd1 = true,
5520 .pd2 = false,
5521 .psl = false,
5522},
5523.{
5524 .name = "MQ",
5525 .syntax = .joined_or_separate,
5526 .zig_equivalent = .dep_file,
5527 .pd1 = true,
5528 .pd2 = false,
5529 .psl = false,
5530},
5531.{
5532 .name = "MT",
5533 .syntax = .joined_or_separate,
5534 .zig_equivalent = .dep_file,
5535 .pd1 = true,
5536 .pd2 = false,
5537 .psl = false,
5538},
5469.{5539.{
5470 .name = "AI",5540 .name = "AI",
5471 .syntax = .joined_or_separate,5541 .syntax = .joined_or_separate,
...@@ -5589,7 +5659,7 @@ jspd1("MT"),...@@ -5589,7 +5659,7 @@ jspd1("MT"),
5589.{5659.{
5590 .name = "MP",5660 .name = "MP",
5591 .syntax = .joined,5661 .syntax = .joined,
5592 .zig_equivalent = .other,5662 .zig_equivalent = .dep_file,
5593 .pd1 = true,5663 .pd1 = true,
5594 .pd2 = false,5664 .pd2 = false,
5595 .psl = true,5665 .psl = true,
src-self-hosted/libc_installation.zig+39-27
...@@ -32,6 +32,7 @@ pub const LibCInstallation = struct {...@@ -32,6 +32,7 @@ pub const LibCInstallation = struct {
32 LibCKernel32LibNotFound,32 LibCKernel32LibNotFound,
33 UnsupportedArchitecture,33 UnsupportedArchitecture,
34 WindowsSdkNotFound,34 WindowsSdkNotFound,
35 ZigIsTheCCompiler,
35 };36 };
3637
37 pub fn parse(38 pub fn parse(
...@@ -60,7 +61,7 @@ pub const LibCInstallation = struct {...@@ -60,7 +61,7 @@ pub const LibCInstallation = struct {
60 var it = std.mem.tokenize(contents, "\n");61 var it = std.mem.tokenize(contents, "\n");
61 while (it.next()) |line| {62 while (it.next()) |line| {
62 if (line.len == 0 or line[0] == '#') continue;63 if (line.len == 0 or line[0] == '#') continue;
63 var line_it = std.mem.separate(line, "=");64 var line_it = std.mem.split(line, "=");
64 const name = line_it.next() orelse {65 const name = line_it.next() orelse {
65 try stderr.print("missing equal sign after field name\n", .{});66 try stderr.print("missing equal sign after field name\n", .{});
66 return error.ParseError;67 return error.ParseError;
...@@ -167,29 +168,22 @@ pub const LibCInstallation = struct {...@@ -167,29 +168,22 @@ pub const LibCInstallation = struct {
167 var self: LibCInstallation = .{};168 var self: LibCInstallation = .{};
168169
169 if (is_windows) {170 if (is_windows) {
170 if (is_gnu) {171 var sdk: *ZigWindowsSDK = undefined;
171 var batch = Batch(FindError!void, 3, .auto_async).init();172 switch (zig_find_windows_sdk(&sdk)) {
172 batch.add(&async self.findNativeIncludeDirPosix(args));173 .None => {
173 batch.add(&async self.findNativeCrtDirPosix(args));174 defer zig_free_windows_sdk(sdk);
174 try batch.wait();175
175 } else {176 var batch = Batch(FindError!void, 5, .auto_async).init();
176 var sdk: *ZigWindowsSDK = undefined;177 batch.add(&async self.findNativeMsvcIncludeDir(args, sdk));
177 switch (zig_find_windows_sdk(&sdk)) {178 batch.add(&async self.findNativeMsvcLibDir(args, sdk));
178 .None => {179 batch.add(&async self.findNativeKernel32LibDir(args, sdk));
179 defer zig_free_windows_sdk(sdk);180 batch.add(&async self.findNativeIncludeDirWindows(args, sdk));
180181 batch.add(&async self.findNativeCrtDirWindows(args, sdk));
181 var batch = Batch(FindError!void, 5, .auto_async).init();182 try batch.wait();
182 batch.add(&async self.findNativeMsvcIncludeDir(args, sdk));183 },
183 batch.add(&async self.findNativeMsvcLibDir(args, sdk));184 .OutOfMemory => return error.OutOfMemory,
184 batch.add(&async self.findNativeKernel32LibDir(args, sdk));185 .NotFound => return error.WindowsSdkNotFound,
185 batch.add(&async self.findNativeIncludeDirWindows(args, sdk));186 .PathTooLong => return error.WindowsSdkNotFound,
186 batch.add(&async self.findNativeCrtDirWindows(args, sdk));
187 try batch.wait();
188 },
189 .OutOfMemory => return error.OutOfMemory,
190 .NotFound => return error.WindowsSdkNotFound,
191 .PathTooLong => return error.WindowsSdkNotFound,
192 }
193 }187 }
194 } else {188 } else {
195 try blk: {189 try blk: {
...@@ -229,10 +223,19 @@ pub const LibCInstallation = struct {...@@ -229,10 +223,19 @@ pub const LibCInstallation = struct {
229 "-xc",223 "-xc",
230 dev_null,224 dev_null,
231 };225 };
226 var env_map = try std.process.getEnvMap(allocator);
227 defer env_map.deinit();
228
229 // Detect infinite loops.
230 const inf_loop_env_key = "ZIG_IS_DETECTING_LIBC_PATHS";
231 if (env_map.get(inf_loop_env_key) != null) return error.ZigIsTheCCompiler;
232 try env_map.set(inf_loop_env_key, "1");
233
232 const exec_res = std.ChildProcess.exec(.{234 const exec_res = std.ChildProcess.exec(.{
233 .allocator = allocator,235 .allocator = allocator,
234 .argv = &argv,236 .argv = &argv,
235 .max_output_bytes = 1024 * 1024,237 .max_output_bytes = 1024 * 1024,
238 .env_map = &env_map,
236 // Some C compilers, such as Clang, are known to rely on argv[0] to find the path239 // Some C compilers, such as Clang, are known to rely on argv[0] to find the path
237 // to their own executable, without even bothering to resolve PATH. This results in the message:240 // to their own executable, without even bothering to resolve PATH. This results in the message:
238 // error: unable to execute command: Executable "" doesn't exist!241 // error: unable to execute command: Executable "" doesn't exist!
...@@ -268,7 +271,7 @@ pub const LibCInstallation = struct {...@@ -268,7 +271,7 @@ pub const LibCInstallation = struct {
268 try search_paths.append(line);271 try search_paths.append(line);
269 }272 }
270 }273 }
271 if (search_paths.len == 0) {274 if (search_paths.items.len == 0) {
272 return error.CCompilerCannotFindHeaders;275 return error.CCompilerCannotFindHeaders;
273 }276 }
274277
...@@ -276,9 +279,9 @@ pub const LibCInstallation = struct {...@@ -276,9 +279,9 @@ pub const LibCInstallation = struct {
276 const sys_include_dir_example_file = if (is_windows) "sys\\types.h" else "sys/errno.h";279 const sys_include_dir_example_file = if (is_windows) "sys\\types.h" else "sys/errno.h";
277280
278 var path_i: usize = 0;281 var path_i: usize = 0;
279 while (path_i < search_paths.len) : (path_i += 1) {282 while (path_i < search_paths.items.len) : (path_i += 1) {
280 // search in reverse order283 // search in reverse order
281 const search_path_untrimmed = search_paths.at(search_paths.len - path_i - 1);284 const search_path_untrimmed = search_paths.at(search_paths.items.len - path_i - 1);
282 const search_path = std.mem.trimLeft(u8, search_path_untrimmed, " ");285 const search_path = std.mem.trimLeft(u8, search_path_untrimmed, " ");
283 var search_dir = fs.cwd().openDir(search_path, .{}) catch |err| switch (err) {286 var search_dir = fs.cwd().openDir(search_path, .{}) catch |err| switch (err) {
284 error.FileNotFound,287 error.FileNotFound,
...@@ -518,10 +521,19 @@ fn ccPrintFileName(args: CCPrintFileNameOptions) ![:0]u8 {...@@ -518,10 +521,19 @@ fn ccPrintFileName(args: CCPrintFileNameOptions) ![:0]u8 {
518 defer allocator.free(arg1);521 defer allocator.free(arg1);
519 const argv = [_][]const u8{ cc_exe, arg1 };522 const argv = [_][]const u8{ cc_exe, arg1 };
520523
524 var env_map = try std.process.getEnvMap(allocator);
525 defer env_map.deinit();
526
527 // Detect infinite loops.
528 const inf_loop_env_key = "ZIG_IS_DETECTING_LIBC_PATHS";
529 if (env_map.get(inf_loop_env_key) != null) return error.ZigIsTheCCompiler;
530 try env_map.set(inf_loop_env_key, "1");
531
521 const exec_res = std.ChildProcess.exec(.{532 const exec_res = std.ChildProcess.exec(.{
522 .allocator = allocator,533 .allocator = allocator,
523 .argv = &argv,534 .argv = &argv,
524 .max_output_bytes = 1024 * 1024,535 .max_output_bytes = 1024 * 1024,
536 .env_map = &env_map,
525 // Some C compilers, such as Clang, are known to rely on argv[0] to find the path537 // Some C compilers, such as Clang, are known to rely on argv[0] to find the path
526 // to their own executable, without even bothering to resolve PATH. This results in the message:538 // to their own executable, without even bothering to resolve PATH. This results in the message:
527 // error: unable to execute command: Executable "" doesn't exist!539 // error: unable to execute command: Executable "" doesn't exist!
src-self-hosted/main.zig+1-1
...@@ -403,7 +403,7 @@ fn buildOutputType(allocator: *Allocator, args: []const []const u8, out_type: Co...@@ -403,7 +403,7 @@ fn buildOutputType(allocator: *Allocator, args: []const []const u8, out_type: Co
403 const root_name = if (provided_name) |n| n else blk: {403 const root_name = if (provided_name) |n| n else blk: {
404 if (root_src_file) |file| {404 if (root_src_file) |file| {
405 const basename = fs.path.basename(file);405 const basename = fs.path.basename(file);
406 var it = mem.separate(basename, ".");406 var it = mem.split(basename, ".");
407 break :blk it.next() orelse basename;407 break :blk it.next() orelse basename;
408 } else {408 } else {
409 try stderr.writeAll("--name [name] not provided and unable to infer\n");409 try stderr.writeAll("--name [name] not provided and unable to infer\n");
src-self-hosted/stage2.zig+5-2
...@@ -115,6 +115,7 @@ const Error = extern enum {...@@ -115,6 +115,7 @@ const Error = extern enum {
115 InvalidOperatingSystemVersion,115 InvalidOperatingSystemVersion,
116 UnknownClangOption,116 UnknownClangOption,
117 NestedResponseFile,117 NestedResponseFile,
118 ZigIsTheCCompiler,
118};119};
119120
120const FILE = std.c.FILE;121const FILE = std.c.FILE;
...@@ -239,7 +240,7 @@ fn fmtMain(argc: c_int, argv: [*]const [*:0]const u8) !void {...@@ -239,7 +240,7 @@ fn fmtMain(argc: c_int, argv: [*]const [*:0]const u8) !void {
239 }240 }
240241
241 if (stdin_flag) {242 if (stdin_flag) {
242 if (input_files.len != 0) {243 if (input_files.items.len != 0) {
243 try stderr.writeAll("cannot use --stdin with positional arguments\n");244 try stderr.writeAll("cannot use --stdin with positional arguments\n");
244 process.exit(1);245 process.exit(1);
245 }246 }
...@@ -273,7 +274,7 @@ fn fmtMain(argc: c_int, argv: [*]const [*:0]const u8) !void {...@@ -273,7 +274,7 @@ fn fmtMain(argc: c_int, argv: [*]const [*:0]const u8) !void {
273 return;274 return;
274 }275 }
275276
276 if (input_files.len == 0) {277 if (input_files.items.len == 0) {
277 try stderr.writeAll("expected at least one source file argument\n");278 try stderr.writeAll("expected at least one source file argument\n");
278 process.exit(1);279 process.exit(1);
279 }280 }
...@@ -868,6 +869,7 @@ export fn stage2_libc_find_native(stage1_libc: *Stage2LibCInstallation) Error {...@@ -868,6 +869,7 @@ export fn stage2_libc_find_native(stage1_libc: *Stage2LibCInstallation) Error {
868 error.LibCKernel32LibNotFound => return .LibCKernel32LibNotFound,869 error.LibCKernel32LibNotFound => return .LibCKernel32LibNotFound,
869 error.UnsupportedArchitecture => return .UnsupportedArchitecture,870 error.UnsupportedArchitecture => return .UnsupportedArchitecture,
870 error.WindowsSdkNotFound => return .WindowsSdkNotFound,871 error.WindowsSdkNotFound => return .WindowsSdkNotFound,
872 error.ZigIsTheCCompiler => return .ZigIsTheCCompiler,
871 };873 };
872 stage1_libc.initFromStage2(libc);874 stage1_libc.initFromStage2(libc);
873 return .None;875 return .None;
...@@ -1293,6 +1295,7 @@ pub const ClangArgIterator = extern struct {...@@ -1293,6 +1295,7 @@ pub const ClangArgIterator = extern struct {
1293 dep_file,1295 dep_file,
1294 framework_dir,1296 framework_dir,
1295 framework,1297 framework,
1298 nostdlibinc,
1296 };1299 };
12971300
1298 const Args = struct {1301 const Args = struct {
src-self-hosted/translate_c.zig+130-42
...@@ -1170,7 +1170,7 @@ fn transBinaryOperator(...@@ -1170,7 +1170,7 @@ fn transBinaryOperator(
1170 }1170 }
1171 },1171 },
1172 .Div => {1172 .Div => {
1173 if (!cIsUnsignedInteger(qt)) {1173 if (cIsSignedInteger(qt)) {
1174 // signed integer division uses @divTrunc1174 // signed integer division uses @divTrunc
1175 const div_trunc_node = try transCreateNodeBuiltinFnCall(rp.c, "@divTrunc");1175 const div_trunc_node = try transCreateNodeBuiltinFnCall(rp.c, "@divTrunc");
1176 try div_trunc_node.params.push(try transExpr(rp, scope, ZigClangBinaryOperator_getLHS(stmt), .used, .l_value));1176 try div_trunc_node.params.push(try transExpr(rp, scope, ZigClangBinaryOperator_getLHS(stmt), .used, .l_value));
...@@ -1182,7 +1182,7 @@ fn transBinaryOperator(...@@ -1182,7 +1182,7 @@ fn transBinaryOperator(
1182 }1182 }
1183 },1183 },
1184 .Rem => {1184 .Rem => {
1185 if (!cIsUnsignedInteger(qt)) {1185 if (cIsSignedInteger(qt)) {
1186 // signed integer division uses @rem1186 // signed integer division uses @rem
1187 const rem_node = try transCreateNodeBuiltinFnCall(rp.c, "@rem");1187 const rem_node = try transCreateNodeBuiltinFnCall(rp.c, "@rem");
1188 try rem_node.params.push(try transExpr(rp, scope, ZigClangBinaryOperator_getLHS(stmt), .used, .l_value));1188 try rem_node.params.push(try transExpr(rp, scope, ZigClangBinaryOperator_getLHS(stmt), .used, .l_value));
...@@ -3018,6 +3018,8 @@ fn transCompoundAssignOperator(rp: RestorePoint, scope: *Scope, stmt: *const Zig...@@ -3018,6 +3018,8 @@ fn transCompoundAssignOperator(rp: RestorePoint, scope: *Scope, stmt: *const Zig
3018 return transCreateCompoundAssign(rp, scope, stmt, .AssignSubWrap, .MinusPercentEqual, "-%=", .SubWrap, .MinusPercent, "-%", used)3018 return transCreateCompoundAssign(rp, scope, stmt, .AssignSubWrap, .MinusPercentEqual, "-%=", .SubWrap, .MinusPercent, "-%", used)
3019 else3019 else
3020 return transCreateCompoundAssign(rp, scope, stmt, .AssignSub, .MinusPercentEqual, "-=", .Sub, .Minus, "-", used),3020 return transCreateCompoundAssign(rp, scope, stmt, .AssignSub, .MinusPercentEqual, "-=", .Sub, .Minus, "-", used),
3021 .DivAssign => return transCreateCompoundAssign(rp, scope, stmt, .AssignDiv, .SlashEqual, "/=", .Div, .Slash, "/", used),
3022 .RemAssign => return transCreateCompoundAssign(rp, scope, stmt, .AssignMod, .PercentEqual, "%=", .Mod, .Percent, "%", used),
3021 .ShlAssign => return transCreateCompoundAssign(rp, scope, stmt, .AssignBitShiftLeft, .AngleBracketAngleBracketLeftEqual, "<<=", .BitShiftLeft, .AngleBracketAngleBracketLeft, "<<", used),3023 .ShlAssign => return transCreateCompoundAssign(rp, scope, stmt, .AssignBitShiftLeft, .AngleBracketAngleBracketLeftEqual, "<<=", .BitShiftLeft, .AngleBracketAngleBracketLeft, "<<", used),
3022 .ShrAssign => return transCreateCompoundAssign(rp, scope, stmt, .AssignBitShiftRight, .AngleBracketAngleBracketRightEqual, ">>=", .BitShiftRight, .AngleBracketAngleBracketRight, ">>", used),3024 .ShrAssign => return transCreateCompoundAssign(rp, scope, stmt, .AssignBitShiftRight, .AngleBracketAngleBracketRightEqual, ">>=", .BitShiftRight, .AngleBracketAngleBracketRight, ">>", used),
3023 .AndAssign => return transCreateCompoundAssign(rp, scope, stmt, .AssignBitAnd, .AmpersandEqual, "&=", .BitAnd, .Ampersand, "&", used),3025 .AndAssign => return transCreateCompoundAssign(rp, scope, stmt, .AssignBitAnd, .AmpersandEqual, "&=", .BitAnd, .Ampersand, "&", used),
...@@ -3046,13 +3048,37 @@ fn transCreateCompoundAssign(...@@ -3046,13 +3048,37 @@ fn transCreateCompoundAssign(
3046 used: ResultUsed,3048 used: ResultUsed,
3047) TransError!*ast.Node {3049) TransError!*ast.Node {
3048 const is_shift = bin_op == .BitShiftLeft or bin_op == .BitShiftRight;3050 const is_shift = bin_op == .BitShiftLeft or bin_op == .BitShiftRight;
3051 const is_div = bin_op == .Div;
3052 const is_mod = bin_op == .Mod;
3049 const lhs = ZigClangCompoundAssignOperator_getLHS(stmt);3053 const lhs = ZigClangCompoundAssignOperator_getLHS(stmt);
3050 const rhs = ZigClangCompoundAssignOperator_getRHS(stmt);3054 const rhs = ZigClangCompoundAssignOperator_getRHS(stmt);
3051 const loc = ZigClangCompoundAssignOperator_getBeginLoc(stmt);3055 const loc = ZigClangCompoundAssignOperator_getBeginLoc(stmt);
3056 const is_signed = cIsSignedInteger(getExprQualType(rp.c, lhs));
3052 if (used == .unused) {3057 if (used == .unused) {
3053 // common case3058 // common case
3054 // c: lhs += rhs3059 // c: lhs += rhs
3055 // zig: lhs += rhs3060 // zig: lhs += rhs
3061
3062 if ((is_mod or is_div) and is_signed) {
3063 const op_token = try appendToken(rp.c, .Equal, "=");
3064 const op_node = try rp.c.a().create(ast.Node.InfixOp);
3065 const builtin = if (is_mod) "@rem" else "@divTrunc";
3066 const builtin_node = try transCreateNodeBuiltinFnCall(rp.c, builtin);
3067 const lhs_node = try transExpr(rp, scope, lhs, .used, .l_value);
3068 try builtin_node.params.push(lhs_node);
3069 _ = try appendToken(rp.c, .Comma, ",");
3070 try builtin_node.params.push(try transExpr(rp, scope, rhs, .used, .r_value));
3071 builtin_node.rparen_token = try appendToken(rp.c, .RParen, ")");
3072 op_node.* = .{
3073 .op_token = op_token,
3074 .lhs = lhs_node,
3075 .op = .Assign,
3076 .rhs = &builtin_node.base,
3077 };
3078 _ = try appendToken(rp.c, .Semicolon, ";");
3079 return &op_node.base;
3080 }
3081
3056 const lhs_node = try transExpr(rp, scope, lhs, .used, .l_value);3082 const lhs_node = try transExpr(rp, scope, lhs, .used, .l_value);
3057 const eq_token = try appendToken(rp.c, assign_tok_id, assign_bytes);3083 const eq_token = try appendToken(rp.c, assign_tok_id, assign_bytes);
3058 var rhs_node = if (is_shift)3084 var rhs_node = if (is_shift)
...@@ -3095,31 +3121,51 @@ fn transCreateCompoundAssign(...@@ -3095,31 +3121,51 @@ fn transCreateCompoundAssign(
3095 const lhs_node = try transCreateNodeIdentifier(rp.c, ref);3121 const lhs_node = try transCreateNodeIdentifier(rp.c, ref);
3096 const ref_node = try transCreateNodePtrDeref(rp.c, lhs_node);3122 const ref_node = try transCreateNodePtrDeref(rp.c, lhs_node);
3097 _ = try appendToken(rp.c, .Semicolon, ";");3123 _ = try appendToken(rp.c, .Semicolon, ";");
3098 const bin_token = try appendToken(rp.c, bin_tok_id, bin_bytes);3124
3099 var rhs_node = try transExpr(rp, scope, rhs, .used, .r_value);3125 if ((is_mod or is_div) and is_signed) {
3100 if (is_shift) {3126 const op_token = try appendToken(rp.c, .Equal, "=");
3101 const cast_node = try transCreateNodeBuiltinFnCall(rp.c, "@intCast");3127 const op_node = try rp.c.a().create(ast.Node.InfixOp);
3102 const rhs_type = try qualTypeToLog2IntRef(rp, getExprQualType(rp.c, rhs), loc);3128 const builtin = if (is_mod) "@rem" else "@divTrunc";
3103 try cast_node.params.push(rhs_type);3129 const builtin_node = try transCreateNodeBuiltinFnCall(rp.c, builtin);
3130 try builtin_node.params.push(try transCreateNodePtrDeref(rp.c, lhs_node));
3104 _ = try appendToken(rp.c, .Comma, ",");3131 _ = try appendToken(rp.c, .Comma, ",");
3105 try cast_node.params.push(rhs_node);3132 try builtin_node.params.push(try transExpr(rp, scope, rhs, .used, .r_value));
3106 cast_node.rparen_token = try appendToken(rp.c, .RParen, ")");3133 builtin_node.rparen_token = try appendToken(rp.c, .RParen, ")");
3107 rhs_node = &cast_node.base;3134 _ = try appendToken(rp.c, .Semicolon, ";");
3108 }3135 op_node.* = .{
3109 const rhs_bin = try transCreateNodeInfixOp(rp, scope, ref_node, bin_op, bin_token, rhs_node, .used, false);3136 .op_token = op_token,
3137 .lhs = ref_node,
3138 .op = .Assign,
3139 .rhs = &builtin_node.base,
3140 };
3141 _ = try appendToken(rp.c, .Semicolon, ";");
3142 try block_scope.block_node.statements.push(&op_node.base);
3143 } else {
3144 const bin_token = try appendToken(rp.c, bin_tok_id, bin_bytes);
3145 var rhs_node = try transExpr(rp, scope, rhs, .used, .r_value);
31103146
3111 _ = try appendToken(rp.c, .Semicolon, ";");3147 if (is_shift) {
3148 const cast_node = try transCreateNodeBuiltinFnCall(rp.c, "@intCast");
3149 const rhs_type = try qualTypeToLog2IntRef(rp, getExprQualType(rp.c, rhs), loc);
3150 try cast_node.params.push(rhs_type);
3151 _ = try appendToken(rp.c, .Comma, ",");
3152 try cast_node.params.push(rhs_node);
3153 cast_node.rparen_token = try appendToken(rp.c, .RParen, ")");
3154 rhs_node = &cast_node.base;
3155 }
31123156
3113 const eq_token = try appendToken(rp.c, .Equal, "=");3157 const rhs_bin = try transCreateNodeInfixOp(rp, scope, ref_node, bin_op, bin_token, rhs_node, .used, false);
3114 const assign = try transCreateNodeInfixOp(rp, scope, ref_node, .Assign, eq_token, rhs_bin, .used, false);3158 _ = try appendToken(rp.c, .Semicolon, ";");
3115 try block_scope.block_node.statements.push(assign);3159
3160 const eq_token = try appendToken(rp.c, .Equal, "=");
3161 const assign = try transCreateNodeInfixOp(rp, scope, ref_node, .Assign, eq_token, rhs_bin, .used, false);
3162 try block_scope.block_node.statements.push(assign);
3163 }
31163164
3117 const break_node = try transCreateNodeBreak(rp.c, block_scope.label);3165 const break_node = try transCreateNodeBreak(rp.c, block_scope.label);
3118 break_node.rhs = ref_node;3166 break_node.rhs = ref_node;
3119 try block_scope.block_node.statements.push(&break_node.base);3167 try block_scope.block_node.statements.push(&break_node.base);
3120 block_scope.block_node.rbrace = try appendToken(rp.c, .RBrace, "}");3168 block_scope.block_node.rbrace = try appendToken(rp.c, .RBrace, "}");
3121 // semicolon must immediately follow rbrace because it is the last token in a block
3122 _ = try appendToken(rp.c, .Semicolon, ";");
3123 const grouped_expr = try rp.c.a().create(ast.Node.GroupedExpression);3169 const grouped_expr = try rp.c.a().create(ast.Node.GroupedExpression);
3124 grouped_expr.* = .{3170 grouped_expr.* = .{
3125 .lparen = try appendToken(rp.c, .LParen, "("),3171 .lparen = try appendToken(rp.c, .LParen, "("),
...@@ -4309,7 +4355,7 @@ fn makeRestorePoint(c: *Context) RestorePoint {...@@ -4309,7 +4355,7 @@ fn makeRestorePoint(c: *Context) RestorePoint {
4309 return RestorePoint{4355 return RestorePoint{
4310 .c = c,4356 .c = c,
4311 .token_index = c.tree.tokens.len,4357 .token_index = c.tree.tokens.len,
4312 .src_buf_index = c.source_buffer.len,4358 .src_buf_index = c.source_buffer.items.len,
4313 };4359 };
4314}4360}
43154361
...@@ -4727,6 +4773,7 @@ pub fn failDecl(c: *Context, loc: ZigClangSourceLocation, name: []const u8, comp...@@ -4727,6 +4773,7 @@ pub fn failDecl(c: *Context, loc: ZigClangSourceLocation, name: []const u8, comp
4727 const msg_tok = try appendTokenFmt(c, .StringLiteral, "\"" ++ format ++ "\"", args);4773 const msg_tok = try appendTokenFmt(c, .StringLiteral, "\"" ++ format ++ "\"", args);
4728 const rparen_tok = try appendToken(c, .RParen, ")");4774 const rparen_tok = try appendToken(c, .RParen, ")");
4729 const semi_tok = try appendToken(c, .Semicolon, ";");4775 const semi_tok = try appendToken(c, .Semicolon, ";");
4776 _ = try appendTokenFmt(c, .LineComment, "// {}", .{c.locStr(loc)});
47304777
4731 const msg_node = try c.a().create(ast.Node.StringLiteral);4778 const msg_node = try c.a().create(ast.Node.StringLiteral);
4732 msg_node.* = ast.Node.StringLiteral{4779 msg_node.* = ast.Node.StringLiteral{
...@@ -4771,11 +4818,11 @@ fn appendToken(c: *Context, token_id: Token.Id, bytes: []const u8) !ast.TokenInd...@@ -4771,11 +4818,11 @@ fn appendToken(c: *Context, token_id: Token.Id, bytes: []const u8) !ast.TokenInd
47714818
4772fn appendTokenFmt(c: *Context, token_id: Token.Id, comptime format: []const u8, args: var) !ast.TokenIndex {4819fn appendTokenFmt(c: *Context, token_id: Token.Id, comptime format: []const u8, args: var) !ast.TokenIndex {
4773 assert(token_id != .Invalid);4820 assert(token_id != .Invalid);
4774 const start_index = c.source_buffer.len;4821 const start_index = c.source_buffer.items.len;
4775 errdefer c.source_buffer.shrink(start_index);4822 errdefer c.source_buffer.shrink(start_index);
47764823
4777 try c.source_buffer.outStream().print(format, args);4824 try c.source_buffer.outStream().print(format, args);
4778 const end_index = c.source_buffer.len;4825 const end_index = c.source_buffer.items.len;
4779 const token_index = c.tree.tokens.len;4826 const token_index = c.tree.tokens.len;
4780 const new_token = try c.tree.tokens.addOne();4827 const new_token = try c.tree.tokens.addOne();
4781 errdefer c.tree.tokens.shrink(token_index);4828 errdefer c.tree.tokens.shrink(token_index);
...@@ -5432,18 +5479,20 @@ fn parseCPrimaryExpr(c: *Context, it: *CTokenList.Iterator, source: []const u8,...@@ -5432,18 +5479,20 @@ fn parseCPrimaryExpr(c: *Context, it: *CTokenList.Iterator, source: []const u8,
5432 .LParen => {5479 .LParen => {
5433 const inner_node = try parseCExpr(c, it, source, source_loc, scope);5480 const inner_node = try parseCExpr(c, it, source, source_loc, scope);
54345481
5435 if (it.next().?.id != .RParen) {5482 const next_id = it.next().?.id;
5483 if (next_id != .RParen) {
5436 const first_tok = it.list.at(0);5484 const first_tok = it.list.at(0);
5437 try failDecl(5485 try failDecl(
5438 c,5486 c,
5439 source_loc,5487 source_loc,
5440 source[first_tok.start..first_tok.end],5488 source[first_tok.start..first_tok.end],
5441 "unable to translate C expr: expected ')'' here",5489 "unable to translate C expr: expected ')'' instead got: {}",
5442 .{},5490 .{@tagName(next_id)},
5443 );5491 );
5444 return error.ParseError;5492 return error.ParseError;
5445 }5493 }
5446 var saw_l_paren = false;5494 var saw_l_paren = false;
5495 var saw_integer_literal = false;
5447 switch (it.peek().?.id) {5496 switch (it.peek().?.id) {
5448 // (type)(to_cast)5497 // (type)(to_cast)
5449 .LParen => {5498 .LParen => {
...@@ -5452,6 +5501,10 @@ fn parseCPrimaryExpr(c: *Context, it: *CTokenList.Iterator, source: []const u8,...@@ -5452,6 +5501,10 @@ fn parseCPrimaryExpr(c: *Context, it: *CTokenList.Iterator, source: []const u8,
5452 },5501 },
5453 // (type)identifier5502 // (type)identifier
5454 .Identifier => {},5503 .Identifier => {},
5504 // (type)integer
5505 .IntegerLiteral => {
5506 saw_integer_literal = true;
5507 },
5455 else => return inner_node,5508 else => return inner_node,
5456 }5509 }
54575510
...@@ -5472,12 +5525,21 @@ fn parseCPrimaryExpr(c: *Context, it: *CTokenList.Iterator, source: []const u8,...@@ -5472,12 +5525,21 @@ fn parseCPrimaryExpr(c: *Context, it: *CTokenList.Iterator, source: []const u8,
5472 return error.ParseError;5525 return error.ParseError;
5473 }5526 }
54745527
5475 //if (@typeInfo(@TypeOf(x)) == .Pointer)5528 if (saw_integer_literal) {
5476 // @ptrCast(dest, x)5529 // @intToPtr(dest, x)
5477 //else if (@typeInfo(@TypeOf(x)) == .Int and @typeInfo(dest) == .Pointer)5530 const int_to_ptr = try transCreateNodeBuiltinFnCall(c, "@intToPtr");
5531 try int_to_ptr.params.push(inner_node);
5532 try int_to_ptr.params.push(node_to_cast);
5533 int_to_ptr.rparen_token = try appendToken(c, .RParen, ")");
5534 return &int_to_ptr.base;
5535 }
5536
5537 //( if (@typeInfo(@TypeOf(x)) == .Pointer)
5538 // @ptrCast(dest, @alignCast(@alignOf(dest.Child), x))
5539 //else if (@typeInfo(@TypeOf(x)) == .Integer and @typeInfo(dest) == .Pointer))
5478 // @intToPtr(dest, x)5540 // @intToPtr(dest, x)
5479 //else5541 //else
5480 // @as(dest, x)5542 // @as(dest, x) )
54815543
5482 const lparen = try appendToken(c, .LParen, "(");5544 const lparen = try appendToken(c, .LParen, "(");
54835545
...@@ -5499,9 +5561,30 @@ fn parseCPrimaryExpr(c: *Context, it: *CTokenList.Iterator, source: []const u8,...@@ -5499,9 +5561,30 @@ fn parseCPrimaryExpr(c: *Context, it: *CTokenList.Iterator, source: []const u8,
5499 if_1.condition = &cmp_1.base;5561 if_1.condition = &cmp_1.base;
5500 _ = try appendToken(c, .RParen, ")");5562 _ = try appendToken(c, .RParen, ")");
55015563
5564 const period_tok = try appendToken(c, .Period, ".");
5565 const child_ident = try transCreateNodeIdentifier(c, "Child");
5566 const inner_node_child = try c.a().create(ast.Node.InfixOp);
5567 inner_node_child.* = .{
5568 .op_token = period_tok,
5569 .lhs = inner_node,
5570 .op = .Period,
5571 .rhs = child_ident,
5572 };
5573
5574 const align_of = try transCreateNodeBuiltinFnCall(c, "@alignOf");
5575 try align_of.params.push(&inner_node_child.base);
5576 align_of.rparen_token = try appendToken(c, .RParen, ")");
5577 // hack to get zig fmt to render a comma in builtin calls
5578 _ = try appendToken(c, .Comma, ",");
5579
5580 const align_cast = try transCreateNodeBuiltinFnCall(c, "@alignCast");
5581 try align_cast.params.push(&align_of.base);
5582 try align_cast.params.push(node_to_cast);
5583 align_cast.rparen_token = try appendToken(c, .RParen, ")");
5584
5502 const ptr_cast = try transCreateNodeBuiltinFnCall(c, "@ptrCast");5585 const ptr_cast = try transCreateNodeBuiltinFnCall(c, "@ptrCast");
5503 try ptr_cast.params.push(inner_node);5586 try ptr_cast.params.push(inner_node);
5504 try ptr_cast.params.push(node_to_cast);5587 try ptr_cast.params.push(&align_cast.base);
5505 ptr_cast.rparen_token = try appendToken(c, .RParen, ")");5588 ptr_cast.rparen_token = try appendToken(c, .RParen, ")");
5506 if_1.body = &ptr_cast.base;5589 if_1.body = &ptr_cast.base;
55075590
...@@ -5682,19 +5765,24 @@ fn parseCSuffixOpExpr(c: *Context, it: *CTokenList.Iterator, source: []const u8,...@@ -5682,19 +5765,24 @@ fn parseCSuffixOpExpr(c: *Context, it: *CTokenList.Iterator, source: []const u8,
5682 // hack to get zig fmt to render a comma in builtin calls5765 // hack to get zig fmt to render a comma in builtin calls
5683 _ = try appendToken(c, .Comma, ",");5766 _ = try appendToken(c, .Comma, ",");
56845767
5685 const ptr_kind = blk: {5768 // * token
5686 // * token5769 _ = it.prev();
5687 _ = it.prev();5770 // last token of `node`
5688 // last token of `node`5771 const prev_id = it.prev().?.id;
5689 const prev_id = it.prev().?.id;5772 _ = it.next();
5690 _ = it.next();5773 _ = it.next();
5691 _ = it.next();
5692 break :blk if (prev_id == .Keyword_void) .Asterisk else Token.Id.Identifier;
5693 };
56945774
5695 const ptr = try transCreateNodePtrType(c, false, false, ptr_kind);5775 if (prev_id == .Keyword_void) {
5696 ptr.rhs = node;5776 const ptr = try transCreateNodePtrType(c, false, false, .Asterisk);
5697 return &ptr.base;5777 ptr.rhs = node;
5778 const optional_node = try transCreateNodePrefixOp(c, .OptionalType, .QuestionMark, "?");
5779 optional_node.rhs = &ptr.base;
5780 return &optional_node.base;
5781 } else {
5782 const ptr = try transCreateNodePtrType(c, false, false, Token.Id.Identifier);
5783 ptr.rhs = node;
5784 return &ptr.base;
5785 }
5698 } else {5786 } else {
5699 // expr * expr5787 // expr * expr
5700 op_token = try appendToken(c, .Asterisk, "*");5788 op_token = try appendToken(c, .Asterisk, "*");
src/all_types.hpp+2-3
...@@ -2083,7 +2083,7 @@ struct CodeGen {...@@ -2083,7 +2083,7 @@ struct CodeGen {
2083 HashMap<Scope *, ZigValue *, fn_eval_hash, fn_eval_eql> memoized_fn_eval_table;2083 HashMap<Scope *, ZigValue *, fn_eval_hash, fn_eval_eql> memoized_fn_eval_table;
2084 HashMap<ZigLLVMFnKey, LLVMValueRef, zig_llvm_fn_key_hash, zig_llvm_fn_key_eql> llvm_fn_table;2084 HashMap<ZigLLVMFnKey, LLVMValueRef, zig_llvm_fn_key_hash, zig_llvm_fn_key_eql> llvm_fn_table;
2085 HashMap<Buf *, Tld *, buf_hash, buf_eql_buf> exported_symbol_names;2085 HashMap<Buf *, Tld *, buf_hash, buf_eql_buf> exported_symbol_names;
2086 HashMap<Buf *, Tld *, buf_hash, buf_eql_buf> external_prototypes;2086 HashMap<Buf *, Tld *, buf_hash, buf_eql_buf> external_symbol_names;
2087 HashMap<Buf *, ZigValue *, buf_hash, buf_eql_buf> string_literals_table;2087 HashMap<Buf *, ZigValue *, buf_hash, buf_eql_buf> string_literals_table;
2088 HashMap<const ZigType *, ZigValue *, type_ptr_hash, type_ptr_eql> type_info_cache;2088 HashMap<const ZigType *, ZigValue *, type_ptr_hash, type_ptr_eql> type_info_cache;
2089 HashMap<const ZigType *, ZigValue *, type_ptr_hash, type_ptr_eql> one_possible_values;2089 HashMap<const ZigType *, ZigValue *, type_ptr_hash, type_ptr_eql> one_possible_values;
...@@ -2259,6 +2259,7 @@ struct CodeGen {...@@ -2259,6 +2259,7 @@ struct CodeGen {
2259 size_t version_minor;2259 size_t version_minor;
2260 size_t version_patch;2260 size_t version_patch;
2261 const char *linker_script;2261 const char *linker_script;
2262 size_t stack_size_override;
22622263
2263 BuildMode build_mode;2264 BuildMode build_mode;
2264 OutType out_type;2265 OutType out_type;
...@@ -3518,8 +3519,6 @@ struct IrInstSrcRef {...@@ -3518,8 +3519,6 @@ struct IrInstSrcRef {
3518 IrInstSrc base;3519 IrInstSrc base;
35193520
3520 IrInstSrc *value;3521 IrInstSrc *value;
3521 bool is_const;
3522 bool is_volatile;
3523};3522};
35243523
3525struct IrInstGenRef {3524struct IrInstGenRef {
src/analyze.cpp+13-1
...@@ -3498,7 +3498,7 @@ static void resolve_decl_fn(CodeGen *g, TldFn *tld_fn) {...@@ -3498,7 +3498,7 @@ static void resolve_decl_fn(CodeGen *g, TldFn *tld_fn) {
3498 }3498 }
3499 } else {3499 } else {
3500 fn_table_entry->inferred_async_node = inferred_async_none;3500 fn_table_entry->inferred_async_node = inferred_async_none;
3501 g->external_prototypes.put_unique(tld_fn->base.name, &tld_fn->base);3501 g->external_symbol_names.put_unique(tld_fn->base.name, &tld_fn->base);
3502 }3502 }
35033503
3504 Scope *child_scope = fn_table_entry->fndef_scope ? &fn_table_entry->fndef_scope->base : tld_fn->base.parent_scope;3504 Scope *child_scope = fn_table_entry->fndef_scope ? &fn_table_entry->fndef_scope->base : tld_fn->base.parent_scope;
...@@ -4048,6 +4048,10 @@ static void resolve_decl_var(CodeGen *g, TldVar *tld_var, bool allow_lazy) {...@@ -4048,6 +4048,10 @@ static void resolve_decl_var(CodeGen *g, TldVar *tld_var, bool allow_lazy) {
4048 add_var_export(g, tld_var->var, tld_var->var->name, GlobalLinkageIdStrong);4048 add_var_export(g, tld_var->var, tld_var->var->name, GlobalLinkageIdStrong);
4049 }4049 }
40504050
4051 if (is_extern) {
4052 g->external_symbol_names.put_unique(tld_var->base.name, &tld_var->base);
4053 }
4054
4051 g->global_vars.append(tld_var);4055 g->global_vars.append(tld_var);
4052}4056}
40534057
...@@ -5769,6 +5773,10 @@ OnePossibleValue type_has_one_possible_value(CodeGen *g, ZigType *type_entry) {...@@ -5769,6 +5773,10 @@ OnePossibleValue type_has_one_possible_value(CodeGen *g, ZigType *type_entry) {
5769 type_entry->one_possible_value = OnePossibleValueNo;5773 type_entry->one_possible_value = OnePossibleValueNo;
5770 for (size_t i = 0; i < type_entry->data.structure.src_field_count; i += 1) {5774 for (size_t i = 0; i < type_entry->data.structure.src_field_count; i += 1) {
5771 TypeStructField *field = type_entry->data.structure.fields[i];5775 TypeStructField *field = type_entry->data.structure.fields[i];
5776 if (field->is_comptime) {
5777 // If this field is comptime then the field can only be one possible value
5778 continue;
5779 }
5772 OnePossibleValue opv = (field->type_entry != nullptr) ?5780 OnePossibleValue opv = (field->type_entry != nullptr) ?
5773 type_has_one_possible_value(g, field->type_entry) :5781 type_has_one_possible_value(g, field->type_entry) :
5774 type_val_resolve_has_one_possible_value(g, field->type_val);5782 type_val_resolve_has_one_possible_value(g, field->type_val);
...@@ -5825,6 +5833,10 @@ ZigValue *get_the_one_possible_value(CodeGen *g, ZigType *type_entry) {...@@ -5825,6 +5833,10 @@ ZigValue *get_the_one_possible_value(CodeGen *g, ZigType *type_entry) {
5825 result->data.x_struct.fields = alloc_const_vals_ptrs(g, field_count);5833 result->data.x_struct.fields = alloc_const_vals_ptrs(g, field_count);
5826 for (size_t i = 0; i < field_count; i += 1) {5834 for (size_t i = 0; i < field_count; i += 1) {
5827 TypeStructField *field = struct_type->data.structure.fields[i];5835 TypeStructField *field = struct_type->data.structure.fields[i];
5836 if (field->is_comptime) {
5837 copy_const_val(g, result->data.x_struct.fields[i], field->init_val);
5838 continue;
5839 }
5828 ZigType *field_type = resolve_struct_field_type(g, field);5840 ZigType *field_type = resolve_struct_field_type(g, field);
5829 assert(field_type != nullptr);5841 assert(field_type != nullptr);
5830 result->data.x_struct.fields[i] = get_the_one_possible_value(g, field_type);5842 result->data.x_struct.fields[i] = get_the_one_possible_value(g, field_type);
src/codegen.cpp+322-247
...@@ -204,15 +204,14 @@ static bool is_symbol_available(CodeGen *g, const char *name) {...@@ -204,15 +204,14 @@ static bool is_symbol_available(CodeGen *g, const char *name) {
204 Buf *buf_name = buf_create_from_str(name);204 Buf *buf_name = buf_create_from_str(name);
205 bool result =205 bool result =
206 g->exported_symbol_names.maybe_get(buf_name) == nullptr &&206 g->exported_symbol_names.maybe_get(buf_name) == nullptr &&
207 g->external_prototypes.maybe_get(buf_name) == nullptr;207 g->external_symbol_names.maybe_get(buf_name) == nullptr;
208 buf_destroy(buf_name);208 buf_destroy(buf_name);
209 return result;209 return result;
210}210}
211211
212static const char *get_mangled_name(CodeGen *g, const char *original_name, bool external_linkage) {212static const char *get_mangled_name(CodeGen *g, const char *original_name) {
213 if (external_linkage || is_symbol_available(g, original_name)) {213 if (is_symbol_available(g, original_name))
214 return original_name;214 return original_name;
215 }
216215
217 int n = 0;216 int n = 0;
218 for (;; n += 1) {217 for (;; n += 1) {
...@@ -437,7 +436,7 @@ static LLVMValueRef make_fn_llvm_value(CodeGen *g, ZigFn *fn) {...@@ -437,7 +436,7 @@ static LLVMValueRef make_fn_llvm_value(CodeGen *g, ZigFn *fn) {
437 symbol_name = unmangled_name;436 symbol_name = unmangled_name;
438 linkage = GlobalLinkageIdStrong;437 linkage = GlobalLinkageIdStrong;
439 } else if (fn->export_list.length == 0) {438 } else if (fn->export_list.length == 0) {
440 symbol_name = get_mangled_name(g, unmangled_name, false);439 symbol_name = get_mangled_name(g, unmangled_name);
441 linkage = GlobalLinkageIdInternal;440 linkage = GlobalLinkageIdInternal;
442 } else {441 } else {
443 GlobalExport *fn_export = &fn->export_list.items[0];442 GlobalExport *fn_export = &fn->export_list.items[0];
...@@ -1115,7 +1114,7 @@ static LLVMValueRef get_add_error_return_trace_addr_fn(CodeGen *g) {...@@ -1115,7 +1114,7 @@ static LLVMValueRef get_add_error_return_trace_addr_fn(CodeGen *g) {
1115 };1114 };
1116 LLVMTypeRef fn_type_ref = LLVMFunctionType(LLVMVoidType(), arg_types, 2, false);1115 LLVMTypeRef fn_type_ref = LLVMFunctionType(LLVMVoidType(), arg_types, 2, false);
11171116
1118 const char *fn_name = get_mangled_name(g, "__zig_add_err_ret_trace_addr", false);1117 const char *fn_name = get_mangled_name(g, "__zig_add_err_ret_trace_addr");
1119 LLVMValueRef fn_val = LLVMAddFunction(g->module, fn_name, fn_type_ref);1118 LLVMValueRef fn_val = LLVMAddFunction(g->module, fn_name, fn_type_ref);
1120 addLLVMFnAttr(fn_val, "alwaysinline");1119 addLLVMFnAttr(fn_val, "alwaysinline");
1121 LLVMSetLinkage(fn_val, LLVMInternalLinkage);1120 LLVMSetLinkage(fn_val, LLVMInternalLinkage);
...@@ -1194,7 +1193,7 @@ static LLVMValueRef get_return_err_fn(CodeGen *g) {...@@ -1194,7 +1193,7 @@ static LLVMValueRef get_return_err_fn(CodeGen *g) {
1194 };1193 };
1195 LLVMTypeRef fn_type_ref = LLVMFunctionType(LLVMVoidType(), arg_types, 1, false);1194 LLVMTypeRef fn_type_ref = LLVMFunctionType(LLVMVoidType(), arg_types, 1, false);
11961195
1197 const char *fn_name = get_mangled_name(g, "__zig_return_error", false);1196 const char *fn_name = get_mangled_name(g, "__zig_return_error");
1198 LLVMValueRef fn_val = LLVMAddFunction(g->module, fn_name, fn_type_ref);1197 LLVMValueRef fn_val = LLVMAddFunction(g->module, fn_name, fn_type_ref);
1199 addLLVMFnAttr(fn_val, "noinline"); // so that we can look at return address1198 addLLVMFnAttr(fn_val, "noinline"); // so that we can look at return address
1200 addLLVMFnAttr(fn_val, "cold");1199 addLLVMFnAttr(fn_val, "cold");
...@@ -1264,7 +1263,7 @@ static LLVMValueRef get_safety_crash_err_fn(CodeGen *g) {...@@ -1264,7 +1263,7 @@ static LLVMValueRef get_safety_crash_err_fn(CodeGen *g) {
1264 LLVMSetLinkage(msg_prefix, LLVMPrivateLinkage);1263 LLVMSetLinkage(msg_prefix, LLVMPrivateLinkage);
1265 LLVMSetGlobalConstant(msg_prefix, true);1264 LLVMSetGlobalConstant(msg_prefix, true);
12661265
1267 const char *fn_name = get_mangled_name(g, "__zig_fail_unwrap", false);1266 const char *fn_name = get_mangled_name(g, "__zig_fail_unwrap");
1268 LLVMTypeRef fn_type_ref;1267 LLVMTypeRef fn_type_ref;
1269 if (g->have_err_ret_tracing) {1268 if (g->have_err_ret_tracing) {
1270 LLVMTypeRef arg_types[] = {1269 LLVMTypeRef arg_types[] = {
...@@ -2174,7 +2173,7 @@ static LLVMValueRef get_merge_err_ret_traces_fn_val(CodeGen *g) {...@@ -2174,7 +2173,7 @@ static LLVMValueRef get_merge_err_ret_traces_fn_val(CodeGen *g) {
2174 };2173 };
2175 LLVMTypeRef fn_type_ref = LLVMFunctionType(LLVMVoidType(), param_types, 2, false);2174 LLVMTypeRef fn_type_ref = LLVMFunctionType(LLVMVoidType(), param_types, 2, false);
21762175
2177 const char *fn_name = get_mangled_name(g, "__zig_merge_error_return_traces", false);2176 const char *fn_name = get_mangled_name(g, "__zig_merge_error_return_traces");
2178 LLVMValueRef fn_val = LLVMAddFunction(g->module, fn_name, fn_type_ref);2177 LLVMValueRef fn_val = LLVMAddFunction(g->module, fn_name, fn_type_ref);
2179 LLVMSetLinkage(fn_val, LLVMInternalLinkage);2178 LLVMSetLinkage(fn_val, LLVMInternalLinkage);
2180 ZigLLVMFunctionSetCallingConv(fn_val, get_llvm_cc(g, CallingConventionUnspecified));2179 ZigLLVMFunctionSetCallingConv(fn_val, get_llvm_cc(g, CallingConventionUnspecified));
...@@ -2535,19 +2534,51 @@ static LLVMValueRef ir_render_return(CodeGen *g, IrExecutableGen *executable, Ir...@@ -2535,19 +2534,51 @@ static LLVMValueRef ir_render_return(CodeGen *g, IrExecutableGen *executable, Ir
2535 return nullptr;2534 return nullptr;
2536}2535}
25372536
2538static LLVMValueRef gen_overflow_shl_op(CodeGen *g, ZigType *type_entry,2537enum class ScalarizePredicate {
2539 LLVMValueRef val1, LLVMValueRef val2)2538 // Returns true iff all the elements in the vector are 1.
2539 // Equivalent to folding all the bits with `and`.
2540 All,
2541 // Returns true iff there's at least one element in the vector that is 1.
2542 // Equivalent to folding all the bits with `or`.
2543 Any,
2544};
2545
2546// Collapses a <N x i1> vector into a single i1 according to the given predicate
2547static LLVMValueRef scalarize_cmp_result(CodeGen *g, LLVMValueRef val, ScalarizePredicate predicate) {
2548 assert(LLVMGetTypeKind(LLVMTypeOf(val)) == LLVMVectorTypeKind);
2549 LLVMTypeRef scalar_type = LLVMIntType(LLVMGetVectorSize(LLVMTypeOf(val)));
2550 LLVMValueRef casted = LLVMBuildBitCast(g->builder, val, scalar_type, "");
2551
2552 switch (predicate) {
2553 case ScalarizePredicate::Any: {
2554 LLVMValueRef all_zeros = LLVMConstNull(scalar_type);
2555 return LLVMBuildICmp(g->builder, LLVMIntNE, casted, all_zeros, "");
2556 }
2557 case ScalarizePredicate::All: {
2558 LLVMValueRef all_ones = LLVMConstAllOnes(scalar_type);
2559 return LLVMBuildICmp(g->builder, LLVMIntEQ, casted, all_ones, "");
2560 }
2561 }
2562
2563 zig_unreachable();
2564}
2565
2566
2567static LLVMValueRef gen_overflow_shl_op(CodeGen *g, ZigType *operand_type,
2568 LLVMValueRef val1, LLVMValueRef val2)
2540{2569{
2541 // for unsigned left shifting, we do the lossy shift, then logically shift2570 // for unsigned left shifting, we do the lossy shift, then logically shift
2542 // right the same number of bits2571 // right the same number of bits
2543 // if the values don't match, we have an overflow2572 // if the values don't match, we have an overflow
2544 // for signed left shifting we do the same except arithmetic shift right2573 // for signed left shifting we do the same except arithmetic shift right
2574 ZigType *scalar_type = (operand_type->id == ZigTypeIdVector) ?
2575 operand_type->data.vector.elem_type : operand_type;
25452576
2546 assert(type_entry->id == ZigTypeIdInt);2577 assert(scalar_type->id == ZigTypeIdInt);
25472578
2548 LLVMValueRef result = LLVMBuildShl(g->builder, val1, val2, "");2579 LLVMValueRef result = LLVMBuildShl(g->builder, val1, val2, "");
2549 LLVMValueRef orig_val;2580 LLVMValueRef orig_val;
2550 if (type_entry->data.integral.is_signed) {2581 if (scalar_type->data.integral.is_signed) {
2551 orig_val = LLVMBuildAShr(g->builder, result, val2, "");2582 orig_val = LLVMBuildAShr(g->builder, result, val2, "");
2552 } else {2583 } else {
2553 orig_val = LLVMBuildLShr(g->builder, result, val2, "");2584 orig_val = LLVMBuildLShr(g->builder, result, val2, "");
...@@ -2556,6 +2587,9 @@ static LLVMValueRef gen_overflow_shl_op(CodeGen *g, ZigType *type_entry,...@@ -2556,6 +2587,9 @@ static LLVMValueRef gen_overflow_shl_op(CodeGen *g, ZigType *type_entry,
25562587
2557 LLVMBasicBlockRef ok_block = LLVMAppendBasicBlock(g->cur_fn_val, "OverflowOk");2588 LLVMBasicBlockRef ok_block = LLVMAppendBasicBlock(g->cur_fn_val, "OverflowOk");
2558 LLVMBasicBlockRef fail_block = LLVMAppendBasicBlock(g->cur_fn_val, "OverflowFail");2589 LLVMBasicBlockRef fail_block = LLVMAppendBasicBlock(g->cur_fn_val, "OverflowFail");
2590 if (operand_type->id == ZigTypeIdVector) {
2591 ok_bit = scalarize_cmp_result(g, ok_bit, ScalarizePredicate::All);
2592 }
2559 LLVMBuildCondBr(g->builder, ok_bit, ok_block, fail_block);2593 LLVMBuildCondBr(g->builder, ok_bit, ok_block, fail_block);
25602594
2561 LLVMPositionBuilderAtEnd(g->builder, fail_block);2595 LLVMPositionBuilderAtEnd(g->builder, fail_block);
...@@ -2565,13 +2599,16 @@ static LLVMValueRef gen_overflow_shl_op(CodeGen *g, ZigType *type_entry,...@@ -2565,13 +2599,16 @@ static LLVMValueRef gen_overflow_shl_op(CodeGen *g, ZigType *type_entry,
2565 return result;2599 return result;
2566}2600}
25672601
2568static LLVMValueRef gen_overflow_shr_op(CodeGen *g, ZigType *type_entry,2602static LLVMValueRef gen_overflow_shr_op(CodeGen *g, ZigType *operand_type,
2569 LLVMValueRef val1, LLVMValueRef val2)2603 LLVMValueRef val1, LLVMValueRef val2)
2570{2604{
2571 assert(type_entry->id == ZigTypeIdInt);2605 ZigType *scalar_type = (operand_type->id == ZigTypeIdVector) ?
2606 operand_type->data.vector.elem_type : operand_type;
2607
2608 assert(scalar_type->id == ZigTypeIdInt);
25722609
2573 LLVMValueRef result;2610 LLVMValueRef result;
2574 if (type_entry->data.integral.is_signed) {2611 if (scalar_type->data.integral.is_signed) {
2575 result = LLVMBuildAShr(g->builder, val1, val2, "");2612 result = LLVMBuildAShr(g->builder, val1, val2, "");
2576 } else {2613 } else {
2577 result = LLVMBuildLShr(g->builder, val1, val2, "");2614 result = LLVMBuildLShr(g->builder, val1, val2, "");
...@@ -2581,6 +2618,9 @@ static LLVMValueRef gen_overflow_shr_op(CodeGen *g, ZigType *type_entry,...@@ -2581,6 +2618,9 @@ static LLVMValueRef gen_overflow_shr_op(CodeGen *g, ZigType *type_entry,
25812618
2582 LLVMBasicBlockRef ok_block = LLVMAppendBasicBlock(g->cur_fn_val, "OverflowOk");2619 LLVMBasicBlockRef ok_block = LLVMAppendBasicBlock(g->cur_fn_val, "OverflowOk");
2583 LLVMBasicBlockRef fail_block = LLVMAppendBasicBlock(g->cur_fn_val, "OverflowFail");2620 LLVMBasicBlockRef fail_block = LLVMAppendBasicBlock(g->cur_fn_val, "OverflowFail");
2621 if (operand_type->id == ZigTypeIdVector) {
2622 ok_bit = scalarize_cmp_result(g, ok_bit, ScalarizePredicate::All);
2623 }
2584 LLVMBuildCondBr(g->builder, ok_bit, ok_block, fail_block);2624 LLVMBuildCondBr(g->builder, ok_bit, ok_block, fail_block);
25852625
2586 LLVMPositionBuilderAtEnd(g->builder, fail_block);2626 LLVMPositionBuilderAtEnd(g->builder, fail_block);
...@@ -2591,12 +2631,7 @@ static LLVMValueRef gen_overflow_shr_op(CodeGen *g, ZigType *type_entry,...@@ -2591,12 +2631,7 @@ static LLVMValueRef gen_overflow_shr_op(CodeGen *g, ZigType *type_entry,
2591}2631}
25922632
2593static LLVMValueRef gen_float_op(CodeGen *g, LLVMValueRef val, ZigType *type_entry, BuiltinFnId op) {2633static LLVMValueRef gen_float_op(CodeGen *g, LLVMValueRef val, ZigType *type_entry, BuiltinFnId op) {
2594 if ((op == BuiltinFnIdCeil ||2634 assert(type_entry->id == ZigTypeIdFloat || type_entry->id == ZigTypeIdVector);
2595 op == BuiltinFnIdFloor) &&
2596 type_entry->id == ZigTypeIdInt)
2597 return val;
2598 assert(type_entry->id == ZigTypeIdFloat);
2599
2600 LLVMValueRef floor_fn = get_float_fn(g, type_entry, ZigLLVMFnIdFloatOp, op);2635 LLVMValueRef floor_fn = get_float_fn(g, type_entry, ZigLLVMFnIdFloatOp, op);
2601 return LLVMBuildCall(g->builder, floor_fn, &val, 1, "");2636 return LLVMBuildCall(g->builder, floor_fn, &val, 1, "");
2602}2637}
...@@ -2612,6 +2647,21 @@ static LLVMValueRef bigint_to_llvm_const(LLVMTypeRef type_ref, BigInt *bigint) {...@@ -2612,6 +2647,21 @@ static LLVMValueRef bigint_to_llvm_const(LLVMTypeRef type_ref, BigInt *bigint) {
2612 if (bigint->digit_count == 0) {2647 if (bigint->digit_count == 0) {
2613 return LLVMConstNull(type_ref);2648 return LLVMConstNull(type_ref);
2614 }2649 }
2650
2651 if (LLVMGetTypeKind(type_ref) == LLVMVectorTypeKind) {
2652 const unsigned vector_len = LLVMGetVectorSize(type_ref);
2653 LLVMTypeRef elem_type = LLVMGetElementType(type_ref);
2654
2655 LLVMValueRef *values = heap::c_allocator.allocate_nonzero<LLVMValueRef>(vector_len);
2656 // Create a vector with all the elements having the same value
2657 for (unsigned i = 0; i < vector_len; i++) {
2658 values[i] = bigint_to_llvm_const(elem_type, bigint);
2659 }
2660 LLVMValueRef result = LLVMConstVector(values, vector_len);
2661 heap::c_allocator.deallocate(values, vector_len);
2662 return result;
2663 }
2664
2615 LLVMValueRef unsigned_val;2665 LLVMValueRef unsigned_val;
2616 if (bigint->digit_count == 1) {2666 if (bigint->digit_count == 1) {
2617 unsigned_val = LLVMConstInt(type_ref, bigint_ptr(bigint)[0], false);2667 unsigned_val = LLVMConstInt(type_ref, bigint_ptr(bigint)[0], false);
...@@ -2626,21 +2676,29 @@ static LLVMValueRef bigint_to_llvm_const(LLVMTypeRef type_ref, BigInt *bigint) {...@@ -2626,21 +2676,29 @@ static LLVMValueRef bigint_to_llvm_const(LLVMTypeRef type_ref, BigInt *bigint) {
2626}2676}
26272677
2628static LLVMValueRef gen_div(CodeGen *g, bool want_runtime_safety, bool want_fast_math,2678static LLVMValueRef gen_div(CodeGen *g, bool want_runtime_safety, bool want_fast_math,
2629 LLVMValueRef val1, LLVMValueRef val2,2679 LLVMValueRef val1, LLVMValueRef val2, ZigType *operand_type, DivKind div_kind)
2630 ZigType *type_entry, DivKind div_kind)
2631{2680{
2681 ZigType *scalar_type = (operand_type->id == ZigTypeIdVector) ?
2682 operand_type->data.vector.elem_type : operand_type;
2683
2632 ZigLLVMSetFastMath(g->builder, want_fast_math);2684 ZigLLVMSetFastMath(g->builder, want_fast_math);
26332685
2634 LLVMValueRef zero = LLVMConstNull(get_llvm_type(g, type_entry));2686 LLVMValueRef zero = LLVMConstNull(get_llvm_type(g, operand_type));
2635 if (want_runtime_safety && (want_fast_math || type_entry->id != ZigTypeIdFloat)) {2687 if (want_runtime_safety && (want_fast_math || scalar_type->id != ZigTypeIdFloat)) {
2688 // Safety check: divisor != 0
2636 LLVMValueRef is_zero_bit;2689 LLVMValueRef is_zero_bit;
2637 if (type_entry->id == ZigTypeIdInt) {2690 if (scalar_type->id == ZigTypeIdInt) {
2638 is_zero_bit = LLVMBuildICmp(g->builder, LLVMIntEQ, val2, zero, "");2691 is_zero_bit = LLVMBuildICmp(g->builder, LLVMIntEQ, val2, zero, "");
2639 } else if (type_entry->id == ZigTypeIdFloat) {2692 } else if (scalar_type->id == ZigTypeIdFloat) {
2640 is_zero_bit = LLVMBuildFCmp(g->builder, LLVMRealOEQ, val2, zero, "");2693 is_zero_bit = LLVMBuildFCmp(g->builder, LLVMRealOEQ, val2, zero, "");
2641 } else {2694 } else {
2642 zig_unreachable();2695 zig_unreachable();
2643 }2696 }
2697
2698 if (operand_type->id == ZigTypeIdVector) {
2699 is_zero_bit = scalarize_cmp_result(g, is_zero_bit, ScalarizePredicate::Any);
2700 }
2701
2644 LLVMBasicBlockRef div_zero_fail_block = LLVMAppendBasicBlock(g->cur_fn_val, "DivZeroFail");2702 LLVMBasicBlockRef div_zero_fail_block = LLVMAppendBasicBlock(g->cur_fn_val, "DivZeroFail");
2645 LLVMBasicBlockRef div_zero_ok_block = LLVMAppendBasicBlock(g->cur_fn_val, "DivZeroOk");2703 LLVMBasicBlockRef div_zero_ok_block = LLVMAppendBasicBlock(g->cur_fn_val, "DivZeroOk");
2646 LLVMBuildCondBr(g->builder, is_zero_bit, div_zero_fail_block, div_zero_ok_block);2704 LLVMBuildCondBr(g->builder, is_zero_bit, div_zero_fail_block, div_zero_ok_block);
...@@ -2650,16 +2708,21 @@ static LLVMValueRef gen_div(CodeGen *g, bool want_runtime_safety, bool want_fast...@@ -2650,16 +2708,21 @@ static LLVMValueRef gen_div(CodeGen *g, bool want_runtime_safety, bool want_fast
26502708
2651 LLVMPositionBuilderAtEnd(g->builder, div_zero_ok_block);2709 LLVMPositionBuilderAtEnd(g->builder, div_zero_ok_block);
26522710
2653 if (type_entry->id == ZigTypeIdInt && type_entry->data.integral.is_signed) {2711 // Safety check: check for overflow (dividend = minInt and divisor = -1)
2654 LLVMValueRef neg_1_value = LLVMConstInt(get_llvm_type(g, type_entry), -1, true);2712 if (scalar_type->id == ZigTypeIdInt && scalar_type->data.integral.is_signed) {
2713 LLVMValueRef neg_1_value = LLVMConstAllOnes(get_llvm_type(g, operand_type));
2655 BigInt int_min_bi = {0};2714 BigInt int_min_bi = {0};
2656 eval_min_max_value_int(g, type_entry, &int_min_bi, false);2715 eval_min_max_value_int(g, scalar_type, &int_min_bi, false);
2657 LLVMValueRef int_min_value = bigint_to_llvm_const(get_llvm_type(g, type_entry), &int_min_bi);2716 LLVMValueRef int_min_value = bigint_to_llvm_const(get_llvm_type(g, operand_type), &int_min_bi);
2717
2658 LLVMBasicBlockRef overflow_fail_block = LLVMAppendBasicBlock(g->cur_fn_val, "DivOverflowFail");2718 LLVMBasicBlockRef overflow_fail_block = LLVMAppendBasicBlock(g->cur_fn_val, "DivOverflowFail");
2659 LLVMBasicBlockRef overflow_ok_block = LLVMAppendBasicBlock(g->cur_fn_val, "DivOverflowOk");2719 LLVMBasicBlockRef overflow_ok_block = LLVMAppendBasicBlock(g->cur_fn_val, "DivOverflowOk");
2660 LLVMValueRef num_is_int_min = LLVMBuildICmp(g->builder, LLVMIntEQ, val1, int_min_value, "");2720 LLVMValueRef num_is_int_min = LLVMBuildICmp(g->builder, LLVMIntEQ, val1, int_min_value, "");
2661 LLVMValueRef den_is_neg_1 = LLVMBuildICmp(g->builder, LLVMIntEQ, val2, neg_1_value, "");2721 LLVMValueRef den_is_neg_1 = LLVMBuildICmp(g->builder, LLVMIntEQ, val2, neg_1_value, "");
2662 LLVMValueRef overflow_fail_bit = LLVMBuildAnd(g->builder, num_is_int_min, den_is_neg_1, "");2722 LLVMValueRef overflow_fail_bit = LLVMBuildAnd(g->builder, num_is_int_min, den_is_neg_1, "");
2723 if (operand_type->id == ZigTypeIdVector) {
2724 overflow_fail_bit = scalarize_cmp_result(g, overflow_fail_bit, ScalarizePredicate::Any);
2725 }
2663 LLVMBuildCondBr(g->builder, overflow_fail_bit, overflow_fail_block, overflow_ok_block);2726 LLVMBuildCondBr(g->builder, overflow_fail_bit, overflow_fail_block, overflow_ok_block);
26642727
2665 LLVMPositionBuilderAtEnd(g->builder, overflow_fail_block);2728 LLVMPositionBuilderAtEnd(g->builder, overflow_fail_block);
...@@ -2669,18 +2732,22 @@ static LLVMValueRef gen_div(CodeGen *g, bool want_runtime_safety, bool want_fast...@@ -2669,18 +2732,22 @@ static LLVMValueRef gen_div(CodeGen *g, bool want_runtime_safety, bool want_fast
2669 }2732 }
2670 }2733 }
26712734
2672 if (type_entry->id == ZigTypeIdFloat) {2735 if (scalar_type->id == ZigTypeIdFloat) {
2673 LLVMValueRef result = LLVMBuildFDiv(g->builder, val1, val2, "");2736 LLVMValueRef result = LLVMBuildFDiv(g->builder, val1, val2, "");
2674 switch (div_kind) {2737 switch (div_kind) {
2675 case DivKindFloat:2738 case DivKindFloat:
2676 return result;2739 return result;
2677 case DivKindExact:2740 case DivKindExact:
2678 if (want_runtime_safety) {2741 if (want_runtime_safety) {
2679 LLVMValueRef floored = gen_float_op(g, result, type_entry, BuiltinFnIdFloor);2742 // Safety check: a / b == floor(a / b)
2743 LLVMValueRef floored = gen_float_op(g, result, operand_type, BuiltinFnIdFloor);
2744
2680 LLVMBasicBlockRef ok_block = LLVMAppendBasicBlock(g->cur_fn_val, "DivExactOk");2745 LLVMBasicBlockRef ok_block = LLVMAppendBasicBlock(g->cur_fn_val, "DivExactOk");
2681 LLVMBasicBlockRef fail_block = LLVMAppendBasicBlock(g->cur_fn_val, "DivExactFail");2746 LLVMBasicBlockRef fail_block = LLVMAppendBasicBlock(g->cur_fn_val, "DivExactFail");
2682 LLVMValueRef ok_bit = LLVMBuildFCmp(g->builder, LLVMRealOEQ, floored, result, "");2747 LLVMValueRef ok_bit = LLVMBuildFCmp(g->builder, LLVMRealOEQ, floored, result, "");
26832748 if (operand_type->id == ZigTypeIdVector) {
2749 ok_bit = scalarize_cmp_result(g, ok_bit, ScalarizePredicate::All);
2750 }
2684 LLVMBuildCondBr(g->builder, ok_bit, ok_block, fail_block);2751 LLVMBuildCondBr(g->builder, ok_bit, ok_block, fail_block);
26852752
2686 LLVMPositionBuilderAtEnd(g->builder, fail_block);2753 LLVMPositionBuilderAtEnd(g->builder, fail_block);
...@@ -2695,54 +2762,61 @@ static LLVMValueRef gen_div(CodeGen *g, bool want_runtime_safety, bool want_fast...@@ -2695,54 +2762,61 @@ static LLVMValueRef gen_div(CodeGen *g, bool want_runtime_safety, bool want_fast
2695 LLVMBasicBlockRef gez_block = LLVMAppendBasicBlock(g->cur_fn_val, "DivTruncGEZero");2762 LLVMBasicBlockRef gez_block = LLVMAppendBasicBlock(g->cur_fn_val, "DivTruncGEZero");
2696 LLVMBasicBlockRef end_block = LLVMAppendBasicBlock(g->cur_fn_val, "DivTruncEnd");2763 LLVMBasicBlockRef end_block = LLVMAppendBasicBlock(g->cur_fn_val, "DivTruncEnd");
2697 LLVMValueRef ltz = LLVMBuildFCmp(g->builder, LLVMRealOLT, val1, zero, "");2764 LLVMValueRef ltz = LLVMBuildFCmp(g->builder, LLVMRealOLT, val1, zero, "");
2765 if (operand_type->id == ZigTypeIdVector) {
2766 ltz = scalarize_cmp_result(g, ltz, ScalarizePredicate::Any);
2767 }
2698 LLVMBuildCondBr(g->builder, ltz, ltz_block, gez_block);2768 LLVMBuildCondBr(g->builder, ltz, ltz_block, gez_block);
26992769
2700 LLVMPositionBuilderAtEnd(g->builder, ltz_block);2770 LLVMPositionBuilderAtEnd(g->builder, ltz_block);
2701 LLVMValueRef ceiled = gen_float_op(g, result, type_entry, BuiltinFnIdCeil);2771 LLVMValueRef ceiled = gen_float_op(g, result, operand_type, BuiltinFnIdCeil);
2702 LLVMBasicBlockRef ceiled_end_block = LLVMGetInsertBlock(g->builder);2772 LLVMBasicBlockRef ceiled_end_block = LLVMGetInsertBlock(g->builder);
2703 LLVMBuildBr(g->builder, end_block);2773 LLVMBuildBr(g->builder, end_block);
27042774
2705 LLVMPositionBuilderAtEnd(g->builder, gez_block);2775 LLVMPositionBuilderAtEnd(g->builder, gez_block);
2706 LLVMValueRef floored = gen_float_op(g, result, type_entry, BuiltinFnIdFloor);2776 LLVMValueRef floored = gen_float_op(g, result, operand_type, BuiltinFnIdFloor);
2707 LLVMBasicBlockRef floored_end_block = LLVMGetInsertBlock(g->builder);2777 LLVMBasicBlockRef floored_end_block = LLVMGetInsertBlock(g->builder);
2708 LLVMBuildBr(g->builder, end_block);2778 LLVMBuildBr(g->builder, end_block);
27092779
2710 LLVMPositionBuilderAtEnd(g->builder, end_block);2780 LLVMPositionBuilderAtEnd(g->builder, end_block);
2711 LLVMValueRef phi = LLVMBuildPhi(g->builder, get_llvm_type(g, type_entry), "");2781 LLVMValueRef phi = LLVMBuildPhi(g->builder, get_llvm_type(g, operand_type), "");
2712 LLVMValueRef incoming_values[] = { ceiled, floored };2782 LLVMValueRef incoming_values[] = { ceiled, floored };
2713 LLVMBasicBlockRef incoming_blocks[] = { ceiled_end_block, floored_end_block };2783 LLVMBasicBlockRef incoming_blocks[] = { ceiled_end_block, floored_end_block };
2714 LLVMAddIncoming(phi, incoming_values, incoming_blocks, 2);2784 LLVMAddIncoming(phi, incoming_values, incoming_blocks, 2);
2715 return phi;2785 return phi;
2716 }2786 }
2717 case DivKindFloor:2787 case DivKindFloor:
2718 return gen_float_op(g, result, type_entry, BuiltinFnIdFloor);2788 return gen_float_op(g, result, operand_type, BuiltinFnIdFloor);
2719 }2789 }
2720 zig_unreachable();2790 zig_unreachable();
2721 }2791 }
27222792
2723 assert(type_entry->id == ZigTypeIdInt);2793 assert(scalar_type->id == ZigTypeIdInt);
27242794
2725 switch (div_kind) {2795 switch (div_kind) {
2726 case DivKindFloat:2796 case DivKindFloat:
2727 zig_unreachable();2797 zig_unreachable();
2728 case DivKindTrunc:2798 case DivKindTrunc:
2729 if (type_entry->data.integral.is_signed) {2799 if (scalar_type->data.integral.is_signed) {
2730 return LLVMBuildSDiv(g->builder, val1, val2, "");2800 return LLVMBuildSDiv(g->builder, val1, val2, "");
2731 } else {2801 } else {
2732 return LLVMBuildUDiv(g->builder, val1, val2, "");2802 return LLVMBuildUDiv(g->builder, val1, val2, "");
2733 }2803 }
2734 case DivKindExact:2804 case DivKindExact:
2735 if (want_runtime_safety) {2805 if (want_runtime_safety) {
2806 // Safety check: a % b == 0
2736 LLVMValueRef remainder_val;2807 LLVMValueRef remainder_val;
2737 if (type_entry->data.integral.is_signed) {2808 if (scalar_type->data.integral.is_signed) {
2738 remainder_val = LLVMBuildSRem(g->builder, val1, val2, "");2809 remainder_val = LLVMBuildSRem(g->builder, val1, val2, "");
2739 } else {2810 } else {
2740 remainder_val = LLVMBuildURem(g->builder, val1, val2, "");2811 remainder_val = LLVMBuildURem(g->builder, val1, val2, "");
2741 }2812 }
2742 LLVMValueRef ok_bit = LLVMBuildICmp(g->builder, LLVMIntEQ, remainder_val, zero, "");
27432813
2744 LLVMBasicBlockRef ok_block = LLVMAppendBasicBlock(g->cur_fn_val, "DivExactOk");2814 LLVMBasicBlockRef ok_block = LLVMAppendBasicBlock(g->cur_fn_val, "DivExactOk");
2745 LLVMBasicBlockRef fail_block = LLVMAppendBasicBlock(g->cur_fn_val, "DivExactFail");2815 LLVMBasicBlockRef fail_block = LLVMAppendBasicBlock(g->cur_fn_val, "DivExactFail");
2816 LLVMValueRef ok_bit = LLVMBuildICmp(g->builder, LLVMIntEQ, remainder_val, zero, "");
2817 if (operand_type->id == ZigTypeIdVector) {
2818 ok_bit = scalarize_cmp_result(g, ok_bit, ScalarizePredicate::All);
2819 }
2746 LLVMBuildCondBr(g->builder, ok_bit, ok_block, fail_block);2820 LLVMBuildCondBr(g->builder, ok_bit, ok_block, fail_block);
27472821
2748 LLVMPositionBuilderAtEnd(g->builder, fail_block);2822 LLVMPositionBuilderAtEnd(g->builder, fail_block);
...@@ -2750,14 +2824,14 @@ static LLVMValueRef gen_div(CodeGen *g, bool want_runtime_safety, bool want_fast...@@ -2750,14 +2824,14 @@ static LLVMValueRef gen_div(CodeGen *g, bool want_runtime_safety, bool want_fast
27502824
2751 LLVMPositionBuilderAtEnd(g->builder, ok_block);2825 LLVMPositionBuilderAtEnd(g->builder, ok_block);
2752 }2826 }
2753 if (type_entry->data.integral.is_signed) {2827 if (scalar_type->data.integral.is_signed) {
2754 return LLVMBuildExactSDiv(g->builder, val1, val2, "");2828 return LLVMBuildExactSDiv(g->builder, val1, val2, "");
2755 } else {2829 } else {
2756 return LLVMBuildExactUDiv(g->builder, val1, val2, "");2830 return LLVMBuildExactUDiv(g->builder, val1, val2, "");
2757 }2831 }
2758 case DivKindFloor:2832 case DivKindFloor:
2759 {2833 {
2760 if (!type_entry->data.integral.is_signed) {2834 if (!scalar_type->data.integral.is_signed) {
2761 return LLVMBuildUDiv(g->builder, val1, val2, "");2835 return LLVMBuildUDiv(g->builder, val1, val2, "");
2762 }2836 }
2763 // const d = @divTrunc(a, b);2837 // const d = @divTrunc(a, b);
...@@ -2784,22 +2858,30 @@ enum RemKind {...@@ -2784,22 +2858,30 @@ enum RemKind {
2784};2858};
27852859
2786static LLVMValueRef gen_rem(CodeGen *g, bool want_runtime_safety, bool want_fast_math,2860static LLVMValueRef gen_rem(CodeGen *g, bool want_runtime_safety, bool want_fast_math,
2787 LLVMValueRef val1, LLVMValueRef val2,2861 LLVMValueRef val1, LLVMValueRef val2, ZigType *operand_type, RemKind rem_kind)
2788 ZigType *type_entry, RemKind rem_kind)
2789{2862{
2863 ZigType *scalar_type = (operand_type->id == ZigTypeIdVector) ?
2864 operand_type->data.vector.elem_type : operand_type;
2865
2790 ZigLLVMSetFastMath(g->builder, want_fast_math);2866 ZigLLVMSetFastMath(g->builder, want_fast_math);
27912867
2792 LLVMValueRef zero = LLVMConstNull(get_llvm_type(g, type_entry));2868 LLVMValueRef zero = LLVMConstNull(get_llvm_type(g, operand_type));
2793 if (want_runtime_safety) {2869 if (want_runtime_safety) {
2870 // Safety check: divisor != 0
2794 LLVMValueRef is_zero_bit;2871 LLVMValueRef is_zero_bit;
2795 if (type_entry->id == ZigTypeIdInt) {2872 if (scalar_type->id == ZigTypeIdInt) {
2796 LLVMIntPredicate pred = type_entry->data.integral.is_signed ? LLVMIntSLE : LLVMIntEQ;2873 LLVMIntPredicate pred = scalar_type->data.integral.is_signed ? LLVMIntSLE : LLVMIntEQ;
2797 is_zero_bit = LLVMBuildICmp(g->builder, pred, val2, zero, "");2874 is_zero_bit = LLVMBuildICmp(g->builder, pred, val2, zero, "");
2798 } else if (type_entry->id == ZigTypeIdFloat) {2875 } else if (scalar_type->id == ZigTypeIdFloat) {
2799 is_zero_bit = LLVMBuildFCmp(g->builder, LLVMRealOEQ, val2, zero, "");2876 is_zero_bit = LLVMBuildFCmp(g->builder, LLVMRealOEQ, val2, zero, "");
2800 } else {2877 } else {
2801 zig_unreachable();2878 zig_unreachable();
2802 }2879 }
2880
2881 if (operand_type->id == ZigTypeIdVector) {
2882 is_zero_bit = scalarize_cmp_result(g, is_zero_bit, ScalarizePredicate::Any);
2883 }
2884
2803 LLVMBasicBlockRef rem_zero_ok_block = LLVMAppendBasicBlock(g->cur_fn_val, "RemZeroOk");2885 LLVMBasicBlockRef rem_zero_ok_block = LLVMAppendBasicBlock(g->cur_fn_val, "RemZeroOk");
2804 LLVMBasicBlockRef rem_zero_fail_block = LLVMAppendBasicBlock(g->cur_fn_val, "RemZeroFail");2886 LLVMBasicBlockRef rem_zero_fail_block = LLVMAppendBasicBlock(g->cur_fn_val, "RemZeroFail");
2805 LLVMBuildCondBr(g->builder, is_zero_bit, rem_zero_fail_block, rem_zero_ok_block);2887 LLVMBuildCondBr(g->builder, is_zero_bit, rem_zero_fail_block, rem_zero_ok_block);
...@@ -2810,7 +2892,7 @@ static LLVMValueRef gen_rem(CodeGen *g, bool want_runtime_safety, bool want_fast...@@ -2810,7 +2892,7 @@ static LLVMValueRef gen_rem(CodeGen *g, bool want_runtime_safety, bool want_fast
2810 LLVMPositionBuilderAtEnd(g->builder, rem_zero_ok_block);2892 LLVMPositionBuilderAtEnd(g->builder, rem_zero_ok_block);
2811 }2893 }
28122894
2813 if (type_entry->id == ZigTypeIdFloat) {2895 if (scalar_type->id == ZigTypeIdFloat) {
2814 if (rem_kind == RemKindRem) {2896 if (rem_kind == RemKindRem) {
2815 return LLVMBuildFRem(g->builder, val1, val2, "");2897 return LLVMBuildFRem(g->builder, val1, val2, "");
2816 } else {2898 } else {
...@@ -2821,8 +2903,8 @@ static LLVMValueRef gen_rem(CodeGen *g, bool want_runtime_safety, bool want_fast...@@ -2821,8 +2903,8 @@ static LLVMValueRef gen_rem(CodeGen *g, bool want_runtime_safety, bool want_fast
2821 return LLVMBuildSelect(g->builder, ltz, c, a, "");2903 return LLVMBuildSelect(g->builder, ltz, c, a, "");
2822 }2904 }
2823 } else {2905 } else {
2824 assert(type_entry->id == ZigTypeIdInt);2906 assert(scalar_type->id == ZigTypeIdInt);
2825 if (type_entry->data.integral.is_signed) {2907 if (scalar_type->data.integral.is_signed) {
2826 if (rem_kind == RemKindRem) {2908 if (rem_kind == RemKindRem) {
2827 return LLVMBuildSRem(g->builder, val1, val2, "");2909 return LLVMBuildSRem(g->builder, val1, val2, "");
2828 } else {2910 } else {
...@@ -2845,11 +2927,17 @@ static void gen_shift_rhs_check(CodeGen *g, ZigType *lhs_type, ZigType *rhs_type...@@ -2845,11 +2927,17 @@ static void gen_shift_rhs_check(CodeGen *g, ZigType *lhs_type, ZigType *rhs_type
2845 // otherwise the check is useful as the allowed values are limited by the2927 // otherwise the check is useful as the allowed values are limited by the
2846 // operand type itself2928 // operand type itself
2847 if (!is_power_of_2(lhs_type->data.integral.bit_count)) {2929 if (!is_power_of_2(lhs_type->data.integral.bit_count)) {
2848 LLVMValueRef bit_count_value = LLVMConstInt(get_llvm_type(g, rhs_type),2930 BigInt bit_count_bi = {0};
2849 lhs_type->data.integral.bit_count, false);2931 bigint_init_unsigned(&bit_count_bi, lhs_type->data.integral.bit_count);
2850 LLVMValueRef less_than_bit = LLVMBuildICmp(g->builder, LLVMIntULT, value, bit_count_value, "");2932 LLVMValueRef bit_count_value = bigint_to_llvm_const(get_llvm_type(g, rhs_type),
2933 &bit_count_bi);
2934
2851 LLVMBasicBlockRef fail_block = LLVMAppendBasicBlock(g->cur_fn_val, "CheckFail");2935 LLVMBasicBlockRef fail_block = LLVMAppendBasicBlock(g->cur_fn_val, "CheckFail");
2852 LLVMBasicBlockRef ok_block = LLVMAppendBasicBlock(g->cur_fn_val, "CheckOk");2936 LLVMBasicBlockRef ok_block = LLVMAppendBasicBlock(g->cur_fn_val, "CheckOk");
2937 LLVMValueRef less_than_bit = LLVMBuildICmp(g->builder, LLVMIntULT, value, bit_count_value, "");
2938 if (rhs_type->id == ZigTypeIdVector) {
2939 less_than_bit = scalarize_cmp_result(g, less_than_bit, ScalarizePredicate::Any);
2940 }
2853 LLVMBuildCondBr(g->builder, less_than_bit, ok_block, fail_block);2941 LLVMBuildCondBr(g->builder, less_than_bit, ok_block, fail_block);
28542942
2855 LLVMPositionBuilderAtEnd(g->builder, fail_block);2943 LLVMPositionBuilderAtEnd(g->builder, fail_block);
...@@ -2966,7 +3054,8 @@ static LLVMValueRef ir_render_bin_op(CodeGen *g, IrExecutableGen *executable,...@@ -2966,7 +3054,8 @@ static LLVMValueRef ir_render_bin_op(CodeGen *g, IrExecutableGen *executable,
2966 case IrBinOpBitShiftLeftExact:3054 case IrBinOpBitShiftLeftExact:
2967 {3055 {
2968 assert(scalar_type->id == ZigTypeIdInt);3056 assert(scalar_type->id == ZigTypeIdInt);
2969 LLVMValueRef op2_casted = gen_widen_or_shorten(g, false, op2->value->type, scalar_type, op2_value);3057 LLVMValueRef op2_casted = LLVMBuildZExt(g->builder, op2_value,
3058 LLVMTypeOf(op1_value), "");
29703059
2971 if (want_runtime_safety) {3060 if (want_runtime_safety) {
2972 gen_shift_rhs_check(g, scalar_type, op2->value->type, op2_value);3061 gen_shift_rhs_check(g, scalar_type, op2->value->type, op2_value);
...@@ -2976,7 +3065,7 @@ static LLVMValueRef ir_render_bin_op(CodeGen *g, IrExecutableGen *executable,...@@ -2976,7 +3065,7 @@ static LLVMValueRef ir_render_bin_op(CodeGen *g, IrExecutableGen *executable,
2976 if (is_sloppy) {3065 if (is_sloppy) {
2977 return LLVMBuildShl(g->builder, op1_value, op2_casted, "");3066 return LLVMBuildShl(g->builder, op1_value, op2_casted, "");
2978 } else if (want_runtime_safety) {3067 } else if (want_runtime_safety) {
2979 return gen_overflow_shl_op(g, scalar_type, op1_value, op2_casted);3068 return gen_overflow_shl_op(g, operand_type, op1_value, op2_casted);
2980 } else if (scalar_type->data.integral.is_signed) {3069 } else if (scalar_type->data.integral.is_signed) {
2981 return ZigLLVMBuildNSWShl(g->builder, op1_value, op2_casted, "");3070 return ZigLLVMBuildNSWShl(g->builder, op1_value, op2_casted, "");
2982 } else {3071 } else {
...@@ -2987,7 +3076,8 @@ static LLVMValueRef ir_render_bin_op(CodeGen *g, IrExecutableGen *executable,...@@ -2987,7 +3076,8 @@ static LLVMValueRef ir_render_bin_op(CodeGen *g, IrExecutableGen *executable,
2987 case IrBinOpBitShiftRightExact:3076 case IrBinOpBitShiftRightExact:
2988 {3077 {
2989 assert(scalar_type->id == ZigTypeIdInt);3078 assert(scalar_type->id == ZigTypeIdInt);
2990 LLVMValueRef op2_casted = gen_widen_or_shorten(g, false, op2->value->type, scalar_type, op2_value);3079 LLVMValueRef op2_casted = LLVMBuildZExt(g->builder, op2_value,
3080 LLVMTypeOf(op1_value), "");
29913081
2992 if (want_runtime_safety) {3082 if (want_runtime_safety) {
2993 gen_shift_rhs_check(g, scalar_type, op2->value->type, op2_value);3083 gen_shift_rhs_check(g, scalar_type, op2->value->type, op2_value);
...@@ -3001,7 +3091,7 @@ static LLVMValueRef ir_render_bin_op(CodeGen *g, IrExecutableGen *executable,...@@ -3001,7 +3091,7 @@ static LLVMValueRef ir_render_bin_op(CodeGen *g, IrExecutableGen *executable,
3001 return LLVMBuildLShr(g->builder, op1_value, op2_casted, "");3091 return LLVMBuildLShr(g->builder, op1_value, op2_casted, "");
3002 }3092 }
3003 } else if (want_runtime_safety) {3093 } else if (want_runtime_safety) {
3004 return gen_overflow_shr_op(g, scalar_type, op1_value, op2_casted);3094 return gen_overflow_shr_op(g, operand_type, op1_value, op2_casted);
3005 } else if (scalar_type->data.integral.is_signed) {3095 } else if (scalar_type->data.integral.is_signed) {
3006 return ZigLLVMBuildAShrExact(g->builder, op1_value, op2_casted, "");3096 return ZigLLVMBuildAShrExact(g->builder, op1_value, op2_casted, "");
3007 } else {3097 } else {
...@@ -3010,22 +3100,22 @@ static LLVMValueRef ir_render_bin_op(CodeGen *g, IrExecutableGen *executable,...@@ -3010,22 +3100,22 @@ static LLVMValueRef ir_render_bin_op(CodeGen *g, IrExecutableGen *executable,
3010 }3100 }
3011 case IrBinOpDivUnspecified:3101 case IrBinOpDivUnspecified:
3012 return gen_div(g, want_runtime_safety, ir_want_fast_math(g, &bin_op_instruction->base),3102 return gen_div(g, want_runtime_safety, ir_want_fast_math(g, &bin_op_instruction->base),
3013 op1_value, op2_value, scalar_type, DivKindFloat);3103 op1_value, op2_value, operand_type, DivKindFloat);
3014 case IrBinOpDivExact:3104 case IrBinOpDivExact:
3015 return gen_div(g, want_runtime_safety, ir_want_fast_math(g, &bin_op_instruction->base),3105 return gen_div(g, want_runtime_safety, ir_want_fast_math(g, &bin_op_instruction->base),
3016 op1_value, op2_value, scalar_type, DivKindExact);3106 op1_value, op2_value, operand_type, DivKindExact);
3017 case IrBinOpDivTrunc:3107 case IrBinOpDivTrunc:
3018 return gen_div(g, want_runtime_safety, ir_want_fast_math(g, &bin_op_instruction->base),3108 return gen_div(g, want_runtime_safety, ir_want_fast_math(g, &bin_op_instruction->base),
3019 op1_value, op2_value, scalar_type, DivKindTrunc);3109 op1_value, op2_value, operand_type, DivKindTrunc);
3020 case IrBinOpDivFloor:3110 case IrBinOpDivFloor:
3021 return gen_div(g, want_runtime_safety, ir_want_fast_math(g, &bin_op_instruction->base),3111 return gen_div(g, want_runtime_safety, ir_want_fast_math(g, &bin_op_instruction->base),
3022 op1_value, op2_value, scalar_type, DivKindFloor);3112 op1_value, op2_value, operand_type, DivKindFloor);
3023 case IrBinOpRemRem:3113 case IrBinOpRemRem:
3024 return gen_rem(g, want_runtime_safety, ir_want_fast_math(g, &bin_op_instruction->base),3114 return gen_rem(g, want_runtime_safety, ir_want_fast_math(g, &bin_op_instruction->base),
3025 op1_value, op2_value, scalar_type, RemKindRem);3115 op1_value, op2_value, operand_type, RemKindRem);
3026 case IrBinOpRemMod:3116 case IrBinOpRemMod:
3027 return gen_rem(g, want_runtime_safety, ir_want_fast_math(g, &bin_op_instruction->base),3117 return gen_rem(g, want_runtime_safety, ir_want_fast_math(g, &bin_op_instruction->base),
3028 op1_value, op2_value, scalar_type, RemKindMod);3118 op1_value, op2_value, operand_type, RemKindMod);
3029 }3119 }
3030 zig_unreachable();3120 zig_unreachable();
3031}3121}
...@@ -5008,7 +5098,7 @@ static LLVMValueRef get_enum_tag_name_function(CodeGen *g, ZigType *enum_type) {...@@ -5008,7 +5098,7 @@ static LLVMValueRef get_enum_tag_name_function(CodeGen *g, ZigType *enum_type) {
5008 &tag_int_llvm_type, 1, false);5098 &tag_int_llvm_type, 1, false);
50095099
5010 const char *fn_name = get_mangled_name(g,5100 const char *fn_name = get_mangled_name(g,
5011 buf_ptr(buf_sprintf("__zig_tag_name_%s", buf_ptr(&enum_type->name))), false);5101 buf_ptr(buf_sprintf("__zig_tag_name_%s", buf_ptr(&enum_type->name))));
5012 LLVMValueRef fn_val = LLVMAddFunction(g->module, fn_name, fn_type_ref);5102 LLVMValueRef fn_val = LLVMAddFunction(g->module, fn_name, fn_type_ref);
5013 LLVMSetLinkage(fn_val, LLVMInternalLinkage);5103 LLVMSetLinkage(fn_val, LLVMInternalLinkage);
5014 ZigLLVMFunctionSetCallingConv(fn_val, get_llvm_cc(g, CallingConventionUnspecified));5104 ZigLLVMFunctionSetCallingConv(fn_val, get_llvm_cc(g, CallingConventionUnspecified));
...@@ -5408,6 +5498,8 @@ static LLVMValueRef ir_render_memcpy(CodeGen *g, IrExecutableGen *executable, Ir...@@ -5408,6 +5498,8 @@ static LLVMValueRef ir_render_memcpy(CodeGen *g, IrExecutableGen *executable, Ir
5408}5498}
54095499
5410static LLVMValueRef ir_render_slice(CodeGen *g, IrExecutableGen *executable, IrInstGenSlice *instruction) {5500static LLVMValueRef ir_render_slice(CodeGen *g, IrExecutableGen *executable, IrInstGenSlice *instruction) {
5501 Error err;
5502
5411 LLVMValueRef array_ptr_ptr = ir_llvm_value(g, instruction->ptr);5503 LLVMValueRef array_ptr_ptr = ir_llvm_value(g, instruction->ptr);
5412 ZigType *array_ptr_type = instruction->ptr->value->type;5504 ZigType *array_ptr_type = instruction->ptr->value->type;
5413 assert(array_ptr_type->id == ZigTypeIdPointer);5505 assert(array_ptr_type->id == ZigTypeIdPointer);
...@@ -5416,15 +5508,16 @@ static LLVMValueRef ir_render_slice(CodeGen *g, IrExecutableGen *executable, IrI...@@ -5416,15 +5508,16 @@ static LLVMValueRef ir_render_slice(CodeGen *g, IrExecutableGen *executable, IrI
54165508
5417 bool want_runtime_safety = instruction->safety_check_on && ir_want_runtime_safety(g, &instruction->base);5509 bool want_runtime_safety = instruction->safety_check_on && ir_want_runtime_safety(g, &instruction->base);
54185510
5511 // The result is either a slice or a pointer to an array
5419 ZigType *result_type = instruction->base.value->type;5512 ZigType *result_type = instruction->base.value->type;
5420 if (!type_has_bits(g, result_type)) {
5421 return nullptr;
5422 }
54235513
5424 // This is not whether the result type has a sentinel, but whether there should be a sentinel check,5514 // This is not whether the result type has a sentinel, but whether there should be a sentinel check,
5425 // e.g. if they used [a..b :s] syntax.5515 // e.g. if they used [a..b :s] syntax.
5426 ZigValue *sentinel = instruction->sentinel;5516 ZigValue *sentinel = instruction->sentinel;
54275517
5518 LLVMValueRef slice_start_ptr = nullptr;
5519 LLVMValueRef len_value = nullptr;
5520
5428 if (array_type->id == ZigTypeIdArray ||5521 if (array_type->id == ZigTypeIdArray ||
5429 (array_type->id == ZigTypeIdPointer && array_type->data.pointer.ptr_len == PtrLenSingle))5522 (array_type->id == ZigTypeIdPointer && array_type->data.pointer.ptr_len == PtrLenSingle))
5430 {5523 {
...@@ -5438,111 +5531,86 @@ static LLVMValueRef ir_render_slice(CodeGen *g, IrExecutableGen *executable, IrI...@@ -5438,111 +5531,86 @@ static LLVMValueRef ir_render_slice(CodeGen *g, IrExecutableGen *executable, IrI
5438 } else {5531 } else {
5439 end_val = LLVMConstInt(g->builtin_types.entry_usize->llvm_type, array_type->data.array.len, false);5532 end_val = LLVMConstInt(g->builtin_types.entry_usize->llvm_type, array_type->data.array.len, false);
5440 }5533 }
5534
5441 if (want_runtime_safety) {5535 if (want_runtime_safety) {
5536 // Safety check: start <= end
5442 if (instruction->start->value->special == ConstValSpecialRuntime || instruction->end) {5537 if (instruction->start->value->special == ConstValSpecialRuntime || instruction->end) {
5443 add_bounds_check(g, start_val, LLVMIntEQ, nullptr, LLVMIntULE, end_val);5538 add_bounds_check(g, start_val, LLVMIntEQ, nullptr, LLVMIntULE, end_val);
5444 }5539 }
5445 if (instruction->end) {
5446 LLVMValueRef array_end = LLVMConstInt(g->builtin_types.entry_usize->llvm_type,
5447 array_type->data.array.len, false);
5448 add_bounds_check(g, end_val, LLVMIntEQ, nullptr, LLVMIntULE, array_end);
54495540
5450 if (sentinel != nullptr) {5541 // Safety check: the last element of the slice (the sentinel if
5451 LLVMValueRef indices[] = {5542 // requested) must be inside the array
5452 LLVMConstNull(g->builtin_types.entry_usize->llvm_type),5543 // XXX: Overflow is not checked here...
5453 end_val,5544 const size_t full_len = array_type->data.array.len +
5454 };5545 (array_type->data.array.sentinel != nullptr);
5455 LLVMValueRef sentinel_elem_ptr = LLVMBuildInBoundsGEP(g->builder, array_ptr, indices, 2, "");5546 LLVMValueRef array_end = LLVMConstInt(g->builtin_types.entry_usize->llvm_type,
5456 add_sentinel_check(g, sentinel_elem_ptr, sentinel);5547 full_len, false);
5457 }
5458 }
5459 }
5460 if (!type_has_bits(g, array_type)) {
5461 LLVMValueRef tmp_struct_ptr = ir_llvm_value(g, instruction->result_loc);
5462
5463 LLVMValueRef len_field_ptr = LLVMBuildStructGEP(g->builder, tmp_struct_ptr, slice_len_index, "");
54645548
5465 // TODO if runtime safety is on, store 0xaaaaaaa in ptr field5549 LLVMValueRef check_end_val = end_val;
5466 LLVMValueRef len_value = LLVMBuildNSWSub(g->builder, end_val, start_val, "");5550 if (sentinel != nullptr) {
5467 gen_store_untyped(g, len_value, len_field_ptr, 0, false);5551 LLVMValueRef usize_one = LLVMConstInt(g->builtin_types.entry_usize->llvm_type, 1, false);
5468 return tmp_struct_ptr;5552 check_end_val = LLVMBuildNUWAdd(g->builder, end_val, usize_one, "");
5553 }
5554 add_bounds_check(g, check_end_val, LLVMIntEQ, nullptr, LLVMIntULE, array_end);
5469 }5555 }
54705556
5471 LLVMValueRef indices[] = {5557 bool value_has_bits;
5472 LLVMConstNull(g->builtin_types.entry_usize->llvm_type),5558 if ((err = type_has_bits2(g, array_type, &value_has_bits)))
5473 start_val,5559 codegen_report_errors_and_exit(g);
5474 };
5475 LLVMValueRef slice_start_ptr = LLVMBuildInBoundsGEP(g->builder, array_ptr, indices, 2, "");
5476 if (result_type->id == ZigTypeIdPointer) {
5477 ir_assert(instruction->result_loc == nullptr, &instruction->base);
5478 LLVMTypeRef result_ptr_type = get_llvm_type(g, result_type);
5479 return LLVMBuildBitCast(g->builder, slice_start_ptr, result_ptr_type, "");
5480 } else {
5481 LLVMValueRef tmp_struct_ptr = ir_llvm_value(g, instruction->result_loc);
5482 LLVMValueRef ptr_field_ptr = LLVMBuildStructGEP(g->builder, tmp_struct_ptr, slice_ptr_index, "");
5483 gen_store_untyped(g, slice_start_ptr, ptr_field_ptr, 0, false);
54845560
5485 LLVMValueRef len_field_ptr = LLVMBuildStructGEP(g->builder, tmp_struct_ptr, slice_len_index, "");5561 if (value_has_bits) {
5486 LLVMValueRef len_value = LLVMBuildNSWSub(g->builder, end_val, start_val, "");5562 if (want_runtime_safety && sentinel != nullptr) {
5487 gen_store_untyped(g, len_value, len_field_ptr, 0, false);5563 LLVMValueRef indices[] = {
5564 LLVMConstNull(g->builtin_types.entry_usize->llvm_type),
5565 end_val,
5566 };
5567 LLVMValueRef sentinel_elem_ptr = LLVMBuildInBoundsGEP(g->builder, array_ptr, indices, 2, "");
5568 add_sentinel_check(g, sentinel_elem_ptr, sentinel);
5569 }
54885570
5489 return tmp_struct_ptr;5571 LLVMValueRef indices[] = {
5572 LLVMConstNull(g->builtin_types.entry_usize->llvm_type),
5573 start_val,
5574 };
5575 slice_start_ptr = LLVMBuildInBoundsGEP(g->builder, array_ptr, indices, 2, "");
5490 }5576 }
5577
5578 len_value = LLVMBuildNUWSub(g->builder, end_val, start_val, "");
5491 } else if (array_type->id == ZigTypeIdPointer) {5579 } else if (array_type->id == ZigTypeIdPointer) {
5492 assert(array_type->data.pointer.ptr_len != PtrLenSingle);5580 assert(array_type->data.pointer.ptr_len != PtrLenSingle);
5493 LLVMValueRef start_val = ir_llvm_value(g, instruction->start);5581 LLVMValueRef start_val = ir_llvm_value(g, instruction->start);
5494 LLVMValueRef end_val = ir_llvm_value(g, instruction->end);5582 LLVMValueRef end_val = ir_llvm_value(g, instruction->end);
54955583
5496 if (want_runtime_safety) {5584 if (want_runtime_safety) {
5585 // Safety check: start <= end
5497 add_bounds_check(g, start_val, LLVMIntEQ, nullptr, LLVMIntULE, end_val);5586 add_bounds_check(g, start_val, LLVMIntEQ, nullptr, LLVMIntULE, end_val);
5498 if (sentinel != nullptr) {5587 }
5588
5589 bool value_has_bits;
5590 if ((err = type_has_bits2(g, array_type, &value_has_bits)))
5591 codegen_report_errors_and_exit(g);
5592
5593 if (value_has_bits) {
5594 if (want_runtime_safety && sentinel != nullptr) {
5499 LLVMValueRef sentinel_elem_ptr = LLVMBuildInBoundsGEP(g->builder, array_ptr, &end_val, 1, "");5595 LLVMValueRef sentinel_elem_ptr = LLVMBuildInBoundsGEP(g->builder, array_ptr, &end_val, 1, "");
5500 add_sentinel_check(g, sentinel_elem_ptr, sentinel);5596 add_sentinel_check(g, sentinel_elem_ptr, sentinel);
5501 }5597 }
5502 }
55035598
5504 if (!type_has_bits(g, array_type)) {5599 slice_start_ptr = LLVMBuildInBoundsGEP(g->builder, array_ptr, &start_val, 1, "");
5505 LLVMValueRef tmp_struct_ptr = ir_llvm_value(g, instruction->result_loc);
5506 size_t gen_len_index = result_type->data.structure.fields[slice_len_index]->gen_index;
5507 LLVMValueRef len_field_ptr = LLVMBuildStructGEP(g->builder, tmp_struct_ptr, gen_len_index, "");
5508 LLVMValueRef len_value = LLVMBuildNSWSub(g->builder, end_val, start_val, "");
5509 gen_store_untyped(g, len_value, len_field_ptr, 0, false);
5510 return tmp_struct_ptr;
5511 }
5512
5513 LLVMValueRef slice_start_ptr = LLVMBuildInBoundsGEP(g->builder, array_ptr, &start_val, 1, "");
5514 if (result_type->id == ZigTypeIdPointer) {
5515 ir_assert(instruction->result_loc == nullptr, &instruction->base);
5516 LLVMTypeRef result_ptr_type = get_llvm_type(g, result_type);
5517 return LLVMBuildBitCast(g->builder, slice_start_ptr, result_ptr_type, "");
5518 }5600 }
55195601
5520 LLVMValueRef tmp_struct_ptr = ir_llvm_value(g, instruction->result_loc);5602 len_value = LLVMBuildNUWSub(g->builder, end_val, start_val, "");
5521
5522 size_t gen_ptr_index = result_type->data.structure.fields[slice_ptr_index]->gen_index;
5523 LLVMValueRef ptr_field_ptr = LLVMBuildStructGEP(g->builder, tmp_struct_ptr, gen_ptr_index, "");
5524 gen_store_untyped(g, slice_start_ptr, ptr_field_ptr, 0, false);
5525
5526 size_t gen_len_index = result_type->data.structure.fields[slice_len_index]->gen_index;
5527 LLVMValueRef len_field_ptr = LLVMBuildStructGEP(g->builder, tmp_struct_ptr, gen_len_index, "");
5528 LLVMValueRef len_value = LLVMBuildNSWSub(g->builder, end_val, start_val, "");
5529 gen_store_untyped(g, len_value, len_field_ptr, 0, false);
5530
5531 return tmp_struct_ptr;
5532
5533 } else if (array_type->id == ZigTypeIdStruct) {5603 } else if (array_type->id == ZigTypeIdStruct) {
5534 assert(array_type->data.structure.special == StructSpecialSlice);5604 assert(array_type->data.structure.special == StructSpecialSlice);
5535 assert(LLVMGetTypeKind(LLVMTypeOf(array_ptr)) == LLVMPointerTypeKind);5605 assert(LLVMGetTypeKind(LLVMTypeOf(array_ptr)) == LLVMPointerTypeKind);
5536 assert(LLVMGetTypeKind(LLVMGetElementType(LLVMTypeOf(array_ptr))) == LLVMStructTypeKind);5606 assert(LLVMGetTypeKind(LLVMGetElementType(LLVMTypeOf(array_ptr))) == LLVMStructTypeKind);
55375607
5538 size_t ptr_index = array_type->data.structure.fields[slice_ptr_index]->gen_index;5608 const size_t gen_len_index = array_type->data.structure.fields[slice_len_index]->gen_index;
5539 assert(ptr_index != SIZE_MAX);5609 assert(gen_len_index != SIZE_MAX);
5540 size_t len_index = array_type->data.structure.fields[slice_len_index]->gen_index;
5541 assert(len_index != SIZE_MAX);
55425610
5543 LLVMValueRef prev_end = nullptr;5611 LLVMValueRef prev_end = nullptr;
5544 if (!instruction->end || want_runtime_safety) {5612 if (!instruction->end || want_runtime_safety) {
5545 LLVMValueRef src_len_ptr = LLVMBuildStructGEP(g->builder, array_ptr, (unsigned)len_index, "");5613 LLVMValueRef src_len_ptr = LLVMBuildStructGEP(g->builder, array_ptr, gen_len_index, "");
5546 prev_end = gen_load_untyped(g, src_len_ptr, 0, false, "");5614 prev_end = gen_load_untyped(g, src_len_ptr, 0, false, "");
5547 }5615 }
55485616
...@@ -5554,41 +5622,104 @@ static LLVMValueRef ir_render_slice(CodeGen *g, IrExecutableGen *executable, IrI...@@ -5554,41 +5622,104 @@ static LLVMValueRef ir_render_slice(CodeGen *g, IrExecutableGen *executable, IrI
5554 end_val = prev_end;5622 end_val = prev_end;
5555 }5623 }
55565624
5557 LLVMValueRef src_ptr_ptr = LLVMBuildStructGEP(g->builder, array_ptr, (unsigned)ptr_index, "");5625 ZigType *ptr_field_type = array_type->data.structure.fields[slice_ptr_index]->type_entry;
5558 LLVMValueRef src_ptr = gen_load_untyped(g, src_ptr_ptr, 0, false, "");
55595626
5560 if (want_runtime_safety) {5627 if (want_runtime_safety) {
5561 assert(prev_end);5628 assert(prev_end);
5629 // Safety check: start <= end
5562 add_bounds_check(g, start_val, LLVMIntEQ, nullptr, LLVMIntULE, end_val);5630 add_bounds_check(g, start_val, LLVMIntEQ, nullptr, LLVMIntULE, end_val);
5563 if (instruction->end) {
5564 add_bounds_check(g, end_val, LLVMIntEQ, nullptr, LLVMIntULE, prev_end);
55655631
5566 if (sentinel != nullptr) {5632 // Safety check: the sentinel counts as one more element
5567 LLVMValueRef sentinel_elem_ptr = LLVMBuildInBoundsGEP(g->builder, src_ptr, &end_val, 1, "");5633 // XXX: Overflow is not checked here...
5568 add_sentinel_check(g, sentinel_elem_ptr, sentinel);5634 LLVMValueRef check_prev_end = prev_end;
5569 }5635 if (ptr_field_type->data.pointer.sentinel != nullptr) {
5636 LLVMValueRef usize_one = LLVMConstInt(g->builtin_types.entry_usize->llvm_type, 1, false);
5637 check_prev_end = LLVMBuildNUWAdd(g->builder, prev_end, usize_one, "");
5638 }
5639 LLVMValueRef check_end_val = end_val;
5640 if (sentinel != nullptr) {
5641 LLVMValueRef usize_one = LLVMConstInt(g->builtin_types.entry_usize->llvm_type, 1, false);
5642 check_end_val = LLVMBuildNUWAdd(g->builder, end_val, usize_one, "");
5570 }5643 }
5644
5645 add_bounds_check(g, check_end_val, LLVMIntEQ, nullptr, LLVMIntULE, check_prev_end);
5571 }5646 }
55725647
5573 LLVMValueRef slice_start_ptr = LLVMBuildInBoundsGEP(g->builder, src_ptr, &start_val, 1, "");5648 bool ptr_has_bits;
5574 if (result_type->id == ZigTypeIdPointer) {5649 if ((err = type_has_bits2(g, ptr_field_type, &ptr_has_bits)))
5575 ir_assert(instruction->result_loc == nullptr, &instruction->base);5650 codegen_report_errors_and_exit(g);
5576 LLVMTypeRef result_ptr_type = get_llvm_type(g, result_type);
5577 return LLVMBuildBitCast(g->builder, slice_start_ptr, result_ptr_type, "");
5578 } else {
5579 LLVMValueRef tmp_struct_ptr = ir_llvm_value(g, instruction->result_loc);
5580 LLVMValueRef ptr_field_ptr = LLVMBuildStructGEP(g->builder, tmp_struct_ptr, (unsigned)ptr_index, "");
5581 gen_store_untyped(g, slice_start_ptr, ptr_field_ptr, 0, false);
55825651
5583 LLVMValueRef len_field_ptr = LLVMBuildStructGEP(g->builder, tmp_struct_ptr, (unsigned)len_index, "");5652 if (ptr_has_bits) {
5584 LLVMValueRef len_value = LLVMBuildNSWSub(g->builder, end_val, start_val, "");5653 const size_t gen_ptr_index = array_type->data.structure.fields[slice_ptr_index]->gen_index;
5585 gen_store_untyped(g, len_value, len_field_ptr, 0, false);5654 assert(gen_ptr_index != SIZE_MAX);
55865655
5587 return tmp_struct_ptr;5656 LLVMValueRef src_ptr_ptr = LLVMBuildStructGEP(g->builder, array_ptr, gen_ptr_index, "");
5657 LLVMValueRef src_ptr = gen_load_untyped(g, src_ptr_ptr, 0, false, "");
5658
5659 if (sentinel != nullptr) {
5660 LLVMValueRef sentinel_elem_ptr = LLVMBuildInBoundsGEP(g->builder, src_ptr, &end_val, 1, "");
5661 add_sentinel_check(g, sentinel_elem_ptr, sentinel);
5662 }
5663
5664 slice_start_ptr = LLVMBuildInBoundsGEP(g->builder, src_ptr, &start_val, 1, "");
5588 }5665 }
5666
5667 len_value = LLVMBuildNUWSub(g->builder, end_val, start_val, "");
5589 } else {5668 } else {
5590 zig_unreachable();5669 zig_unreachable();
5591 }5670 }
5671
5672 bool result_has_bits;
5673 if ((err = type_has_bits2(g, result_type, &result_has_bits)))
5674 codegen_report_errors_and_exit(g);
5675
5676 // Nothing to do, we're only interested in the bound checks emitted above
5677 if (!result_has_bits)
5678 return nullptr;
5679
5680 // The starting pointer for the slice may be null in case of zero-sized
5681 // arrays, the length value is always defined.
5682 assert(len_value != nullptr);
5683
5684 // The slice decays into a pointer to an array, the size is tracked in the
5685 // type itself
5686 if (result_type->id == ZigTypeIdPointer) {
5687 ir_assert(instruction->result_loc == nullptr, &instruction->base);
5688 LLVMTypeRef result_ptr_type = get_llvm_type(g, result_type);
5689
5690 if (slice_start_ptr != nullptr) {
5691 return LLVMBuildBitCast(g->builder, slice_start_ptr, result_ptr_type, "");
5692 }
5693
5694 return LLVMGetUndef(result_ptr_type);
5695 }
5696
5697 ir_assert(instruction->result_loc != nullptr, &instruction->base);
5698 // Create a new slice
5699 LLVMValueRef tmp_struct_ptr = ir_llvm_value(g, instruction->result_loc);
5700
5701 ZigType *slice_ptr_type = result_type->data.structure.fields[slice_ptr_index]->type_entry;
5702
5703 // The slice may not have a pointer at all if it points to a zero-sized type
5704 const size_t gen_ptr_index = result_type->data.structure.fields[slice_ptr_index]->gen_index;
5705 if (gen_ptr_index != SIZE_MAX) {
5706 LLVMValueRef ptr_field_ptr = LLVMBuildStructGEP(g->builder, tmp_struct_ptr, gen_ptr_index, "");
5707 if (slice_start_ptr != nullptr) {
5708 gen_store_untyped(g, slice_start_ptr, ptr_field_ptr, 0, false);
5709 } else if (want_runtime_safety) {
5710 gen_undef_init(g, slice_ptr_type->abi_align, slice_ptr_type, ptr_field_ptr);
5711 } else {
5712 gen_store_untyped(g, LLVMGetUndef(get_llvm_type(g, slice_ptr_type)), ptr_field_ptr, 0, false);
5713 }
5714 }
5715
5716 const size_t gen_len_index = result_type->data.structure.fields[slice_len_index]->gen_index;
5717 assert(gen_len_index != SIZE_MAX);
5718
5719 LLVMValueRef len_field_ptr = LLVMBuildStructGEP(g->builder, tmp_struct_ptr, gen_len_index, "");
5720 gen_store_untyped(g, len_value, len_field_ptr, 0, false);
5721
5722 return tmp_struct_ptr;
5592}5723}
55935724
5594static LLVMValueRef get_trap_fn_val(CodeGen *g) {5725static LLVMValueRef get_trap_fn_val(CodeGen *g) {
...@@ -7497,7 +7628,7 @@ static void generate_error_name_table(CodeGen *g) {...@@ -7497,7 +7628,7 @@ static void generate_error_name_table(CodeGen *g) {
7497 LLVMValueRef err_name_table_init = LLVMConstArray(get_llvm_type(g, str_type), values, (unsigned)g->errors_by_index.length);7628 LLVMValueRef err_name_table_init = LLVMConstArray(get_llvm_type(g, str_type), values, (unsigned)g->errors_by_index.length);
74987629
7499 g->err_name_table = LLVMAddGlobal(g->module, LLVMTypeOf(err_name_table_init),7630 g->err_name_table = LLVMAddGlobal(g->module, LLVMTypeOf(err_name_table_init),
7500 get_mangled_name(g, buf_ptr(buf_create_from_str("__zig_err_name_table")), false));7631 get_mangled_name(g, buf_ptr(buf_create_from_str("__zig_err_name_table"))));
7501 LLVMSetInitializer(g->err_name_table, err_name_table_init);7632 LLVMSetInitializer(g->err_name_table, err_name_table_init);
7502 LLVMSetLinkage(g->err_name_table, LLVMPrivateLinkage);7633 LLVMSetLinkage(g->err_name_table, LLVMPrivateLinkage);
7503 LLVMSetGlobalConstant(g->err_name_table, true);7634 LLVMSetGlobalConstant(g->err_name_table, true);
...@@ -7628,7 +7759,7 @@ static void do_code_gen(CodeGen *g) {...@@ -7628,7 +7759,7 @@ static void do_code_gen(CodeGen *g) {
7628 symbol_name = unmangled_name;7759 symbol_name = unmangled_name;
7629 linkage = GlobalLinkageIdStrong;7760 linkage = GlobalLinkageIdStrong;
7630 } else {7761 } else {
7631 symbol_name = get_mangled_name(g, unmangled_name, false);7762 symbol_name = get_mangled_name(g, unmangled_name);
7632 linkage = GlobalLinkageIdInternal;7763 linkage = GlobalLinkageIdInternal;
7633 }7764 }
7634 } else {7765 } else {
...@@ -8940,10 +9071,24 @@ static void init(CodeGen *g) {...@@ -8940,10 +9071,24 @@ static void init(CodeGen *g) {
8940 fprintf(stderr, "name=%s target_specific_cpu_args=%s\n", buf_ptr(g->root_out_name), target_specific_cpu_args);9071 fprintf(stderr, "name=%s target_specific_cpu_args=%s\n", buf_ptr(g->root_out_name), target_specific_cpu_args);
8941 fprintf(stderr, "name=%s target_specific_features=%s\n", buf_ptr(g->root_out_name), target_specific_features);9072 fprintf(stderr, "name=%s target_specific_features=%s\n", buf_ptr(g->root_out_name), target_specific_features);
8942 }9073 }
9074
9075 // TODO handle float ABI better- it should depend on the ABI portion of std.Target
9076 ZigLLVMABIType float_abi = ZigLLVMABITypeDefault;
9077
9078 // TODO a way to override this as part of std.Target ABI?
9079 const char *abi_name = nullptr;
9080 if (target_is_riscv(g->zig_target)) {
9081 // RISC-V Linux defaults to ilp32d/lp64d
9082 if (g->zig_target->os == OsLinux) {
9083 abi_name = (g->zig_target->arch == ZigLLVM_riscv32) ? "ilp32d" : "lp64d";
9084 } else {
9085 abi_name = (g->zig_target->arch == ZigLLVM_riscv32) ? "ilp32" : "lp64";
9086 }
9087 }
8943 9088
8944 g->target_machine = ZigLLVMCreateTargetMachine(target_ref, buf_ptr(&g->llvm_triple_str),9089 g->target_machine = ZigLLVMCreateTargetMachine(target_ref, buf_ptr(&g->llvm_triple_str),
8945 target_specific_cpu_args, target_specific_features, opt_level, reloc_mode,9090 target_specific_cpu_args, target_specific_features, opt_level, reloc_mode,
8946 to_llvm_code_model(g), g->function_sections);9091 to_llvm_code_model(g), g->function_sections, float_abi, abi_name);
89479092
8948 g->target_data_ref = LLVMCreateTargetDataLayout(g->target_machine);9093 g->target_data_ref = LLVMCreateTargetDataLayout(g->target_machine);
89499094
...@@ -9043,80 +9188,13 @@ static void detect_libc(CodeGen *g) {...@@ -9043,80 +9188,13 @@ static void detect_libc(CodeGen *g) {
9043 if (g->zig_target->is_native_os) {9188 if (g->zig_target->is_native_os) {
9044 g->libc = heap::c_allocator.create<Stage2LibCInstallation>();9189 g->libc = heap::c_allocator.create<Stage2LibCInstallation>();
90459190
9046 // search for native_libc.txt in following dirs:9191 if ((err = stage2_libc_find_native(g->libc))) {
9047 // - LOCAL_CACHE_DIR9192 fprintf(stderr,
9048 // - GLOBAL_CACHE_DIR9193 "Unable to link against libc: Unable to find libc installation: %s\n"
9049 // if not found create at:9194 "See `zig libc --help` for more details.\n", err_str(err));
9050 // - GLOBAL_CACHE_DIR9195 exit(1);
9051 // be mindful local/global caches may be the same dir
9052
9053 Buf basename = BUF_INIT;
9054 buf_init_from_str(&basename, "native_libc.txt");
9055
9056 Buf local_libc_txt = BUF_INIT;
9057 os_path_join(g->cache_dir, &basename, &local_libc_txt);
9058
9059 Buf global_libc_txt = BUF_INIT;
9060 os_path_join(get_global_cache_dir(), &basename, &global_libc_txt);
9061
9062 Buf *pathnames[3] = { nullptr };
9063 size_t pathnames_idx = 0;
9064
9065 pathnames[pathnames_idx] = &local_libc_txt;
9066 pathnames_idx += 1;
9067
9068 if (!buf_eql_buf(pathnames[0], &global_libc_txt)) {
9069 pathnames[pathnames_idx] = &global_libc_txt;
9070 pathnames_idx += 1;
9071 }
9072
9073 Buf* libc_txt = nullptr;
9074 for (auto name : pathnames) {
9075 if (name == nullptr)
9076 break;
9077
9078 bool result;
9079 if (os_file_exists(name, &result) != ErrorNone || !result)
9080 continue;
9081
9082 libc_txt = name;
9083 break;
9084 }9196 }
90859197
9086 if (libc_txt == nullptr)
9087 libc_txt = &global_libc_txt;
9088
9089 if ((err = stage2_libc_parse(g->libc, buf_ptr(libc_txt)))) {
9090 if ((err = stage2_libc_find_native(g->libc))) {
9091 fprintf(stderr,
9092 "Unable to link against libc: Unable to find libc installation: %s\n"
9093 "See `zig libc --help` for more details.\n", err_str(err));
9094 exit(1);
9095 }
9096 Buf libc_txt_dir = BUF_INIT;
9097 os_path_dirname(libc_txt, &libc_txt_dir);
9098 buf_deinit(&libc_txt_dir);
9099 if ((err = os_make_path(&libc_txt_dir))) {
9100 fprintf(stderr, "Unable to create %s directory: %s\n",
9101 buf_ptr(g->cache_dir), err_str(err));
9102 exit(1);
9103 }
9104 Buf *native_libc_tmp = buf_sprintf("%s.tmp", buf_ptr(libc_txt));
9105 FILE *file = fopen(buf_ptr(native_libc_tmp), "wb");
9106 if (file == nullptr) {
9107 fprintf(stderr, "Unable to open %s: %s\n", buf_ptr(native_libc_tmp), strerror(errno));
9108 exit(1);
9109 }
9110 stage2_libc_render(g->libc, file);
9111 if (fclose(file) != 0) {
9112 fprintf(stderr, "Unable to save %s: %s\n", buf_ptr(native_libc_tmp), strerror(errno));
9113 exit(1);
9114 }
9115 if ((err = os_rename(native_libc_tmp, libc_txt))) {
9116 fprintf(stderr, "Unable to create %s: %s\n", buf_ptr(libc_txt), err_str(err));
9117 exit(1);
9118 }
9119 }
9120 bool want_sys_dir = !mem_eql_mem(g->libc->include_dir, g->libc->include_dir_len,9198 bool want_sys_dir = !mem_eql_mem(g->libc->include_dir, g->libc->include_dir_len,
9121 g->libc->sys_include_dir, g->libc->sys_include_dir_len);9199 g->libc->sys_include_dir, g->libc->sys_include_dir_len);
9122 size_t want_um_and_shared_dirs = (g->zig_target->os == OsWindows) ? 2 : 0;9200 size_t want_um_and_shared_dirs = (g->zig_target->os == OsWindows) ? 2 : 0;
...@@ -9150,10 +9228,6 @@ static void detect_libc(CodeGen *g) {...@@ -9150,10 +9228,6 @@ static void detect_libc(CodeGen *g) {
9150 g->libc_include_dir_len += 1;9228 g->libc_include_dir_len += 1;
9151 }9229 }
9152 assert(g->libc_include_dir_len == dir_count);9230 assert(g->libc_include_dir_len == dir_count);
9153
9154 buf_deinit(&global_libc_txt);
9155 buf_deinit(&local_libc_txt);
9156 buf_deinit(&basename);
9157 } else if ((g->out_type == OutTypeExe || (g->out_type == OutTypeLib && g->is_dynamic)) &&9231 } else if ((g->out_type == OutTypeExe || (g->out_type == OutTypeLib && g->is_dynamic)) &&
9158 !target_os_is_darwin(g->zig_target->os))9232 !target_os_is_darwin(g->zig_target->os))
9159 {9233 {
...@@ -10563,6 +10637,7 @@ static Error check_cache(CodeGen *g, Buf *manifest_dir, Buf *digest) {...@@ -10563,6 +10637,7 @@ static Error check_cache(CodeGen *g, Buf *manifest_dir, Buf *digest) {
10563 cache_int(ch, g->linker_allow_shlib_undefined);10637 cache_int(ch, g->linker_allow_shlib_undefined);
10564 cache_bool(ch, g->linker_z_nodelete);10638 cache_bool(ch, g->linker_z_nodelete);
10565 cache_bool(ch, g->linker_z_defs);10639 cache_bool(ch, g->linker_z_defs);
10640 cache_usize(ch, g->stack_size_override);
1056610641
10567 // gen_c_objects appends objects to g->link_objects which we want to include in the hash10642 // gen_c_objects appends objects to g->link_objects which we want to include in the hash
10568 gen_c_objects(g);10643 gen_c_objects(g);
...@@ -10919,7 +10994,7 @@ CodeGen *codegen_create(Buf *main_pkg_path, Buf *root_src_path, const ZigTarget...@@ -10919,7 +10994,7 @@ CodeGen *codegen_create(Buf *main_pkg_path, Buf *root_src_path, const ZigTarget
10919 g->llvm_fn_table.init(16);10994 g->llvm_fn_table.init(16);
10920 g->memoized_fn_eval_table.init(16);10995 g->memoized_fn_eval_table.init(16);
10921 g->exported_symbol_names.init(8);10996 g->exported_symbol_names.init(8);
10922 g->external_prototypes.init(8);10997 g->external_symbol_names.init(8);
10923 g->string_literals_table.init(16);10998 g->string_literals_table.init(16);
10924 g->type_info_cache.init(32);10999 g->type_info_cache.init(32);
10925 g->one_possible_values.init(32);11000 g->one_possible_values.init(32);
...@@ -10929,7 +11004,7 @@ CodeGen *codegen_create(Buf *main_pkg_path, Buf *root_src_path, const ZigTarget...@@ -10929,7 +11004,7 @@ CodeGen *codegen_create(Buf *main_pkg_path, Buf *root_src_path, const ZigTarget
10929 buf_resize(&g->global_asm, 0);11004 buf_resize(&g->global_asm, 0);
1093011005
10931 for (size_t i = 0; i < array_length(symbols_that_llvm_depends_on); i += 1) {11006 for (size_t i = 0; i < array_length(symbols_that_llvm_depends_on); i += 1) {
10932 g->external_prototypes.put(buf_create_from_str(symbols_that_llvm_depends_on[i]), nullptr);11007 g->external_symbol_names.put(buf_create_from_str(symbols_that_llvm_depends_on[i]), nullptr);
10933 }11008 }
1093411009
10935 if (root_src_path) {11010 if (root_src_path) {
src/error.cpp+1
...@@ -85,6 +85,7 @@ const char *err_str(Error err) {...@@ -85,6 +85,7 @@ const char *err_str(Error err) {
85 case ErrorInvalidOperatingSystemVersion: return "invalid operating system version";85 case ErrorInvalidOperatingSystemVersion: return "invalid operating system version";
86 case ErrorUnknownClangOption: return "unknown Clang option";86 case ErrorUnknownClangOption: return "unknown Clang option";
87 case ErrorNestedResponseFile: return "nested response file";87 case ErrorNestedResponseFile: return "nested response file";
88 case ErrorZigIsTheCCompiler: return "Zig was not provided with libc installation information, and so it does not know where the libc paths are on the system. Zig attempted to use the system C compiler to find out where the libc paths are, but discovered that Zig is being used as the system C compiler.";
88 }89 }
89 return "(invalid error)";90 return "(invalid error)";
90}91}
src/glibc.cpp+1
...@@ -17,6 +17,7 @@ static const ZigGLibCLib glibc_libs[] = {...@@ -17,6 +17,7 @@ static const ZigGLibCLib glibc_libs[] = {
17 {"dl", 2},17 {"dl", 2},
18 {"rt", 1},18 {"rt", 1},
19 {"ld", 2},19 {"ld", 2},
20 {"util", 1},
20};21};
2122
22Error glibc_load_metadata(ZigGLibCAbi **out_result, Buf *zig_lib_dir, bool verbose) {23Error glibc_load_metadata(ZigGLibCAbi **out_result, Buf *zig_lib_dir, bool verbose) {
src/ir.cpp+582-215
...@@ -283,6 +283,8 @@ static IrInstGen *ir_analyze_union_init(IrAnalyze *ira, IrInst* source_instructi...@@ -283,6 +283,8 @@ static IrInstGen *ir_analyze_union_init(IrAnalyze *ira, IrInst* source_instructi
283 IrInstGen *result_loc);283 IrInstGen *result_loc);
284static IrInstGen *ir_analyze_struct_value_field_value(IrAnalyze *ira, IrInst* source_instr,284static IrInstGen *ir_analyze_struct_value_field_value(IrAnalyze *ira, IrInst* source_instr,
285 IrInstGen *struct_operand, TypeStructField *field);285 IrInstGen *struct_operand, TypeStructField *field);
286static bool value_cmp_numeric_val_any(ZigValue *left, Cmp predicate, ZigValue *right);
287static bool value_cmp_numeric_val_all(ZigValue *left, Cmp predicate, ZigValue *right);
286288
287static void destroy_instruction_src(IrInstSrc *inst) {289static void destroy_instruction_src(IrInstSrc *inst) {
288 switch (inst->id) {290 switch (inst->id) {
...@@ -3288,13 +3290,9 @@ static IrInstSrc *ir_build_import(IrBuilderSrc *irb, Scope *scope, AstNode *sour...@@ -3288,13 +3290,9 @@ static IrInstSrc *ir_build_import(IrBuilderSrc *irb, Scope *scope, AstNode *sour
3288 return &instruction->base;3290 return &instruction->base;
3289}3291}
32903292
3291static IrInstSrc *ir_build_ref_src(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, IrInstSrc *value,3293static IrInstSrc *ir_build_ref_src(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, IrInstSrc *value) {
3292 bool is_const, bool is_volatile)
3293{
3294 IrInstSrcRef *instruction = ir_build_instruction<IrInstSrcRef>(irb, scope, source_node);3294 IrInstSrcRef *instruction = ir_build_instruction<IrInstSrcRef>(irb, scope, source_node);
3295 instruction->value = value;3295 instruction->value = value;
3296 instruction->is_const = is_const;
3297 instruction->is_volatile = is_volatile;
32983296
3299 ir_ref_instruction(value, irb->current_basic_block);3297 ir_ref_instruction(value, irb->current_basic_block);
33003298
...@@ -5936,7 +5934,7 @@ static IrInstSrc *ir_gen_symbol(IrBuilderSrc *irb, Scope *scope, AstNode *node,...@@ -5936,7 +5934,7 @@ static IrInstSrc *ir_gen_symbol(IrBuilderSrc *irb, Scope *scope, AstNode *node,
5936 } else {5934 } else {
5937 IrInstSrc *value = ir_build_const_type(irb, scope, node, primitive_type);5935 IrInstSrc *value = ir_build_const_type(irb, scope, node, primitive_type);
5938 if (lval == LValPtr) {5936 if (lval == LValPtr) {
5939 return ir_build_ref_src(irb, scope, node, value, false, false);5937 return ir_build_ref_src(irb, scope, node, value);
5940 } else {5938 } else {
5941 return ir_expr_wrap(irb, scope, value, result_loc);5939 return ir_expr_wrap(irb, scope, value, result_loc);
5942 }5940 }
...@@ -7484,7 +7482,7 @@ static IrInstSrc *ir_lval_wrap(IrBuilderSrc *irb, Scope *scope, IrInstSrc *value...@@ -7484,7 +7482,7 @@ static IrInstSrc *ir_lval_wrap(IrBuilderSrc *irb, Scope *scope, IrInstSrc *value
7484 if (lval == LValPtr) {7482 if (lval == LValPtr) {
7485 // We needed a pointer to a value, but we got a value. So we create7483 // We needed a pointer to a value, but we got a value. So we create
7486 // an instruction which just makes a pointer of it.7484 // an instruction which just makes a pointer of it.
7487 return ir_build_ref_src(irb, scope, value->base.source_node, value, false, false);7485 return ir_build_ref_src(irb, scope, value->base.source_node, value);
7488 } else if (result_loc != nullptr) {7486 } else if (result_loc != nullptr) {
7489 return ir_expr_wrap(irb, scope, value, result_loc);7487 return ir_expr_wrap(irb, scope, value, result_loc);
7490 } else {7488 } else {
...@@ -10993,48 +10991,77 @@ static void float_negate(ZigValue *out_val, ZigValue *op) {...@@ -10993,48 +10991,77 @@ static void float_negate(ZigValue *out_val, ZigValue *op) {
10993}10991}
1099410992
10995void float_write_ieee597(ZigValue *op, uint8_t *buf, bool is_big_endian) {10993void float_write_ieee597(ZigValue *op, uint8_t *buf, bool is_big_endian) {
10996 if (op->type->id == ZigTypeIdFloat) {10994 if (op->type->id != ZigTypeIdFloat)
10997 switch (op->type->data.floating.bit_count) {
10998 case 16:
10999 memcpy(buf, &op->data.x_f16, 2); // TODO wrong when compiler is big endian
11000 return;
11001 case 32:
11002 memcpy(buf, &op->data.x_f32, 4); // TODO wrong when compiler is big endian
11003 return;
11004 case 64:
11005 memcpy(buf, &op->data.x_f64, 8); // TODO wrong when compiler is big endian
11006 return;
11007 case 128:
11008 memcpy(buf, &op->data.x_f128, 16); // TODO wrong when compiler is big endian
11009 return;
11010 default:
11011 zig_unreachable();
11012 }
11013 } else {
11014 zig_unreachable();10995 zig_unreachable();
10996
10997 const unsigned n = op->type->data.floating.bit_count / 8;
10998 assert(n <= 16);
10999
11000 switch (op->type->data.floating.bit_count) {
11001 case 16:
11002 memcpy(buf, &op->data.x_f16, 2);
11003 break;
11004 case 32:
11005 memcpy(buf, &op->data.x_f32, 4);
11006 break;
11007 case 64:
11008 memcpy(buf, &op->data.x_f64, 8);
11009 break;
11010 case 128:
11011 memcpy(buf, &op->data.x_f128, 16);
11012 break;
11013 default:
11014 zig_unreachable();
11015 }
11016
11017 if (is_big_endian) {
11018 // Byteswap in place if needed
11019 for (size_t i = 0; i < n / 2; i++) {
11020 uint8_t u = buf[i];
11021 buf[i] = buf[n - 1 - i];
11022 buf[n - 1 - i] = u;
11023 }
11015 }11024 }
11016}11025}
1101711026
11018void float_read_ieee597(ZigValue *val, uint8_t *buf, bool is_big_endian) {11027void float_read_ieee597(ZigValue *val, uint8_t *buf, bool is_big_endian) {
11019 if (val->type->id == ZigTypeIdFloat) {11028 if (val->type->id != ZigTypeIdFloat)
11020 switch (val->type->data.floating.bit_count) {
11021 case 16:
11022 memcpy(&val->data.x_f16, buf, 2); // TODO wrong when compiler is big endian
11023 return;
11024 case 32:
11025 memcpy(&val->data.x_f32, buf, 4); // TODO wrong when compiler is big endian
11026 return;
11027 case 64:
11028 memcpy(&val->data.x_f64, buf, 8); // TODO wrong when compiler is big endian
11029 return;
11030 case 128:
11031 memcpy(&val->data.x_f128, buf, 16); // TODO wrong when compiler is big endian
11032 return;
11033 default:
11034 zig_unreachable();
11035 }
11036 } else {
11037 zig_unreachable();11029 zig_unreachable();
11030
11031 const unsigned n = val->type->data.floating.bit_count / 8;
11032 assert(n <= 16);
11033
11034 uint8_t tmp[16];
11035 uint8_t *ptr = buf;
11036
11037 if (is_big_endian) {
11038 memcpy(tmp, buf, n);
11039
11040 // Byteswap if needed
11041 for (size_t i = 0; i < n / 2; i++) {
11042 uint8_t u = tmp[i];
11043 tmp[i] = tmp[n - 1 - i];
11044 tmp[n - 1 - i] = u;
11045 }
11046
11047 ptr = tmp;
11048 }
11049
11050 switch (val->type->data.floating.bit_count) {
11051 case 16:
11052 memcpy(&val->data.x_f16, ptr, 2);
11053 return;
11054 case 32:
11055 memcpy(&val->data.x_f32, ptr, 4);
11056 return;
11057 case 64:
11058 memcpy(&val->data.x_f64, ptr, 8);
11059 return;
11060 case 128:
11061 memcpy(&val->data.x_f128, ptr, 16);
11062 return;
11063 default:
11064 zig_unreachable();
11038 }11065 }
11039}11066}
1104011067
...@@ -16774,7 +16801,6 @@ static IrInstGen *ir_analyze_math_op(IrAnalyze *ira, IrInst* source_instr,...@@ -16774,7 +16801,6 @@ static IrInstGen *ir_analyze_math_op(IrAnalyze *ira, IrInst* source_instr,
16774 ZigValue *scalar_op2_val = &op2_val->data.x_array.data.s_none.elements[i];16801 ZigValue *scalar_op2_val = &op2_val->data.x_array.data.s_none.elements[i];
16775 ZigValue *scalar_out_val = &out_val->data.x_array.data.s_none.elements[i];16802 ZigValue *scalar_out_val = &out_val->data.x_array.data.s_none.elements[i];
16776 assert(scalar_op1_val->type == scalar_type);16803 assert(scalar_op1_val->type == scalar_type);
16777 assert(scalar_op2_val->type == scalar_type);
16778 assert(scalar_out_val->type == scalar_type);16804 assert(scalar_out_val->type == scalar_type);
16779 ErrorMsg *msg = ir_eval_math_op_scalar(ira, source_instr, scalar_type,16805 ErrorMsg *msg = ir_eval_math_op_scalar(ira, source_instr, scalar_type,
16780 scalar_op1_val, op_id, scalar_op2_val, scalar_out_val);16806 scalar_op1_val, op_id, scalar_op2_val, scalar_out_val);
...@@ -16799,27 +16825,49 @@ static IrInstGen *ir_analyze_bit_shift(IrAnalyze *ira, IrInstSrcBinOp *bin_op_in...@@ -16799,27 +16825,49 @@ static IrInstGen *ir_analyze_bit_shift(IrAnalyze *ira, IrInstSrcBinOp *bin_op_in
16799 if (type_is_invalid(op1->value->type))16825 if (type_is_invalid(op1->value->type))
16800 return ira->codegen->invalid_inst_gen;16826 return ira->codegen->invalid_inst_gen;
1680116827
16802 if (op1->value->type->id != ZigTypeIdInt && op1->value->type->id != ZigTypeIdComptimeInt) {16828 IrInstGen *op2 = bin_op_instruction->op2->child;
16829 if (type_is_invalid(op2->value->type))
16830 return ira->codegen->invalid_inst_gen;
16831
16832 ZigType *op1_type = op1->value->type;
16833 ZigType *op2_type = op2->value->type;
16834
16835 if (op1_type->id == ZigTypeIdVector && op2_type->id != ZigTypeIdVector) {
16803 ir_add_error(ira, &bin_op_instruction->op1->base,16836 ir_add_error(ira, &bin_op_instruction->op1->base,
16804 buf_sprintf("bit shifting operation expected integer type, found '%s'",16837 buf_sprintf("bit shifting operation expected vector type, found '%s'",
16805 buf_ptr(&op1->value->type->name)));16838 buf_ptr(&op2_type->name)));
16806 return ira->codegen->invalid_inst_gen;16839 return ira->codegen->invalid_inst_gen;
16807 }16840 }
1680816841
16809 IrInstGen *op2 = bin_op_instruction->op2->child;16842 if (op1_type->id != ZigTypeIdVector && op2_type->id == ZigTypeIdVector) {
16810 if (type_is_invalid(op2->value->type))16843 ir_add_error(ira, &bin_op_instruction->op1->base,
16844 buf_sprintf("bit shifting operation expected vector type, found '%s'",
16845 buf_ptr(&op1_type->name)));
16846 return ira->codegen->invalid_inst_gen;
16847 }
16848
16849 ZigType *op1_scalar_type = (op1_type->id == ZigTypeIdVector) ?
16850 op1_type->data.vector.elem_type : op1_type;
16851 ZigType *op2_scalar_type = (op2_type->id == ZigTypeIdVector) ?
16852 op2_type->data.vector.elem_type : op2_type;
16853
16854 if (op1_scalar_type->id != ZigTypeIdInt && op1_scalar_type->id != ZigTypeIdComptimeInt) {
16855 ir_add_error(ira, &bin_op_instruction->op1->base,
16856 buf_sprintf("bit shifting operation expected integer type, found '%s'",
16857 buf_ptr(&op1_scalar_type->name)));
16811 return ira->codegen->invalid_inst_gen;16858 return ira->codegen->invalid_inst_gen;
16859 }
1681216860
16813 if (op2->value->type->id != ZigTypeIdInt && op2->value->type->id != ZigTypeIdComptimeInt) {16861 if (op2_scalar_type->id != ZigTypeIdInt && op2_scalar_type->id != ZigTypeIdComptimeInt) {
16814 ir_add_error(ira, &bin_op_instruction->op2->base,16862 ir_add_error(ira, &bin_op_instruction->op2->base,
16815 buf_sprintf("shift amount has to be an integer type, but found '%s'",16863 buf_sprintf("shift amount has to be an integer type, but found '%s'",
16816 buf_ptr(&op2->value->type->name)));16864 buf_ptr(&op2_scalar_type->name)));
16817 return ira->codegen->invalid_inst_gen;16865 return ira->codegen->invalid_inst_gen;
16818 }16866 }
1681916867
16820 IrInstGen *casted_op2;16868 IrInstGen *casted_op2;
16821 IrBinOp op_id = bin_op_instruction->op_id;16869 IrBinOp op_id = bin_op_instruction->op_id;
16822 if (op1->value->type->id == ZigTypeIdComptimeInt) {16870 if (op1_scalar_type->id == ZigTypeIdComptimeInt) {
16823 // comptime_int has no finite bit width16871 // comptime_int has no finite bit width
16824 casted_op2 = op2;16872 casted_op2 = op2;
1682516873
...@@ -16845,10 +16893,15 @@ static IrInstGen *ir_analyze_bit_shift(IrAnalyze *ira, IrInstSrcBinOp *bin_op_in...@@ -16845,10 +16893,15 @@ static IrInstGen *ir_analyze_bit_shift(IrAnalyze *ira, IrInstSrcBinOp *bin_op_in
16845 return ira->codegen->invalid_inst_gen;16893 return ira->codegen->invalid_inst_gen;
16846 }16894 }
16847 } else {16895 } else {
16848 const unsigned bit_count = op1->value->type->data.integral.bit_count;16896 const unsigned bit_count = op1_scalar_type->data.integral.bit_count;
16849 ZigType *shift_amt_type = get_smallest_unsigned_int_type(ira->codegen,16897 ZigType *shift_amt_type = get_smallest_unsigned_int_type(ira->codegen,
16850 bit_count > 0 ? bit_count - 1 : 0);16898 bit_count > 0 ? bit_count - 1 : 0);
1685116899
16900 if (op1_type->id == ZigTypeIdVector) {
16901 shift_amt_type = get_vector_type(ira->codegen, op1_type->data.vector.len,
16902 shift_amt_type);
16903 }
16904
16852 casted_op2 = ir_implicit_cast(ira, op2, shift_amt_type);16905 casted_op2 = ir_implicit_cast(ira, op2, shift_amt_type);
16853 if (type_is_invalid(casted_op2->value->type))16906 if (type_is_invalid(casted_op2->value->type))
16854 return ira->codegen->invalid_inst_gen;16907 return ira->codegen->invalid_inst_gen;
...@@ -16859,10 +16912,10 @@ static IrInstGen *ir_analyze_bit_shift(IrAnalyze *ira, IrInstSrcBinOp *bin_op_in...@@ -16859,10 +16912,10 @@ static IrInstGen *ir_analyze_bit_shift(IrAnalyze *ira, IrInstSrcBinOp *bin_op_in
16859 if (op2_val == nullptr)16912 if (op2_val == nullptr)
16860 return ira->codegen->invalid_inst_gen;16913 return ira->codegen->invalid_inst_gen;
1686116914
16862 BigInt bit_count_value = {0};16915 ZigValue bit_count_value;
16863 bigint_init_unsigned(&bit_count_value, bit_count);16916 init_const_usize(ira->codegen, &bit_count_value, bit_count);
1686416917
16865 if (bigint_cmp(&op2_val->data.x_bigint, &bit_count_value) != CmpLT) {16918 if (!value_cmp_numeric_val_all(op2_val, CmpLT, &bit_count_value)) {
16866 ErrorMsg* msg = ir_add_error(ira,16919 ErrorMsg* msg = ir_add_error(ira,
16867 &bin_op_instruction->base.base,16920 &bin_op_instruction->base.base,
16868 buf_sprintf("RHS of shift is too large for LHS type"));16921 buf_sprintf("RHS of shift is too large for LHS type"));
...@@ -16881,7 +16934,7 @@ static IrInstGen *ir_analyze_bit_shift(IrAnalyze *ira, IrInstSrcBinOp *bin_op_in...@@ -16881,7 +16934,7 @@ static IrInstGen *ir_analyze_bit_shift(IrAnalyze *ira, IrInstSrcBinOp *bin_op_in
16881 if (op2_val == nullptr)16934 if (op2_val == nullptr)
16882 return ira->codegen->invalid_inst_gen;16935 return ira->codegen->invalid_inst_gen;
1688316936
16884 if (bigint_cmp_zero(&op2_val->data.x_bigint) == CmpEQ)16937 if (value_cmp_numeric_val_all(op2_val, CmpEQ, nullptr))
16885 return ir_analyze_cast(ira, &bin_op_instruction->base.base, op1->value->type, op1);16938 return ir_analyze_cast(ira, &bin_op_instruction->base.base, op1->value->type, op1);
16886 }16939 }
1688716940
...@@ -16894,7 +16947,7 @@ static IrInstGen *ir_analyze_bit_shift(IrAnalyze *ira, IrInstSrcBinOp *bin_op_in...@@ -16894,7 +16947,7 @@ static IrInstGen *ir_analyze_bit_shift(IrAnalyze *ira, IrInstSrcBinOp *bin_op_in
16894 if (op2_val == nullptr)16947 if (op2_val == nullptr)
16895 return ira->codegen->invalid_inst_gen;16948 return ira->codegen->invalid_inst_gen;
1689616949
16897 return ir_analyze_math_op(ira, &bin_op_instruction->base.base, op1->value->type, op1_val, op_id, op2_val);16950 return ir_analyze_math_op(ira, &bin_op_instruction->base.base, op1_type, op1_val, op_id, op2_val);
16898 }16951 }
1689916952
16900 return ir_build_bin_op_gen(ira, &bin_op_instruction->base.base, op1->value->type,16953 return ir_build_bin_op_gen(ira, &bin_op_instruction->base.base, op1->value->type,
...@@ -16914,6 +16967,7 @@ static bool ok_float_op(IrBinOp op) {...@@ -16914,6 +16967,7 @@ static bool ok_float_op(IrBinOp op) {
16914 case IrBinOpDivExact:16967 case IrBinOpDivExact:
16915 case IrBinOpRemRem:16968 case IrBinOpRemRem:
16916 case IrBinOpRemMod:16969 case IrBinOpRemMod:
16970 case IrBinOpRemUnspecified:
16917 return true;16971 return true;
1691816972
16919 case IrBinOpBoolOr:16973 case IrBinOpBoolOr:
...@@ -16934,7 +16988,6 @@ static bool ok_float_op(IrBinOp op) {...@@ -16934,7 +16988,6 @@ static bool ok_float_op(IrBinOp op) {
16934 case IrBinOpAddWrap:16988 case IrBinOpAddWrap:
16935 case IrBinOpSubWrap:16989 case IrBinOpSubWrap:
16936 case IrBinOpMultWrap:16990 case IrBinOpMultWrap:
16937 case IrBinOpRemUnspecified:
16938 case IrBinOpArrayCat:16991 case IrBinOpArrayCat:
16939 case IrBinOpArrayMult:16992 case IrBinOpArrayMult:
16940 return false;16993 return false;
...@@ -16962,6 +17015,53 @@ static bool is_pointer_arithmetic_allowed(ZigType *lhs_type, IrBinOp op) {...@@ -16962,6 +17015,53 @@ static bool is_pointer_arithmetic_allowed(ZigType *lhs_type, IrBinOp op) {
16962 zig_unreachable();17015 zig_unreachable();
16963}17016}
1696417017
17018static bool value_cmp_numeric_val(ZigValue *left, Cmp predicate, ZigValue *right, bool any) {
17019 assert(left->special == ConstValSpecialStatic);
17020 assert(right == nullptr || right->special == ConstValSpecialStatic);
17021
17022 switch (left->type->id) {
17023 case ZigTypeIdComptimeInt:
17024 case ZigTypeIdInt: {
17025 const Cmp result = right ?
17026 bigint_cmp(&left->data.x_bigint, &right->data.x_bigint) :
17027 bigint_cmp_zero(&left->data.x_bigint);
17028 return result == predicate;
17029 }
17030 case ZigTypeIdComptimeFloat:
17031 case ZigTypeIdFloat: {
17032 if (float_is_nan(left))
17033 return false;
17034 if (right != nullptr && float_is_nan(right))
17035 return false;
17036
17037 const Cmp result = right ? float_cmp(left, right) : float_cmp_zero(left);
17038 return result == predicate;
17039 }
17040 case ZigTypeIdVector: {
17041 for (size_t i = 0; i < left->type->data.vector.len; i++) {
17042 ZigValue *scalar_val = &left->data.x_array.data.s_none.elements[i];
17043 const bool result = value_cmp_numeric_val(scalar_val, predicate, right, any);
17044
17045 if (any && result)
17046 return true; // This element satisfies the predicate
17047 else if (!any && !result)
17048 return false; // This element doesn't satisfy the predicate
17049 }
17050 return any ? false : true;
17051 }
17052 default:
17053 zig_unreachable();
17054 }
17055}
17056
17057static bool value_cmp_numeric_val_any(ZigValue *left, Cmp predicate, ZigValue *right) {
17058 return value_cmp_numeric_val(left, predicate, right, true);
17059}
17060
17061static bool value_cmp_numeric_val_all(ZigValue *left, Cmp predicate, ZigValue *right) {
17062 return value_cmp_numeric_val(left, predicate, right, false);
17063}
17064
16965static IrInstGen *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstSrcBinOp *instruction) {17065static IrInstGen *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstSrcBinOp *instruction) {
16966 Error err;17066 Error err;
1696717067
...@@ -17067,127 +17167,13 @@ static IrInstGen *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstSrcBinOp *instruc...@@ -17067,127 +17167,13 @@ static IrInstGen *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstSrcBinOp *instruc
17067 if (type_is_invalid(resolved_type))17167 if (type_is_invalid(resolved_type))
17068 return ira->codegen->invalid_inst_gen;17168 return ira->codegen->invalid_inst_gen;
1706917169
17070 bool is_int = resolved_type->id == ZigTypeIdInt || resolved_type->id == ZigTypeIdComptimeInt;17170 ZigType *scalar_type = (resolved_type->id == ZigTypeIdVector) ?
17071 bool is_float = resolved_type->id == ZigTypeIdFloat || resolved_type->id == ZigTypeIdComptimeFloat;17171 resolved_type->data.vector.elem_type : resolved_type;
17072 bool is_signed_div = (
17073 (resolved_type->id == ZigTypeIdInt && resolved_type->data.integral.is_signed) ||
17074 resolved_type->id == ZigTypeIdFloat ||
17075 (resolved_type->id == ZigTypeIdComptimeFloat &&
17076 ((bigfloat_cmp_zero(&op1->value->data.x_bigfloat) != CmpGT) !=
17077 (bigfloat_cmp_zero(&op2->value->data.x_bigfloat) != CmpGT))) ||
17078 (resolved_type->id == ZigTypeIdComptimeInt &&
17079 ((bigint_cmp_zero(&op1->value->data.x_bigint) != CmpGT) !=
17080 (bigint_cmp_zero(&op2->value->data.x_bigint) != CmpGT)))
17081 );
17082 if (op_id == IrBinOpDivUnspecified && is_int) {
17083 if (is_signed_div) {
17084 bool ok = false;
17085 if (instr_is_comptime(op1) && instr_is_comptime(op2)) {
17086 ZigValue *op1_val = ir_resolve_const(ira, op1, UndefBad);
17087 if (op1_val == nullptr)
17088 return ira->codegen->invalid_inst_gen;
17089
17090 ZigValue *op2_val = ir_resolve_const(ira, op2, UndefBad);
17091 if (op2_val == nullptr)
17092 return ira->codegen->invalid_inst_gen;
17093
17094 if (bigint_cmp_zero(&op2_val->data.x_bigint) == CmpEQ) {
17095 // the division by zero error will be caught later, but we don't have a
17096 // division function ambiguity problem.
17097 op_id = IrBinOpDivTrunc;
17098 ok = true;
17099 } else {
17100 BigInt trunc_result;
17101 BigInt floor_result;
17102 bigint_div_trunc(&trunc_result, &op1_val->data.x_bigint, &op2_val->data.x_bigint);
17103 bigint_div_floor(&floor_result, &op1_val->data.x_bigint, &op2_val->data.x_bigint);
17104 if (bigint_cmp(&trunc_result, &floor_result) == CmpEQ) {
17105 ok = true;
17106 op_id = IrBinOpDivTrunc;
17107 }
17108 }
17109 }
17110 if (!ok) {
17111 ir_add_error(ira, &instruction->base.base,
17112 buf_sprintf("division with '%s' and '%s': signed integers must use @divTrunc, @divFloor, or @divExact",
17113 buf_ptr(&op1->value->type->name),
17114 buf_ptr(&op2->value->type->name)));
17115 return ira->codegen->invalid_inst_gen;
17116 }
17117 } else {
17118 op_id = IrBinOpDivTrunc;
17119 }
17120 } else if (op_id == IrBinOpRemUnspecified) {
17121 if (is_signed_div && (is_int || is_float)) {
17122 bool ok = false;
17123 if (instr_is_comptime(op1) && instr_is_comptime(op2)) {
17124 ZigValue *op1_val = ir_resolve_const(ira, op1, UndefBad);
17125 if (op1_val == nullptr)
17126 return ira->codegen->invalid_inst_gen;
17127
17128 if (is_int) {
17129 ZigValue *op2_val = ir_resolve_const(ira, op2, UndefBad);
17130 if (op2_val == nullptr)
17131 return ira->codegen->invalid_inst_gen;
17132
17133 if (bigint_cmp_zero(&op2->value->data.x_bigint) == CmpEQ) {
17134 // the division by zero error will be caught later, but we don't
17135 // have a remainder function ambiguity problem
17136 ok = true;
17137 } else {
17138 BigInt rem_result;
17139 BigInt mod_result;
17140 bigint_rem(&rem_result, &op1_val->data.x_bigint, &op2_val->data.x_bigint);
17141 bigint_mod(&mod_result, &op1_val->data.x_bigint, &op2_val->data.x_bigint);
17142 ok = bigint_cmp(&rem_result, &mod_result) == CmpEQ;
17143 }
17144 } else {
17145 IrInstGen *casted_op2 = ir_implicit_cast(ira, op2, resolved_type);
17146 if (type_is_invalid(casted_op2->value->type))
17147 return ira->codegen->invalid_inst_gen;
1714817172
17149 ZigValue *op2_val = ir_resolve_const(ira, casted_op2, UndefBad);17173 bool is_int = scalar_type->id == ZigTypeIdInt || scalar_type->id == ZigTypeIdComptimeInt;
17150 if (op2_val == nullptr)17174 bool is_float = scalar_type->id == ZigTypeIdFloat || scalar_type->id == ZigTypeIdComptimeFloat;
17151 return ira->codegen->invalid_inst_gen;
1715217175
17153 if (float_cmp_zero(casted_op2->value) == CmpEQ) {17176 if (!is_int && !(is_float && ok_float_op(op_id))) {
17154 // the division by zero error will be caught later, but we don't
17155 // have a remainder function ambiguity problem
17156 ok = true;
17157 } else {
17158 ZigValue rem_result = {};
17159 ZigValue mod_result = {};
17160 float_rem(&rem_result, op1_val, op2_val);
17161 float_mod(&mod_result, op1_val, op2_val);
17162 ok = float_cmp(&rem_result, &mod_result) == CmpEQ;
17163 }
17164 }
17165 }
17166 if (!ok) {
17167 ir_add_error(ira, &instruction->base.base,
17168 buf_sprintf("remainder division with '%s' and '%s': signed integers and floats must use @rem or @mod",
17169 buf_ptr(&op1->value->type->name),
17170 buf_ptr(&op2->value->type->name)));
17171 return ira->codegen->invalid_inst_gen;
17172 }
17173 }
17174 op_id = IrBinOpRemRem;
17175 }
17176
17177 bool ok = false;
17178 if (is_int) {
17179 ok = true;
17180 } else if (is_float && ok_float_op(op_id)) {
17181 ok = true;
17182 } else if (resolved_type->id == ZigTypeIdVector) {
17183 ZigType *elem_type = resolved_type->data.vector.elem_type;
17184 if (elem_type->id == ZigTypeIdInt || elem_type->id == ZigTypeIdComptimeInt) {
17185 ok = true;
17186 } else if ((elem_type->id == ZigTypeIdFloat || elem_type->id == ZigTypeIdComptimeFloat) && ok_float_op(op_id)) {
17187 ok = true;
17188 }
17189 }
17190 if (!ok) {
17191 AstNode *source_node = instruction->base.base.source_node;17177 AstNode *source_node = instruction->base.base.source_node;
17192 ir_add_error_node(ira, source_node,17178 ir_add_error_node(ira, source_node,
17193 buf_sprintf("invalid operands to binary expression: '%s' and '%s'",17179 buf_sprintf("invalid operands to binary expression: '%s' and '%s'",
...@@ -17196,7 +17182,16 @@ static IrInstGen *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstSrcBinOp *instruc...@@ -17196,7 +17182,16 @@ static IrInstGen *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstSrcBinOp *instruc
17196 return ira->codegen->invalid_inst_gen;17182 return ira->codegen->invalid_inst_gen;
17197 }17183 }
1719817184
17199 if (resolved_type->id == ZigTypeIdComptimeInt) {17185 IrInstGen *casted_op1 = ir_implicit_cast(ira, op1, resolved_type);
17186 if (type_is_invalid(casted_op1->value->type))
17187 return ira->codegen->invalid_inst_gen;
17188
17189 IrInstGen *casted_op2 = ir_implicit_cast(ira, op2, resolved_type);
17190 if (type_is_invalid(casted_op2->value->type))
17191 return ira->codegen->invalid_inst_gen;
17192
17193 // Comptime integers have no fixed size
17194 if (scalar_type->id == ZigTypeIdComptimeInt) {
17200 if (op_id == IrBinOpAddWrap) {17195 if (op_id == IrBinOpAddWrap) {
17201 op_id = IrBinOpAdd;17196 op_id = IrBinOpAdd;
17202 } else if (op_id == IrBinOpSubWrap) {17197 } else if (op_id == IrBinOpSubWrap) {
...@@ -17206,25 +17201,131 @@ static IrInstGen *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstSrcBinOp *instruc...@@ -17206,25 +17201,131 @@ static IrInstGen *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstSrcBinOp *instruc
17206 }17201 }
17207 }17202 }
1720817203
17209 IrInstGen *casted_op1 = ir_implicit_cast(ira, op1, resolved_type);
17210 if (type_is_invalid(casted_op1->value->type))
17211 return ira->codegen->invalid_inst_gen;
17212
17213 IrInstGen *casted_op2 = ir_implicit_cast(ira, op2, resolved_type);
17214 if (type_is_invalid(casted_op2->value->type))
17215 return ira->codegen->invalid_inst_gen;
17216
17217 if (instr_is_comptime(casted_op1) && instr_is_comptime(casted_op2)) {17204 if (instr_is_comptime(casted_op1) && instr_is_comptime(casted_op2)) {
17218 ZigValue *op1_val = ir_resolve_const(ira, casted_op1, UndefBad);17205 ZigValue *op1_val = ir_resolve_const(ira, casted_op1, UndefBad);
17219 if (op1_val == nullptr)17206 if (op1_val == nullptr)
17220 return ira->codegen->invalid_inst_gen;17207 return ira->codegen->invalid_inst_gen;
17208
17221 ZigValue *op2_val = ir_resolve_const(ira, casted_op2, UndefBad);17209 ZigValue *op2_val = ir_resolve_const(ira, casted_op2, UndefBad);
17222 if (op2_val == nullptr)17210 if (op2_val == nullptr)
17223 return ira->codegen->invalid_inst_gen;17211 return ira->codegen->invalid_inst_gen;
1722417212
17213 // Promote division with negative numbers to signed
17214 bool is_signed_div = value_cmp_numeric_val_any(op1_val, CmpLT, nullptr) ||
17215 value_cmp_numeric_val_any(op2_val, CmpLT, nullptr);
17216
17217 if (op_id == IrBinOpDivUnspecified && is_int) {
17218 // Default to truncating division and check if it's valid for the
17219 // given operands if signed
17220 op_id = IrBinOpDivTrunc;
17221
17222 if (is_signed_div) {
17223 bool ok = false;
17224
17225 if (value_cmp_numeric_val_any(op2_val, CmpEQ, nullptr)) {
17226 // the division by zero error will be caught later, but we don't have a
17227 // division function ambiguity problem.
17228 ok = true;
17229 } else {
17230 IrInstGen *trunc_val = ir_analyze_math_op(ira, &instruction->base.base, resolved_type,
17231 op1_val, IrBinOpDivTrunc, op2_val);
17232 if (type_is_invalid(trunc_val->value->type))
17233 return ira->codegen->invalid_inst_gen;
17234
17235 IrInstGen *floor_val = ir_analyze_math_op(ira, &instruction->base.base, resolved_type,
17236 op1_val, IrBinOpDivFloor, op2_val);
17237 if (type_is_invalid(floor_val->value->type))
17238 return ira->codegen->invalid_inst_gen;
17239
17240 IrInstGen *cmp_val = ir_analyze_bin_op_cmp_numeric(ira, &instruction->base.base,
17241 trunc_val, floor_val, IrBinOpCmpEq);
17242 if (type_is_invalid(cmp_val->value->type))
17243 return ira->codegen->invalid_inst_gen;
17244
17245 // We can "upgrade" the operator only if trunc(a/b) == floor(a/b)
17246 if (!ir_resolve_bool(ira, cmp_val, &ok))
17247 return ira->codegen->invalid_inst_gen;
17248 }
17249
17250 if (!ok) {
17251 ir_add_error(ira, &instruction->base.base,
17252 buf_sprintf("division with '%s' and '%s': signed integers must use @divTrunc, @divFloor, or @divExact",
17253 buf_ptr(&op1->value->type->name),
17254 buf_ptr(&op2->value->type->name)));
17255 return ira->codegen->invalid_inst_gen;
17256 }
17257 }
17258 } else if (op_id == IrBinOpRemUnspecified) {
17259 op_id = IrBinOpRemRem;
17260
17261 if (is_signed_div) {
17262 bool ok = false;
17263
17264 if (value_cmp_numeric_val_any(op2_val, CmpEQ, nullptr)) {
17265 // the division by zero error will be caught later, but we don't have a
17266 // division function ambiguity problem.
17267 ok = true;
17268 } else {
17269 IrInstGen *rem_val = ir_analyze_math_op(ira, &instruction->base.base, resolved_type,
17270 op1_val, IrBinOpRemRem, op2_val);
17271 if (type_is_invalid(rem_val->value->type))
17272 return ira->codegen->invalid_inst_gen;
17273
17274 IrInstGen *mod_val = ir_analyze_math_op(ira, &instruction->base.base, resolved_type,
17275 op1_val, IrBinOpRemMod, op2_val);
17276 if (type_is_invalid(mod_val->value->type))
17277 return ira->codegen->invalid_inst_gen;
17278
17279 IrInstGen *cmp_val = ir_analyze_bin_op_cmp_numeric(ira, &instruction->base.base,
17280 rem_val, mod_val, IrBinOpCmpEq);
17281 if (type_is_invalid(cmp_val->value->type))
17282 return ira->codegen->invalid_inst_gen;
17283
17284 // We can "upgrade" the operator only if mod(a,b) == rem(a,b)
17285 if (!ir_resolve_bool(ira, cmp_val, &ok))
17286 return ira->codegen->invalid_inst_gen;
17287 }
17288
17289 if (!ok) {
17290 ir_add_error(ira, &instruction->base.base,
17291 buf_sprintf("remainder division with '%s' and '%s': signed integers and floats must use @rem or @mod",
17292 buf_ptr(&op1->value->type->name),
17293 buf_ptr(&op2->value->type->name)));
17294 return ira->codegen->invalid_inst_gen;
17295 }
17296 }
17297 }
17298
17225 return ir_analyze_math_op(ira, &instruction->base.base, resolved_type, op1_val, op_id, op2_val);17299 return ir_analyze_math_op(ira, &instruction->base.base, resolved_type, op1_val, op_id, op2_val);
17226 }17300 }
1722717301
17302 const bool is_signed_div =
17303 (scalar_type->id == ZigTypeIdInt && scalar_type->data.integral.is_signed) ||
17304 scalar_type->id == ZigTypeIdFloat;
17305
17306 // Warn the user to use the proper operators here
17307 if (op_id == IrBinOpDivUnspecified && is_int) {
17308 op_id = IrBinOpDivTrunc;
17309
17310 if (is_signed_div) {
17311 ir_add_error(ira, &instruction->base.base,
17312 buf_sprintf("division with '%s' and '%s': signed integers must use @divTrunc, @divFloor, or @divExact",
17313 buf_ptr(&op1->value->type->name),
17314 buf_ptr(&op2->value->type->name)));
17315 return ira->codegen->invalid_inst_gen;
17316 }
17317 } else if (op_id == IrBinOpRemUnspecified) {
17318 op_id = IrBinOpRemRem;
17319
17320 if (is_signed_div) {
17321 ir_add_error(ira, &instruction->base.base,
17322 buf_sprintf("remainder division with '%s' and '%s': signed integers and floats must use @rem or @mod",
17323 buf_ptr(&op1->value->type->name),
17324 buf_ptr(&op2->value->type->name)));
17325 return ira->codegen->invalid_inst_gen;
17326 }
17327 }
17328
17228 return ir_build_bin_op_gen(ira, &instruction->base.base, resolved_type,17329 return ir_build_bin_op_gen(ira, &instruction->base.base, resolved_type,
17229 op_id, casted_op1, casted_op2, instruction->safety_check_on);17330 op_id, casted_op1, casted_op2, instruction->safety_check_on);
17230}17331}
...@@ -17246,14 +17347,15 @@ static IrInstGen *ir_analyze_tuple_cat(IrAnalyze *ira, IrInst* source_instr,...@@ -17246,14 +17347,15 @@ static IrInstGen *ir_analyze_tuple_cat(IrAnalyze *ira, IrInst* source_instr,
17246 ContainerKindStruct, source_instr->source_node, buf_ptr(name), bare_name, ContainerLayoutAuto);17347 ContainerKindStruct, source_instr->source_node, buf_ptr(name), bare_name, ContainerLayoutAuto);
17247 new_type->data.structure.special = StructSpecialInferredTuple;17348 new_type->data.structure.special = StructSpecialInferredTuple;
17248 new_type->data.structure.resolve_status = ResolveStatusBeingInferred;17349 new_type->data.structure.resolve_status = ResolveStatusBeingInferred;
17249
17250 IrInstGen *new_struct_ptr = ir_resolve_result(ira, source_instr, no_result_loc(),
17251 new_type, nullptr, false, true);
17252 uint32_t new_field_count = op1_field_count + op2_field_count;17350 uint32_t new_field_count = op1_field_count + op2_field_count;
1725317351
17254 new_type->data.structure.src_field_count = new_field_count;17352 new_type->data.structure.src_field_count = new_field_count;
17255 new_type->data.structure.fields = realloc_type_struct_fields(new_type->data.structure.fields,17353 new_type->data.structure.fields = realloc_type_struct_fields(new_type->data.structure.fields,
17256 0, new_field_count);17354 0, new_field_count);
17355
17356 IrInstGen *new_struct_ptr = ir_resolve_result(ira, source_instr, no_result_loc(),
17357 new_type, nullptr, false, true);
17358
17257 for (uint32_t i = 0; i < new_field_count; i += 1) {17359 for (uint32_t i = 0; i < new_field_count; i += 1) {
17258 TypeStructField *src_field;17360 TypeStructField *src_field;
17259 if (i < op1_field_count) {17361 if (i < op1_field_count) {
...@@ -17317,8 +17419,10 @@ static IrInstGen *ir_analyze_tuple_cat(IrAnalyze *ira, IrInst* source_instr,...@@ -17317,8 +17419,10 @@ static IrInstGen *ir_analyze_tuple_cat(IrAnalyze *ira, IrInst* source_instr,
17317 ir_analyze_store_ptr(ira, &elem_result_loc->base, elem_result_loc, deref, true);17419 ir_analyze_store_ptr(ira, &elem_result_loc->base, elem_result_loc, deref, true);
17318 }17420 }
17319 }17421 }
17320 IrInstGen *result = ir_get_deref(ira, source_instr, new_struct_ptr, nullptr);17422
17321 return result;17423 const_ptrs.deinit();
17424
17425 return ir_get_deref(ira, source_instr, new_struct_ptr, nullptr);
17322}17426}
1732317427
17324static IrInstGen *ir_analyze_array_cat(IrAnalyze *ira, IrInstSrcBinOp *instruction) {17428static IrInstGen *ir_analyze_array_cat(IrAnalyze *ira, IrInstSrcBinOp *instruction) {
...@@ -17375,8 +17479,9 @@ static IrInstGen *ir_analyze_array_cat(IrAnalyze *ira, IrInstSrcBinOp *instructi...@@ -17375,8 +17479,9 @@ static IrInstGen *ir_analyze_array_cat(IrAnalyze *ira, IrInstSrcBinOp *instructi
17375 ZigValue *len_val = op1_val->data.x_struct.fields[slice_len_index];17479 ZigValue *len_val = op1_val->data.x_struct.fields[slice_len_index];
17376 op1_array_end = op1_array_index + bigint_as_usize(&len_val->data.x_bigint);17480 op1_array_end = op1_array_index + bigint_as_usize(&len_val->data.x_bigint);
17377 sentinel1 = ptr_type->data.pointer.sentinel;17481 sentinel1 = ptr_type->data.pointer.sentinel;
17378 } else if (op1_type->id == ZigTypeIdPointer && op1_type->data.pointer.ptr_len == PtrLenSingle &&17482 } else if (op1_type->id == ZigTypeIdPointer &&
17379 op1_type->data.pointer.child_type->id == ZigTypeIdArray)17483 op1_type->data.pointer.ptr_len == PtrLenSingle &&
17484 op1_type->data.pointer.child_type->id == ZigTypeIdArray)
17380 {17485 {
17381 ZigType *array_type = op1_type->data.pointer.child_type;17486 ZigType *array_type = op1_type->data.pointer.child_type;
17382 child_type = array_type->data.array.child_type;17487 child_type = array_type->data.array.child_type;
...@@ -17549,6 +17654,103 @@ static IrInstGen *ir_analyze_array_cat(IrAnalyze *ira, IrInstSrcBinOp *instructi...@@ -17549,6 +17654,103 @@ static IrInstGen *ir_analyze_array_cat(IrAnalyze *ira, IrInstSrcBinOp *instructi
17549 return result;17654 return result;
17550}17655}
1755117656
17657static IrInstGen *ir_analyze_tuple_mult(IrAnalyze *ira, IrInst* source_instr,
17658 IrInstGen *op1, IrInstGen *op2)
17659{
17660 Error err;
17661 ZigType *op1_type = op1->value->type;
17662 uint64_t op1_field_count = op1_type->data.structure.src_field_count;
17663
17664 uint64_t mult_amt;
17665 if (!ir_resolve_usize(ira, op2, &mult_amt))
17666 return ira->codegen->invalid_inst_gen;
17667
17668 uint64_t new_field_count;
17669 if (mul_u64_overflow(op1_field_count, mult_amt, &new_field_count)) {
17670 ir_add_error(ira, source_instr, buf_sprintf("operation results in overflow"));
17671 return ira->codegen->invalid_inst_gen;
17672 }
17673
17674 Buf *bare_name = buf_alloc();
17675 Buf *name = get_anon_type_name(ira->codegen, nullptr, container_string(ContainerKindStruct),
17676 source_instr->scope, source_instr->source_node, bare_name);
17677 ZigType *new_type = get_partial_container_type(ira->codegen, source_instr->scope,
17678 ContainerKindStruct, source_instr->source_node, buf_ptr(name), bare_name, ContainerLayoutAuto);
17679 new_type->data.structure.special = StructSpecialInferredTuple;
17680 new_type->data.structure.resolve_status = ResolveStatusBeingInferred;
17681 new_type->data.structure.src_field_count = new_field_count;
17682 new_type->data.structure.fields = realloc_type_struct_fields(
17683 new_type->data.structure.fields, 0, new_field_count);
17684
17685 IrInstGen *new_struct_ptr = ir_resolve_result(ira, source_instr, no_result_loc(),
17686 new_type, nullptr, false, true);
17687
17688 for (uint64_t i = 0; i < new_field_count; i += 1) {
17689 TypeStructField *src_field = op1_type->data.structure.fields[i % op1_field_count];
17690 TypeStructField *new_field = new_type->data.structure.fields[i];
17691
17692 new_field->name = buf_sprintf("%" ZIG_PRI_u64, i);
17693 new_field->type_entry = src_field->type_entry;
17694 new_field->type_val = src_field->type_val;
17695 new_field->src_index = i;
17696 new_field->decl_node = src_field->decl_node;
17697 new_field->init_val = src_field->init_val;
17698 new_field->is_comptime = src_field->is_comptime;
17699 }
17700
17701 if ((err = type_resolve(ira->codegen, new_type, ResolveStatusZeroBitsKnown)))
17702 return ira->codegen->invalid_inst_gen;
17703
17704 ZigList<IrInstGen *> const_ptrs = {};
17705 for (uint64_t i = 0; i < new_field_count; i += 1) {
17706 TypeStructField *src_field = op1_type->data.structure.fields[i % op1_field_count];
17707 TypeStructField *dst_field = new_type->data.structure.fields[i];
17708
17709 IrInstGen *field_value = ir_analyze_struct_value_field_value(
17710 ira, source_instr, op1, src_field);
17711 if (type_is_invalid(field_value->value->type))
17712 return ira->codegen->invalid_inst_gen;
17713
17714 IrInstGen *dest_ptr = ir_analyze_struct_field_ptr(
17715 ira, source_instr, dst_field, new_struct_ptr, new_type, true);
17716 if (type_is_invalid(dest_ptr->value->type))
17717 return ira->codegen->invalid_inst_gen;
17718
17719 if (instr_is_comptime(field_value)) {
17720 const_ptrs.append(dest_ptr);
17721 }
17722
17723 IrInstGen *store_ptr_inst = ir_analyze_store_ptr(
17724 ira, source_instr, dest_ptr, field_value, true);
17725 if (type_is_invalid(store_ptr_inst->value->type))
17726 return ira->codegen->invalid_inst_gen;
17727 }
17728
17729 if (const_ptrs.length != new_field_count) {
17730 new_struct_ptr->value->special = ConstValSpecialRuntime;
17731 for (size_t i = 0; i < const_ptrs.length; i += 1) {
17732 IrInstGen *elem_result_loc = const_ptrs.at(i);
17733 assert(elem_result_loc->value->special == ConstValSpecialStatic);
17734 if (elem_result_loc->value->type->data.pointer.inferred_struct_field != nullptr) {
17735 // This field will be generated comptime; no need to do this.
17736 continue;
17737 }
17738 IrInstGen *deref = ir_get_deref(ira, &elem_result_loc->base, elem_result_loc, nullptr);
17739 if (!type_requires_comptime(ira->codegen, elem_result_loc->value->type->data.pointer.child_type)) {
17740 elem_result_loc->value->special = ConstValSpecialRuntime;
17741 }
17742 IrInstGen *store_ptr_inst = ir_analyze_store_ptr(
17743 ira, &elem_result_loc->base, elem_result_loc, deref, true);
17744 if (type_is_invalid(store_ptr_inst->value->type))
17745 return ira->codegen->invalid_inst_gen;
17746 }
17747 }
17748
17749 const_ptrs.deinit();
17750
17751 return ir_get_deref(ira, source_instr, new_struct_ptr, nullptr);
17752}
17753
17552static IrInstGen *ir_analyze_array_mult(IrAnalyze *ira, IrInstSrcBinOp *instruction) {17754static IrInstGen *ir_analyze_array_mult(IrAnalyze *ira, IrInstSrcBinOp *instruction) {
17553 IrInstGen *op1 = instruction->op1->child;17755 IrInstGen *op1 = instruction->op1->child;
17554 if (type_is_invalid(op1->value->type))17756 if (type_is_invalid(op1->value->type))
...@@ -17566,8 +17768,9 @@ static IrInstGen *ir_analyze_array_mult(IrAnalyze *ira, IrInstSrcBinOp *instruct...@@ -17566,8 +17768,9 @@ static IrInstGen *ir_analyze_array_mult(IrAnalyze *ira, IrInstSrcBinOp *instruct
17566 array_val = ir_resolve_const(ira, op1, UndefOk);17768 array_val = ir_resolve_const(ira, op1, UndefOk);
17567 if (array_val == nullptr)17769 if (array_val == nullptr)
17568 return ira->codegen->invalid_inst_gen;17770 return ira->codegen->invalid_inst_gen;
17569 } else if (op1->value->type->id == ZigTypeIdPointer && op1->value->type->data.pointer.ptr_len == PtrLenSingle &&17771 } else if (op1->value->type->id == ZigTypeIdPointer &&
17570 op1->value->type->data.pointer.child_type->id == ZigTypeIdArray)17772 op1->value->type->data.pointer.ptr_len == PtrLenSingle &&
17773 op1->value->type->data.pointer.child_type->id == ZigTypeIdArray)
17571 {17774 {
17572 array_type = op1->value->type->data.pointer.child_type;17775 array_type = op1->value->type->data.pointer.child_type;
17573 IrInstGen *array_inst = ir_get_deref(ira, &op1->base, op1, nullptr);17776 IrInstGen *array_inst = ir_get_deref(ira, &op1->base, op1, nullptr);
...@@ -17577,6 +17780,8 @@ static IrInstGen *ir_analyze_array_mult(IrAnalyze *ira, IrInstSrcBinOp *instruct...@@ -17577,6 +17780,8 @@ static IrInstGen *ir_analyze_array_mult(IrAnalyze *ira, IrInstSrcBinOp *instruct
17577 if (array_val == nullptr)17780 if (array_val == nullptr)
17578 return ira->codegen->invalid_inst_gen;17781 return ira->codegen->invalid_inst_gen;
17579 want_ptr_to_array = true;17782 want_ptr_to_array = true;
17783 } else if (is_tuple(op1->value->type)) {
17784 return ir_analyze_tuple_mult(ira, &instruction->base.base, op1, op2);
17580 } else {17785 } else {
17581 ir_add_error(ira, &op1->base, buf_sprintf("expected array type, found '%s'", buf_ptr(&op1->value->type->name)));17786 ir_add_error(ira, &op1->base, buf_sprintf("expected array type, found '%s'", buf_ptr(&op1->value->type->name)));
17582 return ira->codegen->invalid_inst_gen;17787 return ira->codegen->invalid_inst_gen;
...@@ -20308,24 +20513,45 @@ static IrInstGen *ir_analyze_bin_not(IrAnalyze *ira, IrInstSrcUnOp *instruction)...@@ -20308,24 +20513,45 @@ static IrInstGen *ir_analyze_bin_not(IrAnalyze *ira, IrInstSrcUnOp *instruction)
20308 if (type_is_invalid(expr_type))20513 if (type_is_invalid(expr_type))
20309 return ira->codegen->invalid_inst_gen;20514 return ira->codegen->invalid_inst_gen;
2031020515
20311 if (expr_type->id == ZigTypeIdInt) {20516 ZigType *scalar_type = (expr_type->id == ZigTypeIdVector) ?
20312 if (instr_is_comptime(value)) {20517 expr_type->data.vector.elem_type : expr_type;
20313 ZigValue *target_const_val = ir_resolve_const(ira, value, UndefBad);
20314 if (target_const_val == nullptr)
20315 return ira->codegen->invalid_inst_gen;
2031620518
20317 IrInstGen *result = ir_const(ira, &instruction->base.base, expr_type);20519 if (scalar_type->id != ZigTypeIdInt) {
20318 bigint_not(&result->value->data.x_bigint, &target_const_val->data.x_bigint,20520 ir_add_error(ira, &instruction->base.base,
20319 expr_type->data.integral.bit_count, expr_type->data.integral.is_signed);20521 buf_sprintf("unable to perform binary not operation on type '%s'", buf_ptr(&expr_type->name)));
20320 return result;20522 return ira->codegen->invalid_inst_gen;
20523 }
20524
20525 if (instr_is_comptime(value)) {
20526 ZigValue *expr_val = ir_resolve_const(ira, value, UndefBad);
20527 if (expr_val == nullptr)
20528 return ira->codegen->invalid_inst_gen;
20529
20530 IrInstGen *result = ir_const(ira, &instruction->base.base, expr_type);
20531
20532 if (expr_type->id == ZigTypeIdVector) {
20533 expand_undef_array(ira->codegen, expr_val);
20534 result->value->special = ConstValSpecialUndef;
20535 expand_undef_array(ira->codegen, result->value);
20536
20537 for (size_t i = 0; i < expr_type->data.vector.len; i++) {
20538 ZigValue *src_val = &expr_val->data.x_array.data.s_none.elements[i];
20539 ZigValue *dst_val = &result->value->data.x_array.data.s_none.elements[i];
20540
20541 dst_val->type = scalar_type;
20542 dst_val->special = ConstValSpecialStatic;
20543 bigint_not(&dst_val->data.x_bigint, &src_val->data.x_bigint,
20544 scalar_type->data.integral.bit_count, scalar_type->data.integral.is_signed);
20545 }
20546 } else {
20547 bigint_not(&result->value->data.x_bigint, &expr_val->data.x_bigint,
20548 scalar_type->data.integral.bit_count, scalar_type->data.integral.is_signed);
20321 }20549 }
2032220550
20323 return ir_build_binary_not(ira, &instruction->base.base, value, expr_type);20551 return result;
20324 }20552 }
2032520553
20326 ir_add_error(ira, &instruction->base.base,20554 return ir_build_binary_not(ira, &instruction->base.base, value, expr_type);
20327 buf_sprintf("unable to perform binary not operation on type '%s'", buf_ptr(&expr_type->name)));
20328 return ira->codegen->invalid_inst_gen;
20329}20555}
2033020556
20331static IrInstGen *ir_analyze_instruction_un_op(IrAnalyze *ira, IrInstSrcUnOp *instruction) {20557static IrInstGen *ir_analyze_instruction_un_op(IrAnalyze *ira, IrInstSrcUnOp *instruction) {
...@@ -20923,7 +21149,11 @@ static IrInstGen *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstSrcElemP...@@ -20923,7 +21149,11 @@ static IrInstGen *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstSrcElemP
2092321149
20924 bool safety_check_on = elem_ptr_instruction->safety_check_on;21150 bool safety_check_on = elem_ptr_instruction->safety_check_on;
20925 if (instr_is_comptime(casted_elem_index)) {21151 if (instr_is_comptime(casted_elem_index)) {
20926 uint64_t index = bigint_as_u64(&casted_elem_index->value->data.x_bigint);21152 ZigValue *index_val = ir_resolve_const(ira, casted_elem_index, UndefBad);
21153 if (index_val == nullptr)
21154 return ira->codegen->invalid_inst_gen;
21155 uint64_t index = bigint_as_u64(&index_val->data.x_bigint);
21156
20927 if (array_type->id == ZigTypeIdArray) {21157 if (array_type->id == ZigTypeIdArray) {
20928 uint64_t array_len = array_type->data.array.len +21158 uint64_t array_len = array_type->data.array.len +
20929 (array_type->data.array.sentinel != nullptr);21159 (array_type->data.array.sentinel != nullptr);
...@@ -23118,7 +23348,16 @@ static IrInstGen *ir_analyze_instruction_ref(IrAnalyze *ira, IrInstSrcRef *ref_i...@@ -23118,7 +23348,16 @@ static IrInstGen *ir_analyze_instruction_ref(IrAnalyze *ira, IrInstSrcRef *ref_i
23118 IrInstGen *value = ref_instruction->value->child;23348 IrInstGen *value = ref_instruction->value->child;
23119 if (type_is_invalid(value->value->type))23349 if (type_is_invalid(value->value->type))
23120 return ira->codegen->invalid_inst_gen;23350 return ira->codegen->invalid_inst_gen;
23121 return ir_get_ref(ira, &ref_instruction->base.base, value, ref_instruction->is_const, ref_instruction->is_volatile);23351
23352 bool is_const = false;
23353 bool is_volatile = false;
23354
23355 ZigValue *child_value = value->value;
23356 if (child_value->special == ConstValSpecialStatic) {
23357 is_const = true;
23358 }
23359
23360 return ir_get_ref(ira, &ref_instruction->base.base, value, is_const, is_volatile);
23122}23361}
2312323362
23124static IrInstGen *ir_analyze_union_init(IrAnalyze *ira, IrInst* source_instruction,23363static IrInstGen *ir_analyze_union_init(IrAnalyze *ira, IrInst* source_instruction,
...@@ -23317,10 +23556,14 @@ static IrInstGen *ir_analyze_instruction_container_init_list(IrAnalyze *ira,...@@ -23317,10 +23556,14 @@ static IrInstGen *ir_analyze_instruction_container_init_list(IrAnalyze *ira,
23317 IrInstGen *result_loc = instruction->result_loc->child;23556 IrInstGen *result_loc = instruction->result_loc->child;
23318 if (type_is_invalid(result_loc->value->type))23557 if (type_is_invalid(result_loc->value->type))
23319 return result_loc;23558 return result_loc;
23559
23320 ir_assert(result_loc->value->type->id == ZigTypeIdPointer, &instruction->base.base);23560 ir_assert(result_loc->value->type->id == ZigTypeIdPointer, &instruction->base.base);
23561 if (result_loc->value->type->data.pointer.is_const) {
23562 ir_add_error(ira, &instruction->base.base, buf_sprintf("cannot assign to constant"));
23563 return ira->codegen->invalid_inst_gen;
23564 }
2332123565
23322 ZigType *container_type = result_loc->value->type->data.pointer.child_type;23566 ZigType *container_type = result_loc->value->type->data.pointer.child_type;
23323
23324 size_t elem_count = instruction->item_count;23567 size_t elem_count = instruction->item_count;
2332523568
23326 if (is_slice(container_type)) {23569 if (is_slice(container_type)) {
...@@ -23471,6 +23714,11 @@ static IrInstGen *ir_analyze_instruction_container_init_fields(IrAnalyze *ira,...@@ -23471,6 +23714,11 @@ static IrInstGen *ir_analyze_instruction_container_init_fields(IrAnalyze *ira,
23471 return result_loc;23714 return result_loc;
2347223715
23473 ir_assert(result_loc->value->type->id == ZigTypeIdPointer, &instruction->base.base);23716 ir_assert(result_loc->value->type->id == ZigTypeIdPointer, &instruction->base.base);
23717 if (result_loc->value->type->data.pointer.is_const) {
23718 ir_add_error(ira, &instruction->base.base, buf_sprintf("cannot assign to constant"));
23719 return ira->codegen->invalid_inst_gen;
23720 }
23721
23474 ZigType *container_type = result_loc->value->type->data.pointer.child_type;23722 ZigType *container_type = result_loc->value->type->data.pointer.child_type;
2347523723
23476 return ir_analyze_container_init_fields(ira, &instruction->base.base, container_type,23724 return ir_analyze_container_init_fields(ira, &instruction->base.base, container_type,
...@@ -26583,7 +26831,6 @@ done_with_return_type:...@@ -26583,7 +26831,6 @@ done_with_return_type:
26583 if (parent_ptr == nullptr)26831 if (parent_ptr == nullptr)
26584 return ira->codegen->invalid_inst_gen;26832 return ira->codegen->invalid_inst_gen;
2658526833
26586
26587 if (parent_ptr->special == ConstValSpecialUndef) {26834 if (parent_ptr->special == ConstValSpecialUndef) {
26588 array_val = nullptr;26835 array_val = nullptr;
26589 abs_offset = 0;26836 abs_offset = 0;
...@@ -26746,6 +26993,113 @@ done_with_return_type:...@@ -26746,6 +26993,113 @@ done_with_return_type:
26746 return ira->codegen->invalid_inst_gen;26993 return ira->codegen->invalid_inst_gen;
26747 }26994 }
2674826995
26996 // check sentinel when target is comptime-known
26997 {
26998 if (!sentinel_val)
26999 goto exit_check_sentinel;
27000
27001 switch (ptr_ptr->value->data.x_ptr.mut) {
27002 case ConstPtrMutComptimeConst:
27003 case ConstPtrMutComptimeVar:
27004 break;
27005 case ConstPtrMutRuntimeVar:
27006 case ConstPtrMutInfer:
27007 goto exit_check_sentinel;
27008 }
27009
27010 // prepare check parameters
27011 ZigValue *target = const_ptr_pointee(ira, ira->codegen, ptr_ptr->value, instruction->base.base.source_node);
27012 if (target == nullptr)
27013 return ira->codegen->invalid_inst_gen;
27014
27015 uint64_t target_len = 0;
27016 ZigValue *target_sentinel = nullptr;
27017 ZigValue *target_elements = nullptr;
27018
27019 for (;;) {
27020 if (target->type->id == ZigTypeIdArray) {
27021 // handle `[N]T`
27022 target_len = target->type->data.array.len;
27023 target_sentinel = target->type->data.array.sentinel;
27024 target_elements = target->data.x_array.data.s_none.elements;
27025 break;
27026 } else if (target->type->id == ZigTypeIdPointer && target->type->data.pointer.child_type->id == ZigTypeIdArray) {
27027 // handle `*[N]T`
27028 target = const_ptr_pointee(ira, ira->codegen, target, instruction->base.base.source_node);
27029 if (target == nullptr)
27030 return ira->codegen->invalid_inst_gen;
27031 assert(target->type->id == ZigTypeIdArray);
27032 continue;
27033 } else if (target->type->id == ZigTypeIdPointer) {
27034 // handle `[*]T`
27035 // handle `[*c]T`
27036 switch (target->data.x_ptr.special) {
27037 case ConstPtrSpecialInvalid:
27038 case ConstPtrSpecialDiscard:
27039 zig_unreachable();
27040 case ConstPtrSpecialRef:
27041 target = target->data.x_ptr.data.ref.pointee;
27042 assert(target->type->id == ZigTypeIdArray);
27043 continue;
27044 case ConstPtrSpecialBaseArray:
27045 case ConstPtrSpecialSubArray:
27046 target = target->data.x_ptr.data.base_array.array_val;
27047 assert(target->type->id == ZigTypeIdArray);
27048 continue;
27049 case ConstPtrSpecialBaseStruct:
27050 zig_panic("TODO slice const inner struct");
27051 case ConstPtrSpecialBaseErrorUnionCode:
27052 zig_panic("TODO slice const inner error union code");
27053 case ConstPtrSpecialBaseErrorUnionPayload:
27054 zig_panic("TODO slice const inner error union payload");
27055 case ConstPtrSpecialBaseOptionalPayload:
27056 zig_panic("TODO slice const inner optional payload");
27057 case ConstPtrSpecialHardCodedAddr:
27058 // skip check
27059 goto exit_check_sentinel;
27060 case ConstPtrSpecialFunction:
27061 zig_panic("TODO slice of ptr cast from function");
27062 case ConstPtrSpecialNull:
27063 zig_panic("TODO slice of null ptr");
27064 }
27065 break;
27066 } else if (is_slice(target->type)) {
27067 // handle `[]T`
27068 target = target->data.x_struct.fields[slice_ptr_index];
27069 assert(target->type->id == ZigTypeIdPointer);
27070 continue;
27071 }
27072
27073 zig_unreachable();
27074 }
27075
27076 // perform check
27077 if (target_sentinel == nullptr) {
27078 if (end_scalar >= target_len) {
27079 ir_add_error(ira, &instruction->base.base, buf_sprintf("slice-sentinel is out of bounds"));
27080 return ira->codegen->invalid_inst_gen;
27081 }
27082 if (!const_values_equal(ira->codegen, sentinel_val, &target_elements[end_scalar])) {
27083 ir_add_error(ira, &instruction->base.base, buf_sprintf("slice-sentinel does not match memory at target index"));
27084 return ira->codegen->invalid_inst_gen;
27085 }
27086 } else {
27087 assert(end_scalar <= target_len);
27088 if (end_scalar == target_len) {
27089 if (!const_values_equal(ira->codegen, sentinel_val, target_sentinel)) {
27090 ir_add_error(ira, &instruction->base.base, buf_sprintf("slice-sentinel does not match target-sentinel"));
27091 return ira->codegen->invalid_inst_gen;
27092 }
27093 } else {
27094 if (!const_values_equal(ira->codegen, sentinel_val, &target_elements[end_scalar])) {
27095 ir_add_error(ira, &instruction->base.base, buf_sprintf("slice-sentinel does not match memory at target index"));
27096 return ira->codegen->invalid_inst_gen;
27097 }
27098 }
27099 }
27100 }
27101 exit_check_sentinel:
27102
26749 IrInstGen *result = ir_const(ira, &instruction->base.base, return_type);27103 IrInstGen *result = ir_const(ira, &instruction->base.base, return_type);
2675027104
26751 ZigValue *ptr_val;27105 ZigValue *ptr_val;
...@@ -26834,6 +27188,13 @@ done_with_return_type:...@@ -26834,6 +27188,13 @@ done_with_return_type:
26834 if (type_is_invalid(result_loc->value->type) || result_loc->value->type->id == ZigTypeIdUnreachable) {27188 if (type_is_invalid(result_loc->value->type) || result_loc->value->type->id == ZigTypeIdUnreachable) {
26835 return result_loc;27189 return result_loc;
26836 }27190 }
27191
27192 ir_assert(result_loc->value->type->id == ZigTypeIdPointer, &instruction->base.base);
27193 if (result_loc->value->type->data.pointer.is_const) {
27194 ir_add_error(ira, &instruction->base.base, buf_sprintf("cannot assign to constant"));
27195 return ira->codegen->invalid_inst_gen;
27196 }
27197
26837 IrInstGen *dummy_value = ir_const(ira, &instruction->base.base, return_type);27198 IrInstGen *dummy_value = ir_const(ira, &instruction->base.base, return_type);
26838 dummy_value->value->special = ConstValSpecialRuntime;27199 dummy_value->value->special = ConstValSpecialRuntime;
26839 IrInstGen *dummy_result = ir_implicit_cast2(ira, &instruction->base.base,27200 IrInstGen *dummy_result = ir_implicit_cast2(ira, &instruction->base.base,
...@@ -28311,6 +28672,7 @@ static Error buf_read_value_bytes(IrAnalyze *ira, CodeGen *codegen, AstNode *sou...@@ -28311,6 +28672,7 @@ static Error buf_read_value_bytes(IrAnalyze *ira, CodeGen *codegen, AstNode *sou
28311 }28672 }
28312 BigInt big_int;28673 BigInt big_int;
28313 bigint_read_twos_complement(&big_int, buf + offset, big_int_byte_count * 8, is_big_endian, false);28674 bigint_read_twos_complement(&big_int, buf + offset, big_int_byte_count * 8, is_big_endian, false);
28675 uint64_t bit_offset = 0;
28314 while (src_i < src_field_count) {28676 while (src_i < src_field_count) {
28315 TypeStructField *field = val->type->data.structure.fields[src_i];28677 TypeStructField *field = val->type->data.structure.fields[src_i];
28316 src_assert(field->gen_index != SIZE_MAX, source_node);28678 src_assert(field->gen_index != SIZE_MAX, source_node);
...@@ -28323,7 +28685,11 @@ static Error buf_read_value_bytes(IrAnalyze *ira, CodeGen *codegen, AstNode *sou...@@ -28323,7 +28685,11 @@ static Error buf_read_value_bytes(IrAnalyze *ira, CodeGen *codegen, AstNode *sou
2832328685
28324 BigInt child_val;28686 BigInt child_val;
28325 if (is_big_endian) {28687 if (is_big_endian) {
28326 zig_panic("TODO buf_read_value_bytes packed struct big endian");28688 BigInt packed_bits_size_bi;
28689 bigint_init_unsigned(&packed_bits_size_bi, big_int_byte_count * 8 - packed_bits_size - bit_offset);
28690 BigInt tmp;
28691 bigint_shr(&tmp, &big_int, &packed_bits_size_bi);
28692 bigint_truncate(&child_val, &tmp, packed_bits_size, false);
28327 } else {28693 } else {
28328 BigInt packed_bits_size_bi;28694 BigInt packed_bits_size_bi;
28329 bigint_init_unsigned(&packed_bits_size_bi, packed_bits_size);28695 bigint_init_unsigned(&packed_bits_size_bi, packed_bits_size);
...@@ -28333,11 +28699,12 @@ static Error buf_read_value_bytes(IrAnalyze *ira, CodeGen *codegen, AstNode *sou...@@ -28333,11 +28699,12 @@ static Error buf_read_value_bytes(IrAnalyze *ira, CodeGen *codegen, AstNode *sou
28333 big_int = tmp;28699 big_int = tmp;
28334 }28700 }
2833528701
28336 bigint_write_twos_complement(&child_val, child_buf, big_int_byte_count * 8, is_big_endian);28702 bigint_write_twos_complement(&child_val, child_buf, packed_bits_size, is_big_endian);
28337 if ((err = buf_read_value_bytes(ira, codegen, source_node, child_buf, field_val))) {28703 if ((err = buf_read_value_bytes(ira, codegen, source_node, child_buf, field_val))) {
28338 return err;28704 return err;
28339 }28705 }
2834028706
28707 bit_offset += packed_bits_size;
28341 src_i += 1;28708 src_i += 1;
28342 }28709 }
28343 offset += big_int_byte_count;28710 offset += big_int_byte_count;
src/ir_print.cpp+1-3
...@@ -1476,9 +1476,7 @@ static void ir_print_import(IrPrintSrc *irp, IrInstSrcImport *instruction) {...@@ -1476,9 +1476,7 @@ static void ir_print_import(IrPrintSrc *irp, IrInstSrcImport *instruction) {
1476}1476}
14771477
1478static void ir_print_ref(IrPrintSrc *irp, IrInstSrcRef *instruction) {1478static void ir_print_ref(IrPrintSrc *irp, IrInstSrcRef *instruction) {
1479 const char *const_str = instruction->is_const ? "const " : "";1479 fprintf(irp->f, "ref ");
1480 const char *volatile_str = instruction->is_volatile ? "volatile " : "";
1481 fprintf(irp->f, "%s%sref ", const_str, volatile_str);
1482 ir_print_other_inst_src(irp, instruction->value);1480 ir_print_other_inst_src(irp, instruction->value);
1483}1481}
14841482
src/link.cpp+98-12
...@@ -72,7 +72,7 @@ static const char *msvcrt_common_src[] = {...@@ -72,7 +72,7 @@ static const char *msvcrt_common_src[] = {
7272
73static const char *msvcrt_i386_src[] = {73static const char *msvcrt_i386_src[] = {
74 "misc" OS_SEP "lc_locale_func.c",74 "misc" OS_SEP "lc_locale_func.c",
7575 "misc" OS_SEP "___mb_cur_max_func.c",
76};76};
7777
78static const char *msvcrt_other_src[] = {78static const char *msvcrt_other_src[] = {
...@@ -517,6 +517,52 @@ static const char *mingwex_arm64_src[] = {...@@ -517,6 +517,52 @@ static const char *mingwex_arm64_src[] = {
517 "math" OS_SEP "arm64" OS_SEP "trunc.S",517 "math" OS_SEP "arm64" OS_SEP "trunc.S",
518};518};
519519
520static const char *mingw_uuid_src[] = {
521 "libsrc/ativscp-uuid.c",
522 "libsrc/atsmedia-uuid.c",
523 "libsrc/bth-uuid.c",
524 "libsrc/cguid-uuid.c",
525 "libsrc/comcat-uuid.c",
526 "libsrc/devguid.c",
527 "libsrc/docobj-uuid.c",
528 "libsrc/dxva-uuid.c",
529 "libsrc/exdisp-uuid.c",
530 "libsrc/extras-uuid.c",
531 "libsrc/fwp-uuid.c",
532 "libsrc/guid_nul.c",
533 "libsrc/hlguids-uuid.c",
534 "libsrc/hlink-uuid.c",
535 "libsrc/mlang-uuid.c",
536 "libsrc/msctf-uuid.c",
537 "libsrc/mshtmhst-uuid.c",
538 "libsrc/mshtml-uuid.c",
539 "libsrc/msxml-uuid.c",
540 "libsrc/netcon-uuid.c",
541 "libsrc/ntddkbd-uuid.c",
542 "libsrc/ntddmou-uuid.c",
543 "libsrc/ntddpar-uuid.c",
544 "libsrc/ntddscsi-uuid.c",
545 "libsrc/ntddser-uuid.c",
546 "libsrc/ntddstor-uuid.c",
547 "libsrc/ntddvdeo-uuid.c",
548 "libsrc/oaidl-uuid.c",
549 "libsrc/objidl-uuid.c",
550 "libsrc/objsafe-uuid.c",
551 "libsrc/ocidl-uuid.c",
552 "libsrc/oleacc-uuid.c",
553 "libsrc/olectlid-uuid.c",
554 "libsrc/oleidl-uuid.c",
555 "libsrc/power-uuid.c",
556 "libsrc/powrprof-uuid.c",
557 "libsrc/uianimation-uuid.c",
558 "libsrc/usbcamdi-uuid.c",
559 "libsrc/usbiodef-uuid.c",
560 "libsrc/uuid.c",
561 "libsrc/vds-uuid.c",
562 "libsrc/virtdisk-uuid.c",
563 "libsrc/wia-uuid.c",
564};
565
520struct MinGWDef {566struct MinGWDef {
521 const char *name;567 const char *name;
522 bool always_link;568 bool always_link;
...@@ -541,11 +587,13 @@ static const MinGWDef mingw_def_list[] = {...@@ -541,11 +587,13 @@ static const MinGWDef mingw_def_list[] = {
541 {"ole32", false},587 {"ole32", false},
542 {"oleaut32",false},588 {"oleaut32",false},
543 {"opengl32",false},589 {"opengl32",false},
590 {"psapi", false},
544 {"rpcns4", false},591 {"rpcns4", false},
545 {"rpcrt4", false},592 {"rpcrt4", false},
546 {"scarddlg",false},593 {"scarddlg",false},
547 {"setupapi",false},594 {"setupapi",false},
548 {"shell32", true},595 {"shell32", true},
596 {"shlwapi", false},
549 {"urlmon", false},597 {"urlmon", false},
550 {"user32", true},598 {"user32", true},
551 {"version", false},599 {"version", false},
...@@ -1261,7 +1309,32 @@ static void add_msvcrt_os_dep(CodeGen *parent, CodeGen *child_gen, const char *s...@@ -1261,7 +1309,32 @@ static void add_msvcrt_os_dep(CodeGen *parent, CodeGen *child_gen, const char *s
1261 child_gen->c_source_files.append(c_file);1309 child_gen->c_source_files.append(c_file);
1262}1310}
12631311
1264static void add_mingwex_os_dep(CodeGen *parent, CodeGen *child_gen, const char *src_path) {1312static void add_mingwex_dep(CodeGen *parent, CodeGen *child_gen, const char *src_path) {
1313 CFile *c_file = heap::c_allocator.create<CFile>();
1314 c_file->source_path = buf_ptr(buf_sprintf("%s" OS_SEP "libc" OS_SEP "mingw" OS_SEP "%s",
1315 buf_ptr(parent->zig_lib_dir), src_path));
1316 c_file->args.append("-DHAVE_CONFIG_H");
1317
1318 c_file->args.append("-I");
1319 c_file->args.append(path_from_libc(parent, "mingw"));
1320
1321 c_file->args.append("-I");
1322 c_file->args.append(path_from_libc(parent, "mingw" OS_SEP "include"));
1323
1324 c_file->args.append("-std=gnu99");
1325 c_file->args.append("-D_CRTBLD");
1326 c_file->args.append("-D_WIN32_WINNT=0x0f00");
1327 c_file->args.append("-D__MSVCRT_VERSION__=0x700");
1328 c_file->args.append("-g");
1329 c_file->args.append("-O2");
1330
1331 c_file->args.append("-isystem");
1332 c_file->args.append(path_from_libc(parent, "include" OS_SEP "any-windows-any"));
1333
1334 child_gen->c_source_files.append(c_file);
1335}
1336
1337static void add_mingw_uuid_dep(CodeGen *parent, CodeGen *child_gen, const char *src_path) {
1265 CFile *c_file = heap::c_allocator.create<CFile>();1338 CFile *c_file = heap::c_allocator.create<CFile>();
1266 c_file->source_path = buf_ptr(buf_sprintf("%s" OS_SEP "libc" OS_SEP "mingw" OS_SEP "%s",1339 c_file->source_path = buf_ptr(buf_sprintf("%s" OS_SEP "libc" OS_SEP "mingw" OS_SEP "%s",
1267 buf_ptr(parent->zig_lib_dir), src_path));1340 buf_ptr(parent->zig_lib_dir), src_path));
...@@ -1387,20 +1460,20 @@ static const char *get_libc_crt_file(CodeGen *parent, const char *file, Stage2Pr...@@ -1387,20 +1460,20 @@ static const char *get_libc_crt_file(CodeGen *parent, const char *file, Stage2Pr
1387 CodeGen *child_gen = create_child_codegen(parent, nullptr, OutTypeLib, nullptr, "mingwex", progress_node);1460 CodeGen *child_gen = create_child_codegen(parent, nullptr, OutTypeLib, nullptr, "mingwex", progress_node);
13881461
1389 for (size_t i = 0; i < array_length(mingwex_generic_src); i += 1) {1462 for (size_t i = 0; i < array_length(mingwex_generic_src); i += 1) {
1390 add_mingwex_os_dep(parent, child_gen, mingwex_generic_src[i]);1463 add_mingwex_dep(parent, child_gen, mingwex_generic_src[i]);
1391 }1464 }
1392 if (parent->zig_target->arch == ZigLLVM_x86 || parent->zig_target->arch == ZigLLVM_x86_64) {1465 if (parent->zig_target->arch == ZigLLVM_x86 || parent->zig_target->arch == ZigLLVM_x86_64) {
1393 for (size_t i = 0; i < array_length(mingwex_x86_src); i += 1) {1466 for (size_t i = 0; i < array_length(mingwex_x86_src); i += 1) {
1394 add_mingwex_os_dep(parent, child_gen, mingwex_x86_src[i]);1467 add_mingwex_dep(parent, child_gen, mingwex_x86_src[i]);
1395 }1468 }
1396 } else if (target_is_arm(parent->zig_target)) {1469 } else if (target_is_arm(parent->zig_target)) {
1397 if (target_arch_pointer_bit_width(parent->zig_target->arch) == 32) {1470 if (target_arch_pointer_bit_width(parent->zig_target->arch) == 32) {
1398 for (size_t i = 0; i < array_length(mingwex_arm32_src); i += 1) {1471 for (size_t i = 0; i < array_length(mingwex_arm32_src); i += 1) {
1399 add_mingwex_os_dep(parent, child_gen, mingwex_arm32_src[i]);1472 add_mingwex_dep(parent, child_gen, mingwex_arm32_src[i]);
1400 }1473 }
1401 } else {1474 } else {
1402 for (size_t i = 0; i < array_length(mingwex_arm64_src); i += 1) {1475 for (size_t i = 0; i < array_length(mingwex_arm64_src); i += 1) {
1403 add_mingwex_os_dep(parent, child_gen, mingwex_arm64_src[i]);1476 add_mingwex_dep(parent, child_gen, mingwex_arm64_src[i]);
1404 }1477 }
1405 }1478 }
1406 } else {1479 } else {
...@@ -1408,6 +1481,13 @@ static const char *get_libc_crt_file(CodeGen *parent, const char *file, Stage2Pr...@@ -1408,6 +1481,13 @@ static const char *get_libc_crt_file(CodeGen *parent, const char *file, Stage2Pr
1408 }1481 }
1409 codegen_build_and_link(child_gen);1482 codegen_build_and_link(child_gen);
1410 return buf_ptr(&child_gen->bin_file_output_path);1483 return buf_ptr(&child_gen->bin_file_output_path);
1484 } else if (strcmp(file, "uuid.lib") == 0) {
1485 CodeGen *child_gen = create_child_codegen(parent, nullptr, OutTypeLib, nullptr, "uuid", progress_node);
1486 for (size_t i = 0; i < array_length(mingw_uuid_src); i += 1) {
1487 add_mingw_uuid_dep(parent, child_gen, mingw_uuid_src[i]);
1488 }
1489 codegen_build_and_link(child_gen);
1490 return buf_ptr(&child_gen->bin_file_output_path);
1411 } else {1491 } else {
1412 zig_unreachable();1492 zig_unreachable();
1413 }1493 }
...@@ -1761,7 +1841,8 @@ static void construct_linker_job_elf(LinkJob *lj) {...@@ -1761,7 +1841,8 @@ static void construct_linker_job_elf(LinkJob *lj) {
17611841
1762 if (g->out_type == OutTypeExe) {1842 if (g->out_type == OutTypeExe) {
1763 lj->args.append("-z");1843 lj->args.append("-z");
1764 lj->args.append("stack-size=16777216"); // default to 16 MiB1844 size_t stack_size = (g->stack_size_override == 0) ? 16777216 : g->stack_size_override;
1845 lj->args.append(buf_ptr(buf_sprintf("stack-size=%" ZIG_PRI_usize, stack_size)));
1765 }1846 }
17661847
1767 if (g->linker_script) {1848 if (g->linker_script) {
...@@ -2400,7 +2481,8 @@ static void construct_linker_job_coff(LinkJob *lj) {...@@ -2400,7 +2481,8 @@ static void construct_linker_job_coff(LinkJob *lj) {
24002481
2401 if (g->out_type == OutTypeExe) {2482 if (g->out_type == OutTypeExe) {
2402 // TODO compile time stack upper bound detection2483 // TODO compile time stack upper bound detection
2403 lj->args.append("-STACK:16777216");2484 size_t stack_size = (g->stack_size_override == 0) ? 16777216 : g->stack_size_override;
2485 lj->args.append(buf_ptr(buf_sprintf("-STACK:%" ZIG_PRI_usize, stack_size)));
2404 }2486 }
24052487
2406 coff_append_machine_arg(g, &lj->args);2488 coff_append_machine_arg(g, &lj->args);
...@@ -2526,10 +2608,14 @@ static void construct_linker_job_coff(LinkJob *lj) {...@@ -2526,10 +2608,14 @@ static void construct_linker_job_coff(LinkJob *lj) {
2526 // If we're linking in the CRT or the libs are provided explictly we don't want to generate def/libs2608 // If we're linking in the CRT or the libs are provided explictly we don't want to generate def/libs
2527 if ((lj->link_in_crt && is_sys_lib) || link_lib->provided_explicitly) {2609 if ((lj->link_in_crt && is_sys_lib) || link_lib->provided_explicitly) {
2528 if (target_abi_is_gnu(lj->codegen->zig_target->abi)) {2610 if (target_abi_is_gnu(lj->codegen->zig_target->abi)) {
2529 Buf* lib_name = buf_sprintf("lib%s.a", buf_ptr(link_lib->name));2611 if (buf_eql_str(link_lib->name, "uuid")) {
2530 lj->args.append(buf_ptr(lib_name));2612 // mingw-w64 provides this lib
2531 }2613 lj->args.append(get_libc_crt_file(g, "uuid.lib", lj->build_dep_prog_node));
2532 else {2614 } else {
2615 Buf* lib_name = buf_sprintf("lib%s.a", buf_ptr(link_lib->name));
2616 lj->args.append(buf_ptr(lib_name));
2617 }
2618 } else {
2533 Buf* lib_name = buf_sprintf("%s.lib", buf_ptr(link_lib->name));2619 Buf* lib_name = buf_sprintf("%s.lib", buf_ptr(link_lib->name));
2534 lj->args.append(buf_ptr(lib_name));2620 lj->args.append(buf_ptr(lib_name));
2535 }2621 }
src/main.cpp+35-15
...@@ -260,18 +260,6 @@ static int main0(int argc, char **argv) {...@@ -260,18 +260,6 @@ static int main0(int argc, char **argv) {
260 char *arg0 = argv[0];260 char *arg0 = argv[0];
261 Error err;261 Error err;
262262
263 if (argc == 2 && strcmp(argv[1], "BUILD_INFO") == 0) {
264 printf("%s\n%s\n%s\n%s\n%s\n%s\n%s\n",
265 ZIG_CMAKE_BINARY_DIR,
266 ZIG_CXX_COMPILER,
267 ZIG_LLVM_CONFIG_EXE,
268 ZIG_LLD_INCLUDE_PATH,
269 ZIG_LLD_LIBRARIES,
270 ZIG_CLANG_LIBRARIES,
271 ZIG_DIA_GUIDS_LIB);
272 return 0;
273 }
274
275 if (argc >= 2 && (strcmp(argv[1], "clang") == 0 ||263 if (argc >= 2 && (strcmp(argv[1], "clang") == 0 ||
276 strcmp(argv[1], "-cc1") == 0 || strcmp(argv[1], "-cc1as") == 0))264 strcmp(argv[1], "-cc1") == 0 || strcmp(argv[1], "-cc1as") == 0))
277 {265 {
...@@ -459,11 +447,13 @@ static int main0(int argc, char **argv) {...@@ -459,11 +447,13 @@ static int main0(int argc, char **argv) {
459 bool ensure_libc_on_non_freestanding = false;447 bool ensure_libc_on_non_freestanding = false;
460 bool ensure_libcpp_on_non_freestanding = false;448 bool ensure_libcpp_on_non_freestanding = false;
461 bool disable_c_depfile = false;449 bool disable_c_depfile = false;
450 bool want_native_include_dirs = false;
462 Buf *linker_optimization = nullptr;451 Buf *linker_optimization = nullptr;
463 OptionalBool linker_gc_sections = OptionalBoolNull;452 OptionalBool linker_gc_sections = OptionalBoolNull;
464 OptionalBool linker_allow_shlib_undefined = OptionalBoolNull;453 OptionalBool linker_allow_shlib_undefined = OptionalBoolNull;
465 bool linker_z_nodelete = false;454 bool linker_z_nodelete = false;
466 bool linker_z_defs = false;455 bool linker_z_defs = false;
456 size_t stack_size_override = 0;
467457
468 ZigList<const char *> llvm_argv = {0};458 ZigList<const char *> llvm_argv = {0};
469 llvm_argv.append("zig (LLVM option parsing)");459 llvm_argv.append("zig (LLVM option parsing)");
...@@ -593,6 +583,7 @@ static int main0(int argc, char **argv) {...@@ -593,6 +583,7 @@ static int main0(int argc, char **argv) {
593 strip = true;583 strip = true;
594 ensure_libc_on_non_freestanding = true;584 ensure_libc_on_non_freestanding = true;
595 ensure_libcpp_on_non_freestanding = (strcmp(argv[1], "c++") == 0);585 ensure_libcpp_on_non_freestanding = (strcmp(argv[1], "c++") == 0);
586 want_native_include_dirs = true;
596587
597 bool c_arg = false;588 bool c_arg = false;
598 Stage2ClangArgIterator it;589 Stage2ClangArgIterator it;
...@@ -759,6 +750,9 @@ static int main0(int argc, char **argv) {...@@ -759,6 +750,9 @@ static int main0(int argc, char **argv) {
759 case Stage2ClangArgFramework:750 case Stage2ClangArgFramework:
760 frameworks.append(it.only_arg);751 frameworks.append(it.only_arg);
761 break;752 break;
753 case Stage2ClangArgNoStdLibInc:
754 want_native_include_dirs = false;
755 break;
762 }756 }
763 }757 }
764 // Parse linker args758 // Parse linker args
...@@ -833,9 +827,13 @@ static int main0(int argc, char **argv) {...@@ -833,9 +827,13 @@ static int main0(int argc, char **argv) {
833 linker_gc_sections = OptionalBoolTrue;827 linker_gc_sections = OptionalBoolTrue;
834 } else if (buf_eql_str(arg, "--no-gc-sections")) {828 } else if (buf_eql_str(arg, "--no-gc-sections")) {
835 linker_gc_sections = OptionalBoolFalse;829 linker_gc_sections = OptionalBoolFalse;
836 } else if (buf_eql_str(arg, "--allow-shlib-undefined")) {830 } else if (buf_eql_str(arg, "--allow-shlib-undefined") ||
831 buf_eql_str(arg, "-allow-shlib-undefined"))
832 {
837 linker_allow_shlib_undefined = OptionalBoolTrue;833 linker_allow_shlib_undefined = OptionalBoolTrue;
838 } else if (buf_eql_str(arg, "--no-allow-shlib-undefined")) {834 } else if (buf_eql_str(arg, "--no-allow-shlib-undefined") ||
835 buf_eql_str(arg, "-no-allow-shlib-undefined"))
836 {
839 linker_allow_shlib_undefined = OptionalBoolFalse;837 linker_allow_shlib_undefined = OptionalBoolFalse;
840 } else if (buf_eql_str(arg, "-z")) {838 } else if (buf_eql_str(arg, "-z")) {
841 i += 1;839 i += 1;
...@@ -851,6 +849,27 @@ static int main0(int argc, char **argv) {...@@ -851,6 +849,27 @@ static int main0(int argc, char **argv) {
851 } else {849 } else {
852 fprintf(stderr, "warning: unsupported linker arg: -z %s\n", buf_ptr(z_arg));850 fprintf(stderr, "warning: unsupported linker arg: -z %s\n", buf_ptr(z_arg));
853 }851 }
852 } else if (buf_eql_str(arg, "--major-image-version")) {
853 i += 1;
854 if (i >= linker_args.length) {
855 fprintf(stderr, "expected linker arg after '%s'\n", buf_ptr(arg));
856 return EXIT_FAILURE;
857 }
858 ver_major = atoi(buf_ptr(linker_args.at(i)));
859 } else if (buf_eql_str(arg, "--minor-image-version")) {
860 i += 1;
861 if (i >= linker_args.length) {
862 fprintf(stderr, "expected linker arg after '%s'\n", buf_ptr(arg));
863 return EXIT_FAILURE;
864 }
865 ver_minor = atoi(buf_ptr(linker_args.at(i)));
866 } else if (buf_eql_str(arg, "--stack")) {
867 i += 1;
868 if (i >= linker_args.length) {
869 fprintf(stderr, "expected linker arg after '%s'\n", buf_ptr(arg));
870 return EXIT_FAILURE;
871 }
872 stack_size_override = atoi(buf_ptr(linker_args.at(i)));
854 } else {873 } else {
855 fprintf(stderr, "warning: unsupported linker arg: %s\n", buf_ptr(arg));874 fprintf(stderr, "warning: unsupported linker arg: %s\n", buf_ptr(arg));
856 }875 }
...@@ -1426,7 +1445,7 @@ static int main0(int argc, char **argv) {...@@ -1426,7 +1445,7 @@ static int main0(int argc, char **argv) {
1426 }1445 }
1427 }1446 }
14281447
1429 if (target.is_native_os && any_system_lib_dependencies) {1448 if (target.is_native_os && (any_system_lib_dependencies || want_native_include_dirs)) {
1430 Error err;1449 Error err;
1431 Stage2NativePaths paths;1450 Stage2NativePaths paths;
1432 if ((err = stage2_detect_native_paths(&paths))) {1451 if ((err = stage2_detect_native_paths(&paths))) {
...@@ -1576,6 +1595,7 @@ static int main0(int argc, char **argv) {...@@ -1576,6 +1595,7 @@ static int main0(int argc, char **argv) {
1576 g->linker_allow_shlib_undefined = linker_allow_shlib_undefined;1595 g->linker_allow_shlib_undefined = linker_allow_shlib_undefined;
1577 g->linker_z_nodelete = linker_z_nodelete;1596 g->linker_z_nodelete = linker_z_nodelete;
1578 g->linker_z_defs = linker_z_defs;1597 g->linker_z_defs = linker_z_defs;
1598 g->stack_size_override = stack_size_override;
15791599
1580 if (override_soname) {1600 if (override_soname) {
1581 g->override_soname = buf_create_from_str(override_soname);1601 g->override_soname = buf_create_from_str(override_soname);
src/os.cpp+2
...@@ -37,7 +37,9 @@...@@ -37,7 +37,9 @@
37#include <fcntl.h>37#include <fcntl.h>
38#include <ntsecapi.h>38#include <ntsecapi.h>
3939
40#if defined(_MSC_VER)
40typedef SSIZE_T ssize_t;41typedef SSIZE_T ssize_t;
42#endif
41#else43#else
42#define ZIG_OS_POSIX44#define ZIG_OS_POSIX
4345
src/stage2.h+2
...@@ -107,6 +107,7 @@ enum Error {...@@ -107,6 +107,7 @@ enum Error {
107 ErrorInvalidOperatingSystemVersion,107 ErrorInvalidOperatingSystemVersion,
108 ErrorUnknownClangOption,108 ErrorUnknownClangOption,
109 ErrorNestedResponseFile,109 ErrorNestedResponseFile,
110 ErrorZigIsTheCCompiler,
110};111};
111112
112// ABI warning113// ABI warning
...@@ -352,6 +353,7 @@ enum Stage2ClangArg {...@@ -352,6 +353,7 @@ enum Stage2ClangArg {
352 Stage2ClangArgDepFile,353 Stage2ClangArgDepFile,
353 Stage2ClangArgFrameworkDir,354 Stage2ClangArgFrameworkDir,
354 Stage2ClangArgFramework,355 Stage2ClangArgFramework,
356 Stage2ClangArgNoStdLibInc,
355};357};
356358
357// ABI warning359// ABI warning
src/target.cpp+2
...@@ -1238,6 +1238,8 @@ bool target_is_libc_lib_name(const ZigTarget *target, const char *name) {...@@ -1238,6 +1238,8 @@ bool target_is_libc_lib_name(const ZigTarget *target, const char *name) {
1238 return true;1238 return true;
1239 if (strcmp(name, "dl") == 0)1239 if (strcmp(name, "dl") == 0)
1240 return true;1240 return true;
1241 if (strcmp(name, "util") == 0)
1242 return true;
1241 }1243 }
12421244
1243 return false;1245 return false;
src/zig_clang.h+3-1
...@@ -50,7 +50,9 @@ enum ZigClangAPValueKind {...@@ -50,7 +50,9 @@ enum ZigClangAPValueKind {
50struct ZigClangAPValue {50struct ZigClangAPValue {
51 enum ZigClangAPValueKind Kind;51 enum ZigClangAPValueKind Kind;
52 // experimentally-derived size of clang::APValue::DataType52 // experimentally-derived size of clang::APValue::DataType
53#if defined(_WIN32) && defined(_MSC_VER)53#if defined(_WIN32) && defined(__i386__)
54 char Data[68];
55#elif defined(_WIN32) && defined(_MSC_VER)
54 char Data[52];56 char Data[52];
55#elif defined(__i386__)57#elif defined(__i386__)
56 char Data[48];58 char Data[48];
src/zig_llvm.cpp+16-1
...@@ -100,7 +100,7 @@ static const bool assertions_on = false;...@@ -100,7 +100,7 @@ static const bool assertions_on = false;
100100
101LLVMTargetMachineRef ZigLLVMCreateTargetMachine(LLVMTargetRef T, const char *Triple,101LLVMTargetMachineRef ZigLLVMCreateTargetMachine(LLVMTargetRef T, const char *Triple,
102 const char *CPU, const char *Features, LLVMCodeGenOptLevel Level, LLVMRelocMode Reloc,102 const char *CPU, const char *Features, LLVMCodeGenOptLevel Level, LLVMRelocMode Reloc,
103 LLVMCodeModel CodeModel, bool function_sections)103 LLVMCodeModel CodeModel, bool function_sections, ZigLLVMABIType float_abi, const char *abi_name)
104{104{
105 Optional<Reloc::Model> RM;105 Optional<Reloc::Model> RM;
106 switch (Reloc){106 switch (Reloc){
...@@ -147,6 +147,21 @@ LLVMTargetMachineRef ZigLLVMCreateTargetMachine(LLVMTargetRef T, const char *Tri...@@ -147,6 +147,21 @@ LLVMTargetMachineRef ZigLLVMCreateTargetMachine(LLVMTargetRef T, const char *Tri
147147
148 TargetOptions opt;148 TargetOptions opt;
149 opt.FunctionSections = function_sections;149 opt.FunctionSections = function_sections;
150 switch (float_abi) {
151 case ZigLLVMABITypeDefault:
152 opt.FloatABIType = FloatABI::Default;
153 break;
154 case ZigLLVMABITypeSoft:
155 opt.FloatABIType = FloatABI::Soft;
156 break;
157 case ZigLLVMABITypeHard:
158 opt.FloatABIType = FloatABI::Hard;
159 break;
160 }
161
162 if (abi_name != nullptr) {
163 opt.MCOptions.ABIName = abi_name;
164 }
150165
151 TargetMachine *TM = reinterpret_cast<Target*>(T)->createTargetMachine(Triple, CPU, Features, opt, RM, CM,166 TargetMachine *TM = reinterpret_cast<Target*>(T)->createTargetMachine(Triple, CPU, Features, opt, RM, CM,
152 OL, JIT);167 OL, JIT);
src/zig_llvm.h+8-1
...@@ -51,9 +51,16 @@ ZIG_EXTERN_C bool ZigLLVMTargetMachineEmitToFile(LLVMTargetMachineRef targ_machi...@@ -51,9 +51,16 @@ ZIG_EXTERN_C bool ZigLLVMTargetMachineEmitToFile(LLVMTargetMachineRef targ_machi
51 bool is_small, bool time_report,51 bool is_small, bool time_report,
52 const char *asm_filename, const char *bin_filename, const char *llvm_ir_filename);52 const char *asm_filename, const char *bin_filename, const char *llvm_ir_filename);
5353
54
55enum ZigLLVMABIType {
56 ZigLLVMABITypeDefault, // Target-specific (either soft or hard depending on triple, etc).
57 ZigLLVMABITypeSoft, // Soft float.
58 ZigLLVMABITypeHard // Hard float.
59};
60
54ZIG_EXTERN_C LLVMTargetMachineRef ZigLLVMCreateTargetMachine(LLVMTargetRef T, const char *Triple,61ZIG_EXTERN_C LLVMTargetMachineRef ZigLLVMCreateTargetMachine(LLVMTargetRef T, const char *Triple,
55 const char *CPU, const char *Features, LLVMCodeGenOptLevel Level, LLVMRelocMode Reloc,62 const char *CPU, const char *Features, LLVMCodeGenOptLevel Level, LLVMRelocMode Reloc,
56 LLVMCodeModel CodeModel, bool function_sections);63 LLVMCodeModel CodeModel, bool function_sections, ZigLLVMABIType float_abi, const char *abi_name);
5764
58ZIG_EXTERN_C LLVMTypeRef ZigLLVMTokenTypeInContext(LLVMContextRef context_ref);65ZIG_EXTERN_C LLVMTypeRef ZigLLVMTokenTypeInContext(LLVMContextRef context_ref);
5966
test/compile_errors.zig+374-5
...@@ -2,6 +2,70 @@ const tests = @import("tests.zig");...@@ -2,6 +2,70 @@ const tests = @import("tests.zig");
2const std = @import("std");2const std = @import("std");
33
4pub fn addCases(cases: *tests.CompileErrorContext) void {4pub fn addCases(cases: *tests.CompileErrorContext) void {
5 cases.addTest("reassign to array parameter",
6 \\fn reassign(a: [3]f32) void {
7 \\ a = [3]f32{4, 5, 6};
8 \\}
9 \\export fn entry() void {
10 \\ reassign(.{1, 2, 3});
11 \\}
12 , &[_][]const u8{
13 "tmp.zig:2:15: error: cannot assign to constant"
14 });
15
16 cases.addTest("reassign to slice parameter",
17 \\pub fn reassign(s: []const u8) void {
18 \\ s = s[0..];
19 \\}
20 \\export fn entry() void {
21 \\ reassign("foo");
22 \\}
23 , &[_][]const u8{
24 "tmp.zig:2:10: error: cannot assign to constant"
25 });
26
27 cases.addTest("reassign to struct parameter",
28 \\const S = struct {
29 \\ x: u32,
30 \\};
31 \\fn reassign(s: S) void {
32 \\ s = S{.x = 2};
33 \\}
34 \\export fn entry() void {
35 \\ reassign(S{.x = 3});
36 \\}
37 , &[_][]const u8{
38 "tmp.zig:5:10: error: cannot assign to constant"
39 });
40
41 cases.addTest("reference to const data",
42 \\export fn foo() void {
43 \\ var ptr = &[_]u8{0,0,0,0};
44 \\ ptr[1] = 2;
45 \\}
46 \\export fn bar() void {
47 \\ var ptr = &@as(u32, 2);
48 \\ ptr.* = 2;
49 \\}
50 \\export fn baz() void {
51 \\ var ptr = &true;
52 \\ ptr.* = false;
53 \\}
54 \\export fn qux() void {
55 \\ const S = struct{
56 \\ x: usize,
57 \\ y: usize,
58 \\ };
59 \\ var ptr = &S{.x=1,.y=2};
60 \\ ptr.x = 2;
61 \\}
62 , &[_][]const u8{
63 "tmp.zig:3:14: error: cannot assign to constant",
64 "tmp.zig:7:13: error: cannot assign to constant",
65 "tmp.zig:11:13: error: cannot assign to constant",
66 "tmp.zig:19:13: error: cannot assign to constant",
67 });
68
5 cases.addTest("cast between ?T where T is not a pointer",69 cases.addTest("cast between ?T where T is not a pointer",
6 \\pub const fnty1 = ?fn (i8) void;70 \\pub const fnty1 = ?fn (i8) void;
7 \\pub const fnty2 = ?fn (u64) void;71 \\pub const fnty2 = ?fn (u64) void;
...@@ -969,7 +1033,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {...@@ -969,7 +1033,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
969 \\ const x = 1 << &@as(u8, 10);1033 \\ const x = 1 << &@as(u8, 10);
970 \\}1034 \\}
971 , &[_][]const u8{1035 , &[_][]const u8{
972 "tmp.zig:2:21: error: shift amount has to be an integer type, but found '*u8'",1036 "tmp.zig:2:21: error: shift amount has to be an integer type, but found '*const u8'",
973 "tmp.zig:2:17: note: referenced here",1037 "tmp.zig:2:17: note: referenced here",
974 });1038 });
9751039
...@@ -978,7 +1042,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {...@@ -978,7 +1042,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
978 \\ const x = &@as(u8, 1) << 10;1042 \\ const x = &@as(u8, 1) << 10;
979 \\}1043 \\}
980 , &[_][]const u8{1044 , &[_][]const u8{
981 "tmp.zig:2:16: error: bit shifting operation expected integer type, found '*u8'",1045 "tmp.zig:2:16: error: bit shifting operation expected integer type, found '*const u8'",
982 "tmp.zig:2:27: note: referenced here",1046 "tmp.zig:2:27: note: referenced here",
983 });1047 });
9841048
...@@ -6005,7 +6069,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {...@@ -6005,7 +6069,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
6005 \\ fn bar(self: *const Foo) void {}6069 \\ fn bar(self: *const Foo) void {}
6006 \\};6070 \\};
6007 , &[_][]const u8{6071 , &[_][]const u8{
6008 "tmp.zig:2:4: error: variable of type '*comptime_int' must be const or comptime",6072 "tmp.zig:2:4: error: variable of type '*const comptime_int' must be const or comptime",
6009 "tmp.zig:5:4: error: variable of type '(undefined)' must be const or comptime",6073 "tmp.zig:5:4: error: variable of type '(undefined)' must be const or comptime",
6010 "tmp.zig:8:4: error: variable of type 'comptime_int' must be const or comptime",6074 "tmp.zig:8:4: error: variable of type 'comptime_int' must be const or comptime",
6011 "tmp.zig:11:4: error: variable of type 'comptime_float' must be const or comptime",6075 "tmp.zig:11:4: error: variable of type 'comptime_float' must be const or comptime",
...@@ -6849,12 +6913,317 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {...@@ -6849,12 +6913,317 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
6849 \\ const word: u16 = @bitCast(u16, bytes[0..]);6913 \\ const word: u16 = @bitCast(u16, bytes[0..]);
6850 \\}6914 \\}
6851 \\export fn foo2() void {6915 \\export fn foo2() void {
6852 \\ var bytes: []u8 = &[_]u8{1, 2};6916 \\ var bytes: []const u8 = &[_]u8{1, 2};
6853 \\ const word: u16 = @bitCast(u16, bytes);6917 \\ const word: u16 = @bitCast(u16, bytes);
6854 \\}6918 \\}
6855 , &[_][]const u8{6919 , &[_][]const u8{
6856 "tmp.zig:3:42: error: unable to @bitCast from pointer type '*[2]u8'",6920 "tmp.zig:3:42: error: unable to @bitCast from pointer type '*[2]u8'",
6857 "tmp.zig:7:32: error: destination type 'u16' has size 2 but source type '[]u8' has size 16",6921 "tmp.zig:7:32: error: destination type 'u16' has size 2 but source type '[]const u8' has size 16",
6858 "tmp.zig:7:37: note: referenced here",6922 "tmp.zig:7:37: note: referenced here",
6859 });6923 });
6924
6925 cases.add("comptime slice-sentinel is out of bounds (unterminated)",
6926 \\export fn foo_array() void {
6927 \\ comptime {
6928 \\ var target = [_]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10;
6929 \\ const slice = target[0..14 :0];
6930 \\ }
6931 \\}
6932 \\export fn foo_ptr_array() void {
6933 \\ comptime {
6934 \\ var buf = [_]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10;
6935 \\ var target = &buf;
6936 \\ const slice = target[0..14 :0];
6937 \\ }
6938 \\}
6939 \\export fn foo_vector_ConstPtrSpecialBaseArray() void {
6940 \\ comptime {
6941 \\ var buf = [_]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10;
6942 \\ var target: [*]u8 = &buf;
6943 \\ const slice = target[0..14 :0];
6944 \\ }
6945 \\}
6946 \\export fn foo_vector_ConstPtrSpecialRef() void {
6947 \\ comptime {
6948 \\ var buf = [_]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10;
6949 \\ var target: [*]u8 = @ptrCast([*]u8, &buf);
6950 \\ const slice = target[0..14 :0];
6951 \\ }
6952 \\}
6953 \\export fn foo_cvector_ConstPtrSpecialBaseArray() void {
6954 \\ comptime {
6955 \\ var buf = [_]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10;
6956 \\ var target: [*c]u8 = &buf;
6957 \\ const slice = target[0..14 :0];
6958 \\ }
6959 \\}
6960 \\export fn foo_cvector_ConstPtrSpecialRef() void {
6961 \\ comptime {
6962 \\ var buf = [_]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10;
6963 \\ var target: [*c]u8 = @ptrCast([*c]u8, &buf);
6964 \\ const slice = target[0..14 :0];
6965 \\ }
6966 \\}
6967 \\export fn foo_slice() void {
6968 \\ comptime {
6969 \\ var buf = [_]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10;
6970 \\ var target: []u8 = &buf;
6971 \\ const slice = target[0..14 :0];
6972 \\ }
6973 \\}
6974 , &[_][]const u8{
6975 ":4:29: error: slice-sentinel is out of bounds",
6976 ":11:29: error: slice-sentinel is out of bounds",
6977 ":18:29: error: slice-sentinel is out of bounds",
6978 ":25:29: error: slice-sentinel is out of bounds",
6979 ":32:29: error: slice-sentinel is out of bounds",
6980 ":39:29: error: slice-sentinel is out of bounds",
6981 ":46:29: error: slice-sentinel is out of bounds",
6982 });
6983
6984 cases.add("comptime slice-sentinel is out of bounds (terminated)",
6985 \\export fn foo_array() void {
6986 \\ comptime {
6987 \\ var target = [_:0]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10;
6988 \\ const slice = target[0..15 :1];
6989 \\ }
6990 \\}
6991 \\export fn foo_ptr_array() void {
6992 \\ comptime {
6993 \\ var buf = [_:0]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10;
6994 \\ var target = &buf;
6995 \\ const slice = target[0..15 :0];
6996 \\ }
6997 \\}
6998 \\export fn foo_vector_ConstPtrSpecialBaseArray() void {
6999 \\ comptime {
7000 \\ var buf = [_:0]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10;
7001 \\ var target: [*]u8 = &buf;
7002 \\ const slice = target[0..15 :0];
7003 \\ }
7004 \\}
7005 \\export fn foo_vector_ConstPtrSpecialRef() void {
7006 \\ comptime {
7007 \\ var buf = [_:0]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10;
7008 \\ var target: [*]u8 = @ptrCast([*]u8, &buf);
7009 \\ const slice = target[0..15 :0];
7010 \\ }
7011 \\}
7012 \\export fn foo_cvector_ConstPtrSpecialBaseArray() void {
7013 \\ comptime {
7014 \\ var buf = [_:0]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10;
7015 \\ var target: [*c]u8 = &buf;
7016 \\ const slice = target[0..15 :0];
7017 \\ }
7018 \\}
7019 \\export fn foo_cvector_ConstPtrSpecialRef() void {
7020 \\ comptime {
7021 \\ var buf = [_:0]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10;
7022 \\ var target: [*c]u8 = @ptrCast([*c]u8, &buf);
7023 \\ const slice = target[0..15 :0];
7024 \\ }
7025 \\}
7026 \\export fn foo_slice() void {
7027 \\ comptime {
7028 \\ var buf = [_:0]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10;
7029 \\ var target: []u8 = &buf;
7030 \\ const slice = target[0..15 :0];
7031 \\ }
7032 \\}
7033 , &[_][]const u8{
7034 ":4:29: error: out of bounds slice",
7035 ":11:29: error: out of bounds slice",
7036 ":18:29: error: out of bounds slice",
7037 ":25:29: error: out of bounds slice",
7038 ":32:29: error: out of bounds slice",
7039 ":39:29: error: out of bounds slice",
7040 ":46:29: error: out of bounds slice",
7041 });
7042
7043 cases.add("comptime slice-sentinel does not match memory at target index (unterminated)",
7044 \\export fn foo_array() void {
7045 \\ comptime {
7046 \\ var target = [_]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10;
7047 \\ const slice = target[0..3 :0];
7048 \\ }
7049 \\}
7050 \\export fn foo_ptr_array() void {
7051 \\ comptime {
7052 \\ var buf = [_]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10;
7053 \\ var target = &buf;
7054 \\ const slice = target[0..3 :0];
7055 \\ }
7056 \\}
7057 \\export fn foo_vector_ConstPtrSpecialBaseArray() void {
7058 \\ comptime {
7059 \\ var buf = [_]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10;
7060 \\ var target: [*]u8 = &buf;
7061 \\ const slice = target[0..3 :0];
7062 \\ }
7063 \\}
7064 \\export fn foo_vector_ConstPtrSpecialRef() void {
7065 \\ comptime {
7066 \\ var buf = [_]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10;
7067 \\ var target: [*]u8 = @ptrCast([*]u8, &buf);
7068 \\ const slice = target[0..3 :0];
7069 \\ }
7070 \\}
7071 \\export fn foo_cvector_ConstPtrSpecialBaseArray() void {
7072 \\ comptime {
7073 \\ var buf = [_]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10;
7074 \\ var target: [*c]u8 = &buf;
7075 \\ const slice = target[0..3 :0];
7076 \\ }
7077 \\}
7078 \\export fn foo_cvector_ConstPtrSpecialRef() void {
7079 \\ comptime {
7080 \\ var buf = [_]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10;
7081 \\ var target: [*c]u8 = @ptrCast([*c]u8, &buf);
7082 \\ const slice = target[0..3 :0];
7083 \\ }
7084 \\}
7085 \\export fn foo_slice() void {
7086 \\ comptime {
7087 \\ var buf = [_]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10;
7088 \\ var target: []u8 = &buf;
7089 \\ const slice = target[0..3 :0];
7090 \\ }
7091 \\}
7092 , &[_][]const u8{
7093 ":4:29: error: slice-sentinel does not match memory at target index",
7094 ":11:29: error: slice-sentinel does not match memory at target index",
7095 ":18:29: error: slice-sentinel does not match memory at target index",
7096 ":25:29: error: slice-sentinel does not match memory at target index",
7097 ":32:29: error: slice-sentinel does not match memory at target index",
7098 ":39:29: error: slice-sentinel does not match memory at target index",
7099 ":46:29: error: slice-sentinel does not match memory at target index",
7100 });
7101
7102 cases.add("comptime slice-sentinel does not match memory at target index (terminated)",
7103 \\export fn foo_array() void {
7104 \\ comptime {
7105 \\ var target = [_:0]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10;
7106 \\ const slice = target[0..3 :0];
7107 \\ }
7108 \\}
7109 \\export fn foo_ptr_array() void {
7110 \\ comptime {
7111 \\ var buf = [_:0]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10;
7112 \\ var target = &buf;
7113 \\ const slice = target[0..3 :0];
7114 \\ }
7115 \\}
7116 \\export fn foo_vector_ConstPtrSpecialBaseArray() void {
7117 \\ comptime {
7118 \\ var buf = [_:0]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10;
7119 \\ var target: [*]u8 = &buf;
7120 \\ const slice = target[0..3 :0];
7121 \\ }
7122 \\}
7123 \\export fn foo_vector_ConstPtrSpecialRef() void {
7124 \\ comptime {
7125 \\ var buf = [_:0]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10;
7126 \\ var target: [*]u8 = @ptrCast([*]u8, &buf);
7127 \\ const slice = target[0..3 :0];
7128 \\ }
7129 \\}
7130 \\export fn foo_cvector_ConstPtrSpecialBaseArray() void {
7131 \\ comptime {
7132 \\ var buf = [_:0]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10;
7133 \\ var target: [*c]u8 = &buf;
7134 \\ const slice = target[0..3 :0];
7135 \\ }
7136 \\}
7137 \\export fn foo_cvector_ConstPtrSpecialRef() void {
7138 \\ comptime {
7139 \\ var buf = [_:0]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10;
7140 \\ var target: [*c]u8 = @ptrCast([*c]u8, &buf);
7141 \\ const slice = target[0..3 :0];
7142 \\ }
7143 \\}
7144 \\export fn foo_slice() void {
7145 \\ comptime {
7146 \\ var buf = [_:0]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10;
7147 \\ var target: []u8 = &buf;
7148 \\ const slice = target[0..3 :0];
7149 \\ }
7150 \\}
7151 , &[_][]const u8{
7152 ":4:29: error: slice-sentinel does not match memory at target index",
7153 ":11:29: error: slice-sentinel does not match memory at target index",
7154 ":18:29: error: slice-sentinel does not match memory at target index",
7155 ":25:29: error: slice-sentinel does not match memory at target index",
7156 ":32:29: error: slice-sentinel does not match memory at target index",
7157 ":39:29: error: slice-sentinel does not match memory at target index",
7158 ":46:29: error: slice-sentinel does not match memory at target index",
7159 });
7160
7161 cases.add("comptime slice-sentinel does not match target-sentinel",
7162 \\export fn foo_array() void {
7163 \\ comptime {
7164 \\ var target = [_:0]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10;
7165 \\ const slice = target[0..14 :255];
7166 \\ }
7167 \\}
7168 \\export fn foo_ptr_array() void {
7169 \\ comptime {
7170 \\ var buf = [_:0]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10;
7171 \\ var target = &buf;
7172 \\ const slice = target[0..14 :255];
7173 \\ }
7174 \\}
7175 \\export fn foo_vector_ConstPtrSpecialBaseArray() void {
7176 \\ comptime {
7177 \\ var buf = [_:0]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10;
7178 \\ var target: [*]u8 = &buf;
7179 \\ const slice = target[0..14 :255];
7180 \\ }
7181 \\}
7182 \\export fn foo_vector_ConstPtrSpecialRef() void {
7183 \\ comptime {
7184 \\ var buf = [_:0]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10;
7185 \\ var target: [*]u8 = @ptrCast([*]u8, &buf);
7186 \\ const slice = target[0..14 :255];
7187 \\ }
7188 \\}
7189 \\export fn foo_cvector_ConstPtrSpecialBaseArray() void {
7190 \\ comptime {
7191 \\ var buf = [_:0]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10;
7192 \\ var target: [*c]u8 = &buf;
7193 \\ const slice = target[0..14 :255];
7194 \\ }
7195 \\}
7196 \\export fn foo_cvector_ConstPtrSpecialRef() void {
7197 \\ comptime {
7198 \\ var buf = [_:0]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10;
7199 \\ var target: [*c]u8 = @ptrCast([*c]u8, &buf);
7200 \\ const slice = target[0..14 :255];
7201 \\ }
7202 \\}
7203 \\export fn foo_slice() void {
7204 \\ comptime {
7205 \\ var buf = [_:0]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10;
7206 \\ var target: []u8 = &buf;
7207 \\ const slice = target[0..14 :255];
7208 \\ }
7209 \\}
7210 , &[_][]const u8{
7211 ":4:29: error: slice-sentinel does not match target-sentinel",
7212 ":11:29: error: slice-sentinel does not match target-sentinel",
7213 ":18:29: error: slice-sentinel does not match target-sentinel",
7214 ":25:29: error: slice-sentinel does not match target-sentinel",
7215 ":32:29: error: slice-sentinel does not match target-sentinel",
7216 ":39:29: error: slice-sentinel does not match target-sentinel",
7217 ":46:29: error: slice-sentinel does not match target-sentinel",
7218 });
7219
7220 cases.add("issue #4207: coerce from non-terminated-slice to terminated-pointer",
7221 \\export fn foo() [*:0]const u8 {
7222 \\ var buffer: [64]u8 = undefined;
7223 \\ return buffer[0..];
7224 \\}
7225 , &[_][]const u8{
7226 ":3:18: error: expected type '[*:0]const u8', found '*[64]u8'",
7227 ":3:18: note: destination pointer requires a terminating '0' sentinel",
7228 });
6860}7229}
test/runtime_safety.zig+112
...@@ -1,6 +1,75 @@...@@ -1,6 +1,75 @@
1const tests = @import("tests.zig");1const tests = @import("tests.zig");
22
3pub fn addCases(cases: *tests.CompareOutputContext) void {3pub fn addCases(cases: *tests.CompareOutputContext) void {
4 {
5 const check_panic_msg =
6 \\pub fn panic(message: []const u8, stack_trace: ?*@import("builtin").StackTrace) noreturn {
7 \\ if (std.mem.eql(u8, message, "index out of bounds")) {
8 \\ std.process.exit(126); // good
9 \\ }
10 \\ std.process.exit(0); // test failed
11 \\}
12 ;
13
14 cases.addRuntimeSafety("slicing operator with sentinel",
15 \\const std = @import("std");
16 ++ check_panic_msg ++
17 \\pub fn main() void {
18 \\ var buf = [4]u8{'a','b','c',0};
19 \\ const slice = buf[0..4 :0];
20 \\}
21 );
22 cases.addRuntimeSafety("slicing operator with sentinel",
23 \\const std = @import("std");
24 ++ check_panic_msg ++
25 \\pub fn main() void {
26 \\ var buf = [4]u8{'a','b','c',0};
27 \\ const slice = buf[0..:0];
28 \\}
29 );
30 cases.addRuntimeSafety("slicing operator with sentinel",
31 \\const std = @import("std");
32 ++ check_panic_msg ++
33 \\pub fn main() void {
34 \\ var buf_zero = [0]u8{};
35 \\ const slice = buf_zero[0..0 :0];
36 \\}
37 );
38 cases.addRuntimeSafety("slicing operator with sentinel",
39 \\const std = @import("std");
40 ++ check_panic_msg ++
41 \\pub fn main() void {
42 \\ var buf_zero = [0]u8{};
43 \\ const slice = buf_zero[0..:0];
44 \\}
45 );
46 cases.addRuntimeSafety("slicing operator with sentinel",
47 \\const std = @import("std");
48 ++ check_panic_msg ++
49 \\pub fn main() void {
50 \\ var buf_sentinel = [2:0]u8{'a','b'};
51 \\ @ptrCast(*[3]u8, &buf_sentinel)[2] = 0;
52 \\ const slice = buf_sentinel[0..3 :0];
53 \\}
54 );
55 cases.addRuntimeSafety("slicing operator with sentinel",
56 \\const std = @import("std");
57 ++ check_panic_msg ++
58 \\pub fn main() void {
59 \\ var buf_slice: []const u8 = &[3]u8{ 'a', 'b', 0 };
60 \\ const slice = buf_slice[0..3 :0];
61 \\}
62 );
63 cases.addRuntimeSafety("slicing operator with sentinel",
64 \\const std = @import("std");
65 ++ check_panic_msg ++
66 \\pub fn main() void {
67 \\ var buf_slice: []const u8 = &[3]u8{ 'a', 'b', 0 };
68 \\ const slice = buf_slice[0.. :0];
69 \\}
70 );
71 }
72
4 cases.addRuntimeSafety("shift left by huge amount",73 cases.addRuntimeSafety("shift left by huge amount",
5 \\const std = @import("std");74 \\const std = @import("std");
6 \\pub fn panic(message: []const u8, stack_trace: ?*@import("builtin").StackTrace) noreturn {75 \\pub fn panic(message: []const u8, stack_trace: ?*@import("builtin").StackTrace) noreturn {
...@@ -505,6 +574,21 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {...@@ -505,6 +574,21 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {
505 \\}574 \\}
506 );575 );
507576
577 cases.addRuntimeSafety("signed integer division overflow - vectors",
578 \\pub fn panic(message: []const u8, stack_trace: ?*@import("builtin").StackTrace) noreturn {
579 \\ @import("std").os.exit(126);
580 \\}
581 \\pub fn main() !void {
582 \\ var a: @Vector(4, i16) = [_]i16{ 1, 2, -32768, 4 };
583 \\ var b: @Vector(4, i16) = [_]i16{ 1, 2, -1, 4 };
584 \\ const x = div(a, b);
585 \\ if (x[2] == 32767) return error.Whatever;
586 \\}
587 \\fn div(a: @Vector(4, i16), b: @Vector(4, i16)) @Vector(4, i16) {
588 \\ return @divTrunc(a, b);
589 \\}
590 );
591
508 cases.addRuntimeSafety("signed shift left overflow",592 cases.addRuntimeSafety("signed shift left overflow",
509 \\pub fn panic(message: []const u8, stack_trace: ?*@import("builtin").StackTrace) noreturn {593 \\pub fn panic(message: []const u8, stack_trace: ?*@import("builtin").StackTrace) noreturn {
510 \\ @import("std").os.exit(126);594 \\ @import("std").os.exit(126);
...@@ -569,6 +653,20 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {...@@ -569,6 +653,20 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {
569 \\}653 \\}
570 );654 );
571655
656 cases.addRuntimeSafety("integer division by zero - vectors",
657 \\pub fn panic(message: []const u8, stack_trace: ?*@import("builtin").StackTrace) noreturn {
658 \\ @import("std").os.exit(126);
659 \\}
660 \\pub fn main() void {
661 \\ var a: @Vector(4, i32) = [4]i32{111, 222, 333, 444};
662 \\ var b: @Vector(4, i32) = [4]i32{111, 0, 333, 444};
663 \\ const x = div0(a, b);
664 \\}
665 \\fn div0(a: @Vector(4, i32), b: @Vector(4, i32)) @Vector(4, i32) {
666 \\ return @divTrunc(a, b);
667 \\}
668 );
669
572 cases.addRuntimeSafety("exact division failure",670 cases.addRuntimeSafety("exact division failure",
573 \\pub fn panic(message: []const u8, stack_trace: ?*@import("builtin").StackTrace) noreturn {671 \\pub fn panic(message: []const u8, stack_trace: ?*@import("builtin").StackTrace) noreturn {
574 \\ @import("std").os.exit(126);672 \\ @import("std").os.exit(126);
...@@ -582,6 +680,20 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {...@@ -582,6 +680,20 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {
582 \\}680 \\}
583 );681 );
584682
683 cases.addRuntimeSafety("exact division failure - vectors",
684 \\pub fn panic(message: []const u8, stack_trace: ?*@import("builtin").StackTrace) noreturn {
685 \\ @import("std").os.exit(126);
686 \\}
687 \\pub fn main() !void {
688 \\ var a: @Vector(4, i32) = [4]i32{111, 222, 333, 444};
689 \\ var b: @Vector(4, i32) = [4]i32{111, 222, 333, 441};
690 \\ const x = divExact(a, b);
691 \\}
692 \\fn divExact(a: @Vector(4, i32), b: @Vector(4, i32)) @Vector(4, i32) {
693 \\ return @divExact(a, b);
694 \\}
695 );
696
585 cases.addRuntimeSafety("cast []u8 to bigger slice of wrong size",697 cases.addRuntimeSafety("cast []u8 to bigger slice of wrong size",
586 \\const std = @import("std");698 \\const std = @import("std");
587 \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn {699 \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn {
test/stage1/behavior.zig+2
...@@ -44,6 +44,7 @@ comptime {...@@ -44,6 +44,7 @@ comptime {
44 _ = @import("behavior/bugs/4769_a.zig");44 _ = @import("behavior/bugs/4769_a.zig");
45 _ = @import("behavior/bugs/4769_b.zig");45 _ = @import("behavior/bugs/4769_b.zig");
46 _ = @import("behavior/bugs/4769_c.zig");46 _ = @import("behavior/bugs/4769_c.zig");
47 _ = @import("behavior/bugs/4954.zig");
47 _ = @import("behavior/bugs/394.zig");48 _ = @import("behavior/bugs/394.zig");
48 _ = @import("behavior/bugs/421.zig");49 _ = @import("behavior/bugs/421.zig");
49 _ = @import("behavior/bugs/529.zig");50 _ = @import("behavior/bugs/529.zig");
...@@ -96,6 +97,7 @@ comptime {...@@ -96,6 +97,7 @@ comptime {
96 _ = @import("behavior/shuffle.zig");97 _ = @import("behavior/shuffle.zig");
97 _ = @import("behavior/sizeof_and_typeof.zig");98 _ = @import("behavior/sizeof_and_typeof.zig");
98 _ = @import("behavior/slice.zig");99 _ = @import("behavior/slice.zig");
100 _ = @import("behavior/slice_sentinel_comptime.zig");
99 _ = @import("behavior/struct.zig");101 _ = @import("behavior/struct.zig");
100 _ = @import("behavior/struct_contains_null_ptr_itself.zig");102 _ = @import("behavior/struct_contains_null_ptr_itself.zig");
101 _ = @import("behavior/struct_contains_slice_of_itself.zig");103 _ = @import("behavior/struct_contains_slice_of_itself.zig");
test/stage1/behavior/bugs/4954.zig created+8
...@@ -0,0 +1,8 @@
1fn f(buf: []u8) void {
2 var ptr = &buf[@sizeOf(u32)];
3}
4
5test "crash" {
6 var buf: [4096]u8 = undefined;
7 f(&buf);
8}
test/stage1/behavior/for.zig+2-2
...@@ -161,8 +161,8 @@ test "for copies its payload" {...@@ -161,8 +161,8 @@ test "for copies its payload" {
161161
162test "for on slice with allowzero ptr" {162test "for on slice with allowzero ptr" {
163 const S = struct {163 const S = struct {
164 fn doTheTest(slice: []u8) void {164 fn doTheTest(slice: []const u8) void {
165 var ptr = @ptrCast([*]allowzero u8, slice.ptr)[0..slice.len];165 var ptr = @ptrCast([*]const allowzero u8, slice.ptr)[0..slice.len];
166 for (ptr) |x, i| expect(x == i + 1);166 for (ptr) |x, i| expect(x == i + 1);
167 for (ptr) |*x, i| expect(x.* == i + 1);167 for (ptr) |*x, i| expect(x.* == i + 1);
168 }168 }
test/stage1/behavior/pointers.zig+3-3
...@@ -253,7 +253,7 @@ test "pointer sentinel with enums" {...@@ -253,7 +253,7 @@ test "pointer sentinel with enums" {
253 };253 };
254254
255 fn doTheTest() void {255 fn doTheTest() void {
256 var ptr: [*:.sentinel]Number = &[_:.sentinel]Number{ .one, .two, .two, .one };256 var ptr: [*:.sentinel]const Number = &[_:.sentinel]Number{ .one, .two, .two, .one };
257 expect(ptr[4] == .sentinel); // TODO this should be comptime expect, see #3731257 expect(ptr[4] == .sentinel); // TODO this should be comptime expect, see #3731
258 }258 }
259 };259 };
...@@ -264,7 +264,7 @@ test "pointer sentinel with enums" {...@@ -264,7 +264,7 @@ test "pointer sentinel with enums" {
264test "pointer sentinel with optional element" {264test "pointer sentinel with optional element" {
265 const S = struct {265 const S = struct {
266 fn doTheTest() void {266 fn doTheTest() void {
267 var ptr: [*:null]?i32 = &[_:null]?i32{ 1, 2, 3, 4 };267 var ptr: [*:null]const ?i32 = &[_:null]?i32{ 1, 2, 3, 4 };
268 expect(ptr[4] == null); // TODO this should be comptime expect, see #3731268 expect(ptr[4] == null); // TODO this should be comptime expect, see #3731
269 }269 }
270 };270 };
...@@ -276,7 +276,7 @@ test "pointer sentinel with +inf" {...@@ -276,7 +276,7 @@ test "pointer sentinel with +inf" {
276 const S = struct {276 const S = struct {
277 fn doTheTest() void {277 fn doTheTest() void {
278 const inf = std.math.inf_f32;278 const inf = std.math.inf_f32;
279 var ptr: [*:inf]f32 = &[_:inf]f32{ 1.1, 2.2, 3.3, 4.4 };279 var ptr: [*:inf]const f32 = &[_:inf]f32{ 1.1, 2.2, 3.3, 4.4 };
280 expect(ptr[4] == inf); // TODO this should be comptime expect, see #3731280 expect(ptr[4] == inf); // TODO this should be comptime expect, see #3731
281 }281 }
282 };282 };
test/stage1/behavior/slice.zig+2-2
...@@ -218,9 +218,9 @@ test "slice syntax resulting in pointer-to-array" {...@@ -218,9 +218,9 @@ test "slice syntax resulting in pointer-to-array" {
218 }218 }
219219
220 fn testPointer0() void {220 fn testPointer0() void {
221 var pointer: [*]u0 = &[1]u0{0};221 var pointer: [*]const u0 = &[1]u0{0};
222 var slice = pointer[0..1];222 var slice = pointer[0..1];
223 comptime expect(@TypeOf(slice) == *[1]u0);223 comptime expect(@TypeOf(slice) == *const [1]u0);
224 expect(slice[0] == 0);224 expect(slice[0] == 0);
225 }225 }
226226
test/stage1/behavior/slice_sentinel_comptime.zig created+199
...@@ -0,0 +1,199 @@
1test "comptime slice-sentinel in bounds (unterminated)" {
2 // array
3 comptime {
4 var target = [_]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10;
5 const slice = target[0..3 :'d'];
6 }
7
8 // ptr_array
9 comptime {
10 var buf = [_]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10;
11 var target = &buf;
12 const slice = target[0..3 :'d'];
13 }
14
15 // vector_ConstPtrSpecialBaseArray
16 comptime {
17 var buf = [_]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10;
18 var target: [*]u8 = &buf;
19 const slice = target[0..3 :'d'];
20 }
21
22 // vector_ConstPtrSpecialRef
23 comptime {
24 var buf = [_]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10;
25 var target: [*]u8 = @ptrCast([*]u8, &buf);
26 const slice = target[0..3 :'d'];
27 }
28
29 // cvector_ConstPtrSpecialBaseArray
30 comptime {
31 var buf = [_]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10;
32 var target: [*c]u8 = &buf;
33 const slice = target[0..3 :'d'];
34 }
35
36 // cvector_ConstPtrSpecialRef
37 comptime {
38 var buf = [_]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10;
39 var target: [*c]u8 = @ptrCast([*c]u8, &buf);
40 const slice = target[0..3 :'d'];
41 }
42
43 // slice
44 comptime {
45 var buf = [_]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10;
46 var target: []u8 = &buf;
47 const slice = target[0..3 :'d'];
48 }
49}
50
51test "comptime slice-sentinel in bounds (end,unterminated)" {
52 // array
53 comptime {
54 var target = [_]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{0xff} ** 10;
55 const slice = target[0..13 :0xff];
56 }
57
58 // ptr_array
59 comptime {
60 var buf = [_]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{0xff} ** 10;
61 var target = &buf;
62 const slice = target[0..13 :0xff];
63 }
64
65 // vector_ConstPtrSpecialBaseArray
66 comptime {
67 var buf = [_]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{0xff} ** 10;
68 var target: [*]u8 = &buf;
69 const slice = target[0..13 :0xff];
70 }
71
72 // vector_ConstPtrSpecialRef
73 comptime {
74 var buf = [_]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{0xff} ** 10;
75 var target: [*]u8 = @ptrCast([*]u8, &buf);
76 const slice = target[0..13 :0xff];
77 }
78
79 // cvector_ConstPtrSpecialBaseArray
80 comptime {
81 var buf = [_]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{0xff} ** 10;
82 var target: [*c]u8 = &buf;
83 const slice = target[0..13 :0xff];
84 }
85
86 // cvector_ConstPtrSpecialRef
87 comptime {
88 var buf = [_]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{0xff} ** 10;
89 var target: [*c]u8 = @ptrCast([*c]u8, &buf);
90 const slice = target[0..13 :0xff];
91 }
92
93 // slice
94 comptime {
95 var buf = [_]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{0xff} ** 10;
96 var target: []u8 = &buf;
97 const slice = target[0..13 :0xff];
98 }
99}
100
101test "comptime slice-sentinel in bounds (terminated)" {
102 // array
103 comptime {
104 var target = [_:0]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10;
105 const slice = target[0..3 :'d'];
106 }
107
108 // ptr_array
109 comptime {
110 var buf = [_:0]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10;
111 var target = &buf;
112 const slice = target[0..3 :'d'];
113 }
114
115 // vector_ConstPtrSpecialBaseArray
116 comptime {
117 var buf = [_:0]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10;
118 var target: [*]u8 = &buf;
119 const slice = target[0..3 :'d'];
120 }
121
122 // vector_ConstPtrSpecialRef
123 comptime {
124 var buf = [_:0]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10;
125 var target: [*]u8 = @ptrCast([*]u8, &buf);
126 const slice = target[0..3 :'d'];
127 }
128
129 // cvector_ConstPtrSpecialBaseArray
130 comptime {
131 var buf = [_:0]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10;
132 var target: [*c]u8 = &buf;
133 const slice = target[0..3 :'d'];
134 }
135
136 // cvector_ConstPtrSpecialRef
137 comptime {
138 var buf = [_:0]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10;
139 var target: [*c]u8 = @ptrCast([*c]u8, &buf);
140 const slice = target[0..3 :'d'];
141 }
142
143 // slice
144 comptime {
145 var buf = [_:0]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10;
146 var target: []u8 = &buf;
147 const slice = target[0..3 :'d'];
148 }
149}
150
151test "comptime slice-sentinel in bounds (on target sentinel)" {
152 // array
153 comptime {
154 var target = [_:0]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10;
155 const slice = target[0..14 :0];
156 }
157
158 // ptr_array
159 comptime {
160 var buf = [_:0]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10;
161 var target = &buf;
162 const slice = target[0..14 :0];
163 }
164
165 // vector_ConstPtrSpecialBaseArray
166 comptime {
167 var buf = [_:0]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10;
168 var target: [*]u8 = &buf;
169 const slice = target[0..14 :0];
170 }
171
172 // vector_ConstPtrSpecialRef
173 comptime {
174 var buf = [_:0]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10;
175 var target: [*]u8 = @ptrCast([*]u8, &buf);
176 const slice = target[0..14 :0];
177 }
178
179 // cvector_ConstPtrSpecialBaseArray
180 comptime {
181 var buf = [_:0]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10;
182 var target: [*c]u8 = &buf;
183 const slice = target[0..14 :0];
184 }
185
186 // cvector_ConstPtrSpecialRef
187 comptime {
188 var buf = [_:0]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10;
189 var target: [*c]u8 = @ptrCast([*c]u8, &buf);
190 const slice = target[0..14 :0];
191 }
192
193 // slice
194 comptime {
195 var buf = [_:0]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10;
196 var target: []u8 = &buf;
197 const slice = target[0..14 :0];
198 }
199}
test/stage1/behavior/tuple.zig+43-4
...@@ -1,5 +1,7 @@...@@ -1,5 +1,7 @@
1const std = @import("std");1const std = @import("std");
2const expect = std.testing.expect;2const testing = std.testing;
3const expect = testing.expect;
4const expectEqual = testing.expectEqual;
35
4test "tuple concatenation" {6test "tuple concatenation" {
5 const S = struct {7 const S = struct {
...@@ -9,8 +11,31 @@ test "tuple concatenation" {...@@ -9,8 +11,31 @@ test "tuple concatenation" {
9 var x = .{a};11 var x = .{a};
10 var y = .{b};12 var y = .{b};
11 var c = x ++ y;13 var c = x ++ y;
12 expect(c[0] == 1);14 expectEqual(@as(i32, 1), c[0]);
13 expect(c[1] == 2);15 expectEqual(@as(i32, 2), c[1]);
16 }
17 };
18 S.doTheTest();
19 comptime S.doTheTest();
20}
21
22test "tuple multiplication" {
23 const S = struct {
24 fn doTheTest() void {
25 {
26 const t = .{} ** 4;
27 expectEqual(0, @typeInfo(@TypeOf(t)).Struct.fields.len);
28 }
29 {
30 const t = .{'a'} ** 4;
31 expectEqual(4, @typeInfo(@TypeOf(t)).Struct.fields.len);
32 inline for (t) |x| expectEqual('a', x);
33 }
34 {
35 const t = .{ 1, 2, 3 } ** 4;
36 expectEqual(12, @typeInfo(@TypeOf(t)).Struct.fields.len);
37 inline for (t) |x, i| expectEqual(1 + i % 3, x);
38 }
14 }39 }
15 };40 };
16 S.doTheTest();41 S.doTheTest();
...@@ -36,7 +61,7 @@ test "tuple concatenation" {...@@ -36,7 +61,7 @@ test "tuple concatenation" {
36 consume_tuple(.{} ++ .{}, 0);61 consume_tuple(.{} ++ .{}, 0);
37 consume_tuple(.{0} ++ .{}, 1);62 consume_tuple(.{0} ++ .{}, 1);
38 consume_tuple(.{0} ++ .{1}, 2);63 consume_tuple(.{0} ++ .{1}, 2);
39 consume_tuple(.{0, 1, 2} ++ .{u8, 1, noreturn}, 6);64 consume_tuple(.{ 0, 1, 2 } ++ .{ u8, 1, noreturn }, 6);
40 consume_tuple(t2 ++ t1, 1);65 consume_tuple(t2 ++ t1, 1);
41 consume_tuple(t1 ++ t2, 1);66 consume_tuple(t1 ++ t2, 1);
42 consume_tuple(t2 ++ t2, 2);67 consume_tuple(t2 ++ t2, 2);
...@@ -54,3 +79,17 @@ test "tuple concatenation" {...@@ -54,3 +79,17 @@ test "tuple concatenation" {
54 T.doTheTest();79 T.doTheTest();
55 comptime T.doTheTest();80 comptime T.doTheTest();
56}81}
82
83test "pass tuple to comptime var parameter" {
84 const S = struct {
85 fn Foo(comptime args: var) void {
86 expect(args[0] == 1);
87 }
88
89 fn doTheTest() void {
90 Foo(.{1});
91 }
92 };
93 S.doTheTest();
94 comptime S.doTheTest();
95}
test/stage1/behavior/vector.zig+195
...@@ -1,5 +1,6 @@...@@ -1,5 +1,6 @@
1const std = @import("std");1const std = @import("std");
2const mem = std.mem;2const mem = std.mem;
3const math = std.math;
3const expect = std.testing.expect;4const expect = std.testing.expect;
4const expectEqual = std.testing.expectEqual;5const expectEqual = std.testing.expectEqual;
56
...@@ -276,3 +277,197 @@ test "vector comparison operators" {...@@ -276,3 +277,197 @@ test "vector comparison operators" {
276 S.doTheTest();277 S.doTheTest();
277 comptime S.doTheTest();278 comptime S.doTheTest();
278}279}
280
281test "vector division operators" {
282 const S = struct {
283 fn doTheTestDiv(comptime T: type, x: @Vector(4, T), y: @Vector(4, T)) void {
284 if (!comptime std.meta.trait.isSignedInt(T)) {
285 const d0 = x / y;
286 for (@as([4]T, d0)) |v, i| {
287 expectEqual(x[i] / y[i], v);
288 }
289 }
290 const d1 = @divExact(x, y);
291 for (@as([4]T, d1)) |v, i| {
292 expectEqual(@divExact(x[i], y[i]), v);
293 }
294 const d2 = @divFloor(x, y);
295 for (@as([4]T, d2)) |v, i| {
296 expectEqual(@divFloor(x[i], y[i]), v);
297 }
298 const d3 = @divTrunc(x, y);
299 for (@as([4]T, d3)) |v, i| {
300 expectEqual(@divTrunc(x[i], y[i]), v);
301 }
302 }
303
304 fn doTheTestMod(comptime T: type, x: @Vector(4, T), y: @Vector(4, T)) void {
305 if ((!comptime std.meta.trait.isSignedInt(T)) and @typeInfo(T) != .Float) {
306 const r0 = x % y;
307 for (@as([4]T, r0)) |v, i| {
308 expectEqual(x[i] % y[i], v);
309 }
310 }
311 const r1 = @mod(x, y);
312 for (@as([4]T, r1)) |v, i| {
313 expectEqual(@mod(x[i], y[i]), v);
314 }
315 const r2 = @rem(x, y);
316 for (@as([4]T, r2)) |v, i| {
317 expectEqual(@rem(x[i], y[i]), v);
318 }
319 }
320
321 fn doTheTest() void {
322 // https://github.com/ziglang/zig/issues/4952
323 if (std.builtin.os.tag != .windows) {
324 doTheTestDiv(f16, [4]f16{ 4.0, -4.0, 4.0, -4.0 }, [4]f16{ 1.0, 2.0, -1.0, -2.0 });
325 }
326
327 doTheTestDiv(f32, [4]f32{ 4.0, -4.0, 4.0, -4.0 }, [4]f32{ 1.0, 2.0, -1.0, -2.0 });
328 doTheTestDiv(f64, [4]f64{ 4.0, -4.0, 4.0, -4.0 }, [4]f64{ 1.0, 2.0, -1.0, -2.0 });
329
330 // https://github.com/ziglang/zig/issues/4952
331 if (std.builtin.os.tag != .windows) {
332 doTheTestMod(f16, [4]f16{ 4.0, -4.0, 4.0, -4.0 }, [4]f16{ 1.0, 2.0, 0.5, 3.0 });
333 }
334 doTheTestMod(f32, [4]f32{ 4.0, -4.0, 4.0, -4.0 }, [4]f32{ 1.0, 2.0, 0.5, 3.0 });
335 doTheTestMod(f64, [4]f64{ 4.0, -4.0, 4.0, -4.0 }, [4]f64{ 1.0, 2.0, 0.5, 3.0 });
336
337 doTheTestDiv(i8, [4]i8{ 4, -4, 4, -4 }, [4]i8{ 1, 2, -1, -2 });
338 doTheTestDiv(i16, [4]i16{ 4, -4, 4, -4 }, [4]i16{ 1, 2, -1, -2 });
339 doTheTestDiv(i32, [4]i32{ 4, -4, 4, -4 }, [4]i32{ 1, 2, -1, -2 });
340 doTheTestDiv(i64, [4]i64{ 4, -4, 4, -4 }, [4]i64{ 1, 2, -1, -2 });
341
342 doTheTestMod(i8, [4]i8{ 4, -4, 4, -4 }, [4]i8{ 1, 2, 4, 8 });
343 doTheTestMod(i16, [4]i16{ 4, -4, 4, -4 }, [4]i16{ 1, 2, 4, 8 });
344 doTheTestMod(i32, [4]i32{ 4, -4, 4, -4 }, [4]i32{ 1, 2, 4, 8 });
345 doTheTestMod(i64, [4]i64{ 4, -4, 4, -4 }, [4]i64{ 1, 2, 4, 8 });
346
347 doTheTestDiv(u8, [4]u8{ 1, 2, 4, 8 }, [4]u8{ 1, 1, 2, 4 });
348 doTheTestDiv(u16, [4]u16{ 1, 2, 4, 8 }, [4]u16{ 1, 1, 2, 4 });
349 doTheTestDiv(u32, [4]u32{ 1, 2, 4, 8 }, [4]u32{ 1, 1, 2, 4 });
350 doTheTestDiv(u64, [4]u64{ 1, 2, 4, 8 }, [4]u64{ 1, 1, 2, 4 });
351
352 doTheTestMod(u8, [4]u8{ 1, 2, 4, 8 }, [4]u8{ 1, 1, 2, 4 });
353 doTheTestMod(u16, [4]u16{ 1, 2, 4, 8 }, [4]u16{ 1, 1, 2, 4 });
354 doTheTestMod(u32, [4]u32{ 1, 2, 4, 8 }, [4]u32{ 1, 1, 2, 4 });
355 doTheTestMod(u64, [4]u64{ 1, 2, 4, 8 }, [4]u64{ 1, 1, 2, 4 });
356 }
357 };
358
359 S.doTheTest();
360 comptime S.doTheTest();
361}
362
363test "vector bitwise not operator" {
364 const S = struct {
365 fn doTheTestNot(comptime T: type, x: @Vector(4, T)) void {
366 var y = ~x;
367 for (@as([4]T, y)) |v, i| {
368 expectEqual(~x[i], v);
369 }
370 }
371 fn doTheTest() void {
372 doTheTestNot(u8, [_]u8{ 0, 2, 4, 255 });
373 doTheTestNot(u16, [_]u16{ 0, 2, 4, 255 });
374 doTheTestNot(u32, [_]u32{ 0, 2, 4, 255 });
375 doTheTestNot(u64, [_]u64{ 0, 2, 4, 255 });
376
377 doTheTestNot(u8, [_]u8{ 0, 2, 4, 255 });
378 doTheTestNot(u16, [_]u16{ 0, 2, 4, 255 });
379 doTheTestNot(u32, [_]u32{ 0, 2, 4, 255 });
380 doTheTestNot(u64, [_]u64{ 0, 2, 4, 255 });
381 }
382 };
383
384 S.doTheTest();
385 comptime S.doTheTest();
386}
387
388test "vector shift operators" {
389 const S = struct {
390 fn doTheTestShift(x: var, y: var) void {
391 const N = @typeInfo(@TypeOf(x)).Array.len;
392 const TX = @typeInfo(@TypeOf(x)).Array.child;
393 const TY = @typeInfo(@TypeOf(y)).Array.child;
394
395 var xv = @as(@Vector(N, TX), x);
396 var yv = @as(@Vector(N, TY), y);
397
398 var z0 = xv >> yv;
399 for (@as([N]TX, z0)) |v, i| {
400 expectEqual(x[i] >> y[i], v);
401 }
402 var z1 = xv << yv;
403 for (@as([N]TX, z1)) |v, i| {
404 expectEqual(x[i] << y[i], v);
405 }
406 }
407 fn doTheTestShiftExact(x: var, y: var, dir: enum { Left, Right }) void {
408 const N = @typeInfo(@TypeOf(x)).Array.len;
409 const TX = @typeInfo(@TypeOf(x)).Array.child;
410 const TY = @typeInfo(@TypeOf(y)).Array.child;
411
412 var xv = @as(@Vector(N, TX), x);
413 var yv = @as(@Vector(N, TY), y);
414
415 var z = if (dir == .Left) @shlExact(xv, yv) else @shrExact(xv, yv);
416 for (@as([N]TX, z)) |v, i| {
417 const check = if (dir == .Left) x[i] << y[i] else x[i] >> y[i];
418 expectEqual(check, v);
419 }
420 }
421 fn doTheTest() void {
422 doTheTestShift([_]u8{ 0, 2, 4, math.maxInt(u8) }, [_]u3{ 2, 0, 2, 7 });
423 doTheTestShift([_]u16{ 0, 2, 4, math.maxInt(u16) }, [_]u4{ 2, 0, 2, 15 });
424 doTheTestShift([_]u24{ 0, 2, 4, math.maxInt(u24) }, [_]u5{ 2, 0, 2, 23 });
425 doTheTestShift([_]u32{ 0, 2, 4, math.maxInt(u32) }, [_]u5{ 2, 0, 2, 31 });
426 doTheTestShift([_]u64{ 0xfe, math.maxInt(u64) }, [_]u6{ 0, 63 });
427
428 doTheTestShift([_]i8{ 0, 2, 4, math.maxInt(i8) }, [_]u3{ 2, 0, 2, 7 });
429 doTheTestShift([_]i16{ 0, 2, 4, math.maxInt(i16) }, [_]u4{ 2, 0, 2, 7 });
430 doTheTestShift([_]i24{ 0, 2, 4, math.maxInt(i24) }, [_]u5{ 2, 0, 2, 7 });
431 doTheTestShift([_]i32{ 0, 2, 4, math.maxInt(i32) }, [_]u5{ 2, 0, 2, 7 });
432 doTheTestShift([_]i64{ 0xfe, math.maxInt(i64) }, [_]u6{ 0, 63 });
433
434 doTheTestShiftExact([_]u8{ 0, 1, 1 << 7, math.maxInt(u8) ^ 1 }, [_]u3{ 4, 0, 7, 1 }, .Right);
435 doTheTestShiftExact([_]u16{ 0, 1, 1 << 15, math.maxInt(u16) ^ 1 }, [_]u4{ 4, 0, 15, 1 }, .Right);
436 doTheTestShiftExact([_]u24{ 0, 1, 1 << 23, math.maxInt(u24) ^ 1 }, [_]u5{ 4, 0, 23, 1 }, .Right);
437 doTheTestShiftExact([_]u32{ 0, 1, 1 << 31, math.maxInt(u32) ^ 1 }, [_]u5{ 4, 0, 31, 1 }, .Right);
438 doTheTestShiftExact([_]u64{ 1 << 63, 1 }, [_]u6{ 63, 0 }, .Right);
439
440 doTheTestShiftExact([_]u8{ 0, 1, 1, math.maxInt(u8) ^ (1 << 7) }, [_]u3{ 4, 0, 7, 1 }, .Left);
441 doTheTestShiftExact([_]u16{ 0, 1, 1, math.maxInt(u16) ^ (1 << 15) }, [_]u4{ 4, 0, 15, 1 }, .Left);
442 doTheTestShiftExact([_]u24{ 0, 1, 1, math.maxInt(u24) ^ (1 << 23) }, [_]u5{ 4, 0, 23, 1 }, .Left);
443 doTheTestShiftExact([_]u32{ 0, 1, 1, math.maxInt(u32) ^ (1 << 31) }, [_]u5{ 4, 0, 31, 1 }, .Left);
444 doTheTestShiftExact([_]u64{ 1 << 63, 1 }, [_]u6{ 0, 63 }, .Left);
445 }
446 };
447
448 switch (std.builtin.arch) {
449 .i386,
450 .aarch64,
451 .aarch64_be,
452 .aarch64_32,
453 .arm,
454 .armeb,
455 .thumb,
456 .thumbeb,
457 .mips,
458 .mipsel,
459 .mips64,
460 .mips64el,
461 .riscv64,
462 .sparcv9,
463 => {
464 // LLVM miscompiles on this architecture
465 // https://github.com/ziglang/zig/issues/4951
466 return error.SkipZigTest;
467 },
468 else => {},
469 }
470
471 S.doTheTest();
472 comptime S.doTheTest();
473}
test/standalone/brace_expansion/main.zig+2-2
...@@ -113,7 +113,7 @@ fn parse(tokens: *const ArrayList(Token), token_index: *usize) ParseError!Node {...@@ -113,7 +113,7 @@ fn parse(tokens: *const ArrayList(Token), token_index: *usize) ParseError!Node {
113113
114fn expandString(input: []const u8, output: *ArrayListSentineled(u8, 0)) !void {114fn expandString(input: []const u8, output: *ArrayListSentineled(u8, 0)) !void {
115 const tokens = try tokenize(input);115 const tokens = try tokenize(input);
116 if (tokens.len == 1) {116 if (tokens.items.len == 1) {
117 return output.resize(0);117 return output.resize(0);
118 }118 }
119119
...@@ -142,7 +142,7 @@ fn expandString(input: []const u8, output: *ArrayListSentineled(u8, 0)) !void {...@@ -142,7 +142,7 @@ fn expandString(input: []const u8, output: *ArrayListSentineled(u8, 0)) !void {
142const ExpandNodeError = error{OutOfMemory};142const ExpandNodeError = error{OutOfMemory};
143143
144fn expandNode(node: Node, output: *ArrayList(ArrayListSentineled(u8, 0))) ExpandNodeError!void {144fn expandNode(node: Node, output: *ArrayList(ArrayListSentineled(u8, 0))) ExpandNodeError!void {
145 assert(output.len == 0);145 assert(output.items.len == 0);
146 switch (node) {146 switch (node) {
147 Node.Scalar => |scalar| {147 Node.Scalar => |scalar| {
148 try output.append(try ArrayListSentineled(u8, 0).init(global_allocator, scalar));148 try output.append(try ArrayListSentineled(u8, 0).init(global_allocator, scalar));
test/tests.zig+36-21
...@@ -89,6 +89,15 @@ const test_targets = blk: {...@@ -89,6 +89,15 @@ const test_targets = blk: {
89 },89 },
90 .link_libc = true,90 .link_libc = true,
91 },91 },
92 // https://github.com/ziglang/zig/issues/4926
93 //TestTarget{
94 // .target = .{
95 // .cpu_arch = .i386,
96 // .os_tag = .linux,
97 // .abi = .gnu,
98 // },
99 // .link_libc = true,
100 //},
92101
93 TestTarget{102 TestTarget{
94 .target = .{103 .target = .{
...@@ -127,7 +136,7 @@ const test_targets = blk: {...@@ -127,7 +136,7 @@ const test_targets = blk: {
127 }) catch unreachable,136 }) catch unreachable,
128 .link_libc = true,137 .link_libc = true,
129 },138 },
130 // TODO https://github.com/ziglang/zig/issues/3287139 // https://github.com/ziglang/zig/issues/3287
131 //TestTarget{140 //TestTarget{
132 // .target = CrossTarget.parse(.{141 // .target = CrossTarget.parse(.{
133 // .arch_os_abi = "arm-linux-gnueabihf",142 // .arch_os_abi = "arm-linux-gnueabihf",
...@@ -151,27 +160,33 @@ const test_targets = blk: {...@@ -151,27 +160,33 @@ const test_targets = blk: {
151 },160 },
152 .link_libc = true,161 .link_libc = true,
153 },162 },
154163 // https://github.com/ziglang/zig/issues/4927
155 // TODO disabled only because the CI server has such an old qemu that
156 // qemu-riscv64 isn't available :(
157 //TestTarget{164 //TestTarget{
158 // .target = .{165 // .target = .{
159 // .cpu_arch = .riscv64,166 // .cpu_arch = .mipsel,
160 // .os_tag = .linux,
161 // .abi = .none,
162 // },
163 //},
164
165 // https://github.com/ziglang/zig/issues/4485
166 //TestTarget{
167 // .target = .{
168 // .cpu_arch = .riscv64,
169 // .os_tag = .linux,167 // .os_tag = .linux,
170 // .abi = .musl,168 // .abi = .gnu,
171 // },169 // },
172 // .link_libc = true,170 // .link_libc = true,
173 //},171 //},
174172
173 TestTarget{
174 .target = .{
175 .cpu_arch = .riscv64,
176 .os_tag = .linux,
177 .abi = .none,
178 },
179 },
180
181 TestTarget{
182 .target = .{
183 .cpu_arch = .riscv64,
184 .os_tag = .linux,
185 .abi = .musl,
186 },
187 .link_libc = true,
188 },
189
175 // https://github.com/ziglang/zig/issues/3340190 // https://github.com/ziglang/zig/issues/3340
176 //TestTarget{191 //TestTarget{
177 // .target = .{192 // .target = .{
...@@ -188,7 +203,7 @@ const test_targets = blk: {...@@ -188,7 +203,7 @@ const test_targets = blk: {
188 .os_tag = .macosx,203 .os_tag = .macosx,
189 .abi = .gnu,204 .abi = .gnu,
190 },205 },
191 // TODO https://github.com/ziglang/zig/issues/3295206 // https://github.com/ziglang/zig/issues/3295
192 .disable_native = true,207 .disable_native = true,
193 },208 },
194209
...@@ -597,7 +612,7 @@ pub const StackTracesContext = struct {...@@ -597,7 +612,7 @@ pub const StackTracesContext = struct {
597612
598 const stdout = child.stdout.?.inStream().readAllAlloc(b.allocator, max_stdout_size) catch unreachable;613 const stdout = child.stdout.?.inStream().readAllAlloc(b.allocator, max_stdout_size) catch unreachable;
599 defer b.allocator.free(stdout);614 defer b.allocator.free(stdout);
600 const stderr = child.stderr.?.inStream().readAllAlloc(b.allocator, max_stdout_size) catch unreachable;615 var stderr = child.stderr.?.inStream().readAllAlloc(b.allocator, max_stdout_size) catch unreachable;
601 defer b.allocator.free(stderr);616 defer b.allocator.free(stderr);
602617
603 const term = child.wait() catch |err| {618 const term = child.wait() catch |err| {
...@@ -642,7 +657,7 @@ pub const StackTracesContext = struct {...@@ -642,7 +657,7 @@ pub const StackTracesContext = struct {
642 var buf = ArrayList(u8).init(b.allocator);657 var buf = ArrayList(u8).init(b.allocator);
643 defer buf.deinit();658 defer buf.deinit();
644 if (stderr.len != 0 and stderr[stderr.len - 1] == '\n') stderr = stderr[0 .. stderr.len - 1];659 if (stderr.len != 0 and stderr[stderr.len - 1] == '\n') stderr = stderr[0 .. stderr.len - 1];
645 var it = mem.separate(stderr, "\n");660 var it = mem.split(stderr, "\n");
646 process_lines: while (it.next()) |line| {661 process_lines: while (it.next()) |line| {
647 if (line.len == 0) continue;662 if (line.len == 0) continue;
648 const delims = [_][]const u8{ ":", ":", ":", " in " };663 const delims = [_][]const u8{ ":", ":", ":", " in " };
...@@ -735,7 +750,7 @@ pub const CompileErrorContext = struct {...@@ -735,7 +750,7 @@ pub const CompileErrorContext = struct {
735 const source_file = "tmp.zig";750 const source_file = "tmp.zig";
736751
737 fn init(input: []const u8) ErrLineIter {752 fn init(input: []const u8) ErrLineIter {
738 return ErrLineIter{ .lines = mem.separate(input, "\n") };753 return ErrLineIter{ .lines = mem.split(input, "\n") };
739 }754 }
740755
741 fn next(self: *ErrLineIter) ?[]const u8 {756 fn next(self: *ErrLineIter) ?[]const u8 {
...@@ -864,13 +879,13 @@ pub const CompileErrorContext = struct {...@@ -864,13 +879,13 @@ pub const CompileErrorContext = struct {
864 var err_iter = ErrLineIter.init(stderr);879 var err_iter = ErrLineIter.init(stderr);
865 var i: usize = 0;880 var i: usize = 0;
866 ok = while (err_iter.next()) |line| : (i += 1) {881 ok = while (err_iter.next()) |line| : (i += 1) {
867 if (i >= self.case.expected_errors.len) break false;882 if (i >= self.case.expected_errors.items.len) break false;
868 const expected = self.case.expected_errors.at(i);883 const expected = self.case.expected_errors.at(i);
869 if (mem.indexOf(u8, line, expected) == null) break false;884 if (mem.indexOf(u8, line, expected) == null) break false;
870 continue;885 continue;
871 } else true;886 } else true;
872887
873 ok = ok and i == self.case.expected_errors.len;888 ok = ok and i == self.case.expected_errors.items.len;
874889
875 if (!ok) {890 if (!ok) {
876 warn("\n======== Expected these compile errors: ========\n", .{});891 warn("\n======== Expected these compile errors: ========\n", .{});
test/translate_c.zig+61-4
...@@ -1458,7 +1458,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {...@@ -1458,7 +1458,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
1458 cases.add("macro pointer cast",1458 cases.add("macro pointer cast",
1459 \\#define NRF_GPIO ((NRF_GPIO_Type *) NRF_GPIO_BASE)1459 \\#define NRF_GPIO ((NRF_GPIO_Type *) NRF_GPIO_BASE)
1460 , &[_][]const u8{1460 , &[_][]const u8{
1461 \\pub const NRF_GPIO = (if (@typeInfo(@TypeOf(NRF_GPIO_BASE)) == .Pointer) @ptrCast([*c]NRF_GPIO_Type, NRF_GPIO_BASE) else if (@typeInfo(@TypeOf(NRF_GPIO_BASE)) == .Int and @typeInfo([*c]NRF_GPIO_Type) == .Pointer) @intToPtr([*c]NRF_GPIO_Type, NRF_GPIO_BASE) else @as([*c]NRF_GPIO_Type, NRF_GPIO_BASE));1461 \\pub const NRF_GPIO = (if (@typeInfo(@TypeOf(NRF_GPIO_BASE)) == .Pointer) @ptrCast([*c]NRF_GPIO_Type, @alignCast(@alignOf([*c]NRF_GPIO_Type.Child), NRF_GPIO_BASE)) else if (@typeInfo(@TypeOf(NRF_GPIO_BASE)) == .Int and @typeInfo([*c]NRF_GPIO_Type) == .Pointer) @intToPtr([*c]NRF_GPIO_Type, NRF_GPIO_BASE) else @as([*c]NRF_GPIO_Type, NRF_GPIO_BASE));
1462 });1462 });
14631463
1464 cases.add("basic macro function",1464 cases.add("basic macro function",
...@@ -2375,6 +2375,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {...@@ -2375,6 +2375,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
2375 cases.add("compound assignment operators",2375 cases.add("compound assignment operators",
2376 \\void foo(void) {2376 \\void foo(void) {
2377 \\ int a = 0;2377 \\ int a = 0;
2378 \\ unsigned b = 0;
2378 \\ a += (a += 1);2379 \\ a += (a += 1);
2379 \\ a -= (a -= 1);2380 \\ a -= (a -= 1);
2380 \\ a *= (a *= 1);2381 \\ a *= (a *= 1);
...@@ -2383,10 +2384,15 @@ pub fn addCases(cases: *tests.TranslateCContext) void {...@@ -2383,10 +2384,15 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
2383 \\ a ^= (a ^= 1);2384 \\ a ^= (a ^= 1);
2384 \\ a >>= (a >>= 1);2385 \\ a >>= (a >>= 1);
2385 \\ a <<= (a <<= 1);2386 \\ a <<= (a <<= 1);
2387 \\ a /= (a /= 1);
2388 \\ a %= (a %= 1);
2389 \\ b /= (b /= 1);
2390 \\ b %= (b %= 1);
2386 \\}2391 \\}
2387 , &[_][]const u8{2392 , &[_][]const u8{
2388 \\pub export fn foo() void {2393 \\pub export fn foo() void {
2389 \\ var a: c_int = 0;2394 \\ var a: c_int = 0;
2395 \\ var b: c_uint = @bitCast(c_uint, @as(c_int, 0));
2390 \\ a += (blk: {2396 \\ a += (blk: {
2391 \\ const ref = &a;2397 \\ const ref = &a;
2392 \\ ref.* = ref.* + @as(c_int, 1);2398 \\ ref.* = ref.* + @as(c_int, 1);
...@@ -2427,6 +2433,26 @@ pub fn addCases(cases: *tests.TranslateCContext) void {...@@ -2427,6 +2433,26 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
2427 \\ ref.* = ref.* << @intCast(@import("std").math.Log2Int(c_int), @as(c_int, 1));2433 \\ ref.* = ref.* << @intCast(@import("std").math.Log2Int(c_int), @as(c_int, 1));
2428 \\ break :blk ref.*;2434 \\ break :blk ref.*;
2429 \\ }));2435 \\ }));
2436 \\ a = @divTrunc(a, (blk: {
2437 \\ const ref = &a;
2438 \\ ref.* = @divTrunc(ref.*, @as(c_int, 1));
2439 \\ break :blk ref.*;
2440 \\ }));
2441 \\ a = @rem(a, (blk: {
2442 \\ const ref = &a;
2443 \\ ref.* = @rem(ref.*, @as(c_int, 1));
2444 \\ break :blk ref.*;
2445 \\ }));
2446 \\ b /= (blk: {
2447 \\ const ref = &b;
2448 \\ ref.* = ref.* / @bitCast(c_uint, @as(c_int, 1));
2449 \\ break :blk ref.*;
2450 \\ });
2451 \\ b %= (blk: {
2452 \\ const ref = &b;
2453 \\ ref.* = ref.* % @bitCast(c_uint, @as(c_int, 1));
2454 \\ break :blk ref.*;
2455 \\ });
2430 \\}2456 \\}
2431 });2457 });
24322458
...@@ -2642,11 +2668,11 @@ pub fn addCases(cases: *tests.TranslateCContext) void {...@@ -2642,11 +2668,11 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
2642 \\#define FOO(bar) baz((void *)(baz))2668 \\#define FOO(bar) baz((void *)(baz))
2643 \\#define BAR (void*) a2669 \\#define BAR (void*) a
2644 , &[_][]const u8{2670 , &[_][]const u8{
2645 \\pub inline fn FOO(bar: var) @TypeOf(baz((if (@typeInfo(@TypeOf(baz)) == .Pointer) @ptrCast(*c_void, baz) else if (@typeInfo(@TypeOf(baz)) == .Int and @typeInfo(*c_void) == .Pointer) @intToPtr(*c_void, baz) else @as(*c_void, baz)))) {2671 \\pub inline fn FOO(bar: var) @TypeOf(baz((if (@typeInfo(@TypeOf(baz)) == .Pointer) @ptrCast(?*c_void, @alignCast(@alignOf(?*c_void.Child), baz)) else if (@typeInfo(@TypeOf(baz)) == .Int and @typeInfo(?*c_void) == .Pointer) @intToPtr(?*c_void, baz) else @as(?*c_void, baz)))) {
2646 \\ return baz((if (@typeInfo(@TypeOf(baz)) == .Pointer) @ptrCast(*c_void, baz) else if (@typeInfo(@TypeOf(baz)) == .Int and @typeInfo(*c_void) == .Pointer) @intToPtr(*c_void, baz) else @as(*c_void, baz)));2672 \\ return baz((if (@typeInfo(@TypeOf(baz)) == .Pointer) @ptrCast(?*c_void, @alignCast(@alignOf(?*c_void.Child), baz)) else if (@typeInfo(@TypeOf(baz)) == .Int and @typeInfo(?*c_void) == .Pointer) @intToPtr(?*c_void, baz) else @as(?*c_void, baz)));
2647 \\}2673 \\}
2648 ,2674 ,
2649 \\pub const BAR = (if (@typeInfo(@TypeOf(a)) == .Pointer) @ptrCast(*c_void, a) else if (@typeInfo(@TypeOf(a)) == .Int and @typeInfo(*c_void) == .Pointer) @intToPtr(*c_void, a) else @as(*c_void, a));2675 \\pub const BAR = (if (@typeInfo(@TypeOf(a)) == .Pointer) @ptrCast(?*c_void, @alignCast(@alignOf(?*c_void.Child), a)) else if (@typeInfo(@TypeOf(a)) == .Int and @typeInfo(?*c_void) == .Pointer) @intToPtr(?*c_void, a) else @as(?*c_void, a));
2650 });2676 });
26512677
2652 cases.add("macro conditional operator",2678 cases.add("macro conditional operator",
...@@ -2853,7 +2879,38 @@ pub fn addCases(cases: *tests.TranslateCContext) void {...@@ -2853,7 +2879,38 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
2853 , &[_][]const u8{2879 , &[_][]const u8{
2854 \\pub const FOO = 0x61626364;2880 \\pub const FOO = 0x61626364;
2855 });2881 });
2882
2883 cases.add("Make sure casts are grouped",
2884 \\typedef struct
2885 \\{
2886 \\ int i;
2887 \\}
2888 \\*_XPrivDisplay;
2889 \\typedef struct _XDisplay Display;
2890 \\#define DefaultScreen(dpy) (((_XPrivDisplay)(dpy))->default_screen)
2891 \\
2892 , &[_][]const u8{
2893 \\pub inline fn DefaultScreen(dpy: var) @TypeOf((if (@typeInfo(@TypeOf(dpy)) == .Pointer) @ptrCast(_XPrivDisplay, @alignCast(@alignOf(_XPrivDisplay.Child), dpy)) else if (@typeInfo(@TypeOf(dpy)) == .Int and @typeInfo(_XPrivDisplay) == .Pointer) @intToPtr(_XPrivDisplay, dpy) else @as(_XPrivDisplay, dpy)).*.default_screen) {
2894 \\ return (if (@typeInfo(@TypeOf(dpy)) == .Pointer) @ptrCast(_XPrivDisplay, @alignCast(@alignOf(_XPrivDisplay.Child), dpy)) else if (@typeInfo(@TypeOf(dpy)) == .Int and @typeInfo(_XPrivDisplay) == .Pointer) @intToPtr(_XPrivDisplay, dpy) else @as(_XPrivDisplay, dpy)).*.default_screen;
2895 \\}
2896 });
28562897
2898 cases.add("Cast from integer literals to poiter",
2899 \\#define NULL ((void*)0)
2900 \\#define GPIO_0_MEM_MAP ((unsigned*)0x8000)
2901 \\#define GPIO_1_MEM_MAP ((unsigned*)0x8004)
2902 \\#define GPIO_2_MEM_MAP ((unsigned*)0x8008)
2903 \\
2904 , &[_][]const u8{
2905 \\pub const NULL = @intToPtr(?*c_void, 0);
2906 ,
2907 \\pub const GPIO_0_MEM_MAP = @intToPtr([*c]c_uint, 0x8000);
2908 ,
2909 \\pub const GPIO_1_MEM_MAP = @intToPtr([*c]c_uint, 0x8004);
2910 ,
2911 \\pub const GPIO_2_MEM_MAP = @intToPtr([*c]c_uint, 0x8008);
2912 });
2913
2857 if (std.Target.current.abi == .msvc) {2914 if (std.Target.current.abi == .msvc) {
2858 cases.add("nameless struct fields",2915 cases.add("nameless struct fields",
2859 \\typedef struct NAMED2916 \\typedef struct NAMED
tools/merge_anal_dumps.zig+5-5
...@@ -23,7 +23,7 @@ pub fn main() anyerror!void {...@@ -23,7 +23,7 @@ pub fn main() anyerror!void {
23 }23 }
2424
25 const stdout = try std.io.getStdOut();25 const stdout = try std.io.getStdOut();
26 try dump.render(&stdout.outStream().stream);26 try dump.render(stdout.outStream());
27}27}
2828
29/// AST source node29/// AST source node
...@@ -194,7 +194,7 @@ const Dump = struct {...@@ -194,7 +194,7 @@ const Dump = struct {
194 for (other_files) |other_file, i| {194 for (other_files) |other_file, i| {
195 const gop = try self.file_map.getOrPut(other_file.String);195 const gop = try self.file_map.getOrPut(other_file.String);
196 if (!gop.found_existing) {196 if (!gop.found_existing) {
197 gop.kv.value = self.file_list.len;197 gop.kv.value = self.file_list.items.len;
198 try self.file_list.append(other_file.String);198 try self.file_list.append(other_file.String);
199 }199 }
200 try other_file_to_mine.putNoClobber(i, gop.kv.value);200 try other_file_to_mine.putNoClobber(i, gop.kv.value);
...@@ -213,7 +213,7 @@ const Dump = struct {...@@ -213,7 +213,7 @@ const Dump = struct {
213 };213 };
214 const gop = try self.node_map.getOrPut(other_node);214 const gop = try self.node_map.getOrPut(other_node);
215 if (!gop.found_existing) {215 if (!gop.found_existing) {
216 gop.kv.value = self.node_list.len;216 gop.kv.value = self.node_list.items.len;
217 try self.node_list.append(other_node);217 try self.node_list.append(other_node);
218 }218 }
219 try other_ast_node_to_mine.putNoClobber(i, gop.kv.value);219 try other_ast_node_to_mine.putNoClobber(i, gop.kv.value);
...@@ -243,7 +243,7 @@ const Dump = struct {...@@ -243,7 +243,7 @@ const Dump = struct {
243 };243 };
244 const gop = try self.error_map.getOrPut(other_error);244 const gop = try self.error_map.getOrPut(other_error);
245 if (!gop.found_existing) {245 if (!gop.found_existing) {
246 gop.kv.value = self.error_list.len;246 gop.kv.value = self.error_list.items.len;
247 try self.error_list.append(other_error);247 try self.error_list.append(other_error);
248 }248 }
249 try other_error_to_mine.putNoClobber(i, gop.kv.value);249 try other_error_to_mine.putNoClobber(i, gop.kv.value);
...@@ -304,7 +304,7 @@ const Dump = struct {...@@ -304,7 +304,7 @@ const Dump = struct {
304 ) !void {304 ) !void {
305 const gop = try self.type_map.getOrPut(other_type);305 const gop = try self.type_map.getOrPut(other_type);
306 if (!gop.found_existing) {306 if (!gop.found_existing) {
307 gop.kv.value = self.type_list.len;307 gop.kv.value = self.type_list.items.len;
308 try self.type_list.append(other_type);308 try self.type_list.append(other_type);
309 }309 }
310 try other_types_to_mine.putNoClobber(other_type_index, gop.kv.value);310 try other_types_to_mine.putNoClobber(other_type_index, gop.kv.value);
tools/update_clang_options.zig+56-1
...@@ -54,6 +54,10 @@ const known_options = [_]KnownOpt{...@@ -54,6 +54,10 @@ const known_options = [_]KnownOpt{
54 .name = "fno-PIC",54 .name = "fno-PIC",
55 .ident = "no_pic",55 .ident = "no_pic",
56 },56 },
57 .{
58 .name = "nolibc",
59 .ident = "nostdlib",
60 },
57 .{61 .{
58 .name = "nostdlib",62 .name = "nostdlib",
59 .ident = "nostdlib",63 .ident = "nostdlib",
...@@ -66,6 +70,22 @@ const known_options = [_]KnownOpt{...@@ -66,6 +70,22 @@ const known_options = [_]KnownOpt{
66 .name = "nostdlib++",70 .name = "nostdlib++",
67 .ident = "nostdlib_cpp",71 .ident = "nostdlib_cpp",
68 },72 },
73 .{
74 .name = "nostdinc++",
75 .ident = "nostdlib_cpp",
76 },
77 .{
78 .name = "nostdlibinc",
79 .ident = "nostdlibinc",
80 },
81 .{
82 .name = "nostdinc",
83 .ident = "nostdlibinc",
84 },
85 .{
86 .name = "no-standard-includes",
87 .ident = "nostdlibinc",
88 },
69 .{89 .{
70 .name = "shared",90 .name = "shared",
71 .ident = "shared",91 .ident = "shared",
...@@ -206,6 +226,34 @@ const known_options = [_]KnownOpt{...@@ -206,6 +226,34 @@ const known_options = [_]KnownOpt{
206 .name = "MF",226 .name = "MF",
207 .ident = "dep_file",227 .ident = "dep_file",
208 },228 },
229 .{
230 .name = "MT",
231 .ident = "dep_file",
232 },
233 .{
234 .name = "MG",
235 .ident = "dep_file",
236 },
237 .{
238 .name = "MJ",
239 .ident = "dep_file",
240 },
241 .{
242 .name = "MM",
243 .ident = "dep_file",
244 },
245 .{
246 .name = "MMD",
247 .ident = "dep_file",
248 },
249 .{
250 .name = "MP",
251 .ident = "dep_file",
252 },
253 .{
254 .name = "MQ",
255 .ident = "dep_file",
256 },
209 .{257 .{
210 .name = "F",258 .name = "F",
211 .ident = "framework_dir",259 .ident = "framework_dir",
...@@ -336,7 +384,12 @@ pub fn main() anyerror!void {...@@ -336,7 +384,12 @@ pub fn main() anyerror!void {
336 }384 }
337 const syntax = objSyntax(obj);385 const syntax = objSyntax(obj);
338386
339 if (knownOption(name)) |ident| {387 if (std.mem.eql(u8, name, "MT") and syntax == .flag) {
388 // `-MT foo` is ambiguous because there is also an -MT flag
389 // The canonical way to specify the flag is with `/MT` and so we make this
390 // the only way.
391 try stdout.print("flagpsl(\"{}\"),\n", .{name});
392 } else if (knownOption(name)) |ident| {
340 try stdout.print(393 try stdout.print(
341 \\.{{394 \\.{{
342 \\ .name = "{}",395 \\ .name = "{}",
...@@ -350,6 +403,8 @@ pub fn main() anyerror!void {...@@ -350,6 +403,8 @@ pub fn main() anyerror!void {
350 , .{ name, syntax, ident, pd1, pd2, pslash });403 , .{ name, syntax, ident, pd1, pd2, pslash });
351 } else if (pd1 and !pd2 and !pslash and syntax == .flag) {404 } else if (pd1 and !pd2 and !pslash and syntax == .flag) {
352 try stdout.print("flagpd1(\"{}\"),\n", .{name});405 try stdout.print("flagpd1(\"{}\"),\n", .{name});
406 } else if (!pd1 and !pd2 and pslash and syntax == .flag) {
407 try stdout.print("flagpsl(\"{}\"),\n", .{name});
353 } else if (pd1 and !pd2 and !pslash and syntax == .joined) {408 } else if (pd1 and !pd2 and !pslash and syntax == .joined) {
354 try stdout.print("joinpd1(\"{}\"),\n", .{name});409 try stdout.print("joinpd1(\"{}\"),\n", .{name});
355 } else if (pd1 and !pd2 and !pslash and syntax == .joined_or_separate) {410 } else if (pd1 and !pd2 and !pslash and syntax == .joined_or_separate) {
tools/update_glibc.zig+3-1
...@@ -21,6 +21,7 @@ const lib_names = [_][]const u8{...@@ -21,6 +21,7 @@ const lib_names = [_][]const u8{
21 "pthread",21 "pthread",
22 "rt",22 "rt",
23 "ld",23 "ld",
24 "util",
24};25};
2526
26// fpu/nofpu are hardcoded elsewhere, based on .gnueabi/.gnueabihf with an exception for .arm27// fpu/nofpu are hardcoded elsewhere, based on .gnueabi/.gnueabihf with an exception for .arm
...@@ -182,7 +183,8 @@ pub fn main() !void {...@@ -182,7 +183,8 @@ pub fn main() !void {
182 }183 }
183 break :blk try fs.path.join(allocator, &[_][]const u8{ prefix, abi_list.path, basename });184 break :blk try fs.path.join(allocator, &[_][]const u8{ prefix, abi_list.path, basename });
184 };185 };
185 const contents = std.io.readFileAlloc(allocator, abi_list_filename) catch |err| {186 const max_bytes = 10 * 1024 * 1024;
187 const contents = std.fs.cwd().readFileAlloc(allocator, abi_list_filename, max_bytes) catch |err| {
186 std.debug.warn("unable to open {}: {}\n", .{ abi_list_filename, err });188 std.debug.warn("unable to open {}: {}\n", .{ abi_list_filename, err });
187 std.process.exit(1);189 std.process.exit(1);
188 };190 };