authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-09-10 13:00:35-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-09-10 13:00:35-04:00
log185cb1327806f073b91218ff2fd6f21d95060c00
tree2b1ad839768962626689df3abd1434b59f43d96f
parent058050f22c5c72507cae57f27e83b2ad2e9afec3
parentba4d83af3e58ce2a34ccb945a297211333fd904c
signature Commit is signed but in an unrecognized format.

Merge remote-tracking branch 'origin/master' into llvm9


171 files changed, 6231 insertions(+), 2802 deletions(-)

CMakeLists.txt+21-7
...@@ -23,14 +23,18 @@ find_program(GIT_EXE NAMES git)...@@ -23,14 +23,18 @@ find_program(GIT_EXE NAMES git)
23if(GIT_EXE)23if(GIT_EXE)
24 execute_process(24 execute_process(
25 COMMAND ${GIT_EXE} -C ${CMAKE_SOURCE_DIR} name-rev HEAD --tags --name-only --no-undefined --always25 COMMAND ${GIT_EXE} -C ${CMAKE_SOURCE_DIR} name-rev HEAD --tags --name-only --no-undefined --always
26 RESULT_VARIABLE EXIT_STATUS
26 OUTPUT_VARIABLE ZIG_GIT_REV27 OUTPUT_VARIABLE ZIG_GIT_REV
27 OUTPUT_STRIP_TRAILING_WHITESPACE)28 OUTPUT_STRIP_TRAILING_WHITESPACE
28 if(ZIG_GIT_REV MATCHES "\\^0$")29 ERROR_QUIET)
29 if(NOT("${ZIG_GIT_REV}" STREQUAL "${ZIG_VERSION}^0"))30 if(EXIT_STATUS EQUAL "0")
30 message("WARNING: Tag does not match configured Zig version")31 if(ZIG_GIT_REV MATCHES "\\^0$")
32 if(NOT("${ZIG_GIT_REV}" STREQUAL "${ZIG_VERSION}^0"))
33 message("WARNING: Tag does not match configured Zig version")
34 endif()
35 else()
36 set(ZIG_VERSION "${ZIG_VERSION}+${ZIG_GIT_REV}")
31 endif()37 endif()
32 else()
33 set(ZIG_VERSION "${ZIG_VERSION}+${ZIG_GIT_REV}")
34 endif()38 endif()
35endif()39endif()
36message("Configuring zig version ${ZIG_VERSION}")40message("Configuring zig version ${ZIG_VERSION}")
...@@ -448,6 +452,7 @@ set(ZIG_SOURCES...@@ -448,6 +452,7 @@ set(ZIG_SOURCES
448 "${CMAKE_SOURCE_DIR}/src/os.cpp"452 "${CMAKE_SOURCE_DIR}/src/os.cpp"
449 "${CMAKE_SOURCE_DIR}/src/parser.cpp"453 "${CMAKE_SOURCE_DIR}/src/parser.cpp"
450 "${CMAKE_SOURCE_DIR}/src/range_set.cpp"454 "${CMAKE_SOURCE_DIR}/src/range_set.cpp"
455 "${CMAKE_SOURCE_DIR}/src/stack_report.cpp"
451 "${CMAKE_SOURCE_DIR}/src/target.cpp"456 "${CMAKE_SOURCE_DIR}/src/target.cpp"
452 "${CMAKE_SOURCE_DIR}/src/tokenizer.cpp"457 "${CMAKE_SOURCE_DIR}/src/tokenizer.cpp"
453 "${CMAKE_SOURCE_DIR}/src/translate_c.cpp"458 "${CMAKE_SOURCE_DIR}/src/translate_c.cpp"
...@@ -504,7 +509,7 @@ endif()...@@ -504,7 +509,7 @@ endif()
504if(MSVC)509if(MSVC)
505 set(EXE_CFLAGS "${EXE_CFLAGS}")510 set(EXE_CFLAGS "${EXE_CFLAGS}")
506else()511else()
507 set(EXE_CFLAGS "${EXE_CFLAGS} -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -D_GNU_SOURCE -fvisibility-inlines-hidden -fno-exceptions -fno-rtti -Werror=strict-prototypes -Werror=old-style-definition -Werror=type-limits -Wno-missing-braces")512 set(EXE_CFLAGS "${EXE_CFLAGS} -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -D_GNU_SOURCE -fvisibility-inlines-hidden -fno-exceptions -fno-rtti -Werror=type-limits -Wno-missing-braces")
508 if(MINGW)513 if(MINGW)
509 set(EXE_CFLAGS "${EXE_CFLAGS} -Wno-format")514 set(EXE_CFLAGS "${EXE_CFLAGS} -Wno-format")
510 endif()515 endif()
...@@ -515,6 +520,9 @@ set(OPTIMIZED_C_FLAGS "-std=c99 -O3")...@@ -515,6 +520,9 @@ set(OPTIMIZED_C_FLAGS "-std=c99 -O3")
515set(EXE_LDFLAGS " ")520set(EXE_LDFLAGS " ")
516if(MSVC)521if(MSVC)
517 set(EXE_LDFLAGS "${EXE_LDFLAGS} /STACK:16777216")522 set(EXE_LDFLAGS "${EXE_LDFLAGS} /STACK:16777216")
523 if(NOT "${CMAKE_BUILD_TYPE}" STREQUAL "Release" AND NOT "${CMAKE_BUILD_TYPE}" STREQUAL "MinSizeRel")
524 set(EXE_LDFLAGS "${EXE_LDFLAGS} /debug:fastlink")
525 endif()
518elseif(MINGW) 526elseif(MINGW)
519 set(EXE_LDFLAGS "${EXE_LDFLAGS} -Wl,--stack,16777216")527 set(EXE_LDFLAGS "${EXE_LDFLAGS} -Wl,--stack,16777216")
520endif()528endif()
...@@ -586,12 +594,18 @@ if(MSVC)...@@ -586,12 +594,18 @@ if(MSVC)
586else()594else()
587 set(LIBUSERLAND "${CMAKE_BINARY_DIR}/libuserland.a")595 set(LIBUSERLAND "${CMAKE_BINARY_DIR}/libuserland.a")
588endif()596endif()
597if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
598 set(LIBUSERLAND_RELEASE_MODE "false")
599else()
600 set(LIBUSERLAND_RELEASE_MODE "true")
601endif()
589add_custom_target(zig_build_libuserland ALL602add_custom_target(zig_build_libuserland ALL
590 COMMAND zig0 build603 COMMAND zig0 build
591 --override-std-dir std604 --override-std-dir std
592 --override-lib-dir "${CMAKE_SOURCE_DIR}"605 --override-lib-dir "${CMAKE_SOURCE_DIR}"
593 libuserland install606 libuserland install
594 "-Doutput-dir=${CMAKE_BINARY_DIR}"607 "-Doutput-dir=${CMAKE_BINARY_DIR}"
608 "-Drelease=${LIBUSERLAND_RELEASE_MODE}"
595 "-Dlib-files-only"609 "-Dlib-files-only"
596 --prefix "${CMAKE_INSTALL_PREFIX}"610 --prefix "${CMAKE_INSTALL_PREFIX}"
597 DEPENDS zig0611 DEPENDS zig0
build.zig+8-3
...@@ -63,7 +63,7 @@ pub fn build(b: *Builder) !void {...@@ -63,7 +63,7 @@ pub fn build(b: *Builder) !void {
63 try configureStage2(b, test_stage2, ctx);63 try configureStage2(b, test_stage2, ctx);
64 try configureStage2(b, exe, ctx);64 try configureStage2(b, exe, ctx);
6565
66 addLibUserlandStep(b);66 addLibUserlandStep(b, mode);
6767
68 const skip_release = b.option(bool, "skip-release", "Main test suite skips release builds") orelse false;68 const skip_release = b.option(bool, "skip-release", "Main test suite skips release builds") orelse false;
69 const skip_release_small = b.option(bool, "skip-release-small", "Main test suite skips release-small builds") orelse skip_release;69 const skip_release_small = b.option(bool, "skip-release-small", "Main test suite skips release-small builds") orelse skip_release;
...@@ -138,12 +138,13 @@ pub fn build(b: *Builder) !void {...@@ -138,12 +138,13 @@ pub fn build(b: *Builder) !void {
138138
139 test_step.dependOn(tests.addCompareOutputTests(b, test_filter, modes));139 test_step.dependOn(tests.addCompareOutputTests(b, test_filter, modes));
140 test_step.dependOn(tests.addStandaloneTests(b, test_filter, modes));140 test_step.dependOn(tests.addStandaloneTests(b, test_filter, modes));
141 test_step.dependOn(tests.addStackTraceTests(b, test_filter, modes));
141 test_step.dependOn(tests.addCliTests(b, test_filter, modes));142 test_step.dependOn(tests.addCliTests(b, test_filter, modes));
142 test_step.dependOn(tests.addCompileErrorTests(b, test_filter, modes));
143 test_step.dependOn(tests.addAssembleAndLinkTests(b, test_filter, modes));143 test_step.dependOn(tests.addAssembleAndLinkTests(b, test_filter, modes));
144 test_step.dependOn(tests.addRuntimeSafetyTests(b, test_filter, modes));144 test_step.dependOn(tests.addRuntimeSafetyTests(b, test_filter, modes));
145 test_step.dependOn(tests.addTranslateCTests(b, test_filter));145 test_step.dependOn(tests.addTranslateCTests(b, test_filter));
146 test_step.dependOn(tests.addGenHTests(b, test_filter));146 test_step.dependOn(tests.addGenHTests(b, test_filter));
147 test_step.dependOn(tests.addCompileErrorTests(b, test_filter, modes));
147 test_step.dependOn(docs_step);148 test_step.dependOn(docs_step);
148}149}
149150
...@@ -369,11 +370,15 @@ const Context = struct {...@@ -369,11 +370,15 @@ const Context = struct {
369 llvm: LibraryDep,370 llvm: LibraryDep,
370};371};
371372
372fn addLibUserlandStep(b: *Builder) void {373fn addLibUserlandStep(b: *Builder, mode: builtin.Mode) void {
373 const artifact = b.addStaticLibrary("userland", "src-self-hosted/stage1.zig");374 const artifact = b.addStaticLibrary("userland", "src-self-hosted/stage1.zig");
374 artifact.disable_gen_h = true;375 artifact.disable_gen_h = true;
375 artifact.bundle_compiler_rt = true;376 artifact.bundle_compiler_rt = true;
376 artifact.setTarget(builtin.arch, builtin.os, builtin.abi);377 artifact.setTarget(builtin.arch, builtin.os, builtin.abi);
378 artifact.setBuildMode(mode);
379 if (mode != .Debug) {
380 artifact.strip = true;
381 }
377 artifact.linkSystemLibrary("c");382 artifact.linkSystemLibrary("c");
378 if (builtin.os == .windows) {383 if (builtin.os == .windows) {
379 artifact.linkSystemLibrary("ntdll");384 artifact.linkSystemLibrary("ntdll");
doc/docgen.zig+28-4
...@@ -307,7 +307,7 @@ const Node = union(enum) {...@@ -307,7 +307,7 @@ const Node = union(enum) {
307const Toc = struct {307const Toc = struct {
308 nodes: []Node,308 nodes: []Node,
309 toc: []u8,309 toc: []u8,
310 urls: std.HashMap([]const u8, Token, mem.hash_slice_u8, mem.eql_slice_u8),310 urls: std.StringHashMap(Token),
311};311};
312312
313const Action = enum {313const Action = enum {
...@@ -316,11 +316,12 @@ const Action = enum {...@@ -316,11 +316,12 @@ const Action = enum {
316};316};
317317
318fn genToc(allocator: *mem.Allocator, tokenizer: *Tokenizer) !Toc {318fn genToc(allocator: *mem.Allocator, tokenizer: *Tokenizer) !Toc {
319 var urls = std.HashMap([]const u8, Token, mem.hash_slice_u8, mem.eql_slice_u8).init(allocator);319 var urls = std.StringHashMap(Token).init(allocator);
320 errdefer urls.deinit();320 errdefer urls.deinit();
321321
322 var header_stack_size: usize = 0;322 var header_stack_size: usize = 0;
323 var last_action = Action.Open;323 var last_action = Action.Open;
324 var last_columns: ?u8 = null;
324325
325 var toc_buf = try std.Buffer.initSize(allocator, 0);326 var toc_buf = try std.Buffer.initSize(allocator, 0);
326 defer toc_buf.deinit();327 defer toc_buf.deinit();
...@@ -361,7 +362,23 @@ fn genToc(allocator: *mem.Allocator, tokenizer: *Tokenizer) !Toc {...@@ -361,7 +362,23 @@ fn genToc(allocator: *mem.Allocator, tokenizer: *Tokenizer) !Toc {
361 _ = try eatToken(tokenizer, Token.Id.Separator);362 _ = try eatToken(tokenizer, Token.Id.Separator);
362 const content_token = try eatToken(tokenizer, Token.Id.TagContent);363 const content_token = try eatToken(tokenizer, Token.Id.TagContent);
363 const content = tokenizer.buffer[content_token.start..content_token.end];364 const content = tokenizer.buffer[content_token.start..content_token.end];
364 _ = try eatToken(tokenizer, Token.Id.BracketClose);365 var columns: ?u8 = null;
366 while (true) {
367 const bracket_tok = tokenizer.next();
368 switch (bracket_tok.id) {
369 .BracketClose => break,
370 .Separator => continue,
371 .TagContent => {
372 const param = tokenizer.buffer[bracket_tok.start..bracket_tok.end];
373 if (mem.eql(u8, param, "3col")) {
374 columns = 3;
375 } else {
376 return parseError(tokenizer, bracket_tok, "unrecognized header_open param: {}", param);
377 }
378 },
379 else => return parseError(tokenizer, bracket_tok, "invalid header_open token"),
380 }
381 }
365382
366 header_stack_size += 1;383 header_stack_size += 1;
367384
...@@ -381,10 +398,15 @@ fn genToc(allocator: *mem.Allocator, tokenizer: *Tokenizer) !Toc {...@@ -381,10 +398,15 @@ fn genToc(allocator: *mem.Allocator, tokenizer: *Tokenizer) !Toc {
381 if (last_action == Action.Open) {398 if (last_action == Action.Open) {
382 try toc.writeByte('\n');399 try toc.writeByte('\n');
383 try toc.writeByteNTimes(' ', header_stack_size * 4);400 try toc.writeByteNTimes(' ', header_stack_size * 4);
384 try toc.write("<ul>\n");401 if (last_columns) |n| {
402 try toc.print("<ul style=\"columns: {}\">\n", n);
403 } else {
404 try toc.write("<ul>\n");
405 }
385 } else {406 } else {
386 last_action = Action.Open;407 last_action = Action.Open;
387 }408 }
409 last_columns = columns;
388 try toc.writeByteNTimes(' ', 4 + header_stack_size * 4);410 try toc.writeByteNTimes(' ', 4 + header_stack_size * 4);
389 try toc.print("<li><a id=\"toc-{}\" href=\"#{}\">{}</a>", urlized, urlized, content);411 try toc.print("<li><a id=\"toc-{}\" href=\"#{}\">{}</a>", urlized, urlized, content);
390 } else if (mem.eql(u8, tag_name, "header_close")) {412 } else if (mem.eql(u8, tag_name, "header_close")) {
...@@ -766,6 +788,8 @@ fn tokenizeAndPrintRaw(docgen_tokenizer: *Tokenizer, out: var, source_token: Tok...@@ -766,6 +788,8 @@ fn tokenizeAndPrintRaw(docgen_tokenizer: *Tokenizer, out: var, source_token: Tok
766 .Keyword_inline,788 .Keyword_inline,
767 .Keyword_nakedcc,789 .Keyword_nakedcc,
768 .Keyword_noalias,790 .Keyword_noalias,
791 .Keyword_noasync,
792 .Keyword_noinline,
769 .Keyword_or,793 .Keyword_or,
770 .Keyword_orelse,794 .Keyword_orelse,
771 .Keyword_packed,795 .Keyword_packed,
doc/langref.html.in+76-4
...@@ -6323,7 +6323,7 @@ fn readFile(allocator: *Allocator, filename: []const u8) ![]u8 {...@@ -6323,7 +6323,7 @@ fn readFile(allocator: *Allocator, filename: []const u8) ![]u8 {
6323 {#header_close#}6323 {#header_close#}
63246324
6325 {#header_close#}6325 {#header_close#}
6326 {#header_open|Builtin Functions#}6326 {#header_open|Builtin Functions|3col#}
6327 <p>6327 <p>
6328 Builtin functions are provided by the compiler and are prefixed with <code>@</code>.6328 Builtin functions are provided by the compiler and are prefixed with <code>@</code>.
6329 The {#syntax#}comptime{#endsyntax#} keyword on a parameter means that the parameter must be known6329 The {#syntax#}comptime{#endsyntax#} keyword on a parameter means that the parameter must be known
...@@ -6976,10 +6976,28 @@ export fn @"A function name that is a complete sentence."() void {}...@@ -6976,10 +6976,28 @@ export fn @"A function name that is a complete sentence."() void {}
69766976
6977 {#header_open|@field#}6977 {#header_open|@field#}
6978 <pre>{#syntax#}@field(lhs: var, comptime field_name: []const u8) (field){#endsyntax#}</pre>6978 <pre>{#syntax#}@field(lhs: var, comptime field_name: []const u8) (field){#endsyntax#}</pre>
6979 <p>Preforms field access equivalent to {#syntax#}lhs.field_name{#endsyntax#}, except instead6979 <p>Performs field access by a compile-time string.
6980 of the field {#syntax#}"field_name"{#endsyntax#}, it accesses the field named by the string
6981 value of {#syntax#}field_name{#endsyntax#}.
6982 </p>6980 </p>
6981 {#code_begin|test#}
6982const std = @import("std");
6983
6984const Point = struct {
6985 x: u32,
6986 y: u32
6987};
6988
6989test "field access by string" {
6990 const assert = std.debug.assert;
6991 var p = Point {.x = 0, .y = 0};
6992
6993 @field(p, "x") = 4;
6994 @field(p, "y") = @field(p, "x") + 1;
6995
6996 assert(@field(p, "x") == 4);
6997 assert(@field(p, "y") == 5);
6998}
6999 {#code_end#}
7000
6983 {#header_close#}7001 {#header_close#}
69847002
6985 {#header_open|@fieldParentPtr#}7003 {#header_open|@fieldParentPtr#}
...@@ -7232,6 +7250,9 @@ fn add(a: i32, b: i32) i32 { return a + b; }...@@ -7232,6 +7250,9 @@ fn add(a: i32, b: i32) i32 { return a + b; }
7232 This function returns an integer type with the given signness and bit count. The maximum7250 This function returns an integer type with the given signness and bit count. The maximum
7233 bit count for an integer type is {#syntax#}65535{#endsyntax#}.7251 bit count for an integer type is {#syntax#}65535{#endsyntax#}.
7234 </p>7252 </p>
7253 <p>
7254 Deprecated. Use {#link|@Type#}.
7255 </p>
7235 {#header_close#}7256 {#header_close#}
72367257
7237 {#header_open|@memberCount#}7258 {#header_open|@memberCount#}
...@@ -7871,6 +7892,57 @@ test "integer truncation" {...@@ -7871,6 +7892,57 @@ test "integer truncation" {
7871 </p>7892 </p>
7872 {#header_close#}7893 {#header_close#}
78737894
7895 {#header_open|@Type#}
7896 <pre>{#syntax#}@Type(comptime info: @import("builtin").TypeInfo) type{#endsyntax#}</pre>
7897 <p>
7898 This function is the inverse of {#link|@typeInfo#}. It reifies type information
7899 into a {#syntax#}type{#endsyntax#}.
7900 </p>
7901 <p>
7902 It is available for the following types:
7903 </p>
7904 <ul>
7905 <li>{#syntax#}type{#endsyntax#}</li>
7906 <li>{#syntax#}noreturn{#endsyntax#}</li>
7907 <li>{#syntax#}void{#endsyntax#}</li>
7908 <li>{#syntax#}bool{#endsyntax#}</li>
7909 <li>{#link|Integers#}</li> - The maximum bit count for an integer type is {#syntax#}65535{#endsyntax#}.
7910 <li>{#link|Floats#}</li>
7911 <li>{#link|Pointers#}</li>
7912 <li>{#syntax#}comptime_int{#endsyntax#}</li>
7913 <li>{#syntax#}comptime_float{#endsyntax#}</li>
7914 <li>{#syntax#}@typeOf(undefined){#endsyntax#}</li>
7915 <li>{#syntax#}@typeOf(null){#endsyntax#}</li>
7916 </ul>
7917 <p>
7918 For these types it is a
7919 <a href="https://github.com/ziglang/zig/issues/2907">TODO in the compiler to implement</a>:
7920 </p>
7921 <ul>
7922 <li>Array</li>
7923 <li>Optional</li>
7924 <li>ErrorUnion</li>
7925 <li>ErrorSet</li>
7926 <li>Enum</li>
7927 <li>Opaque</li>
7928 <li>FnFrame</li>
7929 <li>AnyFrame</li>
7930 <li>Vector</li>
7931 <li>EnumLiteral</li>
7932 </ul>
7933 <p>
7934 For these types, {#syntax#}@Type{#endsyntax#} is not available.
7935 <a href="https://github.com/ziglang/zig/issues/383">There is an open proposal to allow unions and structs</a>.
7936 </p>
7937 <ul>
7938 <li>{#link|union#}</li>
7939 <li>{#link|Functions#}</li>
7940 <li>BoundFn</li>
7941 <li>ArgTuple</li>
7942 <li>{#link|struct#}</li>
7943 </ul>
7944 {#header_close#}
7945
7874 {#header_open|@typeId#}7946 {#header_open|@typeId#}
7875 <pre>{#syntax#}@typeId(comptime T: type) @import("builtin").TypeId{#endsyntax#}</pre>7947 <pre>{#syntax#}@typeId(comptime T: type) @import("builtin").TypeId{#endsyntax#}</pre>
7876 <p>7948 <p>
lib/libc/glibc/abi.txt+330
...@@ -514,6 +514,7 @@ aarch64-linux-gnu aarch64_be-linux-gnu...@@ -514,6 +514,7 @@ aarch64-linux-gnu aarch64_be-linux-gnu
5142951429
5152951529
5162951629
517
5172951829
518519
5192952029
...@@ -655,6 +656,18 @@ aarch64-linux-gnu aarch64_be-linux-gnu...@@ -655,6 +656,18 @@ aarch64-linux-gnu aarch64_be-linux-gnu
655656
656657
657658
659
660
661
662
663
664
665
666
667
668
669
670
658671
659672
660673
...@@ -1928,6 +1941,7 @@ aarch64-linux-gnu aarch64_be-linux-gnu...@@ -1928,6 +1941,7 @@ aarch64-linux-gnu aarch64_be-linux-gnu
192829194129
192929194229
193029194329
194440
193129194529
193229194629
193329194729
...@@ -2048,6 +2062,7 @@ aarch64-linux-gnu aarch64_be-linux-gnu...@@ -2048,6 +2062,7 @@ aarch64-linux-gnu aarch64_be-linux-gnu
204829206229
204929206329
205029206429
206540
205129206629
205229206729
205329206829
...@@ -2721,6 +2736,7 @@ aarch64-linux-gnu aarch64_be-linux-gnu...@@ -2721,6 +2736,7 @@ aarch64-linux-gnu aarch64_be-linux-gnu
272129273629
272229273729
272329273829
273940
272429274029
272529274129
272629274229
...@@ -2749,6 +2765,7 @@ aarch64-linux-gnu aarch64_be-linux-gnu...@@ -2749,6 +2765,7 @@ aarch64-linux-gnu aarch64_be-linux-gnu
274929276529
275029276629
275129276729
276840
275229276929
275329277029
275429277129
...@@ -2776,6 +2793,8 @@ aarch64-linux-gnu aarch64_be-linux-gnu...@@ -2776,6 +2793,8 @@ aarch64-linux-gnu aarch64_be-linux-gnu
277629279329
277729279429
277829279529
279640
279740
277929279829
278029279929
278129280029
...@@ -3002,6 +3021,7 @@ aarch64-linux-gnu aarch64_be-linux-gnu...@@ -3002,6 +3021,7 @@ aarch64-linux-gnu aarch64_be-linux-gnu
300229302129
300329302229
300429302329
302440
300529302529
300629302629
300729302729
...@@ -3370,6 +3390,7 @@ aarch64-linux-gnu aarch64_be-linux-gnu...@@ -3370,6 +3390,7 @@ aarch64-linux-gnu aarch64_be-linux-gnu
337037339037
337137339137
337229339229
339340
337338339438
337438339538
337538339638
...@@ -3443,6 +3464,7 @@ aarch64-linux-gnu aarch64_be-linux-gnu...@@ -3443,6 +3464,7 @@ aarch64-linux-gnu aarch64_be-linux-gnu
344329346429
344429346529
344529346629
346740
344629346829
344729346929
344829347029
...@@ -4218,6 +4240,7 @@ s390x-linux-gnu...@@ -4218,6 +4240,7 @@ s390x-linux-gnu
4218542405
4219542415
4220542425
4243
422127424427
42224245
422327424627
...@@ -4330,12 +4353,18 @@ s390x-linux-gnu...@@ -4330,12 +4353,18 @@ s390x-linux-gnu
433016435316
433116435416
433216435516
435640
435740
433316435816
433438435938
433538436038
433638436138
433716436216
433838436338
436440
436540
436640
436740
433916436816
434016436916
434116437016
...@@ -4356,6 +4385,8 @@ s390x-linux-gnu...@@ -4356,6 +4385,8 @@ s390x-linux-gnu
435616438516
435716438616
435816438716
438840
438940
435916439016
436016439116
436116439216
...@@ -4368,8 +4399,12 @@ s390x-linux-gnu...@@ -4368,8 +4399,12 @@ s390x-linux-gnu
436816439916
436916440016
437016440116
440240
440340
437116440416
437216440516
440640
440740
437316440816
437416440916
4375544105
...@@ -5632,6 +5667,7 @@ s390x-linux-gnu...@@ -5632,6 +5667,7 @@ s390x-linux-gnu
5632556675
5633556685
5634556695
567040
5635556715
5636556725
5637556735
...@@ -5752,6 +5788,7 @@ s390x-linux-gnu...@@ -5752,6 +5788,7 @@ s390x-linux-gnu
5752557885
5753557895
5754557905
579140
5755557925
5756557935
5757557945
...@@ -6425,6 +6462,7 @@ s390x-linux-gnu...@@ -6425,6 +6462,7 @@ s390x-linux-gnu
6425564625
6426564635
64275 1364645 13
646540
64285 1364665 13
64295 1364675 13
64305 1364685 13
...@@ -6453,6 +6491,7 @@ s390x-linux-gnu...@@ -6453,6 +6491,7 @@ s390x-linux-gnu
6453564915
6454564925
6455564935
649440
645624649524
645716649616
6458564975
...@@ -6480,6 +6519,8 @@ s390x-linux-gnu...@@ -6480,6 +6519,8 @@ s390x-linux-gnu
648016651916
6481565205
6482565215
652240
652340
6483565245
6484565255
6485565265
...@@ -6706,6 +6747,7 @@ s390x-linux-gnu...@@ -6706,6 +6747,7 @@ s390x-linux-gnu
6706567475
6707567485
6708567495
675040
6709567515
6710567525
6711567535
...@@ -7074,6 +7116,7 @@ s390x-linux-gnu...@@ -7074,6 +7116,7 @@ s390x-linux-gnu
707437711637
707537711737
70765 1671185 16
711940
707738712038
707838712138
707938712238
...@@ -7147,6 +7190,7 @@ s390x-linux-gnu...@@ -7147,6 +7190,7 @@ s390x-linux-gnu
7147571905
7148571915
7149571925
719340
7150571945
7151571955
7152571965
...@@ -7922,6 +7966,7 @@ arm-linux-gnueabi armeb-linux-gnueabi arm-linux-gnueabihf armeb-linux-gnueabihf...@@ -7922,6 +7966,7 @@ arm-linux-gnueabi armeb-linux-gnueabi arm-linux-gnueabihf armeb-linux-gnueabihf
792216796616
792316796716
792416796816
7969
792527797027
79267971
792727797227
...@@ -8063,6 +8108,18 @@ arm-linux-gnueabi armeb-linux-gnueabi arm-linux-gnueabihf armeb-linux-gnueabihf...@@ -8063,6 +8108,18 @@ arm-linux-gnueabi armeb-linux-gnueabi arm-linux-gnueabihf armeb-linux-gnueabihf
80638108
80648109
80658110
8111
8112
8113
8114
8115
8116
8117
8118
8119
8120
8121
8122
80668123
80678124
80688125
...@@ -9336,6 +9393,7 @@ arm-linux-gnueabi armeb-linux-gnueabi arm-linux-gnueabihf armeb-linux-gnueabihf...@@ -9336,6 +9393,7 @@ arm-linux-gnueabi armeb-linux-gnueabi arm-linux-gnueabihf armeb-linux-gnueabihf
933616939316
933716939416
933816939516
939640
933916939716
934016939816
934116939916
...@@ -9456,6 +9514,7 @@ arm-linux-gnueabi armeb-linux-gnueabi arm-linux-gnueabihf armeb-linux-gnueabihf...@@ -9456,6 +9514,7 @@ arm-linux-gnueabi armeb-linux-gnueabi arm-linux-gnueabihf armeb-linux-gnueabihf
945616951416
945716951516
945816951616
951740
945916951816
946016951916
946116952016
...@@ -10129,6 +10188,7 @@ arm-linux-gnueabi armeb-linux-gnueabi arm-linux-gnueabihf armeb-linux-gnueabihf...@@ -10129,6 +10188,7 @@ arm-linux-gnueabi armeb-linux-gnueabi arm-linux-gnueabihf armeb-linux-gnueabihf
10129161018816
10130161018916
10131161019016
1019140
10132161019216
10133161019316
10134161019416
...@@ -10157,6 +10217,7 @@ arm-linux-gnueabi armeb-linux-gnueabi arm-linux-gnueabihf armeb-linux-gnueabihf...@@ -10157,6 +10217,7 @@ arm-linux-gnueabi armeb-linux-gnueabi arm-linux-gnueabihf armeb-linux-gnueabihf
10157161021716
10158161021816
10159161021916
1022040
10160241022124
10161161022216
10162161022316
...@@ -10184,6 +10245,8 @@ arm-linux-gnueabi armeb-linux-gnueabi arm-linux-gnueabihf armeb-linux-gnueabihf...@@ -10184,6 +10245,8 @@ arm-linux-gnueabi armeb-linux-gnueabi arm-linux-gnueabihf armeb-linux-gnueabihf
10184161024516
10185161024616
10186161024716
1024840
1024940
10187161025016
10188161025116
10189161025216
...@@ -10410,6 +10473,7 @@ arm-linux-gnueabi armeb-linux-gnueabi arm-linux-gnueabihf armeb-linux-gnueabihf...@@ -10410,6 +10473,7 @@ arm-linux-gnueabi armeb-linux-gnueabi arm-linux-gnueabihf armeb-linux-gnueabihf
10410161047316
10411161047416
10412161047516
1047640
10413161047716
10414161047816
10415161047916
...@@ -10778,6 +10842,7 @@ arm-linux-gnueabi armeb-linux-gnueabi arm-linux-gnueabihf armeb-linux-gnueabihf...@@ -10778,6 +10842,7 @@ arm-linux-gnueabi armeb-linux-gnueabi arm-linux-gnueabihf armeb-linux-gnueabihf
10778371084237
1077910843
10780161084416
1084540
10781381084638
10782381084738
10783381084838
...@@ -10851,6 +10916,7 @@ arm-linux-gnueabi armeb-linux-gnueabi arm-linux-gnueabihf armeb-linux-gnueabihf...@@ -10851,6 +10916,7 @@ arm-linux-gnueabi armeb-linux-gnueabi arm-linux-gnueabihf armeb-linux-gnueabihf
10851161091616
10852161091716
10853161091816
1091940
10854161092016
10855161092116
10856161092216
...@@ -11626,6 +11692,7 @@ sparc-linux-gnu sparcel-linux-gnu...@@ -11626,6 +11692,7 @@ sparc-linux-gnu sparcel-linux-gnu
116261116921
116270116930
116280116940
116953
11629271169627
1163011697
11631271169827
...@@ -11738,12 +11805,18 @@ sparc-linux-gnu sparcel-linux-gnu...@@ -11738,12 +11805,18 @@ sparc-linux-gnu sparcel-linux-gnu
11738161180516
11739161180616
11740161180716
1180840
1180940
11741161181016
11742381181138
11743381181238
11744381181338
11745161181416
11746381181538
1181640
1181740
1181840
1181940
11747161182016
11748161182116
11749161182216
...@@ -11764,6 +11837,8 @@ sparc-linux-gnu sparcel-linux-gnu...@@ -11764,6 +11837,8 @@ sparc-linux-gnu sparcel-linux-gnu
11764161183716
11765161183816
11766161183916
1184040
1184140
11767161184216
11768161184316
11769161184416
...@@ -11776,8 +11851,12 @@ sparc-linux-gnu sparcel-linux-gnu...@@ -11776,8 +11851,12 @@ sparc-linux-gnu sparcel-linux-gnu
11776161185116
11777161185216
11778161185316
1185440
1185540
11779161185616
11780161185716
1185840
1185940
11781161186016
11782161186116
117830118620
...@@ -13040,6 +13119,7 @@ sparc-linux-gnu sparcel-linux-gnu...@@ -13040,6 +13119,7 @@ sparc-linux-gnu sparcel-linux-gnu
130401131191
130411131201
130420131210
1312240
130430131230
130445131245
130450131250
...@@ -13160,6 +13240,7 @@ sparc-linux-gnu sparcel-linux-gnu...@@ -13160,6 +13240,7 @@ sparc-linux-gnu sparcel-linux-gnu
131600 3132400 3
131610132410
131620132420
1324340
131630132440
131640132450
131650132460
...@@ -13833,6 +13914,7 @@ sparc-linux-gnu sparcel-linux-gnu...@@ -13833,6 +13914,7 @@ sparc-linux-gnu sparcel-linux-gnu
138335139145
138340139150
138350 13139160 13
1391740
138360 13139180 13
138370 13139190 13
138380 13139200 13
...@@ -13861,6 +13943,7 @@ sparc-linux-gnu sparcel-linux-gnu...@@ -13861,6 +13943,7 @@ sparc-linux-gnu sparcel-linux-gnu
138610139430
138620139440
138630139450
1394640
13864241394724
13865161394816
138660139490
...@@ -13888,6 +13971,8 @@ sparc-linux-gnu sparcel-linux-gnu...@@ -13888,6 +13971,8 @@ sparc-linux-gnu sparcel-linux-gnu
13888161397116
138891139721
138900139730
1397440
1397540
138911139761
138921139771
138931139781
...@@ -14114,6 +14199,7 @@ sparc-linux-gnu sparcel-linux-gnu...@@ -14114,6 +14199,7 @@ sparc-linux-gnu sparcel-linux-gnu
141140141990
141150142000
141160142010
1420240
141172142032
141180 1142040 1
141190 1142050 1
...@@ -14482,6 +14568,7 @@ sparc-linux-gnu sparcel-linux-gnu...@@ -14482,6 +14568,7 @@ sparc-linux-gnu sparcel-linux-gnu
14482371456837
14483371456937
144841 16145701 16
1457140
14485381457238
14486381457338
14487381457438
...@@ -14555,6 +14642,7 @@ sparc-linux-gnu sparcel-linux-gnu...@@ -14555,6 +14642,7 @@ sparc-linux-gnu sparcel-linux-gnu
145550146420
145560146430
145570146440
1464540
145580146460
145590146470
145600146480
...@@ -15330,6 +15418,7 @@ sparcv9-linux-gnu...@@ -15330,6 +15418,7 @@ sparcv9-linux-gnu
153305154185
153315154195
153325154205
15421
15333271542227
1533415423
15335271542427
...@@ -15471,6 +15560,18 @@ sparcv9-linux-gnu...@@ -15471,6 +15560,18 @@ sparcv9-linux-gnu
1547115560
1547215561
1547315562
15563
15564
15565
15566
15567
15568
15569
15570
15571
15572
15573
15574
1547415575
1547515576
1547615577
...@@ -16744,6 +16845,7 @@ sparcv9-linux-gnu...@@ -16744,6 +16845,7 @@ sparcv9-linux-gnu
167445168455
167455168465
167465168475
1684840
167475168495
167485168505
167495168515
...@@ -16864,6 +16966,7 @@ sparcv9-linux-gnu...@@ -16864,6 +16966,7 @@ sparcv9-linux-gnu
168645169665
168655169675
168665169685
1696940
168675169705
168685169715
168695169725
...@@ -17537,6 +17640,7 @@ sparcv9-linux-gnu...@@ -17537,6 +17640,7 @@ sparcv9-linux-gnu
175375176405
175385176415
175395 13176425 13
1764340
175405 13176445 13
175415 13176455 13
175425 13176465 13
...@@ -17565,6 +17669,7 @@ sparcv9-linux-gnu...@@ -17565,6 +17669,7 @@ sparcv9-linux-gnu
175655176695
175665176705
175675176715
1767240
17568241767324
17569161767416
175705176755
...@@ -17592,6 +17697,8 @@ sparcv9-linux-gnu...@@ -17592,6 +17697,8 @@ sparcv9-linux-gnu
17592161769716
175935176985
175945176995
1770040
1770140
175955177025
175965177035
175975177045
...@@ -17818,6 +17925,7 @@ sparcv9-linux-gnu...@@ -17818,6 +17925,7 @@ sparcv9-linux-gnu
178185179255
178195179265
178205179275
1792840
178215179295
178225179305
178235179315
...@@ -18186,6 +18294,7 @@ sparcv9-linux-gnu...@@ -18186,6 +18294,7 @@ sparcv9-linux-gnu
18186371829437
18187371829537
181885182965
1829740
18189381829838
18190381829938
18191381830038
...@@ -18259,6 +18368,7 @@ sparcv9-linux-gnu...@@ -18259,6 +18368,7 @@ sparcv9-linux-gnu
182595183685
182605183695
182615183705
1837140
182625183725
182635183735
182645183745
...@@ -19034,6 +19144,7 @@ mips64el-linux-gnuabi64 mips64-linux-gnuabi64...@@ -19034,6 +19144,7 @@ mips64el-linux-gnuabi64 mips64-linux-gnuabi64
190345191445
190350191450
190360191460
19147
19037271914827
1903819149
19039271915027
...@@ -19175,6 +19286,18 @@ mips64el-linux-gnuabi64 mips64-linux-gnuabi64...@@ -19175,6 +19286,18 @@ mips64el-linux-gnuabi64 mips64-linux-gnuabi64
1917519286
1917619287
1917719288
19289
19290
19291
19292
19293
19294
19295
19296
19297
19298
19299
19300
1917819301
1917919302
1918019303
...@@ -20448,6 +20571,7 @@ mips64el-linux-gnuabi64 mips64-linux-gnuabi64...@@ -20448,6 +20571,7 @@ mips64el-linux-gnuabi64 mips64-linux-gnuabi64
204485205715
204495205725
204500205730
2057440
204510205750
204525205765
204530205770
...@@ -20568,6 +20692,7 @@ mips64el-linux-gnuabi64 mips64-linux-gnuabi64...@@ -20568,6 +20692,7 @@ mips64el-linux-gnuabi64 mips64-linux-gnuabi64
205680 5206920 5
205690206930
205700206940
2069540
205710206960
205720206970
205730206980
...@@ -21241,6 +21366,7 @@ mips64el-linux-gnuabi64 mips64-linux-gnuabi64...@@ -21241,6 +21366,7 @@ mips64el-linux-gnuabi64 mips64-linux-gnuabi64
212415213665
212420213670
212430 13213680 13
2136940
212440 13213700 13
212450 13213710 13
212460 13213720 13
...@@ -21269,6 +21395,7 @@ mips64el-linux-gnuabi64 mips64-linux-gnuabi64...@@ -21269,6 +21395,7 @@ mips64el-linux-gnuabi64 mips64-linux-gnuabi64
212690213950
212700213960
212710213970
2139840
21272242139924
21273162140016
212740214010
...@@ -21296,6 +21423,8 @@ mips64el-linux-gnuabi64 mips64-linux-gnuabi64...@@ -21296,6 +21423,8 @@ mips64el-linux-gnuabi64 mips64-linux-gnuabi64
21296162142316
212975214245
212980214250
2142640
2142740
212995214285
213005214295
213015214305
...@@ -21522,6 +21651,7 @@ mips64el-linux-gnuabi64 mips64-linux-gnuabi64...@@ -21522,6 +21651,7 @@ mips64el-linux-gnuabi64 mips64-linux-gnuabi64
215220216510
215230216520
215240216530
2165440
215255216555
215260 5216560 5
215270 5216570 5
...@@ -21890,6 +22020,7 @@ mips64el-linux-gnuabi64 mips64-linux-gnuabi64...@@ -21890,6 +22020,7 @@ mips64el-linux-gnuabi64 mips64-linux-gnuabi64
21890372202037
21891372202137
218925220225
2202340
21893382202438
21894382202538
21895382202638
...@@ -21963,6 +22094,7 @@ mips64el-linux-gnuabi64 mips64-linux-gnuabi64...@@ -21963,6 +22094,7 @@ mips64el-linux-gnuabi64 mips64-linux-gnuabi64
219630220940
219640220950
219650220960
2209740
219660220980
219670220990
219680221000
...@@ -22738,6 +22870,7 @@ mips64el-linux-gnuabin32 mips64-linux-gnuabin32...@@ -22738,6 +22870,7 @@ mips64el-linux-gnuabin32 mips64-linux-gnuabin32
227385228705
227390228710
227400228720
22873
22741272287427
2274222875
22743272287627
...@@ -22879,6 +23012,18 @@ mips64el-linux-gnuabin32 mips64-linux-gnuabin32...@@ -22879,6 +23012,18 @@ mips64el-linux-gnuabin32 mips64-linux-gnuabin32
2287923012
2288023013
2288123014
23015
23016
23017
23018
23019
23020
23021
23022
23023
23024
23025
23026
2288223027
2288323028
2288423029
...@@ -24152,6 +24297,7 @@ mips64el-linux-gnuabin32 mips64-linux-gnuabin32...@@ -24152,6 +24297,7 @@ mips64el-linux-gnuabin32 mips64-linux-gnuabin32
241525242975
241535242985
241540242990
2430040
241550243010
241565243025
241570243030
...@@ -24272,6 +24418,7 @@ mips64el-linux-gnuabin32 mips64-linux-gnuabin32...@@ -24272,6 +24418,7 @@ mips64el-linux-gnuabin32 mips64-linux-gnuabin32
242720 5244180 5
242730244190
242740244200
2442140
242750244220
242760244230
242770244240
...@@ -24945,6 +25092,7 @@ mips64el-linux-gnuabin32 mips64-linux-gnuabin32...@@ -24945,6 +25092,7 @@ mips64el-linux-gnuabin32 mips64-linux-gnuabin32
249455250925
249460250930
249470 13250940 13
2509540
249480 13250960 13
249490 13250970 13
249500 13250980 13
...@@ -24973,6 +25121,7 @@ mips64el-linux-gnuabin32 mips64-linux-gnuabin32...@@ -24973,6 +25121,7 @@ mips64el-linux-gnuabin32 mips64-linux-gnuabin32
249730251210
249740251220
249750251230
2512440
24976242512524
24977162512616
249780251270
...@@ -25000,6 +25149,8 @@ mips64el-linux-gnuabin32 mips64-linux-gnuabin32...@@ -25000,6 +25149,8 @@ mips64el-linux-gnuabin32 mips64-linux-gnuabin32
25000162514916
250015251505
250020251510
2515240
2515340
250035251545
250045251555
250055251565
...@@ -25226,6 +25377,7 @@ mips64el-linux-gnuabin32 mips64-linux-gnuabin32...@@ -25226,6 +25377,7 @@ mips64el-linux-gnuabin32 mips64-linux-gnuabin32
252260253770
252270253780
252280253790
2538040
252295253815
252300 5253820 5
252310 5253830 5
...@@ -25594,6 +25746,7 @@ mips64el-linux-gnuabin32 mips64-linux-gnuabin32...@@ -25594,6 +25746,7 @@ mips64el-linux-gnuabin32 mips64-linux-gnuabin32
25594372574637
25595372574737
255965257485
2574940
25597382575038
25598382575138
25599382575238
...@@ -25667,6 +25820,7 @@ mips64el-linux-gnuabin32 mips64-linux-gnuabin32...@@ -25667,6 +25820,7 @@ mips64el-linux-gnuabin32 mips64-linux-gnuabin32
256670258200
256680258210
256690258220
2582340
256700258240
256710258250
256720258260
...@@ -26442,6 +26596,7 @@ mipsel-linux-gnueabihf mips-linux-gnueabihf...@@ -26442,6 +26596,7 @@ mipsel-linux-gnueabihf mips-linux-gnueabihf
264425265965
264430265970
264440265980
26599
26445272660027
2644626601
26447272660227
...@@ -26583,6 +26738,18 @@ mipsel-linux-gnueabihf mips-linux-gnueabihf...@@ -26583,6 +26738,18 @@ mipsel-linux-gnueabihf mips-linux-gnueabihf
2658326738
2658426739
2658526740
26741
26742
26743
26744
26745
26746
26747
26748
26749
26750
26751
26752
2658626753
2658726754
2658826755
...@@ -27856,6 +28023,7 @@ mipsel-linux-gnueabihf mips-linux-gnueabihf...@@ -27856,6 +28023,7 @@ mipsel-linux-gnueabihf mips-linux-gnueabihf
278565280235
278575280245
278580280250
2802640
278590280270
278605280285
278610280290
...@@ -27976,6 +28144,7 @@ mipsel-linux-gnueabihf mips-linux-gnueabihf...@@ -27976,6 +28144,7 @@ mipsel-linux-gnueabihf mips-linux-gnueabihf
279760 5281440 5
279770281450
279780281460
2814740
279790281480
279800281490
279810281500
...@@ -28649,6 +28818,7 @@ mipsel-linux-gnueabihf mips-linux-gnueabihf...@@ -28649,6 +28818,7 @@ mipsel-linux-gnueabihf mips-linux-gnueabihf
286495288185
286500288190
286510 13288200 13
2882140
286520 13288220 13
286530 13288230 13
286540 13288240 13
...@@ -28677,6 +28847,7 @@ mipsel-linux-gnueabihf mips-linux-gnueabihf...@@ -28677,6 +28847,7 @@ mipsel-linux-gnueabihf mips-linux-gnueabihf
286770288470
286780288480
286790288490
2885040
28680242885124
28681162885216
286820288530
...@@ -28704,6 +28875,8 @@ mipsel-linux-gnueabihf mips-linux-gnueabihf...@@ -28704,6 +28875,8 @@ mipsel-linux-gnueabihf mips-linux-gnueabihf
28704162887516
287055288765
287060288770
2887840
2887940
287075288805
287085288815
287095288825
...@@ -28930,6 +29103,7 @@ mipsel-linux-gnueabihf mips-linux-gnueabihf...@@ -28930,6 +29103,7 @@ mipsel-linux-gnueabihf mips-linux-gnueabihf
289300291030
289310291040
289320291050
2910640
289335291075
289340 5291080 5
289350 5291090 5
...@@ -29298,6 +29472,7 @@ mipsel-linux-gnueabihf mips-linux-gnueabihf...@@ -29298,6 +29472,7 @@ mipsel-linux-gnueabihf mips-linux-gnueabihf
29298372947237
2929929473
293005294745
2947540
29301382947638
29302382947738
29303382947838
...@@ -29371,6 +29546,7 @@ mipsel-linux-gnueabihf mips-linux-gnueabihf...@@ -29371,6 +29546,7 @@ mipsel-linux-gnueabihf mips-linux-gnueabihf
293710295460
293720295470
293730295480
2954940
293740295500
293750295510
293760295520
...@@ -30146,6 +30322,7 @@ mipsel-linux-gnueabi mips-linux-gnueabi...@@ -30146,6 +30322,7 @@ mipsel-linux-gnueabi mips-linux-gnueabi
301465303225
301470303230
301480303240
30325
30149273032627
3015030327
30151273032827
...@@ -30287,6 +30464,18 @@ mipsel-linux-gnueabi mips-linux-gnueabi...@@ -30287,6 +30464,18 @@ mipsel-linux-gnueabi mips-linux-gnueabi
3028730464
3028830465
3028930466
30467
30468
30469
30470
30471
30472
30473
30474
30475
30476
30477
30478
3029030479
3029130480
3029230481
...@@ -31560,6 +31749,7 @@ mipsel-linux-gnueabi mips-linux-gnueabi...@@ -31560,6 +31749,7 @@ mipsel-linux-gnueabi mips-linux-gnueabi
315605317495
315615317505
315620317510
3175240
315630317530
315645317545
315650317550
...@@ -31680,6 +31870,7 @@ mipsel-linux-gnueabi mips-linux-gnueabi...@@ -31680,6 +31870,7 @@ mipsel-linux-gnueabi mips-linux-gnueabi
316800 5318700 5
316810318710
316820318720
3187340
316830318740
316840318750
316850318760
...@@ -32353,6 +32544,7 @@ mipsel-linux-gnueabi mips-linux-gnueabi...@@ -32353,6 +32544,7 @@ mipsel-linux-gnueabi mips-linux-gnueabi
323535325445
323540325450
323550 13325460 13
3254740
323560 13325480 13
323570 13325490 13
323580 13325500 13
...@@ -32381,6 +32573,7 @@ mipsel-linux-gnueabi mips-linux-gnueabi...@@ -32381,6 +32573,7 @@ mipsel-linux-gnueabi mips-linux-gnueabi
323810325730
323820325740
323830325750
3257640
32384243257724
32385163257816
323860325790
...@@ -32408,6 +32601,8 @@ mipsel-linux-gnueabi mips-linux-gnueabi...@@ -32408,6 +32601,8 @@ mipsel-linux-gnueabi mips-linux-gnueabi
32408163260116
324095326025
324100326030
3260440
3260540
324115326065
324125326075
324135326085
...@@ -32634,6 +32829,7 @@ mipsel-linux-gnueabi mips-linux-gnueabi...@@ -32634,6 +32829,7 @@ mipsel-linux-gnueabi mips-linux-gnueabi
326340328290
326350328300
326360328310
3283240
326375328335
326380 5328340 5
326390 5328350 5
...@@ -33002,6 +33198,7 @@ mipsel-linux-gnueabi mips-linux-gnueabi...@@ -33002,6 +33198,7 @@ mipsel-linux-gnueabi mips-linux-gnueabi
33002373319837
3300333199
330045332005
3320140
33005383320238
33006383320338
33007383320438
...@@ -33075,6 +33272,7 @@ mipsel-linux-gnueabi mips-linux-gnueabi...@@ -33075,6 +33272,7 @@ mipsel-linux-gnueabi mips-linux-gnueabi
330750332720
330760332730
330770332740
3327540
330780332760
330790332770
330800332780
...@@ -33850,6 +34048,7 @@ x86_64-linux-gnu...@@ -33850,6 +34048,7 @@ x86_64-linux-gnu
33850103404810
33851103404910
33852103405010
34051
33853273405227
33854363405336
33855273405427
...@@ -33991,6 +34190,18 @@ x86_64-linux-gnu...@@ -33991,6 +34190,18 @@ x86_64-linux-gnu
3399134190
3399234191
3399334192
34193
34194
34195
34196
34197
34198
34199
34200
34201
34202
34203
34204
3399434205
3399534206
3399634207
...@@ -35264,6 +35475,7 @@ x86_64-linux-gnu...@@ -35264,6 +35475,7 @@ x86_64-linux-gnu
35264103547510
35265103547610
35266103547710
3547840
35267103547910
35268103548010
35269103548110
...@@ -35384,6 +35596,7 @@ x86_64-linux-gnu...@@ -35384,6 +35596,7 @@ x86_64-linux-gnu
35384103559610
35385103559710
35386103559810
3559940
35387103560010
35388103560110
35389103560210
...@@ -36057,6 +36270,7 @@ x86_64-linux-gnu...@@ -36057,6 +36270,7 @@ x86_64-linux-gnu
36057103627010
36058103627110
3605910 133627210 13
3627340
3606010 133627410 13
3606110 133627510 13
3606210 133627610 13
...@@ -36085,6 +36299,7 @@ x86_64-linux-gnu...@@ -36085,6 +36299,7 @@ x86_64-linux-gnu
36085103629910
36086103630010
36087103630110
3630240
36088243630324
36089163630416
36090103630510
...@@ -36112,6 +36327,8 @@ x86_64-linux-gnu...@@ -36112,6 +36327,8 @@ x86_64-linux-gnu
36112163632716
36113103632810
36114103632910
3633040
3633140
36115103633210
36116103633310
36117103633410
...@@ -36338,6 +36555,7 @@ x86_64-linux-gnu...@@ -36338,6 +36555,7 @@ x86_64-linux-gnu
36338103655510
36339103655610
36340103655710
3655840
36341103655910
36342103656010
36343103656110
...@@ -36706,6 +36924,7 @@ x86_64-linux-gnu...@@ -36706,6 +36924,7 @@ x86_64-linux-gnu
36706373692437
36707373692537
36708103692610
3692740
36709383692838
36710383692938
36711383693038
...@@ -36779,6 +36998,7 @@ x86_64-linux-gnu...@@ -36779,6 +36998,7 @@ x86_64-linux-gnu
36779103699810
36780103699910
36781103700010
3700140
36782103700210
36783103700310
36784103700410
...@@ -37554,6 +37774,7 @@ x86_64-linux-gnux32...@@ -37554,6 +37774,7 @@ x86_64-linux-gnux32
37554283777428
37555283777528
37556283777628
37777
37557283777828
37558363777936
37559283778028
...@@ -37695,6 +37916,18 @@ x86_64-linux-gnux32...@@ -37695,6 +37916,18 @@ x86_64-linux-gnux32
3769537916
3769637917
3769737918
37919
37920
37921
37922
37923
37924
37925
37926
37927
37928
37929
37930
3769837931
3769937932
3770037933
...@@ -38968,6 +39201,7 @@ x86_64-linux-gnux32...@@ -38968,6 +39201,7 @@ x86_64-linux-gnux32
38968283920128
38969283920228
38970283920328
3920440
38971283920528
38972283920628
38973283920728
...@@ -39088,6 +39322,7 @@ x86_64-linux-gnux32...@@ -39088,6 +39322,7 @@ x86_64-linux-gnux32
39088283932228
39089283932328
39090283932428
3932540
39091283932628
39092283932728
39093283932828
...@@ -39761,6 +39996,7 @@ x86_64-linux-gnux32...@@ -39761,6 +39996,7 @@ x86_64-linux-gnux32
39761283999628
39762283999728
39763283999828
3999940
39764284000028
39765284000128
39766284000228
...@@ -39789,6 +40025,7 @@ x86_64-linux-gnux32...@@ -39789,6 +40025,7 @@ x86_64-linux-gnux32
39789284002528
39790284002628
39791284002728
4002840
39792284002928
39793284003028
39794284003128
...@@ -39816,6 +40053,8 @@ x86_64-linux-gnux32...@@ -39816,6 +40053,8 @@ x86_64-linux-gnux32
39816284005328
39817284005428
39818284005528
4005640
4005740
39819284005828
39820284005928
39821284006028
...@@ -40042,6 +40281,7 @@ x86_64-linux-gnux32...@@ -40042,6 +40281,7 @@ x86_64-linux-gnux32
40042284028128
40043284028228
40044284028328
4028440
40045284028528
40046284028628
40047284028728
...@@ -40410,6 +40650,7 @@ x86_64-linux-gnux32...@@ -40410,6 +40650,7 @@ x86_64-linux-gnux32
40410374065037
40411374065137
40412284065228
4065340
40413384065438
40414384065538
40415384065638
...@@ -40483,6 +40724,7 @@ x86_64-linux-gnux32...@@ -40483,6 +40724,7 @@ x86_64-linux-gnux32
40483284072428
40484284072528
40485284072628
4072740
40486284072828
40487284072928
40488284073028
...@@ -41258,6 +41500,7 @@ i386-linux-gnu...@@ -41258,6 +41500,7 @@ i386-linux-gnu
412581415001
412590415010
412600415020
415033
41261274150427
41262364150536
41263274150627
...@@ -41399,6 +41642,18 @@ i386-linux-gnu...@@ -41399,6 +41642,18 @@ i386-linux-gnu
4139941642
4140041643
4140141644
41645
41646
41647
41648
41649
41650
41651
41652
41653
41654
41655
41656
4140241657
4140341658
4140441659
...@@ -42672,6 +42927,7 @@ i386-linux-gnu...@@ -42672,6 +42927,7 @@ i386-linux-gnu
426721429271
426731429281
426740429290
4293040
426750429310
426765429325
426770429330
...@@ -42792,6 +43048,7 @@ i386-linux-gnu...@@ -42792,6 +43048,7 @@ i386-linux-gnu
427920 3430480 3
427930430490
427940430500
4305140
427950430520
427960430530
427970430540
...@@ -43465,6 +43722,7 @@ i386-linux-gnu...@@ -43465,6 +43722,7 @@ i386-linux-gnu
434655437225
434660437230
434670 13437240 13
4372540
434680 13437260 13
434690 13437270 13
434700 13437280 13
...@@ -43493,6 +43751,7 @@ i386-linux-gnu...@@ -43493,6 +43751,7 @@ i386-linux-gnu
434930437510
434940437520
434950437530
4375440
43496244375524
43497164375616
434980437570
...@@ -43520,6 +43779,8 @@ i386-linux-gnu...@@ -43520,6 +43779,8 @@ i386-linux-gnu
43520164377916
435211437801
435220437810
4378240
4378340
435231437841
435241437851
435251437861
...@@ -43746,6 +44007,7 @@ i386-linux-gnu...@@ -43746,6 +44007,7 @@ i386-linux-gnu
437460440070
437470440080
437480440090
4401040
437492440112
437500 1440120 1
437510 1440130 1
...@@ -44114,6 +44376,7 @@ i386-linux-gnu...@@ -44114,6 +44376,7 @@ i386-linux-gnu
44114374437637
44115374437737
441161443781
4437940
44117384438038
44118384438138
44119384438238
...@@ -44187,6 +44450,7 @@ i386-linux-gnu...@@ -44187,6 +44450,7 @@ i386-linux-gnu
441870444500
441880444510
441890444520
4445340
441900444540
441910444550
441920444560
...@@ -44962,6 +45226,7 @@ powerpc64le-linux-gnu...@@ -44962,6 +45226,7 @@ powerpc64le-linux-gnu
44962294522629
44963294522729
44964294522829
45229
44965294523029
44966364523136
44967294523229
...@@ -45074,12 +45339,18 @@ powerpc64le-linux-gnu...@@ -45074,12 +45339,18 @@ powerpc64le-linux-gnu
45074294533929
45075294534029
45076294534129
4534240
4534340
45077294534429
45078384534538
45079384534638
45080384534738
45081294534829
45082384534938
4535040
4535140
4535240
4535340
45083294535429
45084294535529
45085294535629
...@@ -45100,6 +45371,8 @@ powerpc64le-linux-gnu...@@ -45100,6 +45371,8 @@ powerpc64le-linux-gnu
45100294537129
45101294537229
45102294537329
4537440
4537540
45103294537629
45104294537729
45105294537829
...@@ -45112,8 +45385,12 @@ powerpc64le-linux-gnu...@@ -45112,8 +45385,12 @@ powerpc64le-linux-gnu
45112294538529
45113294538629
45114294538729
4538840
4538940
45115294539029
45116294539129
4539240
4539340
45117294539429
45118294539529
45119294539629
...@@ -46376,6 +46653,7 @@ powerpc64le-linux-gnu...@@ -46376,6 +46653,7 @@ powerpc64le-linux-gnu
46376294665329
46377294665429
46378294665529
4665640
46379294665729
46380294665829
46381294665929
...@@ -46496,6 +46774,7 @@ powerpc64le-linux-gnu...@@ -46496,6 +46774,7 @@ powerpc64le-linux-gnu
46496294677429
46497294677529
46498294677629
4677740
46499294677829
46500294677929
46501294678029
...@@ -47169,6 +47448,7 @@ powerpc64le-linux-gnu...@@ -47169,6 +47448,7 @@ powerpc64le-linux-gnu
47169294744829
47170294744929
47171294745029
4745140
47172294745229
47173294745329
47174294745429
...@@ -47197,6 +47477,7 @@ powerpc64le-linux-gnu...@@ -47197,6 +47477,7 @@ powerpc64le-linux-gnu
47197294747729
47198294747829
47199294747929
4748040
47200294748129
47201294748229
47202294748329
...@@ -47224,6 +47505,8 @@ powerpc64le-linux-gnu...@@ -47224,6 +47505,8 @@ powerpc64le-linux-gnu
47224294750529
47225294750629
47226294750729
4750840
4750940
47227294751029
47228294751129
47229294751229
...@@ -47450,6 +47733,7 @@ powerpc64le-linux-gnu...@@ -47450,6 +47733,7 @@ powerpc64le-linux-gnu
47450294773329
47451294773429
47452294773529
4773640
47453294773729
47454294773829
47455294773929
...@@ -47818,6 +48102,7 @@ powerpc64le-linux-gnu...@@ -47818,6 +48102,7 @@ powerpc64le-linux-gnu
47818374810237
47819374810337
47820294810429
4810540
47821384810638
47822384810738
47823384810838
...@@ -47891,6 +48176,7 @@ powerpc64le-linux-gnu...@@ -47891,6 +48176,7 @@ powerpc64le-linux-gnu
47891294817629
47892294817729
47893294817829
4817940
47894294818029
47895294818129
47896294818229
...@@ -48666,6 +48952,7 @@ powerpc64-linux-gnu...@@ -48666,6 +48952,7 @@ powerpc64-linux-gnu
48666124895212
48667124895312
48668124895412
48955
48669274895627
4867048957
48671274895827
...@@ -48778,12 +49065,18 @@ powerpc64-linux-gnu...@@ -48778,12 +49065,18 @@ powerpc64-linux-gnu
48778164906516
48779164906616
48780164906716
4906840
4906940
48781164907016
48782384907138
48783384907238
48784384907338
48785164907416
48786384907538
4907640
4907740
4907840
4907940
48787164908016
48788164908116
48789164908216
...@@ -48804,6 +49097,8 @@ powerpc64-linux-gnu...@@ -48804,6 +49097,8 @@ powerpc64-linux-gnu
48804164909716
48805164909816
48806164909916
4910040
4910140
48807164910216
48808164910316
48809164910416
...@@ -48816,8 +49111,12 @@ powerpc64-linux-gnu...@@ -48816,8 +49111,12 @@ powerpc64-linux-gnu
48816164911116
48817164911216
48818164911316
4911440
4911540
48819164911616
48820164911716
4911840
4911940
48821164912016
48822164912116
48823124912212
...@@ -50080,6 +50379,7 @@ powerpc64-linux-gnu...@@ -50080,6 +50379,7 @@ powerpc64-linux-gnu
50080125037912
50081125038012
50082125038112
5038240
50083125038312
50084125038412
50085125038512
...@@ -50200,6 +50500,7 @@ powerpc64-linux-gnu...@@ -50200,6 +50500,7 @@ powerpc64-linux-gnu
50200125050012
50201125050112
50202125050212
5050340
50203125050412
50204125050512
50205125050612
...@@ -50873,6 +51174,7 @@ powerpc64-linux-gnu...@@ -50873,6 +51174,7 @@ powerpc64-linux-gnu
50873125117412
50874125117512
5087512 135117612 13
5117740
5087612 135117812 13
5087712 135117912 13
5087812 135118012 13
...@@ -50901,6 +51203,7 @@ powerpc64-linux-gnu...@@ -50901,6 +51203,7 @@ powerpc64-linux-gnu
50901125120312
50902125120412
50903125120512
5120640
50904245120724
50905165120816
50906125120912
...@@ -50928,6 +51231,8 @@ powerpc64-linux-gnu...@@ -50928,6 +51231,8 @@ powerpc64-linux-gnu
50928165123116
50929125123212
50930125123312
5123440
5123540
50931125123612
50932125123712
50933125123812
...@@ -51154,6 +51459,7 @@ powerpc64-linux-gnu...@@ -51154,6 +51459,7 @@ powerpc64-linux-gnu
51154125145912
51155125146012
51156125146112
5146240
51157125146312
51158125146412
51159125146512
...@@ -51522,6 +51828,7 @@ powerpc64-linux-gnu...@@ -51522,6 +51828,7 @@ powerpc64-linux-gnu
51522375182837
5152351829
5152412 165183012 16
5183140
51525385183238
51526385183338
51527385183438
...@@ -51595,6 +51902,7 @@ powerpc64-linux-gnu...@@ -51595,6 +51902,7 @@ powerpc64-linux-gnu
51595125190212
51596125190312
51597125190412
5190540
51598125190612
51599125190712
51600125190812
...@@ -52370,6 +52678,7 @@ powerpc-linux-gnueabi powerpc-linux-gnueabihf...@@ -52370,6 +52678,7 @@ powerpc-linux-gnueabi powerpc-linux-gnueabihf
523701526781
523710526790
523720526800
526813
52373275268227
5237452683
52375275268427
...@@ -52482,12 +52791,18 @@ powerpc-linux-gnueabi powerpc-linux-gnueabihf...@@ -52482,12 +52791,18 @@ powerpc-linux-gnueabi powerpc-linux-gnueabihf
52482165279116
52483165279216
52484165279316
5279440
5279540
52485165279616
52486385279738
52487385279838
52488385279938
52489165280016
52490385280138
5280240
5280340
5280440
5280540
52491165280616
52492165280716
52493165280816
...@@ -52508,6 +52823,8 @@ powerpc-linux-gnueabi powerpc-linux-gnueabihf...@@ -52508,6 +52823,8 @@ powerpc-linux-gnueabi powerpc-linux-gnueabihf
52508165282316
52509165282416
52510165282516
5282640
5282740
52511165282816
52512165282916
52513165283016
...@@ -52520,8 +52837,12 @@ powerpc-linux-gnueabi powerpc-linux-gnueabihf...@@ -52520,8 +52837,12 @@ powerpc-linux-gnueabi powerpc-linux-gnueabihf
52520165283716
52521165283816
52522165283916
5284040
5284140
52523165284216
52524165284316
5284440
5284540
52525165284616
52526165284716
525270528480
...@@ -53784,6 +54105,7 @@ powerpc-linux-gnueabi powerpc-linux-gnueabihf...@@ -53784,6 +54105,7 @@ powerpc-linux-gnueabi powerpc-linux-gnueabihf
537841541051
537851541061
537860541070
5410840
537870541090
537885541105
537890541110
...@@ -53904,6 +54226,7 @@ powerpc-linux-gnueabi powerpc-linux-gnueabihf...@@ -53904,6 +54226,7 @@ powerpc-linux-gnueabi powerpc-linux-gnueabihf
539040 3542260 3
539050542270
539060542280
5422940
539070542300
539080542310
539090542320
...@@ -54577,6 +54900,7 @@ powerpc-linux-gnueabi powerpc-linux-gnueabihf...@@ -54577,6 +54900,7 @@ powerpc-linux-gnueabi powerpc-linux-gnueabihf
545775549005
545780549010
545790 13549020 13
5490340
545800 13549040 13
545810 13549050 13
545820 13549060 13
...@@ -54605,6 +54929,7 @@ powerpc-linux-gnueabi powerpc-linux-gnueabihf...@@ -54605,6 +54929,7 @@ powerpc-linux-gnueabi powerpc-linux-gnueabihf
546050549290
546060549300
546070549310
5493240
54608245493324
54609165493416
546100549350
...@@ -54632,6 +54957,8 @@ powerpc-linux-gnueabi powerpc-linux-gnueabihf...@@ -54632,6 +54957,8 @@ powerpc-linux-gnueabi powerpc-linux-gnueabihf
54632165495716
546331549581
546340549590
5496040
5496140
546351549621
546361549631
546371549641
...@@ -54858,6 +55185,7 @@ powerpc-linux-gnueabi powerpc-linux-gnueabihf...@@ -54858,6 +55185,7 @@ powerpc-linux-gnueabi powerpc-linux-gnueabihf
548580551850
548590551860
548600551870
5518840
548612551892
548620 1551900 1
548630 1551910 1
...@@ -55226,6 +55554,7 @@ powerpc-linux-gnueabi powerpc-linux-gnueabihf...@@ -55226,6 +55554,7 @@ powerpc-linux-gnueabi powerpc-linux-gnueabihf
55226375555437
5522755555
552281 16555561 16
5555740
55229385555838
55230385555938
55231385556038
...@@ -55299,6 +55628,7 @@ powerpc-linux-gnueabi powerpc-linux-gnueabihf...@@ -55299,6 +55628,7 @@ powerpc-linux-gnueabi powerpc-linux-gnueabihf
552990556280
553000556290
553010556300
5563140
553020556320
553030556330
553040556340
lib/libc/glibc/fns.txt+22
...@@ -513,6 +513,7 @@ __libc_realloc c...@@ -513,6 +513,7 @@ __libc_realloc c
513__libc_sa_len c513__libc_sa_len c
514__libc_start_main c514__libc_start_main c
515__libc_valloc c515__libc_valloc c
516__libpthread_version_placeholder pthread
516__log10_finite m517__log10_finite m
517__log10f128_finite m518__log10f128_finite m
518__log10f_finite m519__log10f_finite m
...@@ -625,12 +626,18 @@ __nldbl___vswprintf_chk c...@@ -625,12 +626,18 @@ __nldbl___vswprintf_chk c
625__nldbl___vsyslog_chk c626__nldbl___vsyslog_chk c
626__nldbl___vwprintf_chk c627__nldbl___vwprintf_chk c
627__nldbl___wprintf_chk c628__nldbl___wprintf_chk c
629__nldbl_argp_error c
630__nldbl_argp_failure c
628__nldbl_asprintf c631__nldbl_asprintf c
629__nldbl_daddl m632__nldbl_daddl m
630__nldbl_ddivl m633__nldbl_ddivl m
631__nldbl_dmull m634__nldbl_dmull m
632__nldbl_dprintf c635__nldbl_dprintf c
633__nldbl_dsubl m636__nldbl_dsubl m
637__nldbl_err c
638__nldbl_error c
639__nldbl_error_at_line c
640__nldbl_errx c
634__nldbl_fprintf c641__nldbl_fprintf c
635__nldbl_fscanf c642__nldbl_fscanf c
636__nldbl_fwprintf c643__nldbl_fwprintf c
...@@ -651,6 +658,8 @@ __nldbl_swscanf c...@@ -651,6 +658,8 @@ __nldbl_swscanf c
651__nldbl_syslog c658__nldbl_syslog c
652__nldbl_vasprintf c659__nldbl_vasprintf c
653__nldbl_vdprintf c660__nldbl_vdprintf c
661__nldbl_verr c
662__nldbl_verrx c
654__nldbl_vfprintf c663__nldbl_vfprintf c
655__nldbl_vfscanf c664__nldbl_vfscanf c
656__nldbl_vfwprintf c665__nldbl_vfwprintf c
...@@ -663,8 +672,12 @@ __nldbl_vsscanf c...@@ -663,8 +672,12 @@ __nldbl_vsscanf c
663__nldbl_vswprintf c672__nldbl_vswprintf c
664__nldbl_vswscanf c673__nldbl_vswscanf c
665__nldbl_vsyslog c674__nldbl_vsyslog c
675__nldbl_vwarn c
676__nldbl_vwarnx c
666__nldbl_vwprintf c677__nldbl_vwprintf c
667__nldbl_vwscanf c678__nldbl_vwscanf c
679__nldbl_warn c
680__nldbl_warnx c
668__nldbl_wprintf c681__nldbl_wprintf c
669__nldbl_wscanf c682__nldbl_wscanf c
670__nss_configure_lookup c683__nss_configure_lookup c
...@@ -1927,6 +1940,7 @@ getdate c...@@ -1927,6 +1940,7 @@ getdate c
1927getdate_err c1940getdate_err c
1928getdate_r c1941getdate_r c
1929getdelim c1942getdelim c
1943getdents64 c
1930getdirentries c1944getdirentries c
1931getdirentries64 c1945getdirentries64 c
1932getdomainname c1946getdomainname c
...@@ -2047,6 +2061,7 @@ getspnam c...@@ -2047,6 +2061,7 @@ getspnam c
2047getspnam_r c2061getspnam_r c
2048getsubopt c2062getsubopt c
2049gettext c2063gettext c
2064gettid c
2050gettimeofday c2065gettimeofday c
2051getttyent c2066getttyent c
2052getttynam c2067getttynam c
...@@ -2720,6 +2735,7 @@ pthread_barrierattr_init pthread...@@ -2720,6 +2735,7 @@ pthread_barrierattr_init pthread
2720pthread_barrierattr_setpshared pthread2735pthread_barrierattr_setpshared pthread
2721pthread_cancel pthread2736pthread_cancel pthread
2722pthread_cond_broadcast c2737pthread_cond_broadcast c
2738pthread_cond_clockwait pthread
2723pthread_cond_destroy c2739pthread_cond_destroy c
2724pthread_cond_init c2740pthread_cond_init c
2725pthread_cond_signal c2741pthread_cond_signal c
...@@ -2748,6 +2764,7 @@ pthread_key_create pthread...@@ -2748,6 +2764,7 @@ pthread_key_create pthread
2748pthread_key_delete pthread2764pthread_key_delete pthread
2749pthread_kill pthread2765pthread_kill pthread
2750pthread_kill_other_threads_np pthread2766pthread_kill_other_threads_np pthread
2767pthread_mutex_clocklock pthread
2751pthread_mutex_consistent pthread2768pthread_mutex_consistent pthread
2752pthread_mutex_consistent_np pthread2769pthread_mutex_consistent_np pthread
2753pthread_mutex_destroy c2770pthread_mutex_destroy c
...@@ -2775,6 +2792,8 @@ pthread_mutexattr_setrobust pthread...@@ -2775,6 +2792,8 @@ pthread_mutexattr_setrobust pthread
2775pthread_mutexattr_setrobust_np pthread2792pthread_mutexattr_setrobust_np pthread
2776pthread_mutexattr_settype pthread2793pthread_mutexattr_settype pthread
2777pthread_once pthread2794pthread_once pthread
2795pthread_rwlock_clockrdlock pthread
2796pthread_rwlock_clockwrlock pthread
2778pthread_rwlock_destroy pthread2797pthread_rwlock_destroy pthread
2779pthread_rwlock_init pthread2798pthread_rwlock_init pthread
2780pthread_rwlock_rdlock pthread2799pthread_rwlock_rdlock pthread
...@@ -3001,6 +3020,7 @@ seed48 c...@@ -3001,6 +3020,7 @@ seed48 c
3001seed48_r c3020seed48_r c
3002seekdir c3021seekdir c
3003select c3022select c
3023sem_clockwait pthread
3004sem_close pthread3024sem_close pthread
3005sem_destroy pthread3025sem_destroy pthread
3006sem_getvalue pthread3026sem_getvalue pthread
...@@ -3369,6 +3389,7 @@ tgammaf32x m...@@ -3369,6 +3389,7 @@ tgammaf32x m
3369tgammaf64 m3389tgammaf64 m
3370tgammaf64x m3390tgammaf64x m
3371tgammal m3391tgammal m
3392tgkill c
3372thrd_create pthread3393thrd_create pthread
3373thrd_current c3394thrd_current c
3374thrd_detach pthread3395thrd_detach pthread
...@@ -3442,6 +3463,7 @@ ttyname c...@@ -3442,6 +3463,7 @@ ttyname c
3442ttyname_r c3463ttyname_r c
3443ttyslot c3464ttyslot c
3444twalk c3465twalk c
3466twalk_r c
3445tzname c3467tzname c
3446tzset c3468tzset c
3447ualarm c3469ualarm c
lib/libc/glibc/vers.txt+1
...@@ -38,3 +38,4 @@ GLIBC_2.26...@@ -38,3 +38,4 @@ GLIBC_2.26
38GLIBC_2.2738GLIBC_2.27
39GLIBC_2.2839GLIBC_2.28
40GLIBC_2.2940GLIBC_2.29
41GLIBC_2.30
lib/libc/include/aarch64-linux-gnu/bits/hwcap.h+4-1
...@@ -50,4 +50,7 @@...@@ -50,4 +50,7 @@
50#define HWCAP_USCAT (1 << 25)50#define HWCAP_USCAT (1 << 25)
51#define HWCAP_ILRCPC (1 << 26)51#define HWCAP_ILRCPC (1 << 26)
52#define HWCAP_FLAGM (1 << 27)52#define HWCAP_FLAGM (1 << 27)
53#define HWCAP_SSBS (1 << 28)
\ No newline at end of file
53#define HWCAP_SSBS (1 << 28)
54#define HWCAP_SB (1 << 29)
55#define HWCAP_PACA (1 << 30)
56#define HWCAP_PACG (1UL << 31)
\ No newline at end of file
lib/libc/include/aarch64-linux-gnu/gnu/stubs-lp64.h-6
...@@ -13,15 +13,9 @@...@@ -13,15 +13,9 @@
13#define __stub___compat_query_module13#define __stub___compat_query_module
14#define __stub___compat_uselib14#define __stub___compat_uselib
15#define __stub_chflags15#define __stub_chflags
16#define __stub_fattach
17#define __stub_fchflags16#define __stub_fchflags
18#define __stub_fdetach
19#define __stub_getmsg
20#define __stub_getpmsg
21#define __stub_gtty17#define __stub_gtty
22#define __stub_lchmod18#define __stub_lchmod
23#define __stub_putmsg
24#define __stub_putpmsg
25#define __stub_revoke19#define __stub_revoke
26#define __stub_setlogin20#define __stub_setlogin
27#define __stub_sigreturn21#define __stub_sigreturn
lib/libc/include/aarch64_be-linux-gnu/bits/hwcap.h+4-1
...@@ -50,4 +50,7 @@...@@ -50,4 +50,7 @@
50#define HWCAP_USCAT (1 << 25)50#define HWCAP_USCAT (1 << 25)
51#define HWCAP_ILRCPC (1 << 26)51#define HWCAP_ILRCPC (1 << 26)
52#define HWCAP_FLAGM (1 << 27)52#define HWCAP_FLAGM (1 << 27)
53#define HWCAP_SSBS (1 << 28)
\ No newline at end of file
53#define HWCAP_SSBS (1 << 28)
54#define HWCAP_SB (1 << 29)
55#define HWCAP_PACA (1 << 30)
56#define HWCAP_PACG (1UL << 31)
\ No newline at end of file
lib/libc/include/aarch64_be-linux-gnu/gnu/stubs-lp64_be.h-6
...@@ -13,15 +13,9 @@...@@ -13,15 +13,9 @@
13#define __stub___compat_query_module13#define __stub___compat_query_module
14#define __stub___compat_uselib14#define __stub___compat_uselib
15#define __stub_chflags15#define __stub_chflags
16#define __stub_fattach
17#define __stub_fchflags16#define __stub_fchflags
18#define __stub_fdetach
19#define __stub_getmsg
20#define __stub_getpmsg
21#define __stub_gtty17#define __stub_gtty
22#define __stub_lchmod18#define __stub_lchmod
23#define __stub_putmsg
24#define __stub_putpmsg
25#define __stub_revoke19#define __stub_revoke
26#define __stub_setlogin20#define __stub_setlogin
27#define __stub_sigreturn21#define __stub_sigreturn
lib/libc/include/generic-glibc/bits/dirent_ext.h created+33
...@@ -0,0 +1,33 @@
1/* System-specific extensions of <dirent.h>. Linux version.
2 Copyright (C) 2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _DIRENT_H
20# error "Never include <bits/dirent_ext.h> directly; use <dirent.h> instead."
21#endif
22
23__BEGIN_DECLS
24
25#ifdef __USE_GNU
26/* Read from the directory descriptor FD into LENGTH bytes at BUFFER.
27 Return the number of bytes read on success (0 for end of
28 directory), and -1 for failure. */
29extern __ssize_t getdents64 (int __fd, void *__buffer, size_t __length)
30 __THROW __nonnull ((2));
31#endif
32
33__END_DECLS
\ No newline at end of file
lib/libc/include/generic-glibc/bits/fcntl-linux.h+2
...@@ -284,6 +284,8 @@ struct f_owner_ex...@@ -284,6 +284,8 @@ struct f_owner_ex
284# define F_SEAL_SHRINK 0x0002 /* Prevent file from shrinking. */284# define F_SEAL_SHRINK 0x0002 /* Prevent file from shrinking. */
285# define F_SEAL_GROW 0x0004 /* Prevent file from growing. */285# define F_SEAL_GROW 0x0004 /* Prevent file from growing. */
286# define F_SEAL_WRITE 0x0008 /* Prevent writes. */286# define F_SEAL_WRITE 0x0008 /* Prevent writes. */
287# define F_SEAL_FUTURE_WRITE 0x0010 /* Prevent future writes while
288 mapped. */
287#endif289#endif
288290
289#ifdef __USE_GNU291#ifdef __USE_GNU
lib/libc/include/generic-glibc/bits/in.h+1
...@@ -192,6 +192,7 @@ struct in_pktinfo...@@ -192,6 +192,7 @@ struct in_pktinfo
192#define IPV6_JOIN_ANYCAST 27192#define IPV6_JOIN_ANYCAST 27
193#define IPV6_LEAVE_ANYCAST 28193#define IPV6_LEAVE_ANYCAST 28
194#define IPV6_MULTICAST_ALL 29194#define IPV6_MULTICAST_ALL 29
195#define IPV6_ROUTER_ALERT_ISOLATE 30
195#define IPV6_IPSEC_POLICY 34196#define IPV6_IPSEC_POLICY 34
196#define IPV6_XFRM_POLICY 35197#define IPV6_XFRM_POLICY 35
197#define IPV6_HDRINCL 36198#define IPV6_HDRINCL 36
lib/libc/include/generic-glibc/bits/math-vector-fortran.h deleted-19
...@@ -1,19 +0,0 @@
1! Platform-specific declarations of SIMD math functions for Fortran. -*- f90 -*-
2! Copyright (C) 2019 Free Software Foundation, Inc.
3! This file is part of the GNU C Library.
4!
5! The GNU C Library is free software; you can redistribute it and/or
6! modify it under the terms of the GNU Lesser General Public
7! License as published by the Free Software Foundation; either
8! version 2.1 of the License, or (at your option) any later version.
9!
10! The GNU C Library is distributed in the hope that it will be useful,
11! but WITHOUT ANY WARRANTY; without even the implied warranty of
12! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13! Lesser General Public License for more details.
14!
15! You should have received a copy of the GNU Lesser General Public
16! License along with the GNU C Library; if not, see
17! <http://www.gnu.org/licenses/>.
18
19! No SIMD math functions are available for this platform.
\ No newline at end of file
lib/libc/include/generic-glibc/bits/signal_ext.h created+31
...@@ -0,0 +1,31 @@
1/* System-specific extensions of <signal.h>, Linux version.
2 Copyright (C) 2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _SIGNAL_H
20# error "Never include <bits/signal_ext.h> directly; use <signal.h> instead."
21#endif
22
23#ifdef __USE_GNU
24
25/* Send SIGNAL to the thread TID in the thread group (process)
26 identified by TGID. This function behaves like kill, but also
27 fails with ESRCH if the specified TID does not belong to the
28 specified thread group. */
29extern int tgkill (__pid_t __tgid, __pid_t __tid, int __signal);
30
31#endif /* __USE_GNU */
\ No newline at end of file
lib/libc/include/generic-glibc/bits/socket-constants.h created+38
...@@ -0,0 +1,38 @@
1/* Socket constants which vary among Linux architectures.
2 Copyright (C) 2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _SYS_SOCKET_H
20# error "Never include <bits/socket-constants.h> directly; use <sys/socket.h> instead."
21#endif
22
23#define SOL_SOCKET 1
24#define SO_ACCEPTCONN 30
25#define SO_BROADCAST 6
26#define SO_DONTROUTE 5
27#define SO_ERROR 4
28#define SO_KEEPALIVE 9
29#define SO_LINGER 13
30#define SO_OOBINLINE 10
31#define SO_RCVBUF 8
32#define SO_RCVLOWAT 18
33#define SO_RCVTIMEO 20
34#define SO_REUSEADDR 2
35#define SO_SNDBUF 7
36#define SO_SNDLOWAT 19
37#define SO_SNDTIMEO 21
38#define SO_TYPE 3
\ No newline at end of file
lib/libc/include/generic-glibc/bits/socket.h+6-92
...@@ -349,98 +349,12 @@ struct ucred...@@ -349,98 +349,12 @@ struct ucred
349};349};
350#endif350#endif
351351
352/* Ugly workaround for unclean kernel headers. */352#ifdef __USE_MISC
353#ifndef __USE_MISC353# include <bits/types/time_t.h>
354# ifndef FIOGETOWN354# include <asm/socket.h>
355# define __SYS_SOCKET_H_undef_FIOGETOWN355#else
356# endif356# define SO_DEBUG 1
357# ifndef FIOSETOWN357# include <bits/socket-constants.h>
358# define __SYS_SOCKET_H_undef_FIOSETOWN
359# endif
360# ifndef SIOCATMARK
361# define __SYS_SOCKET_H_undef_SIOCATMARK
362# endif
363# ifndef SIOCGPGRP
364# define __SYS_SOCKET_H_undef_SIOCGPGRP
365# endif
366# ifndef SIOCGSTAMP
367# define __SYS_SOCKET_H_undef_SIOCGSTAMP
368# endif
369# ifndef SIOCGSTAMPNS
370# define __SYS_SOCKET_H_undef_SIOCGSTAMPNS
371# endif
372# ifndef SIOCSPGRP
373# define __SYS_SOCKET_H_undef_SIOCSPGRP
374# endif
375#endif
376#ifndef IOCSIZE_MASK
377# define __SYS_SOCKET_H_undef_IOCSIZE_MASK
378#endif
379#ifndef IOCSIZE_SHIFT
380# define __SYS_SOCKET_H_undef_IOCSIZE_SHIFT
381#endif
382#ifndef IOC_IN
383# define __SYS_SOCKET_H_undef_IOC_IN
384#endif
385#ifndef IOC_INOUT
386# define __SYS_SOCKET_H_undef_IOC_INOUT
387#endif
388#ifndef IOC_OUT
389# define __SYS_SOCKET_H_undef_IOC_OUT
390#endif
391
392/* Get socket manipulation related informations from kernel headers. */
393#include <asm/socket.h>
394
395#ifndef __USE_MISC
396# ifdef __SYS_SOCKET_H_undef_FIOGETOWN
397# undef __SYS_SOCKET_H_undef_FIOGETOWN
398# undef FIOGETOWN
399# endif
400# ifdef __SYS_SOCKET_H_undef_FIOSETOWN
401# undef __SYS_SOCKET_H_undef_FIOSETOWN
402# undef FIOSETOWN
403# endif
404# ifdef __SYS_SOCKET_H_undef_SIOCATMARK
405# undef __SYS_SOCKET_H_undef_SIOCATMARK
406# undef SIOCATMARK
407# endif
408# ifdef __SYS_SOCKET_H_undef_SIOCGPGRP
409# undef __SYS_SOCKET_H_undef_SIOCGPGRP
410# undef SIOCGPGRP
411# endif
412# ifdef __SYS_SOCKET_H_undef_SIOCGSTAMP
413# undef __SYS_SOCKET_H_undef_SIOCGSTAMP
414# undef SIOCGSTAMP
415# endif
416# ifdef __SYS_SOCKET_H_undef_SIOCGSTAMPNS
417# undef __SYS_SOCKET_H_undef_SIOCGSTAMPNS
418# undef SIOCGSTAMPNS
419# endif
420# ifdef __SYS_SOCKET_H_undef_SIOCSPGRP
421# undef __SYS_SOCKET_H_undef_SIOCSPGRP
422# undef SIOCSPGRP
423# endif
424#endif
425#ifdef __SYS_SOCKET_H_undef_IOCSIZE_MASK
426# undef __SYS_SOCKET_H_undef_IOCSIZE_MASK
427# undef IOCSIZE_MASK
428#endif
429#ifdef __SYS_SOCKET_H_undef_IOCSIZE_SHIFT
430# undef __SYS_SOCKET_H_undef_IOCSIZE_SHIFT
431# undef IOCSIZE_SHIFT
432#endif
433#ifdef __SYS_SOCKET_H_undef_IOC_IN
434# undef __SYS_SOCKET_H_undef_IOC_IN
435# undef IOC_IN
436#endif
437#ifdef __SYS_SOCKET_H_undef_IOC_INOUT
438# undef __SYS_SOCKET_H_undef_IOC_INOUT
439# undef IOC_INOUT
440#endif
441#ifdef __SYS_SOCKET_H_undef_IOC_OUT
442# undef __SYS_SOCKET_H_undef_IOC_OUT
443# undef IOC_OUT
444#endif358#endif
445359
446/* Structure used to manipulate the SO_LINGER option. */360/* Structure used to manipulate the SO_LINGER option. */
lib/libc/include/generic-glibc/bits/statx-generic.h created+60
...@@ -0,0 +1,60 @@
1/* Generic statx-related definitions and declarations.
2 Copyright (C) 2018-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19/* This interface is based on <linux/stat.h> in Linux. */
20
21#ifndef _SYS_STAT_H
22# error Never include <bits/statx-generic.h> directly, include <sys/stat.h> instead.
23#endif
24
25#include <bits/types/struct_statx_timestamp.h>
26#include <bits/types/struct_statx.h>
27
28#ifndef STATX_TYPE
29# define STATX_TYPE 0x0001U
30# define STATX_MODE 0x0002U
31# define STATX_NLINK 0x0004U
32# define STATX_UID 0x0008U
33# define STATX_GID 0x0010U
34# define STATX_ATIME 0x0020U
35# define STATX_MTIME 0x0040U
36# define STATX_CTIME 0x0080U
37# define STATX_INO 0x0100U
38# define STATX_SIZE 0x0200U
39# define STATX_BLOCKS 0x0400U
40# define STATX_BASIC_STATS 0x07ffU
41# define STATX_ALL 0x0fffU
42# define STATX_BTIME 0x0800U
43# define STATX__RESERVED 0x80000000U
44
45# define STATX_ATTR_COMPRESSED 0x0004
46# define STATX_ATTR_IMMUTABLE 0x0010
47# define STATX_ATTR_APPEND 0x0020
48# define STATX_ATTR_NODUMP 0x0040
49# define STATX_ATTR_ENCRYPTED 0x0800
50# define STATX_ATTR_AUTOMOUNT 0x1000
51#endif /* !STATX_TYPE */
52
53__BEGIN_DECLS
54
55/* Fill *BUF with information about PATH in DIRFD. */
56int statx (int __dirfd, const char *__restrict __path, int __flags,
57 unsigned int __mask, struct statx *__restrict __buf)
58 __THROW __nonnull ((2, 5));
59
60__END_DECLS
\ No newline at end of file
lib/libc/include/generic-glibc/bits/statx.h+13-67
...@@ -1,4 +1,4 @@...@@ -1,4 +1,4 @@
1/* statx-related definitions and declarations.1/* statx-related definitions and declarations. Linux version.
2 Copyright (C) 2018-2019 Free Software Foundation, Inc.2 Copyright (C) 2018-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.3 This file is part of the GNU C Library.
44
...@@ -19,73 +19,19 @@...@@ -19,73 +19,19 @@
19/* This interface is based on <linux/stat.h> in Linux. */19/* This interface is based on <linux/stat.h> in Linux. */
2020
21#ifndef _SYS_STAT_H21#ifndef _SYS_STAT_H
22# error Never include <bits/stat.x.h> directly, include <sys/stat.h> instead.22# error Never include <bits/statx.h> directly, include <sys/stat.h> instead.
23#endif23#endif
2424
25struct statx_timestamp25/* Use the Linux kernel header if available. */
26{
27 __int64_t tv_sec;
28 __uint32_t tv_nsec;
29 __int32_t __statx_timestamp_pad1[1];
30};
3126
32/* Warning: The kernel may add additional fields to this struct in the27/* Use "" to work around incorrect macro expansion of the
33 future. Only use this struct for calling the statx function, not28 __has_include argument (GCC PR 80005). */
34 for storing data. (Expansion will be controlled by the mask29#if __glibc_has_include ("linux/stat.h")
35 argument of the statx function.) */30# include "linux/stat.h"
36struct statx31# ifdef STATX_TYPE
37{32# define __statx_timestamp_defined 1
38 __uint32_t stx_mask;33# define __statx_defined 1
39 __uint32_t stx_blksize;34# endif
40 __uint64_t stx_attributes;35#endif
41 __uint32_t stx_nlink;
42 __uint32_t stx_uid;
43 __uint32_t stx_gid;
44 __uint16_t stx_mode;
45 __uint16_t __statx_pad1[1];
46 __uint64_t stx_ino;
47 __uint64_t stx_size;
48 __uint64_t stx_blocks;
49 __uint64_t stx_attributes_mask;
50 struct statx_timestamp stx_atime;
51 struct statx_timestamp stx_btime;
52 struct statx_timestamp stx_ctime;
53 struct statx_timestamp stx_mtime;
54 __uint32_t stx_rdev_major;
55 __uint32_t stx_rdev_minor;
56 __uint32_t stx_dev_major;
57 __uint32_t stx_dev_minor;
58 __uint64_t __statx_pad2[14];
59};
60
61#define STATX_TYPE 0x0001U
62#define STATX_MODE 0x0002U
63#define STATX_NLINK 0x0004U
64#define STATX_UID 0x0008U
65#define STATX_GID 0x0010U
66#define STATX_ATIME 0x0020U
67#define STATX_MTIME 0x0040U
68#define STATX_CTIME 0x0080U
69#define STATX_INO 0x0100U
70#define STATX_SIZE 0x0200U
71#define STATX_BLOCKS 0x0400U
72#define STATX_BASIC_STATS 0x07ffU
73#define STATX_ALL 0x0fffU
74#define STATX_BTIME 0x0800U
75#define STATX__RESERVED 0x80000000U
76
77#define STATX_ATTR_COMPRESSED 0x0004
78#define STATX_ATTR_IMMUTABLE 0x0010
79#define STATX_ATTR_APPEND 0x0020
80#define STATX_ATTR_NODUMP 0x0040
81#define STATX_ATTR_ENCRYPTED 0x0800
82#define STATX_ATTR_AUTOMOUNT 0x1000
83
84__BEGIN_DECLS
85
86/* Fill *BUF with information about PATH in DIRFD. */
87int statx (int __dirfd, const char *__restrict __path, int __flags,
88 unsigned int __mask, struct statx *__restrict __buf)
89 __THROW __nonnull ((2, 5));
9036
91__END_DECLS
\ No newline at end of file
37#include <bits/statx-generic.h>
\ No newline at end of file
lib/libc/include/generic-glibc/bits/stropts.h deleted-230
...@@ -1,230 +0,0 @@
1/* Copyright (C) 1998-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef _STROPTS_H
19# error "Never include <bits/stropts.h> directly; use <stropts.h> instead."
20#endif
21
22#ifndef _BITS_STROPTS_H
23#define _BITS_STROPTS_H 1
24
25#include <bits/types.h>
26
27/* Macros used as `request' argument to `ioctl'. */
28#define __SID ('S' << 8)
29
30#define I_NREAD (__SID | 1) /* Counts the number of data bytes in the data
31 block in the first message. */
32#define I_PUSH (__SID | 2) /* Push STREAMS module onto top of the current
33 STREAM, just below the STREAM head. */
34#define I_POP (__SID | 3) /* Remove STREAMS module from just below the
35 STREAM head. */
36#define I_LOOK (__SID | 4) /* Retrieve the name of the module just below
37 the STREAM head and place it in a character
38 string. */
39#define I_FLUSH (__SID | 5) /* Flush all input and/or output. */
40#define I_SRDOPT (__SID | 6) /* Sets the read mode. */
41#define I_GRDOPT (__SID | 7) /* Returns the current read mode setting. */
42#define I_STR (__SID | 8) /* Construct an internal STREAMS `ioctl'
43 message and send that message downstream. */
44#define I_SETSIG (__SID | 9) /* Inform the STREAM head that the process
45 wants the SIGPOLL signal issued. */
46#define I_GETSIG (__SID |10) /* Return the events for which the calling
47 process is currently registered to be sent
48 a SIGPOLL signal. */
49#define I_FIND (__SID |11) /* Compares the names of all modules currently
50 present in the STREAM to the name pointed to
51 by `arg'. */
52#define I_LINK (__SID |12) /* Connect two STREAMs. */
53#define I_UNLINK (__SID |13) /* Disconnects the two STREAMs. */
54#define I_PEEK (__SID |15) /* Allows a process to retrieve the information
55 in the first message on the STREAM head read
56 queue without taking the message off the
57 queue. */
58#define I_FDINSERT (__SID |16) /* Create a message from the specified
59 buffer(s), adds information about another
60 STREAM, and send the message downstream. */
61#define I_SENDFD (__SID |17) /* Requests the STREAM associated with `fildes'
62 to send a message, containing a file
63 pointer, to the STREAM head at the other end
64 of a STREAMS pipe. */
65#define I_RECVFD (__SID |14) /* Non-EFT definition. */
66#define I_SWROPT (__SID |19) /* Set the write mode. */
67#define I_GWROPT (__SID |20) /* Return the current write mode setting. */
68#define I_LIST (__SID |21) /* List all the module names on the STREAM, up
69 to and including the topmost driver name. */
70#define I_PLINK (__SID |22) /* Connect two STREAMs with a persistent
71 link. */
72#define I_PUNLINK (__SID |23) /* Disconnect the two STREAMs that were
73 connected with a persistent link. */
74#define I_FLUSHBAND (__SID |28) /* Flush only band specified. */
75#define I_CKBAND (__SID |29) /* Check if the message of a given priority
76 band exists on the STREAM head read
77 queue. */
78#define I_GETBAND (__SID |30) /* Return the priority band of the first
79 message on the STREAM head read queue. */
80#define I_ATMARK (__SID |31) /* See if the current message on the STREAM
81 head read queue is "marked" by some module
82 downstream. */
83#define I_SETCLTIME (__SID |32) /* Set the time the STREAM head will delay when
84 a STREAM is closing and there is data on
85 the write queues. */
86#define I_GETCLTIME (__SID |33) /* Get current value for closing timeout. */
87#define I_CANPUT (__SID |34) /* Check if a certain band is writable. */
88
89
90/* Used in `I_LOOK' request. */
91#define FMNAMESZ 8 /* compatibility w/UnixWare/Solaris. */
92
93/* Flush options. */
94#define FLUSHR 0x01 /* Flush read queues. */
95#define FLUSHW 0x02 /* Flush write queues. */
96#define FLUSHRW 0x03 /* Flush read and write queues. */
97#ifdef __USE_GNU
98# define FLUSHBAND 0x04 /* Flush only specified band. */
99#endif
100
101/* Possible arguments for `I_SETSIG'. */
102#define S_INPUT 0x0001 /* A message, other than a high-priority
103 message, has arrived. */
104#define S_HIPRI 0x0002 /* A high-priority message is present. */
105#define S_OUTPUT 0x0004 /* The write queue for normal data is no longer
106 full. */
107#define S_MSG 0x0008 /* A STREAMS signal message that contains the
108 SIGPOLL signal reaches the front of the
109 STREAM head read queue. */
110#define S_ERROR 0x0010 /* Notification of an error condition. */
111#define S_HANGUP 0x0020 /* Notification of a hangup. */
112#define S_RDNORM 0x0040 /* A normal message has arrived. */
113#define S_WRNORM S_OUTPUT
114#define S_RDBAND 0x0080 /* A message with a non-zero priority has
115 arrived. */
116#define S_WRBAND 0x0100 /* The write queue for a non-zero priority
117 band is no longer full. */
118#define S_BANDURG 0x0200 /* When used in conjunction with S_RDBAND,
119 SIGURG is generated instead of SIGPOLL when
120 a priority message reaches the front of the
121 STREAM head read queue. */
122
123/* Option for `I_PEEK'. */
124#define RS_HIPRI 0x01 /* Only look for high-priority messages. */
125
126/* Options for `I_SRDOPT'. */
127#define RNORM 0x0000 /* Byte-STREAM mode, the default. */
128#define RMSGD 0x0001 /* Message-discard mode. */
129#define RMSGN 0x0002 /* Message-nondiscard mode. */
130#define RPROTDAT 0x0004 /* Deliver the control part of a message as
131 data. */
132#define RPROTDIS 0x0008 /* Discard the control part of a message,
133 delivering any data part. */
134#define RPROTNORM 0x0010 /* Fail `read' with EBADMSG if a message
135 containing a control part is at the front
136 of the STREAM head read queue. */
137#ifdef __USE_GNU
138# define RPROTMASK 0x001C /* The RPROT bits */
139#endif
140
141/* Possible mode for `I_SWROPT'. */
142#define SNDZERO 0x001 /* Send a zero-length message downstream when a
143 `write' of 0 bytes occurs. */
144#ifdef __USE_GNU
145# define SNDPIPE 0x002 /* Send SIGPIPE on write and putmsg if
146 sd_werror is set. */
147#endif
148
149/* Arguments for `I_ATMARK'. */
150#define ANYMARK 0x01 /* Check if the message is marked. */
151#define LASTMARK 0x02 /* Check if the message is the last one marked
152 on the queue. */
153
154/* Argument for `I_UNLINK'. */
155#ifdef __USE_GNU
156# define MUXID_ALL (-1) /* Unlink all STREAMs linked to the STREAM
157 associated with `fildes'. */
158#endif
159
160
161/* Macros for `getmsg', `getpmsg', `putmsg' and `putpmsg'. */
162#define MSG_HIPRI 0x01 /* Send/receive high priority message. */
163#define MSG_ANY 0x02 /* Receive any message. */
164#define MSG_BAND 0x04 /* Receive message from specified band. */
165
166/* Values returned by getmsg and getpmsg */
167#define MORECTL 1 /* More control information is left in
168 message. */
169#define MOREDATA 2 /* More data is left in message. */
170
171
172/* Structure used for the I_FLUSHBAND ioctl on streams. */
173struct bandinfo
174 {
175 unsigned char bi_pri;
176 int bi_flag;
177 };
178
179struct strbuf
180 {
181 int maxlen; /* Maximum buffer length. */
182 int len; /* Length of data. */
183 char *buf; /* Pointer to buffer. */
184 };
185
186struct strpeek
187 {
188 struct strbuf ctlbuf;
189 struct strbuf databuf;
190 t_uscalar_t flags; /* UnixWare/Solaris compatibility. */
191 };
192
193struct strfdinsert
194 {
195 struct strbuf ctlbuf;
196 struct strbuf databuf;
197 t_uscalar_t flags; /* UnixWare/Solaris compatibility. */
198 int fildes;
199 int offset;
200 };
201
202struct strioctl
203 {
204 int ic_cmd;
205 int ic_timout;
206 int ic_len;
207 char *ic_dp;
208 };
209
210struct strrecvfd
211 {
212 int fd;
213 uid_t uid;
214 gid_t gid;
215 char __fill[8]; /* UnixWare/Solaris compatibility */
216 };
217
218
219struct str_mlist
220 {
221 char l_name[FMNAMESZ + 1];
222 };
223
224struct str_list
225 {
226 int sl_nmods;
227 struct str_mlist *sl_modlist;
228 };
229
230#endif /* bits/stropts.h */
\ No newline at end of file
lib/libc/include/generic-glibc/bits/syscall.h+154-2
...@@ -1,11 +1,11 @@...@@ -1,11 +1,11 @@
1/* Generated at libc build time from syscall list. */1/* Generated at libc build time from syscall list. */
2/* The system call list corresponds to kernel 4.20. */2/* The system call list corresponds to kernel 5.2. */
33
4#ifndef _SYSCALL_H4#ifndef _SYSCALL_H
5# error "Never use <bits/syscall.h> directly; include <sys/syscall.h> instead."5# error "Never use <bits/syscall.h> directly; include <sys/syscall.h> instead."
6#endif6#endif
77
8#define __GLIBC_LINUX_VERSION_CODE 2672648#define __GLIBC_LINUX_VERSION_CODE 328192
99
10#ifdef __NR_FAST_atomic_update10#ifdef __NR_FAST_atomic_update
11# define SYS_FAST_atomic_update __NR_FAST_atomic_update11# define SYS_FAST_atomic_update __NR_FAST_atomic_update
...@@ -115,6 +115,10 @@...@@ -115,6 +115,10 @@
115# define SYS_break __NR_break115# define SYS_break __NR_break
116#endif116#endif
117117
118#ifdef __NR_breakpoint
119# define SYS_breakpoint __NR_breakpoint
120#endif
121
118#ifdef __NR_brk122#ifdef __NR_brk
119# define SYS_brk __NR_brk123# define SYS_brk __NR_brk
120#endif124#endif
...@@ -159,22 +163,42 @@...@@ -159,22 +163,42 @@
159# define SYS_clock_adjtime __NR_clock_adjtime163# define SYS_clock_adjtime __NR_clock_adjtime
160#endif164#endif
161165
166#ifdef __NR_clock_adjtime64
167# define SYS_clock_adjtime64 __NR_clock_adjtime64
168#endif
169
162#ifdef __NR_clock_getres170#ifdef __NR_clock_getres
163# define SYS_clock_getres __NR_clock_getres171# define SYS_clock_getres __NR_clock_getres
164#endif172#endif
165173
174#ifdef __NR_clock_getres_time64
175# define SYS_clock_getres_time64 __NR_clock_getres_time64
176#endif
177
166#ifdef __NR_clock_gettime178#ifdef __NR_clock_gettime
167# define SYS_clock_gettime __NR_clock_gettime179# define SYS_clock_gettime __NR_clock_gettime
168#endif180#endif
169181
182#ifdef __NR_clock_gettime64
183# define SYS_clock_gettime64 __NR_clock_gettime64
184#endif
185
170#ifdef __NR_clock_nanosleep186#ifdef __NR_clock_nanosleep
171# define SYS_clock_nanosleep __NR_clock_nanosleep187# define SYS_clock_nanosleep __NR_clock_nanosleep
172#endif188#endif
173189
190#ifdef __NR_clock_nanosleep_time64
191# define SYS_clock_nanosleep_time64 __NR_clock_nanosleep_time64
192#endif
193
174#ifdef __NR_clock_settime194#ifdef __NR_clock_settime
175# define SYS_clock_settime __NR_clock_settime195# define SYS_clock_settime __NR_clock_settime
176#endif196#endif
177197
198#ifdef __NR_clock_settime64
199# define SYS_clock_settime64 __NR_clock_settime64
200#endif
201
178#ifdef __NR_clone202#ifdef __NR_clone
179# define SYS_clone __NR_clone203# define SYS_clone __NR_clone
180#endif204#endif
...@@ -367,6 +391,10 @@...@@ -367,6 +391,10 @@
367# define SYS_fork __NR_fork391# define SYS_fork __NR_fork
368#endif392#endif
369393
394#ifdef __NR_fp_udfiex_crtl
395# define SYS_fp_udfiex_crtl __NR_fp_udfiex_crtl
396#endif
397
370#ifdef __NR_free_hugepages398#ifdef __NR_free_hugepages
371# define SYS_free_hugepages __NR_free_hugepages399# define SYS_free_hugepages __NR_free_hugepages
372#endif400#endif
...@@ -375,10 +403,26 @@...@@ -375,10 +403,26 @@
375# define SYS_fremovexattr __NR_fremovexattr403# define SYS_fremovexattr __NR_fremovexattr
376#endif404#endif
377405
406#ifdef __NR_fsconfig
407# define SYS_fsconfig __NR_fsconfig
408#endif
409
378#ifdef __NR_fsetxattr410#ifdef __NR_fsetxattr
379# define SYS_fsetxattr __NR_fsetxattr411# define SYS_fsetxattr __NR_fsetxattr
380#endif412#endif
381413
414#ifdef __NR_fsmount
415# define SYS_fsmount __NR_fsmount
416#endif
417
418#ifdef __NR_fsopen
419# define SYS_fsopen __NR_fsopen
420#endif
421
422#ifdef __NR_fspick
423# define SYS_fspick __NR_fspick
424#endif
425
382#ifdef __NR_fstat426#ifdef __NR_fstat
383# define SYS_fstat __NR_fstat427# define SYS_fstat __NR_fstat
384#endif428#endif
...@@ -419,6 +463,10 @@...@@ -419,6 +463,10 @@
419# define SYS_futex __NR_futex463# define SYS_futex __NR_futex
420#endif464#endif
421465
466#ifdef __NR_futex_time64
467# define SYS_futex_time64 __NR_futex_time64
468#endif
469
422#ifdef __NR_futimesat470#ifdef __NR_futimesat
423# define SYS_futimesat __NR_futimesat471# define SYS_futimesat __NR_futimesat
424#endif472#endif
...@@ -439,6 +487,10 @@...@@ -439,6 +487,10 @@
439# define SYS_get_thread_area __NR_get_thread_area487# define SYS_get_thread_area __NR_get_thread_area
440#endif488#endif
441489
490#ifdef __NR_get_tls
491# define SYS_get_tls __NR_get_tls
492#endif
493
442#ifdef __NR_getcpu494#ifdef __NR_getcpu
443# define SYS_getcpu __NR_getcpu495# define SYS_getcpu __NR_getcpu
444#endif496#endif
...@@ -655,6 +707,10 @@...@@ -655,6 +707,10 @@
655# define SYS_io_pgetevents __NR_io_pgetevents707# define SYS_io_pgetevents __NR_io_pgetevents
656#endif708#endif
657709
710#ifdef __NR_io_pgetevents_time64
711# define SYS_io_pgetevents_time64 __NR_io_pgetevents_time64
712#endif
713
658#ifdef __NR_io_setup714#ifdef __NR_io_setup
659# define SYS_io_setup __NR_io_setup715# define SYS_io_setup __NR_io_setup
660#endif716#endif
...@@ -663,6 +719,18 @@...@@ -663,6 +719,18 @@
663# define SYS_io_submit __NR_io_submit719# define SYS_io_submit __NR_io_submit
664#endif720#endif
665721
722#ifdef __NR_io_uring_enter
723# define SYS_io_uring_enter __NR_io_uring_enter
724#endif
725
726#ifdef __NR_io_uring_register
727# define SYS_io_uring_register __NR_io_uring_register
728#endif
729
730#ifdef __NR_io_uring_setup
731# define SYS_io_uring_setup __NR_io_uring_setup
732#endif
733
666#ifdef __NR_ioctl734#ifdef __NR_ioctl
667# define SYS_ioctl __NR_ioctl735# define SYS_ioctl __NR_ioctl
668#endif736#endif
...@@ -847,6 +915,10 @@...@@ -847,6 +915,10 @@
847# define SYS_mount __NR_mount915# define SYS_mount __NR_mount
848#endif916#endif
849917
918#ifdef __NR_move_mount
919# define SYS_move_mount __NR_move_mount
920#endif
921
850#ifdef __NR_move_pages922#ifdef __NR_move_pages
851# define SYS_move_pages __NR_move_pages923# define SYS_move_pages __NR_move_pages
852#endif924#endif
...@@ -875,10 +947,18 @@...@@ -875,10 +947,18 @@
875# define SYS_mq_timedreceive __NR_mq_timedreceive947# define SYS_mq_timedreceive __NR_mq_timedreceive
876#endif948#endif
877949
950#ifdef __NR_mq_timedreceive_time64
951# define SYS_mq_timedreceive_time64 __NR_mq_timedreceive_time64
952#endif
953
878#ifdef __NR_mq_timedsend954#ifdef __NR_mq_timedsend
879# define SYS_mq_timedsend __NR_mq_timedsend955# define SYS_mq_timedsend __NR_mq_timedsend
880#endif956#endif
881957
958#ifdef __NR_mq_timedsend_time64
959# define SYS_mq_timedsend_time64 __NR_mq_timedsend_time64
960#endif
961
882#ifdef __NR_mq_unlink962#ifdef __NR_mq_unlink
883# define SYS_mq_unlink __NR_mq_unlink963# define SYS_mq_unlink __NR_mq_unlink
884#endif964#endif
...@@ -951,6 +1031,10 @@...@@ -951,6 +1031,10 @@
951# define SYS_old_adjtimex __NR_old_adjtimex1031# define SYS_old_adjtimex __NR_old_adjtimex
952#endif1032#endif
9531033
1034#ifdef __NR_old_getpagesize
1035# define SYS_old_getpagesize __NR_old_getpagesize
1036#endif
1037
954#ifdef __NR_oldfstat1038#ifdef __NR_oldfstat
955# define SYS_oldfstat __NR_oldfstat1039# define SYS_oldfstat __NR_oldfstat
956#endif1040#endif
...@@ -983,6 +1067,10 @@...@@ -983,6 +1067,10 @@
983# define SYS_open_by_handle_at __NR_open_by_handle_at1067# define SYS_open_by_handle_at __NR_open_by_handle_at
984#endif1068#endif
9851069
1070#ifdef __NR_open_tree
1071# define SYS_open_tree __NR_open_tree
1072#endif
1073
986#ifdef __NR_openat1074#ifdef __NR_openat
987# define SYS_openat __NR_openat1075# define SYS_openat __NR_openat
988#endif1076#endif
...@@ -1459,6 +1547,10 @@...@@ -1459,6 +1547,10 @@
1459# define SYS_personality __NR_personality1547# define SYS_personality __NR_personality
1460#endif1548#endif
14611549
1550#ifdef __NR_pidfd_send_signal
1551# define SYS_pidfd_send_signal __NR_pidfd_send_signal
1552#endif
1553
1462#ifdef __NR_pipe1554#ifdef __NR_pipe
1463# define SYS_pipe __NR_pipe1555# define SYS_pipe __NR_pipe
1464#endif1556#endif
...@@ -1491,6 +1583,10 @@...@@ -1491,6 +1583,10 @@
1491# define SYS_ppoll __NR_ppoll1583# define SYS_ppoll __NR_ppoll
1492#endif1584#endif
14931585
1586#ifdef __NR_ppoll_time64
1587# define SYS_ppoll_time64 __NR_ppoll_time64
1588#endif
1589
1494#ifdef __NR_prctl1590#ifdef __NR_prctl
1495# define SYS_prctl __NR_prctl1591# define SYS_prctl __NR_prctl
1496#endif1592#endif
...@@ -1531,6 +1627,10 @@...@@ -1531,6 +1627,10 @@
1531# define SYS_pselect6 __NR_pselect61627# define SYS_pselect6 __NR_pselect6
1532#endif1628#endif
15331629
1630#ifdef __NR_pselect6_time64
1631# define SYS_pselect6_time64 __NR_pselect6_time64
1632#endif
1633
1534#ifdef __NR_ptrace1634#ifdef __NR_ptrace
1535# define SYS_ptrace __NR_ptrace1635# define SYS_ptrace __NR_ptrace
1536#endif1636#endif
...@@ -1599,6 +1699,10 @@...@@ -1599,6 +1699,10 @@
1599# define SYS_recvmmsg __NR_recvmmsg1699# define SYS_recvmmsg __NR_recvmmsg
1600#endif1700#endif
16011701
1702#ifdef __NR_recvmmsg_time64
1703# define SYS_recvmmsg_time64 __NR_recvmmsg_time64
1704#endif
1705
1602#ifdef __NR_recvmsg1706#ifdef __NR_recvmsg
1603# define SYS_recvmsg __NR_recvmsg1707# define SYS_recvmsg __NR_recvmsg
1604#endif1708#endif
...@@ -1671,6 +1775,10 @@...@@ -1671,6 +1775,10 @@
1671# define SYS_rt_sigtimedwait __NR_rt_sigtimedwait1775# define SYS_rt_sigtimedwait __NR_rt_sigtimedwait
1672#endif1776#endif
16731777
1778#ifdef __NR_rt_sigtimedwait_time64
1779# define SYS_rt_sigtimedwait_time64 __NR_rt_sigtimedwait_time64
1780#endif
1781
1674#ifdef __NR_rt_tgsigqueueinfo1782#ifdef __NR_rt_tgsigqueueinfo
1675# define SYS_rt_tgsigqueueinfo __NR_rt_tgsigqueueinfo1783# define SYS_rt_tgsigqueueinfo __NR_rt_tgsigqueueinfo
1676#endif1784#endif
...@@ -1731,6 +1839,10 @@...@@ -1731,6 +1839,10 @@
1731# define SYS_sched_rr_get_interval __NR_sched_rr_get_interval1839# define SYS_sched_rr_get_interval __NR_sched_rr_get_interval
1732#endif1840#endif
17331841
1842#ifdef __NR_sched_rr_get_interval_time64
1843# define SYS_sched_rr_get_interval_time64 __NR_sched_rr_get_interval_time64
1844#endif
1845
1734#ifdef __NR_sched_set_affinity1846#ifdef __NR_sched_set_affinity
1735# define SYS_sched_set_affinity __NR_sched_set_affinity1847# define SYS_sched_set_affinity __NR_sched_set_affinity
1736#endif1848#endif
...@@ -1783,6 +1895,10 @@...@@ -1783,6 +1895,10 @@
1783# define SYS_semtimedop __NR_semtimedop1895# define SYS_semtimedop __NR_semtimedop
1784#endif1896#endif
17851897
1898#ifdef __NR_semtimedop_time64
1899# define SYS_semtimedop_time64 __NR_semtimedop_time64
1900#endif
1901
1786#ifdef __NR_send1902#ifdef __NR_send
1787# define SYS_send __NR_send1903# define SYS_send __NR_send
1788#endif1904#endif
...@@ -1823,6 +1939,10 @@...@@ -1823,6 +1939,10 @@
1823# define SYS_set_tid_address __NR_set_tid_address1939# define SYS_set_tid_address __NR_set_tid_address
1824#endif1940#endif
18251941
1942#ifdef __NR_set_tls
1943# define SYS_set_tls __NR_set_tls
1944#endif
1945
1826#ifdef __NR_setdomainname1946#ifdef __NR_setdomainname
1827# define SYS_setdomainname __NR_setdomainname1947# define SYS_setdomainname __NR_setdomainname
1828#endif1948#endif
...@@ -2171,10 +2291,18 @@...@@ -2171,10 +2291,18 @@
2171# define SYS_timer_gettime __NR_timer_gettime2291# define SYS_timer_gettime __NR_timer_gettime
2172#endif2292#endif
21732293
2294#ifdef __NR_timer_gettime64
2295# define SYS_timer_gettime64 __NR_timer_gettime64
2296#endif
2297
2174#ifdef __NR_timer_settime2298#ifdef __NR_timer_settime
2175# define SYS_timer_settime __NR_timer_settime2299# define SYS_timer_settime __NR_timer_settime
2176#endif2300#endif
21772301
2302#ifdef __NR_timer_settime64
2303# define SYS_timer_settime64 __NR_timer_settime64
2304#endif
2305
2178#ifdef __NR_timerfd2306#ifdef __NR_timerfd
2179# define SYS_timerfd __NR_timerfd2307# define SYS_timerfd __NR_timerfd
2180#endif2308#endif
...@@ -2187,10 +2315,18 @@...@@ -2187,10 +2315,18 @@
2187# define SYS_timerfd_gettime __NR_timerfd_gettime2315# define SYS_timerfd_gettime __NR_timerfd_gettime
2188#endif2316#endif
21892317
2318#ifdef __NR_timerfd_gettime64
2319# define SYS_timerfd_gettime64 __NR_timerfd_gettime64
2320#endif
2321
2190#ifdef __NR_timerfd_settime2322#ifdef __NR_timerfd_settime
2191# define SYS_timerfd_settime __NR_timerfd_settime2323# define SYS_timerfd_settime __NR_timerfd_settime
2192#endif2324#endif
21932325
2326#ifdef __NR_timerfd_settime64
2327# define SYS_timerfd_settime64 __NR_timerfd_settime64
2328#endif
2329
2194#ifdef __NR_times2330#ifdef __NR_times
2195# define SYS_times __NR_times2331# define SYS_times __NR_times
2196#endif2332#endif
...@@ -2211,6 +2347,10 @@...@@ -2211,6 +2347,10 @@
2211# define SYS_tuxcall __NR_tuxcall2347# define SYS_tuxcall __NR_tuxcall
2212#endif2348#endif
22132349
2350#ifdef __NR_udftrap
2351# define SYS_udftrap __NR_udftrap
2352#endif
2353
2214#ifdef __NR_ugetrlimit2354#ifdef __NR_ugetrlimit
2215# define SYS_ugetrlimit __NR_ugetrlimit2355# define SYS_ugetrlimit __NR_ugetrlimit
2216#endif2356#endif
...@@ -2255,6 +2395,14 @@...@@ -2255,6 +2395,14 @@
2255# define SYS_userfaultfd __NR_userfaultfd2395# define SYS_userfaultfd __NR_userfaultfd
2256#endif2396#endif
22572397
2398#ifdef __NR_usr26
2399# define SYS_usr26 __NR_usr26
2400#endif
2401
2402#ifdef __NR_usr32
2403# define SYS_usr32 __NR_usr32
2404#endif
2405
2258#ifdef __NR_ustat2406#ifdef __NR_ustat
2259# define SYS_ustat __NR_ustat2407# define SYS_ustat __NR_ustat
2260#endif2408#endif
...@@ -2267,6 +2415,10 @@...@@ -2267,6 +2415,10 @@
2267# define SYS_utimensat __NR_utimensat2415# define SYS_utimensat __NR_utimensat
2268#endif2416#endif
22692417
2418#ifdef __NR_utimensat_time64
2419# define SYS_utimensat_time64 __NR_utimensat_time64
2420#endif
2421
2270#ifdef __NR_utimes2422#ifdef __NR_utimes
2271# define SYS_utimes __NR_utimes2423# define SYS_utimes __NR_utimes
2272#endif2424#endif
lib/libc/include/generic-glibc/bits/types.h+11-8
...@@ -87,7 +87,7 @@ __extension__ typedef unsigned long long int __uintmax_t;...@@ -87,7 +87,7 @@ __extension__ typedef unsigned long long int __uintmax_t;
87 32 -- "natural" 32-bit type (always int)87 32 -- "natural" 32-bit type (always int)
88 64 -- "natural" 64-bit type (long or long long)88 64 -- "natural" 64-bit type (long or long long)
89 LONG32 -- 32-bit type, traditionally long89 LONG32 -- 32-bit type, traditionally long
90 QUAD -- 64-bit type, always long long90 QUAD -- 64-bit type, traditionally long long
91 WORD -- natural type of __WORDSIZE bits (int or long)91 WORD -- natural type of __WORDSIZE bits (int or long)
92 LONGWORD -- type of __WORDSIZE bits, traditionally long92 LONGWORD -- type of __WORDSIZE bits, traditionally long
9393
...@@ -113,14 +113,14 @@ __extension__ typedef unsigned long long int __uintmax_t;...@@ -113,14 +113,14 @@ __extension__ typedef unsigned long long int __uintmax_t;
113#define __SLONGWORD_TYPE long int113#define __SLONGWORD_TYPE long int
114#define __ULONGWORD_TYPE unsigned long int114#define __ULONGWORD_TYPE unsigned long int
115#if __WORDSIZE == 32115#if __WORDSIZE == 32
116# define __SQUAD_TYPE __quad_t116# define __SQUAD_TYPE __int64_t
117# define __UQUAD_TYPE __u_quad_t117# define __UQUAD_TYPE __uint64_t
118# define __SWORD_TYPE int118# define __SWORD_TYPE int
119# define __UWORD_TYPE unsigned int119# define __UWORD_TYPE unsigned int
120# define __SLONG32_TYPE long int120# define __SLONG32_TYPE long int
121# define __ULONG32_TYPE unsigned long int121# define __ULONG32_TYPE unsigned long int
122# define __S64_TYPE __quad_t122# define __S64_TYPE __int64_t
123# define __U64_TYPE __u_quad_t123# define __U64_TYPE __uint64_t
124/* We want __extension__ before typedef's that use nonstandard base types124/* We want __extension__ before typedef's that use nonstandard base types
125 such as `long long' in C89 mode. */125 such as `long long' in C89 mode. */
126# define __STD_TYPE __extension__ typedef126# define __STD_TYPE __extension__ typedef
...@@ -213,10 +213,13 @@ __STD_TYPE __U32_TYPE __socklen_t;...@@ -213,10 +213,13 @@ __STD_TYPE __U32_TYPE __socklen_t;
213 It is not currently necessary for this to be machine-specific. */213 It is not currently necessary for this to be machine-specific. */
214typedef int __sig_atomic_t;214typedef int __sig_atomic_t;
215215
216#if __TIMESIZE == 64216/* Seconds since the Epoch, visible to user code when time_t is too
217 narrow only for consistency with the old way of widening too-narrow
218 types. User code should never use __time64_t. */
219#if __TIMESIZE == 64 && defined __LIBC
217# define __time64_t __time_t220# define __time64_t __time_t
218#else221#elif __TIMESIZE != 64
219__STD_TYPE __TIME64_T_TYPE __time64_t; /* Seconds since the Epoch. */222__STD_TYPE __TIME64_T_TYPE __time64_t;
220#endif223#endif
221224
222#undef __STD_TYPE225#undef __STD_TYPE
lib/libc/include/generic-glibc/bits/types/struct_statx.h created+55
...@@ -0,0 +1,55 @@
1/* Definition of the generic version of struct statx.
2 Copyright (C) 2018-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _SYS_STAT_H
20# error Never include <bits/types/struct_statx.h> directly, include <sys/stat.h> instead.
21#endif
22
23#ifndef __statx_defined
24#define __statx_defined 1
25
26/* Warning: The kernel may add additional fields to this struct in the
27 future. Only use this struct for calling the statx function, not
28 for storing data. (Expansion will be controlled by the mask
29 argument of the statx function.) */
30struct statx
31{
32 __uint32_t stx_mask;
33 __uint32_t stx_blksize;
34 __uint64_t stx_attributes;
35 __uint32_t stx_nlink;
36 __uint32_t stx_uid;
37 __uint32_t stx_gid;
38 __uint16_t stx_mode;
39 __uint16_t __statx_pad1[1];
40 __uint64_t stx_ino;
41 __uint64_t stx_size;
42 __uint64_t stx_blocks;
43 __uint64_t stx_attributes_mask;
44 struct statx_timestamp stx_atime;
45 struct statx_timestamp stx_btime;
46 struct statx_timestamp stx_ctime;
47 struct statx_timestamp stx_mtime;
48 __uint32_t stx_rdev_major;
49 __uint32_t stx_rdev_minor;
50 __uint32_t stx_dev_major;
51 __uint32_t stx_dev_minor;
52 __uint64_t __statx_pad2[14];
53};
54
55#endif /* __statx_defined */
\ No newline at end of file
lib/libc/include/generic-glibc/bits/types/struct_statx_timestamp.h created+33
...@@ -0,0 +1,33 @@
1/* Definition of the generic version of struct statx_timestamp.
2 Copyright (C) 2018-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _SYS_STAT_H
20# error Never include <bits/types/struct_statx_timestamp.h> directly, include <sys/stat.h> instead.
21#endif
22
23#ifndef __statx_timestamp_defined
24#define __statx_timestamp_defined 1
25
26struct statx_timestamp
27{
28 __int64_t tv_sec;
29 __uint32_t tv_nsec;
30 __int32_t __statx_timestamp_pad1[1];
31};
32
33#endif /* __statx_timestamp_defined */
\ No newline at end of file
lib/libc/include/generic-glibc/bits/xtitypes.h deleted-33
...@@ -1,33 +0,0 @@
1/* bits/xtitypes.h -- Define some types used by <bits/stropts.h>. Generic.
2 Copyright (C) 2002-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _STROPTS_H
20# error "Never include <bits/xtitypes.h> directly; use <stropts.h> instead."
21#endif
22
23#ifndef _BITS_XTITYPES_H
24#define _BITS_XTITYPES_H 1
25
26#include <bits/types.h>
27
28/* This type is used by some structs in <bits/stropts.h>. */
29typedef __SLONGWORD_TYPE __t_scalar_t;
30typedef __ULONGWORD_TYPE __t_uscalar_t;
31
32
33#endif /* bits/xtitypes.h */
\ No newline at end of file
lib/libc/include/generic-glibc/dirent.h+2
...@@ -401,4 +401,6 @@ extern int versionsort64 (const struct dirent64 **__e1,...@@ -401,4 +401,6 @@ extern int versionsort64 (const struct dirent64 **__e1,
401401
402__END_DECLS402__END_DECLS
403403
404#include <bits/dirent_ext.h>
405
404#endif /* dirent.h */406#endif /* dirent.h */
\ No newline at end of file
lib/libc/include/generic-glibc/dlfcn.h+12
...@@ -180,7 +180,19 @@ typedef struct...@@ -180,7 +180,19 @@ typedef struct
180{180{
181 size_t dls_size; /* Size in bytes of the whole buffer. */181 size_t dls_size; /* Size in bytes of the whole buffer. */
182 unsigned int dls_cnt; /* Number of elements in `dls_serpath'. */182 unsigned int dls_cnt; /* Number of elements in `dls_serpath'. */
183# if __GNUC_PREREQ (3, 0)
184 /* The zero-length array avoids an unwanted array subscript check by
185 the compiler, while the surrounding anonymous union preserves the
186 historic size of the type. At the time of writing, GNU C does
187 not support structs with flexible array members in unions. */
188 __extension__ union
189 {
190 Dl_serpath dls_serpath[0]; /* Actually longer, dls_cnt elements. */
191 Dl_serpath __dls_serpath_pad[1];
192 };
193# else
183 Dl_serpath dls_serpath[1]; /* Actually longer, dls_cnt elements. */194 Dl_serpath dls_serpath[1]; /* Actually longer, dls_cnt elements. */
195# endif
184} Dl_serinfo;196} Dl_serinfo;
185#endif /* __USE_GNU */197#endif /* __USE_GNU */
186198
lib/libc/include/generic-glibc/elf.h+30-2
...@@ -360,7 +360,7 @@ typedef struct...@@ -360,7 +360,7 @@ typedef struct
360#define EM_RISCV 243 /* RISC-V */360#define EM_RISCV 243 /* RISC-V */
361361
362#define EM_BPF 247 /* Linux BPF -- in-kernel virtual machine */362#define EM_BPF 247 /* Linux BPF -- in-kernel virtual machine */
363#define EM_CSKY 252 /* C_SKY */363#define EM_CSKY 252 /* C-SKY */
364364
365#define EM_NUM 253365#define EM_NUM 253
366366
...@@ -809,9 +809,16 @@ typedef struct...@@ -809,9 +809,16 @@ typedef struct
809#define NT_ARM_SYSTEM_CALL 0x404 /* ARM system call number */809#define NT_ARM_SYSTEM_CALL 0x404 /* ARM system call number */
810#define NT_ARM_SVE 0x405 /* ARM Scalable Vector Extension810#define NT_ARM_SVE 0x405 /* ARM Scalable Vector Extension
811 registers */811 registers */
812#define NT_ARM_PAC_MASK 0x406 /* ARM pointer authentication
813 code masks. */
814#define NT_ARM_PACA_KEYS 0x407 /* ARM pointer authentication
815 address keys. */
816#define NT_ARM_PACG_KEYS 0x408 /* ARM pointer authentication
817 generic key. */
812#define NT_VMCOREDD 0x700 /* Vmcore Device Dump Note. */818#define NT_VMCOREDD 0x700 /* Vmcore Device Dump Note. */
813#define NT_MIPS_DSP 0x800 /* MIPS DSP ASE registers. */819#define NT_MIPS_DSP 0x800 /* MIPS DSP ASE registers. */
814#define NT_MIPS_FP_MODE 0x801 /* MIPS floating-point mode. */820#define NT_MIPS_FP_MODE 0x801 /* MIPS floating-point mode. */
821#define NT_MIPS_MSA 0x802 /* MIPS SIMD registers. */
815822
816/* Legal values for the note segment descriptor types for object files. */823/* Legal values for the note segment descriptor types for object files. */
817824
...@@ -987,6 +994,9 @@ typedef struct...@@ -987,6 +994,9 @@ typedef struct
987#define DF_1_SINGLETON 0x02000000 /* Singleton symbols are used. */994#define DF_1_SINGLETON 0x02000000 /* Singleton symbols are used. */
988#define DF_1_STUB 0x04000000995#define DF_1_STUB 0x04000000
989#define DF_1_PIE 0x08000000996#define DF_1_PIE 0x08000000
997#define DF_1_KMOD 0x10000000
998#define DF_1_WEAKFILTER 0x20000000
999#define DF_1_NOCOMMON 0x40000000
9901000
991/* Flags for the feature selection in DT_FEATURE_1. */1001/* Flags for the feature selection in DT_FEATURE_1. */
992#define DTF_1_PARINIT 0x000000011002#define DTF_1_PARINIT 0x00000001
...@@ -2854,6 +2864,13 @@ enum...@@ -2854,6 +2864,13 @@ enum
2854#define R_AARCH64_TLSDESC 1031 /* TLS Descriptor. */2864#define R_AARCH64_TLSDESC 1031 /* TLS Descriptor. */
2855#define R_AARCH64_IRELATIVE 1032 /* STT_GNU_IFUNC relocation. */2865#define R_AARCH64_IRELATIVE 1032 /* STT_GNU_IFUNC relocation. */
28562866
2867/* AArch64 specific values for the Dyn d_tag field. */
2868#define DT_AARCH64_VARIANT_PCS (DT_LOPROC + 5)
2869#define DT_AARCH64_NUM 6
2870
2871/* AArch64 specific values for the st_other field. */
2872#define STO_AARCH64_VARIANT_PCS 0x80
2873
2857/* ARM relocs. */2874/* ARM relocs. */
28582875
2859#define R_ARM_NONE 0 /* No reloc */2876#define R_ARM_NONE 0 /* No reloc */
...@@ -3022,7 +3039,7 @@ enum...@@ -3022,7 +3039,7 @@ enum
3022/* Keep this the last entry. */3039/* Keep this the last entry. */
3023#define R_ARM_NUM 2563040#define R_ARM_NUM 256
30243041
3025/* csky */3042/* C-SKY */
3026#define R_CKCORE_NONE 0 /* no reloc */3043#define R_CKCORE_NONE 0 /* no reloc */
3027#define R_CKCORE_ADDR32 1 /* direct 32 bit (S + A) */3044#define R_CKCORE_ADDR32 1 /* direct 32 bit (S + A) */
3028#define R_CKCORE_PCRELIMM8BY4 2 /* disp ((S + A - P) >> 2) & 0xff */3045#define R_CKCORE_PCRELIMM8BY4 2 /* disp ((S + A - P) >> 2) & 0xff */
...@@ -3086,6 +3103,17 @@ enum...@@ -3086,6 +3103,17 @@ enum
3086#define R_CKCORE_TLS_DTPOFF32 573103#define R_CKCORE_TLS_DTPOFF32 57
3087#define R_CKCORE_TLS_TPOFF32 583104#define R_CKCORE_TLS_TPOFF32 58
30883105
3106/* C-SKY elf header definition. */
3107#define EF_CSKY_ABIMASK 0XF0000000
3108#define EF_CSKY_OTHER 0X0FFF0000
3109#define EF_CSKY_PROCESSOR 0X0000FFFF
3110
3111#define EF_CSKY_ABIV1 0X10000000
3112#define EF_CSKY_ABIV2 0X20000000
3113
3114/* C-SKY attributes section. */
3115#define SHT_CSKY_ATTRIBUTES (SHT_LOPROC + 1)
3116
3089/* IA-64 specific declarations. */3117/* IA-64 specific declarations. */
30903118
3091/* Processor specific flags for the Ehdr e_flags field. */3119/* Processor specific flags for the Ehdr e_flags field. */
lib/libc/include/generic-glibc/features.h+1-1
...@@ -439,7 +439,7 @@...@@ -439,7 +439,7 @@
439/* Major and minor version number of the GNU C library package. Use439/* Major and minor version number of the GNU C library package. Use
440 these macros to test for features in specific releases. */440 these macros to test for features in specific releases. */
441#define __GLIBC__ 2441#define __GLIBC__ 2
442#define __GLIBC_MINOR__ 29442#define __GLIBC_MINOR__ 30
443443
444#define __GLIBC_PREREQ(maj, min) \444#define __GLIBC_PREREQ(maj, min) \
445 ((__GLIBC__ << 16) + __GLIBC_MINOR__ >= ((maj) << 16) + (min))445 ((__GLIBC__ << 16) + __GLIBC_MINOR__ >= ((maj) << 16) + (min))
lib/libc/include/generic-glibc/finclude/math-vector-fortran.h created+19
...@@ -0,0 +1,19 @@
1! Platform-specific declarations of SIMD math functions for Fortran. -*- f90 -*-
2! Copyright (C) 2019 Free Software Foundation, Inc.
3! This file is part of the GNU C Library.
4!
5! The GNU C Library is free software; you can redistribute it and/or
6! modify it under the terms of the GNU Lesser General Public
7! License as published by the Free Software Foundation; either
8! version 2.1 of the License, or (at your option) any later version.
9!
10! The GNU C Library is distributed in the hope that it will be useful,
11! but WITHOUT ANY WARRANTY; without even the implied warranty of
12! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13! Lesser General Public License for more details.
14!
15! You should have received a copy of the GNU Lesser General Public
16! License along with the GNU C Library; if not, see
17! <http://www.gnu.org/licenses/>.
18
19! No SIMD math functions are available for this platform.
\ No newline at end of file
lib/libc/include/generic-glibc/gconv.h+2-9
...@@ -86,6 +86,8 @@ struct __gconv_step...@@ -86,6 +86,8 @@ struct __gconv_step
86 struct __gconv_loaded_object *__shlib_handle;86 struct __gconv_loaded_object *__shlib_handle;
87 const char *__modname;87 const char *__modname;
8888
89 /* For internal use by glibc. (Accesses to this member must occur
90 when the internal __gconv_lock mutex is acquired). */
89 int __counter;91 int __counter;
9092
91 char *__from_name;93 char *__from_name;
...@@ -142,13 +144,4 @@ typedef struct __gconv_info...@@ -142,13 +144,4 @@ typedef struct __gconv_info
142 __extension__ struct __gconv_step_data __data[0];144 __extension__ struct __gconv_step_data __data[0];
143} *__gconv_t;145} *__gconv_t;
144146
145/* Transliteration using the locale's data. */
146extern int __gconv_transliterate (struct __gconv_step *step,
147 struct __gconv_step_data *step_data,
148 const unsigned char *inbufstart,
149 const unsigned char **inbufp,
150 const unsigned char *inbufend,
151 unsigned char **outbufstart,
152 size_t *irreversible);
153
154#endif /* gconv.h */147#endif /* gconv.h */
\ No newline at end of file
lib/libc/include/generic-glibc/gnu/stubs-32.h-2
...@@ -8,9 +8,7 @@...@@ -8,9 +8,7 @@
8#endif8#endif
99
10#define __stub_chflags10#define __stub_chflags
11#define __stub_fattach
12#define __stub_fchflags11#define __stub_fchflags
13#define __stub_fdetach
14#define __stub_gtty12#define __stub_gtty
15#define __stub_lchmod13#define __stub_lchmod
16#define __stub_revoke14#define __stub_revoke
lib/libc/include/generic-glibc/gnu/stubs-64.h created+18
...@@ -0,0 +1,18 @@
1/* This file is automatically generated.
2 It defines a symbol `__stub_FUNCTION' for each function
3 in the C library which is a stub, meaning it will fail
4 every time called, usually setting errno to ENOSYS. */
5
6#ifdef _LIBC
7 #error Applications may not define the macro _LIBC
8#endif
9
10#define __stub_chflags
11#define __stub_fchflags
12#define __stub_gtty
13#define __stub_lchmod
14#define __stub_revoke
15#define __stub_setlogin
16#define __stub_sigreturn
17#define __stub_sstk
18#define __stub_stty
\ No newline at end of file
lib/libc/include/generic-glibc/gnu/stubs-hard.h-6
...@@ -11,15 +11,9 @@...@@ -11,15 +11,9 @@
11#define __stub___compat_get_kernel_syms11#define __stub___compat_get_kernel_syms
12#define __stub___compat_query_module12#define __stub___compat_query_module
13#define __stub_chflags13#define __stub_chflags
14#define __stub_fattach
15#define __stub_fchflags14#define __stub_fchflags
16#define __stub_fdetach
17#define __stub_getmsg
18#define __stub_getpmsg
19#define __stub_gtty15#define __stub_gtty
20#define __stub_lchmod16#define __stub_lchmod
21#define __stub_putmsg
22#define __stub_putpmsg
23#define __stub_revoke17#define __stub_revoke
24#define __stub_setlogin18#define __stub_setlogin
25#define __stub_sigreturn19#define __stub_sigreturn
lib/libc/include/generic-glibc/gnu/stubs-n32_hard.h-2
...@@ -10,9 +10,7 @@...@@ -10,9 +10,7 @@
10#define __stub___compat_bdflush10#define __stub___compat_bdflush
11#define __stub___compat_uselib11#define __stub___compat_uselib
12#define __stub_chflags12#define __stub_chflags
13#define __stub_fattach
14#define __stub_fchflags13#define __stub_fchflags
15#define __stub_fdetach
16#define __stub_gtty14#define __stub_gtty
17#define __stub_lchmod15#define __stub_lchmod
18#define __stub_revoke16#define __stub_revoke
lib/libc/include/generic-glibc/gnu/stubs-n64_hard.h-2
...@@ -10,9 +10,7 @@...@@ -10,9 +10,7 @@
10#define __stub___compat_bdflush10#define __stub___compat_bdflush
11#define __stub___compat_uselib11#define __stub___compat_uselib
12#define __stub_chflags12#define __stub_chflags
13#define __stub_fattach
14#define __stub_fchflags13#define __stub_fchflags
15#define __stub_fdetach
16#define __stub_gtty14#define __stub_gtty
17#define __stub_lchmod15#define __stub_lchmod
18#define __stub_revoke16#define __stub_revoke
lib/libc/include/generic-glibc/gnu/stubs-o32_hard.h-2
...@@ -8,9 +8,7 @@...@@ -8,9 +8,7 @@
8#endif8#endif
99
10#define __stub_chflags10#define __stub_chflags
11#define __stub_fattach
12#define __stub_fchflags11#define __stub_fchflags
13#define __stub_fdetach
14#define __stub_gtty12#define __stub_gtty
15#define __stub_lchmod13#define __stub_lchmod
16#define __stub_revoke14#define __stub_revoke
lib/libc/include/generic-glibc/gnu/stubs-soft.h-6
...@@ -11,15 +11,9 @@...@@ -11,15 +11,9 @@
11#define __stub___compat_get_kernel_syms11#define __stub___compat_get_kernel_syms
12#define __stub___compat_query_module12#define __stub___compat_query_module
13#define __stub_chflags13#define __stub_chflags
14#define __stub_fattach
15#define __stub_fchflags14#define __stub_fchflags
16#define __stub_fdetach
17#define __stub_getmsg
18#define __stub_getpmsg
19#define __stub_gtty15#define __stub_gtty
20#define __stub_lchmod16#define __stub_lchmod
21#define __stub_putmsg
22#define __stub_putpmsg
23#define __stub_revoke17#define __stub_revoke
24#define __stub_setlogin18#define __stub_setlogin
25#define __stub_sigreturn19#define __stub_sigreturn
lib/libc/include/generic-glibc/malloc.h+10-10
...@@ -35,11 +35,12 @@...@@ -35,11 +35,12 @@
35__BEGIN_DECLS35__BEGIN_DECLS
3636
37/* Allocate SIZE bytes of memory. */37/* Allocate SIZE bytes of memory. */
38extern void *malloc (size_t __size) __THROW __attribute_malloc__ __wur;38extern void *malloc (size_t __size) __THROW __attribute_malloc__
39 __attribute_alloc_size__ ((1)) __wur;
3940
40/* Allocate NMEMB elements of SIZE bytes each, all initialized to 0. */41/* Allocate NMEMB elements of SIZE bytes each, all initialized to 0. */
41extern void *calloc (size_t __nmemb, size_t __size)42extern void *calloc (size_t __nmemb, size_t __size)
42__THROW __attribute_malloc__ __wur;43__THROW __attribute_malloc__ __attribute_alloc_size__ ((1, 2)) __wur;
4344
44/* Re-allocate the previously allocated block in __ptr, making the new45/* Re-allocate the previously allocated block in __ptr, making the new
45 block SIZE bytes long. */46 block SIZE bytes long. */
...@@ -47,7 +48,7 @@ __THROW __attribute_malloc__ __wur;...@@ -47,7 +48,7 @@ __THROW __attribute_malloc__ __wur;
47 the same pointer that was passed to it, aliasing needs to be allowed48 the same pointer that was passed to it, aliasing needs to be allowed
48 between objects pointed by the old and new pointers. */49 between objects pointed by the old and new pointers. */
49extern void *realloc (void *__ptr, size_t __size)50extern void *realloc (void *__ptr, size_t __size)
50__THROW __attribute_warn_unused_result__;51__THROW __attribute_warn_unused_result__ __attribute_alloc_size__ ((2));
5152
52/* Re-allocate the previously allocated block in PTR, making the new53/* Re-allocate the previously allocated block in PTR, making the new
53 block large enough for NMEMB elements of SIZE bytes each. */54 block large enough for NMEMB elements of SIZE bytes each. */
...@@ -55,21 +56,23 @@ __THROW __attribute_warn_unused_result__;...@@ -55,21 +56,23 @@ __THROW __attribute_warn_unused_result__;
55 the same pointer that was passed to it, aliasing needs to be allowed56 the same pointer that was passed to it, aliasing needs to be allowed
56 between objects pointed by the old and new pointers. */57 between objects pointed by the old and new pointers. */
57extern void *reallocarray (void *__ptr, size_t __nmemb, size_t __size)58extern void *reallocarray (void *__ptr, size_t __nmemb, size_t __size)
58__THROW __attribute_warn_unused_result__;59__THROW __attribute_warn_unused_result__ __attribute_alloc_size__ ((2, 3));
5960
60/* Free a block allocated by `malloc', `realloc' or `calloc'. */61/* Free a block allocated by `malloc', `realloc' or `calloc'. */
61extern void free (void *__ptr) __THROW;62extern void free (void *__ptr) __THROW;
6263
63/* Allocate SIZE bytes allocated to ALIGNMENT bytes. */64/* Allocate SIZE bytes allocated to ALIGNMENT bytes. */
64extern void *memalign (size_t __alignment, size_t __size)65extern void *memalign (size_t __alignment, size_t __size)
65__THROW __attribute_malloc__ __wur;66__THROW __attribute_malloc__ __attribute_alloc_size__ ((2)) __wur;
6667
67/* Allocate SIZE bytes on a page boundary. */68/* Allocate SIZE bytes on a page boundary. */
68extern void *valloc (size_t __size) __THROW __attribute_malloc__ __wur;69extern void *valloc (size_t __size) __THROW __attribute_malloc__
70 __attribute_alloc_size__ ((1)) __wur;
6971
70/* Equivalent to valloc(minimum-page-that-holds(n)), that is, round up72/* Equivalent to valloc(minimum-page-that-holds(n)), that is, round up
71 __size to nearest pagesize. */73 __size to nearest pagesize. */
72extern void *pvalloc (size_t __size) __THROW __attribute_malloc__ __wur;74extern void *pvalloc (size_t __size) __THROW __attribute_malloc__
75 __attribute_alloc_size__ ((1)) __wur;
7376
74/* Underlying allocation function; successive calls should return77/* Underlying allocation function; successive calls should return
75 contiguous pieces of memory. */78 contiguous pieces of memory. */
...@@ -156,9 +159,6 @@ extern void *(*__MALLOC_HOOK_VOLATILE __memalign_hook)(size_t __alignment,...@@ -156,9 +159,6 @@ extern void *(*__MALLOC_HOOK_VOLATILE __memalign_hook)(size_t __alignment,
156__MALLOC_DEPRECATED;159__MALLOC_DEPRECATED;
157extern void (*__MALLOC_HOOK_VOLATILE __after_morecore_hook) (void);160extern void (*__MALLOC_HOOK_VOLATILE __after_morecore_hook) (void);
158161
159/* Activate a standard set of debugging hooks. */
160extern void __malloc_check_init (void) __THROW __MALLOC_DEPRECATED;
161
162162
163__END_DECLS163__END_DECLS
164#endif /* malloc.h */164#endif /* malloc.h */
\ No newline at end of file
lib/libc/include/generic-glibc/math.h+11-6
...@@ -874,7 +874,8 @@ enum...@@ -874,7 +874,8 @@ enum
874 the __SUPPORT_SNAN__ check may be skipped for those versions. */874 the __SUPPORT_SNAN__ check may be skipped for those versions. */
875875
876/* Return number of classification appropriate for X. */876/* Return number of classification appropriate for X. */
877# if __GNUC_PREREQ (4,4) && !defined __SUPPORT_SNAN__ \877# if ((__GNUC_PREREQ (4,4) && !defined __SUPPORT_SNAN__) \
878 || __glibc_clang_prereq (2,8)) \
878 && (!defined __OPTIMIZE_SIZE__ || defined __cplusplus)879 && (!defined __OPTIMIZE_SIZE__ || defined __cplusplus)
879 /* The check for __cplusplus allows the use of the builtin, even880 /* The check for __cplusplus allows the use of the builtin, even
880 when optimization for size is on. This is provided for881 when optimization for size is on. This is provided for
...@@ -889,7 +890,7 @@ enum...@@ -889,7 +890,7 @@ enum
889# endif890# endif
890891
891/* Return nonzero value if sign of X is negative. */892/* Return nonzero value if sign of X is negative. */
892# if __GNUC_PREREQ (6,0)893# if __GNUC_PREREQ (6,0) || __glibc_clang_prereq (3,3)
893# define signbit(x) __builtin_signbit (x)894# define signbit(x) __builtin_signbit (x)
894# elif defined __cplusplus895# elif defined __cplusplus
895 /* In C++ mode, __MATH_TG cannot be used, because it relies on896 /* In C++ mode, __MATH_TG cannot be used, because it relies on
...@@ -907,14 +908,16 @@ enum...@@ -907,14 +908,16 @@ enum
907# endif908# endif
908909
909/* Return nonzero value if X is not +-Inf or NaN. */910/* Return nonzero value if X is not +-Inf or NaN. */
910# if __GNUC_PREREQ (4,4) && !defined __SUPPORT_SNAN__911# if (__GNUC_PREREQ (4,4) && !defined __SUPPORT_SNAN__) \
912 || __glibc_clang_prereq (2,8)
911# define isfinite(x) __builtin_isfinite (x)913# define isfinite(x) __builtin_isfinite (x)
912# else914# else
913# define isfinite(x) __MATH_TG ((x), __finite, (x))915# define isfinite(x) __MATH_TG ((x), __finite, (x))
914# endif916# endif
915917
916/* Return nonzero value if X is neither zero, subnormal, Inf, nor NaN. */918/* Return nonzero value if X is neither zero, subnormal, Inf, nor NaN. */
917# if __GNUC_PREREQ (4,4) && !defined __SUPPORT_SNAN__919# if (__GNUC_PREREQ (4,4) && !defined __SUPPORT_SNAN__) \
920 || __glibc_clang_prereq (2,8)
918# define isnormal(x) __builtin_isnormal (x)921# define isnormal(x) __builtin_isnormal (x)
919# else922# else
920# define isnormal(x) (fpclassify (x) == FP_NORMAL)923# define isnormal(x) (fpclassify (x) == FP_NORMAL)
...@@ -922,7 +925,8 @@ enum...@@ -922,7 +925,8 @@ enum
922925
923/* Return nonzero value if X is a NaN. We could use `fpclassify' but926/* Return nonzero value if X is a NaN. We could use `fpclassify' but
924 we already have this functions `__isnan' and it is faster. */927 we already have this functions `__isnan' and it is faster. */
925# if __GNUC_PREREQ (4,4) && !defined __SUPPORT_SNAN__928# if (__GNUC_PREREQ (4,4) && !defined __SUPPORT_SNAN__) \
929 || __glibc_clang_prereq (2,8)
926# define isnan(x) __builtin_isnan (x)930# define isnan(x) __builtin_isnan (x)
927# else931# else
928# define isnan(x) __MATH_TG ((x), __isnan, (x))932# define isnan(x) __MATH_TG ((x), __isnan, (x))
...@@ -939,7 +943,8 @@ enum...@@ -939,7 +943,8 @@ enum
939# define isinf(x) \943# define isinf(x) \
940 (__builtin_types_compatible_p (__typeof (x), _Float128) \944 (__builtin_types_compatible_p (__typeof (x), _Float128) \
941 ? __isinff128 (x) : __builtin_isinf_sign (x))945 ? __isinff128 (x) : __builtin_isinf_sign (x))
942# elif __GNUC_PREREQ (4,4) && !defined __SUPPORT_SNAN__946# elif (__GNUC_PREREQ (4,4) && !defined __SUPPORT_SNAN__) \
947 || __glibc_clang_prereq (3,7)
943# define isinf(x) __builtin_isinf_sign (x)948# define isinf(x) __builtin_isinf_sign (x)
944# else949# else
945# define isinf(x) __MATH_TG ((x), __isinf, (x))950# define isinf(x) __MATH_TG ((x), __isinf, (x))
lib/libc/include/generic-glibc/netinet/igmp.h+1
...@@ -86,6 +86,7 @@ struct igmp {...@@ -86,6 +86,7 @@ struct igmp {
8686
87#define IGMP_MTRACE_RESP 0x1e /* traceroute resp.(to sender)*/87#define IGMP_MTRACE_RESP 0x1e /* traceroute resp.(to sender)*/
88#define IGMP_MTRACE 0x1f /* mcast traceroute messages */88#define IGMP_MTRACE 0x1f /* mcast traceroute messages */
89#define IGMP_MRDISC_ADV 0x30 /* From RFC4286. */
8990
90#define IGMP_MAX_HOST_REPORT_DELAY 10 /* max delay for response to */91#define IGMP_MAX_HOST_REPORT_DELAY 10 /* max delay for response to */
91 /* query (in seconds) according */92 /* query (in seconds) according */
lib/libc/include/generic-glibc/netinet/in.h+1
...@@ -204,6 +204,7 @@ enum...@@ -204,6 +204,7 @@ enum
204#define INADDR_UNSPEC_GROUP ((in_addr_t) 0xe0000000) /* 224.0.0.0 */204#define INADDR_UNSPEC_GROUP ((in_addr_t) 0xe0000000) /* 224.0.0.0 */
205#define INADDR_ALLHOSTS_GROUP ((in_addr_t) 0xe0000001) /* 224.0.0.1 */205#define INADDR_ALLHOSTS_GROUP ((in_addr_t) 0xe0000001) /* 224.0.0.1 */
206#define INADDR_ALLRTRS_GROUP ((in_addr_t) 0xe0000002) /* 224.0.0.2 */206#define INADDR_ALLRTRS_GROUP ((in_addr_t) 0xe0000002) /* 224.0.0.2 */
207#define INADDR_ALLSNOOPERS_GROUP ((in_addr_t) 0xe000006a) /* 224.0.0.106 */
207#define INADDR_MAX_LOCAL_GROUP ((in_addr_t) 0xe00000ff) /* 224.0.0.255 */208#define INADDR_MAX_LOCAL_GROUP ((in_addr_t) 0xe00000ff) /* 224.0.0.255 */
208209
209#if !__USE_KERNEL_IPV6_DEFS210#if !__USE_KERNEL_IPV6_DEFS
lib/libc/include/generic-glibc/netinet/udp.h+1
...@@ -82,6 +82,7 @@ struct udphdr...@@ -82,6 +82,7 @@ struct udphdr
82#define UDP_NO_CHECK6_RX 102 /* Disable accepting checksum for UDP82#define UDP_NO_CHECK6_RX 102 /* Disable accepting checksum for UDP
83 over IPv6. */83 over IPv6. */
84#define UDP_SEGMENT 103 /* Set GSO segmentation size. */84#define UDP_SEGMENT 103 /* Set GSO segmentation size. */
85#define UDP_GRO 104 /* This socket can receive UDP GRO packets. */
8586
86/* UDP encapsulation types */87/* UDP encapsulation types */
87#define UDP_ENCAP_ESPINUDP_NON_IKE 1 /* draft-ietf-ipsec-nat-t-ike-00/01 */88#define UDP_ENCAP_ESPINUDP_NON_IKE 1 /* draft-ietf-ipsec-nat-t-ike-00/01 */
lib/libc/include/generic-glibc/pthread.h+36
...@@ -770,6 +770,13 @@ extern int pthread_mutex_timedlock (pthread_mutex_t *__restrict __mutex,...@@ -770,6 +770,13 @@ extern int pthread_mutex_timedlock (pthread_mutex_t *__restrict __mutex,
770 __abstime) __THROWNL __nonnull ((1, 2));770 __abstime) __THROWNL __nonnull ((1, 2));
771#endif771#endif
772772
773#ifdef __USE_GNU
774extern int pthread_mutex_clocklock (pthread_mutex_t *__restrict __mutex,
775 clockid_t __clockid,
776 const struct timespec *__restrict
777 __abstime) __THROWNL __nonnull ((1, 3));
778#endif
779
773/* Unlock a mutex. */780/* Unlock a mutex. */
774extern int pthread_mutex_unlock (pthread_mutex_t *__mutex)781extern int pthread_mutex_unlock (pthread_mutex_t *__mutex)
775 __THROWNL __nonnull ((1));782 __THROWNL __nonnull ((1));
...@@ -909,6 +916,13 @@ extern int pthread_rwlock_timedrdlock (pthread_rwlock_t *__restrict __rwlock,...@@ -909,6 +916,13 @@ extern int pthread_rwlock_timedrdlock (pthread_rwlock_t *__restrict __rwlock,
909 __abstime) __THROWNL __nonnull ((1, 2));916 __abstime) __THROWNL __nonnull ((1, 2));
910# endif917# endif
911918
919# ifdef __USE_GNU
920extern int pthread_rwlock_clockrdlock (pthread_rwlock_t *__restrict __rwlock,
921 clockid_t __clockid,
922 const struct timespec *__restrict
923 __abstime) __THROWNL __nonnull ((1, 3));
924# endif
925
912/* Acquire write lock for RWLOCK. */926/* Acquire write lock for RWLOCK. */
913extern int pthread_rwlock_wrlock (pthread_rwlock_t *__rwlock)927extern int pthread_rwlock_wrlock (pthread_rwlock_t *__rwlock)
914 __THROWNL __nonnull ((1));928 __THROWNL __nonnull ((1));
...@@ -924,6 +938,13 @@ extern int pthread_rwlock_timedwrlock (pthread_rwlock_t *__restrict __rwlock,...@@ -924,6 +938,13 @@ extern int pthread_rwlock_timedwrlock (pthread_rwlock_t *__restrict __rwlock,
924 __abstime) __THROWNL __nonnull ((1, 2));938 __abstime) __THROWNL __nonnull ((1, 2));
925# endif939# endif
926940
941# ifdef __USE_GNU
942extern int pthread_rwlock_clockwrlock (pthread_rwlock_t *__restrict __rwlock,
943 clockid_t __clockid,
944 const struct timespec *__restrict
945 __abstime) __THROWNL __nonnull ((1, 3));
946# endif
947
927/* Unlock RWLOCK. */948/* Unlock RWLOCK. */
928extern int pthread_rwlock_unlock (pthread_rwlock_t *__rwlock)949extern int pthread_rwlock_unlock (pthread_rwlock_t *__rwlock)
929 __THROWNL __nonnull ((1));950 __THROWNL __nonnull ((1));
...@@ -1003,6 +1024,21 @@ extern int pthread_cond_timedwait (pthread_cond_t *__restrict __cond,...@@ -1003,6 +1024,21 @@ extern int pthread_cond_timedwait (pthread_cond_t *__restrict __cond,
1003 const struct timespec *__restrict __abstime)1024 const struct timespec *__restrict __abstime)
1004 __nonnull ((1, 2, 3));1025 __nonnull ((1, 2, 3));
10051026
1027# ifdef __USE_GNU
1028/* Wait for condition variable COND to be signaled or broadcast until
1029 ABSTIME measured by the specified clock. MUTEX is assumed to be
1030 locked before. CLOCK is the clock to use. ABSTIME is an absolute
1031 time specification against CLOCK's epoch.
1032
1033 This function is a cancellation point and therefore not marked with
1034 __THROW. */
1035extern int pthread_cond_clockwait (pthread_cond_t *__restrict __cond,
1036 pthread_mutex_t *__restrict __mutex,
1037 __clockid_t __clock_id,
1038 const struct timespec *__restrict __abstime)
1039 __nonnull ((1, 2, 4));
1040# endif
1041
1006/* Functions for handling condition variable attributes. */1042/* Functions for handling condition variable attributes. */
10071043
1008/* Initialize condition variable attribute ATTR. */1044/* Initialize condition variable attribute ATTR. */
lib/libc/include/generic-glibc/resolv.h-4
...@@ -115,11 +115,7 @@ struct res_sym {...@@ -115,11 +115,7 @@ struct res_sym {
115#define RES_DEFNAMES 0x00000080 /* use default domain name */115#define RES_DEFNAMES 0x00000080 /* use default domain name */
116#define RES_STAYOPEN 0x00000100 /* Keep TCP socket open */116#define RES_STAYOPEN 0x00000100 /* Keep TCP socket open */
117#define RES_DNSRCH 0x00000200 /* search up local domain tree */117#define RES_DNSRCH 0x00000200 /* search up local domain tree */
118#define RES_INSECURE1 0x00000400 /* type 1 security disabled */
119#define RES_INSECURE2 0x00000800 /* type 2 security disabled */
120#define RES_NOALIASES 0x00001000 /* shuts off HOSTALIASES feature */118#define RES_NOALIASES 0x00001000 /* shuts off HOSTALIASES feature */
121#define RES_USE_INET6 \
122 __glibc_macro_warning ("RES_USE_INET6 is deprecated") 0x00002000
123#define RES_ROTATE 0x00004000 /* rotate ns list after each query */119#define RES_ROTATE 0x00004000 /* rotate ns list after each query */
124#define RES_NOCHECKNAME \120#define RES_NOCHECKNAME \
125 __glibc_macro_warning ("RES_NOCHECKNAME is deprecated") 0x00008000121 __glibc_macro_warning ("RES_NOCHECKNAME is deprecated") 0x00008000
lib/libc/include/generic-glibc/search.h+7
...@@ -150,6 +150,13 @@ typedef void (*__action_fn_t) (const void *__nodep, VISIT __value,...@@ -150,6 +150,13 @@ typedef void (*__action_fn_t) (const void *__nodep, VISIT __value,
150extern void twalk (const void *__root, __action_fn_t __action);150extern void twalk (const void *__root, __action_fn_t __action);
151151
152#ifdef __USE_GNU152#ifdef __USE_GNU
153/* Like twalk, but pass down a closure parameter instead of the
154 level. */
155extern void twalk_r (const void *__root,
156 void (*) (const void *__nodep, VISIT __value,
157 void *__closure),
158 void *__closure);
159
153/* Callback type for function to free a tree node. If the keys are atomic160/* Callback type for function to free a tree node. If the keys are atomic
154 data this function should do nothing. */161 data this function should do nothing. */
155typedef void (*__free_fn_t) (void *__nodep);162typedef void (*__free_fn_t) (void *__nodep);
lib/libc/include/generic-glibc/semaphore.h+20-10
...@@ -33,24 +33,26 @@ __BEGIN_DECLS...@@ -33,24 +33,26 @@ __BEGIN_DECLS
33/* Initialize semaphore object SEM to VALUE. If PSHARED then share it33/* Initialize semaphore object SEM to VALUE. If PSHARED then share it
34 with other processes. */34 with other processes. */
35extern int sem_init (sem_t *__sem, int __pshared, unsigned int __value)35extern int sem_init (sem_t *__sem, int __pshared, unsigned int __value)
36 __THROW;36 __THROW __nonnull ((1));
37
37/* Free resources associated with semaphore object SEM. */38/* Free resources associated with semaphore object SEM. */
38extern int sem_destroy (sem_t *__sem) __THROW;39extern int sem_destroy (sem_t *__sem) __THROW __nonnull ((1));
3940
40/* Open a named semaphore NAME with open flags OFLAG. */41/* Open a named semaphore NAME with open flags OFLAG. */
41extern sem_t *sem_open (const char *__name, int __oflag, ...) __THROW;42extern sem_t *sem_open (const char *__name, int __oflag, ...)
43 __THROW __nonnull ((1));
4244
43/* Close descriptor for named semaphore SEM. */45/* Close descriptor for named semaphore SEM. */
44extern int sem_close (sem_t *__sem) __THROW;46extern int sem_close (sem_t *__sem) __THROW __nonnull ((1));
4547
46/* Remove named semaphore NAME. */48/* Remove named semaphore NAME. */
47extern int sem_unlink (const char *__name) __THROW;49extern int sem_unlink (const char *__name) __THROW __nonnull ((1));
4850
49/* Wait for SEM being posted.51/* Wait for SEM being posted.
5052
51 This function is a cancellation point and therefore not marked with53 This function is a cancellation point and therefore not marked with
52 __THROW. */54 __THROW. */
53extern int sem_wait (sem_t *__sem);55extern int sem_wait (sem_t *__sem) __nonnull ((1));
5456
55#ifdef __USE_XOPEN2K57#ifdef __USE_XOPEN2K
56/* Similar to `sem_wait' but wait only until ABSTIME.58/* Similar to `sem_wait' but wait only until ABSTIME.
...@@ -58,18 +60,26 @@ extern int sem_wait (sem_t *__sem);...@@ -58,18 +60,26 @@ extern int sem_wait (sem_t *__sem);
58 This function is a cancellation point and therefore not marked with60 This function is a cancellation point and therefore not marked with
59 __THROW. */61 __THROW. */
60extern int sem_timedwait (sem_t *__restrict __sem,62extern int sem_timedwait (sem_t *__restrict __sem,
61 const struct timespec *__restrict __abstime);63 const struct timespec *__restrict __abstime)
64 __nonnull ((1, 2));
65#endif
66
67#ifdef __USE_GNU
68extern int sem_clockwait (sem_t *__restrict __sem,
69 clockid_t clock,
70 const struct timespec *__restrict __abstime)
71 __nonnull ((1, 3));
62#endif72#endif
6373
64/* Test whether SEM is posted. */74/* Test whether SEM is posted. */
65extern int sem_trywait (sem_t *__sem) __THROWNL;75extern int sem_trywait (sem_t *__sem) __THROWNL __nonnull ((1));
6676
67/* Post SEM. */77/* Post SEM. */
68extern int sem_post (sem_t *__sem) __THROWNL;78extern int sem_post (sem_t *__sem) __THROWNL __nonnull ((1));
6979
70/* Get current value of SEM and store it in *SVAL. */80/* Get current value of SEM and store it in *SVAL. */
71extern int sem_getvalue (sem_t *__restrict __sem, int *__restrict __sval)81extern int sem_getvalue (sem_t *__restrict __sem, int *__restrict __sval)
72 __THROW;82 __THROW __nonnull ((1, 2));
7383
7484
75__END_DECLS85__END_DECLS
lib/libc/include/generic-glibc/signal.h+3
...@@ -370,6 +370,9 @@ extern int __libc_current_sigrtmax (void) __THROW;...@@ -370,6 +370,9 @@ extern int __libc_current_sigrtmax (void) __THROW;
370#define SIGRTMIN (__libc_current_sigrtmin ())370#define SIGRTMIN (__libc_current_sigrtmin ())
371#define SIGRTMAX (__libc_current_sigrtmax ())371#define SIGRTMAX (__libc_current_sigrtmax ())
372372
373/* System-specific extensions. */
374#include <bits/signal_ext.h>
375
373__END_DECLS376__END_DECLS
374377
375#endif /* not signal.h */378#endif /* not signal.h */
\ No newline at end of file
lib/libc/include/generic-glibc/stdlib.h+8-5
...@@ -536,10 +536,11 @@ extern int lcong48_r (unsigned short int __param[7],...@@ -536,10 +536,11 @@ extern int lcong48_r (unsigned short int __param[7],
536#endif /* Use misc or X/Open. */536#endif /* Use misc or X/Open. */
537537
538/* Allocate SIZE bytes of memory. */538/* Allocate SIZE bytes of memory. */
539extern void *malloc (size_t __size) __THROW __attribute_malloc__ __wur;539extern void *malloc (size_t __size) __THROW __attribute_malloc__
540 __attribute_alloc_size__ ((1)) __wur;
540/* Allocate NMEMB elements of SIZE bytes each, all initialized to 0. */541/* Allocate NMEMB elements of SIZE bytes each, all initialized to 0. */
541extern void *calloc (size_t __nmemb, size_t __size)542extern void *calloc (size_t __nmemb, size_t __size)
542 __THROW __attribute_malloc__ __wur;543 __THROW __attribute_malloc__ __attribute_alloc_size__ ((1, 2)) __wur;
543544
544/* Re-allocate the previously allocated block545/* Re-allocate the previously allocated block
545 in PTR, making the new block SIZE bytes long. */546 in PTR, making the new block SIZE bytes long. */
...@@ -547,7 +548,7 @@ extern void *calloc (size_t __nmemb, size_t __size)...@@ -547,7 +548,7 @@ extern void *calloc (size_t __nmemb, size_t __size)
547 the same pointer that was passed to it, aliasing needs to be allowed548 the same pointer that was passed to it, aliasing needs to be allowed
548 between objects pointed by the old and new pointers. */549 between objects pointed by the old and new pointers. */
549extern void *realloc (void *__ptr, size_t __size)550extern void *realloc (void *__ptr, size_t __size)
550 __THROW __attribute_warn_unused_result__;551 __THROW __attribute_warn_unused_result__ __attribute_alloc_size__ ((2));
551552
552#ifdef __USE_MISC553#ifdef __USE_MISC
553/* Re-allocate the previously allocated block in PTR, making the new554/* Re-allocate the previously allocated block in PTR, making the new
...@@ -556,7 +557,8 @@ extern void *realloc (void *__ptr, size_t __size)...@@ -556,7 +557,8 @@ extern void *realloc (void *__ptr, size_t __size)
556 the same pointer that was passed to it, aliasing needs to be allowed557 the same pointer that was passed to it, aliasing needs to be allowed
557 between objects pointed by the old and new pointers. */558 between objects pointed by the old and new pointers. */
558extern void *reallocarray (void *__ptr, size_t __nmemb, size_t __size)559extern void *reallocarray (void *__ptr, size_t __nmemb, size_t __size)
559 __THROW __attribute_warn_unused_result__;560 __THROW __attribute_warn_unused_result__
561 __attribute_alloc_size__ ((2, 3));
560#endif562#endif
561563
562/* Free a block allocated by `malloc', `realloc' or `calloc'. */564/* Free a block allocated by `malloc', `realloc' or `calloc'. */
...@@ -569,7 +571,8 @@ extern void free (void *__ptr) __THROW;...@@ -569,7 +571,8 @@ extern void free (void *__ptr) __THROW;
569#if (defined __USE_XOPEN_EXTENDED && !defined __USE_XOPEN2K) \571#if (defined __USE_XOPEN_EXTENDED && !defined __USE_XOPEN2K) \
570 || defined __USE_MISC572 || defined __USE_MISC
571/* Allocate SIZE bytes on a page boundary. The storage cannot be freed. */573/* Allocate SIZE bytes on a page boundary. The storage cannot be freed. */
572extern void *valloc (size_t __size) __THROW __attribute_malloc__ __wur;574extern void *valloc (size_t __size) __THROW __attribute_malloc__
575 __attribute_alloc_size__ ((1)) __wur;
573#endif576#endif
574577
575#ifdef __USE_XOPEN2K578#ifdef __USE_XOPEN2K
lib/libc/include/generic-glibc/stropts.h deleted-92
...@@ -1,92 +0,0 @@
1/* Copyright (C) 1998-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef _STROPTS_H
19#define _STROPTS_H 1
20
21#include <features.h>
22#include <bits/types.h>
23#include <bits/xtitypes.h>
24
25#ifndef __gid_t_defined
26typedef __gid_t gid_t;
27# define __gid_t_defined
28#endif
29
30#ifndef __uid_t_defined
31typedef __uid_t uid_t;
32# define __uid_t_defined
33#endif
34
35typedef __t_scalar_t t_scalar_t;
36typedef __t_uscalar_t t_uscalar_t;
37
38/* Get system specific constants. */
39#include <bits/stropts.h>
40
41
42__BEGIN_DECLS
43
44/* Test whether FILDES is associated with a STREAM-based file. */
45extern int isastream (int __fildes) __THROW;
46
47/* Receive next message from a STREAMS file.
48
49 This function is a cancellation point and therefore not marked with
50 __THROW. */
51extern int getmsg (int __fildes, struct strbuf *__restrict __ctlptr,
52 struct strbuf *__restrict __dataptr,
53 int *__restrict __flagsp);
54
55/* Receive next message from a STREAMS file, with *FLAGSP allowing to
56 control which message.
57
58 This function is a cancellation point and therefore not marked with
59 __THROW. */
60extern int getpmsg (int __fildes, struct strbuf *__restrict __ctlptr,
61 struct strbuf *__restrict __dataptr,
62 int *__restrict __bandp, int *__restrict __flagsp);
63
64/* Perform the I/O control operation specified by REQUEST on FD.
65 One argument may follow; its presence and type depend on REQUEST.
66 Return value depends on REQUEST. Usually -1 indicates error. */
67extern int ioctl (int __fd, unsigned long int __request, ...) __THROW;
68
69/* Send a message on a STREAM.
70
71 This function is a cancellation point and therefore not marked with
72 __THROW. */
73extern int putmsg (int __fildes, const struct strbuf *__ctlptr,
74 const struct strbuf *__dataptr, int __flags);
75
76/* Send a message on a STREAM to the BAND.
77
78 This function is a cancellation point and therefore not marked with
79 __THROW. */
80extern int putpmsg (int __fildes, const struct strbuf *__ctlptr,
81 const struct strbuf *__dataptr, int __band, int __flags);
82
83/* Attach a STREAMS-based file descriptor FILDES to a file PATH in the
84 file system name space. */
85extern int fattach (int __fildes, const char *__path) __THROW;
86
87/* Detach a name PATH from a STREAMS-based file descriptor. */
88extern int fdetach (const char *__path) __THROW;
89
90__END_DECLS
91
92#endif /* stropts.h */
\ No newline at end of file
lib/libc/include/generic-glibc/sys/cdefs.h+8
...@@ -412,6 +412,14 @@...@@ -412,6 +412,14 @@
412# define __glibc_has_attribute(attr) 0412# define __glibc_has_attribute(attr) 0
413#endif413#endif
414414
415#ifdef __has_include
416/* Do not use a function-like macro, so that __has_include can inhibit
417 macro expansion. */
418# define __glibc_has_include __has_include
419#else
420# define __glibc_has_include(header) 0
421#endif
422
415#if (!defined _Noreturn \423#if (!defined _Noreturn \
416 && (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) < 201112 \424 && (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) < 201112 \
417 && !__GNUC_PREREQ (4,7))425 && !__GNUC_PREREQ (4,7))
lib/libc/include/generic-glibc/sys/ifunc.h created+42
...@@ -0,0 +1,42 @@
1/* Definitions used by AArch64 indirect function resolvers.
2 Copyright (C) 2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _SYS_IFUNC_H
20#define _SYS_IFUNC_H
21
22/* A second argument is passed to the ifunc resolver. */
23#define _IFUNC_ARG_HWCAP (1ULL << 62)
24
25/* The prototype of a gnu indirect function resolver on AArch64 is
26
27 ElfW(Addr) ifunc_resolver (uint64_t, const __ifunc_arg_t *);
28
29 the first argument should have the _IFUNC_ARG_HWCAP bit set and
30 the remaining bits should match the AT_HWCAP settings. */
31
32/* Second argument to an ifunc resolver. */
33struct __ifunc_arg_t
34{
35 unsigned long _size; /* Size of the struct, so it can grow. */
36 unsigned long _hwcap;
37 unsigned long _hwcap2;
38};
39
40typedef struct __ifunc_arg_t __ifunc_arg_t;
41
42#endif
\ No newline at end of file
lib/libc/include/generic-glibc/sys/io.h+151-15
...@@ -12,36 +12,172 @@...@@ -12,36 +12,172 @@
12 Lesser General Public License for more details.12 Lesser General Public License for more details.
1313
14 You should have received a copy of the GNU Lesser General Public14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library. If not, see15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */16 <http://www.gnu.org/licenses/>. */
1717
18#ifndef _SYS_IO_H18#ifndef _SYS_IO_H
19
20#define _SYS_IO_H 119#define _SYS_IO_H 1
20
21#include <features.h>21#include <features.h>
2222
23__BEGIN_DECLS23__BEGIN_DECLS
2424
25/* If TURN_ON is TRUE, request for permission to do direct i/o on the25/* If TURN_ON is TRUE, request for permission to do direct i/o on the
26 port numbers in the range [FROM,FROM+NUM-1]. Otherwise, turn I/O26 port numbers in the range [FROM,FROM+NUM-1]. Otherwise, turn I/O
27 permission off for that range. This call requires root privileges. */27 permission off for that range. This call requires root privileges.
28
29 Portability note: not all Linux platforms support this call. Most
30 platforms based on the PC I/O architecture probably will, however.
31 E.g., Linux/Alpha for Alpha PCs supports this. */
28extern int ioperm (unsigned long int __from, unsigned long int __num,32extern int ioperm (unsigned long int __from, unsigned long int __num,
29 int __turn_on) __THROW;33 int __turn_on) __THROW;
3034
31/* Set the I/O privilege level to LEVEL. If LEVEL is nonzero,35/* Set the I/O privilege level to LEVEL. If LEVEL>3, permission to
32 permission to access any I/O port is granted. This call requires36 access any I/O port is granted. This call requires root
33 root privileges. */37 privileges. */
34extern int iopl (int __level) __THROW;38extern int iopl (int __level) __THROW;
3539
36/* The functions that actually perform reads and writes. */40#if defined __GNUC__ && __GNUC__ >= 2
37extern unsigned char inb (unsigned long int __port) __THROW;
38extern unsigned short int inw (unsigned long int __port) __THROW;
39extern unsigned long int inl (unsigned long int __port) __THROW;
4041
41extern void outb (unsigned char __value, unsigned long int __port) __THROW;42static __inline unsigned char
42extern void outw (unsigned short __value, unsigned long int __port) __THROW;43inb (unsigned short int __port)
43extern void outl (unsigned long __value, unsigned long int __port) __THROW;44{
45 unsigned char _v;
4446
45__END_DECLS47 __asm__ __volatile__ ("inb %w1,%0":"=a" (_v):"Nd" (__port));
48 return _v;
49}
50
51static __inline unsigned char
52inb_p (unsigned short int __port)
53{
54 unsigned char _v;
55
56 __asm__ __volatile__ ("inb %w1,%0\noutb %%al,$0x80":"=a" (_v):"Nd" (__port));
57 return _v;
58}
59
60static __inline unsigned short int
61inw (unsigned short int __port)
62{
63 unsigned short _v;
64
65 __asm__ __volatile__ ("inw %w1,%0":"=a" (_v):"Nd" (__port));
66 return _v;
67}
68
69static __inline unsigned short int
70inw_p (unsigned short int __port)
71{
72 unsigned short int _v;
73
74 __asm__ __volatile__ ("inw %w1,%0\noutb %%al,$0x80":"=a" (_v):"Nd" (__port));
75 return _v;
76}
77
78static __inline unsigned int
79inl (unsigned short int __port)
80{
81 unsigned int _v;
82
83 __asm__ __volatile__ ("inl %w1,%0":"=a" (_v):"Nd" (__port));
84 return _v;
85}
86
87static __inline unsigned int
88inl_p (unsigned short int __port)
89{
90 unsigned int _v;
91 __asm__ __volatile__ ("inl %w1,%0\noutb %%al,$0x80":"=a" (_v):"Nd" (__port));
92 return _v;
93}
94
95static __inline void
96outb (unsigned char __value, unsigned short int __port)
97{
98 __asm__ __volatile__ ("outb %b0,%w1": :"a" (__value), "Nd" (__port));
99}
46100
101static __inline void
102outb_p (unsigned char __value, unsigned short int __port)
103{
104 __asm__ __volatile__ ("outb %b0,%w1\noutb %%al,$0x80": :"a" (__value),
105 "Nd" (__port));
106}
107
108static __inline void
109outw (unsigned short int __value, unsigned short int __port)
110{
111 __asm__ __volatile__ ("outw %w0,%w1": :"a" (__value), "Nd" (__port));
112
113}
114
115static __inline void
116outw_p (unsigned short int __value, unsigned short int __port)
117{
118 __asm__ __volatile__ ("outw %w0,%w1\noutb %%al,$0x80": :"a" (__value),
119 "Nd" (__port));
120}
121
122static __inline void
123outl (unsigned int __value, unsigned short int __port)
124{
125 __asm__ __volatile__ ("outl %0,%w1": :"a" (__value), "Nd" (__port));
126}
127
128static __inline void
129outl_p (unsigned int __value, unsigned short int __port)
130{
131 __asm__ __volatile__ ("outl %0,%w1\noutb %%al,$0x80": :"a" (__value),
132 "Nd" (__port));
133}
134
135static __inline void
136insb (unsigned short int __port, void *__addr, unsigned long int __count)
137{
138 __asm__ __volatile__ ("cld ; rep ; insb":"=D" (__addr), "=c" (__count)
139 :"d" (__port), "0" (__addr), "1" (__count));
140}
141
142static __inline void
143insw (unsigned short int __port, void *__addr, unsigned long int __count)
144{
145 __asm__ __volatile__ ("cld ; rep ; insw":"=D" (__addr), "=c" (__count)
146 :"d" (__port), "0" (__addr), "1" (__count));
147}
148
149static __inline void
150insl (unsigned short int __port, void *__addr, unsigned long int __count)
151{
152 __asm__ __volatile__ ("cld ; rep ; insl":"=D" (__addr), "=c" (__count)
153 :"d" (__port), "0" (__addr), "1" (__count));
154}
155
156static __inline void
157outsb (unsigned short int __port, const void *__addr,
158 unsigned long int __count)
159{
160 __asm__ __volatile__ ("cld ; rep ; outsb":"=S" (__addr), "=c" (__count)
161 :"d" (__port), "0" (__addr), "1" (__count));
162}
163
164static __inline void
165outsw (unsigned short int __port, const void *__addr,
166 unsigned long int __count)
167{
168 __asm__ __volatile__ ("cld ; rep ; outsw":"=S" (__addr), "=c" (__count)
169 :"d" (__port), "0" (__addr), "1" (__count));
170}
171
172static __inline void
173outsl (unsigned short int __port, const void *__addr,
174 unsigned long int __count)
175{
176 __asm__ __volatile__ ("cld ; rep ; outsl":"=S" (__addr), "=c" (__count)
177 :"d" (__port), "0" (__addr), "1" (__count));
178}
179
180#endif /* GNU C */
181
182__END_DECLS
47#endif /* _SYS_IO_H */183#endif /* _SYS_IO_H */
\ No newline at end of file
lib/libc/include/generic-glibc/sys/stropts.h deleted-1
...@@ -1 +0,0 @@
1#include <stropts.h>
\ No newline at end of file
lib/libc/include/generic-glibc/sys/sysctl.h+4-1
...@@ -18,6 +18,8 @@...@@ -18,6 +18,8 @@
18#ifndef _SYS_SYSCTL_H18#ifndef _SYS_SYSCTL_H
19#define _SYS_SYSCTL_H 119#define _SYS_SYSCTL_H 1
2020
21#warning "The <sys/sysctl.h> header is deprecated and will be removed."
22
21#include <features.h>23#include <features.h>
22#define __need_size_t24#define __need_size_t
23#include <stddef.h>25#include <stddef.h>
...@@ -66,7 +68,8 @@ __BEGIN_DECLS...@@ -66,7 +68,8 @@ __BEGIN_DECLS
6668
67/* Read or write system parameters. */69/* Read or write system parameters. */
68extern int sysctl (int *__name, int __nlen, void *__oldval,70extern int sysctl (int *__name, int __nlen, void *__oldval,
69 size_t *__oldlenp, void *__newval, size_t __newlen) __THROW;71 size_t *__oldlenp, void *__newval, size_t __newlen) __THROW
72 __attribute_deprecated__;
7073
71__END_DECLS74__END_DECLS
7275
lib/libc/include/generic-glibc/sys/types.h+8-25
...@@ -154,37 +154,20 @@ typedef unsigned int uint;...@@ -154,37 +154,20 @@ typedef unsigned int uint;
154154
155#include <bits/stdint-intn.h>155#include <bits/stdint-intn.h>
156156
157#if !__GNUC_PREREQ (2, 7)
158
159/* These were defined by ISO C without the first `_'. */157/* These were defined by ISO C without the first `_'. */
160typedef unsigned char u_int8_t;158typedef __uint8_t u_int8_t;
161typedef unsigned short int u_int16_t;159typedef __uint16_t u_int16_t;
162typedef unsigned int u_int32_t;160typedef __uint32_t u_int32_t;
163# if __WORDSIZE == 64161typedef __uint64_t u_int64_t;
164typedef unsigned long int u_int64_t;
165# else
166__extension__ typedef unsigned long long int u_int64_t;
167# endif
168
169typedef int register_t;
170
171#else
172
173/* For GCC 2.7 and later, we can use specific type-size attributes. */
174# define __u_intN_t(N, MODE) \
175 typedef unsigned int u_int##N##_t __attribute__ ((__mode__ (MODE)))
176
177__u_intN_t (8, __QI__);
178__u_intN_t (16, __HI__);
179__u_intN_t (32, __SI__);
180__u_intN_t (64, __DI__);
181162
163#if __GNUC_PREREQ (2, 7)
182typedef int register_t __attribute__ ((__mode__ (__word__)));164typedef int register_t __attribute__ ((__mode__ (__word__)));
183165#else
166typedef int register_t;
167#endif
184168
185/* Some code from BIND tests this macro to see if the types above are169/* Some code from BIND tests this macro to see if the types above are
186 defined. */170 defined. */
187#endif
188#define __BIT_TYPES_DEFINED__ 1171#define __BIT_TYPES_DEFINED__ 1
189172
190173
lib/libc/include/i386-linux-gnu/bits/math-vector-fortran.h deleted-43
...@@ -1,43 +0,0 @@
1! Platform-specific declarations of SIMD math functions for Fortran. -*- f90 -*-
2! Copyright (C) 2019 Free Software Foundation, Inc.
3! This file is part of the GNU C Library.
4!
5! The GNU C Library is free software; you can redistribute it and/or
6! modify it under the terms of the GNU Lesser General Public
7! License as published by the Free Software Foundation; either
8! version 2.1 of the License, or (at your option) any later version.
9!
10! The GNU C Library is distributed in the hope that it will be useful,
11! but WITHOUT ANY WARRANTY; without even the implied warranty of
12! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13! Lesser General Public License for more details.
14!
15! You should have received a copy of the GNU Lesser General Public
16! License along with the GNU C Library; if not, see
17! <http://www.gnu.org/licenses/>.
18
19!GCC$ builtin (cos) attributes simd (notinbranch) if('x86_64')
20!GCC$ builtin (cosf) attributes simd (notinbranch) if('x86_64')
21!GCC$ builtin (sin) attributes simd (notinbranch) if('x86_64')
22!GCC$ builtin (sinf) attributes simd (notinbranch) if('x86_64')
23!GCC$ builtin (sincos) attributes simd (notinbranch) if('x86_64')
24!GCC$ builtin (sincosf) attributes simd (notinbranch) if('x86_64')
25!GCC$ builtin (log) attributes simd (notinbranch) if('x86_64')
26!GCC$ builtin (logf) attributes simd (notinbranch) if('x86_64')
27!GCC$ builtin (exp) attributes simd (notinbranch) if('x86_64')
28!GCC$ builtin (expf) attributes simd (notinbranch) if('x86_64')
29!GCC$ builtin (pow) attributes simd (notinbranch) if('x86_64')
30!GCC$ builtin (powf) attributes simd (notinbranch) if('x86_64')
31
32!GCC$ builtin (cos) attributes simd (notinbranch) if('x32')
33!GCC$ builtin (cosf) attributes simd (notinbranch) if('x32')
34!GCC$ builtin (sin) attributes simd (notinbranch) if('x32')
35!GCC$ builtin (sinf) attributes simd (notinbranch) if('x32')
36!GCC$ builtin (sincos) attributes simd (notinbranch) if('x32')
37!GCC$ builtin (sincosf) attributes simd (notinbranch) if('x32')
38!GCC$ builtin (log) attributes simd (notinbranch) if('x32')
39!GCC$ builtin (logf) attributes simd (notinbranch) if('x32')
40!GCC$ builtin (exp) attributes simd (notinbranch) if('x32')
41!GCC$ builtin (expf) attributes simd (notinbranch) if('x32')
42!GCC$ builtin (pow) attributes simd (notinbranch) if('x32')
43!GCC$ builtin (powf) attributes simd (notinbranch) if('x32')
\ No newline at end of file
lib/libc/include/i386-linux-gnu/bits/xtitypes.h deleted-33
...@@ -1,33 +0,0 @@
1/* bits/xtitypes.h -- Define some types used by <bits/stropts.h>. x86-64.
2 Copyright (C) 2002-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _STROPTS_H
20# error "Never include <bits/xtitypes.h> directly; use <stropts.h> instead."
21#endif
22
23#ifndef _BITS_XTITYPES_H
24#define _BITS_XTITYPES_H 1
25
26#include <bits/types.h>
27
28/* This type is used by some structs in <bits/stropts.h>. */
29typedef __SLONG32_TYPE __t_scalar_t;
30typedef __ULONG32_TYPE __t_uscalar_t;
31
32
33#endif /* bits/xtitypes.h */
\ No newline at end of file
lib/libc/include/i386-linux-gnu/finclude/math-vector-fortran.h created+43
...@@ -0,0 +1,43 @@
1! Platform-specific declarations of SIMD math functions for Fortran. -*- f90 -*-
2! Copyright (C) 2019 Free Software Foundation, Inc.
3! This file is part of the GNU C Library.
4!
5! The GNU C Library is free software; you can redistribute it and/or
6! modify it under the terms of the GNU Lesser General Public
7! License as published by the Free Software Foundation; either
8! version 2.1 of the License, or (at your option) any later version.
9!
10! The GNU C Library is distributed in the hope that it will be useful,
11! but WITHOUT ANY WARRANTY; without even the implied warranty of
12! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13! Lesser General Public License for more details.
14!
15! You should have received a copy of the GNU Lesser General Public
16! License along with the GNU C Library; if not, see
17! <http://www.gnu.org/licenses/>.
18
19!GCC$ builtin (cos) attributes simd (notinbranch) if('x86_64')
20!GCC$ builtin (cosf) attributes simd (notinbranch) if('x86_64')
21!GCC$ builtin (sin) attributes simd (notinbranch) if('x86_64')
22!GCC$ builtin (sinf) attributes simd (notinbranch) if('x86_64')
23!GCC$ builtin (sincos) attributes simd (notinbranch) if('x86_64')
24!GCC$ builtin (sincosf) attributes simd (notinbranch) if('x86_64')
25!GCC$ builtin (log) attributes simd (notinbranch) if('x86_64')
26!GCC$ builtin (logf) attributes simd (notinbranch) if('x86_64')
27!GCC$ builtin (exp) attributes simd (notinbranch) if('x86_64')
28!GCC$ builtin (expf) attributes simd (notinbranch) if('x86_64')
29!GCC$ builtin (pow) attributes simd (notinbranch) if('x86_64')
30!GCC$ builtin (powf) attributes simd (notinbranch) if('x86_64')
31
32!GCC$ builtin (cos) attributes simd (notinbranch) if('x32')
33!GCC$ builtin (cosf) attributes simd (notinbranch) if('x32')
34!GCC$ builtin (sin) attributes simd (notinbranch) if('x32')
35!GCC$ builtin (sinf) attributes simd (notinbranch) if('x32')
36!GCC$ builtin (sincos) attributes simd (notinbranch) if('x32')
37!GCC$ builtin (sincosf) attributes simd (notinbranch) if('x32')
38!GCC$ builtin (log) attributes simd (notinbranch) if('x32')
39!GCC$ builtin (logf) attributes simd (notinbranch) if('x32')
40!GCC$ builtin (exp) attributes simd (notinbranch) if('x32')
41!GCC$ builtin (expf) attributes simd (notinbranch) if('x32')
42!GCC$ builtin (pow) attributes simd (notinbranch) if('x32')
43!GCC$ builtin (powf) attributes simd (notinbranch) if('x32')
\ No newline at end of file
lib/libc/include/i386-linux-gnu/sys/io.h deleted-183
...@@ -1,183 +0,0 @@
1/* Copyright (C) 1996-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef _SYS_IO_H
19#define _SYS_IO_H 1
20
21#include <features.h>
22
23__BEGIN_DECLS
24
25/* If TURN_ON is TRUE, request for permission to do direct i/o on the
26 port numbers in the range [FROM,FROM+NUM-1]. Otherwise, turn I/O
27 permission off for that range. This call requires root privileges.
28
29 Portability note: not all Linux platforms support this call. Most
30 platforms based on the PC I/O architecture probably will, however.
31 E.g., Linux/Alpha for Alpha PCs supports this. */
32extern int ioperm (unsigned long int __from, unsigned long int __num,
33 int __turn_on) __THROW;
34
35/* Set the I/O privilege level to LEVEL. If LEVEL>3, permission to
36 access any I/O port is granted. This call requires root
37 privileges. */
38extern int iopl (int __level) __THROW;
39
40#if defined __GNUC__ && __GNUC__ >= 2
41
42static __inline unsigned char
43inb (unsigned short int __port)
44{
45 unsigned char _v;
46
47 __asm__ __volatile__ ("inb %w1,%0":"=a" (_v):"Nd" (__port));
48 return _v;
49}
50
51static __inline unsigned char
52inb_p (unsigned short int __port)
53{
54 unsigned char _v;
55
56 __asm__ __volatile__ ("inb %w1,%0\noutb %%al,$0x80":"=a" (_v):"Nd" (__port));
57 return _v;
58}
59
60static __inline unsigned short int
61inw (unsigned short int __port)
62{
63 unsigned short _v;
64
65 __asm__ __volatile__ ("inw %w1,%0":"=a" (_v):"Nd" (__port));
66 return _v;
67}
68
69static __inline unsigned short int
70inw_p (unsigned short int __port)
71{
72 unsigned short int _v;
73
74 __asm__ __volatile__ ("inw %w1,%0\noutb %%al,$0x80":"=a" (_v):"Nd" (__port));
75 return _v;
76}
77
78static __inline unsigned int
79inl (unsigned short int __port)
80{
81 unsigned int _v;
82
83 __asm__ __volatile__ ("inl %w1,%0":"=a" (_v):"Nd" (__port));
84 return _v;
85}
86
87static __inline unsigned int
88inl_p (unsigned short int __port)
89{
90 unsigned int _v;
91 __asm__ __volatile__ ("inl %w1,%0\noutb %%al,$0x80":"=a" (_v):"Nd" (__port));
92 return _v;
93}
94
95static __inline void
96outb (unsigned char __value, unsigned short int __port)
97{
98 __asm__ __volatile__ ("outb %b0,%w1": :"a" (__value), "Nd" (__port));
99}
100
101static __inline void
102outb_p (unsigned char __value, unsigned short int __port)
103{
104 __asm__ __volatile__ ("outb %b0,%w1\noutb %%al,$0x80": :"a" (__value),
105 "Nd" (__port));
106}
107
108static __inline void
109outw (unsigned short int __value, unsigned short int __port)
110{
111 __asm__ __volatile__ ("outw %w0,%w1": :"a" (__value), "Nd" (__port));
112
113}
114
115static __inline void
116outw_p (unsigned short int __value, unsigned short int __port)
117{
118 __asm__ __volatile__ ("outw %w0,%w1\noutb %%al,$0x80": :"a" (__value),
119 "Nd" (__port));
120}
121
122static __inline void
123outl (unsigned int __value, unsigned short int __port)
124{
125 __asm__ __volatile__ ("outl %0,%w1": :"a" (__value), "Nd" (__port));
126}
127
128static __inline void
129outl_p (unsigned int __value, unsigned short int __port)
130{
131 __asm__ __volatile__ ("outl %0,%w1\noutb %%al,$0x80": :"a" (__value),
132 "Nd" (__port));
133}
134
135static __inline void
136insb (unsigned short int __port, void *__addr, unsigned long int __count)
137{
138 __asm__ __volatile__ ("cld ; rep ; insb":"=D" (__addr), "=c" (__count)
139 :"d" (__port), "0" (__addr), "1" (__count));
140}
141
142static __inline void
143insw (unsigned short int __port, void *__addr, unsigned long int __count)
144{
145 __asm__ __volatile__ ("cld ; rep ; insw":"=D" (__addr), "=c" (__count)
146 :"d" (__port), "0" (__addr), "1" (__count));
147}
148
149static __inline void
150insl (unsigned short int __port, void *__addr, unsigned long int __count)
151{
152 __asm__ __volatile__ ("cld ; rep ; insl":"=D" (__addr), "=c" (__count)
153 :"d" (__port), "0" (__addr), "1" (__count));
154}
155
156static __inline void
157outsb (unsigned short int __port, const void *__addr,
158 unsigned long int __count)
159{
160 __asm__ __volatile__ ("cld ; rep ; outsb":"=S" (__addr), "=c" (__count)
161 :"d" (__port), "0" (__addr), "1" (__count));
162}
163
164static __inline void
165outsw (unsigned short int __port, const void *__addr,
166 unsigned long int __count)
167{
168 __asm__ __volatile__ ("cld ; rep ; outsw":"=S" (__addr), "=c" (__count)
169 :"d" (__port), "0" (__addr), "1" (__count));
170}
171
172static __inline void
173outsl (unsigned short int __port, const void *__addr,
174 unsigned long int __count)
175{
176 __asm__ __volatile__ ("cld ; rep ; outsl":"=S" (__addr), "=c" (__count)
177 :"d" (__port), "0" (__addr), "1" (__count));
178}
179
180#endif /* GNU C */
181
182__END_DECLS
183#endif /* _SYS_IO_H */
\ No newline at end of file
lib/libc/include/mips-linux-gnu/bits/socket-constants.h created+38
...@@ -0,0 +1,38 @@
1/* Socket constants which vary among Linux architectures. Version for MIPS.
2 Copyright (C) 2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _SYS_SOCKET_H
20# error "Never include <bits/socket-constants.h> directly; use <sys/socket.h> instead."
21#endif
22
23#define SOL_SOCKET 65535
24#define SO_ACCEPTCONN 4105
25#define SO_BROADCAST 32
26#define SO_DONTROUTE 16
27#define SO_ERROR 4103
28#define SO_KEEPALIVE 8
29#define SO_LINGER 128
30#define SO_OOBINLINE 256
31#define SO_RCVBUF 4098
32#define SO_RCVLOWAT 4100
33#define SO_RCVTIMEO 4102
34#define SO_REUSEADDR 4
35#define SO_SNDBUF 4097
36#define SO_SNDLOWAT 4099
37#define SO_SNDTIMEO 4101
38#define SO_TYPE 4104
\ No newline at end of file
lib/libc/include/mips64-linux-gnuabi64/bits/socket-constants.h created+38
...@@ -0,0 +1,38 @@
1/* Socket constants which vary among Linux architectures. Version for MIPS.
2 Copyright (C) 2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _SYS_SOCKET_H
20# error "Never include <bits/socket-constants.h> directly; use <sys/socket.h> instead."
21#endif
22
23#define SOL_SOCKET 65535
24#define SO_ACCEPTCONN 4105
25#define SO_BROADCAST 32
26#define SO_DONTROUTE 16
27#define SO_ERROR 4103
28#define SO_KEEPALIVE 8
29#define SO_LINGER 128
30#define SO_OOBINLINE 256
31#define SO_RCVBUF 4098
32#define SO_RCVLOWAT 4100
33#define SO_RCVTIMEO 4102
34#define SO_REUSEADDR 4
35#define SO_SNDBUF 4097
36#define SO_SNDLOWAT 4099
37#define SO_SNDTIMEO 4101
38#define SO_TYPE 4104
\ No newline at end of file
lib/libc/include/mips64-linux-gnuabin32/bits/socket-constants.h created+38
...@@ -0,0 +1,38 @@
1/* Socket constants which vary among Linux architectures. Version for MIPS.
2 Copyright (C) 2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _SYS_SOCKET_H
20# error "Never include <bits/socket-constants.h> directly; use <sys/socket.h> instead."
21#endif
22
23#define SOL_SOCKET 65535
24#define SO_ACCEPTCONN 4105
25#define SO_BROADCAST 32
26#define SO_DONTROUTE 16
27#define SO_ERROR 4103
28#define SO_KEEPALIVE 8
29#define SO_LINGER 128
30#define SO_OOBINLINE 256
31#define SO_RCVBUF 4098
32#define SO_RCVLOWAT 4100
33#define SO_RCVTIMEO 4102
34#define SO_REUSEADDR 4
35#define SO_SNDBUF 4097
36#define SO_SNDLOWAT 4099
37#define SO_SNDTIMEO 4101
38#define SO_TYPE 4104
\ No newline at end of file
lib/libc/include/mips64el-linux-gnuabi64/bits/socket-constants.h created+38
...@@ -0,0 +1,38 @@
1/* Socket constants which vary among Linux architectures. Version for MIPS.
2 Copyright (C) 2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _SYS_SOCKET_H
20# error "Never include <bits/socket-constants.h> directly; use <sys/socket.h> instead."
21#endif
22
23#define SOL_SOCKET 65535
24#define SO_ACCEPTCONN 4105
25#define SO_BROADCAST 32
26#define SO_DONTROUTE 16
27#define SO_ERROR 4103
28#define SO_KEEPALIVE 8
29#define SO_LINGER 128
30#define SO_OOBINLINE 256
31#define SO_RCVBUF 4098
32#define SO_RCVLOWAT 4100
33#define SO_RCVTIMEO 4102
34#define SO_REUSEADDR 4
35#define SO_SNDBUF 4097
36#define SO_SNDLOWAT 4099
37#define SO_SNDTIMEO 4101
38#define SO_TYPE 4104
\ No newline at end of file
lib/libc/include/mips64el-linux-gnuabin32/bits/socket-constants.h created+38
...@@ -0,0 +1,38 @@
1/* Socket constants which vary among Linux architectures. Version for MIPS.
2 Copyright (C) 2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _SYS_SOCKET_H
20# error "Never include <bits/socket-constants.h> directly; use <sys/socket.h> instead."
21#endif
22
23#define SOL_SOCKET 65535
24#define SO_ACCEPTCONN 4105
25#define SO_BROADCAST 32
26#define SO_DONTROUTE 16
27#define SO_ERROR 4103
28#define SO_KEEPALIVE 8
29#define SO_LINGER 128
30#define SO_OOBINLINE 256
31#define SO_RCVBUF 4098
32#define SO_RCVLOWAT 4100
33#define SO_RCVTIMEO 4102
34#define SO_REUSEADDR 4
35#define SO_SNDBUF 4097
36#define SO_SNDLOWAT 4099
37#define SO_SNDTIMEO 4101
38#define SO_TYPE 4104
\ No newline at end of file
lib/libc/include/mipsel-linux-gnu/bits/socket-constants.h created+38
...@@ -0,0 +1,38 @@
1/* Socket constants which vary among Linux architectures. Version for MIPS.
2 Copyright (C) 2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _SYS_SOCKET_H
20# error "Never include <bits/socket-constants.h> directly; use <sys/socket.h> instead."
21#endif
22
23#define SOL_SOCKET 65535
24#define SO_ACCEPTCONN 4105
25#define SO_BROADCAST 32
26#define SO_DONTROUTE 16
27#define SO_ERROR 4103
28#define SO_KEEPALIVE 8
29#define SO_LINGER 128
30#define SO_OOBINLINE 256
31#define SO_RCVBUF 4098
32#define SO_RCVLOWAT 4100
33#define SO_RCVTIMEO 4102
34#define SO_REUSEADDR 4
35#define SO_SNDBUF 4097
36#define SO_SNDLOWAT 4099
37#define SO_SNDTIMEO 4101
38#define SO_TYPE 4104
\ No newline at end of file
lib/libc/include/powerpc-linux-gnu/bits/fenvinline.h+30-7
...@@ -18,13 +18,36 @@...@@ -18,13 +18,36 @@
1818
19#if defined __GNUC__ && !defined _SOFT_FLOAT && !defined __NO_FPRS__19#if defined __GNUC__ && !defined _SOFT_FLOAT && !defined __NO_FPRS__
2020
21/* Inline definition for fegetround. */21/* Inline definitions for fegetround. */
22# define __fegetround() \22# define __fegetround_ISA300() \
23 (__extension__ ({ int __fegetround_result; \23 (__extension__ ({ \
24 __asm__ __volatile__ \24 union { double __d; unsigned long long __ll; } __u; \
25 ("mcrfs 7,7 ; mfcr %0" \25 __asm__ __volatile__ ( \
26 : "=r"(__fegetround_result) : : "cr7"); \26 ".machine push; .machine \"power9\"; mffsl %0; .machine pop" \
27 __fegetround_result & 3; }))27 : "=f" (__u.__d)); \
28 __u.__ll & 0x0000000000000003LL; \
29 }))
30
31# define __fegetround_ISA2() \
32 (__extension__ ({ \
33 int __fegetround_result; \
34 __asm__ __volatile__ ("mcrfs 7,7 ; mfcr %0" \
35 : "=r"(__fegetround_result) : : "cr7"); \
36 __fegetround_result & 3; \
37 }))
38
39# ifdef _ARCH_PWR9
40# define __fegetround() __fegetround_ISA300()
41# elif defined __BUILTIN_CPU_SUPPORTS__
42# define __fegetround() \
43 (__glibc_likely (__builtin_cpu_supports ("arch_3_00")) \
44 ? __fegetround_ISA300() \
45 : __fegetround_ISA2() \
46 )
47# else
48# define __fegetround() __fegetround_ISA2()
49# endif
50
28# define fegetround() __fegetround ()51# define fegetround() __fegetround ()
2952
30# ifndef __NO_MATH_INLINES53# ifndef __NO_MATH_INLINES
lib/libc/include/powerpc-linux-gnu/bits/socket-constants.h created+38
...@@ -0,0 +1,38 @@
1/* Socket constants which vary among Linux architectures. Version for POWER.
2 Copyright (C) 2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _SYS_SOCKET_H
20# error "Never include <bits/socket-constants.h> directly; use <sys/socket.h> instead."
21#endif
22
23#define SOL_SOCKET 1
24#define SO_ACCEPTCONN 30
25#define SO_BROADCAST 6
26#define SO_DONTROUTE 5
27#define SO_ERROR 4
28#define SO_KEEPALIVE 9
29#define SO_LINGER 13
30#define SO_OOBINLINE 10
31#define SO_RCVBUF 8
32#define SO_RCVLOWAT 16
33#define SO_RCVTIMEO 18
34#define SO_REUSEADDR 2
35#define SO_SNDBUF 7
36#define SO_SNDLOWAT 17
37#define SO_SNDTIMEO 19
38#define SO_TYPE 3
\ No newline at end of file
lib/libc/include/powerpc-linux-gnu/fpu_control.h+33-39
...@@ -19,6 +19,10 @@...@@ -19,6 +19,10 @@
19#ifndef _FPU_CONTROL_H19#ifndef _FPU_CONTROL_H
20#define _FPU_CONTROL_H20#define _FPU_CONTROL_H
2121
22#if defined __SPE__ || (defined __NO_FPRS__ && !defined _SOFT_FLOAT)
23# error "SPE/e500 is no longer supported"
24#endif
25
22#ifdef _SOFT_FLOAT26#ifdef _SOFT_FLOAT
2327
24# define _FPU_RESERVED 0xffffffff28# define _FPU_RESERVED 0xffffffff
...@@ -28,41 +32,6 @@ typedef unsigned int fpu_control_t;...@@ -28,41 +32,6 @@ typedef unsigned int fpu_control_t;
28# define _FPU_SETCW(cw) (void) (cw)32# define _FPU_SETCW(cw) (void) (cw)
29extern fpu_control_t __fpu_control;33extern fpu_control_t __fpu_control;
3034
31#elif defined __NO_FPRS__ /* e500 */
32
33/* rounding control */
34# define _FPU_RC_NEAREST 0x00 /* RECOMMENDED */
35# define _FPU_RC_DOWN 0x03
36# define _FPU_RC_UP 0x02
37# define _FPU_RC_ZERO 0x01
38
39/* masking of interrupts */
40# define _FPU_MASK_ZM 0x10 /* zero divide */
41# define _FPU_MASK_OM 0x04 /* overflow */
42# define _FPU_MASK_UM 0x08 /* underflow */
43# define _FPU_MASK_XM 0x40 /* inexact */
44# define _FPU_MASK_IM 0x20 /* invalid operation */
45
46# define _FPU_RESERVED 0x00c10080 /* These bits are reserved and not changed. */
47
48/* Correct IEEE semantics require traps to be enabled at the hardware
49 level; the kernel then does the emulation and determines whether
50 generation of signals from those traps was enabled using prctl. */
51# define _FPU_DEFAULT 0x0000003c /* Default value. */
52# define _FPU_IEEE _FPU_DEFAULT
53
54/* Type of the control word. */
55typedef unsigned int fpu_control_t;
56
57/* Macros for accessing the hardware control word. */
58# define _FPU_GETCW(cw) \
59 __asm__ volatile ("mfspefscr %0" : "=r" (cw))
60# define _FPU_SETCW(cw) \
61 __asm__ volatile ("mtspefscr %0" : : "r" (cw))
62
63/* Default control word set at startup. */
64extern fpu_control_t __fpu_control;
65
66#else /* PowerPC 6xx floating-point. */35#else /* PowerPC 6xx floating-point. */
6736
68/* rounding control */37/* rounding control */
...@@ -71,6 +40,8 @@ extern fpu_control_t __fpu_control;...@@ -71,6 +40,8 @@ extern fpu_control_t __fpu_control;
71# define _FPU_RC_UP 0x0240# define _FPU_RC_UP 0x02
72# define _FPU_RC_ZERO 0x0141# define _FPU_RC_ZERO 0x01
7342
43# define _FPU_MASK_RC (_FPU_RC_NEAREST|_FPU_RC_DOWN|_FPU_RC_UP|_FPU_RC_ZERO)
44
74# define _FPU_MASK_NI 0x04 /* non-ieee mode */45# define _FPU_MASK_NI 0x04 /* non-ieee mode */
7546
76/* masking of interrupts */47/* masking of interrupts */
...@@ -96,20 +67,43 @@ typedef unsigned int fpu_control_t;...@@ -96,20 +67,43 @@ typedef unsigned int fpu_control_t;
96/* Macros for accessing the hardware control word. */67/* Macros for accessing the hardware control word. */
97# define _FPU_GETCW(cw) \68# define _FPU_GETCW(cw) \
98 ({union { double __d; unsigned long long __ll; } __u; \69 ({union { double __d; unsigned long long __ll; } __u; \
99 register double __fr; \70 __asm__ __volatile__("mffs %0" : "=f" (__u.__d)); \
100 __asm__ ("mffs %0" : "=f" (__fr)); \
101 __u.__d = __fr; \
102 (cw) = (fpu_control_t) __u.__ll; \71 (cw) = (fpu_control_t) __u.__ll; \
103 (fpu_control_t) __u.__ll; \72 (fpu_control_t) __u.__ll; \
104 })73 })
10574
75# define _FPU_GET_RC_ISA300() \
76 ({union { double __d; unsigned long long __ll; } __u; \
77 __asm__ __volatile__( \
78 ".machine push; .machine \"power9\"; mffsl %0; .machine pop" \
79 : "=f" (__u.__d)); \
80 (fpu_control_t) (__u.__ll & _FPU_MASK_RC); \
81 })
82
83# ifdef _ARCH_PWR9
84# define _FPU_GET_RC() _FPU_GET_RC_ISA300()
85# elif defined __BUILTIN_CPU_SUPPORTS__
86# define _FPU_GET_RC() \
87 ({fpu_control_t __rc; \
88 __rc = __glibc_likely (__builtin_cpu_supports ("arch_3_00")) \
89 ? _FPU_GET_RC_ISA300 () \
90 : _FPU_GETCW (__rc) & _FPU_MASK_RC; \
91 __rc; \
92 })
93# else
94# define _FPU_GET_RC() \
95 ({fpu_control_t __rc = _FPU_GETCW (__rc) & _FPU_MASK_RC; \
96 __rc; \
97 })
98# endif
99
106# define _FPU_SETCW(cw) \100# define _FPU_SETCW(cw) \
107 { union { double __d; unsigned long long __ll; } __u; \101 { union { double __d; unsigned long long __ll; } __u; \
108 register double __fr; \102 register double __fr; \
109 __u.__ll = 0xfff80000LL << 32; /* This is a QNaN. */ \103 __u.__ll = 0xfff80000LL << 32; /* This is a QNaN. */ \
110 __u.__ll |= (cw) & 0xffffffffLL; \104 __u.__ll |= (cw) & 0xffffffffLL; \
111 __fr = __u.__d; \105 __fr = __u.__d; \
112 __asm__ ("mtfsf 255,%0" : : "f" (__fr)); \106 __asm__ __volatile__("mtfsf 255,%0" : : "f" (__fr)); \
113 }107 }
114108
115/* Default control word set at startup. */109/* Default control word set at startup. */
lib/libc/include/powerpc64-linux-gnu/bits/fenvinline.h+30-7
...@@ -18,13 +18,36 @@...@@ -18,13 +18,36 @@
1818
19#if defined __GNUC__ && !defined _SOFT_FLOAT && !defined __NO_FPRS__19#if defined __GNUC__ && !defined _SOFT_FLOAT && !defined __NO_FPRS__
2020
21/* Inline definition for fegetround. */21/* Inline definitions for fegetround. */
22# define __fegetround() \22# define __fegetround_ISA300() \
23 (__extension__ ({ int __fegetround_result; \23 (__extension__ ({ \
24 __asm__ __volatile__ \24 union { double __d; unsigned long long __ll; } __u; \
25 ("mcrfs 7,7 ; mfcr %0" \25 __asm__ __volatile__ ( \
26 : "=r"(__fegetround_result) : : "cr7"); \26 ".machine push; .machine \"power9\"; mffsl %0; .machine pop" \
27 __fegetround_result & 3; }))27 : "=f" (__u.__d)); \
28 __u.__ll & 0x0000000000000003LL; \
29 }))
30
31# define __fegetround_ISA2() \
32 (__extension__ ({ \
33 int __fegetround_result; \
34 __asm__ __volatile__ ("mcrfs 7,7 ; mfcr %0" \
35 : "=r"(__fegetround_result) : : "cr7"); \
36 __fegetround_result & 3; \
37 }))
38
39# ifdef _ARCH_PWR9
40# define __fegetround() __fegetround_ISA300()
41# elif defined __BUILTIN_CPU_SUPPORTS__
42# define __fegetround() \
43 (__glibc_likely (__builtin_cpu_supports ("arch_3_00")) \
44 ? __fegetround_ISA300() \
45 : __fegetround_ISA2() \
46 )
47# else
48# define __fegetround() __fegetround_ISA2()
49# endif
50
28# define fegetround() __fegetround ()51# define fegetround() __fegetround ()
2952
30# ifndef __NO_MATH_INLINES53# ifndef __NO_MATH_INLINES
lib/libc/include/powerpc64-linux-gnu/bits/socket-constants.h created+38
...@@ -0,0 +1,38 @@
1/* Socket constants which vary among Linux architectures. Version for POWER.
2 Copyright (C) 2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _SYS_SOCKET_H
20# error "Never include <bits/socket-constants.h> directly; use <sys/socket.h> instead."
21#endif
22
23#define SOL_SOCKET 1
24#define SO_ACCEPTCONN 30
25#define SO_BROADCAST 6
26#define SO_DONTROUTE 5
27#define SO_ERROR 4
28#define SO_KEEPALIVE 9
29#define SO_LINGER 13
30#define SO_OOBINLINE 10
31#define SO_RCVBUF 8
32#define SO_RCVLOWAT 16
33#define SO_RCVTIMEO 18
34#define SO_REUSEADDR 2
35#define SO_SNDBUF 7
36#define SO_SNDLOWAT 17
37#define SO_SNDTIMEO 19
38#define SO_TYPE 3
\ No newline at end of file
lib/libc/include/powerpc64-linux-gnu/fpu_control.h+33-39
...@@ -19,6 +19,10 @@...@@ -19,6 +19,10 @@
19#ifndef _FPU_CONTROL_H19#ifndef _FPU_CONTROL_H
20#define _FPU_CONTROL_H20#define _FPU_CONTROL_H
2121
22#if defined __SPE__ || (defined __NO_FPRS__ && !defined _SOFT_FLOAT)
23# error "SPE/e500 is no longer supported"
24#endif
25
22#ifdef _SOFT_FLOAT26#ifdef _SOFT_FLOAT
2327
24# define _FPU_RESERVED 0xffffffff28# define _FPU_RESERVED 0xffffffff
...@@ -28,41 +32,6 @@ typedef unsigned int fpu_control_t;...@@ -28,41 +32,6 @@ typedef unsigned int fpu_control_t;
28# define _FPU_SETCW(cw) (void) (cw)32# define _FPU_SETCW(cw) (void) (cw)
29extern fpu_control_t __fpu_control;33extern fpu_control_t __fpu_control;
3034
31#elif defined __NO_FPRS__ /* e500 */
32
33/* rounding control */
34# define _FPU_RC_NEAREST 0x00 /* RECOMMENDED */
35# define _FPU_RC_DOWN 0x03
36# define _FPU_RC_UP 0x02
37# define _FPU_RC_ZERO 0x01
38
39/* masking of interrupts */
40# define _FPU_MASK_ZM 0x10 /* zero divide */
41# define _FPU_MASK_OM 0x04 /* overflow */
42# define _FPU_MASK_UM 0x08 /* underflow */
43# define _FPU_MASK_XM 0x40 /* inexact */
44# define _FPU_MASK_IM 0x20 /* invalid operation */
45
46# define _FPU_RESERVED 0x00c10080 /* These bits are reserved and not changed. */
47
48/* Correct IEEE semantics require traps to be enabled at the hardware
49 level; the kernel then does the emulation and determines whether
50 generation of signals from those traps was enabled using prctl. */
51# define _FPU_DEFAULT 0x0000003c /* Default value. */
52# define _FPU_IEEE _FPU_DEFAULT
53
54/* Type of the control word. */
55typedef unsigned int fpu_control_t;
56
57/* Macros for accessing the hardware control word. */
58# define _FPU_GETCW(cw) \
59 __asm__ volatile ("mfspefscr %0" : "=r" (cw))
60# define _FPU_SETCW(cw) \
61 __asm__ volatile ("mtspefscr %0" : : "r" (cw))
62
63/* Default control word set at startup. */
64extern fpu_control_t __fpu_control;
65
66#else /* PowerPC 6xx floating-point. */35#else /* PowerPC 6xx floating-point. */
6736
68/* rounding control */37/* rounding control */
...@@ -71,6 +40,8 @@ extern fpu_control_t __fpu_control;...@@ -71,6 +40,8 @@ extern fpu_control_t __fpu_control;
71# define _FPU_RC_UP 0x0240# define _FPU_RC_UP 0x02
72# define _FPU_RC_ZERO 0x0141# define _FPU_RC_ZERO 0x01
7342
43# define _FPU_MASK_RC (_FPU_RC_NEAREST|_FPU_RC_DOWN|_FPU_RC_UP|_FPU_RC_ZERO)
44
74# define _FPU_MASK_NI 0x04 /* non-ieee mode */45# define _FPU_MASK_NI 0x04 /* non-ieee mode */
7546
76/* masking of interrupts */47/* masking of interrupts */
...@@ -96,20 +67,43 @@ typedef unsigned int fpu_control_t;...@@ -96,20 +67,43 @@ typedef unsigned int fpu_control_t;
96/* Macros for accessing the hardware control word. */67/* Macros for accessing the hardware control word. */
97# define _FPU_GETCW(cw) \68# define _FPU_GETCW(cw) \
98 ({union { double __d; unsigned long long __ll; } __u; \69 ({union { double __d; unsigned long long __ll; } __u; \
99 register double __fr; \70 __asm__ __volatile__("mffs %0" : "=f" (__u.__d)); \
100 __asm__ ("mffs %0" : "=f" (__fr)); \
101 __u.__d = __fr; \
102 (cw) = (fpu_control_t) __u.__ll; \71 (cw) = (fpu_control_t) __u.__ll; \
103 (fpu_control_t) __u.__ll; \72 (fpu_control_t) __u.__ll; \
104 })73 })
10574
75# define _FPU_GET_RC_ISA300() \
76 ({union { double __d; unsigned long long __ll; } __u; \
77 __asm__ __volatile__( \
78 ".machine push; .machine \"power9\"; mffsl %0; .machine pop" \
79 : "=f" (__u.__d)); \
80 (fpu_control_t) (__u.__ll & _FPU_MASK_RC); \
81 })
82
83# ifdef _ARCH_PWR9
84# define _FPU_GET_RC() _FPU_GET_RC_ISA300()
85# elif defined __BUILTIN_CPU_SUPPORTS__
86# define _FPU_GET_RC() \
87 ({fpu_control_t __rc; \
88 __rc = __glibc_likely (__builtin_cpu_supports ("arch_3_00")) \
89 ? _FPU_GET_RC_ISA300 () \
90 : _FPU_GETCW (__rc) & _FPU_MASK_RC; \
91 __rc; \
92 })
93# else
94# define _FPU_GET_RC() \
95 ({fpu_control_t __rc = _FPU_GETCW (__rc) & _FPU_MASK_RC; \
96 __rc; \
97 })
98# endif
99
106# define _FPU_SETCW(cw) \100# define _FPU_SETCW(cw) \
107 { union { double __d; unsigned long long __ll; } __u; \101 { union { double __d; unsigned long long __ll; } __u; \
108 register double __fr; \102 register double __fr; \
109 __u.__ll = 0xfff80000LL << 32; /* This is a QNaN. */ \103 __u.__ll = 0xfff80000LL << 32; /* This is a QNaN. */ \
110 __u.__ll |= (cw) & 0xffffffffLL; \104 __u.__ll |= (cw) & 0xffffffffLL; \
111 __fr = __u.__d; \105 __fr = __u.__d; \
112 __asm__ ("mtfsf 255,%0" : : "f" (__fr)); \106 __asm__ __volatile__("mtfsf 255,%0" : : "f" (__fr)); \
113 }107 }
114108
115/* Default control word set at startup. */109/* Default control word set at startup. */
lib/libc/include/powerpc64-linux-gnu/gnu/stubs-64-v1.h-2
...@@ -8,9 +8,7 @@...@@ -8,9 +8,7 @@
8#endif8#endif
99
10#define __stub_chflags10#define __stub_chflags
11#define __stub_fattach
12#define __stub_fchflags11#define __stub_fchflags
13#define __stub_fdetach
14#define __stub_gtty12#define __stub_gtty
15#define __stub_lchmod13#define __stub_lchmod
16#define __stub_revoke14#define __stub_revoke
lib/libc/include/powerpc64le-linux-gnu/bits/fenvinline.h+30-7
...@@ -18,13 +18,36 @@...@@ -18,13 +18,36 @@
1818
19#if defined __GNUC__ && !defined _SOFT_FLOAT && !defined __NO_FPRS__19#if defined __GNUC__ && !defined _SOFT_FLOAT && !defined __NO_FPRS__
2020
21/* Inline definition for fegetround. */21/* Inline definitions for fegetround. */
22# define __fegetround() \22# define __fegetround_ISA300() \
23 (__extension__ ({ int __fegetround_result; \23 (__extension__ ({ \
24 __asm__ __volatile__ \24 union { double __d; unsigned long long __ll; } __u; \
25 ("mcrfs 7,7 ; mfcr %0" \25 __asm__ __volatile__ ( \
26 : "=r"(__fegetround_result) : : "cr7"); \26 ".machine push; .machine \"power9\"; mffsl %0; .machine pop" \
27 __fegetround_result & 3; }))27 : "=f" (__u.__d)); \
28 __u.__ll & 0x0000000000000003LL; \
29 }))
30
31# define __fegetround_ISA2() \
32 (__extension__ ({ \
33 int __fegetround_result; \
34 __asm__ __volatile__ ("mcrfs 7,7 ; mfcr %0" \
35 : "=r"(__fegetround_result) : : "cr7"); \
36 __fegetround_result & 3; \
37 }))
38
39# ifdef _ARCH_PWR9
40# define __fegetround() __fegetround_ISA300()
41# elif defined __BUILTIN_CPU_SUPPORTS__
42# define __fegetround() \
43 (__glibc_likely (__builtin_cpu_supports ("arch_3_00")) \
44 ? __fegetround_ISA300() \
45 : __fegetround_ISA2() \
46 )
47# else
48# define __fegetround() __fegetround_ISA2()
49# endif
50
28# define fegetround() __fegetround ()51# define fegetround() __fegetround ()
2952
30# ifndef __NO_MATH_INLINES53# ifndef __NO_MATH_INLINES
lib/libc/include/powerpc64le-linux-gnu/bits/socket-constants.h created+38
...@@ -0,0 +1,38 @@
1/* Socket constants which vary among Linux architectures. Version for POWER.
2 Copyright (C) 2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _SYS_SOCKET_H
20# error "Never include <bits/socket-constants.h> directly; use <sys/socket.h> instead."
21#endif
22
23#define SOL_SOCKET 1
24#define SO_ACCEPTCONN 30
25#define SO_BROADCAST 6
26#define SO_DONTROUTE 5
27#define SO_ERROR 4
28#define SO_KEEPALIVE 9
29#define SO_LINGER 13
30#define SO_OOBINLINE 10
31#define SO_RCVBUF 8
32#define SO_RCVLOWAT 16
33#define SO_RCVTIMEO 18
34#define SO_REUSEADDR 2
35#define SO_SNDBUF 7
36#define SO_SNDLOWAT 17
37#define SO_SNDTIMEO 19
38#define SO_TYPE 3
\ No newline at end of file
lib/libc/include/powerpc64le-linux-gnu/fpu_control.h+33-39
...@@ -19,6 +19,10 @@...@@ -19,6 +19,10 @@
19#ifndef _FPU_CONTROL_H19#ifndef _FPU_CONTROL_H
20#define _FPU_CONTROL_H20#define _FPU_CONTROL_H
2121
22#if defined __SPE__ || (defined __NO_FPRS__ && !defined _SOFT_FLOAT)
23# error "SPE/e500 is no longer supported"
24#endif
25
22#ifdef _SOFT_FLOAT26#ifdef _SOFT_FLOAT
2327
24# define _FPU_RESERVED 0xffffffff28# define _FPU_RESERVED 0xffffffff
...@@ -28,41 +32,6 @@ typedef unsigned int fpu_control_t;...@@ -28,41 +32,6 @@ typedef unsigned int fpu_control_t;
28# define _FPU_SETCW(cw) (void) (cw)32# define _FPU_SETCW(cw) (void) (cw)
29extern fpu_control_t __fpu_control;33extern fpu_control_t __fpu_control;
3034
31#elif defined __NO_FPRS__ /* e500 */
32
33/* rounding control */
34# define _FPU_RC_NEAREST 0x00 /* RECOMMENDED */
35# define _FPU_RC_DOWN 0x03
36# define _FPU_RC_UP 0x02
37# define _FPU_RC_ZERO 0x01
38
39/* masking of interrupts */
40# define _FPU_MASK_ZM 0x10 /* zero divide */
41# define _FPU_MASK_OM 0x04 /* overflow */
42# define _FPU_MASK_UM 0x08 /* underflow */
43# define _FPU_MASK_XM 0x40 /* inexact */
44# define _FPU_MASK_IM 0x20 /* invalid operation */
45
46# define _FPU_RESERVED 0x00c10080 /* These bits are reserved and not changed. */
47
48/* Correct IEEE semantics require traps to be enabled at the hardware
49 level; the kernel then does the emulation and determines whether
50 generation of signals from those traps was enabled using prctl. */
51# define _FPU_DEFAULT 0x0000003c /* Default value. */
52# define _FPU_IEEE _FPU_DEFAULT
53
54/* Type of the control word. */
55typedef unsigned int fpu_control_t;
56
57/* Macros for accessing the hardware control word. */
58# define _FPU_GETCW(cw) \
59 __asm__ volatile ("mfspefscr %0" : "=r" (cw))
60# define _FPU_SETCW(cw) \
61 __asm__ volatile ("mtspefscr %0" : : "r" (cw))
62
63/* Default control word set at startup. */
64extern fpu_control_t __fpu_control;
65
66#else /* PowerPC 6xx floating-point. */35#else /* PowerPC 6xx floating-point. */
6736
68/* rounding control */37/* rounding control */
...@@ -71,6 +40,8 @@ extern fpu_control_t __fpu_control;...@@ -71,6 +40,8 @@ extern fpu_control_t __fpu_control;
71# define _FPU_RC_UP 0x0240# define _FPU_RC_UP 0x02
72# define _FPU_RC_ZERO 0x0141# define _FPU_RC_ZERO 0x01
7342
43# define _FPU_MASK_RC (_FPU_RC_NEAREST|_FPU_RC_DOWN|_FPU_RC_UP|_FPU_RC_ZERO)
44
74# define _FPU_MASK_NI 0x04 /* non-ieee mode */45# define _FPU_MASK_NI 0x04 /* non-ieee mode */
7546
76/* masking of interrupts */47/* masking of interrupts */
...@@ -96,20 +67,43 @@ typedef unsigned int fpu_control_t;...@@ -96,20 +67,43 @@ typedef unsigned int fpu_control_t;
96/* Macros for accessing the hardware control word. */67/* Macros for accessing the hardware control word. */
97# define _FPU_GETCW(cw) \68# define _FPU_GETCW(cw) \
98 ({union { double __d; unsigned long long __ll; } __u; \69 ({union { double __d; unsigned long long __ll; } __u; \
99 register double __fr; \70 __asm__ __volatile__("mffs %0" : "=f" (__u.__d)); \
100 __asm__ ("mffs %0" : "=f" (__fr)); \
101 __u.__d = __fr; \
102 (cw) = (fpu_control_t) __u.__ll; \71 (cw) = (fpu_control_t) __u.__ll; \
103 (fpu_control_t) __u.__ll; \72 (fpu_control_t) __u.__ll; \
104 })73 })
10574
75# define _FPU_GET_RC_ISA300() \
76 ({union { double __d; unsigned long long __ll; } __u; \
77 __asm__ __volatile__( \
78 ".machine push; .machine \"power9\"; mffsl %0; .machine pop" \
79 : "=f" (__u.__d)); \
80 (fpu_control_t) (__u.__ll & _FPU_MASK_RC); \
81 })
82
83# ifdef _ARCH_PWR9
84# define _FPU_GET_RC() _FPU_GET_RC_ISA300()
85# elif defined __BUILTIN_CPU_SUPPORTS__
86# define _FPU_GET_RC() \
87 ({fpu_control_t __rc; \
88 __rc = __glibc_likely (__builtin_cpu_supports ("arch_3_00")) \
89 ? _FPU_GET_RC_ISA300 () \
90 : _FPU_GETCW (__rc) & _FPU_MASK_RC; \
91 __rc; \
92 })
93# else
94# define _FPU_GET_RC() \
95 ({fpu_control_t __rc = _FPU_GETCW (__rc) & _FPU_MASK_RC; \
96 __rc; \
97 })
98# endif
99
106# define _FPU_SETCW(cw) \100# define _FPU_SETCW(cw) \
107 { union { double __d; unsigned long long __ll; } __u; \101 { union { double __d; unsigned long long __ll; } __u; \
108 register double __fr; \102 register double __fr; \
109 __u.__ll = 0xfff80000LL << 32; /* This is a QNaN. */ \103 __u.__ll = 0xfff80000LL << 32; /* This is a QNaN. */ \
110 __u.__ll |= (cw) & 0xffffffffLL; \104 __u.__ll |= (cw) & 0xffffffffLL; \
111 __fr = __u.__d; \105 __fr = __u.__d; \
112 __asm__ ("mtfsf 255,%0" : : "f" (__fr)); \106 __asm__ __volatile__("mtfsf 255,%0" : : "f" (__fr)); \
113 }107 }
114108
115/* Default control word set at startup. */109/* Default control word set at startup. */
lib/libc/include/powerpc64le-linux-gnu/gnu/stubs-64-v2.h-2
...@@ -8,9 +8,7 @@...@@ -8,9 +8,7 @@
8#endif8#endif
99
10#define __stub_chflags10#define __stub_chflags
11#define __stub_fattach
12#define __stub_fchflags11#define __stub_fchflags
13#define __stub_fdetach
14#define __stub_gtty12#define __stub_gtty
15#define __stub_lchmod13#define __stub_lchmod
16#define __stub_revoke14#define __stub_revoke
lib/libc/include/riscv64-linux-gnu/gnu/stubs-lp64.h-6
...@@ -13,9 +13,7 @@...@@ -13,9 +13,7 @@
13#define __stub___compat_query_module13#define __stub___compat_query_module
14#define __stub___compat_uselib14#define __stub___compat_uselib
15#define __stub_chflags15#define __stub_chflags
16#define __stub_fattach
17#define __stub_fchflags16#define __stub_fchflags
18#define __stub_fdetach
19#define __stub_feclearexcept17#define __stub_feclearexcept
20#define __stub_fedisableexcept18#define __stub_fedisableexcept
21#define __stub_feenableexcept19#define __stub_feenableexcept
...@@ -33,12 +31,8 @@...@@ -33,12 +31,8 @@
33#define __stub_fesetround31#define __stub_fesetround
34#define __stub_fetestexcept32#define __stub_fetestexcept
35#define __stub_feupdateenv33#define __stub_feupdateenv
36#define __stub_getmsg
37#define __stub_getpmsg
38#define __stub_gtty34#define __stub_gtty
39#define __stub_lchmod35#define __stub_lchmod
40#define __stub_putmsg
41#define __stub_putpmsg
42#define __stub_revoke36#define __stub_revoke
43#define __stub_setlogin37#define __stub_setlogin
44#define __stub_sigreturn38#define __stub_sigreturn
lib/libc/include/s390x-linux-gnu/bits/hwcap.h+5-1
...@@ -38,4 +38,8 @@...@@ -38,4 +38,8 @@
38#define HWCAP_S390_VX 204838#define HWCAP_S390_VX 2048
39#define HWCAP_S390_VXD 409639#define HWCAP_S390_VXD 4096
40#define HWCAP_S390_VXE 819240#define HWCAP_S390_VXE 8192
41#define HWCAP_S390_GS 16384
\ No newline at end of file
41#define HWCAP_S390_GS 16384
42#define HWCAP_S390_VXRS_EXT2 32768
43#define HWCAP_S390_VXRS_PDE 65536
44#define HWCAP_S390_SORT 131072
45#define HWCAP_S390_DFLT 262144
\ No newline at end of file
lib/libc/include/s390x-linux-gnu/bits/xtitypes.h deleted-33
...@@ -1,33 +0,0 @@
1/* bits/xtitypes.h -- Define some types used by <bits/stropts.h>. S390/S390x
2 Copyright (C) 2002-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _STROPTS_H
20# error "Never include <bits/xtitypes.h> directly; use <stropts.h> instead."
21#endif
22
23#ifndef _BITS_XTITYPES_H
24#define _BITS_XTITYPES_H 1
25
26#include <bits/types.h>
27
28/* This type is used by some structs in <bits/stropts.h>. */
29typedef __S32_TYPE __t_scalar_t;
30typedef __U32_TYPE __t_uscalar_t;
31
32
33#endif /* bits/xtitypes.h */
\ No newline at end of file
lib/libc/include/s390x-linux-gnu/gnu/stubs-64.h deleted-24
...@@ -1,24 +0,0 @@
1/* This file is automatically generated.
2 It defines a symbol `__stub_FUNCTION' for each function
3 in the C library which is a stub, meaning it will fail
4 every time called, usually setting errno to ENOSYS. */
5
6#ifdef _LIBC
7 #error Applications may not define the macro _LIBC
8#endif
9
10#define __stub_chflags
11#define __stub_fattach
12#define __stub_fchflags
13#define __stub_fdetach
14#define __stub_getmsg
15#define __stub_gtty
16#define __stub_lchmod
17#define __stub_pkey_alloc
18#define __stub_pkey_free
19#define __stub_putmsg
20#define __stub_revoke
21#define __stub_setlogin
22#define __stub_sigreturn
23#define __stub_sstk
24#define __stub_stty
\ No newline at end of file
lib/libc/include/sparc-linux-gnu/bits/socket-constants.h created+38
...@@ -0,0 +1,38 @@
1/* Socket constants which vary among Linux architectures. Version for SPARC.
2 Copyright (C) 2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _SYS_SOCKET_H
20# error "Never include <bits/socket-constants.h> directly; use <sys/socket.h> instead."
21#endif
22
23#define SOL_SOCKET 65535
24#define SO_ACCEPTCONN 32768
25#define SO_BROADCAST 32
26#define SO_DONTROUTE 16
27#define SO_ERROR 4103
28#define SO_KEEPALIVE 8
29#define SO_LINGER 128
30#define SO_OOBINLINE 256
31#define SO_RCVBUF 4098
32#define SO_RCVLOWAT 2048
33#define SO_RCVTIMEO 8192
34#define SO_REUSEADDR 4
35#define SO_SNDBUF 4097
36#define SO_SNDLOWAT 4096
37#define SO_SNDTIMEO 16384
38#define SO_TYPE 4104
\ No newline at end of file
lib/libc/include/sparc-linux-gnu/gnu/stubs-64.h deleted-26
...@@ -1,26 +0,0 @@
1/* This file is automatically generated.
2 It defines a symbol `__stub_FUNCTION' for each function
3 in the C library which is a stub, meaning it will fail
4 every time called, usually setting errno to ENOSYS. */
5
6#ifdef _LIBC
7 #error Applications may not define the macro _LIBC
8#endif
9
10#define __stub_chflags
11#define __stub_fattach
12#define __stub_fchflags
13#define __stub_fdetach
14#define __stub_getmsg
15#define __stub_getpmsg
16#define __stub_gtty
17#define __stub_lchmod
18#define __stub_pkey_alloc
19#define __stub_pkey_free
20#define __stub_putmsg
21#define __stub_putpmsg
22#define __stub_revoke
23#define __stub_setlogin
24#define __stub_sigreturn
25#define __stub_sstk
26#define __stub_stty
\ No newline at end of file
lib/libc/include/sparcv9-linux-gnu/bits/socket-constants.h created+38
...@@ -0,0 +1,38 @@
1/* Socket constants which vary among Linux architectures. Version for SPARC.
2 Copyright (C) 2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _SYS_SOCKET_H
20# error "Never include <bits/socket-constants.h> directly; use <sys/socket.h> instead."
21#endif
22
23#define SOL_SOCKET 65535
24#define SO_ACCEPTCONN 32768
25#define SO_BROADCAST 32
26#define SO_DONTROUTE 16
27#define SO_ERROR 4103
28#define SO_KEEPALIVE 8
29#define SO_LINGER 128
30#define SO_OOBINLINE 256
31#define SO_RCVBUF 4098
32#define SO_RCVLOWAT 2048
33#define SO_RCVTIMEO 8192
34#define SO_REUSEADDR 4
35#define SO_SNDBUF 4097
36#define SO_SNDLOWAT 4096
37#define SO_SNDTIMEO 16384
38#define SO_TYPE 4104
\ No newline at end of file
lib/libc/include/sparcv9-linux-gnu/gnu/stubs-32.h deleted-26
...@@ -1,26 +0,0 @@
1/* This file is automatically generated.
2 It defines a symbol `__stub_FUNCTION' for each function
3 in the C library which is a stub, meaning it will fail
4 every time called, usually setting errno to ENOSYS. */
5
6#ifdef _LIBC
7 #error Applications may not define the macro _LIBC
8#endif
9
10#define __stub_chflags
11#define __stub_fattach
12#define __stub_fchflags
13#define __stub_fdetach
14#define __stub_getmsg
15#define __stub_getpmsg
16#define __stub_gtty
17#define __stub_lchmod
18#define __stub_pkey_alloc
19#define __stub_pkey_free
20#define __stub_putmsg
21#define __stub_putpmsg
22#define __stub_revoke
23#define __stub_setlogin
24#define __stub_sigreturn
25#define __stub_sstk
26#define __stub_stty
\ No newline at end of file
lib/libc/include/x86_64-linux-gnu/bits/math-vector-fortran.h deleted-43
...@@ -1,43 +0,0 @@
1! Platform-specific declarations of SIMD math functions for Fortran. -*- f90 -*-
2! Copyright (C) 2019 Free Software Foundation, Inc.
3! This file is part of the GNU C Library.
4!
5! The GNU C Library is free software; you can redistribute it and/or
6! modify it under the terms of the GNU Lesser General Public
7! License as published by the Free Software Foundation; either
8! version 2.1 of the License, or (at your option) any later version.
9!
10! The GNU C Library is distributed in the hope that it will be useful,
11! but WITHOUT ANY WARRANTY; without even the implied warranty of
12! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13! Lesser General Public License for more details.
14!
15! You should have received a copy of the GNU Lesser General Public
16! License along with the GNU C Library; if not, see
17! <http://www.gnu.org/licenses/>.
18
19!GCC$ builtin (cos) attributes simd (notinbranch) if('x86_64')
20!GCC$ builtin (cosf) attributes simd (notinbranch) if('x86_64')
21!GCC$ builtin (sin) attributes simd (notinbranch) if('x86_64')
22!GCC$ builtin (sinf) attributes simd (notinbranch) if('x86_64')
23!GCC$ builtin (sincos) attributes simd (notinbranch) if('x86_64')
24!GCC$ builtin (sincosf) attributes simd (notinbranch) if('x86_64')
25!GCC$ builtin (log) attributes simd (notinbranch) if('x86_64')
26!GCC$ builtin (logf) attributes simd (notinbranch) if('x86_64')
27!GCC$ builtin (exp) attributes simd (notinbranch) if('x86_64')
28!GCC$ builtin (expf) attributes simd (notinbranch) if('x86_64')
29!GCC$ builtin (pow) attributes simd (notinbranch) if('x86_64')
30!GCC$ builtin (powf) attributes simd (notinbranch) if('x86_64')
31
32!GCC$ builtin (cos) attributes simd (notinbranch) if('x32')
33!GCC$ builtin (cosf) attributes simd (notinbranch) if('x32')
34!GCC$ builtin (sin) attributes simd (notinbranch) if('x32')
35!GCC$ builtin (sinf) attributes simd (notinbranch) if('x32')
36!GCC$ builtin (sincos) attributes simd (notinbranch) if('x32')
37!GCC$ builtin (sincosf) attributes simd (notinbranch) if('x32')
38!GCC$ builtin (log) attributes simd (notinbranch) if('x32')
39!GCC$ builtin (logf) attributes simd (notinbranch) if('x32')
40!GCC$ builtin (exp) attributes simd (notinbranch) if('x32')
41!GCC$ builtin (expf) attributes simd (notinbranch) if('x32')
42!GCC$ builtin (pow) attributes simd (notinbranch) if('x32')
43!GCC$ builtin (powf) attributes simd (notinbranch) if('x32')
\ No newline at end of file
lib/libc/include/x86_64-linux-gnu/bits/xtitypes.h deleted-33
...@@ -1,33 +0,0 @@
1/* bits/xtitypes.h -- Define some types used by <bits/stropts.h>. x86-64.
2 Copyright (C) 2002-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _STROPTS_H
20# error "Never include <bits/xtitypes.h> directly; use <stropts.h> instead."
21#endif
22
23#ifndef _BITS_XTITYPES_H
24#define _BITS_XTITYPES_H 1
25
26#include <bits/types.h>
27
28/* This type is used by some structs in <bits/stropts.h>. */
29typedef __SLONG32_TYPE __t_scalar_t;
30typedef __ULONG32_TYPE __t_uscalar_t;
31
32
33#endif /* bits/xtitypes.h */
\ No newline at end of file
lib/libc/include/x86_64-linux-gnu/finclude/math-vector-fortran.h created+43
...@@ -0,0 +1,43 @@
1! Platform-specific declarations of SIMD math functions for Fortran. -*- f90 -*-
2! Copyright (C) 2019 Free Software Foundation, Inc.
3! This file is part of the GNU C Library.
4!
5! The GNU C Library is free software; you can redistribute it and/or
6! modify it under the terms of the GNU Lesser General Public
7! License as published by the Free Software Foundation; either
8! version 2.1 of the License, or (at your option) any later version.
9!
10! The GNU C Library is distributed in the hope that it will be useful,
11! but WITHOUT ANY WARRANTY; without even the implied warranty of
12! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13! Lesser General Public License for more details.
14!
15! You should have received a copy of the GNU Lesser General Public
16! License along with the GNU C Library; if not, see
17! <http://www.gnu.org/licenses/>.
18
19!GCC$ builtin (cos) attributes simd (notinbranch) if('x86_64')
20!GCC$ builtin (cosf) attributes simd (notinbranch) if('x86_64')
21!GCC$ builtin (sin) attributes simd (notinbranch) if('x86_64')
22!GCC$ builtin (sinf) attributes simd (notinbranch) if('x86_64')
23!GCC$ builtin (sincos) attributes simd (notinbranch) if('x86_64')
24!GCC$ builtin (sincosf) attributes simd (notinbranch) if('x86_64')
25!GCC$ builtin (log) attributes simd (notinbranch) if('x86_64')
26!GCC$ builtin (logf) attributes simd (notinbranch) if('x86_64')
27!GCC$ builtin (exp) attributes simd (notinbranch) if('x86_64')
28!GCC$ builtin (expf) attributes simd (notinbranch) if('x86_64')
29!GCC$ builtin (pow) attributes simd (notinbranch) if('x86_64')
30!GCC$ builtin (powf) attributes simd (notinbranch) if('x86_64')
31
32!GCC$ builtin (cos) attributes simd (notinbranch) if('x32')
33!GCC$ builtin (cosf) attributes simd (notinbranch) if('x32')
34!GCC$ builtin (sin) attributes simd (notinbranch) if('x32')
35!GCC$ builtin (sinf) attributes simd (notinbranch) if('x32')
36!GCC$ builtin (sincos) attributes simd (notinbranch) if('x32')
37!GCC$ builtin (sincosf) attributes simd (notinbranch) if('x32')
38!GCC$ builtin (log) attributes simd (notinbranch) if('x32')
39!GCC$ builtin (logf) attributes simd (notinbranch) if('x32')
40!GCC$ builtin (exp) attributes simd (notinbranch) if('x32')
41!GCC$ builtin (expf) attributes simd (notinbranch) if('x32')
42!GCC$ builtin (pow) attributes simd (notinbranch) if('x32')
43!GCC$ builtin (powf) attributes simd (notinbranch) if('x32')
\ No newline at end of file
lib/libc/include/x86_64-linux-gnu/gnu/stubs-64.h-4
...@@ -9,13 +9,9 @@...@@ -9,13 +9,9 @@
99
10#define __stub___compat_bdflush10#define __stub___compat_bdflush
11#define __stub_chflags11#define __stub_chflags
12#define __stub_fattach
13#define __stub_fchflags12#define __stub_fchflags
14#define __stub_fdetach
15#define __stub_getmsg
16#define __stub_gtty13#define __stub_gtty
17#define __stub_lchmod14#define __stub_lchmod
18#define __stub_putmsg
19#define __stub_revoke15#define __stub_revoke
20#define __stub_setlogin16#define __stub_setlogin
21#define __stub_sigreturn17#define __stub_sigreturn
lib/libc/include/x86_64-linux-gnu/sys/io.h deleted-183
...@@ -1,183 +0,0 @@
1/* Copyright (C) 1996-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef _SYS_IO_H
19#define _SYS_IO_H 1
20
21#include <features.h>
22
23__BEGIN_DECLS
24
25/* If TURN_ON is TRUE, request for permission to do direct i/o on the
26 port numbers in the range [FROM,FROM+NUM-1]. Otherwise, turn I/O
27 permission off for that range. This call requires root privileges.
28
29 Portability note: not all Linux platforms support this call. Most
30 platforms based on the PC I/O architecture probably will, however.
31 E.g., Linux/Alpha for Alpha PCs supports this. */
32extern int ioperm (unsigned long int __from, unsigned long int __num,
33 int __turn_on) __THROW;
34
35/* Set the I/O privilege level to LEVEL. If LEVEL>3, permission to
36 access any I/O port is granted. This call requires root
37 privileges. */
38extern int iopl (int __level) __THROW;
39
40#if defined __GNUC__ && __GNUC__ >= 2
41
42static __inline unsigned char
43inb (unsigned short int __port)
44{
45 unsigned char _v;
46
47 __asm__ __volatile__ ("inb %w1,%0":"=a" (_v):"Nd" (__port));
48 return _v;
49}
50
51static __inline unsigned char
52inb_p (unsigned short int __port)
53{
54 unsigned char _v;
55
56 __asm__ __volatile__ ("inb %w1,%0\noutb %%al,$0x80":"=a" (_v):"Nd" (__port));
57 return _v;
58}
59
60static __inline unsigned short int
61inw (unsigned short int __port)
62{
63 unsigned short _v;
64
65 __asm__ __volatile__ ("inw %w1,%0":"=a" (_v):"Nd" (__port));
66 return _v;
67}
68
69static __inline unsigned short int
70inw_p (unsigned short int __port)
71{
72 unsigned short int _v;
73
74 __asm__ __volatile__ ("inw %w1,%0\noutb %%al,$0x80":"=a" (_v):"Nd" (__port));
75 return _v;
76}
77
78static __inline unsigned int
79inl (unsigned short int __port)
80{
81 unsigned int _v;
82
83 __asm__ __volatile__ ("inl %w1,%0":"=a" (_v):"Nd" (__port));
84 return _v;
85}
86
87static __inline unsigned int
88inl_p (unsigned short int __port)
89{
90 unsigned int _v;
91 __asm__ __volatile__ ("inl %w1,%0\noutb %%al,$0x80":"=a" (_v):"Nd" (__port));
92 return _v;
93}
94
95static __inline void
96outb (unsigned char __value, unsigned short int __port)
97{
98 __asm__ __volatile__ ("outb %b0,%w1": :"a" (__value), "Nd" (__port));
99}
100
101static __inline void
102outb_p (unsigned char __value, unsigned short int __port)
103{
104 __asm__ __volatile__ ("outb %b0,%w1\noutb %%al,$0x80": :"a" (__value),
105 "Nd" (__port));
106}
107
108static __inline void
109outw (unsigned short int __value, unsigned short int __port)
110{
111 __asm__ __volatile__ ("outw %w0,%w1": :"a" (__value), "Nd" (__port));
112
113}
114
115static __inline void
116outw_p (unsigned short int __value, unsigned short int __port)
117{
118 __asm__ __volatile__ ("outw %w0,%w1\noutb %%al,$0x80": :"a" (__value),
119 "Nd" (__port));
120}
121
122static __inline void
123outl (unsigned int __value, unsigned short int __port)
124{
125 __asm__ __volatile__ ("outl %0,%w1": :"a" (__value), "Nd" (__port));
126}
127
128static __inline void
129outl_p (unsigned int __value, unsigned short int __port)
130{
131 __asm__ __volatile__ ("outl %0,%w1\noutb %%al,$0x80": :"a" (__value),
132 "Nd" (__port));
133}
134
135static __inline void
136insb (unsigned short int __port, void *__addr, unsigned long int __count)
137{
138 __asm__ __volatile__ ("cld ; rep ; insb":"=D" (__addr), "=c" (__count)
139 :"d" (__port), "0" (__addr), "1" (__count));
140}
141
142static __inline void
143insw (unsigned short int __port, void *__addr, unsigned long int __count)
144{
145 __asm__ __volatile__ ("cld ; rep ; insw":"=D" (__addr), "=c" (__count)
146 :"d" (__port), "0" (__addr), "1" (__count));
147}
148
149static __inline void
150insl (unsigned short int __port, void *__addr, unsigned long int __count)
151{
152 __asm__ __volatile__ ("cld ; rep ; insl":"=D" (__addr), "=c" (__count)
153 :"d" (__port), "0" (__addr), "1" (__count));
154}
155
156static __inline void
157outsb (unsigned short int __port, const void *__addr,
158 unsigned long int __count)
159{
160 __asm__ __volatile__ ("cld ; rep ; outsb":"=S" (__addr), "=c" (__count)
161 :"d" (__port), "0" (__addr), "1" (__count));
162}
163
164static __inline void
165outsw (unsigned short int __port, const void *__addr,
166 unsigned long int __count)
167{
168 __asm__ __volatile__ ("cld ; rep ; outsw":"=S" (__addr), "=c" (__count)
169 :"d" (__port), "0" (__addr), "1" (__count));
170}
171
172static __inline void
173outsl (unsigned short int __port, const void *__addr,
174 unsigned long int __count)
175{
176 __asm__ __volatile__ ("cld ; rep ; outsl":"=S" (__addr), "=c" (__count)
177 :"d" (__port), "0" (__addr), "1" (__count));
178}
179
180#endif /* GNU C */
181
182__END_DECLS
183#endif /* _SYS_IO_H */
\ No newline at end of file
lib/libc/include/x86_64-linux-gnux32/bits/math-vector-fortran.h deleted-43
...@@ -1,43 +0,0 @@
1! Platform-specific declarations of SIMD math functions for Fortran. -*- f90 -*-
2! Copyright (C) 2019 Free Software Foundation, Inc.
3! This file is part of the GNU C Library.
4!
5! The GNU C Library is free software; you can redistribute it and/or
6! modify it under the terms of the GNU Lesser General Public
7! License as published by the Free Software Foundation; either
8! version 2.1 of the License, or (at your option) any later version.
9!
10! The GNU C Library is distributed in the hope that it will be useful,
11! but WITHOUT ANY WARRANTY; without even the implied warranty of
12! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13! Lesser General Public License for more details.
14!
15! You should have received a copy of the GNU Lesser General Public
16! License along with the GNU C Library; if not, see
17! <http://www.gnu.org/licenses/>.
18
19!GCC$ builtin (cos) attributes simd (notinbranch) if('x86_64')
20!GCC$ builtin (cosf) attributes simd (notinbranch) if('x86_64')
21!GCC$ builtin (sin) attributes simd (notinbranch) if('x86_64')
22!GCC$ builtin (sinf) attributes simd (notinbranch) if('x86_64')
23!GCC$ builtin (sincos) attributes simd (notinbranch) if('x86_64')
24!GCC$ builtin (sincosf) attributes simd (notinbranch) if('x86_64')
25!GCC$ builtin (log) attributes simd (notinbranch) if('x86_64')
26!GCC$ builtin (logf) attributes simd (notinbranch) if('x86_64')
27!GCC$ builtin (exp) attributes simd (notinbranch) if('x86_64')
28!GCC$ builtin (expf) attributes simd (notinbranch) if('x86_64')
29!GCC$ builtin (pow) attributes simd (notinbranch) if('x86_64')
30!GCC$ builtin (powf) attributes simd (notinbranch) if('x86_64')
31
32!GCC$ builtin (cos) attributes simd (notinbranch) if('x32')
33!GCC$ builtin (cosf) attributes simd (notinbranch) if('x32')
34!GCC$ builtin (sin) attributes simd (notinbranch) if('x32')
35!GCC$ builtin (sinf) attributes simd (notinbranch) if('x32')
36!GCC$ builtin (sincos) attributes simd (notinbranch) if('x32')
37!GCC$ builtin (sincosf) attributes simd (notinbranch) if('x32')
38!GCC$ builtin (log) attributes simd (notinbranch) if('x32')
39!GCC$ builtin (logf) attributes simd (notinbranch) if('x32')
40!GCC$ builtin (exp) attributes simd (notinbranch) if('x32')
41!GCC$ builtin (expf) attributes simd (notinbranch) if('x32')
42!GCC$ builtin (pow) attributes simd (notinbranch) if('x32')
43!GCC$ builtin (powf) attributes simd (notinbranch) if('x32')
\ No newline at end of file
lib/libc/include/x86_64-linux-gnux32/bits/xtitypes.h deleted-33
...@@ -1,33 +0,0 @@
1/* bits/xtitypes.h -- Define some types used by <bits/stropts.h>. x86-64.
2 Copyright (C) 2002-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _STROPTS_H
20# error "Never include <bits/xtitypes.h> directly; use <stropts.h> instead."
21#endif
22
23#ifndef _BITS_XTITYPES_H
24#define _BITS_XTITYPES_H 1
25
26#include <bits/types.h>
27
28/* This type is used by some structs in <bits/stropts.h>. */
29typedef __SLONG32_TYPE __t_scalar_t;
30typedef __ULONG32_TYPE __t_uscalar_t;
31
32
33#endif /* bits/xtitypes.h */
\ No newline at end of file
lib/libc/include/x86_64-linux-gnux32/finclude/math-vector-fortran.h created+43
...@@ -0,0 +1,43 @@
1! Platform-specific declarations of SIMD math functions for Fortran. -*- f90 -*-
2! Copyright (C) 2019 Free Software Foundation, Inc.
3! This file is part of the GNU C Library.
4!
5! The GNU C Library is free software; you can redistribute it and/or
6! modify it under the terms of the GNU Lesser General Public
7! License as published by the Free Software Foundation; either
8! version 2.1 of the License, or (at your option) any later version.
9!
10! The GNU C Library is distributed in the hope that it will be useful,
11! but WITHOUT ANY WARRANTY; without even the implied warranty of
12! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13! Lesser General Public License for more details.
14!
15! You should have received a copy of the GNU Lesser General Public
16! License along with the GNU C Library; if not, see
17! <http://www.gnu.org/licenses/>.
18
19!GCC$ builtin (cos) attributes simd (notinbranch) if('x86_64')
20!GCC$ builtin (cosf) attributes simd (notinbranch) if('x86_64')
21!GCC$ builtin (sin) attributes simd (notinbranch) if('x86_64')
22!GCC$ builtin (sinf) attributes simd (notinbranch) if('x86_64')
23!GCC$ builtin (sincos) attributes simd (notinbranch) if('x86_64')
24!GCC$ builtin (sincosf) attributes simd (notinbranch) if('x86_64')
25!GCC$ builtin (log) attributes simd (notinbranch) if('x86_64')
26!GCC$ builtin (logf) attributes simd (notinbranch) if('x86_64')
27!GCC$ builtin (exp) attributes simd (notinbranch) if('x86_64')
28!GCC$ builtin (expf) attributes simd (notinbranch) if('x86_64')
29!GCC$ builtin (pow) attributes simd (notinbranch) if('x86_64')
30!GCC$ builtin (powf) attributes simd (notinbranch) if('x86_64')
31
32!GCC$ builtin (cos) attributes simd (notinbranch) if('x32')
33!GCC$ builtin (cosf) attributes simd (notinbranch) if('x32')
34!GCC$ builtin (sin) attributes simd (notinbranch) if('x32')
35!GCC$ builtin (sinf) attributes simd (notinbranch) if('x32')
36!GCC$ builtin (sincos) attributes simd (notinbranch) if('x32')
37!GCC$ builtin (sincosf) attributes simd (notinbranch) if('x32')
38!GCC$ builtin (log) attributes simd (notinbranch) if('x32')
39!GCC$ builtin (logf) attributes simd (notinbranch) if('x32')
40!GCC$ builtin (exp) attributes simd (notinbranch) if('x32')
41!GCC$ builtin (expf) attributes simd (notinbranch) if('x32')
42!GCC$ builtin (pow) attributes simd (notinbranch) if('x32')
43!GCC$ builtin (powf) attributes simd (notinbranch) if('x32')
\ No newline at end of file
lib/libc/include/x86_64-linux-gnux32/gnu/stubs-x32.h-4
...@@ -14,13 +14,9 @@...@@ -14,13 +14,9 @@
14#define __stub___compat_query_module14#define __stub___compat_query_module
15#define __stub___compat_uselib15#define __stub___compat_uselib
16#define __stub_chflags16#define __stub_chflags
17#define __stub_fattach
18#define __stub_fchflags17#define __stub_fchflags
19#define __stub_fdetach
20#define __stub_getmsg
21#define __stub_gtty18#define __stub_gtty
22#define __stub_lchmod19#define __stub_lchmod
23#define __stub_putmsg
24#define __stub_revoke20#define __stub_revoke
25#define __stub_setlogin21#define __stub_setlogin
26#define __stub_sigreturn22#define __stub_sigreturn
lib/libc/include/x86_64-linux-gnux32/sys/io.h deleted-183
...@@ -1,183 +0,0 @@
1/* Copyright (C) 1996-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef _SYS_IO_H
19#define _SYS_IO_H 1
20
21#include <features.h>
22
23__BEGIN_DECLS
24
25/* If TURN_ON is TRUE, request for permission to do direct i/o on the
26 port numbers in the range [FROM,FROM+NUM-1]. Otherwise, turn I/O
27 permission off for that range. This call requires root privileges.
28
29 Portability note: not all Linux platforms support this call. Most
30 platforms based on the PC I/O architecture probably will, however.
31 E.g., Linux/Alpha for Alpha PCs supports this. */
32extern int ioperm (unsigned long int __from, unsigned long int __num,
33 int __turn_on) __THROW;
34
35/* Set the I/O privilege level to LEVEL. If LEVEL>3, permission to
36 access any I/O port is granted. This call requires root
37 privileges. */
38extern int iopl (int __level) __THROW;
39
40#if defined __GNUC__ && __GNUC__ >= 2
41
42static __inline unsigned char
43inb (unsigned short int __port)
44{
45 unsigned char _v;
46
47 __asm__ __volatile__ ("inb %w1,%0":"=a" (_v):"Nd" (__port));
48 return _v;
49}
50
51static __inline unsigned char
52inb_p (unsigned short int __port)
53{
54 unsigned char _v;
55
56 __asm__ __volatile__ ("inb %w1,%0\noutb %%al,$0x80":"=a" (_v):"Nd" (__port));
57 return _v;
58}
59
60static __inline unsigned short int
61inw (unsigned short int __port)
62{
63 unsigned short _v;
64
65 __asm__ __volatile__ ("inw %w1,%0":"=a" (_v):"Nd" (__port));
66 return _v;
67}
68
69static __inline unsigned short int
70inw_p (unsigned short int __port)
71{
72 unsigned short int _v;
73
74 __asm__ __volatile__ ("inw %w1,%0\noutb %%al,$0x80":"=a" (_v):"Nd" (__port));
75 return _v;
76}
77
78static __inline unsigned int
79inl (unsigned short int __port)
80{
81 unsigned int _v;
82
83 __asm__ __volatile__ ("inl %w1,%0":"=a" (_v):"Nd" (__port));
84 return _v;
85}
86
87static __inline unsigned int
88inl_p (unsigned short int __port)
89{
90 unsigned int _v;
91 __asm__ __volatile__ ("inl %w1,%0\noutb %%al,$0x80":"=a" (_v):"Nd" (__port));
92 return _v;
93}
94
95static __inline void
96outb (unsigned char __value, unsigned short int __port)
97{
98 __asm__ __volatile__ ("outb %b0,%w1": :"a" (__value), "Nd" (__port));
99}
100
101static __inline void
102outb_p (unsigned char __value, unsigned short int __port)
103{
104 __asm__ __volatile__ ("outb %b0,%w1\noutb %%al,$0x80": :"a" (__value),
105 "Nd" (__port));
106}
107
108static __inline void
109outw (unsigned short int __value, unsigned short int __port)
110{
111 __asm__ __volatile__ ("outw %w0,%w1": :"a" (__value), "Nd" (__port));
112
113}
114
115static __inline void
116outw_p (unsigned short int __value, unsigned short int __port)
117{
118 __asm__ __volatile__ ("outw %w0,%w1\noutb %%al,$0x80": :"a" (__value),
119 "Nd" (__port));
120}
121
122static __inline void
123outl (unsigned int __value, unsigned short int __port)
124{
125 __asm__ __volatile__ ("outl %0,%w1": :"a" (__value), "Nd" (__port));
126}
127
128static __inline void
129outl_p (unsigned int __value, unsigned short int __port)
130{
131 __asm__ __volatile__ ("outl %0,%w1\noutb %%al,$0x80": :"a" (__value),
132 "Nd" (__port));
133}
134
135static __inline void
136insb (unsigned short int __port, void *__addr, unsigned long int __count)
137{
138 __asm__ __volatile__ ("cld ; rep ; insb":"=D" (__addr), "=c" (__count)
139 :"d" (__port), "0" (__addr), "1" (__count));
140}
141
142static __inline void
143insw (unsigned short int __port, void *__addr, unsigned long int __count)
144{
145 __asm__ __volatile__ ("cld ; rep ; insw":"=D" (__addr), "=c" (__count)
146 :"d" (__port), "0" (__addr), "1" (__count));
147}
148
149static __inline void
150insl (unsigned short int __port, void *__addr, unsigned long int __count)
151{
152 __asm__ __volatile__ ("cld ; rep ; insl":"=D" (__addr), "=c" (__count)
153 :"d" (__port), "0" (__addr), "1" (__count));
154}
155
156static __inline void
157outsb (unsigned short int __port, const void *__addr,
158 unsigned long int __count)
159{
160 __asm__ __volatile__ ("cld ; rep ; outsb":"=S" (__addr), "=c" (__count)
161 :"d" (__port), "0" (__addr), "1" (__count));
162}
163
164static __inline void
165outsw (unsigned short int __port, const void *__addr,
166 unsigned long int __count)
167{
168 __asm__ __volatile__ ("cld ; rep ; outsw":"=S" (__addr), "=c" (__count)
169 :"d" (__port), "0" (__addr), "1" (__count));
170}
171
172static __inline void
173outsl (unsigned short int __port, const void *__addr,
174 unsigned long int __count)
175{
176 __asm__ __volatile__ ("cld ; rep ; outsl":"=S" (__addr), "=c" (__count)
177 :"d" (__port), "0" (__addr), "1" (__count));
178}
179
180#endif /* GNU C */
181
182__END_DECLS
183#endif /* _SYS_IO_H */
\ No newline at end of file
src-self-hosted/arg.zig+2-2
...@@ -5,7 +5,7 @@ const mem = std.mem;...@@ -5,7 +5,7 @@ const mem = std.mem;
55
6const Allocator = mem.Allocator;6const Allocator = mem.Allocator;
7const ArrayList = std.ArrayList;7const ArrayList = std.ArrayList;
8const HashMap = std.HashMap;8const StringHashMap = std.StringHashMap;
99
10fn trimStart(slice: []const u8, ch: u8) []const u8 {10fn trimStart(slice: []const u8, ch: u8) []const u8 {
11 var i: usize = 0;11 var i: usize = 0;
...@@ -73,7 +73,7 @@ fn readFlagArguments(allocator: *Allocator, args: []const []const u8, required:...@@ -73,7 +73,7 @@ fn readFlagArguments(allocator: *Allocator, args: []const []const u8, required:
73 }73 }
74}74}
7575
76const HashMapFlags = HashMap([]const u8, FlagArg, std.hash.Fnv1a_32.hash, mem.eql_slice_u8);76const HashMapFlags = StringHashMap(FlagArg);
7777
78// A store for querying found flags and positional arguments.78// A store for querying found flags and positional arguments.
79pub const Args = struct {79pub const Args = struct {
src-self-hosted/compilation.zig+1-1
...@@ -249,7 +249,7 @@ pub const Compilation = struct {...@@ -249,7 +249,7 @@ pub const Compilation = struct {
249 const ArrayTypeTable = std.HashMap(*const Type.Array.Key, *Type.Array, Type.Array.Key.hash, Type.Array.Key.eql);249 const ArrayTypeTable = std.HashMap(*const Type.Array.Key, *Type.Array, Type.Array.Key.hash, Type.Array.Key.eql);
250 const PtrTypeTable = std.HashMap(*const Type.Pointer.Key, *Type.Pointer, Type.Pointer.Key.hash, Type.Pointer.Key.eql);250 const PtrTypeTable = std.HashMap(*const Type.Pointer.Key, *Type.Pointer, Type.Pointer.Key.hash, Type.Pointer.Key.eql);
251 const FnTypeTable = std.HashMap(*const Type.Fn.Key, *Type.Fn, Type.Fn.Key.hash, Type.Fn.Key.eql);251 const FnTypeTable = std.HashMap(*const Type.Fn.Key, *Type.Fn, Type.Fn.Key.hash, Type.Fn.Key.eql);
252 const TypeTable = std.HashMap([]const u8, *Type, mem.hash_slice_u8, mem.eql_slice_u8);252 const TypeTable = std.StringHashMap(*Type);
253253
254 const CompileErrList = std.ArrayList(*Msg);254 const CompileErrList = std.ArrayList(*Msg);
255255
src-self-hosted/decl.zig+1-1
...@@ -20,7 +20,7 @@ pub const Decl = struct {...@@ -20,7 +20,7 @@ pub const Decl = struct {
20 // TODO when we destroy the decl, deref the tree scope20 // TODO when we destroy the decl, deref the tree scope
21 tree_scope: *Scope.AstTree,21 tree_scope: *Scope.AstTree,
2222
23 pub const Table = std.HashMap([]const u8, *Decl, mem.hash_slice_u8, mem.eql_slice_u8);23 pub const Table = std.StringHashMap(*Decl);
2424
25 pub fn cast(base: *Decl, comptime T: type) ?*T {25 pub fn cast(base: *Decl, comptime T: type) ?*T {
26 if (base.id != @field(Id, @typeName(T))) return null;26 if (base.id != @field(Id, @typeName(T))) return null;
src-self-hosted/main.zig+1-1
...@@ -541,7 +541,7 @@ const Fmt = struct {...@@ -541,7 +541,7 @@ const Fmt = struct {
541 color: errmsg.Color,541 color: errmsg.Color,
542 loop: *event.Loop,542 loop: *event.Loop,
543543
544 const SeenMap = std.HashMap([]const u8, void, mem.hash_slice_u8, mem.eql_slice_u8);544 const SeenMap = std.StringHashMap(void);
545};545};
546546
547fn parseLibcPaths(allocator: *Allocator, libc: *LibCInstallation, libc_paths_file: []const u8) void {547fn parseLibcPaths(allocator: *Allocator, libc: *LibCInstallation, libc_paths_file: []const u8) void {
src-self-hosted/package.zig+1-1
...@@ -10,7 +10,7 @@ pub const Package = struct {...@@ -10,7 +10,7 @@ pub const Package = struct {
10 /// relative to root_src_dir10 /// relative to root_src_dir
11 table: Table,11 table: Table,
1212
13 pub const Table = std.HashMap([]const u8, *Package, mem.hash_slice_u8, mem.eql_slice_u8);13 pub const Table = std.StringHashMap(*Package);
1414
15 /// makes internal copies of root_src_dir and root_src_path15 /// makes internal copies of root_src_dir and root_src_path
16 /// allocator should be an arena allocator because Package never frees anything16 /// allocator should be an arena allocator because Package never frees anything
src-self-hosted/stage1.zig+2-2
...@@ -343,7 +343,7 @@ const Fmt = struct {...@@ -343,7 +343,7 @@ const Fmt = struct {
343 color: errmsg.Color,343 color: errmsg.Color,
344 allocator: *mem.Allocator,344 allocator: *mem.Allocator,
345345
346 const SeenMap = std.HashMap([]const u8, void, mem.hash_slice_u8, mem.eql_slice_u8);346 const SeenMap = std.StringHashMap(void);
347};347};
348348
349fn printErrMsgToFile(349fn printErrMsgToFile(
...@@ -376,7 +376,7 @@ fn printErrMsgToFile(...@@ -376,7 +376,7 @@ fn printErrMsgToFile(
376 const text = text_buf.toOwnedSlice();376 const text = text_buf.toOwnedSlice();
377377
378 const stream = &file.outStream().stream;378 const stream = &file.outStream().stream;
379 try stream.print( "{}:{}:{}: error: {}\n", path, start_loc.line + 1, start_loc.column + 1, text);379 try stream.print("{}:{}:{}: error: {}\n", path, start_loc.line + 1, start_loc.column + 1, text);
380380
381 if (!color_on) return;381 if (!color_on) return;
382382
src/all_types.hpp+73-14
...@@ -25,6 +25,7 @@ struct ZigFn;...@@ -25,6 +25,7 @@ struct ZigFn;
25struct Scope;25struct Scope;
26struct ScopeBlock;26struct ScopeBlock;
27struct ScopeFnDef;27struct ScopeFnDef;
28struct ScopeExpr;
28struct ZigType;29struct ZigType;
29struct ZigVar;30struct ZigVar;
30struct ErrorTableEntry;31struct ErrorTableEntry;
...@@ -47,6 +48,7 @@ struct ResultLoc;...@@ -47,6 +48,7 @@ struct ResultLoc;
47struct ResultLocPeer;48struct ResultLocPeer;
48struct ResultLocPeerParent;49struct ResultLocPeerParent;
49struct ResultLocBitCast;50struct ResultLocBitCast;
51struct ResultLocReturn;
5052
51enum PtrLen {53enum PtrLen {
52 PtrLenUnknown,54 PtrLenUnknown,
...@@ -54,6 +56,14 @@ enum PtrLen {...@@ -54,6 +56,14 @@ enum PtrLen {
54 PtrLenC,56 PtrLenC,
55};57};
5658
59// This one corresponds to the builtin.zig enum.
60enum BuiltinPtrSize {
61 BuiltinPtrSizeOne,
62 BuiltinPtrSizeMany,
63 BuiltinPtrSizeSlice,
64 BuiltinPtrSizeC,
65};
66
57enum UndefAllowed {67enum UndefAllowed {
58 UndefOk,68 UndefOk,
59 UndefBad,69 UndefBad,
...@@ -595,6 +605,12 @@ enum CallingConvention {...@@ -595,6 +605,12 @@ enum CallingConvention {
595 CallingConventionAsync,605 CallingConventionAsync,
596};606};
597607
608enum FnInline {
609 FnInlineAuto,
610 FnInlineAlways,
611 FnInlineNever,
612};
613
598struct AstNodeFnProto {614struct AstNodeFnProto {
599 VisibMod visib_mod;615 VisibMod visib_mod;
600 Buf *name;616 Buf *name;
...@@ -604,7 +620,7 @@ struct AstNodeFnProto {...@@ -604,7 +620,7 @@ struct AstNodeFnProto {
604 bool is_var_args;620 bool is_var_args;
605 bool is_extern;621 bool is_extern;
606 bool is_export;622 bool is_export;
607 bool is_inline;623 FnInline fn_inline;
608 CallingConvention cc;624 CallingConvention cc;
609 AstNode *fn_def_node;625 AstNode *fn_def_node;
610 // populated if this is an extern declaration626 // populated if this is an extern declaration
...@@ -743,11 +759,17 @@ struct AstNodeUnwrapOptional {...@@ -743,11 +759,17 @@ struct AstNodeUnwrapOptional {
743 AstNode *expr;759 AstNode *expr;
744};760};
745761
762enum CallModifier {
763 CallModifierNone,
764 CallModifierAsync,
765 CallModifierNoAsync,
766 CallModifierBuiltin,
767};
768
746struct AstNodeFnCallExpr {769struct AstNodeFnCallExpr {
747 AstNode *fn_ref_expr;770 AstNode *fn_ref_expr;
748 ZigList<AstNode *> params;771 ZigList<AstNode *> params;
749 bool is_builtin;772 CallModifier modifier;
750 bool is_async;
751 bool seen; // used by @compileLog773 bool seen; // used by @compileLog
752};774};
753775
...@@ -1445,12 +1467,6 @@ enum FnAnalState {...@@ -1445,12 +1467,6 @@ enum FnAnalState {
1445 FnAnalStateInvalid,1467 FnAnalStateInvalid,
1446};1468};
14471469
1448enum FnInline {
1449 FnInlineAuto,
1450 FnInlineAlways,
1451 FnInlineNever,
1452};
1453
1454struct GlobalExport {1470struct GlobalExport {
1455 Buf name;1471 Buf name;
1456 GlobalLinkageId linkage;1472 GlobalLinkageId linkage;
...@@ -1534,6 +1550,7 @@ enum BuiltinFnId {...@@ -1534,6 +1550,7 @@ enum BuiltinFnId {
1534 BuiltinFnIdMemberName,1550 BuiltinFnIdMemberName,
1535 BuiltinFnIdField,1551 BuiltinFnIdField,
1536 BuiltinFnIdTypeInfo,1552 BuiltinFnIdTypeInfo,
1553 BuiltinFnIdType,
1537 BuiltinFnIdHasField,1554 BuiltinFnIdHasField,
1538 BuiltinFnIdTypeof,1555 BuiltinFnIdTypeof,
1539 BuiltinFnIdAddWithOverflow,1556 BuiltinFnIdAddWithOverflow,
...@@ -1664,6 +1681,7 @@ enum PanicMsgId {...@@ -1664,6 +1681,7 @@ enum PanicMsgId {
1664 PanicMsgIdResumedAnAwaitingFn,1681 PanicMsgIdResumedAnAwaitingFn,
1665 PanicMsgIdFrameTooSmall,1682 PanicMsgIdFrameTooSmall,
1666 PanicMsgIdResumedFnPendingAwait,1683 PanicMsgIdResumedFnPendingAwait,
1684 PanicMsgIdBadNoAsyncCall,
16671685
1668 PanicMsgIdCount,1686 PanicMsgIdCount,
1669};1687};
...@@ -1954,6 +1972,8 @@ struct CodeGen {...@@ -1954,6 +1972,8 @@ struct CodeGen {
1954 ZigFn *panic_fn;1972 ZigFn *panic_fn;
1955 TldFn *panic_tld_fn;1973 TldFn *panic_tld_fn;
19561974
1975 ZigFn *largest_frame_fn;
1976
1957 WantPIC want_pic;1977 WantPIC want_pic;
1958 WantStackCheck want_stack_check;1978 WantStackCheck want_stack_check;
1959 CacheHash cache_hash;1979 CacheHash cache_hash;
...@@ -1986,9 +2006,11 @@ struct CodeGen {...@@ -1986,9 +2006,11 @@ struct CodeGen {
1986 bool generate_error_name_table;2006 bool generate_error_name_table;
1987 bool enable_cache; // mutually exclusive with output_dir2007 bool enable_cache; // mutually exclusive with output_dir
1988 bool enable_time_report;2008 bool enable_time_report;
2009 bool enable_stack_report;
1989 bool system_linker_hack;2010 bool system_linker_hack;
1990 bool reported_bad_link_libc_error;2011 bool reported_bad_link_libc_error;
1991 bool is_dynamic; // shared library rather than static library. dynamic musl rather than static musl.2012 bool is_dynamic; // shared library rather than static library. dynamic musl rather than static musl.
2013 bool need_frame_size_prefix_data;
19922014
1993 //////////////////////////// Participates in Input Parameter Cache Hash2015 //////////////////////////// Participates in Input Parameter Cache Hash
1994 /////// Note: there is a separate cache hash for builtin.zig, when adding fields,2016 /////// Note: there is a separate cache hash for builtin.zig, when adding fields,
...@@ -2051,7 +2073,7 @@ struct CodeGen {...@@ -2051,7 +2073,7 @@ struct CodeGen {
2051};2073};
20522074
2053struct ZigVar {2075struct ZigVar {
2054 Buf name;2076 const char *name;
2055 ConstExprValue *const_value;2077 ConstExprValue *const_value;
2056 ZigType *var_type;2078 ZigType *var_type;
2057 LLVMValueRef value_ref;2079 LLVMValueRef value_ref;
...@@ -2066,7 +2088,6 @@ struct ZigVar {...@@ -2066,7 +2088,6 @@ struct ZigVar {
2066 LLVMValueRef param_value_ref;2088 LLVMValueRef param_value_ref;
2067 size_t mem_slot_index;2089 size_t mem_slot_index;
2068 IrExecutable *owner_exec;2090 IrExecutable *owner_exec;
2069 size_t ref_count;
20702091
2071 // In an inline loop, multiple variables may be created,2092 // In an inline loop, multiple variables may be created,
2072 // In this case, a reference to a variable should follow2093 // In this case, a reference to a variable should follow
...@@ -2076,6 +2097,7 @@ struct ZigVar {...@@ -2076,6 +2097,7 @@ struct ZigVar {
2076 ZigList<GlobalExport> export_list;2097 ZigList<GlobalExport> export_list;
20772098
2078 uint32_t align_bytes;2099 uint32_t align_bytes;
2100 uint32_t ref_count;
20792101
2080 bool shadowable;2102 bool shadowable;
2081 bool src_is_const;2103 bool src_is_const;
...@@ -2106,6 +2128,7 @@ enum ScopeId {...@@ -2106,6 +2128,7 @@ enum ScopeId {
2106 ScopeIdCompTime,2128 ScopeIdCompTime,
2107 ScopeIdRuntime,2129 ScopeIdRuntime,
2108 ScopeIdTypeOf,2130 ScopeIdTypeOf,
2131 ScopeIdExpr,
2109};2132};
21102133
2111struct Scope {2134struct Scope {
...@@ -2211,6 +2234,7 @@ struct ScopeLoop {...@@ -2211,6 +2234,7 @@ struct ScopeLoop {
2211 ZigList<IrInstruction *> *incoming_values;2234 ZigList<IrInstruction *> *incoming_values;
2212 ZigList<IrBasicBlock *> *incoming_blocks;2235 ZigList<IrBasicBlock *> *incoming_blocks;
2213 ResultLocPeerParent *peer_parent;2236 ResultLocPeerParent *peer_parent;
2237 ScopeExpr *spill_scope;
2214};2238};
22152239
2216// This scope blocks certain things from working such as comptime continue2240// This scope blocks certain things from working such as comptime continue
...@@ -2253,6 +2277,24 @@ struct ScopeTypeOf {...@@ -2253,6 +2277,24 @@ struct ScopeTypeOf {
2253 Scope base;2277 Scope base;
2254};2278};
22552279
2280enum MemoizedBool {
2281 MemoizedBoolUnknown,
2282 MemoizedBoolFalse,
2283 MemoizedBoolTrue,
2284};
2285
2286// This scope is created for each expression.
2287// It's used to identify when an instruction needs to be spilled,
2288// so that it can be accessed after a suspend point.
2289struct ScopeExpr {
2290 Scope base;
2291
2292 ScopeExpr **children_ptr;
2293 size_t children_len;
2294
2295 MemoizedBool need_spill;
2296};
2297
2256// synchronized with code in define_builtin_compile_vars2298// synchronized with code in define_builtin_compile_vars
2257enum AtomicOrder {2299enum AtomicOrder {
2258 AtomicOrderUnordered,2300 AtomicOrderUnordered,
...@@ -2435,6 +2477,7 @@ enum IrInstructionId {...@@ -2435,6 +2477,7 @@ enum IrInstructionId {
2435 IrInstructionIdByteOffsetOf,2477 IrInstructionIdByteOffsetOf,
2436 IrInstructionIdBitOffsetOf,2478 IrInstructionIdBitOffsetOf,
2437 IrInstructionIdTypeInfo,2479 IrInstructionIdTypeInfo,
2480 IrInstructionIdType,
2438 IrInstructionIdHasField,2481 IrInstructionIdHasField,
2439 IrInstructionIdTypeId,2482 IrInstructionIdTypeId,
2440 IrInstructionIdSetEvalBranchQuota,2483 IrInstructionIdSetEvalBranchQuota,
...@@ -2491,6 +2534,10 @@ struct IrInstruction {...@@ -2491,6 +2534,10 @@ struct IrInstruction {
2491 // with this child field.2534 // with this child field.
2492 IrInstruction *child;2535 IrInstruction *child;
2493 IrBasicBlock *owner_bb;2536 IrBasicBlock *owner_bb;
2537 // Nearly any instruction can have to be stored as a local variable before suspending
2538 // and then loaded after resuming, in case there is an expression with a suspend point
2539 // in it, such as: x + await y
2540 IrInstruction *spill;
2494 IrInstructionId id;2541 IrInstructionId id;
2495 // true if this instruction was generated by zig and not from user code2542 // true if this instruction was generated by zig and not from user code
2496 bool is_gen;2543 bool is_gen;
...@@ -2718,8 +2765,10 @@ struct IrInstructionCallSrc {...@@ -2718,8 +2765,10 @@ struct IrInstructionCallSrc {
2718 ResultLoc *result_loc;2765 ResultLoc *result_loc;
27192766
2720 IrInstruction *new_stack;2767 IrInstruction *new_stack;
2768
2721 FnInline fn_inline;2769 FnInline fn_inline;
2722 bool is_async;2770 CallModifier modifier;
2771
2723 bool is_async_call_builtin;2772 bool is_async_call_builtin;
2724 bool is_comptime;2773 bool is_comptime;
2725};2774};
...@@ -2733,10 +2782,11 @@ struct IrInstructionCallGen {...@@ -2733,10 +2782,11 @@ struct IrInstructionCallGen {
2733 IrInstruction **args;2782 IrInstruction **args;
2734 IrInstruction *result_loc;2783 IrInstruction *result_loc;
2735 IrInstruction *frame_result_loc;2784 IrInstruction *frame_result_loc;
2736
2737 IrInstruction *new_stack;2785 IrInstruction *new_stack;
2786
2738 FnInline fn_inline;2787 FnInline fn_inline;
2739 bool is_async;2788 CallModifier modifier;
2789
2740 bool is_async_call_builtin;2790 bool is_async_call_builtin;
2741};2791};
27422792
...@@ -3471,6 +3521,12 @@ struct IrInstructionTypeInfo {...@@ -3471,6 +3521,12 @@ struct IrInstructionTypeInfo {
3471 IrInstruction *type_value;3521 IrInstruction *type_value;
3472};3522};
34733523
3524struct IrInstructionType {
3525 IrInstruction base;
3526
3527 IrInstruction *type_info;
3528};
3529
3474struct IrInstructionHasField {3530struct IrInstructionHasField {
3475 IrInstruction base;3531 IrInstruction base;
34763532
...@@ -3567,6 +3623,7 @@ struct IrInstructionAddImplicitReturnType {...@@ -3567,6 +3623,7 @@ struct IrInstructionAddImplicitReturnType {
3567 IrInstruction base;3623 IrInstruction base;
35683624
3569 IrInstruction *value;3625 IrInstruction *value;
3626 ResultLocReturn *result_loc_ret;
3570};3627};
35713628
3572// For float ops which take a single argument3629// For float ops which take a single argument
...@@ -3793,6 +3850,8 @@ struct ResultLocVar {...@@ -3793,6 +3850,8 @@ struct ResultLocVar {
37933850
3794struct ResultLocReturn {3851struct ResultLocReturn {
3795 ResultLoc base;3852 ResultLoc base;
3853
3854 bool implicit_return_type_done;
3796};3855};
37973856
3798struct IrSuspendPosition {3857struct IrSuspendPosition {
src/analyze.cpp+337-88
...@@ -96,6 +96,30 @@ static ScopeDecls **get_container_scope_ptr(ZigType *type_entry) {...@@ -96,6 +96,30 @@ static ScopeDecls **get_container_scope_ptr(ZigType *type_entry) {
96 zig_unreachable();96 zig_unreachable();
97}97}
9898
99static ScopeExpr *find_expr_scope(Scope *scope) {
100 for (;;) {
101 switch (scope->id) {
102 case ScopeIdExpr:
103 return reinterpret_cast<ScopeExpr *>(scope);
104 case ScopeIdDefer:
105 case ScopeIdDeferExpr:
106 case ScopeIdDecls:
107 case ScopeIdFnDef:
108 case ScopeIdCompTime:
109 case ScopeIdVarDecl:
110 case ScopeIdCImport:
111 case ScopeIdSuspend:
112 case ScopeIdTypeOf:
113 case ScopeIdBlock:
114 return nullptr;
115 case ScopeIdLoop:
116 case ScopeIdRuntime:
117 scope = scope->parent;
118 continue;
119 }
120 }
121}
122
99ScopeDecls *get_container_scope(ZigType *type_entry) {123ScopeDecls *get_container_scope(ZigType *type_entry) {
100 return *get_container_scope_ptr(type_entry);124 return *get_container_scope_ptr(type_entry);
101}125}
...@@ -203,6 +227,20 @@ Scope *create_typeof_scope(CodeGen *g, AstNode *node, Scope *parent) {...@@ -203,6 +227,20 @@ Scope *create_typeof_scope(CodeGen *g, AstNode *node, Scope *parent) {
203 return &scope->base;227 return &scope->base;
204}228}
205229
230ScopeExpr *create_expr_scope(CodeGen *g, AstNode *node, Scope *parent) {
231 ScopeExpr *scope = allocate<ScopeExpr>(1);
232 init_scope(g, &scope->base, ScopeIdExpr, node, parent);
233 ScopeExpr *parent_expr = find_expr_scope(parent);
234 if (parent_expr != nullptr) {
235 size_t new_len = parent_expr->children_len + 1;
236 parent_expr->children_ptr = reallocate_nonzero<ScopeExpr *>(
237 parent_expr->children_ptr, parent_expr->children_len, new_len);
238 parent_expr->children_ptr[parent_expr->children_len] = scope;
239 parent_expr->children_len = new_len;
240 }
241 return scope;
242}
243
206ZigType *get_scope_import(Scope *scope) {244ZigType *get_scope_import(Scope *scope) {
207 while (scope) {245 while (scope) {
208 if (scope->id == ScopeIdDecls) {246 if (scope->id == ScopeIdDecls) {
...@@ -1719,6 +1757,32 @@ static ZigType *analyze_fn_type(CodeGen *g, AstNode *proto_node, Scope *child_sc...@@ -1719,6 +1757,32 @@ static ZigType *analyze_fn_type(CodeGen *g, AstNode *proto_node, Scope *child_sc
1719 return g->builtin_types.entry_invalid;1757 return g->builtin_types.entry_invalid;
1720 }1758 }
17211759
1760 switch (specified_return_type->id) {
1761 case ZigTypeIdInvalid:
1762 zig_unreachable();
1763
1764 case ZigTypeIdUndefined:
1765 case ZigTypeIdNull:
1766 case ZigTypeIdArgTuple:
1767 add_node_error(g, fn_proto->return_type,
1768 buf_sprintf("return type '%s' not allowed", buf_ptr(&specified_return_type->name)));
1769 return g->builtin_types.entry_invalid;
1770
1771 case ZigTypeIdOpaque:
1772 {
1773 ErrorMsg* msg = add_node_error(g, fn_proto->return_type,
1774 buf_sprintf("opaque return type '%s' not allowed", buf_ptr(&specified_return_type->name)));
1775 Tld *tld = find_decl(g, &fn_entry->fndef_scope->base, &specified_return_type->name);
1776 if (tld != nullptr) {
1777 add_error_note(g, msg, tld->source_node, buf_sprintf("declared here"));
1778 }
1779 return g->builtin_types.entry_invalid;
1780 }
1781
1782 default:
1783 break;
1784 }
1785
1722 if (fn_proto->auto_err_set) {1786 if (fn_proto->auto_err_set) {
1723 ZigType *inferred_err_set_type = get_auto_err_set_type(g, fn_entry);1787 ZigType *inferred_err_set_type = get_auto_err_set_type(g, fn_entry);
1724 if ((err = type_resolve(g, specified_return_type, ResolveStatusSizeKnown)))1788 if ((err = type_resolve(g, specified_return_type, ResolveStatusSizeKnown)))
...@@ -1744,15 +1808,11 @@ static ZigType *analyze_fn_type(CodeGen *g, AstNode *proto_node, Scope *child_sc...@@ -1744,15 +1808,11 @@ static ZigType *analyze_fn_type(CodeGen *g, AstNode *proto_node, Scope *child_sc
17441808
1745 switch (fn_type_id.return_type->id) {1809 switch (fn_type_id.return_type->id) {
1746 case ZigTypeIdInvalid:1810 case ZigTypeIdInvalid:
1747 zig_unreachable();
1748
1749 case ZigTypeIdUndefined:1811 case ZigTypeIdUndefined:
1750 case ZigTypeIdNull:1812 case ZigTypeIdNull:
1751 case ZigTypeIdArgTuple:1813 case ZigTypeIdArgTuple:
1752 case ZigTypeIdOpaque:1814 case ZigTypeIdOpaque:
1753 add_node_error(g, fn_proto->return_type,1815 zig_unreachable();
1754 buf_sprintf("return type '%s' not allowed", buf_ptr(&fn_type_id.return_type->name)));
1755 return g->builtin_types.entry_invalid;
17561816
1757 case ZigTypeIdComptimeFloat:1817 case ZigTypeIdComptimeFloat:
1758 case ZigTypeIdComptimeInt:1818 case ZigTypeIdComptimeInt:
...@@ -2043,34 +2103,30 @@ static Error resolve_struct_type(CodeGen *g, ZigType *struct_type) {...@@ -2043,34 +2103,30 @@ static Error resolve_struct_type(CodeGen *g, ZigType *struct_type) {
20432103
20442104
2045 // Resolve types for fields2105 // Resolve types for fields
2046 if (!packed) {2106 for (size_t i = 0; i < field_count; i += 1) {
2047 for (size_t i = 0; i < field_count; i += 1) {2107 TypeStructField *field = &struct_type->data.structure.fields[i];
2048 TypeStructField *field = &struct_type->data.structure.fields[i];2108 ZigType *field_type = resolve_struct_field_type(g, field);
2049 ZigType *field_type = resolve_struct_field_type(g, field);2109 if (field_type == nullptr) {
2050 if (field_type == nullptr) {2110 struct_type->data.structure.resolve_status = ResolveStatusInvalid;
2051 struct_type->data.structure.resolve_status = ResolveStatusInvalid;2111 return err;
2052 return err;2112 }
2053 }
2054
2055 if ((err = type_resolve(g, field_type, ResolveStatusSizeKnown))) {
2056 struct_type->data.structure.resolve_status = ResolveStatusInvalid;
2057 return err;
2058 }
20592113
2060 if (struct_type->data.structure.layout == ContainerLayoutExtern &&2114 if ((err = type_resolve(g, field_type, ResolveStatusSizeKnown))) {
2061 !type_allowed_in_extern(g, field_type))2115 struct_type->data.structure.resolve_status = ResolveStatusInvalid;
2062 {2116 return err;
2063 add_node_error(g, field->decl_node,2117 }
2064 buf_sprintf("extern structs cannot contain fields of type '%s'",
2065 buf_ptr(&field_type->name)));
2066 struct_type->data.structure.resolve_status = ResolveStatusInvalid;
2067 return ErrorSemanticAnalyzeFail;
2068 }
20692118
2119 if (struct_type->data.structure.layout == ContainerLayoutExtern &&
2120 !type_allowed_in_extern(g, field_type))
2121 {
2122 add_node_error(g, field->decl_node,
2123 buf_sprintf("extern structs cannot contain fields of type '%s'",
2124 buf_ptr(&field_type->name)));
2125 struct_type->data.structure.resolve_status = ResolveStatusInvalid;
2126 return ErrorSemanticAnalyzeFail;
2070 }2127 }
2071 }2128 }
20722129
2073
2074 return ErrorNone;2130 return ErrorNone;
2075}2131}
20762132
...@@ -2671,6 +2727,10 @@ static Error resolve_struct_alignment(CodeGen *g, ZigType *struct_type) {...@@ -2671,6 +2727,10 @@ static Error resolve_struct_alignment(CodeGen *g, ZigType *struct_type) {
2671 }2727 }
2672 }2728 }
26732729
2730 if (!type_has_bits(struct_type)) {
2731 assert(struct_type->abi_align == 0);
2732 }
2733
2674 struct_type->data.structure.resolve_loop_flag_other = false;2734 struct_type->data.structure.resolve_loop_flag_other = false;
26752735
2676 if (struct_type->data.structure.resolve_status == ResolveStatusInvalid) {2736 if (struct_type->data.structure.resolve_status == ResolveStatusInvalid) {
...@@ -3062,8 +3122,7 @@ ZigFn *create_fn(CodeGen *g, AstNode *proto_node) {...@@ -3062,8 +3122,7 @@ ZigFn *create_fn(CodeGen *g, AstNode *proto_node) {
3062 assert(proto_node->type == NodeTypeFnProto);3122 assert(proto_node->type == NodeTypeFnProto);
3063 AstNodeFnProto *fn_proto = &proto_node->data.fn_proto;3123 AstNodeFnProto *fn_proto = &proto_node->data.fn_proto;
30643124
3065 FnInline inline_value = fn_proto->is_inline ? FnInlineAlways : FnInlineAuto;3125 ZigFn *fn_entry = create_fn_raw(g, fn_proto->fn_inline);
3066 ZigFn *fn_entry = create_fn_raw(g, inline_value);
30673126
3068 fn_entry->proto_node = proto_node;3127 fn_entry->proto_node = proto_node;
3069 fn_entry->body_node = (proto_node->data.fn_proto.fn_def_node == nullptr) ? nullptr :3128 fn_entry->body_node = (proto_node->data.fn_proto.fn_def_node == nullptr) ? nullptr :
...@@ -3111,26 +3170,26 @@ ZigType *get_test_fn_type(CodeGen *g) {...@@ -3111,26 +3170,26 @@ ZigType *get_test_fn_type(CodeGen *g) {
3111 return g->test_fn_type;3170 return g->test_fn_type;
3112}3171}
31133172
3114void add_var_export(CodeGen *g, ZigVar *var, Buf *symbol_name, GlobalLinkageId linkage) {3173void add_var_export(CodeGen *g, ZigVar *var, const char *symbol_name, GlobalLinkageId linkage) {
3115 GlobalExport *global_export = var->export_list.add_one();3174 GlobalExport *global_export = var->export_list.add_one();
3116 memset(global_export, 0, sizeof(GlobalExport));3175 memset(global_export, 0, sizeof(GlobalExport));
3117 buf_init_from_buf(&global_export->name, symbol_name);3176 buf_init_from_str(&global_export->name, symbol_name);
3118 global_export->linkage = linkage;3177 global_export->linkage = linkage;
3119}3178}
31203179
3121void add_fn_export(CodeGen *g, ZigFn *fn_table_entry, Buf *symbol_name, GlobalLinkageId linkage, bool ccc) {3180void add_fn_export(CodeGen *g, ZigFn *fn_table_entry, const char *symbol_name, GlobalLinkageId linkage, bool ccc) {
3122 if (ccc) {3181 if (ccc) {
3123 if (buf_eql_str(symbol_name, "main") && g->libc_link_lib != nullptr) {3182 if (strcmp(symbol_name, "main") == 0 && g->libc_link_lib != nullptr) {
3124 g->have_c_main = true;3183 g->have_c_main = true;
3125 } else if (buf_eql_str(symbol_name, "WinMain") &&3184 } else if (strcmp(symbol_name, "WinMain") == 0 &&
3126 g->zig_target->os == OsWindows)3185 g->zig_target->os == OsWindows)
3127 {3186 {
3128 g->have_winmain = true;3187 g->have_winmain = true;
3129 } else if (buf_eql_str(symbol_name, "WinMainCRTStartup") &&3188 } else if (strcmp(symbol_name, "WinMainCRTStartup") == 0 &&
3130 g->zig_target->os == OsWindows)3189 g->zig_target->os == OsWindows)
3131 {3190 {
3132 g->have_winmain_crt_startup = true;3191 g->have_winmain_crt_startup = true;
3133 } else if (buf_eql_str(symbol_name, "DllMainCRTStartup") &&3192 } else if (strcmp(symbol_name, "DllMainCRTStartup") == 0 &&
3134 g->zig_target->os == OsWindows)3193 g->zig_target->os == OsWindows)
3135 {3194 {
3136 g->have_dllmain_crt_startup = true;3195 g->have_dllmain_crt_startup = true;
...@@ -3139,7 +3198,7 @@ void add_fn_export(CodeGen *g, ZigFn *fn_table_entry, Buf *symbol_name, GlobalLi...@@ -3139,7 +3198,7 @@ void add_fn_export(CodeGen *g, ZigFn *fn_table_entry, Buf *symbol_name, GlobalLi
31393198
3140 GlobalExport *fn_export = fn_table_entry->export_list.add_one();3199 GlobalExport *fn_export = fn_table_entry->export_list.add_one();
3141 memset(fn_export, 0, sizeof(GlobalExport));3200 memset(fn_export, 0, sizeof(GlobalExport));
3142 buf_init_from_buf(&fn_export->name, symbol_name);3201 buf_init_from_str(&fn_export->name, symbol_name);
3143 fn_export->linkage = linkage;3202 fn_export->linkage = linkage;
3144}3203}
31453204
...@@ -3163,7 +3222,7 @@ static void resolve_decl_fn(CodeGen *g, TldFn *tld_fn) {...@@ -3163,7 +3222,7 @@ static void resolve_decl_fn(CodeGen *g, TldFn *tld_fn) {
31633222
3164 if (fn_proto->is_export) {3223 if (fn_proto->is_export) {
3165 bool ccc = (fn_proto->cc == CallingConventionUnspecified || fn_proto->cc == CallingConventionC);3224 bool ccc = (fn_proto->cc == CallingConventionUnspecified || fn_proto->cc == CallingConventionC);
3166 add_fn_export(g, fn_table_entry, &fn_table_entry->symbol_name, GlobalLinkageIdStrong, ccc);3225 add_fn_export(g, fn_table_entry, buf_ptr(&fn_table_entry->symbol_name), GlobalLinkageIdStrong, ccc);
3167 }3226 }
31683227
3169 if (!is_extern) {3228 if (!is_extern) {
...@@ -3522,7 +3581,7 @@ ZigVar *add_variable(CodeGen *g, AstNode *source_node, Scope *parent_scope, Buf...@@ -3522,7 +3581,7 @@ ZigVar *add_variable(CodeGen *g, AstNode *source_node, Scope *parent_scope, Buf
3522 variable_entry->src_arg_index = SIZE_MAX;3581 variable_entry->src_arg_index = SIZE_MAX;
35233582
3524 assert(name);3583 assert(name);
3525 buf_init_from_buf(&variable_entry->name, name);3584 variable_entry->name = strdup(buf_ptr(name));
35263585
3527 if ((err = type_resolve(g, var_type, ResolveStatusAlignmentKnown))) {3586 if ((err = type_resolve(g, var_type, ResolveStatusAlignmentKnown))) {
3528 variable_entry->var_type = g->builtin_types.entry_invalid;3587 variable_entry->var_type = g->builtin_types.entry_invalid;
...@@ -3670,7 +3729,7 @@ static void resolve_decl_var(CodeGen *g, TldVar *tld_var, bool allow_lazy) {...@@ -3670,7 +3729,7 @@ static void resolve_decl_var(CodeGen *g, TldVar *tld_var, bool allow_lazy) {
3670 }3729 }
36713730
3672 if (is_export) {3731 if (is_export) {
3673 add_var_export(g, tld_var->var, &tld_var->var->name, GlobalLinkageIdStrong);3732 add_var_export(g, tld_var->var, tld_var->var->name, GlobalLinkageIdStrong);
3674 }3733 }
36753734
3676 g->global_vars.append(tld_var);3735 g->global_vars.append(tld_var);
...@@ -3879,7 +3938,7 @@ ZigVar *find_variable(CodeGen *g, Scope *scope, Buf *name, ScopeFnDef **crossed_...@@ -3879,7 +3938,7 @@ ZigVar *find_variable(CodeGen *g, Scope *scope, Buf *name, ScopeFnDef **crossed_
3879 while (scope) {3938 while (scope) {
3880 if (scope->id == ScopeIdVarDecl) {3939 if (scope->id == ScopeIdVarDecl) {
3881 ScopeVarDecl *var_scope = (ScopeVarDecl *)scope;3940 ScopeVarDecl *var_scope = (ScopeVarDecl *)scope;
3882 if (buf_eql_buf(name, &var_scope->var->name)) {3941 if (buf_eql_str(name, var_scope->var->name)) {
3883 if (crossed_fndef_scope != nullptr)3942 if (crossed_fndef_scope != nullptr)
3884 *crossed_fndef_scope = my_crossed_fndef_scope;3943 *crossed_fndef_scope = my_crossed_fndef_scope;
3885 return var_scope->var;3944 return var_scope->var;
...@@ -4191,7 +4250,7 @@ bool fn_is_async(ZigFn *fn) {...@@ -4191,7 +4250,7 @@ bool fn_is_async(ZigFn *fn) {
4191 return fn->inferred_async_node != inferred_async_none;4250 return fn->inferred_async_node != inferred_async_none;
4192}4251}
41934252
4194static void add_async_error_notes(CodeGen *g, ErrorMsg *msg, ZigFn *fn) {4253void add_async_error_notes(CodeGen *g, ErrorMsg *msg, ZigFn *fn) {
4195 assert(fn->inferred_async_node != nullptr);4254 assert(fn->inferred_async_node != nullptr);
4196 assert(fn->inferred_async_node != inferred_async_checking);4255 assert(fn->inferred_async_node != inferred_async_checking);
4197 assert(fn->inferred_async_node != inferred_async_none);4256 assert(fn->inferred_async_node != inferred_async_none);
...@@ -4215,7 +4274,7 @@ static void add_async_error_notes(CodeGen *g, ErrorMsg *msg, ZigFn *fn) {...@@ -4215,7 +4274,7 @@ static void add_async_error_notes(CodeGen *g, ErrorMsg *msg, ZigFn *fn) {
4215 add_error_note(g, msg, fn->inferred_async_node,4274 add_error_note(g, msg, fn->inferred_async_node,
4216 buf_sprintf("await here is a suspend point"));4275 buf_sprintf("await here is a suspend point"));
4217 } else if (fn->inferred_async_node->type == NodeTypeFnCallExpr &&4276 } else if (fn->inferred_async_node->type == NodeTypeFnCallExpr &&
4218 fn->inferred_async_node->data.fn_call_expr.is_builtin)4277 fn->inferred_async_node->data.fn_call_expr.modifier == CallModifierBuiltin)
4219 {4278 {
4220 add_error_note(g, msg, fn->inferred_async_node,4279 add_error_note(g, msg, fn->inferred_async_node,
4221 buf_sprintf("@frame() causes function to be async"));4280 buf_sprintf("@frame() causes function to be async"));
...@@ -4229,33 +4288,44 @@ static void add_async_error_notes(CodeGen *g, ErrorMsg *msg, ZigFn *fn) {...@@ -4229,33 +4288,44 @@ static void add_async_error_notes(CodeGen *g, ErrorMsg *msg, ZigFn *fn) {
4229// ErrorIsAsync - yes async4288// ErrorIsAsync - yes async
4230// ErrorSemanticAnalyzeFail - compile error emitted result is invalid4289// ErrorSemanticAnalyzeFail - compile error emitted result is invalid
4231static Error analyze_callee_async(CodeGen *g, ZigFn *fn, ZigFn *callee, AstNode *call_node,4290static Error analyze_callee_async(CodeGen *g, ZigFn *fn, ZigFn *callee, AstNode *call_node,
4232 bool must_not_be_async)4291 bool must_not_be_async, CallModifier modifier)
4233{4292{
4234 if (callee->type_entry->data.fn.fn_type_id.cc != CallingConventionUnspecified)4293 if (modifier == CallModifierNoAsync)
4235 return ErrorNone;4294 return ErrorNone;
4236 if (callee->anal_state == FnAnalStateReady) {4295 bool callee_is_async = false;
4237 analyze_fn_body(g, callee);4296 switch (callee->type_entry->data.fn.fn_type_id.cc) {
4238 if (callee->anal_state == FnAnalStateInvalid) {4297 case CallingConventionUnspecified:
4239 return ErrorSemanticAnalyzeFail;4298 break;
4240 }4299 case CallingConventionAsync:
4300 callee_is_async = true;
4301 break;
4302 default:
4303 return ErrorNone;
4241 }4304 }
4242 bool callee_is_async;4305 if (!callee_is_async) {
4243 if (callee->anal_state == FnAnalStateComplete) {4306 if (callee->anal_state == FnAnalStateReady) {
4244 analyze_fn_async(g, callee, true);4307 analyze_fn_body(g, callee);
4245 if (callee->anal_state == FnAnalStateInvalid) {4308 if (callee->anal_state == FnAnalStateInvalid) {
4246 return ErrorSemanticAnalyzeFail;4309 return ErrorSemanticAnalyzeFail;
4310 }
4247 }4311 }
4248 callee_is_async = fn_is_async(callee);4312 if (callee->anal_state == FnAnalStateComplete) {
4249 } else {4313 analyze_fn_async(g, callee, true);
4250 // If it's already been determined, use that value. Otherwise4314 if (callee->anal_state == FnAnalStateInvalid) {
4251 // assume non-async, emit an error later if it turned out to be async.4315 return ErrorSemanticAnalyzeFail;
4252 if (callee->inferred_async_node == nullptr ||4316 }
4253 callee->inferred_async_node == inferred_async_checking)4317 callee_is_async = fn_is_async(callee);
4254 {
4255 callee->assumed_non_async = call_node;
4256 callee_is_async = false;
4257 } else {4318 } else {
4258 callee_is_async = callee->inferred_async_node != inferred_async_none;4319 // If it's already been determined, use that value. Otherwise
4320 // assume non-async, emit an error later if it turned out to be async.
4321 if (callee->inferred_async_node == nullptr ||
4322 callee->inferred_async_node == inferred_async_checking)
4323 {
4324 callee->assumed_non_async = call_node;
4325 callee_is_async = false;
4326 } else {
4327 callee_is_async = callee->inferred_async_node != inferred_async_none;
4328 }
4259 }4329 }
4260 }4330 }
4261 if (callee_is_async) {4331 if (callee_is_async) {
...@@ -4313,7 +4383,9 @@ static void analyze_fn_async(CodeGen *g, ZigFn *fn, bool resolve_frame) {...@@ -4313,7 +4383,9 @@ static void analyze_fn_async(CodeGen *g, ZigFn *fn, bool resolve_frame) {
4313 // TODO function pointer call here, could be anything4383 // TODO function pointer call here, could be anything
4314 continue;4384 continue;
4315 }4385 }
4316 switch (analyze_callee_async(g, fn, call->fn_entry, call->base.source_node, must_not_be_async)) {4386 switch (analyze_callee_async(g, fn, call->fn_entry, call->base.source_node, must_not_be_async,
4387 call->modifier))
4388 {
4317 case ErrorSemanticAnalyzeFail:4389 case ErrorSemanticAnalyzeFail:
4318 fn->anal_state = FnAnalStateInvalid;4390 fn->anal_state = FnAnalStateInvalid;
4319 return;4391 return;
...@@ -4330,7 +4402,11 @@ static void analyze_fn_async(CodeGen *g, ZigFn *fn, bool resolve_frame) {...@@ -4330,7 +4402,11 @@ static void analyze_fn_async(CodeGen *g, ZigFn *fn, bool resolve_frame) {
4330 }4402 }
4331 for (size_t i = 0; i < fn->await_list.length; i += 1) {4403 for (size_t i = 0; i < fn->await_list.length; i += 1) {
4332 IrInstructionAwaitGen *await = fn->await_list.at(i);4404 IrInstructionAwaitGen *await = fn->await_list.at(i);
4333 switch (analyze_callee_async(g, fn, await->target_fn, await->base.source_node, must_not_be_async)) {4405 // TODO If this is a noasync await, it doesn't count
4406 // https://github.com/ziglang/zig/issues/3157
4407 switch (analyze_callee_async(g, fn, await->target_fn, await->base.source_node, must_not_be_async,
4408 CallModifierNone))
4409 {
4334 case ErrorSemanticAnalyzeFail:4410 case ErrorSemanticAnalyzeFail:
4335 fn->anal_state = FnAnalStateInvalid;4411 fn->anal_state = FnAnalStateInvalid;
4336 return;4412 return;
...@@ -4415,7 +4491,7 @@ static void analyze_fn_ir(CodeGen *g, ZigFn *fn, AstNode *return_type_node) {...@@ -4415,7 +4491,7 @@ static void analyze_fn_ir(CodeGen *g, ZigFn *fn, AstNode *return_type_node) {
44154491
4416 if (g->verbose_ir) {4492 if (g->verbose_ir) {
4417 fprintf(stderr, "fn %s() { // (analyzed)\n", buf_ptr(&fn->symbol_name));4493 fprintf(stderr, "fn %s() { // (analyzed)\n", buf_ptr(&fn->symbol_name));
4418 ir_print(g, stderr, &fn->analyzed_executable, 4, 2);4494 ir_print(g, stderr, &fn->analyzed_executable, 4, IrPassGen);
4419 fprintf(stderr, "}\n");4495 fprintf(stderr, "}\n");
4420 }4496 }
4421 fn->anal_state = FnAnalStateComplete;4497 fn->anal_state = FnAnalStateComplete;
...@@ -4448,8 +4524,8 @@ static void analyze_fn_body(CodeGen *g, ZigFn *fn_table_entry) {...@@ -4448,8 +4524,8 @@ static void analyze_fn_body(CodeGen *g, ZigFn *fn_table_entry) {
4448 if (g->verbose_ir) {4524 if (g->verbose_ir) {
4449 fprintf(stderr, "\n");4525 fprintf(stderr, "\n");
4450 ast_render(stderr, fn_table_entry->body_node, 4);4526 ast_render(stderr, fn_table_entry->body_node, 4);
4451 fprintf(stderr, "\n{ // (IR)\n");4527 fprintf(stderr, "\nfn %s() { // (IR)\n", buf_ptr(&fn_table_entry->symbol_name));
4452 ir_print(g, stderr, &fn_table_entry->ir_executable, 4, 1);4528 ir_print(g, stderr, &fn_table_entry->ir_executable, 4, IrPassSrc);
4453 fprintf(stderr, "}\n");4529 fprintf(stderr, "}\n");
4454 }4530 }
44554531
...@@ -5638,6 +5714,83 @@ static ZigType *get_async_fn_type(CodeGen *g, ZigType *orig_fn_type) {...@@ -5638,6 +5714,83 @@ static ZigType *get_async_fn_type(CodeGen *g, ZigType *orig_fn_type) {
5638 return fn_type;5714 return fn_type;
5639}5715}
56405716
5717// Traverse up to the very top ExprScope, which has children.
5718// We have just arrived at the top from a child. That child,
5719// and its next siblings, do not need to be marked. But the previous
5720// siblings do.
5721// x + (await y)
5722// vs
5723// (await y) + x
5724static void mark_suspension_point(Scope *scope) {
5725 ScopeExpr *child_expr_scope = (scope->id == ScopeIdExpr) ? reinterpret_cast<ScopeExpr *>(scope) : nullptr;
5726 bool looking_for_exprs = true;
5727 for (;;) {
5728 scope = scope->parent;
5729 switch (scope->id) {
5730 case ScopeIdDeferExpr:
5731 case ScopeIdDecls:
5732 case ScopeIdFnDef:
5733 case ScopeIdCompTime:
5734 case ScopeIdCImport:
5735 case ScopeIdSuspend:
5736 case ScopeIdTypeOf:
5737 return;
5738 case ScopeIdVarDecl:
5739 case ScopeIdDefer:
5740 case ScopeIdBlock:
5741 looking_for_exprs = false;
5742 continue;
5743 case ScopeIdRuntime:
5744 continue;
5745 case ScopeIdLoop: {
5746 ScopeLoop *loop_scope = reinterpret_cast<ScopeLoop *>(scope);
5747 if (loop_scope->spill_scope != nullptr) {
5748 loop_scope->spill_scope->need_spill = MemoizedBoolTrue;
5749 }
5750 looking_for_exprs = false;
5751 continue;
5752 }
5753 case ScopeIdExpr: {
5754 if (!looking_for_exprs) {
5755 // Now we're only looking for a block, to see if it's in a loop (see the case ScopeIdBlock)
5756 continue;
5757 }
5758 ScopeExpr *parent_expr_scope = reinterpret_cast<ScopeExpr *>(scope);
5759 if (child_expr_scope != nullptr) {
5760 for (size_t i = 0; parent_expr_scope->children_ptr[i] != child_expr_scope; i += 1) {
5761 assert(i < parent_expr_scope->children_len);
5762 parent_expr_scope->children_ptr[i]->need_spill = MemoizedBoolTrue;
5763 }
5764 }
5765 parent_expr_scope->need_spill = MemoizedBoolTrue;
5766 child_expr_scope = parent_expr_scope;
5767 continue;
5768 }
5769 }
5770 }
5771}
5772
5773static bool scope_needs_spill(Scope *scope) {
5774 ScopeExpr *scope_expr = find_expr_scope(scope);
5775 if (scope_expr == nullptr) return false;
5776
5777 switch (scope_expr->need_spill) {
5778 case MemoizedBoolUnknown:
5779 if (scope_needs_spill(scope_expr->base.parent)) {
5780 scope_expr->need_spill = MemoizedBoolTrue;
5781 return true;
5782 } else {
5783 scope_expr->need_spill = MemoizedBoolFalse;
5784 return false;
5785 }
5786 case MemoizedBoolFalse:
5787 return false;
5788 case MemoizedBoolTrue:
5789 return true;
5790 }
5791 zig_unreachable();
5792}
5793
5641static Error resolve_async_frame(CodeGen *g, ZigType *frame_type) {5794static Error resolve_async_frame(CodeGen *g, ZigType *frame_type) {
5642 Error err;5795 Error err;
56435796
...@@ -5766,16 +5919,87 @@ static Error resolve_async_frame(CodeGen *g, ZigType *frame_type) {...@@ -5766,16 +5919,87 @@ static Error resolve_async_frame(CodeGen *g, ZigType *frame_type) {
5766 if (!fn_is_async(callee))5919 if (!fn_is_async(callee))
5767 continue;5920 continue;
57685921
5769 IrInstructionAllocaGen *alloca_gen = allocate<IrInstructionAllocaGen>(1);5922 mark_suspension_point(call->base.scope);
5770 alloca_gen->base.id = IrInstructionIdAllocaGen;5923
5771 alloca_gen->base.source_node = call->base.source_node;5924 call->frame_result_loc = ir_create_alloca(g, call->base.scope, call->base.source_node, fn,
5772 alloca_gen->base.scope = call->base.scope;5925 callee_frame_type, "");
5773 alloca_gen->base.value.type = get_pointer_to_type(g, callee_frame_type, false);5926 }
5774 alloca_gen->base.ref_count = 1;5927 // Since this frame is async, an await might represent a suspend point, and
5775 alloca_gen->name_hint = "";5928 // therefore need to spill. It also needs to mark expr scopes as having to spill.
5776 fn->alloca_gen_list.append(alloca_gen);5929 // For example: foo() + await z
5777 call->frame_result_loc = &alloca_gen->base;5930 // The funtion call result of foo() must be spilled.
5931 for (size_t i = 0; i < fn->await_list.length; i += 1) {
5932 IrInstructionAwaitGen *await = fn->await_list.at(i);
5933 // TODO If this is a noasync await, it doesn't suspend
5934 // https://github.com/ziglang/zig/issues/3157
5935 if (await->base.value.special != ConstValSpecialRuntime) {
5936 // Known at comptime. No spill, no suspend.
5937 continue;
5938 }
5939 if (await->target_fn != nullptr) {
5940 // we might not need to suspend
5941 analyze_fn_async(g, await->target_fn, false);
5942 if (await->target_fn->anal_state == FnAnalStateInvalid) {
5943 frame_type->data.frame.locals_struct = g->builtin_types.entry_invalid;
5944 return ErrorSemanticAnalyzeFail;
5945 }
5946 if (!fn_is_async(await->target_fn)) {
5947 // This await does not represent a suspend point. No spill needed,
5948 // and no need to mark ExprScope.
5949 continue;
5950 }
5951 }
5952 // This await is a suspend point, but it might not need a spill.
5953 // We do need to mark the ExprScope as having a suspend point in it.
5954 mark_suspension_point(await->base.scope);
5955
5956 if (await->result_loc != nullptr) {
5957 // If there's a result location, that is the spill
5958 continue;
5959 }
5960 if (await->base.ref_count == 0)
5961 continue;
5962 if (!type_has_bits(await->base.value.type))
5963 continue;
5964 await->result_loc = ir_create_alloca(g, await->base.scope, await->base.source_node, fn,
5965 await->base.value.type, "");
5966 }
5967 for (size_t block_i = 0; block_i < fn->analyzed_executable.basic_block_list.length; block_i += 1) {
5968 IrBasicBlock *block = fn->analyzed_executable.basic_block_list.at(block_i);
5969 for (size_t instr_i = 0; instr_i < block->instruction_list.length; instr_i += 1) {
5970 IrInstruction *instruction = block->instruction_list.at(instr_i);
5971 if (instruction->id == IrInstructionIdSuspendFinish) {
5972 mark_suspension_point(instruction->scope);
5973 }
5974 }
5975 }
5976 // Now that we've marked all the expr scopes that have to spill, we go over the instructions
5977 // and spill the relevant ones.
5978 for (size_t block_i = 0; block_i < fn->analyzed_executable.basic_block_list.length; block_i += 1) {
5979 IrBasicBlock *block = fn->analyzed_executable.basic_block_list.at(block_i);
5980 for (size_t instr_i = 0; instr_i < block->instruction_list.length; instr_i += 1) {
5981 IrInstruction *instruction = block->instruction_list.at(instr_i);
5982 if (instruction->id == IrInstructionIdAwaitGen ||
5983 instruction->id == IrInstructionIdVarPtr ||
5984 instruction->id == IrInstructionIdDeclRef ||
5985 instruction->id == IrInstructionIdAllocaGen)
5986 {
5987 // This instruction does its own spilling specially, or otherwise doesn't need it.
5988 continue;
5989 }
5990 if (instruction->value.special != ConstValSpecialRuntime)
5991 continue;
5992 if (instruction->ref_count == 0)
5993 continue;
5994 if (!type_has_bits(instruction->value.type))
5995 continue;
5996 if (scope_needs_spill(instruction->scope)) {
5997 instruction->spill = ir_create_alloca(g, instruction->scope, instruction->source_node,
5998 fn, instruction->value.type, "");
5999 }
6000 }
5778 }6001 }
6002
5779 FnTypeId *fn_type_id = &fn_type->data.fn.fn_type_id;6003 FnTypeId *fn_type_id = &fn_type->data.fn.fn_type_id;
5780 ZigType *ptr_return_type = get_pointer_to_type(g, fn_type_id->return_type, false);6004 ZigType *ptr_return_type = get_pointer_to_type(g, fn_type_id->return_type, false);
57816005
...@@ -5858,6 +6082,11 @@ static Error resolve_async_frame(CodeGen *g, ZigType *frame_type) {...@@ -5858,6 +6082,11 @@ static Error resolve_async_frame(CodeGen *g, ZigType *frame_type) {
5858 frame_type->abi_size = frame_type->data.frame.locals_struct->abi_size;6082 frame_type->abi_size = frame_type->data.frame.locals_struct->abi_size;
5859 frame_type->abi_align = frame_type->data.frame.locals_struct->abi_align;6083 frame_type->abi_align = frame_type->data.frame.locals_struct->abi_align;
5860 frame_type->size_in_bits = frame_type->data.frame.locals_struct->size_in_bits;6084 frame_type->size_in_bits = frame_type->data.frame.locals_struct->size_in_bits;
6085
6086 if (g->largest_frame_fn == nullptr || frame_type->abi_size > g->largest_frame_fn->frame_type->abi_size) {
6087 g->largest_frame_fn = fn;
6088 }
6089
5861 return ErrorNone;6090 return ErrorNone;
5862}6091}
58636092
...@@ -6216,9 +6445,7 @@ void eval_min_max_value(CodeGen *g, ZigType *type_entry, ConstExprValue *const_v...@@ -6216,9 +6445,7 @@ void eval_min_max_value(CodeGen *g, ZigType *type_entry, ConstExprValue *const_v
6216}6445}
62176446
6218static void render_const_val_ptr(CodeGen *g, Buf *buf, ConstExprValue *const_val, ZigType *type_entry) {6447static void render_const_val_ptr(CodeGen *g, Buf *buf, ConstExprValue *const_val, ZigType *type_entry) {
6219 assert(type_entry->id == ZigTypeIdPointer);6448 if (type_entry->id == ZigTypeIdPointer && type_entry->data.pointer.child_type->id == ZigTypeIdOpaque) {
6220
6221 if (type_entry->data.pointer.child_type->id == ZigTypeIdOpaque) {
6222 buf_append_buf(buf, &type_entry->name);6449 buf_append_buf(buf, &type_entry->name);
6223 return;6450 return;
6224 }6451 }
...@@ -7683,12 +7910,19 @@ static void resolve_llvm_types_enum(CodeGen *g, ZigType *enum_type, ResolveStatu...@@ -7683,12 +7910,19 @@ static void resolve_llvm_types_enum(CodeGen *g, ZigType *enum_type, ResolveStatu
7683static void resolve_llvm_types_union(CodeGen *g, ZigType *union_type, ResolveStatus wanted_resolve_status) {7910static void resolve_llvm_types_union(CodeGen *g, ZigType *union_type, ResolveStatus wanted_resolve_status) {
7684 if (union_type->data.unionation.resolve_status >= wanted_resolve_status) return;7911 if (union_type->data.unionation.resolve_status >= wanted_resolve_status) return;
76857912
7913 bool packed = (union_type->data.unionation.layout == ContainerLayoutPacked);
7914
7686 TypeUnionField *most_aligned_union_member = union_type->data.unionation.most_aligned_union_member;7915 TypeUnionField *most_aligned_union_member = union_type->data.unionation.most_aligned_union_member;
7687 ZigType *tag_type = union_type->data.unionation.tag_type;7916 ZigType *tag_type = union_type->data.unionation.tag_type;
7688 uint32_t gen_field_count = union_type->data.unionation.gen_field_count;7917 uint32_t gen_field_count = union_type->data.unionation.gen_field_count;
7689 if (gen_field_count == 0) {7918 if (gen_field_count == 0) {
7690 union_type->llvm_type = get_llvm_type(g, tag_type);7919 if (tag_type == nullptr) {
7691 union_type->llvm_di_type = get_llvm_di_type(g, tag_type);7920 union_type->llvm_type = g->builtin_types.entry_void->llvm_type;
7921 union_type->llvm_di_type = g->builtin_types.entry_void->llvm_di_type;
7922 } else {
7923 union_type->llvm_type = get_llvm_type(g, tag_type);
7924 union_type->llvm_di_type = get_llvm_di_type(g, tag_type);
7925 }
7692 union_type->data.unionation.resolve_status = ResolveStatusLLVMFull;7926 union_type->data.unionation.resolve_status = ResolveStatusLLVMFull;
7693 return;7927 return;
7694 }7928 }
...@@ -7744,9 +7978,9 @@ static void resolve_llvm_types_union(CodeGen *g, ZigType *union_type, ResolveSta...@@ -7744,9 +7978,9 @@ static void resolve_llvm_types_union(CodeGen *g, ZigType *union_type, ResolveSta
7744 most_aligned_union_member->type_entry->llvm_type,7978 most_aligned_union_member->type_entry->llvm_type,
7745 get_llvm_type(g, padding_array),7979 get_llvm_type(g, padding_array),
7746 };7980 };
7747 LLVMStructSetBody(union_type->llvm_type, union_element_types, 2, false);7981 LLVMStructSetBody(union_type->llvm_type, union_element_types, 2, packed);
7748 } else {7982 } else {
7749 LLVMStructSetBody(union_type->llvm_type, &most_aligned_union_member->type_entry->llvm_type, 1, false);7983 LLVMStructSetBody(union_type->llvm_type, &most_aligned_union_member->type_entry->llvm_type, 1, packed);
7750 }7984 }
7751 union_type->data.unionation.union_llvm_type = union_type->llvm_type;7985 union_type->data.unionation.union_llvm_type = union_type->llvm_type;
7752 union_type->data.unionation.gen_tag_index = SIZE_MAX;7986 union_type->data.unionation.gen_tag_index = SIZE_MAX;
...@@ -7785,7 +8019,7 @@ static void resolve_llvm_types_union(CodeGen *g, ZigType *union_type, ResolveSta...@@ -7785,7 +8019,7 @@ static void resolve_llvm_types_union(CodeGen *g, ZigType *union_type, ResolveSta
7785 LLVMTypeRef root_struct_element_types[2];8019 LLVMTypeRef root_struct_element_types[2];
7786 root_struct_element_types[union_type->data.unionation.gen_tag_index] = get_llvm_type(g, tag_type);8020 root_struct_element_types[union_type->data.unionation.gen_tag_index] = get_llvm_type(g, tag_type);
7787 root_struct_element_types[union_type->data.unionation.gen_union_index] = union_type_ref;8021 root_struct_element_types[union_type->data.unionation.gen_union_index] = union_type_ref;
7788 LLVMStructSetBody(union_type->llvm_type, root_struct_element_types, 2, false);8022 LLVMStructSetBody(union_type->llvm_type, root_struct_element_types, 2, packed);
77898023
7790 // create debug type for union8024 // create debug type for union
7791 ZigLLVMDIType *union_di_type = ZigLLVMCreateDebugUnionType(g->dbuilder,8025 ZigLLVMDIType *union_di_type = ZigLLVMCreateDebugUnionType(g->dbuilder,
...@@ -8495,3 +8729,18 @@ void src_assert(bool ok, AstNode *source_node) {...@@ -8495,3 +8729,18 @@ void src_assert(bool ok, AstNode *source_node) {
8495 const char *msg = "assertion failed. This is a bug in the Zig compiler.";8729 const char *msg = "assertion failed. This is a bug in the Zig compiler.";
8496 stage2_panic(msg, strlen(msg));8730 stage2_panic(msg, strlen(msg));
8497}8731}
8732
8733IrInstruction *ir_create_alloca(CodeGen *g, Scope *scope, AstNode *source_node, ZigFn *fn,
8734 ZigType *var_type, const char *name_hint)
8735{
8736 IrInstructionAllocaGen *alloca_gen = allocate<IrInstructionAllocaGen>(1);
8737 alloca_gen->base.id = IrInstructionIdAllocaGen;
8738 alloca_gen->base.source_node = source_node;
8739 alloca_gen->base.scope = scope;
8740 alloca_gen->base.value.type = get_pointer_to_type(g, var_type, false);
8741 alloca_gen->base.ref_count = 1;
8742 alloca_gen->name_hint = name_hint;
8743 fn->alloca_gen_list.append(alloca_gen);
8744 return &alloca_gen->base;
8745}
8746
src/analyze.hpp+8-2
...@@ -114,6 +114,7 @@ ScopeFnDef *create_fndef_scope(CodeGen *g, AstNode *node, Scope *parent, ZigFn *...@@ -114,6 +114,7 @@ ScopeFnDef *create_fndef_scope(CodeGen *g, AstNode *node, Scope *parent, ZigFn *
114Scope *create_comptime_scope(CodeGen *g, AstNode *node, Scope *parent);114Scope *create_comptime_scope(CodeGen *g, AstNode *node, Scope *parent);
115Scope *create_runtime_scope(CodeGen *g, AstNode *node, Scope *parent, IrInstruction *is_comptime);115Scope *create_runtime_scope(CodeGen *g, AstNode *node, Scope *parent, IrInstruction *is_comptime);
116Scope *create_typeof_scope(CodeGen *g, AstNode *node, Scope *parent);116Scope *create_typeof_scope(CodeGen *g, AstNode *node, Scope *parent);
117ScopeExpr *create_expr_scope(CodeGen *g, AstNode *node, Scope *parent);
117118
118void init_const_str_lit(CodeGen *g, ConstExprValue *const_val, Buf *str);119void init_const_str_lit(CodeGen *g, ConstExprValue *const_val, Buf *str);
119ConstExprValue *create_const_str_lit(CodeGen *g, Buf *str);120ConstExprValue *create_const_str_lit(CodeGen *g, Buf *str);
...@@ -188,8 +189,8 @@ ZigType *get_align_amt_type(CodeGen *g);...@@ -188,8 +189,8 @@ ZigType *get_align_amt_type(CodeGen *g);
188ZigPackage *new_anonymous_package(void);189ZigPackage *new_anonymous_package(void);
189190
190Buf *const_value_to_buffer(ConstExprValue *const_val);191Buf *const_value_to_buffer(ConstExprValue *const_val);
191void add_fn_export(CodeGen *g, ZigFn *fn_table_entry, Buf *symbol_name, GlobalLinkageId linkage, bool ccc);192void add_fn_export(CodeGen *g, ZigFn *fn_table_entry, const char *symbol_name, GlobalLinkageId linkage, bool ccc);
192void add_var_export(CodeGen *g, ZigVar *fn_table_entry, Buf *symbol_name, GlobalLinkageId linkage);193void add_var_export(CodeGen *g, ZigVar *fn_table_entry, const char *symbol_name, GlobalLinkageId linkage);
193194
194195
195ConstExprValue *get_builtin_value(CodeGen *codegen, const char *name);196ConstExprValue *get_builtin_value(CodeGen *codegen, const char *name);
...@@ -256,4 +257,9 @@ Error type_val_resolve_zero_bits(CodeGen *g, ConstExprValue *type_val, ZigType *...@@ -256,4 +257,9 @@ Error type_val_resolve_zero_bits(CodeGen *g, ConstExprValue *type_val, ZigType *
256ZigType *resolve_union_field_type(CodeGen *g, TypeUnionField *union_field);257ZigType *resolve_union_field_type(CodeGen *g, TypeUnionField *union_field);
257ZigType *resolve_struct_field_type(CodeGen *g, TypeStructField *struct_field);258ZigType *resolve_struct_field_type(CodeGen *g, TypeStructField *struct_field);
258259
260void add_async_error_notes(CodeGen *g, ErrorMsg *msg, ZigFn *fn);
261
262IrInstruction *ir_create_alloca(CodeGen *g, Scope *scope, AstNode *source_node, ZigFn *fn,
263 ZigType *var_type, const char *name_hint);
264
259#endif265#endif
src/ast_render.cpp+20-8
...@@ -124,8 +124,13 @@ static const char *export_string(bool is_export) {...@@ -124,8 +124,13 @@ static const char *export_string(bool is_export) {
124// zig_unreachable();124// zig_unreachable();
125//}125//}
126126
127static const char *inline_string(bool is_inline) {127static const char *inline_string(FnInline fn_inline) {
128 return is_inline ? "inline " : "";128 switch (fn_inline) {
129 case FnInlineAlways: return "inline ";
130 case FnInlineNever: return "noinline ";
131 case FnInlineAuto: return "";
132 }
133 zig_unreachable();
129}134}
130135
131static const char *const_or_var_string(bool is_const) {136static const char *const_or_var_string(bool is_const) {
...@@ -436,7 +441,7 @@ static void render_node_extra(AstRender *ar, AstNode *node, bool grouped) {...@@ -436,7 +441,7 @@ static void render_node_extra(AstRender *ar, AstNode *node, bool grouped) {
436 const char *pub_str = visib_mod_string(node->data.fn_proto.visib_mod);441 const char *pub_str = visib_mod_string(node->data.fn_proto.visib_mod);
437 const char *extern_str = extern_string(node->data.fn_proto.is_extern);442 const char *extern_str = extern_string(node->data.fn_proto.is_extern);
438 const char *export_str = export_string(node->data.fn_proto.is_export);443 const char *export_str = export_string(node->data.fn_proto.is_export);
439 const char *inline_str = inline_string(node->data.fn_proto.is_inline);444 const char *inline_str = inline_string(node->data.fn_proto.fn_inline);
440 fprintf(ar->f, "%s%s%s%sfn ", pub_str, inline_str, export_str, extern_str);445 fprintf(ar->f, "%s%s%s%sfn ", pub_str, inline_str, export_str, extern_str);
441 if (node->data.fn_proto.name != nullptr) {446 if (node->data.fn_proto.name != nullptr) {
442 print_symbol(ar, node->data.fn_proto.name);447 print_symbol(ar, node->data.fn_proto.name);
...@@ -693,11 +698,18 @@ static void render_node_extra(AstRender *ar, AstNode *node, bool grouped) {...@@ -693,11 +698,18 @@ static void render_node_extra(AstRender *ar, AstNode *node, bool grouped) {
693 }698 }
694 case NodeTypeFnCallExpr:699 case NodeTypeFnCallExpr:
695 {700 {
696 if (node->data.fn_call_expr.is_builtin) {701 switch (node->data.fn_call_expr.modifier) {
697 fprintf(ar->f, "@");702 case CallModifierNone:
698 }703 break;
699 if (node->data.fn_call_expr.is_async) {704 case CallModifierBuiltin:
700 fprintf(ar->f, "async ");705 fprintf(ar->f, "@");
706 break;
707 case CallModifierAsync:
708 fprintf(ar->f, "async ");
709 break;
710 case CallModifierNoAsync:
711 fprintf(ar->f, "noasync ");
712 break;
701 }713 }
702 AstNode *fn_ref_node = node->data.fn_call_expr.fn_ref_expr;714 AstNode *fn_ref_node = node->data.fn_call_expr.fn_ref_expr;
703 bool grouped = (fn_ref_node->type != NodeTypePrefixOpExpr && fn_ref_node->type != NodeTypePointerType);715 bool grouped = (fn_ref_node->type != NodeTypePrefixOpExpr && fn_ref_node->type != NodeTypePointerType);
src/buffer.hpp+5
...@@ -57,6 +57,11 @@ static inline void buf_deinit(Buf *buf) {...@@ -57,6 +57,11 @@ static inline void buf_deinit(Buf *buf) {
57 buf->list.deinit();57 buf->list.deinit();
58}58}
5959
60static inline void buf_destroy(Buf *buf) {
61 buf_deinit(buf);
62 free(buf);
63}
64
60static inline void buf_init_from_mem(Buf *buf, const char *ptr, size_t len) {65static inline void buf_init_from_mem(Buf *buf, const char *ptr, size_t len) {
61 assert(len != SIZE_MAX);66 assert(len != SIZE_MAX);
62 buf->list.resize(len + 1);67 buf->list.resize(len + 1);
src/codegen.cpp+216-85
...@@ -183,9 +183,12 @@ static void render_const_val(CodeGen *g, ConstExprValue *const_val, const char *...@@ -183,9 +183,12 @@ static void render_const_val(CodeGen *g, ConstExprValue *const_val, const char *
183static void render_const_val_global(CodeGen *g, ConstExprValue *const_val, const char *name);183static void render_const_val_global(CodeGen *g, ConstExprValue *const_val, const char *name);
184static LLVMValueRef gen_const_val(CodeGen *g, ConstExprValue *const_val, const char *name);184static LLVMValueRef gen_const_val(CodeGen *g, ConstExprValue *const_val, const char *name);
185static void generate_error_name_table(CodeGen *g);185static void generate_error_name_table(CodeGen *g);
186static bool value_is_all_undef(ConstExprValue *const_val);186static bool value_is_all_undef(CodeGen *g, ConstExprValue *const_val);
187static void gen_undef_init(CodeGen *g, uint32_t ptr_align_bytes, ZigType *value_type, LLVMValueRef ptr);187static void gen_undef_init(CodeGen *g, uint32_t ptr_align_bytes, ZigType *value_type, LLVMValueRef ptr);
188static LLVMValueRef build_alloca(CodeGen *g, ZigType *type_entry, const char *name, uint32_t alignment);188static LLVMValueRef build_alloca(CodeGen *g, ZigType *type_entry, const char *name, uint32_t alignment);
189static LLVMValueRef gen_await_early_return(CodeGen *g, IrInstruction *source_instr,
190 LLVMValueRef target_frame_ptr, ZigType *result_type, ZigType *ptr_result_type,
191 LLVMValueRef result_loc, bool non_async);
189192
190static void addLLVMAttr(LLVMValueRef val, LLVMAttributeIndex attr_index, const char *attr_name) {193static void addLLVMAttr(LLVMValueRef val, LLVMAttributeIndex attr_index, const char *attr_name) {
191 unsigned kind_id = LLVMGetEnumAttributeKindForName(attr_name, strlen(attr_name));194 unsigned kind_id = LLVMGetEnumAttributeKindForName(attr_name, strlen(attr_name));
...@@ -231,18 +234,23 @@ static void addLLVMArgAttrInt(LLVMValueRef fn_val, unsigned param_index, const c...@@ -231,18 +234,23 @@ static void addLLVMArgAttrInt(LLVMValueRef fn_val, unsigned param_index, const c
231 return addLLVMAttrInt(fn_val, param_index + 1, attr_name, attr_val);234 return addLLVMAttrInt(fn_val, param_index + 1, attr_name, attr_val);
232}235}
233236
234static bool is_symbol_available(CodeGen *g, Buf *name) {237static bool is_symbol_available(CodeGen *g, const char *name) {
235 return g->exported_symbol_names.maybe_get(name) == nullptr && g->external_prototypes.maybe_get(name) == nullptr;238 Buf *buf_name = buf_create_from_str(name);
239 bool result =
240 g->exported_symbol_names.maybe_get(buf_name) == nullptr &&
241 g->external_prototypes.maybe_get(buf_name) == nullptr;
242 buf_destroy(buf_name);
243 return result;
236}244}
237245
238static Buf *get_mangled_name(CodeGen *g, Buf *original_name, bool external_linkage) {246static const char *get_mangled_name(CodeGen *g, const char *original_name, bool external_linkage) {
239 if (external_linkage || is_symbol_available(g, original_name)) {247 if (external_linkage || is_symbol_available(g, original_name)) {
240 return original_name;248 return original_name;
241 }249 }
242250
243 int n = 0;251 int n = 0;
244 for (;; n += 1) {252 for (;; n += 1) {
245 Buf *new_name = buf_sprintf("%s.%d", buf_ptr(original_name), n);253 const char *new_name = buf_ptr(buf_sprintf("%s.%d", original_name, n));
246 if (is_symbol_available(g, new_name)) {254 if (is_symbol_available(g, new_name)) {
247 return new_name;255 return new_name;
248 }256 }
...@@ -384,8 +392,8 @@ static bool codegen_have_frame_pointer(CodeGen *g) {...@@ -384,8 +392,8 @@ static bool codegen_have_frame_pointer(CodeGen *g) {
384}392}
385393
386static LLVMValueRef make_fn_llvm_value(CodeGen *g, ZigFn *fn) {394static LLVMValueRef make_fn_llvm_value(CodeGen *g, ZigFn *fn) {
387 Buf *unmangled_name = &fn->symbol_name;395 const char *unmangled_name = buf_ptr(&fn->symbol_name);
388 Buf *symbol_name;396 const char *symbol_name;
389 GlobalLinkageId linkage;397 GlobalLinkageId linkage;
390 if (fn->body_node == nullptr) {398 if (fn->body_node == nullptr) {
391 symbol_name = unmangled_name;399 symbol_name = unmangled_name;
...@@ -395,7 +403,7 @@ static LLVMValueRef make_fn_llvm_value(CodeGen *g, ZigFn *fn) {...@@ -395,7 +403,7 @@ static LLVMValueRef make_fn_llvm_value(CodeGen *g, ZigFn *fn) {
395 linkage = GlobalLinkageIdInternal;403 linkage = GlobalLinkageIdInternal;
396 } else {404 } else {
397 GlobalExport *fn_export = &fn->export_list.items[0];405 GlobalExport *fn_export = &fn->export_list.items[0];
398 symbol_name = &fn_export->name;406 symbol_name = buf_ptr(&fn_export->name);
399 linkage = fn_export->linkage;407 linkage = fn_export->linkage;
400 }408 }
401409
...@@ -405,7 +413,7 @@ static LLVMValueRef make_fn_llvm_value(CodeGen *g, ZigFn *fn) {...@@ -405,7 +413,7 @@ static LLVMValueRef make_fn_llvm_value(CodeGen *g, ZigFn *fn) {
405 g->zig_target->arch == ZigLLVM_x86)413 g->zig_target->arch == ZigLLVM_x86)
406 {414 {
407 // prevent llvm name mangling415 // prevent llvm name mangling
408 symbol_name = buf_sprintf("\x01_%s", buf_ptr(symbol_name));416 symbol_name = buf_ptr(buf_sprintf("\x01_%s", symbol_name));
409 }417 }
410418
411 bool is_async = fn_is_async(fn);419 bool is_async = fn_is_async(fn);
...@@ -417,13 +425,16 @@ static LLVMValueRef make_fn_llvm_value(CodeGen *g, ZigFn *fn) {...@@ -417,13 +425,16 @@ static LLVMValueRef make_fn_llvm_value(CodeGen *g, ZigFn *fn) {
417 LLVMTypeRef fn_llvm_type = fn->raw_type_ref;425 LLVMTypeRef fn_llvm_type = fn->raw_type_ref;
418 LLVMValueRef llvm_fn = nullptr;426 LLVMValueRef llvm_fn = nullptr;
419 if (fn->body_node == nullptr) {427 if (fn->body_node == nullptr) {
420 LLVMValueRef existing_llvm_fn = LLVMGetNamedFunction(g->module, buf_ptr(symbol_name));428 LLVMValueRef existing_llvm_fn = LLVMGetNamedFunction(g->module, symbol_name);
421 if (existing_llvm_fn) {429 if (existing_llvm_fn) {
422 return LLVMConstBitCast(existing_llvm_fn, LLVMPointerType(fn_llvm_type, 0));430 return LLVMConstBitCast(existing_llvm_fn, LLVMPointerType(fn_llvm_type, 0));
423 } else {431 } else {
424 auto entry = g->exported_symbol_names.maybe_get(symbol_name);432 Buf *buf_symbol_name = buf_create_from_str(symbol_name);
433 auto entry = g->exported_symbol_names.maybe_get(buf_symbol_name);
434 buf_destroy(buf_symbol_name);
435
425 if (entry == nullptr) {436 if (entry == nullptr) {
426 llvm_fn = LLVMAddFunction(g->module, buf_ptr(symbol_name), fn_llvm_type);437 llvm_fn = LLVMAddFunction(g->module, symbol_name, fn_llvm_type);
427438
428 if (target_is_wasm(g->zig_target)) {439 if (target_is_wasm(g->zig_target)) {
429 assert(fn->proto_node->type == NodeTypeFnProto);440 assert(fn->proto_node->type == NodeTypeFnProto);
...@@ -437,7 +448,7 @@ static LLVMValueRef make_fn_llvm_value(CodeGen *g, ZigFn *fn) {...@@ -437,7 +448,7 @@ static LLVMValueRef make_fn_llvm_value(CodeGen *g, ZigFn *fn) {
437 TldFn *tld_fn = reinterpret_cast<TldFn *>(entry->value);448 TldFn *tld_fn = reinterpret_cast<TldFn *>(entry->value);
438 // Make the raw_type_ref populated449 // Make the raw_type_ref populated
439 resolve_llvm_types_fn(g, tld_fn->fn_entry);450 resolve_llvm_types_fn(g, tld_fn->fn_entry);
440 tld_fn->fn_entry->llvm_value = LLVMAddFunction(g->module, buf_ptr(symbol_name),451 tld_fn->fn_entry->llvm_value = LLVMAddFunction(g->module, symbol_name,
441 tld_fn->fn_entry->raw_type_ref);452 tld_fn->fn_entry->raw_type_ref);
442 llvm_fn = LLVMConstBitCast(tld_fn->fn_entry->llvm_value, LLVMPointerType(fn_llvm_type, 0));453 llvm_fn = LLVMConstBitCast(tld_fn->fn_entry->llvm_value, LLVMPointerType(fn_llvm_type, 0));
443 return llvm_fn;454 return llvm_fn;
...@@ -445,7 +456,7 @@ static LLVMValueRef make_fn_llvm_value(CodeGen *g, ZigFn *fn) {...@@ -445,7 +456,7 @@ static LLVMValueRef make_fn_llvm_value(CodeGen *g, ZigFn *fn) {
445 }456 }
446 } else {457 } else {
447 if (llvm_fn == nullptr) {458 if (llvm_fn == nullptr) {
448 llvm_fn = LLVMAddFunction(g->module, buf_ptr(symbol_name), fn_llvm_type);459 llvm_fn = LLVMAddFunction(g->module, symbol_name, fn_llvm_type);
449 }460 }
450461
451 for (size_t i = 1; i < fn->export_list.length; i += 1) {462 for (size_t i = 1; i < fn->export_list.length; i += 1) {
...@@ -646,6 +657,7 @@ static ZigLLVMDIScope *get_di_scope(CodeGen *g, Scope *scope) {...@@ -646,6 +657,7 @@ static ZigLLVMDIScope *get_di_scope(CodeGen *g, Scope *scope) {
646 case ScopeIdCompTime:657 case ScopeIdCompTime:
647 case ScopeIdRuntime:658 case ScopeIdRuntime:
648 case ScopeIdTypeOf:659 case ScopeIdTypeOf:
660 case ScopeIdExpr:
649 return get_di_scope(g, scope->parent);661 return get_di_scope(g, scope->parent);
650 }662 }
651 zig_unreachable();663 zig_unreachable();
...@@ -920,6 +932,8 @@ static Buf *panic_msg_buf(PanicMsgId msg_id) {...@@ -920,6 +932,8 @@ static Buf *panic_msg_buf(PanicMsgId msg_id) {
920 return buf_create_from_str("frame too small");932 return buf_create_from_str("frame too small");
921 case PanicMsgIdResumedFnPendingAwait:933 case PanicMsgIdResumedFnPendingAwait:
922 return buf_create_from_str("resumed an async function which can only be awaited");934 return buf_create_from_str("resumed an async function which can only be awaited");
935 case PanicMsgIdBadNoAsyncCall:
936 return buf_create_from_str("async function called with noasync suspended");
923 }937 }
924 zig_unreachable();938 zig_unreachable();
925}939}
...@@ -1052,8 +1066,8 @@ static LLVMValueRef get_add_error_return_trace_addr_fn(CodeGen *g) {...@@ -1052,8 +1066,8 @@ static LLVMValueRef get_add_error_return_trace_addr_fn(CodeGen *g) {
1052 };1066 };
1053 LLVMTypeRef fn_type_ref = LLVMFunctionType(LLVMVoidType(), arg_types, 2, false);1067 LLVMTypeRef fn_type_ref = LLVMFunctionType(LLVMVoidType(), arg_types, 2, false);
10541068
1055 Buf *fn_name = get_mangled_name(g, buf_create_from_str("__zig_add_err_ret_trace_addr"), false);1069 const char *fn_name = get_mangled_name(g, "__zig_add_err_ret_trace_addr", false);
1056 LLVMValueRef fn_val = LLVMAddFunction(g->module, buf_ptr(fn_name), fn_type_ref);1070 LLVMValueRef fn_val = LLVMAddFunction(g->module, fn_name, fn_type_ref);
1057 addLLVMFnAttr(fn_val, "alwaysinline");1071 addLLVMFnAttr(fn_val, "alwaysinline");
1058 LLVMSetLinkage(fn_val, LLVMInternalLinkage);1072 LLVMSetLinkage(fn_val, LLVMInternalLinkage);
1059 LLVMSetFunctionCallConv(fn_val, get_llvm_cc(g, CallingConventionUnspecified));1073 LLVMSetFunctionCallConv(fn_val, get_llvm_cc(g, CallingConventionUnspecified));
...@@ -1132,8 +1146,8 @@ static LLVMValueRef get_return_err_fn(CodeGen *g) {...@@ -1132,8 +1146,8 @@ static LLVMValueRef get_return_err_fn(CodeGen *g) {
1132 };1146 };
1133 LLVMTypeRef fn_type_ref = LLVMFunctionType(LLVMVoidType(), arg_types, 1, false);1147 LLVMTypeRef fn_type_ref = LLVMFunctionType(LLVMVoidType(), arg_types, 1, false);
11341148
1135 Buf *fn_name = get_mangled_name(g, buf_create_from_str("__zig_return_error"), false);1149 const char *fn_name = get_mangled_name(g, "__zig_return_error", false);
1136 LLVMValueRef fn_val = LLVMAddFunction(g->module, buf_ptr(fn_name), fn_type_ref);1150 LLVMValueRef fn_val = LLVMAddFunction(g->module, fn_name, fn_type_ref);
1137 addLLVMFnAttr(fn_val, "noinline"); // so that we can look at return address1151 addLLVMFnAttr(fn_val, "noinline"); // so that we can look at return address
1138 addLLVMFnAttr(fn_val, "cold");1152 addLLVMFnAttr(fn_val, "cold");
1139 LLVMSetLinkage(fn_val, LLVMInternalLinkage);1153 LLVMSetLinkage(fn_val, LLVMInternalLinkage);
...@@ -1202,7 +1216,7 @@ static LLVMValueRef get_safety_crash_err_fn(CodeGen *g) {...@@ -1202,7 +1216,7 @@ static LLVMValueRef get_safety_crash_err_fn(CodeGen *g) {
1202 LLVMSetLinkage(msg_prefix, LLVMInternalLinkage);1216 LLVMSetLinkage(msg_prefix, LLVMInternalLinkage);
1203 LLVMSetGlobalConstant(msg_prefix, true);1217 LLVMSetGlobalConstant(msg_prefix, true);
12041218
1205 Buf *fn_name = get_mangled_name(g, buf_create_from_str("__zig_fail_unwrap"), false);1219 const char *fn_name = get_mangled_name(g, "__zig_fail_unwrap", false);
1206 LLVMTypeRef fn_type_ref;1220 LLVMTypeRef fn_type_ref;
1207 if (g->have_err_ret_tracing) {1221 if (g->have_err_ret_tracing) {
1208 LLVMTypeRef arg_types[] = {1222 LLVMTypeRef arg_types[] = {
...@@ -1216,7 +1230,7 @@ static LLVMValueRef get_safety_crash_err_fn(CodeGen *g) {...@@ -1216,7 +1230,7 @@ static LLVMValueRef get_safety_crash_err_fn(CodeGen *g) {
1216 };1230 };
1217 fn_type_ref = LLVMFunctionType(LLVMVoidType(), arg_types, 1, false);1231 fn_type_ref = LLVMFunctionType(LLVMVoidType(), arg_types, 1, false);
1218 }1232 }
1219 LLVMValueRef fn_val = LLVMAddFunction(g->module, buf_ptr(fn_name), fn_type_ref);1233 LLVMValueRef fn_val = LLVMAddFunction(g->module, fn_name, fn_type_ref);
1220 addLLVMFnAttr(fn_val, "noreturn");1234 addLLVMFnAttr(fn_val, "noreturn");
1221 addLLVMFnAttr(fn_val, "cold");1235 addLLVMFnAttr(fn_val, "cold");
1222 LLVMSetLinkage(fn_val, LLVMInternalLinkage);1236 LLVMSetLinkage(fn_val, LLVMInternalLinkage);
...@@ -1639,7 +1653,6 @@ static void gen_assign_raw(CodeGen *g, LLVMValueRef ptr, ZigType *ptr_type,...@@ -1639,7 +1653,6 @@ static void gen_assign_raw(CodeGen *g, LLVMValueRef ptr, ZigType *ptr_type,
1639 LLVMValueRef ored_value = LLVMBuildOr(g->builder, shifted_value, anded_containing_int, "");1653 LLVMValueRef ored_value = LLVMBuildOr(g->builder, shifted_value, anded_containing_int, "");
16401654
1641 gen_store(g, ored_value, ptr, ptr_type);1655 gen_store(g, ored_value, ptr, ptr_type);
1642 return;
1643}1656}
16441657
1645static void gen_var_debug_decl(CodeGen *g, ZigVar *var) {1658static void gen_var_debug_decl(CodeGen *g, ZigVar *var) {
...@@ -1656,6 +1669,19 @@ static LLVMValueRef ir_llvm_value(CodeGen *g, IrInstruction *instruction) {...@@ -1656,6 +1669,19 @@ static LLVMValueRef ir_llvm_value(CodeGen *g, IrInstruction *instruction) {
1656 if (!type_has_bits(instruction->value.type))1669 if (!type_has_bits(instruction->value.type))
1657 return nullptr;1670 return nullptr;
1658 if (!instruction->llvm_value) {1671 if (!instruction->llvm_value) {
1672 if (instruction->id == IrInstructionIdAwaitGen) {
1673 IrInstructionAwaitGen *await = reinterpret_cast<IrInstructionAwaitGen*>(instruction);
1674 if (await->result_loc != nullptr) {
1675 return get_handle_value(g, ir_llvm_value(g, await->result_loc),
1676 await->result_loc->value.type->data.pointer.child_type, await->result_loc->value.type);
1677 }
1678 }
1679 if (instruction->spill != nullptr) {
1680 ZigType *ptr_type = instruction->spill->value.type;
1681 src_assert(ptr_type->id == ZigTypeIdPointer, instruction->source_node);
1682 return get_handle_value(g, ir_llvm_value(g, instruction->spill),
1683 ptr_type->data.pointer.child_type, instruction->spill->value.type);
1684 }
1659 src_assert(instruction->value.special != ConstValSpecialRuntime, instruction->source_node);1685 src_assert(instruction->value.special != ConstValSpecialRuntime, instruction->source_node);
1660 assert(instruction->value.type);1686 assert(instruction->value.type);
1661 render_const_val(g, &instruction->value, "");1687 render_const_val(g, &instruction->value, "");
...@@ -1787,7 +1813,7 @@ static bool iter_function_params_c_abi(CodeGen *g, ZigType *fn_type, FnWalk *fn_...@@ -1787,7 +1813,7 @@ static bool iter_function_params_c_abi(CodeGen *g, ZigType *fn_type, FnWalk *fn_
1787 fn_walk->data.types.param_di_types->append(get_llvm_di_type(g, ty));1813 fn_walk->data.types.param_di_types->append(get_llvm_di_type(g, ty));
1788 break;1814 break;
1789 case FnWalkIdVars: {1815 case FnWalkIdVars: {
1790 var->value_ref = build_alloca(g, ty, buf_ptr(&var->name), var->align_bytes);1816 var->value_ref = build_alloca(g, ty, var->name, var->align_bytes);
1791 di_arg_index = fn_walk->data.vars.gen_i;1817 di_arg_index = fn_walk->data.vars.gen_i;
1792 fn_walk->data.vars.gen_i += 1;1818 fn_walk->data.vars.gen_i += 1;
1793 dest_ty = ty;1819 dest_ty = ty;
...@@ -1898,7 +1924,7 @@ static bool iter_function_params_c_abi(CodeGen *g, ZigType *fn_type, FnWalk *fn_...@@ -1898,7 +1924,7 @@ static bool iter_function_params_c_abi(CodeGen *g, ZigType *fn_type, FnWalk *fn_
1898 }1924 }
1899 case FnWalkIdVars: {1925 case FnWalkIdVars: {
1900 di_arg_index = fn_walk->data.vars.gen_i;1926 di_arg_index = fn_walk->data.vars.gen_i;
1901 var->value_ref = build_alloca(g, ty, buf_ptr(&var->name), var->align_bytes);1927 var->value_ref = build_alloca(g, ty, var->name, var->align_bytes);
1902 fn_walk->data.vars.gen_i += 1;1928 fn_walk->data.vars.gen_i += 1;
1903 dest_ty = ty;1929 dest_ty = ty;
1904 goto var_ok;1930 goto var_ok;
...@@ -1931,7 +1957,7 @@ var_ok:...@@ -1931,7 +1957,7 @@ var_ok:
1931 if (dest_ty != nullptr && var->decl_node) {1957 if (dest_ty != nullptr && var->decl_node) {
1932 // arg index + 1 because the 0 index is return value1958 // arg index + 1 because the 0 index is return value
1933 var->di_loc_var = ZigLLVMCreateParameterVariable(g->dbuilder, get_di_scope(g, var->parent_scope),1959 var->di_loc_var = ZigLLVMCreateParameterVariable(g->dbuilder, get_di_scope(g, var->parent_scope),
1934 buf_ptr(&var->name), fn_walk->data.vars.import->data.structure.root_struct->di_file,1960 var->name, fn_walk->data.vars.import->data.structure.root_struct->di_file,
1935 (unsigned)(var->decl_node->line + 1),1961 (unsigned)(var->decl_node->line + 1),
1936 get_llvm_di_type(g, dest_ty), !g->strip_debug_symbols, 0, di_arg_index + 1);1962 get_llvm_di_type(g, dest_ty), !g->strip_debug_symbols, 0, di_arg_index + 1);
1937 }1963 }
...@@ -2042,8 +2068,8 @@ static LLVMValueRef get_merge_err_ret_traces_fn_val(CodeGen *g) {...@@ -2042,8 +2068,8 @@ static LLVMValueRef get_merge_err_ret_traces_fn_val(CodeGen *g) {
2042 };2068 };
2043 LLVMTypeRef fn_type_ref = LLVMFunctionType(LLVMVoidType(), param_types, 2, false);2069 LLVMTypeRef fn_type_ref = LLVMFunctionType(LLVMVoidType(), param_types, 2, false);
20442070
2045 Buf *fn_name = get_mangled_name(g, buf_create_from_str("__zig_merge_error_return_traces"), false);2071 const char *fn_name = get_mangled_name(g, "__zig_merge_error_return_traces", false);
2046 LLVMValueRef fn_val = LLVMAddFunction(g->module, buf_ptr(fn_name), fn_type_ref);2072 LLVMValueRef fn_val = LLVMAddFunction(g->module, fn_name, fn_type_ref);
2047 LLVMSetLinkage(fn_val, LLVMInternalLinkage);2073 LLVMSetLinkage(fn_val, LLVMInternalLinkage);
2048 LLVMSetFunctionCallConv(fn_val, get_llvm_cc(g, CallingConventionUnspecified));2074 LLVMSetFunctionCallConv(fn_val, get_llvm_cc(g, CallingConventionUnspecified));
2049 addLLVMFnAttr(fn_val, "nounwind");2075 addLLVMFnAttr(fn_val, "nounwind");
...@@ -3377,7 +3403,7 @@ static LLVMValueRef ir_render_load_ptr(CodeGen *g, IrExecutable *executable, IrI...@@ -3377,7 +3403,7 @@ static LLVMValueRef ir_render_load_ptr(CodeGen *g, IrExecutable *executable, IrI
3377 return LLVMBuildTrunc(g->builder, shifted_value, get_llvm_type(g, child_type), "");3403 return LLVMBuildTrunc(g->builder, shifted_value, get_llvm_type(g, child_type), "");
3378}3404}
33793405
3380static bool value_is_all_undef_array(ConstExprValue *const_val, size_t len) {3406static bool value_is_all_undef_array(CodeGen *g, ConstExprValue *const_val, size_t len) {
3381 switch (const_val->data.x_array.special) {3407 switch (const_val->data.x_array.special) {
3382 case ConstArraySpecialUndef:3408 case ConstArraySpecialUndef:
3383 return true;3409 return true;
...@@ -3385,7 +3411,7 @@ static bool value_is_all_undef_array(ConstExprValue *const_val, size_t len) {...@@ -3385,7 +3411,7 @@ static bool value_is_all_undef_array(ConstExprValue *const_val, size_t len) {
3385 return false;3411 return false;
3386 case ConstArraySpecialNone:3412 case ConstArraySpecialNone:
3387 for (size_t i = 0; i < len; i += 1) {3413 for (size_t i = 0; i < len; i += 1) {
3388 if (!value_is_all_undef(&const_val->data.x_array.data.s_none.elements[i]))3414 if (!value_is_all_undef(g, &const_val->data.x_array.data.s_none.elements[i]))
3389 return false;3415 return false;
3390 }3416 }
3391 return true;3417 return true;
...@@ -3393,7 +3419,12 @@ static bool value_is_all_undef_array(ConstExprValue *const_val, size_t len) {...@@ -3393,7 +3419,12 @@ static bool value_is_all_undef_array(ConstExprValue *const_val, size_t len) {
3393 zig_unreachable();3419 zig_unreachable();
3394}3420}
33953421
3396static bool value_is_all_undef(ConstExprValue *const_val) {3422static bool value_is_all_undef(CodeGen *g, ConstExprValue *const_val) {
3423 Error err;
3424 if (const_val->special == ConstValSpecialLazy &&
3425 (err = ir_resolve_lazy(g, nullptr, const_val)))
3426 report_errors_and_exit(g);
3427
3397 switch (const_val->special) {3428 switch (const_val->special) {
3398 case ConstValSpecialLazy:3429 case ConstValSpecialLazy:
3399 zig_unreachable();3430 zig_unreachable();
...@@ -3404,14 +3435,14 @@ static bool value_is_all_undef(ConstExprValue *const_val) {...@@ -3404,14 +3435,14 @@ static bool value_is_all_undef(ConstExprValue *const_val) {
3404 case ConstValSpecialStatic:3435 case ConstValSpecialStatic:
3405 if (const_val->type->id == ZigTypeIdStruct) {3436 if (const_val->type->id == ZigTypeIdStruct) {
3406 for (size_t i = 0; i < const_val->type->data.structure.src_field_count; i += 1) {3437 for (size_t i = 0; i < const_val->type->data.structure.src_field_count; i += 1) {
3407 if (!value_is_all_undef(&const_val->data.x_struct.fields[i]))3438 if (!value_is_all_undef(g, &const_val->data.x_struct.fields[i]))
3408 return false;3439 return false;
3409 }3440 }
3410 return true;3441 return true;
3411 } else if (const_val->type->id == ZigTypeIdArray) {3442 } else if (const_val->type->id == ZigTypeIdArray) {
3412 return value_is_all_undef_array(const_val, const_val->type->data.array.len);3443 return value_is_all_undef_array(g, const_val, const_val->type->data.array.len);
3413 } else if (const_val->type->id == ZigTypeIdVector) {3444 } else if (const_val->type->id == ZigTypeIdVector) {
3414 return value_is_all_undef_array(const_val, const_val->type->data.vector.len);3445 return value_is_all_undef_array(g, const_val, const_val->type->data.vector.len);
3415 } else {3446 } else {
3416 return false;3447 return false;
3417 }3448 }
...@@ -3532,7 +3563,7 @@ static LLVMValueRef ir_render_store_ptr(CodeGen *g, IrExecutable *executable, Ir...@@ -3532,7 +3563,7 @@ static LLVMValueRef ir_render_store_ptr(CodeGen *g, IrExecutable *executable, Ir
3532 return nullptr;3563 return nullptr;
3533 }3564 }
35343565
3535 bool have_init_expr = !value_is_all_undef(&instruction->value->value);3566 bool have_init_expr = !value_is_all_undef(g, &instruction->value->value);
3536 if (have_init_expr) {3567 if (have_init_expr) {
3537 LLVMValueRef ptr = ir_llvm_value(g, instruction->ptr);3568 LLVMValueRef ptr = ir_llvm_value(g, instruction->ptr);
3538 LLVMValueRef value = ir_llvm_value(g, instruction->value);3569 LLVMValueRef value = ir_llvm_value(g, instruction->value);
...@@ -3720,12 +3751,11 @@ static void render_async_spills(CodeGen *g) {...@@ -3720,12 +3751,11 @@ static void render_async_spills(CodeGen *g) {
3720 continue;3751 continue;
3721 }3752 }
37223753
3723 var->value_ref = LLVMBuildStructGEP(g->builder, g->cur_frame_ptr, async_var_index,3754 var->value_ref = LLVMBuildStructGEP(g->builder, g->cur_frame_ptr, async_var_index, var->name);
3724 buf_ptr(&var->name));
3725 async_var_index += 1;3755 async_var_index += 1;
3726 if (var->decl_node) {3756 if (var->decl_node) {
3727 var->di_loc_var = ZigLLVMCreateAutoVariable(g->dbuilder, get_di_scope(g, var->parent_scope),3757 var->di_loc_var = ZigLLVMCreateAutoVariable(g->dbuilder, get_di_scope(g, var->parent_scope),
3728 buf_ptr(&var->name), import->data.structure.root_struct->di_file,3758 var->name, import->data.structure.root_struct->di_file,
3729 (unsigned)(var->decl_node->line + 1),3759 (unsigned)(var->decl_node->line + 1),
3730 get_llvm_di_type(g, var->var_type), !g->strip_debug_symbols, 0);3760 get_llvm_di_type(g, var->var_type), !g->strip_debug_symbols, 0);
3731 gen_var_debug_decl(g, var);3761 gen_var_debug_decl(g, var);
...@@ -3768,6 +3798,7 @@ static void render_async_var_decls(CodeGen *g, Scope *scope) {...@@ -3768,6 +3798,7 @@ static void render_async_var_decls(CodeGen *g, Scope *scope) {
3768 case ScopeIdCompTime:3798 case ScopeIdCompTime:
3769 case ScopeIdRuntime:3799 case ScopeIdRuntime:
3770 case ScopeIdTypeOf:3800 case ScopeIdTypeOf:
3801 case ScopeIdExpr:
3771 scope = scope->parent;3802 scope = scope->parent;
3772 continue;3803 continue;
3773 }3804 }
...@@ -3775,6 +3806,7 @@ static void render_async_var_decls(CodeGen *g, Scope *scope) {...@@ -3775,6 +3806,7 @@ static void render_async_var_decls(CodeGen *g, Scope *scope) {
3775}3806}
37763807
3777static LLVMValueRef gen_frame_size(CodeGen *g, LLVMValueRef fn_val) {3808static LLVMValueRef gen_frame_size(CodeGen *g, LLVMValueRef fn_val) {
3809 assert(g->need_frame_size_prefix_data);
3778 LLVMTypeRef usize_llvm_type = g->builtin_types.entry_usize->llvm_type;3810 LLVMTypeRef usize_llvm_type = g->builtin_types.entry_usize->llvm_type;
3779 LLVMTypeRef ptr_usize_llvm_type = LLVMPointerType(usize_llvm_type, 0);3811 LLVMTypeRef ptr_usize_llvm_type = LLVMPointerType(usize_llvm_type, 0);
3780 LLVMValueRef casted_fn_val = LLVMBuildBitCast(g->builder, fn_val, ptr_usize_llvm_type, "");3812 LLVMValueRef casted_fn_val = LLVMBuildBitCast(g->builder, fn_val, ptr_usize_llvm_type, "");
...@@ -3836,7 +3868,7 @@ static LLVMValueRef ir_render_call(CodeGen *g, IrExecutable *executable, IrInstr...@@ -3836,7 +3868,7 @@ static LLVMValueRef ir_render_call(CodeGen *g, IrExecutable *executable, IrInstr
3836 LLVMValueRef ret_ptr;3868 LLVMValueRef ret_ptr;
3837 if (callee_is_async) {3869 if (callee_is_async) {
3838 if (instruction->new_stack == nullptr) {3870 if (instruction->new_stack == nullptr) {
3839 if (instruction->is_async) {3871 if (instruction->modifier == CallModifierAsync) {
3840 frame_result_loc = result_loc;3872 frame_result_loc = result_loc;
3841 } else {3873 } else {
3842 frame_result_loc = ir_llvm_value(g, instruction->frame_result_loc);3874 frame_result_loc = ir_llvm_value(g, instruction->frame_result_loc);
...@@ -3877,7 +3909,7 @@ static LLVMValueRef ir_render_call(CodeGen *g, IrExecutable *executable, IrInstr...@@ -3877,7 +3909,7 @@ static LLVMValueRef ir_render_call(CodeGen *g, IrExecutable *executable, IrInstr
3877 }3909 }
3878 }3910 }
3879 }3911 }
3880 if (instruction->is_async) {3912 if (instruction->modifier == CallModifierAsync) {
3881 if (instruction->new_stack == nullptr) {3913 if (instruction->new_stack == nullptr) {
3882 awaiter_init_val = zero;3914 awaiter_init_val = zero;
38833915
...@@ -3902,9 +3934,15 @@ static LLVMValueRef ir_render_call(CodeGen *g, IrExecutable *executable, IrInstr...@@ -3902,9 +3934,15 @@ static LLVMValueRef ir_render_call(CodeGen *g, IrExecutable *executable, IrInstr
3902 // even if prefix_arg_err_ret_stack is true, let the async function do its own3934 // even if prefix_arg_err_ret_stack is true, let the async function do its own
3903 // initialization.3935 // initialization.
3904 } else {3936 } else {
3905 // async function called as a normal function3937 if (instruction->modifier == CallModifierNoAsync && !fn_is_async(g->cur_fn)) {
39063938 // Async function called as a normal function, and calling function is not async.
3907 awaiter_init_val = LLVMBuildPtrToInt(g->builder, g->cur_frame_ptr, usize_type_ref, ""); // caller's own frame pointer3939 // This is allowed because it was called with `noasync` which asserts that it will
3940 // never suspend.
3941 awaiter_init_val = zero;
3942 } else {
3943 // async function called as a normal function
3944 awaiter_init_val = LLVMBuildPtrToInt(g->builder, g->cur_frame_ptr, usize_type_ref, ""); // caller's own frame pointer
3945 }
3908 if (ret_has_bits) {3946 if (ret_has_bits) {
3909 if (result_loc == nullptr) {3947 if (result_loc == nullptr) {
3910 // return type is a scalar, but we still need a pointer to it. Use the async fn frame.3948 // return type is a scalar, but we still need a pointer to it. Use the async fn frame.
...@@ -3945,7 +3983,7 @@ static LLVMValueRef ir_render_call(CodeGen *g, IrExecutable *executable, IrInstr...@@ -3945,7 +3983,7 @@ static LLVMValueRef ir_render_call(CodeGen *g, IrExecutable *executable, IrInstr
3945 LLVMValueRef ret_ptr_ptr = LLVMBuildStructGEP(g->builder, frame_result_loc, frame_ret_start, "");3983 LLVMValueRef ret_ptr_ptr = LLVMBuildStructGEP(g->builder, frame_result_loc, frame_ret_start, "");
3946 LLVMBuildStore(g->builder, ret_ptr, ret_ptr_ptr);3984 LLVMBuildStore(g->builder, ret_ptr, ret_ptr_ptr);
3947 }3985 }
3948 } else if (instruction->is_async) {3986 } else if (instruction->modifier == CallModifierAsync) {
3949 // Async call of blocking function3987 // Async call of blocking function
3950 if (instruction->new_stack != nullptr) {3988 if (instruction->new_stack != nullptr) {
3951 zig_panic("TODO @asyncCall of non-async function");3989 zig_panic("TODO @asyncCall of non-async function");
...@@ -4042,13 +4080,39 @@ static LLVMValueRef ir_render_call(CodeGen *g, IrExecutable *executable, IrInstr...@@ -4042,13 +4080,39 @@ static LLVMValueRef ir_render_call(CodeGen *g, IrExecutable *executable, IrInstr
4042 gen_param_values.at(arg_i));4080 gen_param_values.at(arg_i));
4043 }4081 }
40444082
4045 if (instruction->is_async) {4083 if (instruction->modifier == CallModifierAsync) {
4046 gen_resume(g, fn_val, frame_result_loc, ResumeIdCall);4084 gen_resume(g, fn_val, frame_result_loc, ResumeIdCall);
4047 if (instruction->new_stack != nullptr) {4085 if (instruction->new_stack != nullptr) {
4048 return LLVMBuildBitCast(g->builder, frame_result_loc,4086 return LLVMBuildBitCast(g->builder, frame_result_loc,
4049 get_llvm_type(g, instruction->base.value.type), "");4087 get_llvm_type(g, instruction->base.value.type), "");
4050 }4088 }
4051 return nullptr;4089 return nullptr;
4090 } else if (instruction->modifier == CallModifierNoAsync && !fn_is_async(g->cur_fn)) {
4091 gen_resume(g, fn_val, frame_result_loc, ResumeIdCall);
4092
4093 if (ir_want_runtime_safety(g, &instruction->base)) {
4094 LLVMValueRef awaiter_ptr = LLVMBuildStructGEP(g->builder, frame_result_loc,
4095 frame_awaiter_index, "");
4096 LLVMValueRef all_ones = LLVMConstAllOnes(usize_type_ref);
4097 LLVMValueRef prev_val = gen_maybe_atomic_op(g, LLVMAtomicRMWBinOpXchg, awaiter_ptr,
4098 all_ones, LLVMAtomicOrderingRelease);
4099 LLVMValueRef ok_val = LLVMBuildICmp(g->builder, LLVMIntEQ, prev_val, all_ones, "");
4100
4101 LLVMBasicBlockRef bad_block = LLVMAppendBasicBlock(g->cur_fn_val, "NoAsyncPanic");
4102 LLVMBasicBlockRef ok_block = LLVMAppendBasicBlock(g->cur_fn_val, "NoAsyncOk");
4103 LLVMBuildCondBr(g->builder, ok_val, ok_block, bad_block);
4104
4105 // The async function suspended, but this noasync call asserted it wouldn't.
4106 LLVMPositionBuilderAtEnd(g->builder, bad_block);
4107 gen_safety_crash(g, PanicMsgIdBadNoAsyncCall);
4108
4109 LLVMPositionBuilderAtEnd(g->builder, ok_block);
4110 }
4111
4112 ZigType *result_type = instruction->base.value.type;
4113 ZigType *ptr_result_type = get_pointer_to_type(g, result_type, true);
4114 return gen_await_early_return(g, &instruction->base, frame_result_loc,
4115 result_type, ptr_result_type, result_loc, true);
4052 } else {4116 } else {
4053 ZigType *ptr_result_type = get_pointer_to_type(g, src_return_type, true);4117 ZigType *ptr_result_type = get_pointer_to_type(g, src_return_type, true);
40544118
...@@ -4065,8 +4129,14 @@ static LLVMValueRef ir_render_call(CodeGen *g, IrExecutable *executable, IrInstr...@@ -4065,8 +4129,14 @@ static LLVMValueRef ir_render_call(CodeGen *g, IrExecutable *executable, IrInstr
4065 if (!type_has_bits(src_return_type))4129 if (!type_has_bits(src_return_type))
4066 return nullptr;4130 return nullptr;
40674131
4068 if (result_loc != nullptr) 4132 if (result_loc != nullptr) {
4069 return get_handle_value(g, result_loc, src_return_type, ptr_result_type);4133 if (instruction->result_loc->id == IrInstructionIdReturnPtr) {
4134 instruction->base.spill = nullptr;
4135 return g->cur_ret_ptr;
4136 } else {
4137 return get_handle_value(g, result_loc, src_return_type, ptr_result_type);
4138 }
4139 }
40704140
4071 LLVMValueRef result_ptr = LLVMBuildStructGEP(g->builder, frame_result_loc, frame_ret_start + 2, "");4141 LLVMValueRef result_ptr = LLVMBuildStructGEP(g->builder, frame_result_loc, frame_ret_start + 2, "");
4072 return LLVMBuildLoad(g->builder, result_ptr, "");4142 return LLVMBuildLoad(g->builder, result_ptr, "");
...@@ -4076,7 +4146,7 @@ static LLVMValueRef ir_render_call(CodeGen *g, IrExecutable *executable, IrInstr...@@ -4076,7 +4146,7 @@ static LLVMValueRef ir_render_call(CodeGen *g, IrExecutable *executable, IrInstr
4076 if (instruction->new_stack == nullptr || instruction->is_async_call_builtin) {4146 if (instruction->new_stack == nullptr || instruction->is_async_call_builtin) {
4077 result = ZigLLVMBuildCall(g->builder, fn_val,4147 result = ZigLLVMBuildCall(g->builder, fn_val,
4078 gen_param_values.items, (unsigned)gen_param_values.length, llvm_cc, fn_inline, "");4148 gen_param_values.items, (unsigned)gen_param_values.length, llvm_cc, fn_inline, "");
4079 } else if (instruction->is_async) {4149 } else if (instruction->modifier == CallModifierAsync) {
4080 zig_panic("TODO @asyncCall of non-async function");4150 zig_panic("TODO @asyncCall of non-async function");
4081 } else {4151 } else {
4082 LLVMValueRef stacksave_fn_val = get_stacksave_fn_val(g);4152 LLVMValueRef stacksave_fn_val = get_stacksave_fn_val(g);
...@@ -4101,7 +4171,7 @@ static LLVMValueRef ir_render_call(CodeGen *g, IrExecutable *executable, IrInstr...@@ -4101,7 +4171,7 @@ static LLVMValueRef ir_render_call(CodeGen *g, IrExecutable *executable, IrInstr
4101 LLVMValueRef store_instr = LLVMBuildStore(g->builder, result, result_loc);4171 LLVMValueRef store_instr = LLVMBuildStore(g->builder, result, result_loc);
4102 LLVMSetAlignment(store_instr, get_ptr_align(g, instruction->result_loc->value.type));4172 LLVMSetAlignment(store_instr, get_ptr_align(g, instruction->result_loc->value.type));
4103 return result_loc;4173 return result_loc;
4104 } else if (!callee_is_async && instruction->is_async) {4174 } else if (!callee_is_async && instruction->modifier == CallModifierAsync) {
4105 LLVMBuildStore(g->builder, result, ret_ptr);4175 LLVMBuildStore(g->builder, result, ret_ptr);
4106 return result_loc;4176 return result_loc;
4107 } else {4177 } else {
...@@ -4112,6 +4182,8 @@ static LLVMValueRef ir_render_call(CodeGen *g, IrExecutable *executable, IrInstr...@@ -4112,6 +4182,8 @@ static LLVMValueRef ir_render_call(CodeGen *g, IrExecutable *executable, IrInstr
4112static LLVMValueRef ir_render_struct_field_ptr(CodeGen *g, IrExecutable *executable,4182static LLVMValueRef ir_render_struct_field_ptr(CodeGen *g, IrExecutable *executable,
4113 IrInstructionStructFieldPtr *instruction)4183 IrInstructionStructFieldPtr *instruction)
4114{4184{
4185 Error err;
4186
4115 if (instruction->base.value.special != ConstValSpecialRuntime)4187 if (instruction->base.value.special != ConstValSpecialRuntime)
4116 return nullptr;4188 return nullptr;
41174189
...@@ -4129,6 +4201,11 @@ static LLVMValueRef ir_render_struct_field_ptr(CodeGen *g, IrExecutable *executa...@@ -4129,6 +4201,11 @@ static LLVMValueRef ir_render_struct_field_ptr(CodeGen *g, IrExecutable *executa
4129 return struct_ptr;4201 return struct_ptr;
4130 }4202 }
41314203
4204 ZigType *struct_type = (struct_ptr_type->id == ZigTypeIdPointer) ?
4205 struct_ptr_type->data.pointer.child_type : struct_ptr_type;
4206 if ((err = type_resolve(g, struct_type, ResolveStatusLLVMFull)))
4207 report_errors_and_exit(g);
4208
4132 assert(field->gen_index != SIZE_MAX);4209 assert(field->gen_index != SIZE_MAX);
4133 return LLVMBuildStructGEP(g->builder, struct_ptr, (unsigned)field->gen_index, "");4210 return LLVMBuildStructGEP(g->builder, struct_ptr, (unsigned)field->gen_index, "");
4134}4211}
...@@ -4583,8 +4660,9 @@ static LLVMValueRef get_enum_tag_name_function(CodeGen *g, ZigType *enum_type) {...@@ -4583,8 +4660,9 @@ static LLVMValueRef get_enum_tag_name_function(CodeGen *g, ZigType *enum_type) {
4583 LLVMTypeRef fn_type_ref = LLVMFunctionType(LLVMPointerType(get_llvm_type(g, u8_slice_type), 0),4660 LLVMTypeRef fn_type_ref = LLVMFunctionType(LLVMPointerType(get_llvm_type(g, u8_slice_type), 0),
4584 &tag_int_llvm_type, 1, false);4661 &tag_int_llvm_type, 1, false);
45854662
4586 Buf *fn_name = get_mangled_name(g, buf_sprintf("__zig_tag_name_%s", buf_ptr(&enum_type->name)), false);4663 const char *fn_name = get_mangled_name(g,
4587 LLVMValueRef fn_val = LLVMAddFunction(g->module, buf_ptr(fn_name), fn_type_ref);4664 buf_ptr(buf_sprintf("__zig_tag_name_%s", buf_ptr(&enum_type->name))), false);
4665 LLVMValueRef fn_val = LLVMAddFunction(g->module, fn_name, fn_type_ref);
4588 LLVMSetLinkage(fn_val, LLVMInternalLinkage);4666 LLVMSetLinkage(fn_val, LLVMInternalLinkage);
4589 LLVMSetFunctionCallConv(fn_val, get_llvm_cc(g, CallingConventionUnspecified));4667 LLVMSetFunctionCallConv(fn_val, get_llvm_cc(g, CallingConventionUnspecified));
4590 addLLVMFnAttr(fn_val, "nounwind");4668 addLLVMFnAttr(fn_val, "nounwind");
...@@ -4879,7 +4957,7 @@ static LLVMValueRef ir_render_memset(CodeGen *g, IrExecutable *executable, IrIns...@@ -4879,7 +4957,7 @@ static LLVMValueRef ir_render_memset(CodeGen *g, IrExecutable *executable, IrIns
4879 ZigType *ptr_type = instruction->dest_ptr->value.type;4957 ZigType *ptr_type = instruction->dest_ptr->value.type;
4880 assert(ptr_type->id == ZigTypeIdPointer);4958 assert(ptr_type->id == ZigTypeIdPointer);
48814959
4882 bool val_is_undef = value_is_all_undef(&instruction->byte->value);4960 bool val_is_undef = value_is_all_undef(g, &instruction->byte->value);
4883 LLVMValueRef fill_char;4961 LLVMValueRef fill_char;
4884 if (val_is_undef) {4962 if (val_is_undef) {
4885 fill_char = LLVMConstInt(LLVMInt8Type(), 0xaa, false);4963 fill_char = LLVMConstInt(LLVMInt8Type(), 0xaa, false);
...@@ -5595,7 +5673,6 @@ static LLVMValueRef ir_render_await(CodeGen *g, IrExecutable *executable, IrInst...@@ -5595,7 +5673,6 @@ static LLVMValueRef ir_render_await(CodeGen *g, IrExecutable *executable, IrInst
5595 // At this point resuming the function will continue from resume_bb.5673 // At this point resuming the function will continue from resume_bb.
5596 // This code is as if it is running inside the suspend block.5674 // This code is as if it is running inside the suspend block.
55975675
5598
5599 // supply the awaiter return pointer5676 // supply the awaiter return pointer
5600 if (type_has_bits(result_type)) {5677 if (type_has_bits(result_type)) {
5601 LLVMValueRef awaiter_ret_ptr_ptr = LLVMBuildStructGEP(g->builder, target_frame_ptr, frame_ret_start + 1, "");5678 LLVMValueRef awaiter_ret_ptr_ptr = LLVMBuildStructGEP(g->builder, target_frame_ptr, frame_ret_start + 1, "");
...@@ -5653,9 +5730,8 @@ static LLVMValueRef ir_render_await(CodeGen *g, IrExecutable *executable, IrInst...@@ -5653,9 +5730,8 @@ static LLVMValueRef ir_render_await(CodeGen *g, IrExecutable *executable, IrInst
5653 LLVMBuildBr(g->builder, end_bb);5730 LLVMBuildBr(g->builder, end_bb);
56545731
5655 LLVMPositionBuilderAtEnd(g->builder, end_bb);5732 LLVMPositionBuilderAtEnd(g->builder, end_bb);
5656 if (type_has_bits(result_type) && result_loc != nullptr) {5733 // Rely on the spill for the llvm_value to be populated.
5657 return get_handle_value(g, result_loc, result_type, ptr_result_type);5734 // See the implementation of ir_llvm_value.
5658 }
5659 return nullptr;5735 return nullptr;
5660}5736}
56615737
...@@ -5762,6 +5838,7 @@ static LLVMValueRef ir_render_instruction(CodeGen *g, IrExecutable *executable,...@@ -5762,6 +5838,7 @@ static LLVMValueRef ir_render_instruction(CodeGen *g, IrExecutable *executable,
5762 case IrInstructionIdByteOffsetOf:5838 case IrInstructionIdByteOffsetOf:
5763 case IrInstructionIdBitOffsetOf:5839 case IrInstructionIdBitOffsetOf:
5764 case IrInstructionIdTypeInfo:5840 case IrInstructionIdTypeInfo:
5841 case IrInstructionIdType:
5765 case IrInstructionIdHasField:5842 case IrInstructionIdHasField:
5766 case IrInstructionIdTypeId:5843 case IrInstructionIdTypeId:
5767 case IrInstructionIdSetEvalBranchQuota:5844 case IrInstructionIdSetEvalBranchQuota:
...@@ -5992,6 +6069,11 @@ static void ir_render(CodeGen *g, ZigFn *fn_entry) {...@@ -5992,6 +6069,11 @@ static void ir_render(CodeGen *g, ZigFn *fn_entry) {
5992 set_debug_location(g, instruction);6069 set_debug_location(g, instruction);
5993 }6070 }
5994 instruction->llvm_value = ir_render_instruction(g, executable, instruction);6071 instruction->llvm_value = ir_render_instruction(g, executable, instruction);
6072 if (instruction->spill != nullptr) {
6073 LLVMValueRef spill_ptr = ir_llvm_value(g, instruction->spill);
6074 gen_assign_raw(g, spill_ptr, instruction->spill->value.type, instruction->llvm_value);
6075 instruction->llvm_value = nullptr;
6076 }
5995 }6077 }
5996 current_block->llvm_exit_block = LLVMGetInsertBlock(g->builder);6078 current_block->llvm_exit_block = LLVMGetInsertBlock(g->builder);
5997 }6079 }
...@@ -6845,7 +6927,7 @@ static void generate_error_name_table(CodeGen *g) {...@@ -6845,7 +6927,7 @@ static void generate_error_name_table(CodeGen *g) {
6845 LLVMValueRef err_name_table_init = LLVMConstArray(get_llvm_type(g, str_type), values, (unsigned)g->errors_by_index.length);6927 LLVMValueRef err_name_table_init = LLVMConstArray(get_llvm_type(g, str_type), values, (unsigned)g->errors_by_index.length);
68466928
6847 g->err_name_table = LLVMAddGlobal(g->module, LLVMTypeOf(err_name_table_init),6929 g->err_name_table = LLVMAddGlobal(g->module, LLVMTypeOf(err_name_table_init),
6848 buf_ptr(get_mangled_name(g, buf_create_from_str("__zig_err_name_table"), false)));6930 get_mangled_name(g, buf_ptr(buf_create_from_str("__zig_err_name_table")), false));
6849 LLVMSetInitializer(g->err_name_table, err_name_table_init);6931 LLVMSetInitializer(g->err_name_table, err_name_table_init);
6850 LLVMSetLinkage(g->err_name_table, LLVMPrivateLinkage);6932 LLVMSetLinkage(g->err_name_table, LLVMPrivateLinkage);
6851 LLVMSetGlobalConstant(g->err_name_table, true);6933 LLVMSetGlobalConstant(g->err_name_table, true);
...@@ -6886,8 +6968,8 @@ static void gen_global_var(CodeGen *g, ZigVar *var, LLVMValueRef init_val,...@@ -6886,8 +6968,8 @@ static void gen_global_var(CodeGen *g, ZigVar *var, LLVMValueRef init_val,
6886 assert(import);6968 assert(import);
68876969
6888 bool is_local_to_unit = true;6970 bool is_local_to_unit = true;
6889 ZigLLVMCreateGlobalVariable(g->dbuilder, get_di_scope(g, var->parent_scope), buf_ptr(&var->name),6971 ZigLLVMCreateGlobalVariable(g->dbuilder, get_di_scope(g, var->parent_scope), var->name,
6890 buf_ptr(&var->name), import->data.structure.root_struct->di_file,6972 var->name, import->data.structure.root_struct->di_file,
6891 (unsigned)(var->decl_node->line + 1),6973 (unsigned)(var->decl_node->line + 1),
6892 get_llvm_di_type(g, type_entry), is_local_to_unit);6974 get_llvm_di_type(g, type_entry), is_local_to_unit);
68936975
...@@ -6969,8 +7051,8 @@ static void do_code_gen(CodeGen *g) {...@@ -6969,8 +7051,8 @@ static void do_code_gen(CodeGen *g) {
6969 assert(var->decl_node);7051 assert(var->decl_node);
69707052
6971 GlobalLinkageId linkage;7053 GlobalLinkageId linkage;
6972 Buf *unmangled_name = &var->name;7054 const char *unmangled_name = var->name;
6973 Buf *symbol_name;7055 const char *symbol_name;
6974 if (var->export_list.length == 0) {7056 if (var->export_list.length == 0) {
6975 if (var->decl_node->data.variable_declaration.is_extern) {7057 if (var->decl_node->data.variable_declaration.is_extern) {
6976 symbol_name = unmangled_name;7058 symbol_name = unmangled_name;
...@@ -6981,19 +7063,19 @@ static void do_code_gen(CodeGen *g) {...@@ -6981,19 +7063,19 @@ static void do_code_gen(CodeGen *g) {
6981 }7063 }
6982 } else {7064 } else {
6983 GlobalExport *global_export = &var->export_list.items[0];7065 GlobalExport *global_export = &var->export_list.items[0];
6984 symbol_name = &global_export->name;7066 symbol_name = buf_ptr(&global_export->name);
6985 linkage = global_export->linkage;7067 linkage = global_export->linkage;
6986 }7068 }
69877069
6988 LLVMValueRef global_value;7070 LLVMValueRef global_value;
6989 bool externally_initialized = var->decl_node->data.variable_declaration.expr == nullptr;7071 bool externally_initialized = var->decl_node->data.variable_declaration.expr == nullptr;
6990 if (externally_initialized) {7072 if (externally_initialized) {
6991 LLVMValueRef existing_llvm_var = LLVMGetNamedGlobal(g->module, buf_ptr(symbol_name));7073 LLVMValueRef existing_llvm_var = LLVMGetNamedGlobal(g->module, symbol_name);
6992 if (existing_llvm_var) {7074 if (existing_llvm_var) {
6993 global_value = LLVMConstBitCast(existing_llvm_var,7075 global_value = LLVMConstBitCast(existing_llvm_var,
6994 LLVMPointerType(get_llvm_type(g, var->var_type), 0));7076 LLVMPointerType(get_llvm_type(g, var->var_type), 0));
6995 } else {7077 } else {
6996 global_value = LLVMAddGlobal(g->module, get_llvm_type(g, var->var_type), buf_ptr(symbol_name));7078 global_value = LLVMAddGlobal(g->module, get_llvm_type(g, var->var_type), symbol_name);
6997 // TODO debug info for the extern variable7079 // TODO debug info for the extern variable
69987080
6999 LLVMSetLinkage(global_value, to_llvm_linkage(linkage));7081 LLVMSetLinkage(global_value, to_llvm_linkage(linkage));
...@@ -7004,8 +7086,8 @@ static void do_code_gen(CodeGen *g) {...@@ -7004,8 +7086,8 @@ static void do_code_gen(CodeGen *g) {
7004 }7086 }
7005 } else {7087 } else {
7006 bool exported = (linkage != GlobalLinkageIdInternal);7088 bool exported = (linkage != GlobalLinkageIdInternal);
7007 render_const_val(g, var->const_value, buf_ptr(symbol_name));7089 render_const_val(g, var->const_value, symbol_name);
7008 render_const_val_global(g, var->const_value, buf_ptr(symbol_name));7090 render_const_val_global(g, var->const_value, symbol_name);
7009 global_value = var->const_value->global_refs->llvm_global;7091 global_value = var->const_value->global_refs->llvm_global;
70107092
7011 if (exported) {7093 if (exported) {
...@@ -7090,6 +7172,21 @@ static void do_code_gen(CodeGen *g) {...@@ -7090,6 +7172,21 @@ static void do_code_gen(CodeGen *g) {
7090 }7172 }
70917173
7092 if (!is_async) {7174 if (!is_async) {
7175 // allocate async frames for noasync calls & awaits to async functions
7176 for (size_t i = 0; i < fn_table_entry->call_list.length; i += 1) {
7177 IrInstructionCallGen *call = fn_table_entry->call_list.at(i);
7178 if (call->fn_entry == nullptr)
7179 continue;
7180 if (!fn_is_async(call->fn_entry))
7181 continue;
7182 if (call->modifier != CallModifierNoAsync)
7183 continue;
7184 if (call->frame_result_loc != nullptr)
7185 continue;
7186 ZigType *callee_frame_type = get_fn_frame_type(g, call->fn_entry);
7187 call->frame_result_loc = ir_create_alloca(g, call->base.scope, call->base.source_node,
7188 fn_table_entry, callee_frame_type, "");
7189 }
7093 // allocate temporary stack data7190 // allocate temporary stack data
7094 for (size_t alloca_i = 0; alloca_i < fn_table_entry->alloca_gen_list.length; alloca_i += 1) {7191 for (size_t alloca_i = 0; alloca_i < fn_table_entry->alloca_gen_list.length; alloca_i += 1) {
7095 IrInstructionAllocaGen *instruction = fn_table_entry->alloca_gen_list.at(alloca_i);7192 IrInstructionAllocaGen *instruction = fn_table_entry->alloca_gen_list.at(alloca_i);
...@@ -7145,7 +7242,7 @@ static void do_code_gen(CodeGen *g) {...@@ -7145,7 +7242,7 @@ static void do_code_gen(CodeGen *g) {
71457242
7146 if (var->src_arg_index == SIZE_MAX) {7243 if (var->src_arg_index == SIZE_MAX) {
7147 var->di_loc_var = ZigLLVMCreateAutoVariable(g->dbuilder, get_di_scope(g, var->parent_scope),7244 var->di_loc_var = ZigLLVMCreateAutoVariable(g->dbuilder, get_di_scope(g, var->parent_scope),
7148 buf_ptr(&var->name), import->data.structure.root_struct->di_file, (unsigned)(var->decl_node->line + 1),7245 var->name, import->data.structure.root_struct->di_file, (unsigned)(var->decl_node->line + 1),
7149 get_llvm_di_type(g, var->var_type), !g->strip_debug_symbols, 0);7246 get_llvm_di_type(g, var->var_type), !g->strip_debug_symbols, 0);
71507247
7151 } else if (is_c_abi) {7248 } else if (is_c_abi) {
...@@ -7165,11 +7262,11 @@ static void do_code_gen(CodeGen *g) {...@@ -7165,11 +7262,11 @@ static void do_code_gen(CodeGen *g) {
7165 var->value_ref = LLVMGetParam(fn, gen_info->gen_index);7262 var->value_ref = LLVMGetParam(fn, gen_info->gen_index);
7166 } else {7263 } else {
7167 gen_type = var->var_type;7264 gen_type = var->var_type;
7168 var->value_ref = build_alloca(g, var->var_type, buf_ptr(&var->name), var->align_bytes);7265 var->value_ref = build_alloca(g, var->var_type, var->name, var->align_bytes);
7169 }7266 }
7170 if (var->decl_node) {7267 if (var->decl_node) {
7171 var->di_loc_var = ZigLLVMCreateParameterVariable(g->dbuilder, get_di_scope(g, var->parent_scope),7268 var->di_loc_var = ZigLLVMCreateParameterVariable(g->dbuilder, get_di_scope(g, var->parent_scope),
7172 buf_ptr(&var->name), import->data.structure.root_struct->di_file,7269 var->name, import->data.structure.root_struct->di_file,
7173 (unsigned)(var->decl_node->line + 1),7270 (unsigned)(var->decl_node->line + 1),
7174 get_llvm_di_type(g, gen_type), !g->strip_debug_symbols, 0, (unsigned)(gen_info->gen_index+1));7271 get_llvm_di_type(g, gen_type), !g->strip_debug_symbols, 0, (unsigned)(gen_info->gen_index+1));
7175 }7272 }
...@@ -7208,7 +7305,9 @@ static void do_code_gen(CodeGen *g) {...@@ -7208,7 +7305,9 @@ static void do_code_gen(CodeGen *g) {
72087305
7209 LLVMTypeRef usize_type_ref = g->builtin_types.entry_usize->llvm_type;7306 LLVMTypeRef usize_type_ref = g->builtin_types.entry_usize->llvm_type;
7210 LLVMValueRef size_val = LLVMConstInt(usize_type_ref, fn_table_entry->frame_type->abi_size, false);7307 LLVMValueRef size_val = LLVMConstInt(usize_type_ref, fn_table_entry->frame_type->abi_size, false);
7211 ZigLLVMFunctionSetPrefixData(fn_table_entry->llvm_value, size_val);7308 if (g->need_frame_size_prefix_data) {
7309 ZigLLVMFunctionSetPrefixData(fn_table_entry->llvm_value, size_val);
7310 }
72127311
7213 if (!g->strip_debug_symbols) {7312 if (!g->strip_debug_symbols) {
7214 AstNode *source_node = fn_table_entry->proto_node;7313 AstNode *source_node = fn_table_entry->proto_node;
...@@ -7296,10 +7395,8 @@ static void do_code_gen(CodeGen *g) {...@@ -7296,10 +7395,8 @@ static void do_code_gen(CodeGen *g) {
7296 LLVMDumpModule(g->module);7395 LLVMDumpModule(g->module);
7297 }7396 }
72987397
7299#ifndef NDEBUG
7300 char *error = nullptr;7398 char *error = nullptr;
7301 LLVMVerifyModule(g->module, LLVMAbortProcessAction, &error);7399 LLVMVerifyModule(g->module, LLVMAbortProcessAction, &error);
7302#endif
7303}7400}
73047401
7305static void zig_llvm_emit_output(CodeGen *g) {7402static void zig_llvm_emit_output(CodeGen *g) {
...@@ -7587,6 +7684,7 @@ static void define_builtin_fns(CodeGen *g) {...@@ -7587,6 +7684,7 @@ static void define_builtin_fns(CodeGen *g) {
7587 create_builtin_fn(g, BuiltinFnIdMemberName, "memberName", 2);7684 create_builtin_fn(g, BuiltinFnIdMemberName, "memberName", 2);
7588 create_builtin_fn(g, BuiltinFnIdField, "field", 2);7685 create_builtin_fn(g, BuiltinFnIdField, "field", 2);
7589 create_builtin_fn(g, BuiltinFnIdTypeInfo, "typeInfo", 1);7686 create_builtin_fn(g, BuiltinFnIdTypeInfo, "typeInfo", 1);
7687 create_builtin_fn(g, BuiltinFnIdType, "Type", 1);
7590 create_builtin_fn(g, BuiltinFnIdHasField, "hasField", 2);7688 create_builtin_fn(g, BuiltinFnIdHasField, "hasField", 2);
7591 create_builtin_fn(g, BuiltinFnIdTypeof, "typeOf", 1); // TODO rename to TypeOf7689 create_builtin_fn(g, BuiltinFnIdTypeof, "typeOf", 1); // TODO rename to TypeOf
7592 create_builtin_fn(g, BuiltinFnIdAddWithOverflow, "addWithOverflow", 4);7690 create_builtin_fn(g, BuiltinFnIdAddWithOverflow, "addWithOverflow", 4);
...@@ -8149,20 +8247,25 @@ Buf *codegen_generate_builtin_source(CodeGen *g) {...@@ -8149,20 +8247,25 @@ Buf *codegen_generate_builtin_source(CodeGen *g) {
8149 " };\n"8247 " };\n"
8150 " };\n"8248 " };\n"
8151 "};\n\n");8249 "};\n\n");
8152 assert(ContainerLayoutAuto == 0);8250 static_assert(ContainerLayoutAuto == 0, "");
8153 assert(ContainerLayoutExtern == 1);8251 static_assert(ContainerLayoutExtern == 1, "");
8154 assert(ContainerLayoutPacked == 2);8252 static_assert(ContainerLayoutPacked == 2, "");
81558253
8156 assert(CallingConventionUnspecified == 0);8254 static_assert(CallingConventionUnspecified == 0, "");
8157 assert(CallingConventionC == 1);8255 static_assert(CallingConventionC == 1, "");
8158 assert(CallingConventionCold == 2);8256 static_assert(CallingConventionCold == 2, "");
8159 assert(CallingConventionNaked == 3);8257 static_assert(CallingConventionNaked == 3, "");
8160 assert(CallingConventionStdcall == 4);8258 static_assert(CallingConventionStdcall == 4, "");
8161 assert(CallingConventionAsync == 5);8259 static_assert(CallingConventionAsync == 5, "");
81628260
8163 assert(FnInlineAuto == 0);8261 static_assert(FnInlineAuto == 0, "");
8164 assert(FnInlineAlways == 1);8262 static_assert(FnInlineAlways == 1, "");
8165 assert(FnInlineNever == 2);8263 static_assert(FnInlineNever == 2, "");
8264
8265 static_assert(BuiltinPtrSizeOne == 0, "");
8266 static_assert(BuiltinPtrSizeMany == 1, "");
8267 static_assert(BuiltinPtrSizeSlice == 2, "");
8268 static_assert(BuiltinPtrSizeC == 3, "");
8166 }8269 }
8167 {8270 {
8168 buf_appendf(contents,8271 buf_appendf(contents,
...@@ -8458,8 +8561,21 @@ static void init(CodeGen *g) {...@@ -8458,8 +8561,21 @@ static void init(CodeGen *g) {
8458 Buf *producer = buf_sprintf("zig %d.%d.%d", ZIG_VERSION_MAJOR, ZIG_VERSION_MINOR, ZIG_VERSION_PATCH);8561 Buf *producer = buf_sprintf("zig %d.%d.%d", ZIG_VERSION_MAJOR, ZIG_VERSION_MINOR, ZIG_VERSION_PATCH);
8459 const char *flags = "";8562 const char *flags = "";
8460 unsigned runtime_version = 0;8563 unsigned runtime_version = 0;
8564
8565 // For macOS stack traces, we want to avoid having to parse the compilation unit debug
8566 // info. As long as each debug info file has a path independent of the compilation unit
8567 // directory (DW_AT_comp_dir), then we never have to look at the compilation unit debug
8568 // info. If we provide an absolute path to LLVM here for the compilation unit debug info,
8569 // LLVM will emit DWARF info that depends on DW_AT_comp_dir. To avoid this, we pass "."
8570 // for the compilation unit directory. This forces each debug file to have a directory
8571 // rather than be relative to DW_AT_comp_dir. According to DWARF 5, debug files will
8572 // no longer reference DW_AT_comp_dir, for the purpose of being able to support the
8573 // common practice of stripping all but the line number sections from an executable.
8574 const char *compile_unit_dir = target_os_is_darwin(g->zig_target->os) ? "." :
8575 buf_ptr(&g->root_package->root_src_dir);
8576
8461 ZigLLVMDIFile *compile_unit_file = ZigLLVMCreateFile(g->dbuilder, buf_ptr(g->root_out_name),8577 ZigLLVMDIFile *compile_unit_file = ZigLLVMCreateFile(g->dbuilder, buf_ptr(g->root_out_name),
8462 buf_ptr(&g->root_package->root_src_dir));8578 compile_unit_dir);
8463 g->compile_unit = ZigLLVMCreateCompileUnit(g->dbuilder, ZigLLVMLang_DW_LANG_C99(),8579 g->compile_unit = ZigLLVMCreateCompileUnit(g->dbuilder, ZigLLVMLang_DW_LANG_C99(),
8464 compile_unit_file, buf_ptr(producer), is_optimized, flags, runtime_version,8580 compile_unit_file, buf_ptr(producer), is_optimized, flags, runtime_version,
8465 "", 0, !g->strip_debug_symbols);8581 "", 0, !g->strip_debug_symbols);
...@@ -8674,6 +8790,11 @@ void add_cc_args(CodeGen *g, ZigList<const char *> &args, const char *out_dep_pa...@@ -8674,6 +8790,11 @@ void add_cc_args(CodeGen *g, ZigList<const char *> &args, const char *out_dep_pa
8674 }8790 }
8675 }8791 }
86768792
8793 for (size_t i = 0; i < g->framework_dirs.length; i += 1) {
8794 args.append("-iframework");
8795 args.append(g->framework_dirs.at(i));
8796 }
8797
8677 // According to Rich Felker libc headers are supposed to go before C language headers.8798 // According to Rich Felker libc headers are supposed to go before C language headers.
8678 // However as noted by @dimenus, appending libc headers before c_headers breaks intrinsics8799 // However as noted by @dimenus, appending libc headers before c_headers breaks intrinsics
8679 // and other compiler specific items.8800 // and other compiler specific items.
...@@ -8896,6 +9017,15 @@ static void create_test_compile_var_and_add_test_runner(CodeGen *g) {...@@ -8896,6 +9017,15 @@ static void create_test_compile_var_and_add_test_runner(CodeGen *g) {
8896 for (size_t i = 0; i < g->test_fns.length; i += 1) {9017 for (size_t i = 0; i < g->test_fns.length; i += 1) {
8897 ZigFn *test_fn_entry = g->test_fns.at(i);9018 ZigFn *test_fn_entry = g->test_fns.at(i);
88989019
9020 if (fn_is_async(test_fn_entry)) {
9021 ErrorMsg *msg = add_node_error(g, test_fn_entry->proto_node,
9022 buf_create_from_str("test functions cannot be async"));
9023 add_error_note(g, msg, test_fn_entry->proto_node,
9024 buf_sprintf("this restriction may be lifted in the future. See https://github.com/ziglang/zig/issues/3117 for more details"));
9025 add_async_error_notes(g, msg, test_fn_entry);
9026 continue;
9027 }
9028
8899 ConstExprValue *this_val = &test_fn_array->data.x_array.data.s_none.elements[i];9029 ConstExprValue *this_val = &test_fn_array->data.x_array.data.s_none.elements[i];
8900 this_val->special = ConstValSpecialStatic;9030 this_val->special = ConstValSpecialStatic;
8901 this_val->type = struct_type;9031 this_val->type = struct_type;
...@@ -8915,6 +9045,7 @@ static void create_test_compile_var_and_add_test_runner(CodeGen *g) {...@@ -8915,6 +9045,7 @@ static void create_test_compile_var_and_add_test_runner(CodeGen *g) {
8915 fn_field->data.x_ptr.mut = ConstPtrMutComptimeConst;9045 fn_field->data.x_ptr.mut = ConstPtrMutComptimeConst;
8916 fn_field->data.x_ptr.data.fn.fn_entry = test_fn_entry;9046 fn_field->data.x_ptr.data.fn.fn_entry = test_fn_entry;
8917 }9047 }
9048 report_errors_and_maybe_exit(g);
89189049
8919 ConstExprValue *test_fn_slice = create_const_slice(g, test_fn_array, 0, g->test_fns.length, true);9050 ConstExprValue *test_fn_slice = create_const_slice(g, test_fn_array, 0, g->test_fns.length, true);
89209051
src/ir.cpp+445-81
...@@ -197,6 +197,7 @@ static IrInstruction *ir_analyze_store_ptr(IrAnalyze *ira, IrInstruction *source...@@ -197,6 +197,7 @@ static IrInstruction *ir_analyze_store_ptr(IrAnalyze *ira, IrInstruction *source
197static IrInstruction *ir_gen_union_init_expr(IrBuilder *irb, Scope *scope, AstNode *source_node,197static IrInstruction *ir_gen_union_init_expr(IrBuilder *irb, Scope *scope, AstNode *source_node,
198 IrInstruction *union_type, IrInstruction *field_name, AstNode *expr_node,198 IrInstruction *union_type, IrInstruction *field_name, AstNode *expr_node,
199 LVal lval, ResultLoc *parent_result_loc);199 LVal lval, ResultLoc *parent_result_loc);
200static void ir_reset_result(ResultLoc *result_loc);
200201
201static ConstExprValue *const_ptr_pointee_unchecked(CodeGen *g, ConstExprValue *const_val) {202static ConstExprValue *const_ptr_pointee_unchecked(CodeGen *g, ConstExprValue *const_val) {
202 assert(get_src_ptr_type(const_val->type) != nullptr);203 assert(get_src_ptr_type(const_val->type) != nullptr);
...@@ -912,6 +913,10 @@ static constexpr IrInstructionId ir_instruction_id(IrInstructionTypeInfo *) {...@@ -912,6 +913,10 @@ static constexpr IrInstructionId ir_instruction_id(IrInstructionTypeInfo *) {
912 return IrInstructionIdTypeInfo;913 return IrInstructionIdTypeInfo;
913}914}
914915
916static constexpr IrInstructionId ir_instruction_id(IrInstructionType *) {
917 return IrInstructionIdType;
918}
919
915static constexpr IrInstructionId ir_instruction_id(IrInstructionHasField *) {920static constexpr IrInstructionId ir_instruction_id(IrInstructionHasField *) {
916 return IrInstructionIdHasField;921 return IrInstructionIdHasField;
917}922}
...@@ -1384,7 +1389,7 @@ static IrInstruction *ir_build_union_field_ptr(IrBuilder *irb, Scope *scope, Ast...@@ -1384,7 +1389,7 @@ static IrInstruction *ir_build_union_field_ptr(IrBuilder *irb, Scope *scope, Ast
13841389
1385static IrInstruction *ir_build_call_src(IrBuilder *irb, Scope *scope, AstNode *source_node,1390static IrInstruction *ir_build_call_src(IrBuilder *irb, Scope *scope, AstNode *source_node,
1386 ZigFn *fn_entry, IrInstruction *fn_ref, size_t arg_count, IrInstruction **args,1391 ZigFn *fn_entry, IrInstruction *fn_ref, size_t arg_count, IrInstruction **args,
1387 bool is_comptime, FnInline fn_inline, bool is_async, bool is_async_call_builtin,1392 bool is_comptime, FnInline fn_inline, CallModifier modifier, bool is_async_call_builtin,
1388 IrInstruction *new_stack, ResultLoc *result_loc)1393 IrInstruction *new_stack, ResultLoc *result_loc)
1389{1394{
1390 IrInstructionCallSrc *call_instruction = ir_build_instruction<IrInstructionCallSrc>(irb, scope, source_node);1395 IrInstructionCallSrc *call_instruction = ir_build_instruction<IrInstructionCallSrc>(irb, scope, source_node);
...@@ -1394,7 +1399,7 @@ static IrInstruction *ir_build_call_src(IrBuilder *irb, Scope *scope, AstNode *s...@@ -1394,7 +1399,7 @@ static IrInstruction *ir_build_call_src(IrBuilder *irb, Scope *scope, AstNode *s
1394 call_instruction->fn_inline = fn_inline;1399 call_instruction->fn_inline = fn_inline;
1395 call_instruction->args = args;1400 call_instruction->args = args;
1396 call_instruction->arg_count = arg_count;1401 call_instruction->arg_count = arg_count;
1397 call_instruction->is_async = is_async;1402 call_instruction->modifier = modifier;
1398 call_instruction->is_async_call_builtin = is_async_call_builtin;1403 call_instruction->is_async_call_builtin = is_async_call_builtin;
1399 call_instruction->new_stack = new_stack;1404 call_instruction->new_stack = new_stack;
1400 call_instruction->result_loc = result_loc;1405 call_instruction->result_loc = result_loc;
...@@ -1402,7 +1407,7 @@ static IrInstruction *ir_build_call_src(IrBuilder *irb, Scope *scope, AstNode *s...@@ -1402,7 +1407,7 @@ static IrInstruction *ir_build_call_src(IrBuilder *irb, Scope *scope, AstNode *s
1402 if (fn_ref != nullptr) ir_ref_instruction(fn_ref, irb->current_basic_block);1407 if (fn_ref != nullptr) ir_ref_instruction(fn_ref, irb->current_basic_block);
1403 for (size_t i = 0; i < arg_count; i += 1)1408 for (size_t i = 0; i < arg_count; i += 1)
1404 ir_ref_instruction(args[i], irb->current_basic_block);1409 ir_ref_instruction(args[i], irb->current_basic_block);
1405 if (is_async && new_stack != nullptr) {1410 if (modifier == CallModifierAsync && new_stack != nullptr) {
1406 // in this case the arg at the end is the return pointer1411 // in this case the arg at the end is the return pointer
1407 ir_ref_instruction(args[arg_count], irb->current_basic_block);1412 ir_ref_instruction(args[arg_count], irb->current_basic_block);
1408 }1413 }
...@@ -1413,7 +1418,7 @@ static IrInstruction *ir_build_call_src(IrBuilder *irb, Scope *scope, AstNode *s...@@ -1413,7 +1418,7 @@ static IrInstruction *ir_build_call_src(IrBuilder *irb, Scope *scope, AstNode *s
14131418
1414static IrInstructionCallGen *ir_build_call_gen(IrAnalyze *ira, IrInstruction *source_instruction,1419static IrInstructionCallGen *ir_build_call_gen(IrAnalyze *ira, IrInstruction *source_instruction,
1415 ZigFn *fn_entry, IrInstruction *fn_ref, size_t arg_count, IrInstruction **args,1420 ZigFn *fn_entry, IrInstruction *fn_ref, size_t arg_count, IrInstruction **args,
1416 FnInline fn_inline, bool is_async, IrInstruction *new_stack, bool is_async_call_builtin,1421 FnInline fn_inline, CallModifier modifier, IrInstruction *new_stack, bool is_async_call_builtin,
1417 IrInstruction *result_loc, ZigType *return_type)1422 IrInstruction *result_loc, ZigType *return_type)
1418{1423{
1419 IrInstructionCallGen *call_instruction = ir_build_instruction<IrInstructionCallGen>(&ira->new_irb,1424 IrInstructionCallGen *call_instruction = ir_build_instruction<IrInstructionCallGen>(&ira->new_irb,
...@@ -1424,7 +1429,7 @@ static IrInstructionCallGen *ir_build_call_gen(IrAnalyze *ira, IrInstruction *so...@@ -1424,7 +1429,7 @@ static IrInstructionCallGen *ir_build_call_gen(IrAnalyze *ira, IrInstruction *so
1424 call_instruction->fn_inline = fn_inline;1429 call_instruction->fn_inline = fn_inline;
1425 call_instruction->args = args;1430 call_instruction->args = args;
1426 call_instruction->arg_count = arg_count;1431 call_instruction->arg_count = arg_count;
1427 call_instruction->is_async = is_async;1432 call_instruction->modifier = modifier;
1428 call_instruction->is_async_call_builtin = is_async_call_builtin;1433 call_instruction->is_async_call_builtin = is_async_call_builtin;
1429 call_instruction->new_stack = new_stack;1434 call_instruction->new_stack = new_stack;
1430 call_instruction->result_loc = result_loc;1435 call_instruction->result_loc = result_loc;
...@@ -2907,6 +2912,15 @@ static IrInstruction *ir_build_type_info(IrBuilder *irb, Scope *scope, AstNode *...@@ -2907,6 +2912,15 @@ static IrInstruction *ir_build_type_info(IrBuilder *irb, Scope *scope, AstNode *
2907 return &instruction->base;2912 return &instruction->base;
2908}2913}
29092914
2915static IrInstruction *ir_build_type(IrBuilder *irb, Scope *scope, AstNode *source_node, IrInstruction *type_info) {
2916 IrInstructionType *instruction = ir_build_instruction<IrInstructionType>(irb, scope, source_node);
2917 instruction->type_info = type_info;
2918
2919 ir_ref_instruction(type_info, irb->current_basic_block);
2920
2921 return &instruction->base;
2922}
2923
2910static IrInstruction *ir_build_type_id(IrBuilder *irb, Scope *scope, AstNode *source_node,2924static IrInstruction *ir_build_type_id(IrBuilder *irb, Scope *scope, AstNode *source_node,
2911 IrInstruction *type_value)2925 IrInstruction *type_value)
2912{2926{
...@@ -3072,10 +3086,11 @@ static IrInstruction *ir_build_save_err_ret_addr(IrBuilder *irb, Scope *scope, A...@@ -3072,10 +3086,11 @@ static IrInstruction *ir_build_save_err_ret_addr(IrBuilder *irb, Scope *scope, A
3072}3086}
30733087
3074static IrInstruction *ir_build_add_implicit_return_type(IrBuilder *irb, Scope *scope, AstNode *source_node,3088static IrInstruction *ir_build_add_implicit_return_type(IrBuilder *irb, Scope *scope, AstNode *source_node,
3075 IrInstruction *value)3089 IrInstruction *value, ResultLocReturn *result_loc_ret)
3076{3090{
3077 IrInstructionAddImplicitReturnType *instruction = ir_build_instruction<IrInstructionAddImplicitReturnType>(irb, scope, source_node);3091 IrInstructionAddImplicitReturnType *instruction = ir_build_instruction<IrInstructionAddImplicitReturnType>(irb, scope, source_node);
3078 instruction->value = value;3092 instruction->value = value;
3093 instruction->result_loc_ret = result_loc_ret;
30793094
3080 ir_ref_instruction(value, irb->current_basic_block);3095 ir_ref_instruction(value, irb->current_basic_block);
30813096
...@@ -3349,6 +3364,7 @@ static void ir_count_defers(IrBuilder *irb, Scope *inner_scope, Scope *outer_sco...@@ -3349,6 +3364,7 @@ static void ir_count_defers(IrBuilder *irb, Scope *inner_scope, Scope *outer_sco
3349 case ScopeIdCompTime:3364 case ScopeIdCompTime:
3350 case ScopeIdRuntime:3365 case ScopeIdRuntime:
3351 case ScopeIdTypeOf:3366 case ScopeIdTypeOf:
3367 case ScopeIdExpr:
3352 scope = scope->parent;3368 scope = scope->parent;
3353 continue;3369 continue;
3354 case ScopeIdDeferExpr:3370 case ScopeIdDeferExpr:
...@@ -3405,6 +3421,7 @@ static bool ir_gen_defers_for_block(IrBuilder *irb, Scope *inner_scope, Scope *o...@@ -3405,6 +3421,7 @@ static bool ir_gen_defers_for_block(IrBuilder *irb, Scope *inner_scope, Scope *o
3405 case ScopeIdCompTime:3421 case ScopeIdCompTime:
3406 case ScopeIdRuntime:3422 case ScopeIdRuntime:
3407 case ScopeIdTypeOf:3423 case ScopeIdTypeOf:
3424 case ScopeIdExpr:
3408 scope = scope->parent;3425 scope = scope->parent;
3409 continue;3426 continue;
3410 case ScopeIdDeferExpr:3427 case ScopeIdDeferExpr:
...@@ -3492,7 +3509,7 @@ static IrInstruction *ir_gen_return(IrBuilder *irb, Scope *scope, AstNode *node,...@@ -3492,7 +3509,7 @@ static IrInstruction *ir_gen_return(IrBuilder *irb, Scope *scope, AstNode *node,
3492 return_value = ir_build_const_void(irb, scope, node);3509 return_value = ir_build_const_void(irb, scope, node);
3493 }3510 }
34943511
3495 ir_mark_gen(ir_build_add_implicit_return_type(irb, scope, node, return_value));3512 ir_mark_gen(ir_build_add_implicit_return_type(irb, scope, node, return_value, result_loc_ret));
34963513
3497 size_t defer_counts[2];3514 size_t defer_counts[2];
3498 ir_count_defers(irb, scope, outer_scope, defer_counts);3515 ir_count_defers(irb, scope, outer_scope, defer_counts);
...@@ -3567,7 +3584,7 @@ static IrInstruction *ir_gen_return(IrBuilder *irb, Scope *scope, AstNode *node,...@@ -3567,7 +3584,7 @@ static IrInstruction *ir_gen_return(IrBuilder *irb, Scope *scope, AstNode *node,
3567 ir_set_cursor_at_end_and_append_block(irb, return_block);3584 ir_set_cursor_at_end_and_append_block(irb, return_block);
3568 IrInstruction *err_val_ptr = ir_build_unwrap_err_code(irb, scope, node, err_union_ptr);3585 IrInstruction *err_val_ptr = ir_build_unwrap_err_code(irb, scope, node, err_union_ptr);
3569 IrInstruction *err_val = ir_build_load_ptr(irb, scope, node, err_val_ptr);3586 IrInstruction *err_val = ir_build_load_ptr(irb, scope, node, err_val_ptr);
3570 ir_mark_gen(ir_build_add_implicit_return_type(irb, scope, node, err_val));3587 ir_mark_gen(ir_build_add_implicit_return_type(irb, scope, node, err_val, nullptr));
3571 IrInstructionSpillBegin *spill_begin = ir_build_spill_begin(irb, scope, node, err_val,3588 IrInstructionSpillBegin *spill_begin = ir_build_spill_begin(irb, scope, node, err_val,
3572 SpillIdRetErrCode);3589 SpillIdRetErrCode);
3573 ResultLocReturn *result_loc_ret = allocate<ResultLocReturn>(1);3590 ResultLocReturn *result_loc_ret = allocate<ResultLocReturn>(1);
...@@ -3611,7 +3628,7 @@ static ZigVar *create_local_var(CodeGen *codegen, AstNode *node, Scope *parent_s...@@ -3611,7 +3628,7 @@ static ZigVar *create_local_var(CodeGen *codegen, AstNode *node, Scope *parent_s
3611 }3628 }
36123629
3613 if (name) {3630 if (name) {
3614 buf_init_from_buf(&variable_entry->name, name);3631 variable_entry->name = strdup(buf_ptr(name));
36153632
3616 if (!skip_name_check) {3633 if (!skip_name_check) {
3617 ZigVar *existing_var = find_variable(codegen, parent_scope, name, nullptr);3634 ZigVar *existing_var = find_variable(codegen, parent_scope, name, nullptr);
...@@ -3644,7 +3661,7 @@ static ZigVar *create_local_var(CodeGen *codegen, AstNode *node, Scope *parent_s...@@ -3644,7 +3661,7 @@ static ZigVar *create_local_var(CodeGen *codegen, AstNode *node, Scope *parent_s
3644 // TODO make this name not actually be in scope. user should be able to make a variable called "_anon"3661 // TODO make this name not actually be in scope. user should be able to make a variable called "_anon"
3645 // might already be solved, let's just make sure it has test coverage3662 // might already be solved, let's just make sure it has test coverage
3646 // maybe we put a prefix on this so the debug info doesn't clobber user debug info for same named variables3663 // maybe we put a prefix on this so the debug info doesn't clobber user debug info for same named variables
3647 buf_init_from_str(&variable_entry->name, "_anon");3664 variable_entry->name = "_anon";
3648 }3665 }
36493666
3650 variable_entry->src_is_const = src_is_const;3667 variable_entry->src_is_const = src_is_const;
...@@ -3677,6 +3694,7 @@ static ResultLocPeer *create_peer_result(ResultLocPeerParent *peer_parent) {...@@ -3677,6 +3694,7 @@ static ResultLocPeer *create_peer_result(ResultLocPeerParent *peer_parent) {
3677 result->base.id = ResultLocIdPeer;3694 result->base.id = ResultLocIdPeer;
3678 result->base.source_instruction = peer_parent->base.source_instruction;3695 result->base.source_instruction = peer_parent->base.source_instruction;
3679 result->parent = peer_parent;3696 result->parent = peer_parent;
3697 result->base.allow_write_through_const = peer_parent->parent->allow_write_through_const;
3680 return result;3698 return result;
3681}3699}
36823700
...@@ -3799,7 +3817,7 @@ static IrInstruction *ir_gen_block(IrBuilder *irb, Scope *parent_scope, AstNode...@@ -3799,7 +3817,7 @@ static IrInstruction *ir_gen_block(IrBuilder *irb, Scope *parent_scope, AstNode
3799 // no need for save_err_ret_addr because this cannot return error3817 // no need for save_err_ret_addr because this cannot return error
3800 // only generate unconditional defers3818 // only generate unconditional defers
38013819
3802 ir_mark_gen(ir_build_add_implicit_return_type(irb, child_scope, block_node, result));3820 ir_mark_gen(ir_build_add_implicit_return_type(irb, child_scope, block_node, result, nullptr));
3803 ir_gen_defers_for_block(irb, child_scope, outer_block_scope, false);3821 ir_gen_defers_for_block(irb, child_scope, outer_block_scope, false);
3804 return ir_mark_gen(ir_build_return(irb, child_scope, result->source_node, result));3822 return ir_mark_gen(ir_build_return(irb, child_scope, result->source_node, result));
3805}3823}
...@@ -4396,10 +4414,10 @@ static IrInstruction *ir_gen_async_call(IrBuilder *irb, Scope *scope, AstNode *a...@@ -4396,10 +4414,10 @@ static IrInstruction *ir_gen_async_call(IrBuilder *irb, Scope *scope, AstNode *a
43964414
4397 args[arg_count] = ret_ptr;4415 args[arg_count] = ret_ptr;
43984416
4399 bool is_async = await_node == nullptr;4417 CallModifier modifier = (await_node == nullptr) ? CallModifierAsync : CallModifierNone;
4400 bool is_async_call_builtin = true;4418 bool is_async_call_builtin = true;
4401 IrInstruction *call = ir_build_call_src(irb, scope, call_node, nullptr, fn_ref, arg_count, args, false,4419 IrInstruction *call = ir_build_call_src(irb, scope, call_node, nullptr, fn_ref, arg_count, args, false,
4402 FnInlineAuto, is_async, is_async_call_builtin, bytes, result_loc);4420 FnInlineAuto, modifier, is_async_call_builtin, bytes, result_loc);
4403 return ir_lval_wrap(irb, scope, call, lval, result_loc);4421 return ir_lval_wrap(irb, scope, call, lval, result_loc);
4404}4422}
44054423
...@@ -5046,6 +5064,16 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo...@@ -5046,6 +5064,16 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo
5046 IrInstruction *type_info = ir_build_type_info(irb, scope, node, arg0_value);5064 IrInstruction *type_info = ir_build_type_info(irb, scope, node, arg0_value);
5047 return ir_lval_wrap(irb, scope, type_info, lval, result_loc);5065 return ir_lval_wrap(irb, scope, type_info, lval, result_loc);
5048 }5066 }
5067 case BuiltinFnIdType:
5068 {
5069 AstNode *arg_node = node->data.fn_call_expr.params.at(0);
5070 IrInstruction *arg = ir_gen_node(irb, arg_node, scope);
5071 if (arg == irb->codegen->invalid_instruction)
5072 return arg;
5073
5074 IrInstruction *type = ir_build_type(irb, scope, node, arg);
5075 return ir_lval_wrap(irb, scope, type, lval, result_loc);
5076 }
5049 case BuiltinFnIdBreakpoint:5077 case BuiltinFnIdBreakpoint:
5050 return ir_lval_wrap(irb, scope, ir_build_breakpoint(irb, scope, node), lval, result_loc);5078 return ir_lval_wrap(irb, scope, ir_build_breakpoint(irb, scope, node), lval, result_loc);
5051 case BuiltinFnIdReturnAddress:5079 case BuiltinFnIdReturnAddress:
...@@ -5276,7 +5304,7 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo...@@ -5276,7 +5304,7 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo
5276 FnInline fn_inline = (builtin_fn->id == BuiltinFnIdInlineCall) ? FnInlineAlways : FnInlineNever;5304 FnInline fn_inline = (builtin_fn->id == BuiltinFnIdInlineCall) ? FnInlineAlways : FnInlineNever;
52775305
5278 IrInstruction *call = ir_build_call_src(irb, scope, node, nullptr, fn_ref, arg_count, args, false,5306 IrInstruction *call = ir_build_call_src(irb, scope, node, nullptr, fn_ref, arg_count, args, false,
5279 fn_inline, false, false, nullptr, result_loc);5307 fn_inline, CallModifierNone, false, nullptr, result_loc);
5280 return ir_lval_wrap(irb, scope, call, lval, result_loc);5308 return ir_lval_wrap(irb, scope, call, lval, result_loc);
5281 }5309 }
5282 case BuiltinFnIdNewStackCall:5310 case BuiltinFnIdNewStackCall:
...@@ -5309,7 +5337,7 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo...@@ -5309,7 +5337,7 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo
5309 }5337 }
53105338
5311 IrInstruction *call = ir_build_call_src(irb, scope, node, nullptr, fn_ref, arg_count, args, false,5339 IrInstruction *call = ir_build_call_src(irb, scope, node, nullptr, fn_ref, arg_count, args, false,
5312 FnInlineAuto, false, false, new_stack, result_loc);5340 FnInlineAuto, CallModifierNone, false, new_stack, result_loc);
5313 return ir_lval_wrap(irb, scope, call, lval, result_loc);5341 return ir_lval_wrap(irb, scope, call, lval, result_loc);
5314 }5342 }
5315 case BuiltinFnIdAsyncCall:5343 case BuiltinFnIdAsyncCall:
...@@ -5598,7 +5626,7 @@ static IrInstruction *ir_gen_fn_call(IrBuilder *irb, Scope *scope, AstNode *node...@@ -5598,7 +5626,7 @@ static IrInstruction *ir_gen_fn_call(IrBuilder *irb, Scope *scope, AstNode *node
5598{5626{
5599 assert(node->type == NodeTypeFnCallExpr);5627 assert(node->type == NodeTypeFnCallExpr);
56005628
5601 if (node->data.fn_call_expr.is_builtin)5629 if (node->data.fn_call_expr.modifier == CallModifierBuiltin)
5602 return ir_gen_builtin_fn_call(irb, scope, node, lval, result_loc);5630 return ir_gen_builtin_fn_call(irb, scope, node, lval, result_loc);
56035631
5604 AstNode *fn_ref_node = node->data.fn_call_expr.fn_ref_expr;5632 AstNode *fn_ref_node = node->data.fn_call_expr.fn_ref_expr;
...@@ -5615,9 +5643,8 @@ static IrInstruction *ir_gen_fn_call(IrBuilder *irb, Scope *scope, AstNode *node...@@ -5615,9 +5643,8 @@ static IrInstruction *ir_gen_fn_call(IrBuilder *irb, Scope *scope, AstNode *node
5615 return args[i];5643 return args[i];
5616 }5644 }
56175645
5618 bool is_async = node->data.fn_call_expr.is_async;
5619 IrInstruction *fn_call = ir_build_call_src(irb, scope, node, nullptr, fn_ref, arg_count, args, false,5646 IrInstruction *fn_call = ir_build_call_src(irb, scope, node, nullptr, fn_ref, arg_count, args, false,
5620 FnInlineAuto, is_async, false, nullptr, result_loc);5647 FnInlineAuto, node->data.fn_call_expr.modifier, false, nullptr, result_loc);
5621 return ir_lval_wrap(irb, scope, fn_call, lval, result_loc);5648 return ir_lval_wrap(irb, scope, fn_call, lval, result_loc);
5622}5649}
56235650
...@@ -6440,7 +6467,9 @@ static IrInstruction *ir_gen_for_expr(IrBuilder *irb, Scope *parent_scope, AstNo...@@ -6440,7 +6467,9 @@ static IrInstruction *ir_gen_for_expr(IrBuilder *irb, Scope *parent_scope, AstNo
6440 }6467 }
6441 assert(elem_node->type == NodeTypeSymbol);6468 assert(elem_node->type == NodeTypeSymbol);
64426469
6443 IrInstruction *array_val_ptr = ir_gen_node_extra(irb, array_node, parent_scope, LValPtr, nullptr);6470 ScopeExpr *spill_scope = create_expr_scope(irb->codegen, node, parent_scope);
6471
6472 IrInstruction *array_val_ptr = ir_gen_node_extra(irb, array_node, &spill_scope->base, LValPtr, nullptr);
6444 if (array_val_ptr == irb->codegen->invalid_instruction)6473 if (array_val_ptr == irb->codegen->invalid_instruction)
6445 return array_val_ptr;6474 return array_val_ptr;
64466475
...@@ -6477,11 +6506,11 @@ static IrInstruction *ir_gen_for_expr(IrBuilder *irb, Scope *parent_scope, AstNo...@@ -6477,11 +6506,11 @@ static IrInstruction *ir_gen_for_expr(IrBuilder *irb, Scope *parent_scope, AstNo
64776506
6478 Buf *len_field_name = buf_create_from_str("len");6507 Buf *len_field_name = buf_create_from_str("len");
6479 IrInstruction *len_ref = ir_build_field_ptr(irb, parent_scope, node, array_val_ptr, len_field_name, false);6508 IrInstruction *len_ref = ir_build_field_ptr(irb, parent_scope, node, array_val_ptr, len_field_name, false);
6480 IrInstruction *len_val = ir_build_load_ptr(irb, parent_scope, node, len_ref);6509 IrInstruction *len_val = ir_build_load_ptr(irb, &spill_scope->base, node, len_ref);
6481 ir_build_br(irb, parent_scope, node, cond_block, is_comptime);6510 ir_build_br(irb, parent_scope, node, cond_block, is_comptime);
64826511
6483 ir_set_cursor_at_end_and_append_block(irb, cond_block);6512 ir_set_cursor_at_end_and_append_block(irb, cond_block);
6484 IrInstruction *index_val = ir_build_load_ptr(irb, parent_scope, node, index_ptr);6513 IrInstruction *index_val = ir_build_load_ptr(irb, &spill_scope->base, node, index_ptr);
6485 IrInstruction *cond = ir_build_bin_op(irb, parent_scope, node, IrBinOpCmpLessThan, index_val, len_val, false);6514 IrInstruction *cond = ir_build_bin_op(irb, parent_scope, node, IrBinOpCmpLessThan, index_val, len_val, false);
6486 IrBasicBlock *after_cond_block = irb->current_basic_block;6515 IrBasicBlock *after_cond_block = irb->current_basic_block;
6487 IrInstruction *void_else_value = else_node ? nullptr : ir_mark_gen(ir_build_const_void(irb, parent_scope, node));6516 IrInstruction *void_else_value = else_node ? nullptr : ir_mark_gen(ir_build_const_void(irb, parent_scope, node));
...@@ -6491,7 +6520,8 @@ static IrInstruction *ir_gen_for_expr(IrBuilder *irb, Scope *parent_scope, AstNo...@@ -6491,7 +6520,8 @@ static IrInstruction *ir_gen_for_expr(IrBuilder *irb, Scope *parent_scope, AstNo
6491 ResultLocPeerParent *peer_parent = ir_build_result_peers(irb, cond_br_inst, end_block, result_loc, is_comptime);6520 ResultLocPeerParent *peer_parent = ir_build_result_peers(irb, cond_br_inst, end_block, result_loc, is_comptime);
64926521
6493 ir_set_cursor_at_end_and_append_block(irb, body_block);6522 ir_set_cursor_at_end_and_append_block(irb, body_block);
6494 IrInstruction *elem_ptr = ir_build_elem_ptr(irb, parent_scope, node, array_val_ptr, index_val, false,6523 Scope *elem_ptr_scope = node->data.for_expr.elem_is_ptr ? parent_scope : &spill_scope->base;
6524 IrInstruction *elem_ptr = ir_build_elem_ptr(irb, elem_ptr_scope, node, array_val_ptr, index_val, false,
6495 PtrLenSingle, nullptr);6525 PtrLenSingle, nullptr);
6496 // TODO make it an error to write to element variable or i variable.6526 // TODO make it an error to write to element variable or i variable.
6497 Buf *elem_var_name = elem_node->data.symbol_expr.symbol;6527 Buf *elem_var_name = elem_node->data.symbol_expr.symbol;
...@@ -6499,7 +6529,7 @@ static IrInstruction *ir_gen_for_expr(IrBuilder *irb, Scope *parent_scope, AstNo...@@ -6499,7 +6529,7 @@ static IrInstruction *ir_gen_for_expr(IrBuilder *irb, Scope *parent_scope, AstNo
6499 Scope *child_scope = elem_var->child_scope;6529 Scope *child_scope = elem_var->child_scope;
65006530
6501 IrInstruction *var_ptr = node->data.for_expr.elem_is_ptr ?6531 IrInstruction *var_ptr = node->data.for_expr.elem_is_ptr ?
6502 ir_build_ref(irb, parent_scope, elem_node, elem_ptr, true, false) : elem_ptr;6532 ir_build_ref(irb, &spill_scope->base, elem_node, elem_ptr, true, false) : elem_ptr;
6503 ir_build_var_decl_src(irb, parent_scope, elem_node, elem_var, nullptr, var_ptr);6533 ir_build_var_decl_src(irb, parent_scope, elem_node, elem_var, nullptr, var_ptr);
65046534
6505 ZigList<IrInstruction *> incoming_values = {0};6535 ZigList<IrInstruction *> incoming_values = {0};
...@@ -6512,6 +6542,7 @@ static IrInstruction *ir_gen_for_expr(IrBuilder *irb, Scope *parent_scope, AstNo...@@ -6512,6 +6542,7 @@ static IrInstruction *ir_gen_for_expr(IrBuilder *irb, Scope *parent_scope, AstNo
6512 loop_scope->incoming_values = &incoming_values;6542 loop_scope->incoming_values = &incoming_values;
6513 loop_scope->lval = LValNone;6543 loop_scope->lval = LValNone;
6514 loop_scope->peer_parent = peer_parent;6544 loop_scope->peer_parent = peer_parent;
6545 loop_scope->spill_scope = spill_scope;
65156546
6516 // Note the body block of the loop is not the place that lval and result_loc are used -6547 // Note the body block of the loop is not the place that lval and result_loc are used -
6517 // it's actually in break statements, handled similarly to return statements.6548 // it's actually in break statements, handled similarly to return statements.
...@@ -7911,7 +7942,7 @@ static IrInstruction *ir_gen_await_expr(IrBuilder *irb, Scope *scope, AstNode *n...@@ -7911,7 +7942,7 @@ static IrInstruction *ir_gen_await_expr(IrBuilder *irb, Scope *scope, AstNode *n
7911 assert(node->type == NodeTypeAwaitExpr);7942 assert(node->type == NodeTypeAwaitExpr);
79127943
7913 AstNode *expr_node = node->data.await_expr.expr;7944 AstNode *expr_node = node->data.await_expr.expr;
7914 if (expr_node->type == NodeTypeFnCallExpr && expr_node->data.fn_call_expr.is_builtin) {7945 if (expr_node->type == NodeTypeFnCallExpr && expr_node->data.fn_call_expr.modifier == CallModifierBuiltin) {
7915 AstNode *fn_ref_expr = expr_node->data.fn_call_expr.fn_ref_expr;7946 AstNode *fn_ref_expr = expr_node->data.fn_call_expr.fn_ref_expr;
7916 Buf *name = fn_ref_expr->data.symbol_expr.symbol;7947 Buf *name = fn_ref_expr->data.symbol_expr.symbol;
7917 auto entry = irb->codegen->builtin_fn_table.maybe_get(name);7948 auto entry = irb->codegen->builtin_fn_table.maybe_get(name);
...@@ -8133,7 +8164,15 @@ static IrInstruction *ir_gen_node_extra(IrBuilder *irb, AstNode *node, Scope *sc...@@ -8133,7 +8164,15 @@ static IrInstruction *ir_gen_node_extra(IrBuilder *irb, AstNode *node, Scope *sc
8133 result_loc = no_result_loc();8164 result_loc = no_result_loc();
8134 ir_build_reset_result(irb, scope, node, result_loc);8165 ir_build_reset_result(irb, scope, node, result_loc);
8135 }8166 }
8136 IrInstruction *result = ir_gen_node_raw(irb, node, scope, lval, result_loc);8167 Scope *child_scope;
8168 if (irb->exec->is_inline ||
8169 (irb->exec->fn_entry != nullptr && irb->exec->fn_entry->child_scope == scope))
8170 {
8171 child_scope = scope;
8172 } else {
8173 child_scope = &create_expr_scope(irb->codegen, node, scope)->base;
8174 }
8175 IrInstruction *result = ir_gen_node_raw(irb, node, child_scope, lval, result_loc);
8137 if (result == irb->codegen->invalid_instruction) {8176 if (result == irb->codegen->invalid_instruction) {
8138 if (irb->exec->first_err_trace_msg == nullptr) {8177 if (irb->exec->first_err_trace_msg == nullptr) {
8139 irb->exec->first_err_trace_msg = irb->codegen->trace_err;8178 irb->exec->first_err_trace_msg = irb->codegen->trace_err;
...@@ -8184,7 +8223,7 @@ bool ir_gen(CodeGen *codegen, AstNode *node, Scope *scope, IrExecutable *ir_exec...@@ -8184,7 +8223,7 @@ bool ir_gen(CodeGen *codegen, AstNode *node, Scope *scope, IrExecutable *ir_exec
8184 }8223 }
81858224
8186 if (!instr_is_unreachable(result)) {8225 if (!instr_is_unreachable(result)) {
8187 ir_mark_gen(ir_build_add_implicit_return_type(irb, scope, result->source_node, result));8226 ir_mark_gen(ir_build_add_implicit_return_type(irb, scope, result->source_node, result, nullptr));
8188 // no need for save_err_ret_addr because this cannot return error8227 // no need for save_err_ret_addr because this cannot return error
8189 ir_mark_gen(ir_build_return(irb, scope, result->source_node, result));8228 ir_mark_gen(ir_build_return(irb, scope, result->source_node, result));
8190 }8229 }
...@@ -10869,7 +10908,7 @@ ConstExprValue *ir_eval_const_value(CodeGen *codegen, Scope *scope, AstNode *nod...@@ -10869,7 +10908,7 @@ ConstExprValue *ir_eval_const_value(CodeGen *codegen, Scope *scope, AstNode *nod
10869 fprintf(stderr, "\nSource: ");10908 fprintf(stderr, "\nSource: ");
10870 ast_render(stderr, node, 4);10909 ast_render(stderr, node, 4);
10871 fprintf(stderr, "\n{ // (IR)\n");10910 fprintf(stderr, "\n{ // (IR)\n");
10872 ir_print(codegen, stderr, ir_executable, 2, 1);10911 ir_print(codegen, stderr, ir_executable, 2, IrPassSrc);
10873 fprintf(stderr, "}\n");10912 fprintf(stderr, "}\n");
10874 }10913 }
10875 IrExecutable *analyzed_executable = allocate<IrExecutable>(1);10914 IrExecutable *analyzed_executable = allocate<IrExecutable>(1);
...@@ -10890,7 +10929,7 @@ ConstExprValue *ir_eval_const_value(CodeGen *codegen, Scope *scope, AstNode *nod...@@ -10890,7 +10929,7 @@ ConstExprValue *ir_eval_const_value(CodeGen *codegen, Scope *scope, AstNode *nod
1089010929
10891 if (codegen->verbose_ir) {10930 if (codegen->verbose_ir) {
10892 fprintf(stderr, "{ // (analyzed)\n");10931 fprintf(stderr, "{ // (analyzed)\n");
10893 ir_print(codegen, stderr, analyzed_executable, 2, 2);10932 ir_print(codegen, stderr, analyzed_executable, 2, IrPassGen);
10894 fprintf(stderr, "}\n");10933 fprintf(stderr, "}\n");
10895 }10934 }
1089610935
...@@ -12058,6 +12097,29 @@ static bool is_pointery_and_elem_is_not_pointery(ZigType *ty) {...@@ -12058,6 +12097,29 @@ static bool is_pointery_and_elem_is_not_pointery(ZigType *ty) {
12058 return false;12097 return false;
12059}12098}
1206012099
12100static IrInstruction *ir_analyze_enum_literal(IrAnalyze *ira, IrInstruction *source_instr, IrInstruction *value,
12101 ZigType *enum_type)
12102{
12103 assert(enum_type->id == ZigTypeIdEnum);
12104
12105 Error err;
12106 if ((err = type_resolve(ira->codegen, enum_type, ResolveStatusZeroBitsKnown)))
12107 return ira->codegen->invalid_instruction;
12108
12109 TypeEnumField *field = find_enum_type_field(enum_type, value->value.data.x_enum_literal);
12110 if (field == nullptr) {
12111 ErrorMsg *msg = ir_add_error(ira, source_instr, buf_sprintf("enum '%s' has no field named '%s'",
12112 buf_ptr(&enum_type->name), buf_ptr(value->value.data.x_enum_literal)));
12113 add_error_note(ira->codegen, msg, enum_type->data.enumeration.decl_node,
12114 buf_sprintf("'%s' declared here", buf_ptr(&enum_type->name)));
12115 return ira->codegen->invalid_instruction;
12116 }
12117 IrInstruction *result = ir_const(ira, source_instr, enum_type);
12118 bigint_init_bigint(&result->value.data.x_enum_tag, &field->value);
12119
12120 return result;
12121}
12122
12061static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_instr,12123static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_instr,
12062 ZigType *wanted_type, IrInstruction *value, ResultLoc *result_loc)12124 ZigType *wanted_type, IrInstruction *value, ResultLoc *result_loc)
12063{12125{
...@@ -12416,21 +12478,31 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst...@@ -12416,21 +12478,31 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst
12416 }12478 }
1241712479
12418 // cast from enum literal to enum with matching field name12480 // cast from enum literal to enum with matching field name
12419 if (actual_type->id == ZigTypeIdEnumLiteral && wanted_type->id == ZigTypeIdEnum) {12481 if (actual_type->id == ZigTypeIdEnumLiteral && wanted_type->id == ZigTypeIdEnum)
12420 if ((err = type_resolve(ira->codegen, wanted_type, ResolveStatusZeroBitsKnown)))12482 {
12421 return ira->codegen->invalid_instruction;12483 return ir_analyze_enum_literal(ira, source_instr, value, wanted_type);
12484 }
1242212485
12423 TypeEnumField *field = find_enum_type_field(wanted_type, value->value.data.x_enum_literal);12486 // cast from enum literal to optional enum
12424 if (field == nullptr) {12487 if (actual_type->id == ZigTypeIdEnumLiteral &&
12425 ErrorMsg *msg = ir_add_error(ira, source_instr, buf_sprintf("enum '%s' has no field named '%s'",12488 (wanted_type->id == ZigTypeIdOptional && wanted_type->data.maybe.child_type->id == ZigTypeIdEnum))
12426 buf_ptr(&wanted_type->name), buf_ptr(value->value.data.x_enum_literal)));12489 {
12427 add_error_note(ira->codegen, msg, wanted_type->data.enumeration.decl_node,12490 IrInstruction *result = ir_analyze_enum_literal(ira, source_instr, value, wanted_type->data.maybe.child_type);
12428 buf_sprintf("'%s' declared here", buf_ptr(&wanted_type->name)));12491 if (result == ira->codegen->invalid_instruction)
12429 return ira->codegen->invalid_instruction;12492 return result;
12430 }12493
12431 IrInstruction *result = ir_const(ira, source_instr, wanted_type);12494 return ir_analyze_optional_wrap(ira, result, value, wanted_type, result_loc);
12432 bigint_init_bigint(&result->value.data.x_enum_tag, &field->value);12495 }
12433 return result;12496
12497 // cast from enum literal to error union when payload is an enum
12498 if (actual_type->id == ZigTypeIdEnumLiteral &&
12499 (wanted_type->id == ZigTypeIdErrorUnion && wanted_type->data.error_union.payload_type->id == ZigTypeIdEnum))
12500 {
12501 IrInstruction *result = ir_analyze_enum_literal(ira, source_instr, value, wanted_type->data.error_union.payload_type);
12502 if (result == ira->codegen->invalid_instruction)
12503 return result;
12504
12505 return ir_analyze_err_wrap_payload(ira, result, value, wanted_type, result_loc);
12434 }12506 }
1243512507
12436 // cast from union to the enum type of the union12508 // cast from union to the enum type of the union
...@@ -12883,7 +12955,9 @@ static IrInstruction *ir_analyze_instruction_add_implicit_return_type(IrAnalyze...@@ -12883,7 +12955,9 @@ static IrInstruction *ir_analyze_instruction_add_implicit_return_type(IrAnalyze
12883 if (type_is_invalid(value->value.type))12955 if (type_is_invalid(value->value.type))
12884 return ir_unreach_error(ira);12956 return ir_unreach_error(ira);
1288512957
12886 ira->src_implicit_return_type_list.append(value);12958 if (instruction->result_loc_ret == nullptr || !instruction->result_loc_ret->implicit_return_type_done) {
12959 ira->src_implicit_return_type_list.append(value);
12960 }
1288712961
12888 return ir_const_void(ira, &instruction->base);12962 return ir_const_void(ira, &instruction->base);
12889}12963}
...@@ -13154,6 +13228,46 @@ static IrInstruction *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp *...@@ -13154,6 +13228,46 @@ static IrInstruction *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp *
13154 ir_add_error_node(ira, source_node, buf_sprintf("comparison of '%s' with null",13228 ir_add_error_node(ira, source_node, buf_sprintf("comparison of '%s' with null",
13155 buf_ptr(&non_null_type->name)));13229 buf_ptr(&non_null_type->name)));
13156 return ira->codegen->invalid_instruction;13230 return ira->codegen->invalid_instruction;
13231 } else if (is_equality_cmp && (
13232 (op1->value.type->id == ZigTypeIdEnumLiteral && op2->value.type->id == ZigTypeIdUnion) ||
13233 (op2->value.type->id == ZigTypeIdEnumLiteral && op1->value.type->id == ZigTypeIdUnion)))
13234 {
13235 // Support equality comparison between a union's tag value and a enum literal
13236 IrInstruction *union_val = op1->value.type->id == ZigTypeIdUnion ? op1 : op2;
13237 IrInstruction *enum_val = op1->value.type->id == ZigTypeIdUnion ? op2 : op1;
13238
13239 ZigType *tag_type = union_val->value.type->data.unionation.tag_type;
13240 assert(tag_type != nullptr);
13241
13242 IrInstruction *casted_union = ir_implicit_cast(ira, union_val, tag_type);
13243 if (type_is_invalid(casted_union->value.type))
13244 return ira->codegen->invalid_instruction;
13245
13246 IrInstruction *casted_val = ir_implicit_cast(ira, enum_val, tag_type);
13247 if (type_is_invalid(casted_val->value.type))
13248 return ira->codegen->invalid_instruction;
13249
13250 if (instr_is_comptime(casted_union)) {
13251 ConstExprValue *const_union_val = ir_resolve_const(ira, casted_union, UndefBad);
13252 if (!const_union_val)
13253 return ira->codegen->invalid_instruction;
13254
13255 ConstExprValue *const_enum_val = ir_resolve_const(ira, casted_val, UndefBad);
13256 if (!const_enum_val)
13257 return ira->codegen->invalid_instruction;
13258
13259 Cmp cmp_result = bigint_cmp(&const_union_val->data.x_union.tag, &const_enum_val->data.x_enum_tag);
13260 bool bool_result = (op_id == IrBinOpCmpEq) ? cmp_result == CmpEQ : cmp_result != CmpEQ;
13261
13262 return ir_const_bool(ira, &bin_op_instruction->base, bool_result);
13263 }
13264
13265 IrInstruction *result = ir_build_bin_op(&ira->new_irb,
13266 bin_op_instruction->base.scope, bin_op_instruction->base.source_node,
13267 op_id, casted_union, casted_val, bin_op_instruction->safety_check_on);
13268 result->value.type = ira->codegen->builtin_types.entry_bool;
13269
13270 return result;
13157 }13271 }
1315813272
13159 if (op1->value.type->id == ZigTypeIdErrorSet && op2->value.type->id == ZigTypeIdErrorSet) {13273 if (op1->value.type->id == ZigTypeIdErrorSet && op2->value.type->id == ZigTypeIdErrorSet) {
...@@ -13678,7 +13792,7 @@ static IrInstruction *ir_analyze_bit_shift(IrAnalyze *ira, IrInstructionBinOp *b...@@ -13678,7 +13792,7 @@ static IrInstruction *ir_analyze_bit_shift(IrAnalyze *ira, IrInstructionBinOp *b
13678 return ira->codegen->invalid_instruction;13792 return ira->codegen->invalid_instruction;
1367913793
13680 if (op1->value.type->id != ZigTypeIdInt && op1->value.type->id != ZigTypeIdComptimeInt) {13794 if (op1->value.type->id != ZigTypeIdInt && op1->value.type->id != ZigTypeIdComptimeInt) {
13681 ir_add_error(ira, &bin_op_instruction->base,13795 ir_add_error(ira, bin_op_instruction->op1,
13682 buf_sprintf("bit shifting operation expected integer type, found '%s'",13796 buf_sprintf("bit shifting operation expected integer type, found '%s'",
13683 buf_ptr(&op1->value.type->name)));13797 buf_ptr(&op1->value.type->name)));
13684 return ira->codegen->invalid_instruction;13798 return ira->codegen->invalid_instruction;
...@@ -13688,6 +13802,13 @@ static IrInstruction *ir_analyze_bit_shift(IrAnalyze *ira, IrInstructionBinOp *b...@@ -13688,6 +13802,13 @@ static IrInstruction *ir_analyze_bit_shift(IrAnalyze *ira, IrInstructionBinOp *b
13688 if (type_is_invalid(op2->value.type))13802 if (type_is_invalid(op2->value.type))
13689 return ira->codegen->invalid_instruction;13803 return ira->codegen->invalid_instruction;
1369013804
13805 if (op2->value.type->id != ZigTypeIdInt && op2->value.type->id != ZigTypeIdComptimeInt) {
13806 ir_add_error(ira, bin_op_instruction->op2,
13807 buf_sprintf("shift amount has to be an integer type, but found '%s'",
13808 buf_ptr(&op2->value.type->name)));
13809 return ira->codegen->invalid_instruction;
13810 }
13811
13691 IrInstruction *casted_op2;13812 IrInstruction *casted_op2;
13692 IrBinOp op_id = bin_op_instruction->op_id;13813 IrBinOp op_id = bin_op_instruction->op_id;
13693 if (op1->value.type->id == ZigTypeIdComptimeInt) {13814 if (op1->value.type->id == ZigTypeIdComptimeInt) {
...@@ -14478,7 +14599,8 @@ static IrInstruction *ir_analyze_instruction_decl_var(IrAnalyze *ira,...@@ -14478,7 +14599,8 @@ static IrInstruction *ir_analyze_instruction_decl_var(IrAnalyze *ira,
14478 // We make a new variable so that it can hold a different type, and so the debug info can14599 // We make a new variable so that it can hold a different type, and so the debug info can
14479 // be distinct.14600 // be distinct.
14480 ZigVar *new_var = create_local_var(ira->codegen, var->decl_node, var->child_scope,14601 ZigVar *new_var = create_local_var(ira->codegen, var->decl_node, var->child_scope,
14481 &var->name, var->src_is_const, var->gen_is_const, var->shadowable, var->is_comptime, true);14602 buf_create_from_str(var->name), var->src_is_const, var->gen_is_const,
14603 var->shadowable, var->is_comptime, true);
14482 new_var->owner_exec = var->owner_exec;14604 new_var->owner_exec = var->owner_exec;
14483 new_var->align_bytes = var->align_bytes;14605 new_var->align_bytes = var->align_bytes;
14484 if (var->mem_slot_index != SIZE_MAX) {14606 if (var->mem_slot_index != SIZE_MAX) {
...@@ -14621,7 +14743,8 @@ static IrInstruction *ir_analyze_instruction_export(IrAnalyze *ira, IrInstructio...@@ -14621,7 +14743,8 @@ static IrInstruction *ir_analyze_instruction_export(IrAnalyze *ira, IrInstructio
14621 case CallingConventionNaked:14743 case CallingConventionNaked:
14622 case CallingConventionCold:14744 case CallingConventionCold:
14623 case CallingConventionStdcall:14745 case CallingConventionStdcall:
14624 add_fn_export(ira->codegen, fn_entry, symbol_name, global_linkage_id, cc == CallingConventionC);14746 add_fn_export(ira->codegen, fn_entry, buf_ptr(symbol_name), global_linkage_id,
14747 cc == CallingConventionC);
14625 break;14748 break;
14626 }14749 }
14627 } break;14750 } break;
...@@ -14759,7 +14882,7 @@ static IrInstruction *ir_analyze_instruction_export(IrAnalyze *ira, IrInstructio...@@ -14759,7 +14882,7 @@ static IrInstruction *ir_analyze_instruction_export(IrAnalyze *ira, IrInstructio
14759 if (load_ptr->ptr->id == IrInstructionIdVarPtr) {14882 if (load_ptr->ptr->id == IrInstructionIdVarPtr) {
14760 IrInstructionVarPtr *var_ptr = reinterpret_cast<IrInstructionVarPtr *>(load_ptr->ptr);14883 IrInstructionVarPtr *var_ptr = reinterpret_cast<IrInstructionVarPtr *>(load_ptr->ptr);
14761 ZigVar *var = var_ptr->var;14884 ZigVar *var = var_ptr->var;
14762 add_var_export(ira->codegen, var, symbol_name, global_linkage_id);14885 add_var_export(ira->codegen, var, buf_ptr(symbol_name), global_linkage_id);
14763 }14886 }
14764 }14887 }
1476514888
...@@ -14839,6 +14962,12 @@ static IrInstruction *ir_analyze_alloca(IrAnalyze *ira, IrInstruction *source_in...@@ -14839,6 +14962,12 @@ static IrInstruction *ir_analyze_alloca(IrAnalyze *ira, IrInstruction *source_in
14839 if (align != 0) {14962 if (align != 0) {
14840 if ((err = type_resolve(ira->codegen, var_type, ResolveStatusAlignmentKnown)))14963 if ((err = type_resolve(ira->codegen, var_type, ResolveStatusAlignmentKnown)))
14841 return ira->codegen->invalid_instruction;14964 return ira->codegen->invalid_instruction;
14965 if (!type_has_bits(var_type)) {
14966 ir_add_error(ira, source_inst,
14967 buf_sprintf("variable '%s' of zero-bit type '%s' has no in-memory representation, it cannot be aligned",
14968 name_hint, buf_ptr(&var_type->name)));
14969 return ira->codegen->invalid_instruction;
14970 }
14842 }14971 }
14843 assert(result->base.value.data.x_ptr.special != ConstPtrSpecialInvalid);14972 assert(result->base.value.data.x_ptr.special != ConstPtrSpecialInvalid);
1484414973
...@@ -14907,6 +15036,24 @@ static void set_up_result_loc_for_inferred_comptime(IrInstruction *ptr) {...@@ -14907,6 +15036,24 @@ static void set_up_result_loc_for_inferred_comptime(IrInstruction *ptr) {
14907 ptr->value.data.x_ptr.data.ref.pointee = undef_child;15036 ptr->value.data.x_ptr.data.ref.pointee = undef_child;
14908}15037}
1490915038
15039static bool ir_result_has_type(ResultLoc *result_loc) {
15040 switch (result_loc->id) {
15041 case ResultLocIdInvalid:
15042 case ResultLocIdPeerParent:
15043 zig_unreachable();
15044 case ResultLocIdNone:
15045 case ResultLocIdPeer:
15046 return false;
15047 case ResultLocIdReturn:
15048 case ResultLocIdInstruction:
15049 case ResultLocIdBitCast:
15050 return true;
15051 case ResultLocIdVar:
15052 return reinterpret_cast<ResultLocVar *>(result_loc)->var->decl_node->data.variable_declaration.type != nullptr;
15053 }
15054 zig_unreachable();
15055}
15056
14910// when calling this function, at the callsite must check for result type noreturn and propagate it up15057// when calling this function, at the callsite must check for result type noreturn and propagate it up
14911static IrInstruction *ir_resolve_result_raw(IrAnalyze *ira, IrInstruction *suspend_source_instr,15058static IrInstruction *ir_resolve_result_raw(IrAnalyze *ira, IrInstruction *suspend_source_instr,
14912 ResultLoc *result_loc, ZigType *value_type, IrInstruction *value, bool force_runtime, bool non_null_comptime)15059 ResultLoc *result_loc, ZigType *value_type, IrInstruction *value, bool force_runtime, bool non_null_comptime)
...@@ -15036,14 +15183,23 @@ static IrInstruction *ir_resolve_result_raw(IrAnalyze *ira, IrInstruction *suspe...@@ -15036,14 +15183,23 @@ static IrInstruction *ir_resolve_result_raw(IrAnalyze *ira, IrInstruction *suspe
15036 bool is_comptime;15183 bool is_comptime;
15037 if (!ir_resolve_comptime(ira, peer_parent->is_comptime->child, &is_comptime))15184 if (!ir_resolve_comptime(ira, peer_parent->is_comptime->child, &is_comptime))
15038 return ira->codegen->invalid_instruction;15185 return ira->codegen->invalid_instruction;
15039 peer_parent->skipped = is_comptime;15186 if (is_comptime) {
15040 if (peer_parent->skipped) {15187 peer_parent->skipped = true;
15041 if (non_null_comptime) {15188 if (non_null_comptime) {
15042 return ir_resolve_result(ira, suspend_source_instr, peer_parent->parent,15189 return ir_resolve_result(ira, suspend_source_instr, peer_parent->parent,
15043 value_type, value, force_runtime, non_null_comptime, true);15190 value_type, value, force_runtime, non_null_comptime, true);
15044 }15191 }
15045 return nullptr;15192 return nullptr;
15046 }15193 }
15194 if (ir_result_has_type(peer_parent->parent)) {
15195 if (peer_parent->parent->id == ResultLocIdReturn && value != nullptr) {
15196 reinterpret_cast<ResultLocReturn *>(peer_parent->parent)->implicit_return_type_done = true;
15197 ira->src_implicit_return_type_list.append(value);
15198 }
15199 peer_parent->skipped = true;
15200 return ir_resolve_result(ira, suspend_source_instr, peer_parent->parent,
15201 value_type, value, force_runtime, true, true);
15202 }
1504715203
15048 if (peer_parent->resolved_type == nullptr) {15204 if (peer_parent->resolved_type == nullptr) {
15049 if (peer_parent->end_bb->suspend_instruction_ref == nullptr) {15205 if (peer_parent->end_bb->suspend_instruction_ref == nullptr) {
...@@ -15253,9 +15409,11 @@ static void ir_reset_result(ResultLoc *result_loc) {...@@ -15253,9 +15409,11 @@ static void ir_reset_result(ResultLoc *result_loc) {
15253 alloca_src->base.child = nullptr;15409 alloca_src->base.child = nullptr;
15254 break;15410 break;
15255 }15411 }
15412 case ResultLocIdReturn:
15413 reinterpret_cast<ResultLocReturn *>(result_loc)->implicit_return_type_done = false;
15414 break;
15256 case ResultLocIdPeer:15415 case ResultLocIdPeer:
15257 case ResultLocIdNone:15416 case ResultLocIdNone:
15258 case ResultLocIdReturn:
15259 case ResultLocIdInstruction:15417 case ResultLocIdInstruction:
15260 case ResultLocIdBitCast:15418 case ResultLocIdBitCast:
15261 break;15419 break;
...@@ -15305,7 +15463,7 @@ static IrInstruction *ir_analyze_async_call(IrAnalyze *ira, IrInstructionCallSrc...@@ -15305,7 +15463,7 @@ static IrInstruction *ir_analyze_async_call(IrAnalyze *ira, IrInstructionCallSrc
15305 ZigType *anyframe_type = get_any_frame_type(ira->codegen, fn_ret_type);15463 ZigType *anyframe_type = get_any_frame_type(ira->codegen, fn_ret_type);
1530615464
15307 IrInstructionCallGen *call_gen = ir_build_call_gen(ira, &call_instruction->base, fn_entry, fn_ref,15465 IrInstructionCallGen *call_gen = ir_build_call_gen(ira, &call_instruction->base, fn_entry, fn_ref,
15308 arg_count, casted_args, FnInlineAuto, true, casted_new_stack,15466 arg_count, casted_args, FnInlineAuto, CallModifierAsync, casted_new_stack,
15309 call_instruction->is_async_call_builtin, ret_ptr, anyframe_type);15467 call_instruction->is_async_call_builtin, ret_ptr, anyframe_type);
15310 return &call_gen->base;15468 return &call_gen->base;
15311 } else {15469 } else {
...@@ -15319,8 +15477,8 @@ static IrInstruction *ir_analyze_async_call(IrAnalyze *ira, IrInstructionCallSrc...@@ -15319,8 +15477,8 @@ static IrInstruction *ir_analyze_async_call(IrAnalyze *ira, IrInstructionCallSrc
15319 if (type_is_invalid(result_loc->value.type))15477 if (type_is_invalid(result_loc->value.type))
15320 return ira->codegen->invalid_instruction;15478 return ira->codegen->invalid_instruction;
15321 return &ir_build_call_gen(ira, &call_instruction->base, fn_entry, fn_ref, arg_count,15479 return &ir_build_call_gen(ira, &call_instruction->base, fn_entry, fn_ref, arg_count,
15322 casted_args, FnInlineAuto, true, casted_new_stack, call_instruction->is_async_call_builtin,15480 casted_args, FnInlineAuto, CallModifierAsync, casted_new_stack,
15323 result_loc, frame_type)->base;15481 call_instruction->is_async_call_builtin, result_loc, frame_type)->base;
15324 }15482 }
15325}15483}
15326static bool ir_analyze_fn_call_inline_arg(IrAnalyze *ira, AstNode *fn_proto_node,15484static bool ir_analyze_fn_call_inline_arg(IrAnalyze *ira, AstNode *fn_proto_node,
...@@ -15671,6 +15829,7 @@ static IrInstruction *analyze_casted_new_stack(IrAnalyze *ira, IrInstructionCall...@@ -15671,6 +15829,7 @@ static IrInstruction *analyze_casted_new_stack(IrAnalyze *ira, IrInstructionCall
15671 ZigType *u8_ptr = get_pointer_to_type_extra(ira->codegen, ira->codegen->builtin_types.entry_u8,15829 ZigType *u8_ptr = get_pointer_to_type_extra(ira->codegen, ira->codegen->builtin_types.entry_u8,
15672 false, false, PtrLenUnknown, target_fn_align(ira->codegen->zig_target), 0, 0, false);15830 false, false, PtrLenUnknown, target_fn_align(ira->codegen->zig_target), 0, 0, false);
15673 ZigType *u8_slice = get_slice_type(ira->codegen, u8_ptr);15831 ZigType *u8_slice = get_slice_type(ira->codegen, u8_ptr);
15832 ira->codegen->need_frame_size_prefix_data = true;
15674 return ir_implicit_cast(ira, new_stack, u8_slice);15833 return ir_implicit_cast(ira, new_stack, u8_slice);
15675 }15834 }
15676}15835}
...@@ -16070,7 +16229,7 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c...@@ -16070,7 +16229,7 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c
16070 return ira->codegen->invalid_instruction;16229 return ira->codegen->invalid_instruction;
1607116230
16072 size_t impl_param_count = impl_fn_type_id->param_count;16231 size_t impl_param_count = impl_fn_type_id->param_count;
16073 if (call_instruction->is_async) {16232 if (call_instruction->modifier == CallModifierAsync) {
16074 IrInstruction *result = ir_analyze_async_call(ira, call_instruction, impl_fn, impl_fn->type_entry,16233 IrInstruction *result = ir_analyze_async_call(ira, call_instruction, impl_fn, impl_fn->type_entry,
16075 nullptr, casted_args, impl_param_count, casted_new_stack);16234 nullptr, casted_args, impl_param_count, casted_new_stack);
16076 return ir_finish_anal(ira, result);16235 return ir_finish_anal(ira, result);
...@@ -16097,14 +16256,17 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c...@@ -16097,14 +16256,17 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c
16097 result_loc = nullptr;16256 result_loc = nullptr;
16098 }16257 }
1609916258
16100 if (impl_fn_type_id->cc == CallingConventionAsync && parent_fn_entry->inferred_async_node == nullptr) {16259 if (impl_fn_type_id->cc == CallingConventionAsync &&
16260 parent_fn_entry->inferred_async_node == nullptr &&
16261 call_instruction->modifier != CallModifierNoAsync)
16262 {
16101 parent_fn_entry->inferred_async_node = fn_ref->source_node;16263 parent_fn_entry->inferred_async_node = fn_ref->source_node;
16102 parent_fn_entry->inferred_async_fn = impl_fn;16264 parent_fn_entry->inferred_async_fn = impl_fn;
16103 }16265 }
1610416266
16105 IrInstructionCallGen *new_call_instruction = ir_build_call_gen(ira, &call_instruction->base,16267 IrInstructionCallGen *new_call_instruction = ir_build_call_gen(ira, &call_instruction->base,
16106 impl_fn, nullptr, impl_param_count, casted_args, fn_inline,16268 impl_fn, nullptr, impl_param_count, casted_args, fn_inline,
16107 false, casted_new_stack, call_instruction->is_async_call_builtin, result_loc,16269 call_instruction->modifier, casted_new_stack, call_instruction->is_async_call_builtin, result_loc,
16108 impl_fn_type_id->return_type);16270 impl_fn_type_id->return_type);
1610916271
16110 if (get_scope_typeof(call_instruction->base.scope) == nullptr) {16272 if (get_scope_typeof(call_instruction->base.scope) == nullptr) {
...@@ -16221,13 +16383,16 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c...@@ -16221,13 +16383,16 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c
16221 if (casted_new_stack != nullptr && type_is_invalid(casted_new_stack->value.type))16383 if (casted_new_stack != nullptr && type_is_invalid(casted_new_stack->value.type))
16222 return ira->codegen->invalid_instruction;16384 return ira->codegen->invalid_instruction;
1622316385
16224 if (call_instruction->is_async) {16386 if (call_instruction->modifier == CallModifierAsync) {
16225 IrInstruction *result = ir_analyze_async_call(ira, call_instruction, fn_entry, fn_type, fn_ref,16387 IrInstruction *result = ir_analyze_async_call(ira, call_instruction, fn_entry, fn_type, fn_ref,
16226 casted_args, call_param_count, casted_new_stack);16388 casted_args, call_param_count, casted_new_stack);
16227 return ir_finish_anal(ira, result);16389 return ir_finish_anal(ira, result);
16228 }16390 }
1622916391
16230 if (fn_type_id->cc == CallingConventionAsync && parent_fn_entry->inferred_async_node == nullptr) {16392 if (fn_type_id->cc == CallingConventionAsync &&
16393 parent_fn_entry->inferred_async_node == nullptr &&
16394 call_instruction->modifier != CallModifierNoAsync)
16395 {
16231 parent_fn_entry->inferred_async_node = fn_ref->source_node;16396 parent_fn_entry->inferred_async_node = fn_ref->source_node;
16232 parent_fn_entry->inferred_async_fn = fn_entry;16397 parent_fn_entry->inferred_async_fn = fn_entry;
16233 }16398 }
...@@ -16254,7 +16419,7 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c...@@ -16254,7 +16419,7 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c
16254 }16419 }
1625516420
16256 IrInstructionCallGen *new_call_instruction = ir_build_call_gen(ira, &call_instruction->base, fn_entry, fn_ref,16421 IrInstructionCallGen *new_call_instruction = ir_build_call_gen(ira, &call_instruction->base, fn_entry, fn_ref,
16257 call_param_count, casted_args, fn_inline, false, casted_new_stack,16422 call_param_count, casted_args, fn_inline, call_instruction->modifier, casted_new_stack,
16258 call_instruction->is_async_call_builtin, result_loc, return_type);16423 call_instruction->is_async_call_builtin, result_loc, return_type);
16259 if (get_scope_typeof(call_instruction->base.scope) == nullptr) {16424 if (get_scope_typeof(call_instruction->base.scope) == nullptr) {
16260 parent_fn_entry->call_list.append(new_call_instruction);16425 parent_fn_entry->call_list.append(new_call_instruction);
...@@ -16461,6 +16626,15 @@ static IrInstruction *ir_analyze_negation(IrAnalyze *ira, IrInstructionUnOp *ins...@@ -16461,6 +16626,15 @@ static IrInstruction *ir_analyze_negation(IrAnalyze *ira, IrInstructionUnOp *ins
16461 if (type_is_invalid(expr_type))16626 if (type_is_invalid(expr_type))
16462 return ira->codegen->invalid_instruction;16627 return ira->codegen->invalid_instruction;
1646316628
16629 if (!(expr_type->id == ZigTypeIdInt || expr_type->id == ZigTypeIdComptimeInt ||
16630 expr_type->id == ZigTypeIdFloat || expr_type->id == ZigTypeIdComptimeFloat ||
16631 expr_type->id == ZigTypeIdVector))
16632 {
16633 ir_add_error(ira, &instruction->base,
16634 buf_sprintf("negation of type '%s'", buf_ptr(&expr_type->name)));
16635 return ira->codegen->invalid_instruction;
16636 }
16637
16464 bool is_wrap_op = (instruction->op_id == IrUnOpNegationWrap);16638 bool is_wrap_op = (instruction->op_id == IrUnOpNegationWrap);
1646516639
16466 ZigType *scalar_type = (expr_type->id == ZigTypeIdVector) ? expr_type->data.vector.elem_type : expr_type;16640 ZigType *scalar_type = (expr_type->id == ZigTypeIdVector) ? expr_type->data.vector.elem_type : expr_type;
...@@ -16810,10 +16984,21 @@ static IrInstruction *ir_analyze_instruction_phi(IrAnalyze *ira, IrInstructionPh...@@ -16810,10 +16984,21 @@ static IrInstruction *ir_analyze_instruction_phi(IrAnalyze *ira, IrInstructionPh
16810 return new_incoming_values.at(0);16984 return new_incoming_values.at(0);
16811 }16985 }
1681216986
16813 ZigType *resolved_type = ir_resolve_peer_types(ira, phi_instruction->base.source_node, nullptr,16987 ZigType *resolved_type;
16814 new_incoming_values.items, new_incoming_values.length);16988 if (peer_parent != nullptr && ir_result_has_type(peer_parent->parent)) {
16815 if (type_is_invalid(resolved_type))16989 if (peer_parent->parent->id == ResultLocIdReturn) {
16816 return ira->codegen->invalid_instruction;16990 resolved_type = ira->explicit_return_type;
16991 } else {
16992 ZigType *resolved_loc_ptr_type = peer_parent->parent->resolved_loc->value.type;
16993 ir_assert(resolved_loc_ptr_type->id == ZigTypeIdPointer, &phi_instruction->base);
16994 resolved_type = resolved_loc_ptr_type->data.pointer.child_type;
16995 }
16996 } else {
16997 resolved_type = ir_resolve_peer_types(ira, phi_instruction->base.source_node, nullptr,
16998 new_incoming_values.items, new_incoming_values.length);
16999 if (type_is_invalid(resolved_type))
17000 return ira->codegen->invalid_instruction;
17001 }
1681717002
16818 switch (type_has_one_possible_value(ira->codegen, resolved_type)) {17003 switch (type_has_one_possible_value(ira->codegen, resolved_type)) {
16819 case OnePossibleValueInvalid:17004 case OnePossibleValueInvalid:
...@@ -16880,7 +17065,7 @@ static IrInstruction *ir_analyze_instruction_var_ptr(IrAnalyze *ira, IrInstructi...@@ -16880,7 +17065,7 @@ static IrInstruction *ir_analyze_instruction_var_ptr(IrAnalyze *ira, IrInstructi
16880 IrInstruction *result = ir_get_var_ptr(ira, &instruction->base, var);17065 IrInstruction *result = ir_get_var_ptr(ira, &instruction->base, var);
16881 if (instruction->crossed_fndef_scope != nullptr && !instr_is_comptime(result)) {17066 if (instruction->crossed_fndef_scope != nullptr && !instr_is_comptime(result)) {
16882 ErrorMsg *msg = ir_add_error(ira, &instruction->base,17067 ErrorMsg *msg = ir_add_error(ira, &instruction->base,
16883 buf_sprintf("'%s' not accessible from inner function", buf_ptr(&var->name)));17068 buf_sprintf("'%s' not accessible from inner function", var->name));
16884 add_error_note(ira->codegen, msg, instruction->crossed_fndef_scope->base.source_node,17069 add_error_note(ira->codegen, msg, instruction->crossed_fndef_scope->base.source_node,
16885 buf_sprintf("crossed function definition here"));17070 buf_sprintf("crossed function definition here"));
16886 add_error_note(ira->codegen, msg, var->decl_node,17071 add_error_note(ira->codegen, msg, var->decl_node,
...@@ -17463,7 +17648,12 @@ static IrInstruction *ir_analyze_container_field_ptr(IrAnalyze *ira, Buf *field_...@@ -17463,7 +17648,12 @@ static IrInstruction *ir_analyze_container_field_ptr(IrAnalyze *ira, Buf *field_
17463 return ir_analyze_container_member_access_inner(ira, bare_type, field_name,17648 return ir_analyze_container_member_access_inner(ira, bare_type, field_name,
17464 source_instr, container_ptr, container_type);17649 source_instr, container_ptr, container_type);
17465 }17650 }
17466 ZigType *ptr_type = get_pointer_to_type_extra(ira->codegen, field->type_entry,17651
17652 ZigType *field_type = resolve_union_field_type(ira->codegen, field);
17653 if (field_type == nullptr)
17654 return ira->codegen->invalid_instruction;
17655
17656 ZigType *ptr_type = get_pointer_to_type_extra(ira->codegen, field_type,
17467 is_const, is_volatile, PtrLenSingle, 0, 0, 0, false);17657 is_const, is_volatile, PtrLenSingle, 0, 0, 0, false);
17468 if (instr_is_comptime(container_ptr)) {17658 if (instr_is_comptime(container_ptr)) {
17469 ConstExprValue *ptr_val = ir_resolve_const(ira, container_ptr, UndefBad);17659 ConstExprValue *ptr_val = ir_resolve_const(ira, container_ptr, UndefBad);
...@@ -17480,7 +17670,7 @@ static IrInstruction *ir_analyze_container_field_ptr(IrAnalyze *ira, Buf *field_...@@ -17480,7 +17670,7 @@ static IrInstruction *ir_analyze_container_field_ptr(IrAnalyze *ira, Buf *field_
17480 if (initializing) {17670 if (initializing) {
17481 ConstExprValue *payload_val = create_const_vals(1);17671 ConstExprValue *payload_val = create_const_vals(1);
17482 payload_val->special = ConstValSpecialUndef;17672 payload_val->special = ConstValSpecialUndef;
17483 payload_val->type = field->type_entry;17673 payload_val->type = field_type;
17484 payload_val->parent.id = ConstParentIdUnion;17674 payload_val->parent.id = ConstParentIdUnion;
17485 payload_val->parent.data.p_union.union_val = union_val;17675 payload_val->parent.data.p_union.union_val = union_val;
1748617676
...@@ -17587,7 +17777,8 @@ static IrInstruction *ir_analyze_decl_ref(IrAnalyze *ira, IrInstruction *source_...@@ -17587,7 +17777,8 @@ static IrInstruction *ir_analyze_decl_ref(IrAnalyze *ira, IrInstruction *source_
17587 return ir_error_dependency_loop(ira, source_instruction);17777 return ir_error_dependency_loop(ira, source_instruction);
17588 }17778 }
17589 if (tld_var->extern_lib_name != nullptr) {17779 if (tld_var->extern_lib_name != nullptr) {
17590 add_link_lib_symbol(ira, tld_var->extern_lib_name, &var->name, source_instruction->source_node);17780 add_link_lib_symbol(ira, tld_var->extern_lib_name, buf_create_from_str(var->name),
17781 source_instruction->source_node);
17591 }17782 }
1759217783
17593 return ir_get_var_ptr(ira, source_instruction, var);17784 return ir_get_var_ptr(ira, source_instruction, var);
...@@ -19544,6 +19735,11 @@ static IrInstruction *ir_analyze_instruction_compile_log(IrAnalyze *ira, IrInstr...@@ -19544,6 +19735,11 @@ static IrInstruction *ir_analyze_instruction_compile_log(IrAnalyze *ira, IrInstr
19544 if (type_is_invalid(msg->value.type))19735 if (type_is_invalid(msg->value.type))
19545 return ira->codegen->invalid_instruction;19736 return ira->codegen->invalid_instruction;
19546 buf_resize(&buf, 0);19737 buf_resize(&buf, 0);
19738 if (msg->value.special == ConstValSpecialLazy) {
19739 // Resolve any lazy value that's passed, we need its value
19740 if (ir_resolve_lazy(ira->codegen, msg->source_node, &msg->value))
19741 return ira->codegen->invalid_instruction;
19742 }
19547 render_const_value(ira->codegen, &buf, &msg->value);19743 render_const_value(ira->codegen, &buf, &msg->value);
19548 const char *comma_str = (i != 0) ? ", " : "";19744 const char *comma_str = (i != 0) ? ", " : "";
19549 fprintf(stderr, "%s%s", comma_str, buf_ptr(&buf));19745 fprintf(stderr, "%s%s", comma_str, buf_ptr(&buf));
...@@ -20041,8 +20237,9 @@ static Error ir_make_type_info_decls(IrAnalyze *ira, IrInstruction *source_instr...@@ -20041,8 +20237,9 @@ static Error ir_make_type_info_decls(IrAnalyze *ira, IrInstruction *source_instr
20041 for (size_t fn_arg_index = 0; fn_arg_index < fn_arg_count; fn_arg_index++) {20237 for (size_t fn_arg_index = 0; fn_arg_index < fn_arg_count; fn_arg_index++) {
20042 ZigVar *arg_var = fn_entry->variable_list.at(fn_arg_index);20238 ZigVar *arg_var = fn_entry->variable_list.at(fn_arg_index);
20043 ConstExprValue *fn_arg_name_val = &fn_arg_name_array->data.x_array.data.s_none.elements[fn_arg_index];20239 ConstExprValue *fn_arg_name_val = &fn_arg_name_array->data.x_array.data.s_none.elements[fn_arg_index];
20044 ConstExprValue *arg_name = create_const_str_lit(ira->codegen, &arg_var->name);20240 ConstExprValue *arg_name = create_const_str_lit(ira->codegen,
20045 init_const_slice(ira->codegen, fn_arg_name_val, arg_name, 0, buf_len(&arg_var->name), true);20241 buf_create_from_str(arg_var->name));
20242 init_const_slice(ira->codegen, fn_arg_name_val, arg_name, 0, strlen(arg_var->name), true);
20046 fn_arg_name_val->parent.id = ConstParentIdArray;20243 fn_arg_name_val->parent.id = ConstParentIdArray;
20047 fn_arg_name_val->parent.data.p_array.array_val = fn_arg_name_array;20244 fn_arg_name_val->parent.data.p_array.array_val = fn_arg_name_array;
20048 fn_arg_name_val->parent.data.p_array.elem_index = fn_arg_index;20245 fn_arg_name_val->parent.data.p_array.elem_index = fn_arg_index;
...@@ -20080,14 +20277,27 @@ static Error ir_make_type_info_decls(IrAnalyze *ira, IrInstruction *source_instr...@@ -20080,14 +20277,27 @@ static Error ir_make_type_info_decls(IrAnalyze *ira, IrInstruction *source_instr
20080 return ErrorNone;20277 return ErrorNone;
20081}20278}
2008220279
20083static uint32_t ptr_len_to_size_enum_index(PtrLen ptr_len) {20280static BuiltinPtrSize ptr_len_to_size_enum_index(PtrLen ptr_len) {
20084 switch (ptr_len) {20281 switch (ptr_len) {
20085 case PtrLenSingle:20282 case PtrLenSingle:
20086 return 0;20283 return BuiltinPtrSizeOne;
20087 case PtrLenUnknown:20284 case PtrLenUnknown:
20088 return 1;20285 return BuiltinPtrSizeMany;
20089 case PtrLenC:20286 case PtrLenC:
20090 return 3;20287 return BuiltinPtrSizeC;
20288 }
20289 zig_unreachable();
20290}
20291
20292static PtrLen size_enum_index_to_ptr_len(BuiltinPtrSize size_enum_index) {
20293 switch (size_enum_index) {
20294 case BuiltinPtrSizeOne:
20295 return PtrLenSingle;
20296 case BuiltinPtrSizeMany:
20297 case BuiltinPtrSizeSlice:
20298 return PtrLenUnknown;
20299 case BuiltinPtrSizeC:
20300 return PtrLenC;
20091 }20301 }
20092 zig_unreachable();20302 zig_unreachable();
20093}20303}
...@@ -20095,10 +20305,10 @@ static uint32_t ptr_len_to_size_enum_index(PtrLen ptr_len) {...@@ -20095,10 +20305,10 @@ static uint32_t ptr_len_to_size_enum_index(PtrLen ptr_len) {
20095static ConstExprValue *create_ptr_like_type_info(IrAnalyze *ira, ZigType *ptr_type_entry) {20305static ConstExprValue *create_ptr_like_type_info(IrAnalyze *ira, ZigType *ptr_type_entry) {
20096 Error err;20306 Error err;
20097 ZigType *attrs_type;20307 ZigType *attrs_type;
20098 uint32_t size_enum_index;20308 BuiltinPtrSize size_enum_index;
20099 if (is_slice(ptr_type_entry)) {20309 if (is_slice(ptr_type_entry)) {
20100 attrs_type = ptr_type_entry->data.structure.fields[slice_ptr_index].type_entry;20310 attrs_type = ptr_type_entry->data.structure.fields[slice_ptr_index].type_entry;
20101 size_enum_index = 2;20311 size_enum_index = BuiltinPtrSizeSlice;
20102 } else if (ptr_type_entry->id == ZigTypeIdPointer) {20312 } else if (ptr_type_entry->id == ZigTypeIdPointer) {
20103 attrs_type = ptr_type_entry;20313 attrs_type = ptr_type_entry;
20104 size_enum_index = ptr_len_to_size_enum_index(ptr_type_entry->data.pointer.ptr_len);20314 size_enum_index = ptr_len_to_size_enum_index(ptr_type_entry->data.pointer.ptr_len);
...@@ -20777,6 +20987,148 @@ static IrInstruction *ir_analyze_instruction_type_info(IrAnalyze *ira,...@@ -20777,6 +20987,148 @@ static IrInstruction *ir_analyze_instruction_type_info(IrAnalyze *ira,
20777 return result;20987 return result;
20778}20988}
2077920989
20990static ConstExprValue *get_const_field(IrAnalyze *ira, ConstExprValue *struct_value, const char *name, size_t field_index)
20991{
20992 ensure_field_index(struct_value->type, name, field_index);
20993 assert(struct_value->data.x_struct.fields[field_index].special == ConstValSpecialStatic);
20994 return &struct_value->data.x_struct.fields[field_index];
20995}
20996
20997static bool get_const_field_bool(IrAnalyze *ira, ConstExprValue *struct_value, const char *name, size_t field_index)
20998{
20999 ConstExprValue *value = get_const_field(ira, struct_value, name, field_index);
21000 assert(value->type == ira->codegen->builtin_types.entry_bool);
21001 return value->data.x_bool;
21002}
21003
21004static BigInt *get_const_field_lit_int(IrAnalyze *ira, ConstExprValue *struct_value, const char *name, size_t field_index)
21005{
21006 ConstExprValue *value = get_const_field(ira, struct_value, name, field_index);
21007 assert(value->type == ira->codegen->builtin_types.entry_num_lit_int);
21008 return &value->data.x_bigint;
21009}
21010
21011static ZigType *get_const_field_meta_type(IrAnalyze *ira, ConstExprValue *struct_value, const char *name, size_t field_index)
21012{
21013 ConstExprValue *value = get_const_field(ira, struct_value, name, field_index);
21014 assert(value->type == ira->codegen->builtin_types.entry_type);
21015 return value->data.x_type;
21016}
21017
21018static ZigType *type_info_to_type(IrAnalyze *ira, IrInstruction *instruction, ZigTypeId tagTypeId, ConstExprValue *payload) {
21019 switch (tagTypeId) {
21020 case ZigTypeIdInvalid:
21021 zig_unreachable();
21022 case ZigTypeIdMetaType:
21023 return ira->codegen->builtin_types.entry_type;
21024 case ZigTypeIdVoid:
21025 return ira->codegen->builtin_types.entry_void;
21026 case ZigTypeIdBool:
21027 return ira->codegen->builtin_types.entry_bool;
21028 case ZigTypeIdUnreachable:
21029 return ira->codegen->builtin_types.entry_unreachable;
21030 case ZigTypeIdInt:
21031 assert(payload->special == ConstValSpecialStatic);
21032 assert(payload->type == ir_type_info_get_type(ira, "Int", nullptr));
21033 return get_int_type(ira->codegen,
21034 get_const_field_bool(ira, payload, "is_signed", 0),
21035 bigint_as_u32(get_const_field_lit_int(ira, payload, "bits", 1)));
21036 case ZigTypeIdFloat:
21037 {
21038 assert(payload->special == ConstValSpecialStatic);
21039 assert(payload->type == ir_type_info_get_type(ira, "Float", nullptr));
21040 uint32_t bits = bigint_as_u32(get_const_field_lit_int(ira, payload, "bits", 0));
21041 switch (bits) {
21042 case 16: return ira->codegen->builtin_types.entry_f16;
21043 case 32: return ira->codegen->builtin_types.entry_f32;
21044 case 64: return ira->codegen->builtin_types.entry_f64;
21045 case 128: return ira->codegen->builtin_types.entry_f128;
21046 }
21047 ir_add_error(ira, instruction,
21048 buf_sprintf("%d-bit float unsupported", bits));
21049 return nullptr;
21050 }
21051 case ZigTypeIdPointer:
21052 {
21053 ZigType *type_info_pointer_type = ir_type_info_get_type(ira, "Pointer", nullptr);
21054 assert(payload->special == ConstValSpecialStatic);
21055 assert(payload->type == type_info_pointer_type);
21056 ConstExprValue *size_value = get_const_field(ira, payload, "size", 0);
21057 assert(size_value->type == ir_type_info_get_type(ira, "Size", type_info_pointer_type));
21058 BuiltinPtrSize size_enum_index = (BuiltinPtrSize)bigint_as_u32(&size_value->data.x_enum_tag);
21059 PtrLen ptr_len = size_enum_index_to_ptr_len(size_enum_index);
21060 ZigType *ptr_type = get_pointer_to_type_extra(ira->codegen,
21061 get_const_field_meta_type(ira, payload, "child", 4),
21062 get_const_field_bool(ira, payload, "is_const", 1),
21063 get_const_field_bool(ira, payload, "is_volatile", 2),
21064 ptr_len,
21065 bigint_as_u32(get_const_field_lit_int(ira, payload, "alignment", 3)),
21066 0, // bit_offset_in_host
21067 0, // host_int_bytes
21068 get_const_field_bool(ira, payload, "is_allowzero", 5)
21069 );
21070 if (size_enum_index != 2)
21071 return ptr_type;
21072 return get_slice_type(ira->codegen, ptr_type);
21073 }
21074 case ZigTypeIdArray:
21075 assert(payload->special == ConstValSpecialStatic);
21076 assert(payload->type == ir_type_info_get_type(ira, "Array", nullptr));
21077 return get_array_type(ira->codegen,
21078 get_const_field_meta_type(ira, payload, "child", 1),
21079 bigint_as_u64(get_const_field_lit_int(ira, payload, "len", 0))
21080 );
21081 case ZigTypeIdComptimeFloat:
21082 return ira->codegen->builtin_types.entry_num_lit_float;
21083 case ZigTypeIdComptimeInt:
21084 return ira->codegen->builtin_types.entry_num_lit_int;
21085 case ZigTypeIdUndefined:
21086 return ira->codegen->builtin_types.entry_undef;
21087 case ZigTypeIdNull:
21088 return ira->codegen->builtin_types.entry_null;
21089 case ZigTypeIdOptional:
21090 case ZigTypeIdErrorUnion:
21091 case ZigTypeIdErrorSet:
21092 case ZigTypeIdEnum:
21093 case ZigTypeIdOpaque:
21094 case ZigTypeIdFnFrame:
21095 case ZigTypeIdAnyFrame:
21096 case ZigTypeIdVector:
21097 case ZigTypeIdEnumLiteral:
21098 ir_add_error(ira, instruction, buf_sprintf(
21099 "TODO implement @Type for 'TypeInfo.%s': see https://github.com/ziglang/zig/issues/2907", type_id_name(tagTypeId)));
21100 return nullptr;
21101 case ZigTypeIdUnion:
21102 case ZigTypeIdFn:
21103 case ZigTypeIdBoundFn:
21104 case ZigTypeIdArgTuple:
21105 case ZigTypeIdStruct:
21106 ir_add_error(ira, instruction, buf_sprintf(
21107 "@Type not availble for 'TypeInfo.%s'", type_id_name(tagTypeId)));
21108 return nullptr;
21109 }
21110 zig_unreachable();
21111}
21112
21113static IrInstruction *ir_analyze_instruction_type(IrAnalyze *ira, IrInstructionType *instruction) {
21114 IrInstruction *type_info_ir = instruction->type_info->child;
21115 if (type_is_invalid(type_info_ir->value.type))
21116 return ira->codegen->invalid_instruction;
21117
21118 IrInstruction *casted_ir = ir_implicit_cast(ira, type_info_ir, ir_type_info_get_type(ira, nullptr, nullptr));
21119 if (type_is_invalid(casted_ir->value.type))
21120 return ira->codegen->invalid_instruction;
21121
21122 ConstExprValue *type_info_value = ir_resolve_const(ira, casted_ir, UndefBad);
21123 if (!type_info_value)
21124 return ira->codegen->invalid_instruction;
21125 ZigTypeId typeId = type_id_at_index(bigint_as_usize(&type_info_value->data.x_union.tag));
21126 ZigType *type = type_info_to_type(ira, type_info_ir, typeId, type_info_value->data.x_union.payload);
21127 if (!type)
21128 return ira->codegen->invalid_instruction;
21129 return ir_const_type(ira, &instruction->base, type);
21130}
21131
20780static IrInstruction *ir_analyze_instruction_type_id(IrAnalyze *ira,21132static IrInstruction *ir_analyze_instruction_type_id(IrAnalyze *ira,
20781 IrInstructionTypeId *instruction)21133 IrInstructionTypeId *instruction)
20782{21134{
...@@ -21036,15 +21388,20 @@ static IrInstruction *ir_analyze_instruction_c_define(IrAnalyze *ira, IrInstruct...@@ -21036,15 +21388,20 @@ static IrInstruction *ir_analyze_instruction_c_define(IrAnalyze *ira, IrInstruct
21036 if (type_is_invalid(value->value.type))21388 if (type_is_invalid(value->value.type))
21037 return ira->codegen->invalid_instruction;21389 return ira->codegen->invalid_instruction;
2103821390
21039 Buf *define_value = ir_resolve_str(ira, value);21391 Buf *define_value = nullptr;
21040 if (!define_value)21392 // The second parameter is either a string or void (equivalent to "")
21041 return ira->codegen->invalid_instruction;21393 if (value->value.type->id != ZigTypeIdVoid) {
21394 define_value = ir_resolve_str(ira, value);
21395 if (!define_value)
21396 return ira->codegen->invalid_instruction;
21397 }
2104221398
21043 Buf *c_import_buf = exec_c_import_buf(ira->new_irb.exec);21399 Buf *c_import_buf = exec_c_import_buf(ira->new_irb.exec);
21044 // We check for this error in pass121400 // We check for this error in pass1
21045 assert(c_import_buf);21401 assert(c_import_buf);
2104621402
21047 buf_appendf(c_import_buf, "#define %s %s\n", buf_ptr(define_name), buf_ptr(define_value));21403 buf_appendf(c_import_buf, "#define %s %s\n", buf_ptr(define_name),
21404 define_value ? buf_ptr(define_value) : "");
2104821405
21049 return ir_const_void(ira, &instruction->base);21406 return ir_const_void(ira, &instruction->base);
21050}21407}
...@@ -22533,6 +22890,8 @@ static IrInstruction *ir_analyze_instruction_frame_size(IrAnalyze *ira, IrInstru...@@ -22533,6 +22890,8 @@ static IrInstruction *ir_analyze_instruction_frame_size(IrAnalyze *ira, IrInstru
22533 return ira->codegen->invalid_instruction;22890 return ira->codegen->invalid_instruction;
22534 }22891 }
2253522892
22893 ira->codegen->need_frame_size_prefix_data = true;
22894
22536 IrInstruction *result = ir_build_frame_size_gen(&ira->new_irb, instruction->base.scope,22895 IrInstruction *result = ir_build_frame_size_gen(&ira->new_irb, instruction->base.scope,
22537 instruction->base.source_node, fn);22896 instruction->base.source_node, fn);
22538 result->value.type = ira->codegen->builtin_types.entry_usize;22897 result->value.type = ira->codegen->builtin_types.entry_usize;
...@@ -24823,7 +25182,7 @@ static IrInstruction *ir_analyze_instruction_end_expr(IrAnalyze *ira, IrInstruct...@@ -24823,7 +25182,7 @@ static IrInstruction *ir_analyze_instruction_end_expr(IrAnalyze *ira, IrInstruct
24823 if (result_loc->value.type->id == ZigTypeIdUnreachable)25182 if (result_loc->value.type->id == ZigTypeIdUnreachable)
24824 return result_loc;25183 return result_loc;
2482525184
24826 if (!was_written) {25185 if (!was_written || instruction->result_loc->id == ResultLocIdPeer) {
24827 IrInstruction *store_ptr = ir_analyze_store_ptr(ira, &instruction->base, result_loc, value,25186 IrInstruction *store_ptr = ir_analyze_store_ptr(ira, &instruction->base, result_loc, value,
24828 instruction->result_loc->allow_write_through_const);25187 instruction->result_loc->allow_write_through_const);
24829 if (type_is_invalid(store_ptr->value.type)) {25188 if (type_is_invalid(store_ptr->value.type)) {
...@@ -24831,7 +25190,9 @@ static IrInstruction *ir_analyze_instruction_end_expr(IrAnalyze *ira, IrInstruct...@@ -24831,7 +25190,9 @@ static IrInstruction *ir_analyze_instruction_end_expr(IrAnalyze *ira, IrInstruct
24831 }25190 }
24832 }25191 }
2483325192
24834 if (result_loc->value.data.x_ptr.mut == ConstPtrMutInfer) {25193 if (result_loc->value.data.x_ptr.mut == ConstPtrMutInfer &&
25194 instruction->result_loc->id != ResultLocIdPeer)
25195 {
24835 if (instr_is_comptime(value)) {25196 if (instr_is_comptime(value)) {
24836 result_loc->value.data.x_ptr.mut = ConstPtrMutComptimeConst;25197 result_loc->value.data.x_ptr.mut = ConstPtrMutComptimeConst;
24837 } else {25198 } else {
...@@ -25281,6 +25642,8 @@ static IrInstruction *ir_analyze_instruction_base(IrAnalyze *ira, IrInstruction...@@ -25281,6 +25642,8 @@ static IrInstruction *ir_analyze_instruction_base(IrAnalyze *ira, IrInstruction
25281 return ir_analyze_instruction_bit_offset_of(ira, (IrInstructionBitOffsetOf *)instruction);25642 return ir_analyze_instruction_bit_offset_of(ira, (IrInstructionBitOffsetOf *)instruction);
25282 case IrInstructionIdTypeInfo:25643 case IrInstructionIdTypeInfo:
25283 return ir_analyze_instruction_type_info(ira, (IrInstructionTypeInfo *) instruction);25644 return ir_analyze_instruction_type_info(ira, (IrInstructionTypeInfo *) instruction);
25645 case IrInstructionIdType:
25646 return ir_analyze_instruction_type(ira, (IrInstructionType *)instruction);
25284 case IrInstructionIdHasField:25647 case IrInstructionIdHasField:
25285 return ir_analyze_instruction_has_field(ira, (IrInstructionHasField *) instruction);25648 return ir_analyze_instruction_has_field(ira, (IrInstructionHasField *) instruction);
25286 case IrInstructionIdTypeId:25649 case IrInstructionIdTypeId:
...@@ -25584,6 +25947,7 @@ bool ir_has_side_effects(IrInstruction *instruction) {...@@ -25584,6 +25947,7 @@ bool ir_has_side_effects(IrInstruction *instruction) {
25584 case IrInstructionIdByteOffsetOf:25947 case IrInstructionIdByteOffsetOf:
25585 case IrInstructionIdBitOffsetOf:25948 case IrInstructionIdBitOffsetOf:
25586 case IrInstructionIdTypeInfo:25949 case IrInstructionIdTypeInfo:
25950 case IrInstructionIdType:
25587 case IrInstructionIdHasField:25951 case IrInstructionIdHasField:
25588 case IrInstructionIdTypeId:25952 case IrInstructionIdTypeId:
25589 case IrInstructionIdAlignCast:25953 case IrInstructionIdAlignCast:
src/ir.hpp+5
...@@ -10,6 +10,11 @@...@@ -10,6 +10,11 @@
1010
11#include "all_types.hpp"11#include "all_types.hpp"
1212
13enum IrPass {
14 IrPassSrc,
15 IrPassGen,
16};
17
13bool ir_gen(CodeGen *g, AstNode *node, Scope *scope, IrExecutable *ir_executable);18bool ir_gen(CodeGen *g, AstNode *node, Scope *scope, IrExecutable *ir_executable);
14bool ir_gen_fn(CodeGen *g, ZigFn *fn_entry);19bool ir_gen_fn(CodeGen *g, ZigFn *fn_entry);
1520
src/ir_print.cpp+43-14
...@@ -22,7 +22,7 @@ using InstructionSet = HashMap<IrInstruction*, uint8_t, hash_instruction_ptr, in...@@ -22,7 +22,7 @@ using InstructionSet = HashMap<IrInstruction*, uint8_t, hash_instruction_ptr, in
22using InstructionList = ZigList<IrInstruction*>;22using InstructionList = ZigList<IrInstruction*>;
2323
24struct IrPrint {24struct IrPrint {
25 size_t pass_num;25 IrPass pass;
26 CodeGen *codegen;26 CodeGen *codegen;
27 FILE *f;27 FILE *f;
28 int indent;28 int indent;
...@@ -280,6 +280,8 @@ static const char* ir_instruction_type_str(IrInstruction* instruction) {...@@ -280,6 +280,8 @@ static const char* ir_instruction_type_str(IrInstruction* instruction) {
280 return "BitOffsetOf";280 return "BitOffsetOf";
281 case IrInstructionIdTypeInfo:281 case IrInstructionIdTypeInfo:
282 return "TypeInfo";282 return "TypeInfo";
283 case IrInstructionIdType:
284 return "Type";
283 case IrInstructionIdHasField:285 case IrInstructionIdHasField:
284 return "HasField";286 return "HasField";
285 case IrInstructionIdTypeId:287 case IrInstructionIdTypeId:
...@@ -389,7 +391,7 @@ static void ir_print_const_value(IrPrint *irp, ConstExprValue *const_val) {...@@ -389,7 +391,7 @@ static void ir_print_const_value(IrPrint *irp, ConstExprValue *const_val) {
389391
390static void ir_print_var_instruction(IrPrint *irp, IrInstruction *instruction) {392static void ir_print_var_instruction(IrPrint *irp, IrInstruction *instruction) {
391 fprintf(irp->f, "#%" ZIG_PRI_usize "", instruction->debug_id);393 fprintf(irp->f, "#%" ZIG_PRI_usize "", instruction->debug_id);
392 if (irp->pass_num == 2 && irp->printed.maybe_get(instruction) == nullptr) {394 if (irp->pass != IrPassSrc && irp->printed.maybe_get(instruction) == nullptr) {
393 irp->printed.put(instruction, 0);395 irp->printed.put(instruction, 0);
394 irp->pending.append(instruction);396 irp->pending.append(instruction);
395 }397 }
...@@ -529,7 +531,7 @@ static void ir_print_bin_op(IrPrint *irp, IrInstructionBinOp *bin_op_instruction...@@ -529,7 +531,7 @@ static void ir_print_bin_op(IrPrint *irp, IrInstructionBinOp *bin_op_instruction
529531
530static void ir_print_decl_var_src(IrPrint *irp, IrInstructionDeclVarSrc *decl_var_instruction) {532static void ir_print_decl_var_src(IrPrint *irp, IrInstructionDeclVarSrc *decl_var_instruction) {
531 const char *var_or_const = decl_var_instruction->var->gen_is_const ? "const" : "var";533 const char *var_or_const = decl_var_instruction->var->gen_is_const ? "const" : "var";
532 const char *name = buf_ptr(&decl_var_instruction->var->name);534 const char *name = decl_var_instruction->var->name;
533 if (decl_var_instruction->var_type) {535 if (decl_var_instruction->var_type) {
534 fprintf(irp->f, "%s %s: ", var_or_const, name);536 fprintf(irp->f, "%s %s: ", var_or_const, name);
535 ir_print_other_instruction(irp, decl_var_instruction->var_type);537 ir_print_other_instruction(irp, decl_var_instruction->var_type);
...@@ -606,8 +608,17 @@ static void ir_print_result_loc(IrPrint *irp, ResultLoc *result_loc) {...@@ -606,8 +608,17 @@ static void ir_print_result_loc(IrPrint *irp, ResultLoc *result_loc) {
606}608}
607609
608static void ir_print_call_src(IrPrint *irp, IrInstructionCallSrc *call_instruction) {610static void ir_print_call_src(IrPrint *irp, IrInstructionCallSrc *call_instruction) {
609 if (call_instruction->is_async) {611 switch (call_instruction->modifier) {
610 fprintf(irp->f, "async ");612 case CallModifierNone:
613 break;
614 case CallModifierAsync:
615 fprintf(irp->f, "async ");
616 break;
617 case CallModifierNoAsync:
618 fprintf(irp->f, "noasync ");
619 break;
620 case CallModifierBuiltin:
621 zig_unreachable();
611 }622 }
612 if (call_instruction->fn_entry) {623 if (call_instruction->fn_entry) {
613 fprintf(irp->f, "%s", buf_ptr(&call_instruction->fn_entry->symbol_name));624 fprintf(irp->f, "%s", buf_ptr(&call_instruction->fn_entry->symbol_name));
...@@ -627,8 +638,17 @@ static void ir_print_call_src(IrPrint *irp, IrInstructionCallSrc *call_instructi...@@ -627,8 +638,17 @@ static void ir_print_call_src(IrPrint *irp, IrInstructionCallSrc *call_instructi
627}638}
628639
629static void ir_print_call_gen(IrPrint *irp, IrInstructionCallGen *call_instruction) {640static void ir_print_call_gen(IrPrint *irp, IrInstructionCallGen *call_instruction) {
630 if (call_instruction->is_async) {641 switch (call_instruction->modifier) {
631 fprintf(irp->f, "async ");642 case CallModifierNone:
643 break;
644 case CallModifierAsync:
645 fprintf(irp->f, "async ");
646 break;
647 case CallModifierNoAsync:
648 fprintf(irp->f, "noasync ");
649 break;
650 case CallModifierBuiltin:
651 zig_unreachable();
632 }652 }
633 if (call_instruction->fn_entry) {653 if (call_instruction->fn_entry) {
634 fprintf(irp->f, "%s", buf_ptr(&call_instruction->fn_entry->symbol_name));654 fprintf(irp->f, "%s", buf_ptr(&call_instruction->fn_entry->symbol_name));
...@@ -727,7 +747,7 @@ static void ir_print_elem_ptr(IrPrint *irp, IrInstructionElemPtr *instruction) {...@@ -727,7 +747,7 @@ static void ir_print_elem_ptr(IrPrint *irp, IrInstructionElemPtr *instruction) {
727}747}
728748
729static void ir_print_var_ptr(IrPrint *irp, IrInstructionVarPtr *instruction) {749static void ir_print_var_ptr(IrPrint *irp, IrInstructionVarPtr *instruction) {
730 fprintf(irp->f, "&%s", buf_ptr(&instruction->var->name));750 fprintf(irp->f, "&%s", instruction->var->name);
731}751}
732752
733static void ir_print_return_ptr(IrPrint *irp, IrInstructionReturnPtr *instruction) {753static void ir_print_return_ptr(IrPrint *irp, IrInstructionReturnPtr *instruction) {
...@@ -1627,6 +1647,12 @@ static void ir_print_type_info(IrPrint *irp, IrInstructionTypeInfo *instruction)...@@ -1627,6 +1647,12 @@ static void ir_print_type_info(IrPrint *irp, IrInstructionTypeInfo *instruction)
1627 fprintf(irp->f, ")");1647 fprintf(irp->f, ")");
1628}1648}
16291649
1650static void ir_print_type(IrPrint *irp, IrInstructionType *instruction) {
1651 fprintf(irp->f, "@Type(");
1652 ir_print_other_instruction(irp, instruction->type_info);
1653 fprintf(irp->f, ")");
1654}
1655
1630static void ir_print_has_field(IrPrint *irp, IrInstructionHasField *instruction) {1656static void ir_print_has_field(IrPrint *irp, IrInstructionHasField *instruction) {
1631 fprintf(irp->f, "@hasField(");1657 fprintf(irp->f, "@hasField(");
1632 ir_print_other_instruction(irp, instruction->container_type);1658 ir_print_other_instruction(irp, instruction->container_type);
...@@ -1826,7 +1852,7 @@ static void ir_print_mul_add(IrPrint *irp, IrInstructionMulAdd *instruction) {...@@ -1826,7 +1852,7 @@ static void ir_print_mul_add(IrPrint *irp, IrInstructionMulAdd *instruction) {
1826static void ir_print_decl_var_gen(IrPrint *irp, IrInstructionDeclVarGen *decl_var_instruction) {1852static void ir_print_decl_var_gen(IrPrint *irp, IrInstructionDeclVarGen *decl_var_instruction) {
1827 ZigVar *var = decl_var_instruction->var;1853 ZigVar *var = decl_var_instruction->var;
1828 const char *var_or_const = decl_var_instruction->var->gen_is_const ? "const" : "var";1854 const char *var_or_const = decl_var_instruction->var->gen_is_const ? "const" : "var";
1829 const char *name = buf_ptr(&decl_var_instruction->var->name);1855 const char *name = decl_var_instruction->var->name;
1830 fprintf(irp->f, "%s %s: %s align(%u) = ", var_or_const, name, buf_ptr(&var->var_type->name),1856 fprintf(irp->f, "%s %s: %s align(%u) = ", var_or_const, name, buf_ptr(&var->var_type->name),
1831 var->align_bytes);1857 var->align_bytes);
18321858
...@@ -2258,6 +2284,9 @@ static void ir_print_instruction(IrPrint *irp, IrInstruction *instruction, bool...@@ -2258,6 +2284,9 @@ static void ir_print_instruction(IrPrint *irp, IrInstruction *instruction, bool
2258 case IrInstructionIdTypeInfo:2284 case IrInstructionIdTypeInfo:
2259 ir_print_type_info(irp, (IrInstructionTypeInfo *)instruction);2285 ir_print_type_info(irp, (IrInstructionTypeInfo *)instruction);
2260 break;2286 break;
2287 case IrInstructionIdType:
2288 ir_print_type(irp, (IrInstructionType *)instruction);
2289 break;
2261 case IrInstructionIdHasField:2290 case IrInstructionIdHasField:
2262 ir_print_has_field(irp, (IrInstructionHasField *)instruction);2291 ir_print_has_field(irp, (IrInstructionHasField *)instruction);
2263 break;2292 break;
...@@ -2388,10 +2417,10 @@ static void ir_print_instruction(IrPrint *irp, IrInstruction *instruction, bool...@@ -2388,10 +2417,10 @@ static void ir_print_instruction(IrPrint *irp, IrInstruction *instruction, bool
2388 fprintf(irp->f, "\n");2417 fprintf(irp->f, "\n");
2389}2418}
23902419
2391void ir_print(CodeGen *codegen, FILE *f, IrExecutable *executable, int indent_size, size_t pass_num) {2420void ir_print(CodeGen *codegen, FILE *f, IrExecutable *executable, int indent_size, IrPass pass) {
2392 IrPrint ir_print = {};2421 IrPrint ir_print = {};
2393 IrPrint *irp = &ir_print;2422 IrPrint *irp = &ir_print;
2394 irp->pass_num = pass_num;2423 irp->pass = pass;
2395 irp->codegen = codegen;2424 irp->codegen = codegen;
2396 irp->f = f;2425 irp->f = f;
2397 irp->indent = indent_size;2426 irp->indent = indent_size;
...@@ -2405,7 +2434,7 @@ void ir_print(CodeGen *codegen, FILE *f, IrExecutable *executable, int indent_si...@@ -2405,7 +2434,7 @@ void ir_print(CodeGen *codegen, FILE *f, IrExecutable *executable, int indent_si
2405 fprintf(irp->f, "%s_%" ZIG_PRI_usize ":\n", current_block->name_hint, current_block->debug_id);2434 fprintf(irp->f, "%s_%" ZIG_PRI_usize ":\n", current_block->name_hint, current_block->debug_id);
2406 for (size_t instr_i = 0; instr_i < current_block->instruction_list.length; instr_i += 1) {2435 for (size_t instr_i = 0; instr_i < current_block->instruction_list.length; instr_i += 1) {
2407 IrInstruction *instruction = current_block->instruction_list.at(instr_i);2436 IrInstruction *instruction = current_block->instruction_list.at(instr_i);
2408 if (irp->pass_num == 2) {2437 if (irp->pass != IrPassSrc) {
2409 irp->printed.put(instruction, 0);2438 irp->printed.put(instruction, 0);
2410 irp->pending.clear();2439 irp->pending.clear();
2411 }2440 }
...@@ -2419,10 +2448,10 @@ void ir_print(CodeGen *codegen, FILE *f, IrExecutable *executable, int indent_si...@@ -2419,10 +2448,10 @@ void ir_print(CodeGen *codegen, FILE *f, IrExecutable *executable, int indent_si
2419 irp->printed.deinit();2448 irp->printed.deinit();
2420}2449}
24212450
2422void ir_print_instruction(CodeGen *codegen, FILE *f, IrInstruction *instruction, int indent_size, size_t pass_num) {2451void ir_print_instruction(CodeGen *codegen, FILE *f, IrInstruction *instruction, int indent_size, IrPass pass) {
2423 IrPrint ir_print = {};2452 IrPrint ir_print = {};
2424 IrPrint *irp = &ir_print;2453 IrPrint *irp = &ir_print;
2425 irp->pass_num = pass_num;2454 irp->pass = pass;
2426 irp->codegen = codegen;2455 irp->codegen = codegen;
2427 irp->f = f;2456 irp->f = f;
2428 irp->indent = indent_size;2457 irp->indent = indent_size;
src/ir_print.hpp+2-2
...@@ -12,7 +12,7 @@...@@ -12,7 +12,7 @@
1212
13#include <stdio.h>13#include <stdio.h>
1414
15void ir_print(CodeGen *codegen, FILE *f, IrExecutable *executable, int indent_size, size_t pass_num);15void ir_print(CodeGen *codegen, FILE *f, IrExecutable *executable, int indent_size, IrPass pass);
16void ir_print_instruction(CodeGen *codegen, FILE *f, IrInstruction *instruction, int indent_size, size_t pass_num);16void ir_print_instruction(CodeGen *codegen, FILE *f, IrInstruction *instruction, int indent_size, IrPass pass);
1717
18#endif18#endif
src/main.cpp+20-1
...@@ -16,6 +16,7 @@...@@ -16,6 +16,7 @@
16#include "libc_installation.hpp"16#include "libc_installation.hpp"
17#include "userland.h"17#include "userland.h"
18#include "glibc.hpp"18#include "glibc.hpp"
19#include "stack_report.hpp"
1920
20#include <stdio.h>21#include <stdio.h>
2122
...@@ -62,6 +63,7 @@ static int print_full_usage(const char *arg0, FILE *file, int return_code) {...@@ -62,6 +63,7 @@ static int print_full_usage(const char *arg0, FILE *file, int return_code) {
62 " -fPIC enable Position Independent Code\n"63 " -fPIC enable Position Independent Code\n"
63 " -fno-PIC disable Position Independent Code\n"64 " -fno-PIC disable Position Independent Code\n"
64 " -ftime-report print timing diagnostics\n"65 " -ftime-report print timing diagnostics\n"
66 " -fstack-report print stack size diagnostics\n"
65 " --libc [file] Provide a file which specifies libc paths\n"67 " --libc [file] Provide a file which specifies libc paths\n"
66 " --name [name] override output name\n"68 " --name [name] override output name\n"
67 " --output-dir [dir] override output directory (defaults to cwd)\n"69 " --output-dir [dir] override output directory (defaults to cwd)\n"
...@@ -101,6 +103,7 @@ static int print_full_usage(const char *arg0, FILE *file, int return_code) {...@@ -101,6 +103,7 @@ static int print_full_usage(const char *arg0, FILE *file, int return_code) {
101 " --version-script [path] provide a version .map file\n"103 " --version-script [path] provide a version .map file\n"
102 " --object [obj] add object file to build\n"104 " --object [obj] add object file to build\n"
103 " -L[dir] alias for --library-path\n"105 " -L[dir] alias for --library-path\n"
106 " -l[lib] alias for --library\n"
104 " -rdynamic add all symbols to the dynamic symbol table\n"107 " -rdynamic add all symbols to the dynamic symbol table\n"
105 " -rpath [path] add directory to the runtime library search path\n"108 " -rpath [path] add directory to the runtime library search path\n"
106 " --subsystem [subsystem] (windows) /SUBSYSTEM:<subsystem> to the linker\n"109 " --subsystem [subsystem] (windows) /SUBSYSTEM:<subsystem> to the linker\n"
...@@ -475,6 +478,7 @@ int main(int argc, char **argv) {...@@ -475,6 +478,7 @@ int main(int argc, char **argv) {
475 size_t ver_minor = 0;478 size_t ver_minor = 0;
476 size_t ver_patch = 0;479 size_t ver_patch = 0;
477 bool timing_info = false;480 bool timing_info = false;
481 bool stack_report = false;
478 const char *cache_dir = nullptr;482 const char *cache_dir = nullptr;
479 CliPkg *cur_pkg = allocate<CliPkg>(1);483 CliPkg *cur_pkg = allocate<CliPkg>(1);
480 BuildMode build_mode = BuildModeDebug;484 BuildMode build_mode = BuildModeDebug;
...@@ -663,6 +667,8 @@ int main(int argc, char **argv) {...@@ -663,6 +667,8 @@ int main(int argc, char **argv) {
663 each_lib_rpath = true;667 each_lib_rpath = true;
664 } else if (strcmp(arg, "-ftime-report") == 0) {668 } else if (strcmp(arg, "-ftime-report") == 0) {
665 timing_info = true;669 timing_info = true;
670 } else if (strcmp(arg, "-fstack-report") == 0) {
671 stack_report = true;
666 } else if (strcmp(arg, "--enable-valgrind") == 0) {672 } else if (strcmp(arg, "--enable-valgrind") == 0) {
667 valgrind_support = ValgrindSupportEnabled;673 valgrind_support = ValgrindSupportEnabled;
668 } else if (strcmp(arg, "--disable-valgrind") == 0) {674 } else if (strcmp(arg, "--disable-valgrind") == 0) {
...@@ -688,6 +694,12 @@ int main(int argc, char **argv) {...@@ -688,6 +694,12 @@ int main(int argc, char **argv) {
688 } else if (arg[1] == 'L' && arg[2] != 0) {694 } else if (arg[1] == 'L' && arg[2] != 0) {
689 // alias for --library-path695 // alias for --library-path
690 lib_dirs.append(&arg[2]);696 lib_dirs.append(&arg[2]);
697 } else if (arg[1] == 'l' && arg[2] != 0) {
698 // alias for --library
699 const char *l = &arg[2];
700 if (strcmp(l, "c") == 0)
701 have_libc = true;
702 link_libs.append(l);
691 } else if (arg[1] == 'F' && arg[2] != 0) {703 } else if (arg[1] == 'F' && arg[2] != 0) {
692 framework_dirs.append(&arg[2]);704 framework_dirs.append(&arg[2]);
693 } else if (strcmp(arg, "--pkg-begin") == 0) {705 } else if (strcmp(arg, "--pkg-begin") == 0) {
...@@ -778,7 +790,7 @@ int main(int argc, char **argv) {...@@ -778,7 +790,7 @@ int main(int argc, char **argv) {
778 lib_dirs.append(argv[i]);790 lib_dirs.append(argv[i]);
779 } else if (strcmp(arg, "-F") == 0) {791 } else if (strcmp(arg, "-F") == 0) {
780 framework_dirs.append(argv[i]);792 framework_dirs.append(argv[i]);
781 } else if (strcmp(arg, "--library") == 0) {793 } else if (strcmp(arg, "--library") == 0 || strcmp(arg, "-l") == 0) {
782 if (strcmp(argv[i], "c") == 0)794 if (strcmp(argv[i], "c") == 0)
783 have_libc = true;795 have_libc = true;
784 link_libs.append(argv[i]);796 link_libs.append(argv[i]);
...@@ -1129,6 +1141,7 @@ int main(int argc, char **argv) {...@@ -1129,6 +1141,7 @@ int main(int argc, char **argv) {
1129 g->subsystem = subsystem;1141 g->subsystem = subsystem;
11301142
1131 g->enable_time_report = timing_info;1143 g->enable_time_report = timing_info;
1144 g->enable_stack_report = stack_report;
1132 codegen_set_out_name(g, buf_out_name);1145 codegen_set_out_name(g, buf_out_name);
1133 codegen_set_lib_version(g, ver_major, ver_minor, ver_patch);1146 codegen_set_lib_version(g, ver_major, ver_minor, ver_patch);
1134 g->want_single_threaded = want_single_threaded;1147 g->want_single_threaded = want_single_threaded;
...@@ -1216,6 +1229,8 @@ int main(int argc, char **argv) {...@@ -1216,6 +1229,8 @@ int main(int argc, char **argv) {
1216 codegen_build_and_link(g);1229 codegen_build_and_link(g);
1217 if (timing_info)1230 if (timing_info)
1218 codegen_print_timing_report(g, stdout);1231 codegen_print_timing_report(g, stdout);
1232 if (stack_report)
1233 zig_print_stack_report(g, stdout);
12191234
1220 if (cmd == CmdRun) {1235 if (cmd == CmdRun) {
1221 const char *exec_path = buf_ptr(&g->output_file_path);1236 const char *exec_path = buf_ptr(&g->output_file_path);
...@@ -1265,6 +1280,10 @@ int main(int argc, char **argv) {...@@ -1265,6 +1280,10 @@ int main(int argc, char **argv) {
1265 codegen_print_timing_report(g, stdout);1280 codegen_print_timing_report(g, stdout);
1266 }1281 }
12671282
1283 if (stack_report) {
1284 zig_print_stack_report(g, stdout);
1285 }
1286
1268 Buf *test_exe_path_unresolved = &g->output_file_path;1287 Buf *test_exe_path_unresolved = &g->output_file_path;
1269 Buf *test_exe_path = buf_alloc();1288 Buf *test_exe_path = buf_alloc();
1270 *test_exe_path = os_path_resolve(&test_exe_path_unresolved, 1);1289 *test_exe_path = os_path_resolve(&test_exe_path_unresolved, 1);
src/os.cpp+24
...@@ -45,6 +45,7 @@ typedef SSIZE_T ssize_t;...@@ -45,6 +45,7 @@ typedef SSIZE_T ssize_t;
45#include <sys/types.h>45#include <sys/types.h>
46#include <sys/stat.h>46#include <sys/stat.h>
47#include <sys/wait.h>47#include <sys/wait.h>
48#include <sys/resource.h>
48#include <fcntl.h>49#include <fcntl.h>
49#include <limits.h>50#include <limits.h>
50#include <spawn.h>51#include <spawn.h>
...@@ -1374,6 +1375,29 @@ int os_init(void) {...@@ -1374,6 +1375,29 @@ int os_init(void) {
1374#elif defined(__MACH__)1375#elif defined(__MACH__)
1375 host_get_clock_service(mach_host_self(), SYSTEM_CLOCK, &macos_monotonic_clock);1376 host_get_clock_service(mach_host_self(), SYSTEM_CLOCK, &macos_monotonic_clock);
1376 host_get_clock_service(mach_host_self(), CALENDAR_CLOCK, &macos_calendar_clock);1377 host_get_clock_service(mach_host_self(), CALENDAR_CLOCK, &macos_calendar_clock);
1378#endif
1379#if defined(ZIG_OS_POSIX)
1380 // Raise the open file descriptor limit.
1381 // Code lifted from node.js
1382 struct rlimit lim;
1383 if (getrlimit(RLIMIT_NOFILE, &lim) == 0 && lim.rlim_cur != lim.rlim_max) {
1384 // Do a binary search for the limit.
1385 rlim_t min = lim.rlim_cur;
1386 rlim_t max = 1 << 20;
1387 // But if there's a defined upper bound, don't search, just set it.
1388 if (lim.rlim_max != RLIM_INFINITY) {
1389 min = lim.rlim_max;
1390 max = lim.rlim_max;
1391 }
1392 do {
1393 lim.rlim_cur = min + (max - min) / 2;
1394 if (setrlimit(RLIMIT_NOFILE, &lim)) {
1395 max = lim.rlim_cur;
1396 } else {
1397 min = lim.rlim_cur;
1398 }
1399 } while (min + 1 < max);
1400 }
1377#endif1401#endif
1378 return 0;1402 return 0;
1379}1403}
src/parser.cpp+31-16
...@@ -113,7 +113,7 @@ static AstNode *ast_parse_multiply_op(ParseContext *pc);...@@ -113,7 +113,7 @@ static AstNode *ast_parse_multiply_op(ParseContext *pc);
113static AstNode *ast_parse_prefix_op(ParseContext *pc);113static AstNode *ast_parse_prefix_op(ParseContext *pc);
114static AstNode *ast_parse_prefix_type_op(ParseContext *pc);114static AstNode *ast_parse_prefix_type_op(ParseContext *pc);
115static AstNode *ast_parse_suffix_op(ParseContext *pc);115static AstNode *ast_parse_suffix_op(ParseContext *pc);
116static AstNode *ast_parse_fn_call_argumnets(ParseContext *pc);116static AstNode *ast_parse_fn_call_arguments(ParseContext *pc);
117static AstNode *ast_parse_array_type_start(ParseContext *pc);117static AstNode *ast_parse_array_type_start(ParseContext *pc);
118static AstNode *ast_parse_ptr_type_start(ParseContext *pc);118static AstNode *ast_parse_ptr_type_start(ParseContext *pc);
119static AstNode *ast_parse_container_decl_auto(ParseContext *pc);119static AstNode *ast_parse_container_decl_auto(ParseContext *pc);
...@@ -578,7 +578,7 @@ static AstNode *ast_parse_top_level_comptime(ParseContext *pc) {...@@ -578,7 +578,7 @@ static AstNode *ast_parse_top_level_comptime(ParseContext *pc) {
578}578}
579579
580// TopLevelDecl580// TopLevelDecl
581// <- (KEYWORD_export / KEYWORD_extern STRINGLITERAL? / KEYWORD_inline)? FnProto (SEMICOLON / Block)581// <- (KEYWORD_export / KEYWORD_extern STRINGLITERAL? / (KEYWORD_inline / KEYWORD_noinline))? FnProto (SEMICOLON / Block)
582// / (KEYWORD_export / KEYWORD_extern STRINGLITERAL?)? KEYWORD_threadlocal? VarDecl582// / (KEYWORD_export / KEYWORD_extern STRINGLITERAL?)? KEYWORD_threadlocal? VarDecl
583// / KEYWORD_use Expr SEMICOLON583// / KEYWORD_use Expr SEMICOLON
584static AstNode *ast_parse_top_level_decl(ParseContext *pc, VisibMod visib_mod) {584static AstNode *ast_parse_top_level_decl(ParseContext *pc, VisibMod visib_mod) {
...@@ -587,12 +587,14 @@ static AstNode *ast_parse_top_level_decl(ParseContext *pc, VisibMod visib_mod) {...@@ -587,12 +587,14 @@ static AstNode *ast_parse_top_level_decl(ParseContext *pc, VisibMod visib_mod) {
587 first = eat_token_if(pc, TokenIdKeywordExtern);587 first = eat_token_if(pc, TokenIdKeywordExtern);
588 if (first == nullptr)588 if (first == nullptr)
589 first = eat_token_if(pc, TokenIdKeywordInline);589 first = eat_token_if(pc, TokenIdKeywordInline);
590 if (first == nullptr)
591 first = eat_token_if(pc, TokenIdKeywordNoInline);
590 if (first != nullptr) {592 if (first != nullptr) {
591 Token *lib_name = nullptr;593 Token *lib_name = nullptr;
592 if (first->id == TokenIdKeywordExtern)594 if (first->id == TokenIdKeywordExtern)
593 lib_name = eat_token_if(pc, TokenIdStringLiteral);595 lib_name = eat_token_if(pc, TokenIdStringLiteral);
594596
595 if (first->id != TokenIdKeywordInline) {597 if (first->id != TokenIdKeywordInline && first->id != TokenIdKeywordNoInline) {
596 Token *thread_local_kw = eat_token_if(pc, TokenIdKeywordThreadLocal);598 Token *thread_local_kw = eat_token_if(pc, TokenIdKeywordThreadLocal);
597 AstNode *var_decl = ast_parse_var_decl(pc);599 AstNode *var_decl = ast_parse_var_decl(pc);
598 if (var_decl != nullptr) {600 if (var_decl != nullptr) {
...@@ -623,8 +625,19 @@ static AstNode *ast_parse_top_level_decl(ParseContext *pc, VisibMod visib_mod) {...@@ -623,8 +625,19 @@ static AstNode *ast_parse_top_level_decl(ParseContext *pc, VisibMod visib_mod) {
623 fn_proto->data.fn_proto.visib_mod = visib_mod;625 fn_proto->data.fn_proto.visib_mod = visib_mod;
624 fn_proto->data.fn_proto.is_extern = first->id == TokenIdKeywordExtern;626 fn_proto->data.fn_proto.is_extern = first->id == TokenIdKeywordExtern;
625 fn_proto->data.fn_proto.is_export = first->id == TokenIdKeywordExport;627 fn_proto->data.fn_proto.is_export = first->id == TokenIdKeywordExport;
626 fn_proto->data.fn_proto.is_inline = first->id == TokenIdKeywordInline;628 switch (first->id) {
629 case TokenIdKeywordInline:
630 fn_proto->data.fn_proto.fn_inline = FnInlineAlways;
631 break;
632 case TokenIdKeywordNoInline:
633 fn_proto->data.fn_proto.fn_inline = FnInlineNever;
634 break;
635 default:
636 fn_proto->data.fn_proto.fn_inline = FnInlineAuto;
637 break;
638 }
627 fn_proto->data.fn_proto.lib_name = token_buf(lib_name);639 fn_proto->data.fn_proto.lib_name = token_buf(lib_name);
640
628 AstNode *res = fn_proto;641 AstNode *res = fn_proto;
629 if (body != nullptr) {642 if (body != nullptr) {
630 res = ast_create_node_copy_line_info(pc, NodeTypeFnDef, fn_proto);643 res = ast_create_node_copy_line_info(pc, NodeTypeFnDef, fn_proto);
...@@ -1390,12 +1403,14 @@ static AstNode *ast_parse_error_union_expr(ParseContext *pc) {...@@ -1390,12 +1403,14 @@ static AstNode *ast_parse_error_union_expr(ParseContext *pc) {
1390}1403}
13911404
1392// SuffixExpr1405// SuffixExpr
1393// <- KEYWORD_async PrimaryTypeExpr SuffixOp* FnCallArguments1406// <- KEYWORD_async PrimaryTypeExpr SuffixOp* FnCallArguments
1407// / KEYWORD_noasync PrimaryTypeExpr SuffixOp* FnCallArguments
1394// / PrimaryTypeExpr (SuffixOp / FnCallArguments)*1408// / PrimaryTypeExpr (SuffixOp / FnCallArguments)*
1395static AstNode *ast_parse_suffix_expr(ParseContext *pc) {1409static AstNode *ast_parse_suffix_expr(ParseContext *pc) {
1396 Token *async_token = eat_token_if(pc, TokenIdKeywordAsync);1410 Token *async_token = eat_token(pc);
1397 if (async_token != nullptr) {1411 bool is_async = async_token->id == TokenIdKeywordAsync;
1398 if (eat_token_if(pc, TokenIdKeywordFn) != nullptr) {1412 if (is_async || async_token->id == TokenIdKeywordNoAsync) {
1413 if (is_async && eat_token_if(pc, TokenIdKeywordFn) != nullptr) {
1399 // HACK: If we see the keyword `fn`, then we assume that1414 // HACK: If we see the keyword `fn`, then we assume that
1400 // we are parsing an async fn proto, and not a call.1415 // we are parsing an async fn proto, and not a call.
1401 // We therefore put back all tokens consumed by the async1416 // We therefore put back all tokens consumed by the async
...@@ -1434,24 +1449,24 @@ static AstNode *ast_parse_suffix_expr(ParseContext *pc) {...@@ -1434,24 +1449,24 @@ static AstNode *ast_parse_suffix_expr(ParseContext *pc) {
1434 child = suffix;1449 child = suffix;
1435 }1450 }
14361451
1437 // TODO: Both *_async_prefix and *_fn_call_argumnets returns an1452 // TODO: Both *_async_prefix and *_fn_call_arguments returns an
1438 // AstNode *. All we really want here is the arguments of1453 // AstNode *. All we really want here is the arguments of
1439 // the call we parse. We therefor "leak" the node for now.1454 // the call we parse. We therefor "leak" the node for now.
1440 // Wait till we get async rework to fix this.1455 // Wait till we get async rework to fix this.
1441 AstNode *args = ast_parse_fn_call_argumnets(pc);1456 AstNode *args = ast_parse_fn_call_arguments(pc);
1442 if (args == nullptr)1457 if (args == nullptr)
1443 ast_invalid_token_error(pc, peek_token(pc));1458 ast_invalid_token_error(pc, peek_token(pc));
14441459
1445 assert(args->type == NodeTypeFnCallExpr);1460 assert(args->type == NodeTypeFnCallExpr);
14461461
1447 AstNode *res = ast_create_node(pc, NodeTypeFnCallExpr, async_token);1462 AstNode *res = ast_create_node(pc, NodeTypeFnCallExpr, async_token);
1448 res->data.fn_call_expr.is_async = true;1463 res->data.fn_call_expr.modifier = is_async ? CallModifierAsync : CallModifierNoAsync;
1449 res->data.fn_call_expr.seen = false;1464 res->data.fn_call_expr.seen = false;
1450 res->data.fn_call_expr.fn_ref_expr = child;1465 res->data.fn_call_expr.fn_ref_expr = child;
1451 res->data.fn_call_expr.params = args->data.fn_call_expr.params;1466 res->data.fn_call_expr.params = args->data.fn_call_expr.params;
1452 res->data.fn_call_expr.is_builtin = false;
1453 return res;1467 return res;
1454 }1468 }
1469 put_back_token(pc);
14551470
1456 AstNode *res = ast_parse_primary_type_expr(pc);1471 AstNode *res = ast_parse_primary_type_expr(pc);
1457 if (res == nullptr)1472 if (res == nullptr)
...@@ -1483,7 +1498,7 @@ static AstNode *ast_parse_suffix_expr(ParseContext *pc) {...@@ -1483,7 +1498,7 @@ static AstNode *ast_parse_suffix_expr(ParseContext *pc) {
1483 continue;1498 continue;
1484 }1499 }
14851500
1486 AstNode * call = ast_parse_fn_call_argumnets(pc);1501 AstNode * call = ast_parse_fn_call_arguments(pc);
1487 if (call != nullptr) {1502 if (call != nullptr) {
1488 assert(call->type == NodeTypeFnCallExpr);1503 assert(call->type == NodeTypeFnCallExpr);
1489 call->data.fn_call_expr.fn_ref_expr = res;1504 call->data.fn_call_expr.fn_ref_expr = res;
...@@ -1539,7 +1554,7 @@ static AstNode *ast_parse_primary_type_expr(ParseContext *pc) {...@@ -1539,7 +1554,7 @@ static AstNode *ast_parse_primary_type_expr(ParseContext *pc) {
1539 name = buf_create_from_str("export");1554 name = buf_create_from_str("export");
1540 }1555 }
15411556
1542 AstNode *res = ast_expect(pc, ast_parse_fn_call_argumnets);1557 AstNode *res = ast_expect(pc, ast_parse_fn_call_arguments);
1543 AstNode *name_sym = ast_create_node(pc, NodeTypeSymbol, token);1558 AstNode *name_sym = ast_create_node(pc, NodeTypeSymbol, token);
1544 name_sym->data.symbol_expr.symbol = name;1559 name_sym->data.symbol_expr.symbol = name;
15451560
...@@ -1547,7 +1562,7 @@ static AstNode *ast_parse_primary_type_expr(ParseContext *pc) {...@@ -1547,7 +1562,7 @@ static AstNode *ast_parse_primary_type_expr(ParseContext *pc) {
1547 res->line = at_sign->start_line;1562 res->line = at_sign->start_line;
1548 res->column = at_sign->start_column;1563 res->column = at_sign->start_column;
1549 res->data.fn_call_expr.fn_ref_expr = name_sym;1564 res->data.fn_call_expr.fn_ref_expr = name_sym;
1550 res->data.fn_call_expr.is_builtin = true;1565 res->data.fn_call_expr.modifier = CallModifierBuiltin;
1551 return res;1566 return res;
1552 }1567 }
15531568
...@@ -2659,7 +2674,7 @@ static AstNode *ast_parse_suffix_op(ParseContext *pc) {...@@ -2659,7 +2674,7 @@ static AstNode *ast_parse_suffix_op(ParseContext *pc) {
2659}2674}
26602675
2661// FnCallArguments <- LPAREN ExprList RPAREN2676// FnCallArguments <- LPAREN ExprList RPAREN
2662static AstNode *ast_parse_fn_call_argumnets(ParseContext *pc) {2677static AstNode *ast_parse_fn_call_arguments(ParseContext *pc) {
2663 Token *paren = eat_token_if(pc, TokenIdLParen);2678 Token *paren = eat_token_if(pc, TokenIdLParen);
2664 if (paren == nullptr)2679 if (paren == nullptr)
2665 return nullptr;2680 return nullptr;
src/stack_report.cpp created+121
...@@ -0,0 +1,121 @@
1/*
2 * Copyright (c) 2019 Andrew Kelley
3 *
4 * This file is part of zig, which is MIT licensed.
5 * See http://opensource.org/licenses/MIT
6 */
7
8#include "stack_report.hpp"
9
10static void tree_print(FILE *f, ZigType *ty, size_t indent);
11
12static void pretty_print_bytes(FILE *f, double n) {
13 if (n > 1024.0 * 1024.0 * 1024.0) {
14 fprintf(f, "%.02f GiB", n / 1024.0 / 1024.0 / 1024.0);
15 return;
16 }
17 if (n > 1024.0 * 1024.0) {
18 fprintf(f, "%.02f MiB", n / 1024.0 / 1024.0);
19 return;
20 }
21 if (n > 1024.0) {
22 fprintf(f, "%.02f KiB", n / 1024.0);
23 return;
24 }
25 fprintf(f, "%.02f bytes", n );
26 return;
27}
28
29static int compare_type_abi_sizes_desc(const void *a, const void *b) {
30 uint64_t size_a = (*(ZigType * const*)(a))->abi_size;
31 uint64_t size_b = (*(ZigType * const*)(b))->abi_size;
32 if (size_a > size_b)
33 return -1;
34 if (size_a < size_b)
35 return 1;
36 return 0;
37}
38
39static void start_child(FILE *f, size_t indent) {
40 fprintf(f, "\n");
41 for (size_t i = 0; i < indent; i += 1) {
42 fprintf(f, " ");
43 }
44}
45
46static void start_peer(FILE *f, size_t indent) {
47 fprintf(f, ",\n");
48 for (size_t i = 0; i < indent; i += 1) {
49 fprintf(f, " ");
50 }
51}
52
53static void tree_print_struct(FILE *f, ZigType *struct_type, size_t indent) {
54 ZigList<ZigType *> children = {};
55 uint64_t sum_from_fields = 0;
56 for (size_t i = 0; i < struct_type->data.structure.src_field_count; i += 1) {
57 TypeStructField *field = &struct_type->data.structure.fields[i];
58 children.append(field->type_entry);
59 sum_from_fields += field->type_entry->abi_size;
60 }
61 qsort(children.items, children.length, sizeof(ZigType *), compare_type_abi_sizes_desc);
62
63 start_peer(f, indent);
64 fprintf(f, "\"padding\": \"%" ZIG_PRI_u64 "\"", struct_type->abi_size - sum_from_fields);
65
66 start_peer(f, indent);
67 fprintf(f, "\"fields\": [");
68
69 for (size_t i = 0; i < children.length; i += 1) {
70 if (i == 0) {
71 start_child(f, indent + 1);
72 } else {
73 start_peer(f, indent + 1);
74 }
75 fprintf(f, "{");
76
77 ZigType *child_type = children.at(i);
78 tree_print(f, child_type, indent + 2);
79
80 start_child(f, indent + 1);
81 fprintf(f, "}");
82 }
83
84 start_child(f, indent);
85 fprintf(f, "]");
86}
87
88static void tree_print(FILE *f, ZigType *ty, size_t indent) {
89 start_child(f, indent);
90 fprintf(f, "\"type\": \"%s\"", buf_ptr(&ty->name));
91
92 start_peer(f, indent);
93 fprintf(f, "\"sizef\": \"");
94 pretty_print_bytes(f, ty->abi_size);
95 fprintf(f, "\"");
96
97 start_peer(f, indent);
98 fprintf(f, "\"size\": \"%" ZIG_PRI_u64 "\"", ty->abi_size);
99
100 switch (ty->id) {
101 case ZigTypeIdFnFrame:
102 return tree_print_struct(f, ty->data.frame.locals_struct, indent);
103 case ZigTypeIdStruct:
104 return tree_print_struct(f, ty, indent);
105 default:
106 start_child(f, indent);
107 return;
108 }
109}
110
111void zig_print_stack_report(CodeGen *g, FILE *f) {
112 if (g->largest_frame_fn == nullptr) {
113 fprintf(f, "{\"error\": \"No async function frames in entire compilation.\"}\n");
114 return;
115 }
116 fprintf(f, "{");
117 tree_print(f, g->largest_frame_fn->frame_type, 1);
118
119 start_child(f, 0);
120 fprintf(f, "}\n");
121}
src/stack_report.hpp created+16
...@@ -0,0 +1,16 @@
1/*
2 * Copyright (c) 2019 Andrew Kelley
3 *
4 * This file is part of zig, which is MIT licensed.
5 * See http://opensource.org/licenses/MIT
6 */
7
8#ifndef ZIG_STACK_REPORT_HPP
9#define ZIG_STACK_REPORT_HPP
10
11#include "all_types.hpp"
12#include <stdio.h>
13
14void zig_print_stack_report(CodeGen *g, FILE *f);
15
16#endif
src/target.cpp+4-4
...@@ -1441,6 +1441,10 @@ const char *arch_stack_pointer_register_name(ZigLLVM_ArchType arch) {...@@ -1441,6 +1441,10 @@ const char *arch_stack_pointer_register_name(ZigLLVM_ArchType arch) {
1441 return "esp";1441 return "esp";
1442 case ZigLLVM_x86_64:1442 case ZigLLVM_x86_64:
1443 return "rsp";1443 return "rsp";
1444 case ZigLLVM_arm:
1445 case ZigLLVM_armeb:
1446 case ZigLLVM_thumb:
1447 case ZigLLVM_thumbeb:
1444 case ZigLLVM_aarch64:1448 case ZigLLVM_aarch64:
1445 case ZigLLVM_aarch64_be:1449 case ZigLLVM_aarch64_be:
1446 case ZigLLVM_aarch64_32:1450 case ZigLLVM_aarch64_32:
...@@ -1448,12 +1452,9 @@ const char *arch_stack_pointer_register_name(ZigLLVM_ArchType arch) {...@@ -1448,12 +1452,9 @@ const char *arch_stack_pointer_register_name(ZigLLVM_ArchType arch) {
1448 case ZigLLVM_riscv64:1452 case ZigLLVM_riscv64:
1449 return "sp";1453 return "sp";
14501454
1451 case ZigLLVM_arm:
1452 case ZigLLVM_thumb:
1453 case ZigLLVM_amdgcn:1455 case ZigLLVM_amdgcn:
1454 case ZigLLVM_amdil:1456 case ZigLLVM_amdil:
1455 case ZigLLVM_amdil64:1457 case ZigLLVM_amdil64:
1456 case ZigLLVM_armeb:
1457 case ZigLLVM_arc:1458 case ZigLLVM_arc:
1458 case ZigLLVM_avr:1459 case ZigLLVM_avr:
1459 case ZigLLVM_bpfeb:1460 case ZigLLVM_bpfeb:
...@@ -1485,7 +1486,6 @@ const char *arch_stack_pointer_register_name(ZigLLVM_ArchType arch) {...@@ -1485,7 +1486,6 @@ const char *arch_stack_pointer_register_name(ZigLLVM_ArchType arch) {
1485 case ZigLLVM_systemz:1486 case ZigLLVM_systemz:
1486 case ZigLLVM_tce:1487 case ZigLLVM_tce:
1487 case ZigLLVM_tcele:1488 case ZigLLVM_tcele:
1488 case ZigLLVM_thumbeb:
1489 case ZigLLVM_wasm32:1489 case ZigLLVM_wasm32:
1490 case ZigLLVM_wasm64:1490 case ZigLLVM_wasm64:
1491 case ZigLLVM_xcore:1491 case ZigLLVM_xcore:
src/tokenizer.cpp+4
...@@ -132,6 +132,8 @@ static const struct ZigKeyword zig_keywords[] = {...@@ -132,6 +132,8 @@ static const struct ZigKeyword zig_keywords[] = {
132 {"inline", TokenIdKeywordInline},132 {"inline", TokenIdKeywordInline},
133 {"nakedcc", TokenIdKeywordNakedCC},133 {"nakedcc", TokenIdKeywordNakedCC},
134 {"noalias", TokenIdKeywordNoAlias},134 {"noalias", TokenIdKeywordNoAlias},
135 {"noasync", TokenIdKeywordNoAsync},
136 {"noinline", TokenIdKeywordNoInline},
135 {"null", TokenIdKeywordNull},137 {"null", TokenIdKeywordNull},
136 {"or", TokenIdKeywordOr},138 {"or", TokenIdKeywordOr},
137 {"orelse", TokenIdKeywordOrElse},139 {"orelse", TokenIdKeywordOrElse},
...@@ -1553,6 +1555,8 @@ const char * token_name(TokenId id) {...@@ -1553,6 +1555,8 @@ const char * token_name(TokenId id) {
1553 case TokenIdKeywordInline: return "inline";1555 case TokenIdKeywordInline: return "inline";
1554 case TokenIdKeywordNakedCC: return "nakedcc";1556 case TokenIdKeywordNakedCC: return "nakedcc";
1555 case TokenIdKeywordNoAlias: return "noalias";1557 case TokenIdKeywordNoAlias: return "noalias";
1558 case TokenIdKeywordNoAsync: return "noasync";
1559 case TokenIdKeywordNoInline: return "noinline";
1556 case TokenIdKeywordNull: return "null";1560 case TokenIdKeywordNull: return "null";
1557 case TokenIdKeywordOr: return "or";1561 case TokenIdKeywordOr: return "or";
1558 case TokenIdKeywordOrElse: return "orelse";1562 case TokenIdKeywordOrElse: return "orelse";
src/tokenizer.hpp+2
...@@ -74,9 +74,11 @@ enum TokenId {...@@ -74,9 +74,11 @@ enum TokenId {
74 TokenIdKeywordFor,74 TokenIdKeywordFor,
75 TokenIdKeywordIf,75 TokenIdKeywordIf,
76 TokenIdKeywordInline,76 TokenIdKeywordInline,
77 TokenIdKeywordNoInline,
77 TokenIdKeywordLinkSection,78 TokenIdKeywordLinkSection,
78 TokenIdKeywordNakedCC,79 TokenIdKeywordNakedCC,
79 TokenIdKeywordNoAlias,80 TokenIdKeywordNoAlias,
81 TokenIdKeywordNoAsync,
80 TokenIdKeywordNull,82 TokenIdKeywordNull,
81 TokenIdKeywordOr,83 TokenIdKeywordOr,
82 TokenIdKeywordOrElse,84 TokenIdKeywordOrElse,
src/translate_c.cpp+2-2
...@@ -253,7 +253,7 @@ static AstNode *trans_create_node_symbol_str(Context *c, const char *name) {...@@ -253,7 +253,7 @@ static AstNode *trans_create_node_symbol_str(Context *c, const char *name) {
253static AstNode *trans_create_node_builtin_fn_call(Context *c, Buf *name) {253static AstNode *trans_create_node_builtin_fn_call(Context *c, Buf *name) {
254 AstNode *node = trans_create_node(c, NodeTypeFnCallExpr);254 AstNode *node = trans_create_node(c, NodeTypeFnCallExpr);
255 node->data.fn_call_expr.fn_ref_expr = trans_create_node_symbol(c, name);255 node->data.fn_call_expr.fn_ref_expr = trans_create_node_symbol(c, name);
256 node->data.fn_call_expr.is_builtin = true;256 node->data.fn_call_expr.modifier = CallModifierBuiltin;
257 return node;257 return node;
258}258}
259259
...@@ -432,7 +432,7 @@ static AstNode *trans_create_node_inline_fn(Context *c, Buf *fn_name, AstNode *r...@@ -432,7 +432,7 @@ static AstNode *trans_create_node_inline_fn(Context *c, Buf *fn_name, AstNode *r
432 AstNode *fn_proto = trans_create_node(c, NodeTypeFnProto);432 AstNode *fn_proto = trans_create_node(c, NodeTypeFnProto);
433 fn_proto->data.fn_proto.visib_mod = c->visib_mod;433 fn_proto->data.fn_proto.visib_mod = c->visib_mod;
434 fn_proto->data.fn_proto.name = fn_name;434 fn_proto->data.fn_proto.name = fn_name;
435 fn_proto->data.fn_proto.is_inline = true;435 fn_proto->data.fn_proto.fn_inline = FnInlineAlways;
436 fn_proto->data.fn_proto.return_type = src_proto_node->data.fn_proto.return_type; // TODO ok for these to alias?436 fn_proto->data.fn_proto.return_type = src_proto_node->data.fn_proto.return_type; // TODO ok for these to alias?
437437
438 fn_def->data.fn_def.fn_proto = fn_proto;438 fn_def->data.fn_def.fn_proto = fn_proto;
src/zig_llvm.cpp+1
...@@ -853,6 +853,7 @@ const char *ZigLLVMGetSubArchTypeName(ZigLLVM_SubArchType sub_arch) {...@@ -853,6 +853,7 @@ const char *ZigLLVMGetSubArchTypeName(ZigLLVM_SubArchType sub_arch) {
853853
854void ZigLLVMAddModuleDebugInfoFlag(LLVMModuleRef module) {854void ZigLLVMAddModuleDebugInfoFlag(LLVMModuleRef module) {
855 unwrap(module)->addModuleFlag(Module::Warning, "Debug Info Version", DEBUG_METADATA_VERSION);855 unwrap(module)->addModuleFlag(Module::Warning, "Debug Info Version", DEBUG_METADATA_VERSION);
856 unwrap(module)->addModuleFlag(Module::Warning, "Dwarf Version", 4);
856}857}
857858
858void ZigLLVMAddModuleCodeViewFlag(LLVMModuleRef module) {859void ZigLLVMAddModuleCodeViewFlag(LLVMModuleRef module) {
std/bloom_filter.zig created+253
...@@ -0,0 +1,253 @@
1const builtin = @import("builtin");
2const std = @import("std.zig");
3const math = std.math;
4const debug = std.debug;
5const assert = std.debug.assert;
6const testing = std.testing;
7
8/// There is a trade off of how quickly to fill a bloom filter;
9/// the number of items is:
10/// n_items / K * ln(2)
11/// the rate of false positives is:
12/// (1-e^(-K*N/n_items))^K
13/// where N is the number of items
14pub fn BloomFilter(
15 /// Size of bloom filter in cells, must be a power of two.
16 comptime n_items: usize,
17 /// Number of cells to set per item
18 comptime K: usize,
19 /// Cell type, should be:
20 /// - `bool` for a standard bloom filter
21 /// - an unsigned integer type for a counting bloom filter
22 comptime Cell: type,
23 /// endianess of the Cell
24 comptime endian: builtin.Endian,
25 /// Hash function to use
26 comptime hash: fn (out: []u8, Ki: usize, in: []const u8) void,
27) type {
28 assert(n_items > 0);
29 assert(math.isPowerOfTwo(n_items));
30 assert(K > 0);
31 const cellEmpty = if (Cell == bool) false else Cell(0);
32 const cellMax = if (Cell == bool) true else math.maxInt(Cell);
33 const n_bytes = (n_items * comptime std.meta.bitCount(Cell)) / 8;
34 assert(n_bytes > 0);
35 const Io = std.packed_int_array.PackedIntIo(Cell, endian);
36
37 return struct {
38 const Self = @This();
39 pub const items = n_items;
40 pub const Index = math.IntFittingRange(0, n_items - 1);
41
42 data: [n_bytes]u8 = [_]u8{0} ** n_bytes,
43
44 pub fn reset(self: *Self) void {
45 std.mem.set(u8, self.data[0..], 0);
46 }
47
48 pub fn @"union"(x: Self, y: Self) Self {
49 var r = Self{ .data = undefined };
50 inline for (x.data) |v, i| {
51 r.data[i] = v | y.data[i];
52 }
53 return r;
54 }
55
56 pub fn intersection(x: Self, y: Self) Self {
57 var r = Self{ .data = undefined };
58 inline for (x.data) |v, i| {
59 r.data[i] = v & y.data[i];
60 }
61 return r;
62 }
63
64 pub fn getCell(self: Self, cell: Index) Cell {
65 return Io.get(self.data, cell, 0);
66 }
67
68 pub fn incrementCell(self: *Self, cell: Index) void {
69 if (Cell == bool or Cell == u1) {
70 // skip the 'get' operation
71 Io.set(&self.data, cell, 0, cellMax);
72 } else {
73 const old = Io.get(self.data, cell, 0);
74 if (old != cellMax) {
75 Io.set(&self.data, cell, 0, old + 1);
76 }
77 }
78 }
79
80 pub fn clearCell(self: *Self, cell: Index) void {
81 Io.set(&self.data, cell, 0, cellEmpty);
82 }
83
84 pub fn add(self: *Self, item: []const u8) void {
85 comptime var i = 0;
86 inline while (i < K) : (i += 1) {
87 var K_th_bit: packed struct { x: Index } = undefined;
88 hash(std.mem.asBytes(&K_th_bit), i, item);
89 incrementCell(self, K_th_bit.x);
90 }
91 }
92
93 pub fn contains(self: Self, item: []const u8) bool {
94 comptime var i = 0;
95 inline while (i < K) : (i += 1) {
96 var K_th_bit: packed struct { x: Index } = undefined;
97 hash(std.mem.asBytes(&K_th_bit), i, item);
98 if (getCell(self, K_th_bit.x) == cellEmpty)
99 return false;
100 }
101 return true;
102 }
103
104 pub fn resize(self: Self, comptime newsize: usize) BloomFilter(newsize, K, Cell, endian, hash) {
105 var r: BloomFilter(newsize, K, Cell, endian, hash) = undefined;
106 if (newsize < n_items) {
107 std.mem.copy(u8, r.data[0..], self.data[0..r.data.len]);
108 var copied: usize = r.data.len;
109 while (copied < self.data.len) : (copied += r.data.len) {
110 for (self.data[copied .. copied + r.data.len]) |s, i| {
111 r.data[i] |= s;
112 }
113 }
114 } else if (newsize == n_items) {
115 r = self;
116 } else if (newsize > n_items) {
117 var copied: usize = 0;
118 while (copied < r.data.len) : (copied += self.data.len) {
119 std.mem.copy(u8, r.data[copied .. copied + self.data.len], self.data);
120 }
121 }
122 return r;
123 }
124
125 /// Returns number of non-zero cells
126 pub fn popCount(self: Self) Index {
127 var n: Index = 0;
128 if (Cell == bool or Cell == u1) {
129 for (self.data) |b, i| {
130 n += @popCount(u8, b);
131 }
132 } else {
133 var i: usize = 0;
134 while (i < n_items) : (i += 1) {
135 const cell = self.getCell(@intCast(Index, i));
136 n += if (if (Cell == bool) cell else cell > 0) Index(1) else Index(0);
137 }
138 }
139 return n;
140 }
141
142 pub fn estimateItems(self: Self) f64 {
143 const m = comptime @intToFloat(f64, n_items);
144 const k = comptime @intToFloat(f64, K);
145 const X = @intToFloat(f64, self.popCount());
146 return (comptime (-m / k)) * math.log1p(X * comptime (-1 / m));
147 }
148 };
149}
150
151fn hashFunc(out: []u8, Ki: usize, in: []const u8) void {
152 var st = std.crypto.gimli.Hash.init();
153 st.update(std.mem.asBytes(&Ki));
154 st.update(in);
155 st.final(out);
156}
157
158test "std.BloomFilter" {
159 inline for ([_]type{ bool, u1, u2, u3, u4 }) |Cell| {
160 const emptyCell = if (Cell == bool) false else Cell(0);
161 const BF = BloomFilter(128 * 8, 8, Cell, builtin.endian, hashFunc);
162 var bf = BF{};
163 var i: usize = undefined;
164 // confirm that it is initialised to the empty filter
165 i = 0;
166 while (i < BF.items) : (i += 1) {
167 testing.expectEqual(emptyCell, bf.getCell(@intCast(BF.Index, i)));
168 }
169 testing.expectEqual(BF.Index(0), bf.popCount());
170 testing.expectEqual(f64(0), bf.estimateItems());
171 // fill in a few items
172 bf.incrementCell(42);
173 bf.incrementCell(255);
174 bf.incrementCell(256);
175 bf.incrementCell(257);
176 // check that they were set
177 testing.expectEqual(true, bf.getCell(42) != emptyCell);
178 testing.expectEqual(true, bf.getCell(255) != emptyCell);
179 testing.expectEqual(true, bf.getCell(256) != emptyCell);
180 testing.expectEqual(true, bf.getCell(257) != emptyCell);
181 // clear just one of them; make sure the rest are still set
182 bf.clearCell(256);
183 testing.expectEqual(true, bf.getCell(42) != emptyCell);
184 testing.expectEqual(true, bf.getCell(255) != emptyCell);
185 testing.expectEqual(false, bf.getCell(256) != emptyCell);
186 testing.expectEqual(true, bf.getCell(257) != emptyCell);
187 // reset any of the ones we've set and confirm we're back to the empty filter
188 bf.clearCell(42);
189 bf.clearCell(255);
190 bf.clearCell(257);
191 i = 0;
192 while (i < BF.items) : (i += 1) {
193 testing.expectEqual(emptyCell, bf.getCell(@intCast(BF.Index, i)));
194 }
195 testing.expectEqual(BF.Index(0), bf.popCount());
196 testing.expectEqual(f64(0), bf.estimateItems());
197
198 // Lets add a string
199 bf.add("foo");
200 testing.expectEqual(true, bf.contains("foo"));
201 {
202 // try adding same string again. make sure popcount is the same
203 const old_popcount = bf.popCount();
204 testing.expect(old_popcount > 0);
205 bf.add("foo");
206 testing.expectEqual(true, bf.contains("foo"));
207 testing.expectEqual(old_popcount, bf.popCount());
208 }
209
210 // Get back to empty filter via .reset
211 bf.reset();
212 // Double check that .reset worked
213 i = 0;
214 while (i < BF.items) : (i += 1) {
215 testing.expectEqual(emptyCell, bf.getCell(@intCast(BF.Index, i)));
216 }
217 testing.expectEqual(BF.Index(0), bf.popCount());
218 testing.expectEqual(f64(0), bf.estimateItems());
219
220 comptime var teststrings = [_][]const u8{
221 "foo",
222 "bar",
223 "a longer string",
224 "some more",
225 "the quick brown fox",
226 "unique string",
227 };
228 inline for (teststrings) |str| {
229 bf.add(str);
230 }
231 inline for (teststrings) |str| {
232 testing.expectEqual(true, bf.contains(str));
233 }
234
235 { // estimate should be close for low packing
236 const est = bf.estimateItems();
237 testing.expect(est > @intToFloat(f64, teststrings.len) - 1);
238 testing.expect(est < @intToFloat(f64, teststrings.len) + 1);
239 }
240
241 const larger_bf = bf.resize(4096);
242 inline for (teststrings) |str| {
243 testing.expectEqual(true, larger_bf.contains(str));
244 }
245 testing.expectEqual(u12(bf.popCount()) * (4096 / 1024), larger_bf.popCount());
246
247 const smaller_bf = bf.resize(64);
248 inline for (teststrings) |str| {
249 testing.expectEqual(true, smaller_bf.contains(str));
250 }
251 testing.expect(bf.popCount() <= u10(smaller_bf.popCount()) * (1024 / 64));
252 }
253}
std/buf_map.zig+2-2
...@@ -1,5 +1,5 @@...@@ -1,5 +1,5 @@
1const std = @import("std.zig");1const std = @import("std.zig");
2const HashMap = std.HashMap;2const StringHashMap = std.StringHashMap;
3const mem = std.mem;3const mem = std.mem;
4const Allocator = mem.Allocator;4const Allocator = mem.Allocator;
5const testing = std.testing;5const testing = std.testing;
...@@ -9,7 +9,7 @@ const testing = std.testing;...@@ -9,7 +9,7 @@ const testing = std.testing;
9pub const BufMap = struct {9pub const BufMap = struct {
10 hash_map: BufMapHashMap,10 hash_map: BufMapHashMap,
1111
12 const BufMapHashMap = HashMap([]const u8, []const u8, mem.hash_slice_u8, mem.eql_slice_u8);12 const BufMapHashMap = StringHashMap([]const u8);
1313
14 pub fn init(allocator: *Allocator) BufMap {14 pub fn init(allocator: *Allocator) BufMap {
15 var self = BufMap{ .hash_map = BufMapHashMap.init(allocator) };15 var self = BufMap{ .hash_map = BufMapHashMap.init(allocator) };
std/buf_set.zig+2-2
...@@ -1,5 +1,5 @@...@@ -1,5 +1,5 @@
1const std = @import("std.zig");1const std = @import("std.zig");
2const HashMap = @import("hash_map.zig").HashMap;2const StringHashMap = std.StringHashMap;
3const mem = @import("mem.zig");3const mem = @import("mem.zig");
4const Allocator = mem.Allocator;4const Allocator = mem.Allocator;
5const testing = std.testing;5const testing = std.testing;
...@@ -7,7 +7,7 @@ const testing = std.testing;...@@ -7,7 +7,7 @@ const testing = std.testing;
7pub const BufSet = struct {7pub const BufSet = struct {
8 hash_map: BufSetHashMap,8 hash_map: BufSetHashMap,
99
10 const BufSetHashMap = HashMap([]const u8, void, mem.hash_slice_u8, mem.eql_slice_u8);10 const BufSetHashMap = StringHashMap(void);
1111
12 pub fn init(a: *Allocator) BufSet {12 pub fn init(a: *Allocator) BufSet {
13 var self = BufSet{ .hash_map = BufSetHashMap.init(a) };13 var self = BufSet{ .hash_map = BufSetHashMap.init(a) };
std/build.zig+21-17
...@@ -4,10 +4,11 @@ const io = std.io;...@@ -4,10 +4,11 @@ const io = std.io;
4const fs = std.fs;4const fs = std.fs;
5const mem = std.mem;5const mem = std.mem;
6const debug = std.debug;6const debug = std.debug;
7const panic = std.debug.panic;
7const assert = debug.assert;8const assert = debug.assert;
8const warn = std.debug.warn;9const warn = std.debug.warn;
9const ArrayList = std.ArrayList;10const ArrayList = std.ArrayList;
10const HashMap = std.HashMap;11const StringHashMap = std.StringHashMap;
11const Allocator = mem.Allocator;12const Allocator = mem.Allocator;
12const process = std.process;13const process = std.process;
13const BufSet = std.BufSet;14const BufSet = std.BufSet;
...@@ -42,8 +43,8 @@ pub const Builder = struct {...@@ -42,8 +43,8 @@ pub const Builder = struct {
42 top_level_steps: ArrayList(*TopLevelStep),43 top_level_steps: ArrayList(*TopLevelStep),
43 install_prefix: ?[]const u8,44 install_prefix: ?[]const u8,
44 dest_dir: ?[]const u8,45 dest_dir: ?[]const u8,
45 lib_dir: ?[]const u8,46 lib_dir: []const u8,
46 exe_dir: ?[]const u8,47 exe_dir: []const u8,
47 install_path: []const u8,48 install_path: []const u8,
48 search_prefixes: ArrayList([]const u8),49 search_prefixes: ArrayList([]const u8),
49 installed_files: ArrayList(InstalledFile),50 installed_files: ArrayList(InstalledFile),
...@@ -60,8 +61,8 @@ pub const Builder = struct {...@@ -60,8 +61,8 @@ pub const Builder = struct {
60 C11,61 C11,
61 };62 };
6263
63 const UserInputOptionsMap = HashMap([]const u8, UserInputOption, mem.hash_slice_u8, mem.eql_slice_u8);64 const UserInputOptionsMap = StringHashMap(UserInputOption);
64 const AvailableOptionsMap = HashMap([]const u8, AvailableOption, mem.hash_slice_u8, mem.eql_slice_u8);65 const AvailableOptionsMap = StringHashMap(AvailableOption);
6566
66 const AvailableOption = struct {67 const AvailableOption = struct {
67 name: []const u8,68 name: []const u8,
...@@ -129,8 +130,8 @@ pub const Builder = struct {...@@ -129,8 +130,8 @@ pub const Builder = struct {
129 .env_map = env_map,130 .env_map = env_map,
130 .search_prefixes = ArrayList([]const u8).init(allocator),131 .search_prefixes = ArrayList([]const u8).init(allocator),
131 .install_prefix = null,132 .install_prefix = null,
132 .lib_dir = null,133 .lib_dir = undefined,
133 .exe_dir = null,134 .exe_dir = undefined,
134 .dest_dir = env_map.get("DESTDIR"),135 .dest_dir = env_map.get("DESTDIR"),
135 .installed_files = ArrayList(InstalledFile).init(allocator),136 .installed_files = ArrayList(InstalledFile).init(allocator),
136 .install_tls = TopLevelStep{137 .install_tls = TopLevelStep{
...@@ -163,11 +164,13 @@ pub const Builder = struct {...@@ -163,11 +164,13 @@ pub const Builder = struct {
163 self.allocator.destroy(self);164 self.allocator.destroy(self);
164 }165 }
165166
167 /// This function is intended to be called by std/special/build_runner.zig, not a build.zig file.
166 pub fn setInstallPrefix(self: *Builder, optional_prefix: ?[]const u8) void {168 pub fn setInstallPrefix(self: *Builder, optional_prefix: ?[]const u8) void {
167 self.install_prefix = optional_prefix;169 self.install_prefix = optional_prefix;
168 }170 }
169171
170 fn resolveInstallPrefix(self: *Builder) void {172 /// This function is intended to be called by std/special/build_runner.zig, not a build.zig file.
173 pub fn resolveInstallPrefix(self: *Builder) void {
171 if (self.dest_dir) |dest_dir| {174 if (self.dest_dir) |dest_dir| {
172 const install_prefix = self.install_prefix orelse "/usr";175 const install_prefix = self.install_prefix orelse "/usr";
173 self.install_path = fs.path.join(self.allocator, [_][]const u8{ dest_dir, install_prefix }) catch unreachable;176 self.install_path = fs.path.join(self.allocator, [_][]const u8{ dest_dir, install_prefix }) catch unreachable;
...@@ -437,7 +440,7 @@ pub const Builder = struct {...@@ -437,7 +440,7 @@ pub const Builder = struct {
437 .description = description,440 .description = description,
438 };441 };
439 if ((self.available_options_map.put(name, available_option) catch unreachable) != null) {442 if ((self.available_options_map.put(name, available_option) catch unreachable) != null) {
440 debug.panic("Option '{}' declared twice", name);443 panic("Option '{}' declared twice", name);
441 }444 }
442 self.available_options_list.append(available_option) catch unreachable;445 self.available_options_list.append(available_option) catch unreachable;
443446
...@@ -463,8 +466,8 @@ pub const Builder = struct {...@@ -463,8 +466,8 @@ pub const Builder = struct {
463 return null;466 return null;
464 },467 },
465 },468 },
466 TypeId.Int => debug.panic("TODO integer options to build script"),469 TypeId.Int => panic("TODO integer options to build script"),
467 TypeId.Float => debug.panic("TODO float options to build script"),470 TypeId.Float => panic("TODO float options to build script"),
468 TypeId.String => switch (entry.value.value) {471 TypeId.String => switch (entry.value.value) {
469 UserValue.Flag => {472 UserValue.Flag => {
470 warn("Expected -D{} to be a string, but received a boolean.\n", name);473 warn("Expected -D{} to be a string, but received a boolean.\n", name);
...@@ -478,7 +481,7 @@ pub const Builder = struct {...@@ -478,7 +481,7 @@ pub const Builder = struct {
478 },481 },
479 UserValue.Scalar => |s| return s,482 UserValue.Scalar => |s| return s,
480 },483 },
481 TypeId.List => debug.panic("TODO list options to build script"),484 TypeId.List => panic("TODO list options to build script"),
482 }485 }
483 }486 }
484487
...@@ -644,8 +647,6 @@ pub const Builder = struct {...@@ -644,8 +647,6 @@ pub const Builder = struct {
644 }647 }
645648
646 pub fn validateUserInputDidItFail(self: *Builder) bool {649 pub fn validateUserInputDidItFail(self: *Builder) bool {
647 self.resolveInstallPrefix();
648
649 // make sure all args are used650 // make sure all args are used
650 var it = self.user_input_options.iterator();651 var it = self.user_input_options.iterator();
651 while (true) {652 while (true) {
...@@ -855,7 +856,7 @@ pub const Builder = struct {...@@ -855,7 +856,7 @@ pub const Builder = struct {
855 var stdout_file_in_stream = child.stdout.?.inStream();856 var stdout_file_in_stream = child.stdout.?.inStream();
856 try stdout_file_in_stream.stream.readAllBuffer(&stdout, max_output_size);857 try stdout_file_in_stream.stream.readAllBuffer(&stdout, max_output_size);
857858
858 const term = child.wait() catch |err| std.debug.panic("unable to spawn {}: {}", argv[0], err);859 const term = child.wait() catch |err| panic("unable to spawn {}: {}", argv[0], err);
859 switch (term) {860 switch (term) {
860 .Exited => |code| {861 .Exited => |code| {
861 if (code != 0) {862 if (code != 0) {
...@@ -882,8 +883,8 @@ pub const Builder = struct {...@@ -882,8 +883,8 @@ pub const Builder = struct {
882 fn getInstallPath(self: *Builder, dir: InstallDir, dest_rel_path: []const u8) []const u8 {883 fn getInstallPath(self: *Builder, dir: InstallDir, dest_rel_path: []const u8) []const u8 {
883 const base_dir = switch (dir) {884 const base_dir = switch (dir) {
884 .Prefix => self.install_path,885 .Prefix => self.install_path,
885 .Bin => self.exe_dir.?,886 .Bin => self.exe_dir,
886 .Lib => self.lib_dir.?,887 .Lib => self.lib_dir,
887 };888 };
888 return fs.path.resolve(889 return fs.path.resolve(
889 self.allocator,890 self.allocator,
...@@ -1318,6 +1319,9 @@ pub const LibExeObjStep = struct {...@@ -1318,6 +1319,9 @@ pub const LibExeObjStep = struct {
1318 }1319 }
13191320
1320 fn initExtraArgs(builder: *Builder, name: []const u8, root_src: ?[]const u8, kind: Kind, is_dynamic: bool, ver: Version) LibExeObjStep {1321 fn initExtraArgs(builder: *Builder, name: []const u8, root_src: ?[]const u8, kind: Kind, is_dynamic: bool, ver: Version) LibExeObjStep {
1322 if (mem.indexOf(u8, name, "/") != null or mem.indexOf(u8, name, "\\") != null) {
1323 panic("invalid name: '{}'. It looks like a file path, but it is supposed to be the library or application name.", name);
1324 }
1321 var self = LibExeObjStep{1325 var self = LibExeObjStep{
1322 .strip = false,1326 .strip = false,
1323 .builder = builder,1327 .builder = builder,
std/c.zig+1
...@@ -68,6 +68,7 @@ pub extern "c" fn open(path: [*]const u8, oflag: c_uint, ...) c_int;...@@ -68,6 +68,7 @@ pub extern "c" fn open(path: [*]const u8, oflag: c_uint, ...) c_int;
68pub extern "c" fn openat(fd: c_int, path: [*]const u8, oflag: c_uint, ...) c_int;68pub extern "c" fn openat(fd: c_int, path: [*]const u8, oflag: c_uint, ...) c_int;
69pub extern "c" fn raise(sig: c_int) c_int;69pub extern "c" fn raise(sig: c_int) c_int;
70pub extern "c" fn read(fd: fd_t, buf: [*]u8, nbyte: usize) isize;70pub extern "c" fn read(fd: fd_t, buf: [*]u8, nbyte: usize) isize;
71pub extern "c" fn readv(fd: c_int, iov: [*]const iovec, iovcnt: c_uint) isize;
71pub extern "c" fn pread(fd: fd_t, buf: [*]u8, nbyte: usize, offset: u64) isize;72pub extern "c" fn pread(fd: fd_t, buf: [*]u8, nbyte: usize, offset: u64) isize;
72pub extern "c" fn preadv(fd: c_int, iov: [*]const iovec, iovcnt: c_uint, offset: usize) isize;73pub extern "c" fn preadv(fd: c_int, iov: [*]const iovec, iovcnt: c_uint, offset: usize) isize;
73pub extern "c" fn writev(fd: c_int, iov: [*]const iovec_const, iovcnt: c_uint) isize;74pub extern "c" fn writev(fd: c_int, iov: [*]const iovec_const, iovcnt: c_uint) isize;
std/debug.zig+32-14
...@@ -330,14 +330,16 @@ pub fn writeCurrentStackTraceWindows(...@@ -330,14 +330,16 @@ pub fn writeCurrentStackTraceWindows(
330 }330 }
331}331}
332332
333/// TODO once https://github.com/ziglang/zig/issues/3157 is fully implemented,
334/// make this `noasync fn` and remove the individual noasync calls.
333pub fn printSourceAtAddress(debug_info: *DebugInfo, out_stream: var, address: usize, tty_color: bool) !void {335pub fn printSourceAtAddress(debug_info: *DebugInfo, out_stream: var, address: usize, tty_color: bool) !void {
334 if (windows.is_the_target) {336 if (windows.is_the_target) {
335 return printSourceAtAddressWindows(debug_info, out_stream, address, tty_color);337 return noasync printSourceAtAddressWindows(debug_info, out_stream, address, tty_color);
336 }338 }
337 if (os.darwin.is_the_target) {339 if (os.darwin.is_the_target) {
338 return printSourceAtAddressMacOs(debug_info, out_stream, address, tty_color);340 return noasync printSourceAtAddressMacOs(debug_info, out_stream, address, tty_color);
339 }341 }
340 return printSourceAtAddressPosix(debug_info, out_stream, address, tty_color);342 return noasync printSourceAtAddressPosix(debug_info, out_stream, address, tty_color);
341}343}
342344
343fn printSourceAtAddressWindows(di: *DebugInfo, out_stream: var, relocated_address: usize, tty_color: bool) !void {345fn printSourceAtAddressWindows(di: *DebugInfo, out_stream: var, relocated_address: usize, tty_color: bool) !void {
...@@ -793,7 +795,7 @@ fn printLineInfo(...@@ -793,7 +795,7 @@ fn printLineInfo(
793 try out_stream.write(GREEN ++ "^" ++ RESET ++ "\n");795 try out_stream.write(GREEN ++ "^" ++ RESET ++ "\n");
794 }796 }
795 } else |err| switch (err) {797 } else |err| switch (err) {
796 error.EndOfFile => {},798 error.EndOfFile, error.FileNotFound => {},
797 else => return err,799 else => return err,
798 }800 }
799 } else {801 } else {
...@@ -816,16 +818,18 @@ pub const OpenSelfDebugInfoError = error{...@@ -816,16 +818,18 @@ pub const OpenSelfDebugInfoError = error{
816 UnsupportedOperatingSystem,818 UnsupportedOperatingSystem,
817};819};
818820
821/// TODO once https://github.com/ziglang/zig/issues/3157 is fully implemented,
822/// make this `noasync fn` and remove the individual noasync calls.
819pub fn openSelfDebugInfo(allocator: *mem.Allocator) !DebugInfo {823pub fn openSelfDebugInfo(allocator: *mem.Allocator) !DebugInfo {
820 if (builtin.strip_debug_info)824 if (builtin.strip_debug_info)
821 return error.MissingDebugInfo;825 return error.MissingDebugInfo;
822 if (windows.is_the_target) {826 if (windows.is_the_target) {
823 return openSelfDebugInfoWindows(allocator);827 return noasync openSelfDebugInfoWindows(allocator);
824 }828 }
825 if (os.darwin.is_the_target) {829 if (os.darwin.is_the_target) {
826 return openSelfDebugInfoMacOs(allocator);830 return noasync openSelfDebugInfoMacOs(allocator);
827 }831 }
828 return openSelfDebugInfoPosix(allocator);832 return noasync openSelfDebugInfoPosix(allocator);
829}833}
830834
831fn openSelfDebugInfoWindows(allocator: *mem.Allocator) !DebugInfo {835fn openSelfDebugInfoWindows(allocator: *mem.Allocator) !DebugInfo {
...@@ -1053,7 +1057,8 @@ fn openSelfDebugInfoPosix(allocator: *mem.Allocator) !DwarfInfo {...@@ -1053,7 +1057,8 @@ fn openSelfDebugInfoPosix(allocator: *mem.Allocator) !DwarfInfo {
1053 S.self_exe_file = try fs.openSelfExe();1057 S.self_exe_file = try fs.openSelfExe();
1054 errdefer S.self_exe_file.close();1058 errdefer S.self_exe_file.close();
10551059
1056 const self_exe_mmap_len = mem.alignForward(try S.self_exe_file.getEndPos(), mem.page_size);1060 const self_exe_len = math.cast(usize, try S.self_exe_file.getEndPos()) catch return error.DebugInfoTooLarge;
1061 const self_exe_mmap_len = mem.alignForward(self_exe_len, mem.page_size);
1057 const self_exe_mmap = try os.mmap(1062 const self_exe_mmap = try os.mmap(
1058 null,1063 null,
1059 self_exe_mmap_len,1064 self_exe_mmap_len,
...@@ -1507,15 +1512,25 @@ fn parseFormValueBlock(allocator: *mem.Allocator, in_stream: var, size: usize) !...@@ -1507,15 +1512,25 @@ fn parseFormValueBlock(allocator: *mem.Allocator, in_stream: var, size: usize) !
1507}1512}
15081513
1509fn parseFormValueConstant(allocator: *mem.Allocator, in_stream: var, signed: bool, comptime size: i32) !FormValue {1514fn parseFormValueConstant(allocator: *mem.Allocator, in_stream: var, signed: bool, comptime size: i32) !FormValue {
1515 // TODO: Please forgive me, I've worked around zig not properly spilling some intermediate values here.
1516 // `noasync` should be removed from all the function calls once it is fixed.
1510 return FormValue{1517 return FormValue{
1511 .Const = Constant{1518 .Const = Constant{
1512 .signed = signed,1519 .signed = signed,
1513 .payload = switch (size) {1520 .payload = switch (size) {
1514 1 => try in_stream.readIntLittle(u8),1521 1 => try noasync in_stream.readIntLittle(u8),
1515 2 => try in_stream.readIntLittle(u16),1522 2 => try noasync in_stream.readIntLittle(u16),
1516 4 => try in_stream.readIntLittle(u32),1523 4 => try noasync in_stream.readIntLittle(u32),
1517 8 => try in_stream.readIntLittle(u64),1524 8 => try noasync in_stream.readIntLittle(u64),
1518 -1 => if (signed) @bitCast(u64, try leb.readILEB128(i64, in_stream)) else try leb.readULEB128(u64, in_stream),1525 -1 => blk: {
1526 if (signed) {
1527 const x = try noasync leb.readILEB128(i64, in_stream);
1528 break :blk @bitCast(u64, x);
1529 } else {
1530 const x = try noasync leb.readULEB128(u64, in_stream);
1531 break :blk x;
1532 }
1533 },
1519 else => @compileError("Invalid size"),1534 else => @compileError("Invalid size"),
1520 },1535 },
1521 },1536 },
...@@ -1583,7 +1598,10 @@ fn parseFormValue(allocator: *mem.Allocator, in_stream: var, form_id: u64, is_64...@@ -1583,7 +1598,10 @@ fn parseFormValue(allocator: *mem.Allocator, in_stream: var, form_id: u64, is_64
1583 DW.FORM_strp => FormValue{ .StrPtr = try parseFormValueDwarfOffsetSize(in_stream, is_64) },1598 DW.FORM_strp => FormValue{ .StrPtr = try parseFormValueDwarfOffsetSize(in_stream, is_64) },
1584 DW.FORM_indirect => {1599 DW.FORM_indirect => {
1585 const child_form_id = try leb.readULEB128(u64, in_stream);1600 const child_form_id = try leb.readULEB128(u64, in_stream);
1586 return parseFormValue(allocator, in_stream, child_form_id, is_64);1601 const F = @typeOf(async parseFormValue(allocator, in_stream, child_form_id, is_64));
1602 var frame = try allocator.create(F);
1603 defer allocator.destroy(frame);
1604 return await @asyncCall(frame, {}, parseFormValue, allocator, in_stream, child_form_id, is_64);
1587 },1605 },
1588 else => error.InvalidDebugInfo,1606 else => error.InvalidDebugInfo,
1589 };1607 };
std/event.zig-2
...@@ -6,7 +6,6 @@ pub const Locked = @import("event/locked.zig").Locked;...@@ -6,7 +6,6 @@ pub const Locked = @import("event/locked.zig").Locked;
6pub const RwLock = @import("event/rwlock.zig").RwLock;6pub const RwLock = @import("event/rwlock.zig").RwLock;
7pub const RwLocked = @import("event/rwlocked.zig").RwLocked;7pub const RwLocked = @import("event/rwlocked.zig").RwLocked;
8pub const Loop = @import("event/loop.zig").Loop;8pub const Loop = @import("event/loop.zig").Loop;
9pub const io = @import("event/io.zig");
10pub const fs = @import("event/fs.zig");9pub const fs = @import("event/fs.zig");
11pub const net = @import("event/net.zig");10pub const net = @import("event/net.zig");
1211
...@@ -15,7 +14,6 @@ test "import event tests" {...@@ -15,7 +14,6 @@ test "import event tests" {
15 _ = @import("event/fs.zig");14 _ = @import("event/fs.zig");
16 _ = @import("event/future.zig");15 _ = @import("event/future.zig");
17 _ = @import("event/group.zig");16 _ = @import("event/group.zig");
18 _ = @import("event/io.zig");
19 _ = @import("event/lock.zig");17 _ = @import("event/lock.zig");
20 _ = @import("event/locked.zig");18 _ = @import("event/locked.zig");
21 _ = @import("event/rwlock.zig");19 _ = @import("event/rwlock.zig");
std/event/future.zig+1-5
...@@ -104,11 +104,7 @@ fn testFuture(loop: *Loop) void {...@@ -104,11 +104,7 @@ fn testFuture(loop: *Loop) void {
104 var b = async waitOnFuture(&future);104 var b = async waitOnFuture(&future);
105 resolveFuture(&future);105 resolveFuture(&future);
106106
107 // TODO https://github.com/ziglang/zig/issues/3077107 const result = (await a) + (await b);
108 //const result = (await a) + (await b);
109 const a_result = await a;
110 const b_result = await b;
111 const result = a_result + b_result;
112108
113 testing.expect(result == 12);109 testing.expect(result == 12);
114}110}
std/event/io.zig deleted-76
...@@ -1,76 +0,0 @@
1const std = @import("../std.zig");
2const builtin = @import("builtin");
3const assert = std.debug.assert;
4const mem = std.mem;
5
6pub fn InStream(comptime ReadError: type) type {
7 return struct {
8 const Self = @This();
9 pub const Error = ReadError;
10
11 /// Return the number of bytes read. It may be less than buffer.len.
12 /// If the number of bytes read is 0, it means end of stream.
13 /// End of stream is not an error condition.
14 readFn: async fn (self: *Self, buffer: []u8) Error!usize,
15
16 /// Return the number of bytes read. It may be less than buffer.len.
17 /// If the number of bytes read is 0, it means end of stream.
18 /// End of stream is not an error condition.
19 pub async fn read(self: *Self, buffer: []u8) !usize {
20 return self.readFn(self, buffer);
21 }
22
23 /// Return the number of bytes read. If it is less than buffer.len
24 /// it means end of stream.
25 pub async fn readFull(self: *Self, buffer: []u8) !usize {
26 var index: usize = 0;
27 while (index != buf.len) {
28 const amt_read = try self.read(buf[index..]);
29 if (amt_read == 0) return index;
30 index += amt_read;
31 }
32 return index;
33 }
34
35 /// Same as `readFull` but end of stream returns `error.EndOfStream`.
36 pub async fn readNoEof(self: *Self, buf: []u8) !void {
37 const amt_read = try self.readFull(buf[index..]);
38 if (amt_read < buf.len) return error.EndOfStream;
39 }
40
41 pub async fn readIntLittle(self: *Self, comptime T: type) !T {
42 var bytes: [@sizeOf(T)]u8 = undefined;
43 try self.readNoEof(bytes[0..]);
44 return mem.readIntLittle(T, &bytes);
45 }
46
47 pub async fn readIntBe(self: *Self, comptime T: type) !T {
48 var bytes: [@sizeOf(T)]u8 = undefined;
49 try self.readNoEof(bytes[0..]);
50 return mem.readIntBig(T, &bytes);
51 }
52
53 pub async fn readInt(self: *Self, comptime T: type, endian: builtin.Endian) !T {
54 var bytes: [@sizeOf(T)]u8 = undefined;
55 try self.readNoEof(bytes[0..]);
56 return mem.readInt(T, &bytes, endian);
57 }
58
59 pub async fn readStruct(self: *Self, comptime T: type) !T {
60 // Only extern and packed structs have defined in-memory layout.
61 comptime assert(@typeInfo(T).Struct.layout != builtin.TypeInfo.ContainerLayout.Auto);
62 var res: [1]T = undefined;
63 try self.readNoEof(@sliceToBytes(res[0..]));
64 return res[0];
65 }
66 };
67}
68
69pub fn OutStream(comptime WriteError: type) type {
70 return struct {
71 const Self = @This();
72 pub const Error = WriteError;
73
74 writeFn: async fn (self: *Self, buffer: []u8) Error!void,
75 };
76}
std/event/loop.zig+5-9
...@@ -86,18 +86,10 @@ pub const Loop = struct {...@@ -86,18 +86,10 @@ pub const Loop = struct {
86 };86 };
87 };87 };
8888
89 pub const IoMode = enum {
90 blocking,
91 evented,
92 mixed,
93 };
94 pub const io_mode: IoMode = if (@hasDecl(root, "io_mode")) root.io_mode else IoMode.blocking;
95 var global_instance_state: Loop = undefined;89 var global_instance_state: Loop = undefined;
96 threadlocal var per_thread_instance: ?*Loop = null;90 const default_instance: ?*Loop = switch (std.io.mode) {
97 const default_instance: ?*Loop = switch (io_mode) {
98 .blocking => null,91 .blocking => null,
99 .evented => &global_instance_state,92 .evented => &global_instance_state,
100 .mixed => per_thread_instance,
101 };93 };
102 pub const instance: ?*Loop = if (@hasDecl(root, "event_loop")) root.event_loop else default_instance;94 pub const instance: ?*Loop = if (@hasDecl(root, "event_loop")) root.event_loop else default_instance;
10395
...@@ -470,6 +462,10 @@ pub const Loop = struct {...@@ -470,6 +462,10 @@ pub const Loop = struct {
470 }462 }
471 }463 }
472464
465 pub fn waitUntilFdReadable(self: *Loop, fd: os.fd_t) !void {
466 return self.linuxWaitFd(fd, os.EPOLLET | os.EPOLLIN);
467 }
468
473 pub async fn bsdWaitKev(self: *Loop, ident: usize, filter: i16, fflags: u32) !os.Kevent {469 pub async fn bsdWaitKev(self: *Loop, ident: usize, filter: i16, fflags: u32) !os.Kevent {
474 var resume_node = ResumeNode.Basic{470 var resume_node = ResumeNode.Basic{
475 .base = ResumeNode{471 .base = ResumeNode{
std/fmt/parse_float.zig+11-3
...@@ -110,9 +110,7 @@ fn convertRepr(comptime T: type, n: FloatRepr) T {...@@ -110,9 +110,7 @@ fn convertRepr(comptime T: type, n: FloatRepr) T {
110 q.shiftLeft1(s); // q = p << 1110 q.shiftLeft1(s); // q = p << 1
111 r.shiftLeft1(q); // r = p << 2111 r.shiftLeft1(q); // r = p << 2
112 s.shiftLeft1(r); // p = p << 3112 s.shiftLeft1(r); // p = p << 3
113 q.add(s); // p = (p << 3) + (p << 1)113 s.add(q); // p = (p << 3) + (p << 1)
114
115 exp -= 1;
116114
117 while (s.d2 & mask28 != 0) {115 while (s.d2 & mask28 != 0) {
118 q.shiftRight1(s);116 q.shiftRight1(s);
...@@ -402,6 +400,13 @@ test "fmt.parseFloat" {...@@ -402,6 +400,13 @@ test "fmt.parseFloat" {
402 expectEqual((try parseFloat(T, "+0")), 0.0);400 expectEqual((try parseFloat(T, "+0")), 0.0);
403 expectEqual((try parseFloat(T, "-0")), 0.0);401 expectEqual((try parseFloat(T, "-0")), 0.0);
404402
403 expectEqual((try parseFloat(T, "0e0")), 0);
404 expectEqual((try parseFloat(T, "2e3")), 2000.0);
405 expectEqual((try parseFloat(T, "1e0")), 1.0);
406 expectEqual((try parseFloat(T, "-2e3")), -2000.0);
407 expectEqual((try parseFloat(T, "-1e0")), -1.0);
408 expectEqual((try parseFloat(T, "1.234e3")), 1234);
409
405 expect(approxEq(T, try parseFloat(T, "3.141"), 3.141, epsilon));410 expect(approxEq(T, try parseFloat(T, "3.141"), 3.141, epsilon));
406 expect(approxEq(T, try parseFloat(T, "-3.141"), -3.141, epsilon));411 expect(approxEq(T, try parseFloat(T, "-3.141"), -3.141, epsilon));
407412
...@@ -413,6 +418,9 @@ test "fmt.parseFloat" {...@@ -413,6 +418,9 @@ test "fmt.parseFloat" {
413 expectEqual((try parseFloat(T, "-INF")), -std.math.inf(T));418 expectEqual((try parseFloat(T, "-INF")), -std.math.inf(T));
414419
415 if (T != f16) {420 if (T != f16) {
421 expect(approxEq(T, try parseFloat(T, "1e-2"), 0.01, epsilon));
422 expect(approxEq(T, try parseFloat(T, "1234e-2"), 12.34, epsilon));
423
416 expect(approxEq(T, try parseFloat(T, "123142.1"), 123142.1, epsilon));424 expect(approxEq(T, try parseFloat(T, "123142.1"), 123142.1, epsilon));
417 expect(approxEq(T, try parseFloat(T, "-123142.1124"), T(-123142.1124), epsilon));425 expect(approxEq(T, try parseFloat(T, "-123142.1124"), T(-123142.1124), epsilon));
418 expect(approxEq(T, try parseFloat(T, "0.7062146892655368"), T(0.7062146892655368), epsilon));426 expect(approxEq(T, try parseFloat(T, "0.7062146892655368"), T(0.7062146892655368), epsilon));
std/fs/file.zig+3-3
...@@ -261,9 +261,9 @@ pub const File = struct {...@@ -261,9 +261,9 @@ pub const File = struct {
261 return Stat{261 return Stat{
262 .size = @bitCast(u64, st.size),262 .size = @bitCast(u64, st.size),
263 .mode = st.mode,263 .mode = st.mode,
264 .atime = atime.tv_sec * std.time.ns_per_s + atime.tv_nsec,264 .atime = i64(atime.tv_sec) * std.time.ns_per_s + atime.tv_nsec,
265 .mtime = mtime.tv_sec * std.time.ns_per_s + mtime.tv_nsec,265 .mtime = i64(mtime.tv_sec) * std.time.ns_per_s + mtime.tv_nsec,
266 .ctime = ctime.tv_sec * std.time.ns_per_s + ctime.tv_nsec,266 .ctime = i64(ctime.tv_sec) * std.time.ns_per_s + ctime.tv_nsec,
267 };267 };
268 }268 }
269269
std/hash/cityhash.zig+4-4
...@@ -214,7 +214,7 @@ pub const CityHash64 = struct {...@@ -214,7 +214,7 @@ pub const CityHash64 = struct {
214 }214 }
215215
216 fn hashLen0To16(str: []const u8) u64 {216 fn hashLen0To16(str: []const u8) u64 {
217 const len: u64 = @truncate(u64, str.len);217 const len: u64 = u64(str.len);
218 if (len >= 8) {218 if (len >= 8) {
219 const mul: u64 = k2 +% len *% 2;219 const mul: u64 = k2 +% len *% 2;
220 const a: u64 = fetch64(str.ptr) +% k2;220 const a: u64 = fetch64(str.ptr) +% k2;
...@@ -240,7 +240,7 @@ pub const CityHash64 = struct {...@@ -240,7 +240,7 @@ pub const CityHash64 = struct {
240 }240 }
241241
242 fn hashLen17To32(str: []const u8) u64 {242 fn hashLen17To32(str: []const u8) u64 {
243 const len: u64 = @truncate(u64, str.len);243 const len: u64 = u64(str.len);
244 const mul: u64 = k2 +% len *% 2;244 const mul: u64 = k2 +% len *% 2;
245 const a: u64 = fetch64(str.ptr) *% k1;245 const a: u64 = fetch64(str.ptr) *% k1;
246 const b: u64 = fetch64(str.ptr + 8);246 const b: u64 = fetch64(str.ptr + 8);
...@@ -251,7 +251,7 @@ pub const CityHash64 = struct {...@@ -251,7 +251,7 @@ pub const CityHash64 = struct {
251 }251 }
252252
253 fn hashLen33To64(str: []const u8) u64 {253 fn hashLen33To64(str: []const u8) u64 {
254 const len: u64 = @truncate(u64, str.len);254 const len: u64 = u64(str.len);
255 const mul: u64 = k2 +% len *% 2;255 const mul: u64 = k2 +% len *% 2;
256 const a: u64 = fetch64(str.ptr) *% k2;256 const a: u64 = fetch64(str.ptr) *% k2;
257 const b: u64 = fetch64(str.ptr + 8);257 const b: u64 = fetch64(str.ptr + 8);
...@@ -305,7 +305,7 @@ pub const CityHash64 = struct {...@@ -305,7 +305,7 @@ pub const CityHash64 = struct {
305 return hashLen33To64(str);305 return hashLen33To64(str);
306 }306 }
307307
308 var len: u64 = @truncate(u64, str.len);308 var len: u64 = u64(str.len);
309309
310 var x: u64 = fetch64(str.ptr + str.len - 40);310 var x: u64 = fetch64(str.ptr + str.len - 40);
311 var y: u64 = fetch64(str.ptr + str.len - 16) +% fetch64(str.ptr + str.len - 56);311 var y: u64 = fetch64(str.ptr + str.len - 16) +% fetch64(str.ptr + str.len - 56);
std/hash/murmur.zig+3-3
...@@ -98,9 +98,9 @@ pub const Murmur2_64 = struct {...@@ -98,9 +98,9 @@ pub const Murmur2_64 = struct {
9898
99 pub fn hashWithSeed(str: []const u8, seed: u64) u64 {99 pub fn hashWithSeed(str: []const u8, seed: u64) u64 {
100 const m: u64 = 0xc6a4a7935bd1e995;100 const m: u64 = 0xc6a4a7935bd1e995;
101 const len = @truncate(u64, str.len);101 const len = u64(str.len);
102 var h1: u64 = seed ^ (len *% m);102 var h1: u64 = seed ^ (len *% m);
103 for (@ptrCast([*]allowzero align(1) const u64, str.ptr)[0..(len >> 3)]) |v| {103 for (@ptrCast([*]allowzero align(1) const u64, str.ptr)[0..@intCast(usize, len >> 3)]) |v| {
104 var k1: u64 = v;104 var k1: u64 = v;
105 if (builtin.endian == builtin.Endian.Big)105 if (builtin.endian == builtin.Endian.Big)
106 k1 = @byteSwap(u64, k1);106 k1 = @byteSwap(u64, k1);
...@@ -114,7 +114,7 @@ pub const Murmur2_64 = struct {...@@ -114,7 +114,7 @@ pub const Murmur2_64 = struct {
114 const offset = len - rest;114 const offset = len - rest;
115 if (rest > 0) {115 if (rest > 0) {
116 var k1: u64 = 0;116 var k1: u64 = 0;
117 @memcpy(@ptrCast([*]u8, &k1), @ptrCast([*]const u8, &str[offset]), rest);117 @memcpy(@ptrCast([*]u8, &k1), @ptrCast([*]const u8, &str[@intCast(usize, offset)]), @intCast(usize, rest));
118 if (builtin.endian == builtin.Endian.Big)118 if (builtin.endian == builtin.Endian.Big)
119 k1 = @byteSwap(u64, k1);119 k1 = @byteSwap(u64, k1);
120 h1 ^= k1;120 h1 ^= k1;
std/hash_map.zig+1-3
...@@ -23,9 +23,7 @@ pub fn StringHashMap(comptime V: type) type {...@@ -23,9 +23,7 @@ pub fn StringHashMap(comptime V: type) type {
23}23}
2424
25pub fn eqlString(a: []const u8, b: []const u8) bool {25pub fn eqlString(a: []const u8, b: []const u8) bool {
26 if (a.len != b.len) return false;26 return mem.eql(u8, a, b);
27 if (a.ptr == b.ptr) return true;
28 return mem.compare(u8, a, b) == .Equal;
29}27}
3028
31pub fn hashString(s: []const u8) u32 {29pub fn hashString(s: []const u8) u32 {
std/io.zig+14-174
...@@ -1,5 +1,6 @@...@@ -1,5 +1,6 @@
1const std = @import("std.zig");1const std = @import("std.zig");
2const builtin = @import("builtin");2const builtin = @import("builtin");
3const root = @import("root");
3const c = std.c;4const c = std.c;
45
5const math = std.math;6const math = std.math;
...@@ -15,6 +16,18 @@ const fmt = std.fmt;...@@ -15,6 +16,18 @@ const fmt = std.fmt;
15const File = std.fs.File;16const File = std.fs.File;
16const testing = std.testing;17const testing = std.testing;
1718
19pub const Mode = enum {
20 blocking,
21 evented,
22};
23pub const mode: Mode = if (@hasDecl(root, "io_mode"))
24 root.io_mode
25else if (@hasDecl(root, "event_loop"))
26 Mode.evented
27else
28 Mode.blocking;
29pub const is_async = mode != .blocking;
30
18pub const GetStdIoError = os.windows.GetStdHandleError;31pub const GetStdIoError = os.windows.GetStdHandleError;
1932
20pub fn getStdOut() GetStdIoError!File {33pub fn getStdOut() GetStdIoError!File {
...@@ -44,180 +57,7 @@ pub fn getStdIn() GetStdIoError!File {...@@ -44,180 +57,7 @@ pub fn getStdIn() GetStdIoError!File {
44pub const SeekableStream = @import("io/seekable_stream.zig").SeekableStream;57pub const SeekableStream = @import("io/seekable_stream.zig").SeekableStream;
45pub const SliceSeekableInStream = @import("io/seekable_stream.zig").SliceSeekableInStream;58pub const SliceSeekableInStream = @import("io/seekable_stream.zig").SliceSeekableInStream;
46pub const COutStream = @import("io/c_out_stream.zig").COutStream;59pub const COutStream = @import("io/c_out_stream.zig").COutStream;
4760pub const InStream = @import("io/in_stream.zig").InStream;
48pub fn InStream(comptime ReadError: type) type {
49 return struct {
50 const Self = @This();
51 pub const Error = ReadError;
52
53 /// Return the number of bytes read. If the number read is smaller than buf.len, it
54 /// means the stream reached the end. Reaching the end of a stream is not an error
55 /// condition.
56 readFn: fn (self: *Self, buffer: []u8) Error!usize,
57
58 /// Replaces `buffer` contents by reading from the stream until it is finished.
59 /// If `buffer.len()` would exceed `max_size`, `error.StreamTooLong` is returned and
60 /// the contents read from the stream are lost.
61 pub fn readAllBuffer(self: *Self, buffer: *Buffer, max_size: usize) !void {
62 try buffer.resize(0);
63
64 var actual_buf_len: usize = 0;
65 while (true) {
66 const dest_slice = buffer.toSlice()[actual_buf_len..];
67 const bytes_read = try self.readFull(dest_slice);
68 actual_buf_len += bytes_read;
69
70 if (bytes_read != dest_slice.len) {
71 buffer.shrink(actual_buf_len);
72 return;
73 }
74
75 const new_buf_size = math.min(max_size, actual_buf_len + mem.page_size);
76 if (new_buf_size == actual_buf_len) return error.StreamTooLong;
77 try buffer.resize(new_buf_size);
78 }
79 }
80
81 /// Allocates enough memory to hold all the contents of the stream. If the allocated
82 /// memory would be greater than `max_size`, returns `error.StreamTooLong`.
83 /// Caller owns returned memory.
84 /// If this function returns an error, the contents from the stream read so far are lost.
85 pub fn readAllAlloc(self: *Self, allocator: *mem.Allocator, max_size: usize) ![]u8 {
86 var buf = Buffer.initNull(allocator);
87 defer buf.deinit();
88
89 try self.readAllBuffer(&buf, max_size);
90 return buf.toOwnedSlice();
91 }
92
93 /// Replaces `buffer` contents by reading from the stream until `delimiter` is found.
94 /// Does not include the delimiter in the result.
95 /// If `buffer.len()` would exceed `max_size`, `error.StreamTooLong` is returned and the contents
96 /// read from the stream so far are lost.
97 pub fn readUntilDelimiterBuffer(self: *Self, buffer: *Buffer, delimiter: u8, max_size: usize) !void {
98 try buffer.resize(0);
99
100 while (true) {
101 var byte: u8 = try self.readByte();
102
103 if (byte == delimiter) {
104 return;
105 }
106
107 if (buffer.len() == max_size) {
108 return error.StreamTooLong;
109 }
110
111 try buffer.appendByte(byte);
112 }
113 }
114
115 /// Allocates enough memory to read until `delimiter`. If the allocated
116 /// memory would be greater than `max_size`, returns `error.StreamTooLong`.
117 /// Caller owns returned memory.
118 /// If this function returns an error, the contents from the stream read so far are lost.
119 pub fn readUntilDelimiterAlloc(self: *Self, allocator: *mem.Allocator, delimiter: u8, max_size: usize) ![]u8 {
120 var buf = Buffer.initNull(allocator);
121 defer buf.deinit();
122
123 try self.readUntilDelimiterBuffer(&buf, delimiter, max_size);
124 return buf.toOwnedSlice();
125 }
126
127 /// Returns the number of bytes read. It may be less than buffer.len.
128 /// If the number of bytes read is 0, it means end of stream.
129 /// End of stream is not an error condition.
130 pub fn read(self: *Self, buffer: []u8) Error!usize {
131 return self.readFn(self, buffer);
132 }
133
134 /// Returns the number of bytes read. If the number read is smaller than buf.len, it
135 /// means the stream reached the end. Reaching the end of a stream is not an error
136 /// condition.
137 pub fn readFull(self: *Self, buffer: []u8) Error!usize {
138 var index: usize = 0;
139 while (index != buffer.len) {
140 const amt = try self.read(buffer[index..]);
141 if (amt == 0) return index;
142 index += amt;
143 }
144 return index;
145 }
146
147 /// Same as `readFull` but end of stream returns `error.EndOfStream`.
148 pub fn readNoEof(self: *Self, buf: []u8) !void {
149 const amt_read = try self.readFull(buf);
150 if (amt_read < buf.len) return error.EndOfStream;
151 }
152
153 /// Reads 1 byte from the stream or returns `error.EndOfStream`.
154 pub fn readByte(self: *Self) !u8 {
155 var result: [1]u8 = undefined;
156 try self.readNoEof(result[0..]);
157 return result[0];
158 }
159
160 /// Same as `readByte` except the returned byte is signed.
161 pub fn readByteSigned(self: *Self) !i8 {
162 return @bitCast(i8, try self.readByte());
163 }
164
165 /// Reads a native-endian integer
166 pub fn readIntNative(self: *Self, comptime T: type) !T {
167 var bytes: [(T.bit_count + 7) / 8]u8 = undefined;
168 try self.readNoEof(bytes[0..]);
169 return mem.readIntNative(T, &bytes);
170 }
171
172 /// Reads a foreign-endian integer
173 pub fn readIntForeign(self: *Self, comptime T: type) !T {
174 var bytes: [(T.bit_count + 7) / 8]u8 = undefined;
175 try self.readNoEof(bytes[0..]);
176 return mem.readIntForeign(T, &bytes);
177 }
178
179 pub fn readIntLittle(self: *Self, comptime T: type) !T {
180 var bytes: [(T.bit_count + 7) / 8]u8 = undefined;
181 try self.readNoEof(bytes[0..]);
182 return mem.readIntLittle(T, &bytes);
183 }
184
185 pub fn readIntBig(self: *Self, comptime T: type) !T {
186 var bytes: [(T.bit_count + 7) / 8]u8 = undefined;
187 try self.readNoEof(bytes[0..]);
188 return mem.readIntBig(T, &bytes);
189 }
190
191 pub fn readInt(self: *Self, comptime T: type, endian: builtin.Endian) !T {
192 var bytes: [(T.bit_count + 7) / 8]u8 = undefined;
193 try self.readNoEof(bytes[0..]);
194 return mem.readInt(T, &bytes, endian);
195 }
196
197 pub fn readVarInt(self: *Self, comptime ReturnType: type, endian: builtin.Endian, size: usize) !ReturnType {
198 assert(size <= @sizeOf(ReturnType));
199 var bytes_buf: [@sizeOf(ReturnType)]u8 = undefined;
200 const bytes = bytes_buf[0..size];
201 try self.readNoEof(bytes);
202 return mem.readVarInt(ReturnType, bytes, endian);
203 }
204
205 pub fn skipBytes(self: *Self, num_bytes: u64) !void {
206 var i: u64 = 0;
207 while (i < num_bytes) : (i += 1) {
208 _ = try self.readByte();
209 }
210 }
211
212 pub fn readStruct(self: *Self, comptime T: type) !T {
213 // Only extern and packed structs have defined in-memory layout.
214 comptime assert(@typeInfo(T).Struct.layout != builtin.TypeInfo.ContainerLayout.Auto);
215 var res: [1]T = undefined;
216 try self.readNoEof(@sliceToBytes(res[0..]));
217 return res[0];
218 }
219 };
220}
22161
222pub fn OutStream(comptime WriteError: type) type {62pub fn OutStream(comptime WriteError: type) type {
223 return struct {63 return struct {
std/io/in_stream.zig created+200
...@@ -0,0 +1,200 @@
1const std = @import("../std.zig");
2const builtin = @import("builtin");
3const root = @import("root");
4const math = std.math;
5const assert = std.debug.assert;
6const mem = std.mem;
7const Buffer = std.Buffer;
8
9pub const default_stack_size = 4 * 1024 * 1024;
10pub const stack_size: usize = if (@hasDecl(root, "stack_size_std_io_InStream"))
11 root.stack_size_std_io_InStream
12else
13 default_stack_size;
14pub const stack_align = 16;
15
16pub fn InStream(comptime ReadError: type) type {
17 return struct {
18 const Self = @This();
19 pub const Error = ReadError;
20 pub const ReadFn = if (std.io.is_async)
21 async fn (self: *Self, buffer: []u8) Error!usize
22 else
23 fn (self: *Self, buffer: []u8) Error!usize;
24
25 /// Returns the number of bytes read. It may be less than buffer.len.
26 /// If the number of bytes read is 0, it means end of stream.
27 /// End of stream is not an error condition.
28 readFn: ReadFn,
29
30 /// Returns the number of bytes read. It may be less than buffer.len.
31 /// If the number of bytes read is 0, it means end of stream.
32 /// End of stream is not an error condition.
33 pub fn read(self: *Self, buffer: []u8) Error!usize {
34 if (std.io.is_async) {
35 var stack_frame: [stack_size]u8 align(stack_align) = undefined;
36 // TODO https://github.com/ziglang/zig/issues/3068
37 var result: Error!usize = undefined;
38 return await @asyncCall(&stack_frame, &result, self.readFn, self, buffer);
39 } else {
40 return self.readFn(self, buffer);
41 }
42 }
43
44 /// Returns the number of bytes read. If the number read is smaller than buf.len, it
45 /// means the stream reached the end. Reaching the end of a stream is not an error
46 /// condition.
47 pub fn readFull(self: *Self, buffer: []u8) Error!usize {
48 var index: usize = 0;
49 while (index != buffer.len) {
50 const amt = try self.read(buffer[index..]);
51 if (amt == 0) return index;
52 index += amt;
53 }
54 return index;
55 }
56
57 /// Returns the number of bytes read. If the number read would be smaller than buf.len,
58 /// error.EndOfStream is returned instead.
59 pub fn readNoEof(self: *Self, buf: []u8) !void {
60 const amt_read = try self.readFull(buf);
61 if (amt_read < buf.len) return error.EndOfStream;
62 }
63
64 /// Replaces `buffer` contents by reading from the stream until it is finished.
65 /// If `buffer.len()` would exceed `max_size`, `error.StreamTooLong` is returned and
66 /// the contents read from the stream are lost.
67 pub fn readAllBuffer(self: *Self, buffer: *Buffer, max_size: usize) !void {
68 try buffer.resize(0);
69
70 var actual_buf_len: usize = 0;
71 while (true) {
72 const dest_slice = buffer.toSlice()[actual_buf_len..];
73 const bytes_read = try self.readFull(dest_slice);
74 actual_buf_len += bytes_read;
75
76 if (bytes_read != dest_slice.len) {
77 buffer.shrink(actual_buf_len);
78 return;
79 }
80
81 const new_buf_size = math.min(max_size, actual_buf_len + mem.page_size);
82 if (new_buf_size == actual_buf_len) return error.StreamTooLong;
83 try buffer.resize(new_buf_size);
84 }
85 }
86
87 /// Allocates enough memory to hold all the contents of the stream. If the allocated
88 /// memory would be greater than `max_size`, returns `error.StreamTooLong`.
89 /// Caller owns returned memory.
90 /// If this function returns an error, the contents from the stream read so far are lost.
91 pub fn readAllAlloc(self: *Self, allocator: *mem.Allocator, max_size: usize) ![]u8 {
92 var buf = Buffer.initNull(allocator);
93 defer buf.deinit();
94
95 try self.readAllBuffer(&buf, max_size);
96 return buf.toOwnedSlice();
97 }
98
99 /// Replaces `buffer` contents by reading from the stream until `delimiter` is found.
100 /// Does not include the delimiter in the result.
101 /// If `buffer.len()` would exceed `max_size`, `error.StreamTooLong` is returned and the contents
102 /// read from the stream so far are lost.
103 pub fn readUntilDelimiterBuffer(self: *Self, buffer: *Buffer, delimiter: u8, max_size: usize) !void {
104 try buffer.resize(0);
105
106 while (true) {
107 var byte: u8 = try self.readByte();
108
109 if (byte == delimiter) {
110 return;
111 }
112
113 if (buffer.len() == max_size) {
114 return error.StreamTooLong;
115 }
116
117 try buffer.appendByte(byte);
118 }
119 }
120
121 /// Allocates enough memory to read until `delimiter`. If the allocated
122 /// memory would be greater than `max_size`, returns `error.StreamTooLong`.
123 /// Caller owns returned memory.
124 /// If this function returns an error, the contents from the stream read so far are lost.
125 pub fn readUntilDelimiterAlloc(self: *Self, allocator: *mem.Allocator, delimiter: u8, max_size: usize) ![]u8 {
126 var buf = Buffer.initNull(allocator);
127 defer buf.deinit();
128
129 try self.readUntilDelimiterBuffer(&buf, delimiter, max_size);
130 return buf.toOwnedSlice();
131 }
132
133 /// Reads 1 byte from the stream or returns `error.EndOfStream`.
134 pub fn readByte(self: *Self) !u8 {
135 var result: [1]u8 = undefined;
136 try self.readNoEof(result[0..]);
137 return result[0];
138 }
139
140 /// Same as `readByte` except the returned byte is signed.
141 pub fn readByteSigned(self: *Self) !i8 {
142 return @bitCast(i8, try self.readByte());
143 }
144
145 /// Reads a native-endian integer
146 pub fn readIntNative(self: *Self, comptime T: type) !T {
147 var bytes: [(T.bit_count + 7) / 8]u8 = undefined;
148 try self.readNoEof(bytes[0..]);
149 return mem.readIntNative(T, &bytes);
150 }
151
152 /// Reads a foreign-endian integer
153 pub fn readIntForeign(self: *Self, comptime T: type) !T {
154 var bytes: [(T.bit_count + 7) / 8]u8 = undefined;
155 try self.readNoEof(bytes[0..]);
156 return mem.readIntForeign(T, &bytes);
157 }
158
159 pub fn readIntLittle(self: *Self, comptime T: type) !T {
160 var bytes: [(T.bit_count + 7) / 8]u8 = undefined;
161 try self.readNoEof(bytes[0..]);
162 return mem.readIntLittle(T, &bytes);
163 }
164
165 pub fn readIntBig(self: *Self, comptime T: type) !T {
166 var bytes: [(T.bit_count + 7) / 8]u8 = undefined;
167 try self.readNoEof(bytes[0..]);
168 return mem.readIntBig(T, &bytes);
169 }
170
171 pub fn readInt(self: *Self, comptime T: type, endian: builtin.Endian) !T {
172 var bytes: [(T.bit_count + 7) / 8]u8 = undefined;
173 try self.readNoEof(bytes[0..]);
174 return mem.readInt(T, &bytes, endian);
175 }
176
177 pub fn readVarInt(self: *Self, comptime ReturnType: type, endian: builtin.Endian, size: usize) !ReturnType {
178 assert(size <= @sizeOf(ReturnType));
179 var bytes_buf: [@sizeOf(ReturnType)]u8 = undefined;
180 const bytes = bytes_buf[0..size];
181 try self.readNoEof(bytes);
182 return mem.readVarInt(ReturnType, bytes, endian);
183 }
184
185 pub fn skipBytes(self: *Self, num_bytes: u64) !void {
186 var i: u64 = 0;
187 while (i < num_bytes) : (i += 1) {
188 _ = try self.readByte();
189 }
190 }
191
192 pub fn readStruct(self: *Self, comptime T: type) !T {
193 // Only extern and packed structs have defined in-memory layout.
194 comptime assert(@typeInfo(T).Struct.layout != builtin.TypeInfo.ContainerLayout.Auto);
195 var res: [1]T = undefined;
196 try self.readNoEof(@sliceToBytes(res[0..]));
197 return res[0];
198 }
199 };
200}
std/json.zig+2-2
...@@ -989,7 +989,7 @@ test "json.validate" {...@@ -989,7 +989,7 @@ test "json.validate" {
989const Allocator = std.mem.Allocator;989const Allocator = std.mem.Allocator;
990const ArenaAllocator = std.heap.ArenaAllocator;990const ArenaAllocator = std.heap.ArenaAllocator;
991const ArrayList = std.ArrayList;991const ArrayList = std.ArrayList;
992const HashMap = std.HashMap;992const StringHashMap = std.StringHashMap;
993993
994pub const ValueTree = struct {994pub const ValueTree = struct {
995 arena: ArenaAllocator,995 arena: ArenaAllocator,
...@@ -1000,7 +1000,7 @@ pub const ValueTree = struct {...@@ -1000,7 +1000,7 @@ pub const ValueTree = struct {
1000 }1000 }
1001};1001};
10021002
1003pub const ObjectMap = HashMap([]const u8, Value, mem.hash_slice_u8, mem.eql_slice_u8);1003pub const ObjectMap = StringHashMap(Value);
10041004
1005pub const Value = union(enum) {1005pub const Value = union(enum) {
1006 Null,1006 Null,
std/mem.zig+13-25
...@@ -339,6 +339,7 @@ test "mem.lessThan" {...@@ -339,6 +339,7 @@ test "mem.lessThan" {
339/// Compares two slices and returns whether they are equal.339/// Compares two slices and returns whether they are equal.
340pub fn eql(comptime T: type, a: []const T, b: []const T) bool {340pub fn eql(comptime T: type, a: []const T, b: []const T) bool {
341 if (a.len != b.len) return false;341 if (a.len != b.len) return false;
342 if (a.ptr == b.ptr) return true;
342 for (a) |item, index| {343 for (a) |item, index| {
343 if (b[index] != item) return false;344 if (b[index] != item) return false;
344 }345 }
...@@ -738,47 +739,34 @@ test "writeIntBig and writeIntLittle" {...@@ -738,47 +739,34 @@ test "writeIntBig and writeIntLittle" {
738 var buf9: [9]u8 = undefined;739 var buf9: [9]u8 = undefined;
739740
740 writeIntBig(u0, &buf0, 0x0);741 writeIntBig(u0, &buf0, 0x0);
741 testing.expect(eql_slice_u8(buf0[0..], [_]u8{}));742 testing.expect(eql(u8, buf0[0..], [_]u8{}));
742 writeIntLittle(u0, &buf0, 0x0);743 writeIntLittle(u0, &buf0, 0x0);
743 testing.expect(eql_slice_u8(buf0[0..], [_]u8{}));744 testing.expect(eql(u8, buf0[0..], [_]u8{}));
744745
745 writeIntBig(u8, &buf1, 0x12);746 writeIntBig(u8, &buf1, 0x12);
746 testing.expect(eql_slice_u8(buf1[0..], [_]u8{0x12}));747 testing.expect(eql(u8, buf1[0..], [_]u8{0x12}));
747 writeIntLittle(u8, &buf1, 0x34);748 writeIntLittle(u8, &buf1, 0x34);
748 testing.expect(eql_slice_u8(buf1[0..], [_]u8{0x34}));749 testing.expect(eql(u8, buf1[0..], [_]u8{0x34}));
749750
750 writeIntBig(u16, &buf2, 0x1234);751 writeIntBig(u16, &buf2, 0x1234);
751 testing.expect(eql_slice_u8(buf2[0..], [_]u8{ 0x12, 0x34 }));752 testing.expect(eql(u8, buf2[0..], [_]u8{ 0x12, 0x34 }));
752 writeIntLittle(u16, &buf2, 0x5678);753 writeIntLittle(u16, &buf2, 0x5678);
753 testing.expect(eql_slice_u8(buf2[0..], [_]u8{ 0x78, 0x56 }));754 testing.expect(eql(u8, buf2[0..], [_]u8{ 0x78, 0x56 }));
754755
755 writeIntBig(u72, &buf9, 0x123456789abcdef024);756 writeIntBig(u72, &buf9, 0x123456789abcdef024);
756 testing.expect(eql_slice_u8(buf9[0..], [_]u8{ 0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0, 0x24 }));757 testing.expect(eql(u8, buf9[0..], [_]u8{ 0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0, 0x24 }));
757 writeIntLittle(u72, &buf9, 0xfedcba9876543210ec);758 writeIntLittle(u72, &buf9, 0xfedcba9876543210ec);
758 testing.expect(eql_slice_u8(buf9[0..], [_]u8{ 0xec, 0x10, 0x32, 0x54, 0x76, 0x98, 0xba, 0xdc, 0xfe }));759 testing.expect(eql(u8, buf9[0..], [_]u8{ 0xec, 0x10, 0x32, 0x54, 0x76, 0x98, 0xba, 0xdc, 0xfe }));
759760
760 writeIntBig(i8, &buf1, -1);761 writeIntBig(i8, &buf1, -1);
761 testing.expect(eql_slice_u8(buf1[0..], [_]u8{0xff}));762 testing.expect(eql(u8, buf1[0..], [_]u8{0xff}));
762 writeIntLittle(i8, &buf1, -2);763 writeIntLittle(i8, &buf1, -2);
763 testing.expect(eql_slice_u8(buf1[0..], [_]u8{0xfe}));764 testing.expect(eql(u8, buf1[0..], [_]u8{0xfe}));
764765
765 writeIntBig(i16, &buf2, -3);766 writeIntBig(i16, &buf2, -3);
766 testing.expect(eql_slice_u8(buf2[0..], [_]u8{ 0xff, 0xfd }));767 testing.expect(eql(u8, buf2[0..], [_]u8{ 0xff, 0xfd }));
767 writeIntLittle(i16, &buf2, -4);768 writeIntLittle(i16, &buf2, -4);
768 testing.expect(eql_slice_u8(buf2[0..], [_]u8{ 0xfc, 0xff }));769 testing.expect(eql(u8, buf2[0..], [_]u8{ 0xfc, 0xff }));
769}
770
771pub fn hash_slice_u8(k: []const u8) u32 {
772 // FNV 32-bit hash
773 var h: u32 = 2166136261;
774 for (k) |b| {
775 h = (h ^ b) *% 16777619;
776 }
777 return h;
778}
779
780pub fn eql_slice_u8(a: []const u8, b: []const u8) bool {
781 return eql(u8, a, b);
782}770}
783771
784/// Returns an iterator that iterates over the slices of `buffer` that are not772/// Returns an iterator that iterates over the slices of `buffer` that are not
std/meta.zig+2-1
...@@ -74,9 +74,10 @@ test "std.meta.stringToEnum" {...@@ -74,9 +74,10 @@ test "std.meta.stringToEnum" {
7474
75pub fn bitCount(comptime T: type) comptime_int {75pub fn bitCount(comptime T: type) comptime_int {
76 return switch (@typeInfo(T)) {76 return switch (@typeInfo(T)) {
77 TypeId.Bool => 1,
77 TypeId.Int => |info| info.bits,78 TypeId.Int => |info| info.bits,
78 TypeId.Float => |info| info.bits,79 TypeId.Float => |info| info.bits,
79 else => @compileError("Expected int or float type, found '" ++ @typeName(T) ++ "'"),80 else => @compileError("Expected bool, int or float type, found '" ++ @typeName(T) ++ "'"),
80 };81 };
81}82}
8283
std/os.zig+18-24
...@@ -254,13 +254,18 @@ pub const ReadError = error{...@@ -254,13 +254,18 @@ pub const ReadError = error{
254 IsDir,254 IsDir,
255 OperationAborted,255 OperationAborted,
256 BrokenPipe,256 BrokenPipe,
257
258 /// This error occurs when no global event loop is configured,
259 /// and reading from the file descriptor would block.
260 WouldBlock,
261
257 Unexpected,262 Unexpected,
258};263};
259264
260/// Returns the number of bytes that were read, which can be less than265/// Returns the number of bytes that were read, which can be less than
261/// buf.len. If 0 bytes were read, that means EOF.266/// buf.len. If 0 bytes were read, that means EOF.
262/// This function is for blocking file descriptors only. For non-blocking, see267/// If the application has a global event loop enabled, EAGAIN is handled
263/// `readAsync`.268/// via the event loop. Otherwise EAGAIN results in error.WouldBlock.
264pub fn read(fd: fd_t, buf: []u8) ReadError!usize {269pub fn read(fd: fd_t, buf: []u8) ReadError!usize {
265 if (windows.is_the_target) {270 if (windows.is_the_target) {
266 return windows.ReadFile(fd, buf);271 return windows.ReadFile(fd, buf);
...@@ -279,28 +284,19 @@ pub fn read(fd: fd_t, buf: []u8) ReadError!usize {...@@ -279,28 +284,19 @@ pub fn read(fd: fd_t, buf: []u8) ReadError!usize {
279 }284 }
280 }285 }
281286
282 // Linux can return EINVAL when read amount is > 0x7ffff000287 while (true) {
283 // See https://github.com/ziglang/zig/pull/743#issuecomment-363158274288 const rc = system.read(fd, buf.ptr, buf.len);
284 // TODO audit this. Shawn Landden says that this is not actually true.
285 // if this logic should stay, move it to std.os.linux
286 const max_buf_len = 0x7ffff000;
287
288 var index: usize = 0;
289 while (index < buf.len) {
290 const want_to_read = math.min(buf.len - index, usize(max_buf_len));
291 const rc = system.read(fd, buf.ptr + index, want_to_read);
292 switch (errno(rc)) {289 switch (errno(rc)) {
293 0 => {290 0 => return @intCast(usize, rc),
294 const amt_read = @intCast(usize, rc);
295 index += amt_read;
296 if (amt_read == want_to_read) continue;
297 // Read returned less than buf.len.
298 return index;
299 },
300 EINTR => continue,291 EINTR => continue,
301 EINVAL => unreachable,292 EINVAL => unreachable,
302 EFAULT => unreachable,293 EFAULT => unreachable,
303 EAGAIN => unreachable, // This function is for blocking reads.294 EAGAIN => if (std.event.Loop.instance) |loop| {
295 loop.waitUntilFdReadable(fd) catch return error.WouldBlock;
296 continue;
297 } else {
298 return error.WouldBlock;
299 },
304 EBADF => unreachable, // Always a race condition.300 EBADF => unreachable, // Always a race condition.
305 EIO => return error.InputOutput,301 EIO => return error.InputOutput,
306 EISDIR => return error.IsDir,302 EISDIR => return error.IsDir,
...@@ -313,8 +309,7 @@ pub fn read(fd: fd_t, buf: []u8) ReadError!usize {...@@ -313,8 +309,7 @@ pub fn read(fd: fd_t, buf: []u8) ReadError!usize {
313}309}
314310
315/// Number of bytes read is returned. Upon reading end-of-file, zero is returned.311/// Number of bytes read is returned. Upon reading end-of-file, zero is returned.
316/// This function is for blocking file descriptors only. For non-blocking, see312/// This function is for blocking file descriptors only.
317/// `preadvAsync`.
318pub fn preadv(fd: fd_t, iov: []const iovec, offset: u64) ReadError!usize {313pub fn preadv(fd: fd_t, iov: []const iovec, offset: u64) ReadError!usize {
319 if (darwin.is_the_target) {314 if (darwin.is_the_target) {
320 // Darwin does not have preadv but it does have pread.315 // Darwin does not have preadv but it does have pread.
...@@ -386,8 +381,7 @@ pub const WriteError = error{...@@ -386,8 +381,7 @@ pub const WriteError = error{
386};381};
387382
388/// Write to a file descriptor. Keeps trying if it gets interrupted.383/// Write to a file descriptor. Keeps trying if it gets interrupted.
389/// This function is for blocking file descriptors only. For non-blocking, see384/// This function is for blocking file descriptors only.
390/// `writeAsync`.
391pub fn write(fd: fd_t, bytes: []const u8) WriteError!void {385pub fn write(fd: fd_t, bytes: []const u8) WriteError!void {
392 if (windows.is_the_target) {386 if (windows.is_the_target) {
393 return windows.WriteFile(fd, bytes);387 return windows.WriteFile(fd, bytes);
std/os/bits/linux.zig+1
...@@ -7,6 +7,7 @@ pub usingnamespace @import("linux/errno.zig");...@@ -7,6 +7,7 @@ pub usingnamespace @import("linux/errno.zig");
7pub usingnamespace switch (builtin.arch) {7pub usingnamespace switch (builtin.arch) {
8 .x86_64 => @import("linux/x86_64.zig"),8 .x86_64 => @import("linux/x86_64.zig"),
9 .aarch64 => @import("linux/arm64.zig"),9 .aarch64 => @import("linux/arm64.zig"),
10 .arm => @import("linux/arm-eabi.zig"),
10 .riscv64 => @import("linux/riscv64.zig"),11 .riscv64 => @import("linux/riscv64.zig"),
11 else => struct {},12 else => struct {},
12};13};
std/os/bits/linux/arm-eabi.zig created+573
...@@ -0,0 +1,573 @@
1// arm-eabi-specific declarations that are intended to be imported into the POSIX namespace.
2
3const std = @import("../../std.zig");
4const linux = std.os.linux;
5const socklen_t = linux.socklen_t;
6const iovec = linux.iovec;
7const iovec_const = linux.iovec_const;
8
9pub const SYS_restart_syscall = 0;
10pub const SYS_exit = 1;
11pub const SYS_fork = 2;
12pub const SYS_read = 3;
13pub const SYS_write = 4;
14pub const SYS_open = 5;
15pub const SYS_close = 6;
16pub const SYS_creat = 8;
17pub const SYS_link = 9;
18pub const SYS_unlink = 10;
19pub const SYS_execve = 11;
20pub const SYS_chdir = 12;
21pub const SYS_mknod = 14;
22pub const SYS_chmod = 15;
23pub const SYS_lchown = 16;
24pub const SYS_lseek = 19;
25pub const SYS_getpid = 20;
26pub const SYS_mount = 21;
27pub const SYS_setuid = 23;
28pub const SYS_getuid = 24;
29pub const SYS_ptrace = 26;
30pub const SYS_pause = 29;
31pub const SYS_access = 33;
32pub const SYS_nice = 34;
33pub const SYS_sync = 36;
34pub const SYS_kill = 37;
35pub const SYS_rename = 38;
36pub const SYS_mkdir = 39;
37pub const SYS_rmdir = 40;
38pub const SYS_dup = 41;
39pub const SYS_pipe = 42;
40pub const SYS_times = 43;
41pub const SYS_brk = 45;
42pub const SYS_setgid = 46;
43pub const SYS_getgid = 47;
44pub const SYS_geteuid = 49;
45pub const SYS_getegid = 50;
46pub const SYS_acct = 51;
47pub const SYS_umount2 = 52;
48pub const SYS_ioctl = 54;
49pub const SYS_fcntl = 55;
50pub const SYS_setpgid = 57;
51pub const SYS_umask = 60;
52pub const SYS_chroot = 61;
53pub const SYS_ustat = 62;
54pub const SYS_dup2 = 63;
55pub const SYS_getppid = 64;
56pub const SYS_getpgrp = 65;
57pub const SYS_setsid = 66;
58pub const SYS_sigaction = 67;
59pub const SYS_setreuid = 70;
60pub const SYS_setregid = 71;
61pub const SYS_sigsuspend = 72;
62pub const SYS_sigpending = 73;
63pub const SYS_sethostname = 74;
64pub const SYS_setrlimit = 75;
65pub const SYS_getrusage = 77;
66pub const SYS_gettimeofday = 78;
67pub const SYS_settimeofday = 79;
68pub const SYS_getgroups = 80;
69pub const SYS_setgroups = 81;
70pub const SYS_symlink = 83;
71pub const SYS_readlink = 85;
72pub const SYS_uselib = 86;
73pub const SYS_swapon = 87;
74pub const SYS_reboot = 88;
75pub const SYS_munmap = 91;
76pub const SYS_truncate = 92;
77pub const SYS_ftruncate = 93;
78pub const SYS_fchmod = 94;
79pub const SYS_fchown = 95;
80pub const SYS_getpriority = 96;
81pub const SYS_setpriority = 97;
82pub const SYS_statfs = 99;
83pub const SYS_fstatfs = 100;
84pub const SYS_syslog = 103;
85pub const SYS_setitimer = 104;
86pub const SYS_getitimer = 105;
87pub const SYS_stat = 106;
88pub const SYS_lstat = 107;
89pub const SYS_fstat = 108;
90pub const SYS_vhangup = 111;
91pub const SYS_wait4 = 114;
92pub const SYS_swapoff = 115;
93pub const SYS_sysinfo = 116;
94pub const SYS_fsync = 118;
95pub const SYS_sigreturn = 119;
96pub const SYS_clone = 120;
97pub const SYS_setdomainname = 121;
98pub const SYS_uname = 122;
99pub const SYS_adjtimex = 124;
100pub const SYS_mprotect = 125;
101pub const SYS_sigprocmask = 126;
102pub const SYS_init_module = 128;
103pub const SYS_delete_module = 129;
104pub const SYS_quotactl = 131;
105pub const SYS_getpgid = 132;
106pub const SYS_fchdir = 133;
107pub const SYS_bdflush = 134;
108pub const SYS_sysfs = 135;
109pub const SYS_personality = 136;
110pub const SYS_setfsuid = 138;
111pub const SYS_setfsgid = 139;
112pub const SYS__llseek = 140;
113pub const SYS_getdents = 141;
114pub const SYS__newselect = 142;
115pub const SYS_flock = 143;
116pub const SYS_msync = 144;
117pub const SYS_readv = 145;
118pub const SYS_writev = 146;
119pub const SYS_getsid = 147;
120pub const SYS_fdatasync = 148;
121pub const SYS__sysctl = 149;
122pub const SYS_mlock = 150;
123pub const SYS_munlock = 151;
124pub const SYS_mlockall = 152;
125pub const SYS_munlockall = 153;
126pub const SYS_sched_setparam = 154;
127pub const SYS_sched_getparam = 155;
128pub const SYS_sched_setscheduler = 156;
129pub const SYS_sched_getscheduler = 157;
130pub const SYS_sched_yield = 158;
131pub const SYS_sched_get_priority_max = 159;
132pub const SYS_sched_get_priority_min = 160;
133pub const SYS_sched_rr_get_interval = 161;
134pub const SYS_nanosleep = 162;
135pub const SYS_mremap = 163;
136pub const SYS_setresuid = 164;
137pub const SYS_getresuid = 165;
138pub const SYS_poll = 168;
139pub const SYS_nfsservctl = 169;
140pub const SYS_setresgid = 170;
141pub const SYS_getresgid = 171;
142pub const SYS_prctl = 172;
143pub const SYS_rt_sigreturn = 173;
144pub const SYS_rt_sigaction = 174;
145pub const SYS_rt_sigprocmask = 175;
146pub const SYS_rt_sigpending = 176;
147pub const SYS_rt_sigtimedwait = 177;
148pub const SYS_rt_sigqueueinfo = 178;
149pub const SYS_rt_sigsuspend = 179;
150pub const SYS_pread64 = 180;
151pub const SYS_pwrite64 = 181;
152pub const SYS_chown = 182;
153pub const SYS_getcwd = 183;
154pub const SYS_capget = 184;
155pub const SYS_capset = 185;
156pub const SYS_sigaltstack = 186;
157pub const SYS_sendfile = 187;
158pub const SYS_vfork = 190;
159pub const SYS_ugetrlimit = 191;
160pub const SYS_mmap2 = 192;
161pub const SYS_truncate64 = 193;
162pub const SYS_ftruncate64 = 194;
163pub const SYS_stat64 = 195;
164pub const SYS_lstat64 = 196;
165pub const SYS_fstat64 = 197;
166pub const SYS_lchown32 = 198;
167pub const SYS_getuid32 = 199;
168pub const SYS_getgid32 = 200;
169pub const SYS_geteuid32 = 201;
170pub const SYS_getegid32 = 202;
171pub const SYS_setreuid32 = 203;
172pub const SYS_setregid32 = 204;
173pub const SYS_getgroups32 = 205;
174pub const SYS_setgroups32 = 206;
175pub const SYS_fchown32 = 207;
176pub const SYS_setresuid32 = 208;
177pub const SYS_getresuid32 = 209;
178pub const SYS_setresgid32 = 210;
179pub const SYS_getresgid32 = 211;
180pub const SYS_chown32 = 212;
181pub const SYS_setuid32 = 213;
182pub const SYS_setgid32 = 214;
183pub const SYS_setfsuid32 = 215;
184pub const SYS_setfsgid32 = 216;
185pub const SYS_getdents64 = 217;
186pub const SYS_pivot_root = 218;
187pub const SYS_mincore = 219;
188pub const SYS_madvise = 220;
189pub const SYS_fcntl64 = 221;
190pub const SYS_gettid = 224;
191pub const SYS_readahead = 225;
192pub const SYS_setxattr = 226;
193pub const SYS_lsetxattr = 227;
194pub const SYS_fsetxattr = 228;
195pub const SYS_getxattr = 229;
196pub const SYS_lgetxattr = 230;
197pub const SYS_fgetxattr = 231;
198pub const SYS_listxattr = 232;
199pub const SYS_llistxattr = 233;
200pub const SYS_flistxattr = 234;
201pub const SYS_removexattr = 235;
202pub const SYS_lremovexattr = 236;
203pub const SYS_fremovexattr = 237;
204pub const SYS_tkill = 238;
205pub const SYS_sendfile64 = 239;
206pub const SYS_futex = 240;
207pub const SYS_sched_setaffinity = 241;
208pub const SYS_sched_getaffinity = 242;
209pub const SYS_io_setup = 243;
210pub const SYS_io_destroy = 244;
211pub const SYS_io_getevents = 245;
212pub const SYS_io_submit = 246;
213pub const SYS_io_cancel = 247;
214pub const SYS_exit_group = 248;
215pub const SYS_lookup_dcookie = 249;
216pub const SYS_epoll_create = 250;
217pub const SYS_epoll_ctl = 251;
218pub const SYS_epoll_wait = 252;
219pub const SYS_remap_file_pages = 253;
220pub const SYS_set_tid_address = 256;
221pub const SYS_timer_create = 257;
222pub const SYS_timer_settime = 258;
223pub const SYS_timer_gettime = 259;
224pub const SYS_timer_getoverrun = 260;
225pub const SYS_timer_delete = 261;
226pub const SYS_clock_settime = 262;
227pub const SYS_clock_gettime = 263;
228pub const SYS_clock_getres = 264;
229pub const SYS_clock_nanosleep = 265;
230pub const SYS_statfs64 = 266;
231pub const SYS_fstatfs64 = 267;
232pub const SYS_tgkill = 268;
233pub const SYS_utimes = 269;
234pub const SYS_fadvise64_64 = 270;
235pub const SYS_arm_fadvise64_64 = 270;
236pub const SYS_pciconfig_iobase = 271;
237pub const SYS_pciconfig_read = 272;
238pub const SYS_pciconfig_write = 273;
239pub const SYS_mq_open = 274;
240pub const SYS_mq_unlink = 275;
241pub const SYS_mq_timedsend = 276;
242pub const SYS_mq_timedreceive = 277;
243pub const SYS_mq_notify = 278;
244pub const SYS_mq_getsetattr = 279;
245pub const SYS_waitid = 280;
246pub const SYS_socket = 281;
247pub const SYS_bind = 282;
248pub const SYS_connect = 283;
249pub const SYS_listen = 284;
250pub const SYS_accept = 285;
251pub const SYS_getsockname = 286;
252pub const SYS_getpeername = 287;
253pub const SYS_socketpair = 288;
254pub const SYS_send = 289;
255pub const SYS_sendto = 290;
256pub const SYS_recv = 291;
257pub const SYS_recvfrom = 292;
258pub const SYS_shutdown = 293;
259pub const SYS_setsockopt = 294;
260pub const SYS_getsockopt = 295;
261pub const SYS_sendmsg = 296;
262pub const SYS_recvmsg = 297;
263pub const SYS_semop = 298;
264pub const SYS_semget = 299;
265pub const SYS_semctl = 300;
266pub const SYS_msgsnd = 301;
267pub const SYS_msgrcv = 302;
268pub const SYS_msgget = 303;
269pub const SYS_msgctl = 304;
270pub const SYS_shmat = 305;
271pub const SYS_shmdt = 306;
272pub const SYS_shmget = 307;
273pub const SYS_shmctl = 308;
274pub const SYS_add_key = 309;
275pub const SYS_request_key = 310;
276pub const SYS_keyctl = 311;
277pub const SYS_semtimedop = 312;
278pub const SYS_vserver = 313;
279pub const SYS_ioprio_set = 314;
280pub const SYS_ioprio_get = 315;
281pub const SYS_inotify_init = 316;
282pub const SYS_inotify_add_watch = 317;
283pub const SYS_inotify_rm_watch = 318;
284pub const SYS_mbind = 319;
285pub const SYS_get_mempolicy = 320;
286pub const SYS_set_mempolicy = 321;
287pub const SYS_openat = 322;
288pub const SYS_mkdirat = 323;
289pub const SYS_mknodat = 324;
290pub const SYS_fchownat = 325;
291pub const SYS_futimesat = 326;
292pub const SYS_fstatat64 = 327;
293pub const SYS_unlinkat = 328;
294pub const SYS_renameat = 329;
295pub const SYS_linkat = 330;
296pub const SYS_symlinkat = 331;
297pub const SYS_readlinkat = 332;
298pub const SYS_fchmodat = 333;
299pub const SYS_faccessat = 334;
300pub const SYS_pselect6 = 335;
301pub const SYS_ppoll = 336;
302pub const SYS_unshare = 337;
303pub const SYS_set_robust_list = 338;
304pub const SYS_get_robust_list = 339;
305pub const SYS_splice = 340;
306pub const SYS_sync_file_range2 = 341;
307pub const SYS_arm_sync_file_range = 341;
308pub const SYS_tee = 342;
309pub const SYS_vmsplice = 343;
310pub const SYS_move_pages = 344;
311pub const SYS_getcpu = 345;
312pub const SYS_epoll_pwait = 346;
313pub const SYS_kexec_load = 347;
314pub const SYS_utimensat = 348;
315pub const SYS_signalfd = 349;
316pub const SYS_timerfd_create = 350;
317pub const SYS_eventfd = 351;
318pub const SYS_fallocate = 352;
319pub const SYS_timerfd_settime = 353;
320pub const SYS_timerfd_gettime = 354;
321pub const SYS_signalfd4 = 355;
322pub const SYS_eventfd2 = 356;
323pub const SYS_epoll_create1 = 357;
324pub const SYS_dup3 = 358;
325pub const SYS_pipe2 = 359;
326pub const SYS_inotify_init1 = 360;
327pub const SYS_preadv = 361;
328pub const SYS_pwritev = 362;
329pub const SYS_rt_tgsigqueueinfo = 363;
330pub const SYS_perf_event_open = 364;
331pub const SYS_recvmmsg = 365;
332pub const SYS_accept4 = 366;
333pub const SYS_fanotify_init = 367;
334pub const SYS_fanotify_mark = 368;
335pub const SYS_prlimit64 = 369;
336pub const SYS_name_to_handle_at = 370;
337pub const SYS_open_by_handle_at = 371;
338pub const SYS_clock_adjtime = 372;
339pub const SYS_syncfs = 373;
340pub const SYS_sendmmsg = 374;
341pub const SYS_setns = 375;
342pub const SYS_process_vm_readv = 376;
343pub const SYS_process_vm_writev = 377;
344pub const SYS_kcmp = 378;
345pub const SYS_finit_module = 379;
346pub const SYS_sched_setattr = 380;
347pub const SYS_sched_getattr = 381;
348pub const SYS_renameat2 = 382;
349pub const SYS_seccomp = 383;
350pub const SYS_getrandom = 384;
351pub const SYS_memfd_create = 385;
352pub const SYS_bpf = 386;
353pub const SYS_execveat = 387;
354pub const SYS_userfaultfd = 388;
355pub const SYS_membarrier = 389;
356pub const SYS_mlock2 = 390;
357pub const SYS_copy_file_range = 391;
358pub const SYS_preadv2 = 392;
359pub const SYS_pwritev2 = 393;
360pub const SYS_pkey_mprotect = 394;
361pub const SYS_pkey_alloc = 395;
362pub const SYS_pkey_free = 396;
363pub const SYS_statx = 397;
364pub const SYS_rseq = 398;
365pub const SYS_io_pgetevents = 399;
366pub const SYS_migrate_pages = 400;
367pub const SYS_kexec_file_load = 401;
368pub const SYS_clock_gettime64 = 403;
369pub const SYS_clock_settime64 = 404;
370pub const SYS_clock_adjtime64 = 405;
371pub const SYS_clock_getres_time64 = 406;
372pub const SYS_clock_nanosleep_time64 = 407;
373pub const SYS_timer_gettime64 = 408;
374pub const SYS_timer_settime64 = 409;
375pub const SYS_timerfd_gettime64 = 410;
376pub const SYS_timerfd_settime64 = 411;
377pub const SYS_utimensat_time64 = 412;
378pub const SYS_pselect6_time64 = 413;
379pub const SYS_ppoll_time64 = 414;
380pub const SYS_io_pgetevents_time64 = 416;
381pub const SYS_recvmmsg_time64 = 417;
382pub const SYS_mq_timedsend_time64 = 418;
383pub const SYS_mq_timedreceive_time64 = 419;
384pub const SYS_semtimedop_time64 = 420;
385pub const SYS_rt_sigtimedwait_time64 = 421;
386pub const SYS_futex_time64 = 422;
387pub const SYS_sched_rr_get_interval_time64 = 423;
388pub const SYS_pidfd_send_signal = 424;
389pub const SYS_io_uring_setup = 425;
390pub const SYS_io_uring_enter = 426;
391pub const SYS_io_uring_register = 427;
392
393pub const SYS_breakpoint = 0x0f0001;
394pub const SYS_cacheflush = 0x0f0002;
395pub const SYS_usr26 = 0x0f0003;
396pub const SYS_usr32 = 0x0f0004;
397pub const SYS_set_tls = 0x0f0005;
398pub const SYS_get_tls = 0x0f0006;
399
400pub const MMAP2_UNIT = 4096;
401
402pub const O_CREAT = 0o100;
403pub const O_EXCL = 0o200;
404pub const O_NOCTTY = 0o400;
405pub const O_TRUNC = 0o1000;
406pub const O_APPEND = 0o2000;
407pub const O_NONBLOCK = 0o4000;
408pub const O_DSYNC = 0o10000;
409pub const O_SYNC = 0o4010000;
410pub const O_RSYNC = 0o4010000;
411pub const O_DIRECTORY = 0o40000;
412pub const O_NOFOLLOW = 0o100000;
413pub const O_CLOEXEC = 0o2000000;
414
415pub const O_ASYNC = 0o20000;
416pub const O_DIRECT = 0o200000;
417pub const O_LARGEFILE = 0o400000;
418pub const O_NOATIME = 0o1000000;
419pub const O_PATH = 0o10000000;
420pub const O_TMPFILE = 0o20040000;
421pub const O_NDELAY = O_NONBLOCK;
422
423pub const F_DUPFD = 0;
424pub const F_GETFD = 1;
425pub const F_SETFD = 2;
426pub const F_GETFL = 3;
427pub const F_SETFL = 4;
428
429pub const F_SETOWN = 8;
430pub const F_GETOWN = 9;
431pub const F_SETSIG = 10;
432pub const F_GETSIG = 11;
433
434pub const F_GETLK = 12;
435pub const F_SETLK = 13;
436pub const F_SETLKW = 14;
437
438pub const F_SETOWN_EX = 15;
439pub const F_GETOWN_EX = 16;
440
441pub const F_GETOWNER_UIDS = 17;
442
443/// stack-like segment
444pub const MAP_GROWSDOWN = 0x0100;
445
446/// ETXTBSY
447pub const MAP_DENYWRITE = 0x0800;
448
449/// mark it as an executable
450pub const MAP_EXECUTABLE = 0x1000;
451
452/// pages are locked
453pub const MAP_LOCKED = 0x2000;
454
455/// don't check for reservations
456pub const MAP_NORESERVE = 0x4000;
457
458/// populate (prefault) pagetables
459pub const MAP_POPULATE = 0x8000;
460
461/// do not block on IO
462pub const MAP_NONBLOCK = 0x10000;
463
464/// give out an address that is best suited for process/thread stacks
465pub const MAP_STACK = 0x20000;
466
467/// create a huge page mapping
468pub const MAP_HUGETLB = 0x40000;
469
470/// perform synchronous page faults for the mapping
471pub const MAP_SYNC = 0x80000;
472
473pub const VDSO_USEFUL = true;
474pub const VDSO_CGT_SYM = "__vdso_clock_gettime";
475pub const VDSO_CGT_VER = "LINUX_2.6";
476
477pub const HWCAP_SWP = 1 << 0;
478pub const HWCAP_HALF = 1 << 1;
479pub const HWCAP_THUMB = 1 << 2;
480pub const HWCAP_26BIT = 1 << 3;
481pub const HWCAP_FAST_MULT = 1 << 4;
482pub const HWCAP_FPA = 1 << 5;
483pub const HWCAP_VFP = 1 << 6;
484pub const HWCAP_EDSP = 1 << 7;
485pub const HWCAP_JAVA = 1 << 8;
486pub const HWCAP_IWMMXT = 1 << 9;
487pub const HWCAP_CRUNCH = 1 << 10;
488pub const HWCAP_THUMBEE = 1 << 11;
489pub const HWCAP_NEON = 1 << 12;
490pub const HWCAP_VFPv3 = 1 << 13;
491pub const HWCAP_VFPv3D16 = 1 << 14;
492pub const HWCAP_TLS = 1 << 15;
493pub const HWCAP_VFPv4 = 1 << 16;
494pub const HWCAP_IDIVA = 1 << 17;
495pub const HWCAP_IDIVT = 1 << 18;
496pub const HWCAP_VFPD32 = 1 << 19;
497pub const HWCAP_IDIV = HWCAP_IDIVA | HWCAP_IDIVT;
498pub const HWCAP_LPAE = 1 << 20;
499pub const HWCAP_EVTSTRM = 1 << 21;
500
501pub const msghdr = extern struct {
502 msg_name: ?*sockaddr,
503 msg_namelen: socklen_t,
504 msg_iov: [*]iovec,
505 msg_iovlen: i32,
506 msg_control: ?*c_void,
507 msg_controllen: socklen_t,
508 msg_flags: i32,
509};
510
511pub const msghdr_const = extern struct {
512 msg_name: ?*const sockaddr,
513 msg_namelen: socklen_t,
514 msg_iov: [*]iovec_const,
515 msg_iovlen: i32,
516 msg_control: ?*c_void,
517 msg_controllen: socklen_t,
518 msg_flags: i32,
519};
520
521/// Renamed to Stat to not conflict with the stat function.
522/// atime, mtime, and ctime have functions to return `timespec`,
523/// because although this is a POSIX API, the layout and names of
524/// the structs are inconsistent across operating systems, and
525/// in C, macros are used to hide the differences. Here we use
526/// methods to accomplish this.
527pub const Stat = extern struct {
528 dev: u64,
529 __dev_padding: u32,
530 __ino_truncated: u32,
531 mode: u32,
532 nlink: u32,
533 uid: u32,
534 gid: u32,
535 rdev: u64,
536 __rdev_padding: u32,
537 size: i64,
538 blksize: i32,
539 blocks: u64,
540 atim: timespec,
541 mtim: timespec,
542 ctim: timespec,
543 ino: u64,
544
545 pub fn atime(self: Stat) timespec {
546 return self.atim;
547 }
548
549 pub fn mtime(self: Stat) timespec {
550 return self.mtim;
551 }
552
553 pub fn ctime(self: Stat) timespec {
554 return self.ctim;
555 }
556};
557
558pub const timespec = extern struct {
559 tv_sec: i32,
560 tv_nsec: i32,
561};
562
563pub const timeval = extern struct {
564 tv_sec: i32,
565 tv_usec: i32,
566};
567
568pub const timezone = extern struct {
569 tz_minuteswest: i32,
570 tz_dsttime: i32,
571};
572
573pub const Elf_Symndx = u32;
std/os/linux.zig+132-25
...@@ -17,6 +17,7 @@ pub const is_the_target = builtin.os == .linux;...@@ -17,6 +17,7 @@ pub const is_the_target = builtin.os == .linux;
17pub usingnamespace switch (builtin.arch) {17pub usingnamespace switch (builtin.arch) {
18 .x86_64 => @import("linux/x86_64.zig"),18 .x86_64 => @import("linux/x86_64.zig"),
19 .aarch64 => @import("linux/arm64.zig"),19 .aarch64 => @import("linux/arm64.zig"),
20 .arm => @import("linux/arm-eabi.zig"),
20 .riscv64 => @import("linux/riscv64.zig"),21 .riscv64 => @import("linux/riscv64.zig"),
21 else => struct {},22 else => struct {},
22};23};
...@@ -190,7 +191,11 @@ pub fn umount2(special: [*]const u8, flags: u32) usize {...@@ -190,7 +191,11 @@ pub fn umount2(special: [*]const u8, flags: u32) usize {
190}191}
191192
192pub fn mmap(address: ?[*]u8, length: usize, prot: usize, flags: u32, fd: i32, offset: isize) usize {193pub fn mmap(address: ?[*]u8, length: usize, prot: usize, flags: u32, fd: i32, offset: isize) usize {
193 return syscall6(SYS_mmap, @ptrToInt(address), length, prot, flags, @bitCast(usize, isize(fd)), @bitCast(usize, offset));194 if (@hasDecl(@This(), "SYS_mmap2")) {
195 return syscall6(SYS_mmap2, @ptrToInt(address), length, prot, flags, @bitCast(usize, isize(fd)), @bitCast(usize, @divTrunc(offset, MMAP2_UNIT)));
196 } else {
197 return syscall6(SYS_mmap, @ptrToInt(address), length, prot, flags, @bitCast(usize, isize(fd)), @bitCast(usize, offset));
198 }
194}199}
195200
196pub fn mprotect(address: [*]const u8, length: usize, protection: usize) usize {201pub fn mprotect(address: [*]const u8, length: usize, protection: usize) usize {
...@@ -206,11 +211,26 @@ pub fn read(fd: i32, buf: [*]u8, count: usize) usize {...@@ -206,11 +211,26 @@ pub fn read(fd: i32, buf: [*]u8, count: usize) usize {
206}211}
207212
208pub fn preadv(fd: i32, iov: [*]const iovec, count: usize, offset: u64) usize {213pub fn preadv(fd: i32, iov: [*]const iovec, count: usize, offset: u64) usize {
209 return syscall4(SYS_preadv, @bitCast(usize, isize(fd)), @ptrToInt(iov), count, offset);214 return syscall5(
215 SYS_preadv,
216 @bitCast(usize, isize(fd)),
217 @ptrToInt(iov),
218 count,
219 @truncate(usize, offset),
220 @truncate(usize, offset >> 32),
221 );
210}222}
211223
212pub fn preadv2(fd: i32, iov: [*]const iovec, count: usize, offset: u64, flags: kernel_rwf) usize {224pub fn preadv2(fd: i32, iov: [*]const iovec, count: usize, offset: u64, flags: kernel_rwf) usize {
213 return syscall5(SYS_preadv2, @bitCast(usize, isize(fd)), @ptrToInt(iov), count, offset, flags);225 return syscall6(
226 SYS_preadv2,
227 @bitCast(usize, isize(fd)),
228 @ptrToInt(iov),
229 count,
230 @truncate(usize, offset),
231 @truncate(usize, offset >> 32),
232 flags,
233 );
214}234}
215235
216pub fn readv(fd: i32, iov: [*]const iovec, count: usize) usize {236pub fn readv(fd: i32, iov: [*]const iovec, count: usize) usize {
...@@ -222,11 +242,26 @@ pub fn writev(fd: i32, iov: [*]const iovec_const, count: usize) usize {...@@ -222,11 +242,26 @@ pub fn writev(fd: i32, iov: [*]const iovec_const, count: usize) usize {
222}242}
223243
224pub fn pwritev(fd: i32, iov: [*]const iovec_const, count: usize, offset: u64) usize {244pub fn pwritev(fd: i32, iov: [*]const iovec_const, count: usize, offset: u64) usize {
225 return syscall4(SYS_pwritev, @bitCast(usize, isize(fd)), @ptrToInt(iov), count, offset);245 return syscall5(
246 SYS_pwritev,
247 @bitCast(usize, isize(fd)),
248 @ptrToInt(iov),
249 count,
250 @truncate(usize, offset),
251 @truncate(usize, offset >> 32),
252 );
226}253}
227254
228pub fn pwritev2(fd: i32, iov: [*]const iovec_const, count: usize, offset: u64, flags: kernel_rwf) usize {255pub fn pwritev2(fd: i32, iov: [*]const iovec_const, count: usize, offset: u64, flags: kernel_rwf) usize {
229 return syscall5(SYS_pwritev2, @bitCast(usize, isize(fd)), @ptrToInt(iov), count, offset, flags);256 return syscall6(
257 SYS_pwritev2,
258 @bitCast(usize, isize(fd)),
259 @ptrToInt(iov),
260 count,
261 @truncate(usize, offset),
262 @truncate(usize, offset >> 32),
263 flags,
264 );
230}265}
231266
232// TODO https://github.com/ziglang/zig/issues/265267// TODO https://github.com/ziglang/zig/issues/265
...@@ -482,67 +517,123 @@ pub fn nanosleep(req: *const timespec, rem: ?*timespec) usize {...@@ -482,67 +517,123 @@ pub fn nanosleep(req: *const timespec, rem: ?*timespec) usize {
482}517}
483518
484pub fn setuid(uid: u32) usize {519pub fn setuid(uid: u32) usize {
485 return syscall1(SYS_setuid, uid);520 if (@hasDecl(@This(), "SYS_setuid32")) {
521 return syscall1(SYS_setuid32, uid);
522 } else {
523 return syscall1(SYS_setuid, uid);
524 }
486}525}
487526
488pub fn setgid(gid: u32) usize {527pub fn setgid(gid: u32) usize {
489 return syscall1(SYS_setgid, gid);528 if (@hasDecl(@This(), "SYS_setgid32")) {
529 return syscall1(SYS_setgid32, gid);
530 } else {
531 return syscall1(SYS_setgid, gid);
532 }
490}533}
491534
492pub fn setreuid(ruid: u32, euid: u32) usize {535pub fn setreuid(ruid: u32, euid: u32) usize {
493 return syscall2(SYS_setreuid, ruid, euid);536 if (@hasDecl(@This(), "SYS_setreuid32")) {
537 return syscall2(SYS_setreuid32, ruid, euid);
538 } else {
539 return syscall2(SYS_setreuid, ruid, euid);
540 }
494}541}
495542
496pub fn setregid(rgid: u32, egid: u32) usize {543pub fn setregid(rgid: u32, egid: u32) usize {
497 return syscall2(SYS_setregid, rgid, egid);544 if (@hasDecl(@This(), "SYS_setregid32")) {
545 return syscall2(SYS_setregid32, rgid, egid);
546 } else {
547 return syscall2(SYS_setregid, rgid, egid);
548 }
498}549}
499550
500pub fn getuid() u32 {551pub fn getuid() u32 {
501 return u32(syscall0(SYS_getuid));552 if (@hasDecl(@This(), "SYS_getuid32")) {
553 return u32(syscall0(SYS_getuid32));
554 } else {
555 return u32(syscall0(SYS_getuid));
556 }
502}557}
503558
504pub fn getgid() u32 {559pub fn getgid() u32 {
505 return u32(syscall0(SYS_getgid));560 if (@hasDecl(@This(), "SYS_getgid32")) {
561 return u32(syscall0(SYS_getgid32));
562 } else {
563 return u32(syscall0(SYS_getgid));
564 }
506}565}
507566
508pub fn geteuid() u32 {567pub fn geteuid() u32 {
509 return u32(syscall0(SYS_geteuid));568 if (@hasDecl(@This(), "SYS_geteuid32")) {
569 return u32(syscall0(SYS_geteuid32));
570 } else {
571 return u32(syscall0(SYS_geteuid));
572 }
510}573}
511574
512pub fn getegid() u32 {575pub fn getegid() u32 {
513 return u32(syscall0(SYS_getegid));576 if (@hasDecl(@This(), "SYS_getegid32")) {
577 return u32(syscall0(SYS_getegid32));
578 } else {
579 return u32(syscall0(SYS_getegid));
580 }
514}581}
515582
516pub fn seteuid(euid: u32) usize {583pub fn seteuid(euid: u32) usize {
517 return syscall1(SYS_seteuid, euid);584 return setreuid(std.math.maxInt(u32), euid);
518}585}
519586
520pub fn setegid(egid: u32) usize {587pub fn setegid(egid: u32) usize {
521 return syscall1(SYS_setegid, egid);588 return setregid(std.math.maxInt(u32), egid);
522}589}
523590
524pub fn getresuid(ruid: *u32, euid: *u32, suid: *u32) usize {591pub fn getresuid(ruid: *u32, euid: *u32, suid: *u32) usize {
525 return syscall3(SYS_getresuid, @ptrToInt(ruid), @ptrToInt(euid), @ptrToInt(suid));592 if (@hasDecl(@This(), "SYS_getresuid32")) {
593 return syscall3(SYS_getresuid32, @ptrToInt(ruid), @ptrToInt(euid), @ptrToInt(suid));
594 } else {
595 return syscall3(SYS_getresuid, @ptrToInt(ruid), @ptrToInt(euid), @ptrToInt(suid));
596 }
526}597}
527598
528pub fn getresgid(rgid: *u32, egid: *u32, sgid: *u32) usize {599pub fn getresgid(rgid: *u32, egid: *u32, sgid: *u32) usize {
529 return syscall3(SYS_getresgid, @ptrToInt(rgid), @ptrToInt(egid), @ptrToInt(sgid));600 if (@hasDecl(@This(), "SYS_getresgid32")) {
601 return syscall3(SYS_getresgid32, @ptrToInt(rgid), @ptrToInt(egid), @ptrToInt(sgid));
602 } else {
603 return syscall3(SYS_getresgid, @ptrToInt(rgid), @ptrToInt(egid), @ptrToInt(sgid));
604 }
530}605}
531606
532pub fn setresuid(ruid: u32, euid: u32, suid: u32) usize {607pub fn setresuid(ruid: u32, euid: u32, suid: u32) usize {
533 return syscall3(SYS_setresuid, ruid, euid, suid);608 if (@hasDecl(@This(), "SYS_setresuid32")) {
609 return syscall3(SYS_setresuid32, ruid, euid, suid);
610 } else {
611 return syscall3(SYS_setresuid, ruid, euid, suid);
612 }
534}613}
535614
536pub fn setresgid(rgid: u32, egid: u32, sgid: u32) usize {615pub fn setresgid(rgid: u32, egid: u32, sgid: u32) usize {
537 return syscall3(SYS_setresgid, rgid, egid, sgid);616 if (@hasDecl(@This(), "SYS_setresgid32")) {
617 return syscall3(SYS_setresgid32, rgid, egid, sgid);
618 } else {
619 return syscall3(SYS_setresgid, rgid, egid, sgid);
620 }
538}621}
539622
540pub fn getgroups(size: usize, list: *u32) usize {623pub fn getgroups(size: usize, list: *u32) usize {
541 return syscall2(SYS_getgroups, size, @ptrToInt(list));624 if (@hasDecl(@This(), "SYS_getgroups32")) {
625 return syscall2(SYS_getgroups32, size, @ptrToInt(list));
626 } else {
627 return syscall2(SYS_getgroups, size, @ptrToInt(list));
628 }
542}629}
543630
544pub fn setgroups(size: usize, list: *const u32) usize {631pub fn setgroups(size: usize, list: *const u32) usize {
545 return syscall2(SYS_setgroups, size, @ptrToInt(list));632 if (@hasDecl(@This(), "SYS_setgroups32")) {
633 return syscall2(SYS_setgroups32, size, @ptrToInt(list));
634 } else {
635 return syscall2(SYS_setgroups, size, @ptrToInt(list));
636 }
546}637}
547638
548pub fn getpid() i32 {639pub fn getpid() i32 {
...@@ -709,22 +800,38 @@ pub fn accept4(fd: i32, noalias addr: *sockaddr, noalias len: *socklen_t, flags:...@@ -709,22 +800,38 @@ pub fn accept4(fd: i32, noalias addr: *sockaddr, noalias len: *socklen_t, flags:
709}800}
710801
711pub fn fstat(fd: i32, stat_buf: *Stat) usize {802pub fn fstat(fd: i32, stat_buf: *Stat) usize {
712 return syscall2(SYS_fstat, @bitCast(usize, isize(fd)), @ptrToInt(stat_buf));803 if (@hasDecl(@This(), "SYS_fstat64")) {
804 return syscall2(SYS_fstat64, @bitCast(usize, isize(fd)), @ptrToInt(stat_buf));
805 } else {
806 return syscall2(SYS_fstat, @bitCast(usize, isize(fd)), @ptrToInt(stat_buf));
807 }
713}808}
714809
715// TODO https://github.com/ziglang/zig/issues/265810// TODO https://github.com/ziglang/zig/issues/265
716pub fn stat(pathname: [*]const u8, statbuf: *Stat) usize {811pub fn stat(pathname: [*]const u8, statbuf: *Stat) usize {
717 return syscall2(SYS_stat, @ptrToInt(pathname), @ptrToInt(statbuf));812 if (@hasDecl(@This(), "SYS_stat64")) {
813 return syscall2(SYS_stat64, @ptrToInt(pathname), @ptrToInt(statbuf));
814 } else {
815 return syscall2(SYS_stat, @ptrToInt(pathname), @ptrToInt(statbuf));
816 }
718}817}
719818
720// TODO https://github.com/ziglang/zig/issues/265819// TODO https://github.com/ziglang/zig/issues/265
721pub fn lstat(pathname: [*]const u8, statbuf: *Stat) usize {820pub fn lstat(pathname: [*]const u8, statbuf: *Stat) usize {
722 return syscall2(SYS_lstat, @ptrToInt(pathname), @ptrToInt(statbuf));821 if (@hasDecl(@This(), "SYS_lstat64")) {
822 return syscall2(SYS_lstat64, @ptrToInt(pathname), @ptrToInt(statbuf));
823 } else {
824 return syscall2(SYS_lstat, @ptrToInt(pathname), @ptrToInt(statbuf));
825 }
723}826}
724827
725// TODO https://github.com/ziglang/zig/issues/265828// TODO https://github.com/ziglang/zig/issues/265
726pub fn fstatat(dirfd: i32, path: [*]const u8, stat_buf: *Stat, flags: u32) usize {829pub fn fstatat(dirfd: i32, path: [*]const u8, stat_buf: *Stat, flags: u32) usize {
727 return syscall4(SYS_fstatat, @bitCast(usize, isize(dirfd)), @ptrToInt(path), @ptrToInt(stat_buf), flags);830 if (@hasDecl(@This(), "SYS_fstatat64")) {
831 return syscall4(SYS_fstatat64, @bitCast(usize, isize(dirfd)), @ptrToInt(path), @ptrToInt(stat_buf), flags);
832 } else {
833 return syscall4(SYS_fstatat, @bitCast(usize, isize(dirfd)), @ptrToInt(path), @ptrToInt(stat_buf), flags);
834 }
728}835}
729836
730// TODO https://github.com/ziglang/zig/issues/265837// TODO https://github.com/ziglang/zig/issues/265
std/os/linux/arm-eabi.zig created+96
...@@ -0,0 +1,96 @@
1pub fn syscall0(number: usize) usize {
2 return asm volatile ("svc #0"
3 : [ret] "={r0}" (-> usize)
4 : [number] "{r7}" (number)
5 : "memory"
6 );
7}
8
9pub fn syscall1(number: usize, arg1: usize) usize {
10 return asm volatile ("svc #0"
11 : [ret] "={r0}" (-> usize)
12 : [number] "{r7}" (number),
13 [arg1] "{r0}" (arg1)
14 : "memory"
15 );
16}
17
18pub fn syscall2(number: usize, arg1: usize, arg2: usize) usize {
19 return asm volatile ("svc #0"
20 : [ret] "={r0}" (-> usize)
21 : [number] "{r7}" (number),
22 [arg1] "{r0}" (arg1),
23 [arg2] "{r1}" (arg2)
24 : "memory"
25 );
26}
27
28pub fn syscall3(number: usize, arg1: usize, arg2: usize, arg3: usize) usize {
29 return asm volatile ("svc #0"
30 : [ret] "={r0}" (-> usize)
31 : [number] "{r7}" (number),
32 [arg1] "{r0}" (arg1),
33 [arg2] "{r1}" (arg2),
34 [arg3] "{r2}" (arg3)
35 : "memory"
36 );
37}
38
39pub fn syscall4(number: usize, arg1: usize, arg2: usize, arg3: usize, arg4: usize) usize {
40 return asm volatile ("svc #0"
41 : [ret] "={r0}" (-> usize)
42 : [number] "{r7}" (number),
43 [arg1] "{r0}" (arg1),
44 [arg2] "{r1}" (arg2),
45 [arg3] "{r2}" (arg3),
46 [arg4] "{r3}" (arg4)
47 : "memory"
48 );
49}
50
51pub fn syscall5(number: usize, arg1: usize, arg2: usize, arg3: usize, arg4: usize, arg5: usize) usize {
52 return asm volatile ("svc #0"
53 : [ret] "={r0}" (-> usize)
54 : [number] "{r7}" (number),
55 [arg1] "{r0}" (arg1),
56 [arg2] "{r1}" (arg2),
57 [arg3] "{r2}" (arg3),
58 [arg4] "{r3}" (arg4),
59 [arg5] "{r4}" (arg5)
60 : "memory"
61 );
62}
63
64pub fn syscall6(
65 number: usize,
66 arg1: usize,
67 arg2: usize,
68 arg3: usize,
69 arg4: usize,
70 arg5: usize,
71 arg6: usize,
72) usize {
73 return asm volatile ("svc #0"
74 : [ret] "={r0}" (-> usize)
75 : [number] "{r7}" (number),
76 [arg1] "{r0}" (arg1),
77 [arg2] "{r1}" (arg2),
78 [arg3] "{r2}" (arg3),
79 [arg4] "{r3}" (arg4),
80 [arg5] "{r4}" (arg5),
81 [arg6] "{r5}" (arg6)
82 : "memory"
83 );
84}
85
86/// This matches the libc clone function.
87pub extern fn clone(func: extern fn (arg: usize) u8, stack: usize, flags: u32, arg: usize, ptid: *i32, tls: usize, ctid: *i32) usize;
88
89// LLVM calls this when the read-tp-hard feature is set to false. Currently, there is no way to pass
90// that to llvm via zig, see https://github.com/ziglang/zig/issues/2883.
91// LLVM expects libc to provide this function as __aeabi_read_tp, so it is exported if needed from special/c.zig.
92pub extern fn getThreadPointer() usize {
93 return asm volatile("mrc p15, 0, %[ret], c13, c0, 3"
94 : [ret] "=r" (-> usize)
95 );
96}
\ No newline at end of file
std/os/linux/arm64.zig+7-7
...@@ -2,7 +2,7 @@ pub fn syscall0(number: usize) usize {...@@ -2,7 +2,7 @@ pub fn syscall0(number: usize) usize {
2 return asm volatile ("svc #0"2 return asm volatile ("svc #0"
3 : [ret] "={x0}" (-> usize)3 : [ret] "={x0}" (-> usize)
4 : [number] "{x8}" (number)4 : [number] "{x8}" (number)
5 : "memory"5 : "memory", "cc"
6 );6 );
7}7}
88
...@@ -11,7 +11,7 @@ pub fn syscall1(number: usize, arg1: usize) usize {...@@ -11,7 +11,7 @@ pub fn syscall1(number: usize, arg1: usize) usize {
11 : [ret] "={x0}" (-> usize)11 : [ret] "={x0}" (-> usize)
12 : [number] "{x8}" (number),12 : [number] "{x8}" (number),
13 [arg1] "{x0}" (arg1)13 [arg1] "{x0}" (arg1)
14 : "memory"14 : "memory", "cc"
15 );15 );
16}16}
1717
...@@ -21,7 +21,7 @@ pub fn syscall2(number: usize, arg1: usize, arg2: usize) usize {...@@ -21,7 +21,7 @@ pub fn syscall2(number: usize, arg1: usize, arg2: usize) usize {
21 : [number] "{x8}" (number),21 : [number] "{x8}" (number),
22 [arg1] "{x0}" (arg1),22 [arg1] "{x0}" (arg1),
23 [arg2] "{x1}" (arg2)23 [arg2] "{x1}" (arg2)
24 : "memory"24 : "memory", "cc"
25 );25 );
26}26}
2727
...@@ -32,7 +32,7 @@ pub fn syscall3(number: usize, arg1: usize, arg2: usize, arg3: usize) usize {...@@ -32,7 +32,7 @@ pub fn syscall3(number: usize, arg1: usize, arg2: usize, arg3: usize) usize {
32 [arg1] "{x0}" (arg1),32 [arg1] "{x0}" (arg1),
33 [arg2] "{x1}" (arg2),33 [arg2] "{x1}" (arg2),
34 [arg3] "{x2}" (arg3)34 [arg3] "{x2}" (arg3)
35 : "memory"35 : "memory", "cc"
36 );36 );
37}37}
3838
...@@ -44,7 +44,7 @@ pub fn syscall4(number: usize, arg1: usize, arg2: usize, arg3: usize, arg4: usiz...@@ -44,7 +44,7 @@ pub fn syscall4(number: usize, arg1: usize, arg2: usize, arg3: usize, arg4: usiz
44 [arg2] "{x1}" (arg2),44 [arg2] "{x1}" (arg2),
45 [arg3] "{x2}" (arg3),45 [arg3] "{x2}" (arg3),
46 [arg4] "{x3}" (arg4)46 [arg4] "{x3}" (arg4)
47 : "memory"47 : "memory", "cc"
48 );48 );
49}49}
5050
...@@ -57,7 +57,7 @@ pub fn syscall5(number: usize, arg1: usize, arg2: usize, arg3: usize, arg4: usiz...@@ -57,7 +57,7 @@ pub fn syscall5(number: usize, arg1: usize, arg2: usize, arg3: usize, arg4: usiz
57 [arg3] "{x2}" (arg3),57 [arg3] "{x2}" (arg3),
58 [arg4] "{x3}" (arg4),58 [arg4] "{x3}" (arg4),
59 [arg5] "{x4}" (arg5)59 [arg5] "{x4}" (arg5)
60 : "memory"60 : "memory", "cc"
61 );61 );
62}62}
6363
...@@ -79,7 +79,7 @@ pub fn syscall6(...@@ -79,7 +79,7 @@ pub fn syscall6(
79 [arg4] "{x3}" (arg4),79 [arg4] "{x3}" (arg4),
80 [arg5] "{x4}" (arg5),80 [arg5] "{x4}" (arg5),
81 [arg6] "{x5}" (arg6)81 [arg6] "{x5}" (arg6)
82 : "memory"82 : "memory", "cc"
83 );83 );
84}84}
8585
std/os/linux/tls.zig+13
...@@ -118,6 +118,9 @@ pub fn setThreadPointer(addr: usize) void {...@@ -118,6 +118,9 @@ pub fn setThreadPointer(addr: usize) void {
118 : [addr] "r" (addr)118 : [addr] "r" (addr)
119 );119 );
120 },120 },
121 .arm => |arm| {
122 _ = std.os.linux.syscall1(std.os.linux.SYS_set_tls, addr);
123 },
121 .riscv64 => {124 .riscv64 => {
122 asm volatile (125 asm volatile (
123 \\ mv tp, %[addr]126 \\ mv tp, %[addr]
...@@ -137,6 +140,7 @@ pub fn initTLS() void {...@@ -137,6 +140,7 @@ pub fn initTLS() void {
137 var at_phent: usize = undefined;140 var at_phent: usize = undefined;
138 var at_phnum: usize = undefined;141 var at_phnum: usize = undefined;
139 var at_phdr: usize = undefined;142 var at_phdr: usize = undefined;
143 var at_hwcap: usize = undefined;
140144
141 var i: usize = 0;145 var i: usize = 0;
142 while (auxv[i].a_type != std.elf.AT_NULL) : (i += 1) {146 while (auxv[i].a_type != std.elf.AT_NULL) : (i += 1) {
...@@ -144,6 +148,7 @@ pub fn initTLS() void {...@@ -144,6 +148,7 @@ pub fn initTLS() void {
144 elf.AT_PHENT => at_phent = auxv[i].a_un.a_val,148 elf.AT_PHENT => at_phent = auxv[i].a_un.a_val,
145 elf.AT_PHNUM => at_phnum = auxv[i].a_un.a_val,149 elf.AT_PHNUM => at_phnum = auxv[i].a_un.a_val,
146 elf.AT_PHDR => at_phdr = auxv[i].a_un.a_val,150 elf.AT_PHDR => at_phdr = auxv[i].a_un.a_val,
151 elf.AT_HWCAP => at_hwcap = auxv[i].a_un.a_val,
147 else => continue,152 else => continue,
148 }153 }
149 }154 }
...@@ -163,6 +168,14 @@ pub fn initTLS() void {...@@ -163,6 +168,14 @@ pub fn initTLS() void {
163 }168 }
164169
165 if (tls_phdr) |phdr| {170 if (tls_phdr) |phdr| {
171 // If the cpu is arm-based, check if it supports the TLS register
172 if (builtin.arch == builtin.Arch.arm and at_hwcap & std.os.linux.HWCAP_TLS == 0) {
173 // If the CPU does not support TLS via a coprocessor register,
174 // a kernel helper function can be used instead on certain linux kernels.
175 // See linux/arch/arm/include/asm/tls.h and musl/src/thread/arm/__set_thread_area.c.
176 @panic("TODO: Implement ARM fallback TLS functionality");
177 }
178
166 // Offsets into the allocated TLS area179 // Offsets into the allocated TLS area
167 var tcb_offset: usize = undefined;180 var tcb_offset: usize = undefined;
168 var dtv_offset: usize = undefined;181 var dtv_offset: usize = undefined;
std/special/build_runner.zig+2
...@@ -123,6 +123,7 @@ pub fn main() !void {...@@ -123,6 +123,7 @@ pub fn main() !void {
123 }123 }
124 }124 }
125125
126 builder.resolveInstallPrefix();
126 try runBuild(builder);127 try runBuild(builder);
127128
128 if (builder.validateUserInputDidItFail())129 if (builder.validateUserInputDidItFail())
...@@ -151,6 +152,7 @@ fn usage(builder: *Builder, already_ran_build: bool, out_stream: var) !void {...@@ -151,6 +152,7 @@ fn usage(builder: *Builder, already_ran_build: bool, out_stream: var) !void {
151 // run the build script to collect the options152 // run the build script to collect the options
152 if (!already_ran_build) {153 if (!already_ran_build) {
153 builder.setInstallPrefix(null);154 builder.setInstallPrefix(null);
155 builder.resolveInstallPrefix();
154 try runBuild(builder);156 try runBuild(builder);
155 }157 }
156158
std/special/c.zig+31
...@@ -31,6 +31,8 @@ comptime {...@@ -31,6 +31,8 @@ comptime {
31 @export("strlen", strlen, .Strong);31 @export("strlen", strlen, .Strong);
32 } else if (is_msvc) {32 } else if (is_msvc) {
33 @export("_fltused", _fltused, .Strong);33 @export("_fltused", _fltused, .Strong);
34 } else if (builtin.arch == builtin.Arch.arm and builtin.os == .linux) {
35 @export("__aeabi_read_tp", std.os.linux.getThreadPointer, .Strong);
34 }36 }
35}37}
3638
...@@ -249,6 +251,35 @@ nakedcc fn clone() void {...@@ -249,6 +251,35 @@ nakedcc fn clone() void {
249 \\ mov x8,#93 // SYS_exit251 \\ mov x8,#93 // SYS_exit
250 \\ svc #0252 \\ svc #0
251 );253 );
254 } else if (builtin.arch == builtin.Arch.arm) {
255 asm volatile (
256 \\ stmfd sp!,{r4,r5,r6,r7}
257 \\ mov r7,#120
258 \\ mov r6,r3
259 \\ mov r5,r0
260 \\ mov r0,r2
261 \\ and r1,r1,#-16
262 \\ ldr r2,[sp,#16]
263 \\ ldr r3,[sp,#20]
264 \\ ldr r4,[sp,#24]
265 \\ svc 0
266 \\ tst r0,r0
267 \\ beq 1f
268 \\ ldmfd sp!,{r4,r5,r6,r7}
269 \\ bx lr
270 \\
271 \\1: mov r0,r6
272 \\ tst r5,#1
273 \\ bne 1f
274 \\ mov lr,pc
275 \\ mov pc,r5
276 \\2: mov r7,#1
277 \\ svc 0
278 \\
279 \\1: mov lr,pc
280 \\ bx r5
281 \\ b 2b
282 );
252 } else {283 } else {
253 @compileError("Implement clone() for this arch.");284 @compileError("Implement clone() for this arch.");
254 }285 }
std/special/start.zig+1-1
...@@ -44,7 +44,7 @@ nakedcc fn _start() noreturn {...@@ -44,7 +44,7 @@ nakedcc fn _start() noreturn {
44 : [argc] "={esp}" (-> [*]usize)44 : [argc] "={esp}" (-> [*]usize)
45 );45 );
46 },46 },
47 .aarch64, .aarch64_be => {47 .aarch64, .aarch64_be, .arm => {
48 argc_ptr = asm ("mov %[argc], sp"48 argc_ptr = asm ("mov %[argc], sp"
49 : [argc] "=r" (-> [*]usize)49 : [argc] "=r" (-> [*]usize)
50 );50 );
std/std.zig+3
...@@ -1,6 +1,7 @@...@@ -1,6 +1,7 @@
1pub const AlignedArrayList = @import("array_list.zig").AlignedArrayList;1pub const AlignedArrayList = @import("array_list.zig").AlignedArrayList;
2pub const ArrayList = @import("array_list.zig").ArrayList;2pub const ArrayList = @import("array_list.zig").ArrayList;
3pub const AutoHashMap = @import("hash_map.zig").AutoHashMap;3pub const AutoHashMap = @import("hash_map.zig").AutoHashMap;
4pub const BloomFilter = @import("bloom_filter.zig").BloomFilter;
4pub const BufMap = @import("buf_map.zig").BufMap;5pub const BufMap = @import("buf_map.zig").BufMap;
5pub const BufSet = @import("buf_set.zig").BufSet;6pub const BufSet = @import("buf_set.zig").BufSet;
6pub const Buffer = @import("buffer.zig").Buffer;7pub const Buffer = @import("buffer.zig").Buffer;
...@@ -48,6 +49,7 @@ pub const mem = @import("mem.zig");...@@ -48,6 +49,7 @@ pub const mem = @import("mem.zig");
48pub const meta = @import("meta.zig");49pub const meta = @import("meta.zig");
49pub const net = @import("net.zig");50pub const net = @import("net.zig");
50pub const os = @import("os.zig");51pub const os = @import("os.zig");
52pub const packed_int_array = @import("packed_int_array.zig");
51pub const pdb = @import("pdb.zig");53pub const pdb = @import("pdb.zig");
52pub const process = @import("process.zig");54pub const process = @import("process.zig");
53pub const rand = @import("rand.zig");55pub const rand = @import("rand.zig");
...@@ -64,6 +66,7 @@ test "std" {...@@ -64,6 +66,7 @@ test "std" {
64 // run tests from these66 // run tests from these
65 _ = @import("array_list.zig");67 _ = @import("array_list.zig");
66 _ = @import("atomic.zig");68 _ = @import("atomic.zig");
69 _ = @import("bloom_filter.zig");
67 _ = @import("buf_map.zig");70 _ = @import("buf_map.zig");
68 _ = @import("buf_set.zig");71 _ = @import("buf_set.zig");
69 _ = @import("buffer.zig");72 _ = @import("buffer.zig");
std/zig/parse.zig+4-2
...@@ -201,7 +201,7 @@ fn parseTopLevelComptime(arena: *Allocator, it: *TokenIterator, tree: *Tree) !?*...@@ -201,7 +201,7 @@ fn parseTopLevelComptime(arena: *Allocator, it: *TokenIterator, tree: *Tree) !?*
201}201}
202202
203/// TopLevelDecl203/// TopLevelDecl
204/// <- (KEYWORD_export / KEYWORD_extern STRINGLITERAL? / KEYWORD_inline)? FnProto (SEMICOLON / Block)204/// <- (KEYWORD_export / KEYWORD_extern STRINGLITERAL? / (KEYWORD_inline / KEYWORD_noinline))? FnProto (SEMICOLON / Block)
205/// / (KEYWORD_export / KEYWORD_extern STRINGLITERAL?)? KEYWORD_threadlocal? VarDecl205/// / (KEYWORD_export / KEYWORD_extern STRINGLITERAL?)? KEYWORD_threadlocal? VarDecl
206/// / KEYWORD_usingnamespace Expr SEMICOLON206/// / KEYWORD_usingnamespace Expr SEMICOLON
207fn parseTopLevelDecl(arena: *Allocator, it: *TokenIterator, tree: *Tree) !?*Node {207fn parseTopLevelDecl(arena: *Allocator, it: *TokenIterator, tree: *Tree) !?*Node {
...@@ -213,6 +213,7 @@ fn parseTopLevelDecl(arena: *Allocator, it: *TokenIterator, tree: *Tree) !?*Node...@@ -213,6 +213,7 @@ fn parseTopLevelDecl(arena: *Allocator, it: *TokenIterator, tree: *Tree) !?*Node
213 break :blk token;213 break :blk token;
214 }214 }
215 if (eatToken(it, .Keyword_inline)) |token| break :blk token;215 if (eatToken(it, .Keyword_inline)) |token| break :blk token;
216 if (eatToken(it, .Keyword_noinline)) |token| break :blk token;
216 break :blk null;217 break :blk null;
217 };218 };
218219
...@@ -232,7 +233,8 @@ fn parseTopLevelDecl(arena: *Allocator, it: *TokenIterator, tree: *Tree) !?*Node...@@ -232,7 +233,8 @@ fn parseTopLevelDecl(arena: *Allocator, it: *TokenIterator, tree: *Tree) !?*Node
232 }233 }
233234
234 if (extern_export_inline_token) |token| {235 if (extern_export_inline_token) |token| {
235 if (tree.tokens.at(token).id == .Keyword_inline) {236 if (tree.tokens.at(token).id == .Keyword_inline or
237 tree.tokens.at(token).id == .Keyword_noinline) {
236 putBackToken(it, token);238 putBackToken(it, token);
237 return null;239 return null;
238 }240 }
std/zig/parser_test.zig+91
...@@ -1677,14 +1677,17 @@ test "zig fmt: functions" {...@@ -1677,14 +1677,17 @@ test "zig fmt: functions" {
1677 \\extern "c" fn puts(s: *const u8) c_int;1677 \\extern "c" fn puts(s: *const u8) c_int;
1678 \\export fn puts(s: *const u8) c_int;1678 \\export fn puts(s: *const u8) c_int;
1679 \\inline fn puts(s: *const u8) c_int;1679 \\inline fn puts(s: *const u8) c_int;
1680 \\noinline fn puts(s: *const u8) c_int;
1680 \\pub extern fn puts(s: *const u8) c_int;1681 \\pub extern fn puts(s: *const u8) c_int;
1681 \\pub extern "c" fn puts(s: *const u8) c_int;1682 \\pub extern "c" fn puts(s: *const u8) c_int;
1682 \\pub export fn puts(s: *const u8) c_int;1683 \\pub export fn puts(s: *const u8) c_int;
1683 \\pub inline fn puts(s: *const u8) c_int;1684 \\pub inline fn puts(s: *const u8) c_int;
1685 \\pub noinline fn puts(s: *const u8) c_int;
1684 \\pub extern fn puts(s: *const u8) align(2 + 2) c_int;1686 \\pub extern fn puts(s: *const u8) align(2 + 2) c_int;
1685 \\pub extern "c" fn puts(s: *const u8) align(2 + 2) c_int;1687 \\pub extern "c" fn puts(s: *const u8) align(2 + 2) c_int;
1686 \\pub export fn puts(s: *const u8) align(2 + 2) c_int;1688 \\pub export fn puts(s: *const u8) align(2 + 2) c_int;
1687 \\pub inline fn puts(s: *const u8) align(2 + 2) c_int;1689 \\pub inline fn puts(s: *const u8) align(2 + 2) c_int;
1690 \\pub noinline fn puts(s: *const u8) align(2 + 2) c_int;
1688 \\1691 \\
1689 );1692 );
1690}1693}
...@@ -2419,6 +2422,94 @@ test "zig fmt: comment after empty comment" {...@@ -2419,6 +2422,94 @@ test "zig fmt: comment after empty comment" {
2419 );2422 );
2420}2423}
24212424
2425test "zig fmt: line comment in array" {
2426 try testTransform(
2427 \\test "a" {
2428 \\ var arr = [_]u32{
2429 \\ 0
2430 \\ // 1,
2431 \\ // 2,
2432 \\ };
2433 \\}
2434 \\
2435 ,
2436 \\test "a" {
2437 \\ var arr = [_]u32{
2438 \\ 0, // 1,
2439 \\ // 2,
2440 \\ };
2441 \\}
2442 \\
2443 );
2444 try testCanonical(
2445 \\test "a" {
2446 \\ var arr = [_]u32{
2447 \\ 0,
2448 \\ // 1,
2449 \\ // 2,
2450 \\ };
2451 \\}
2452 \\
2453 );
2454}
2455
2456test "zig fmt: comment after params" {
2457 try testTransform(
2458 \\fn a(
2459 \\ b: u32
2460 \\ // c: u32,
2461 \\ // d: u32,
2462 \\) void {}
2463 \\
2464 ,
2465 \\fn a(
2466 \\ b: u32, // c: u32,
2467 \\ // d: u32,
2468 \\) void {}
2469 \\
2470 );
2471 try testCanonical(
2472 \\fn a(
2473 \\ b: u32,
2474 \\ // c: u32,
2475 \\ // d: u32,
2476 \\) void {}
2477 \\
2478 );
2479}
2480
2481test "zig fmt: comment in array initializer/access" {
2482 try testCanonical(
2483 \\test "a" {
2484 \\ var a = x{ //aa
2485 \\ //bb
2486 \\ };
2487 \\ var a = []x{ //aa
2488 \\ //bb
2489 \\ };
2490 \\ var b = [ //aa
2491 \\ _
2492 \\ ]x{ //aa
2493 \\ //bb
2494 \\ 9,
2495 \\ };
2496 \\ var c = b[ //aa
2497 \\ 0
2498 \\ ];
2499 \\ var d = [_
2500 \\ //aa
2501 \\ ]x{ //aa
2502 \\ //bb
2503 \\ 9,
2504 \\ };
2505 \\ var e = d[0
2506 \\ //aa
2507 \\ ];
2508 \\}
2509 \\
2510 );
2511}
2512
2422test "zig fmt: comments at several places in struct init" {2513test "zig fmt: comments at several places in struct init" {
2423 try testTransform(2514 try testTransform(
2424 \\var bar = Bar{2515 \\var bar = Bar{
std/zig/render.zig+34-9
...@@ -483,9 +483,23 @@ fn renderExpression(...@@ -483,9 +483,23 @@ fn renderExpression(
483 },483 },
484484
485 ast.Node.PrefixOp.Op.ArrayType => |array_index| {485 ast.Node.PrefixOp.Op.ArrayType => |array_index| {
486 try renderToken(tree, stream, prefix_op_node.op_token, indent, start_col, Space.None); // [486 const lbracket = prefix_op_node.op_token;
487 try renderExpression(allocator, stream, tree, indent, start_col, array_index, Space.None);487 const rbracket = tree.nextToken(array_index.lastToken());
488 try renderToken(tree, stream, tree.nextToken(array_index.lastToken()), indent, start_col, Space.None); // ]488
489 try renderToken(tree, stream, lbracket, indent, start_col, Space.None); // [
490
491 const starts_with_comment = tree.tokens.at(lbracket + 1).id == .LineComment;
492 const ends_with_comment = tree.tokens.at(rbracket - 1).id == .LineComment;
493 const new_indent = if (ends_with_comment) indent + indent_delta else indent;
494 const new_space = if (ends_with_comment) Space.Newline else Space.None;
495 try renderExpression(allocator, stream, tree, new_indent, start_col, array_index, new_space);
496 if (starts_with_comment) {
497 try stream.writeByte('\n');
498 }
499 if (ends_with_comment or starts_with_comment) {
500 try stream.writeByteNTimes(' ', indent);
501 }
502 try renderToken(tree, stream, rbracket, indent, start_col, Space.None); // ]
489 },503 },
490 ast.Node.PrefixOp.Op.BitNot,504 ast.Node.PrefixOp.Op.BitNot,
491 ast.Node.PrefixOp.Op.BoolNot,505 ast.Node.PrefixOp.Op.BoolNot,
...@@ -580,7 +594,18 @@ fn renderExpression(...@@ -580,7 +594,18 @@ fn renderExpression(
580594
581 try renderExpression(allocator, stream, tree, indent, start_col, suffix_op.lhs, Space.None);595 try renderExpression(allocator, stream, tree, indent, start_col, suffix_op.lhs, Space.None);
582 try renderToken(tree, stream, lbracket, indent, start_col, Space.None); // [596 try renderToken(tree, stream, lbracket, indent, start_col, Space.None); // [
583 try renderExpression(allocator, stream, tree, indent, start_col, index_expr, Space.None);597
598 const starts_with_comment = tree.tokens.at(lbracket + 1).id == .LineComment;
599 const ends_with_comment = tree.tokens.at(rbracket - 1).id == .LineComment;
600 const new_indent = if (ends_with_comment) indent + indent_delta else indent;
601 const new_space = if (ends_with_comment) Space.Newline else Space.None;
602 try renderExpression(allocator, stream, tree, new_indent, start_col, index_expr, new_space);
603 if (starts_with_comment) {
604 try stream.writeByte('\n');
605 }
606 if (ends_with_comment or starts_with_comment) {
607 try stream.writeByteNTimes(' ', indent);
608 }
584 return renderToken(tree, stream, rbracket, indent, start_col, space); // ]609 return renderToken(tree, stream, rbracket, indent, start_col, space); // ]
585 },610 },
586611
...@@ -615,7 +640,7 @@ fn renderExpression(...@@ -615,7 +640,7 @@ fn renderExpression(
615640
616 if (field_inits.len == 0) {641 if (field_inits.len == 0) {
617 try renderExpression(allocator, stream, tree, indent, start_col, suffix_op.lhs, Space.None);642 try renderExpression(allocator, stream, tree, indent, start_col, suffix_op.lhs, Space.None);
618 try renderToken(tree, stream, lbrace, indent, start_col, Space.None);643 try renderToken(tree, stream, lbrace, indent + indent_delta, start_col, Space.None);
619 return renderToken(tree, stream, suffix_op.rtoken, indent, start_col, space);644 return renderToken(tree, stream, suffix_op.rtoken, indent, start_col, space);
620 }645 }
621646
...@@ -714,7 +739,7 @@ fn renderExpression(...@@ -714,7 +739,7 @@ fn renderExpression(
714 try renderToken(tree, stream, lbrace, indent, start_col, Space.None);739 try renderToken(tree, stream, lbrace, indent, start_col, Space.None);
715 return renderToken(tree, stream, suffix_op.rtoken, indent, start_col, space);740 return renderToken(tree, stream, suffix_op.rtoken, indent, start_col, space);
716 }741 }
717 if (exprs.len == 1) {742 if (exprs.len == 1 and tree.tokens.at(exprs.at(0).*.lastToken() + 1).id == .RBrace) {
718 const expr = exprs.at(0).*;743 const expr = exprs.at(0).*;
719744
720 try renderExpression(allocator, stream, tree, indent, start_col, suffix_op.lhs, Space.None);745 try renderExpression(allocator, stream, tree, indent, start_col, suffix_op.lhs, Space.None);
...@@ -775,7 +800,7 @@ fn renderExpression(...@@ -775,7 +800,7 @@ fn renderExpression(
775 while (it.next()) |expr| : (i += 1) {800 while (it.next()) |expr| : (i += 1) {
776 counting_stream.bytes_written = 0;801 counting_stream.bytes_written = 0;
777 var dummy_col: usize = 0;802 var dummy_col: usize = 0;
778 try renderExpression(allocator, &counting_stream.stream, tree, 0, &dummy_col, expr.*, Space.None);803 try renderExpression(allocator, &counting_stream.stream, tree, indent, &dummy_col, expr.*, Space.None);
779 const width = @intCast(usize, counting_stream.bytes_written);804 const width = @intCast(usize, counting_stream.bytes_written);
780 const col = i % row_size;805 const col = i % row_size;
781 column_widths[col] = std.math.max(column_widths[col], width);806 column_widths[col] = std.math.max(column_widths[col], width);
...@@ -1191,8 +1216,8 @@ fn renderExpression(...@@ -1191,8 +1216,8 @@ fn renderExpression(
1191 });1216 });
11921217
1193 const src_params_trailing_comma = blk: {1218 const src_params_trailing_comma = blk: {
1194 const maybe_comma = tree.prevToken(rparen);1219 const maybe_comma = tree.tokens.at(rparen - 1).id;
1195 break :blk tree.tokens.at(maybe_comma).id == Token.Id.Comma;1220 break :blk maybe_comma == .Comma or maybe_comma == .LineComment;
1196 };1221 };
11971222
1198 if (!src_params_trailing_comma) {1223 if (!src_params_trailing_comma) {
std/zig/tokenizer.zig+4
...@@ -38,6 +38,8 @@ pub const Token = struct {...@@ -38,6 +38,8 @@ pub const Token = struct {
38 Keyword{ .bytes = "inline", .id = Id.Keyword_inline },38 Keyword{ .bytes = "inline", .id = Id.Keyword_inline },
39 Keyword{ .bytes = "nakedcc", .id = Id.Keyword_nakedcc },39 Keyword{ .bytes = "nakedcc", .id = Id.Keyword_nakedcc },
40 Keyword{ .bytes = "noalias", .id = Id.Keyword_noalias },40 Keyword{ .bytes = "noalias", .id = Id.Keyword_noalias },
41 Keyword{ .bytes = "noasync", .id = Id.Keyword_noasync },
42 Keyword{ .bytes = "noinline", .id = Id.Keyword_noinline },
41 Keyword{ .bytes = "null", .id = Id.Keyword_null },43 Keyword{ .bytes = "null", .id = Id.Keyword_null },
42 Keyword{ .bytes = "or", .id = Id.Keyword_or },44 Keyword{ .bytes = "or", .id = Id.Keyword_or },
43 Keyword{ .bytes = "orelse", .id = Id.Keyword_orelse },45 Keyword{ .bytes = "orelse", .id = Id.Keyword_orelse },
...@@ -168,6 +170,8 @@ pub const Token = struct {...@@ -168,6 +170,8 @@ pub const Token = struct {
168 Keyword_inline,170 Keyword_inline,
169 Keyword_nakedcc,171 Keyword_nakedcc,
170 Keyword_noalias,172 Keyword_noalias,
173 Keyword_noasync,
174 Keyword_noinline,
171 Keyword_null,175 Keyword_null,
172 Keyword_or,176 Keyword_or,
173 Keyword_orelse,177 Keyword_orelse,
test/compile_errors.zig+105
...@@ -2,6 +2,71 @@ const tests = @import("tests.zig");...@@ -2,6 +2,71 @@ const tests = @import("tests.zig");
2const builtin = @import("builtin");2const builtin = @import("builtin");
33
4pub fn addCases(cases: *tests.CompileErrorContext) void {4pub fn addCases(cases: *tests.CompileErrorContext) void {
5 cases.add(
6 "attempt to negate a non-integer, non-float or non-vector type",
7 \\fn foo() anyerror!u32 {
8 \\ return 1;
9 \\}
10 \\
11 \\export fn entry() void {
12 \\ const x = -foo();
13 \\}
14 ,
15 "tmp.zig:6:15: error: negation of type 'anyerror!u32'",
16 );
17
18 cases.add(
19 "attempt to create 17 bit float type",
20 \\const builtin = @import("builtin");
21 \\comptime {
22 \\ _ = @Type(builtin.TypeInfo { .Float = builtin.TypeInfo.Float { .bits = 17 } });
23 \\}
24 ,
25 "tmp.zig:3:32: error: 17-bit float unsupported",
26 );
27
28 cases.add(
29 "wrong type for @Type",
30 \\export fn entry() void {
31 \\ _ = @Type(0);
32 \\}
33 ,
34 "tmp.zig:2:15: error: expected type 'builtin.TypeInfo', found 'comptime_int'",
35 );
36
37 cases.add(
38 "@Type with non-constant expression",
39 \\const builtin = @import("builtin");
40 \\var globalTypeInfo : builtin.TypeInfo = undefined;
41 \\export fn entry() void {
42 \\ _ = @Type(globalTypeInfo);
43 \\}
44 ,
45 "tmp.zig:4:15: error: unable to evaluate constant expression",
46 );
47
48 cases.add(
49 "@Type with TypeInfo.Int",
50 \\const builtin = @import("builtin");
51 \\export fn entry() void {
52 \\ _ = @Type(builtin.TypeInfo.Int {
53 \\ .is_signed = true,
54 \\ .bits = 8,
55 \\ });
56 \\}
57 ,
58 "tmp.zig:3:36: error: expected type 'builtin.TypeInfo', found 'builtin.Int'",
59 );
60
61 cases.add(
62 "Struct unavailable for @Type",
63 \\export fn entry() void {
64 \\ _ = @Type(@typeInfo(struct { }));
65 \\}
66 ,
67 "tmp.zig:2:15: error: @Type not availble for 'TypeInfo.Struct'",
68 );
69
5 cases.add(70 cases.add(
6 "wrong type for result ptr to @asyncCall",71 "wrong type for result ptr to @asyncCall",
7 \\export fn entry() void {72 \\export fn entry() void {
...@@ -18,6 +83,26 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {...@@ -18,6 +83,26 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
18 "tmp.zig:6:37: error: expected type '*i32', found 'bool'",83 "tmp.zig:6:37: error: expected type '*i32', found 'bool'",
19 );84 );
2085
86 cases.add(
87 "shift amount has to be an integer type",
88 \\export fn entry() void {
89 \\ const x = 1 << &u8(10);
90 \\}
91 ,
92 "tmp.zig:2:23: error: shift amount has to be an integer type, but found '*u8'",
93 "tmp.zig:2:17: note: referenced here",
94 );
95
96 cases.add(
97 "bit shifting only works on integer types",
98 \\export fn entry() void {
99 \\ const x = &u8(1) << 10;
100 \\}
101 ,
102 "tmp.zig:2:18: error: bit shifting operation expected integer type, found '*u8'",
103 "tmp.zig:2:22: note: referenced here",
104 );
105
21 cases.add(106 cases.add(
22 "struct depends on itself via optional field",107 "struct depends on itself via optional field",
23 \\const LhsExpr = struct {108 \\const LhsExpr = struct {
...@@ -6462,4 +6547,24 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {...@@ -6462,4 +6547,24 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
6462 "tmp.zig:5:30: error: expression value is ignored",6547 "tmp.zig:5:30: error: expression value is ignored",
6463 "tmp.zig:9:30: error: expression value is ignored",6548 "tmp.zig:9:30: error: expression value is ignored",
6464 );6549 );
6550
6551 cases.add(
6552 "aligned variable of zero-bit type",
6553 \\export fn f() void {
6554 \\ var s: struct {} align(4) = undefined;
6555 \\}
6556 ,
6557 "tmp.zig:2:5: error: variable 's' of zero-bit type 'struct:2:12' has no in-memory representation, it cannot be aligned",
6558 );
6559
6560 cases.add(
6561 "function returning opaque type",
6562 \\const FooType = @OpaqueType();
6563 \\export fn bar() !FooType {
6564 \\ return error.InvalidValue;
6565 \\}
6566 ,
6567 "tmp.zig:2:18: error: opaque return type 'FooType' not allowed",
6568 "tmp.zig:1:1: note: declared here",
6569 );
6465}6570}
test/runtime_safety.zig+15
...@@ -1,6 +1,21 @@...@@ -1,6 +1,21 @@
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 cases.addRuntimeSafety("noasync function call, callee suspends",
5 \\pub fn panic(message: []const u8, stack_trace: ?*@import("builtin").StackTrace) noreturn {
6 \\ @import("std").os.exit(126);
7 \\}
8 \\pub fn main() void {
9 \\ _ = noasync add(101, 100);
10 \\}
11 \\fn add(a: i32, b: i32) i32 {
12 \\ if (a > 100) {
13 \\ suspend;
14 \\ }
15 \\ return a + b;
16 \\}
17 );
18
4 cases.addRuntimeSafety("awaiting twice",19 cases.addRuntimeSafety("awaiting twice",
5 \\pub fn panic(message: []const u8, stack_trace: ?*@import("builtin").StackTrace) noreturn {20 \\pub fn panic(message: []const u8, stack_trace: ?*@import("builtin").StackTrace) noreturn {
6 \\ @import("std").os.exit(126);21 \\ @import("std").os.exit(126);
test/stack_traces.zig created+355
...@@ -0,0 +1,355 @@
1const builtin = @import("builtin");
2const std = @import("std");
3const os = std.os;
4const tests = @import("tests.zig");
5
6pub fn addCases(cases: *tests.StackTracesContext) void {
7 const source_return =
8 \\const std = @import("std");
9 \\
10 \\pub fn main() !void {
11 \\ return error.TheSkyIsFalling;
12 \\}
13 ;
14 const source_try_return =
15 \\const std = @import("std");
16 \\
17 \\fn foo() !void {
18 \\ return error.TheSkyIsFalling;
19 \\}
20 \\
21 \\pub fn main() !void {
22 \\ try foo();
23 \\}
24 ;
25 const source_try_try_return_return =
26 \\const std = @import("std");
27 \\
28 \\fn foo() !void {
29 \\ try bar();
30 \\}
31 \\
32 \\fn bar() !void {
33 \\ return make_error();
34 \\}
35 \\
36 \\fn make_error() !void {
37 \\ return error.TheSkyIsFalling;
38 \\}
39 \\
40 \\pub fn main() !void {
41 \\ try foo();
42 \\}
43 ;
44 // zig fmt: off
45 switch (builtin.os) {
46 .freebsd => {
47 cases.addCase(
48 "return",
49 source_return,
50 [_][]const u8{
51 // debug
52 \\error: TheSkyIsFalling
53 \\source.zig:4:5: [address] in main (test)
54 \\
55 ,
56 // release-safe
57 \\error: TheSkyIsFalling
58 \\source.zig:4:5: [address] in std.special.main (test)
59 \\
60 ,
61 // release-fast
62 \\error: TheSkyIsFalling
63 \\
64 ,
65 // release-small
66 \\error: TheSkyIsFalling
67 \\
68 },
69 );
70 cases.addCase(
71 "try return",
72 source_try_return,
73 [_][]const u8{
74 // debug
75 \\error: TheSkyIsFalling
76 \\source.zig:4:5: [address] in foo (test)
77 \\source.zig:8:5: [address] in main (test)
78 \\
79 ,
80 // release-safe
81 \\error: TheSkyIsFalling
82 \\source.zig:4:5: [address] in std.special.main (test)
83 \\source.zig:8:5: [address] in std.special.main (test)
84 \\
85 ,
86 // release-fast
87 \\error: TheSkyIsFalling
88 \\
89 ,
90 // release-small
91 \\error: TheSkyIsFalling
92 \\
93 },
94 );
95 cases.addCase(
96 "try try return return",
97 source_try_try_return_return,
98 [_][]const u8{
99 // debug
100 \\error: TheSkyIsFalling
101 \\source.zig:12:5: [address] in make_error (test)
102 \\source.zig:8:5: [address] in bar (test)
103 \\source.zig:4:5: [address] in foo (test)
104 \\source.zig:16:5: [address] in main (test)
105 \\
106 ,
107 // release-safe
108 \\error: TheSkyIsFalling
109 \\source.zig:12:5: [address] in std.special.main (test)
110 \\source.zig:8:5: [address] in std.special.main (test)
111 \\source.zig:4:5: [address] in std.special.main (test)
112 \\source.zig:16:5: [address] in std.special.main (test)
113 \\
114 ,
115 // release-fast
116 \\error: TheSkyIsFalling
117 \\
118 ,
119 // release-small
120 \\error: TheSkyIsFalling
121 \\
122 },
123 );
124 },
125 .linux => {
126 cases.addCase(
127 "return",
128 source_return,
129 [_][]const u8{
130 // debug
131 \\error: TheSkyIsFalling
132 \\source.zig:4:5: [address] in main (test)
133 \\
134 ,
135 // release-safe
136 \\error: TheSkyIsFalling
137 \\source.zig:4:5: [address] in std.special.posixCallMainAndExit (test)
138 \\
139 ,
140 // release-fast
141 \\error: TheSkyIsFalling
142 \\
143 ,
144 // release-small
145 \\error: TheSkyIsFalling
146 \\
147 },
148 );
149 cases.addCase(
150 "try return",
151 source_try_return,
152 [_][]const u8{
153 // debug
154 \\error: TheSkyIsFalling
155 \\source.zig:4:5: [address] in foo (test)
156 \\source.zig:8:5: [address] in main (test)
157 \\
158 ,
159 // release-safe
160 \\error: TheSkyIsFalling
161 \\source.zig:4:5: [address] in std.special.posixCallMainAndExit (test)
162 \\source.zig:8:5: [address] in std.special.posixCallMainAndExit (test)
163 \\
164 ,
165 // release-fast
166 \\error: TheSkyIsFalling
167 \\
168 ,
169 // release-small
170 \\error: TheSkyIsFalling
171 \\
172 },
173 );
174 cases.addCase(
175 "try try return return",
176 source_try_try_return_return,
177 [_][]const u8{
178 // debug
179 \\error: TheSkyIsFalling
180 \\source.zig:12:5: [address] in make_error (test)
181 \\source.zig:8:5: [address] in bar (test)
182 \\source.zig:4:5: [address] in foo (test)
183 \\source.zig:16:5: [address] in main (test)
184 \\
185 ,
186 // release-safe
187 \\error: TheSkyIsFalling
188 \\source.zig:12:5: [address] in std.special.posixCallMainAndExit (test)
189 \\source.zig:8:5: [address] in std.special.posixCallMainAndExit (test)
190 \\source.zig:4:5: [address] in std.special.posixCallMainAndExit (test)
191 \\source.zig:16:5: [address] in std.special.posixCallMainAndExit (test)
192 \\
193 ,
194 // release-fast
195 \\error: TheSkyIsFalling
196 \\
197 ,
198 // release-small
199 \\error: TheSkyIsFalling
200 \\
201 },
202 );
203 },
204 .macosx => {
205 cases.addCase(
206 "return",
207 source_return,
208 [_][]const u8{
209 // debug
210 \\error: TheSkyIsFalling
211 \\source.zig:4:5: [address] in _main.0 (test.o)
212 \\
213 ,
214 // release-safe
215 \\error: TheSkyIsFalling
216 \\source.zig:4:5: [address] in _main (test.o)
217 \\
218 ,
219 // release-fast
220 \\error: TheSkyIsFalling
221 \\
222 ,
223 // release-small
224 \\error: TheSkyIsFalling
225 \\
226 },
227 );
228 cases.addCase(
229 "try return",
230 source_try_return,
231 [_][]const u8{
232 // debug
233 \\error: TheSkyIsFalling
234 \\source.zig:4:5: [address] in _foo (test.o)
235 \\source.zig:8:5: [address] in _main.0 (test.o)
236 \\
237 ,
238 // release-safe
239 \\error: TheSkyIsFalling
240 \\source.zig:4:5: [address] in _main (test.o)
241 \\source.zig:8:5: [address] in _main (test.o)
242 \\
243 ,
244 // release-fast
245 \\error: TheSkyIsFalling
246 \\
247 ,
248 // release-small
249 \\error: TheSkyIsFalling
250 \\
251 },
252 );
253 cases.addCase(
254 "try try return return",
255 source_try_try_return_return,
256 [_][]const u8{
257 // debug
258 \\error: TheSkyIsFalling
259 \\source.zig:12:5: [address] in _make_error (test.o)
260 \\source.zig:8:5: [address] in _bar (test.o)
261 \\source.zig:4:5: [address] in _foo (test.o)
262 \\source.zig:16:5: [address] in _main.0 (test.o)
263 \\
264 ,
265 // release-safe
266 \\error: TheSkyIsFalling
267 \\source.zig:12:5: [address] in _main (test.o)
268 \\source.zig:8:5: [address] in _main (test.o)
269 \\source.zig:4:5: [address] in _main (test.o)
270 \\source.zig:16:5: [address] in _main (test.o)
271 \\
272 ,
273 // release-fast
274 \\error: TheSkyIsFalling
275 \\
276 ,
277 // release-small
278 \\error: TheSkyIsFalling
279 \\
280 },
281 );
282 },
283 .windows => {
284 cases.addCase(
285 "return",
286 source_return,
287 [_][]const u8{
288 // debug
289 \\error: TheSkyIsFalling
290 \\source.zig:4:5: [address] in main (test.obj)
291 \\
292 ,
293 // release-safe
294 // --disabled-- results in segmenetation fault
295 "",
296 // release-fast
297 \\error: TheSkyIsFalling
298 \\
299 ,
300 // release-small
301 \\error: TheSkyIsFalling
302 \\
303 },
304 );
305 cases.addCase(
306 "try return",
307 source_try_return,
308 [_][]const u8{
309 // debug
310 \\error: TheSkyIsFalling
311 \\source.zig:4:5: [address] in foo (test.obj)
312 \\source.zig:8:5: [address] in main (test.obj)
313 \\
314 ,
315 // release-safe
316 // --disabled-- results in segmenetation fault
317 "",
318 // release-fast
319 \\error: TheSkyIsFalling
320 \\
321 ,
322 // release-small
323 \\error: TheSkyIsFalling
324 \\
325 },
326 );
327 cases.addCase(
328 "try try return return",
329 source_try_try_return_return,
330 [_][]const u8{
331 // debug
332 \\error: TheSkyIsFalling
333 \\source.zig:12:5: [address] in make_error (test.obj)
334 \\source.zig:8:5: [address] in bar (test.obj)
335 \\source.zig:4:5: [address] in foo (test.obj)
336 \\source.zig:16:5: [address] in main (test.obj)
337 \\
338 ,
339 // release-safe
340 // --disabled-- results in segmenetation fault
341 "",
342 // release-fast
343 \\error: TheSkyIsFalling
344 \\
345 ,
346 // release-small
347 \\error: TheSkyIsFalling
348 \\
349 },
350 );
351 },
352 else => {},
353 }
354 // zig fmt: off
355}
test/stage1/behavior.zig+1
...@@ -93,6 +93,7 @@ comptime {...@@ -93,6 +93,7 @@ comptime {
93 _ = @import("behavior/this.zig");93 _ = @import("behavior/this.zig");
94 _ = @import("behavior/truncate.zig");94 _ = @import("behavior/truncate.zig");
95 _ = @import("behavior/try.zig");95 _ = @import("behavior/try.zig");
96 _ = @import("behavior/type.zig");
96 _ = @import("behavior/type_info.zig");97 _ = @import("behavior/type_info.zig");
97 _ = @import("behavior/typename.zig");98 _ = @import("behavior/typename.zig");
98 _ = @import("behavior/undefined.zig");99 _ = @import("behavior/undefined.zig");
test/stage1/behavior/async_fn.zig+184-8
...@@ -921,12 +921,10 @@ fn recursiveAsyncFunctionTest(comptime suspending_implementation: bool) type {...@@ -921,12 +921,10 @@ fn recursiveAsyncFunctionTest(comptime suspending_implementation: bool) type {
921 var sum: u32 = 0;921 var sum: u32 = 0;
922922
923 f1_awaited = true;923 f1_awaited = true;
924 const result_f1 = await f1; // TODO https://github.com/ziglang/zig/issues/3077924 sum += try await f1;
925 sum += try result_f1;
926925
927 f2_awaited = true;926 f2_awaited = true;
928 const result_f2 = await f2; // TODO https://github.com/ziglang/zig/issues/3077927 sum += try await f2;
929 sum += try result_f2;
930928
931 return sum;929 return sum;
932 }930 }
...@@ -943,8 +941,7 @@ fn recursiveAsyncFunctionTest(comptime suspending_implementation: bool) type {...@@ -943,8 +941,7 @@ fn recursiveAsyncFunctionTest(comptime suspending_implementation: bool) type {
943941
944 fn amain(result: *u32) void {942 fn amain(result: *u32) void {
945 var x = async fib(std.heap.direct_allocator, 10);943 var x = async fib(std.heap.direct_allocator, 10);
946 const res = await x; // TODO https://github.com/ziglang/zig/issues/3077944 result.* = (await x) catch unreachable;
947 result.* = res catch unreachable;
948 }945 }
949 };946 };
950}947}
...@@ -1002,8 +999,7 @@ test "@asyncCall using the result location inside the frame" {...@@ -1002,8 +999,7 @@ test "@asyncCall using the result location inside the frame" {
1002 return 1234;999 return 1234;
1003 }1000 }
1004 fn getAnswer(f: anyframe->i32, out: *i32) void {1001 fn getAnswer(f: anyframe->i32, out: *i32) void {
1005 var res = await f; // TODO https://github.com/ziglang/zig/issues/30771002 out.* = await f;
1006 out.* = res;
1007 }1003 }
1008 };1004 };
1009 var data: i32 = 1;1005 var data: i32 = 1;
...@@ -1092,3 +1088,183 @@ test "recursive call of await @asyncCall with struct return type" {...@@ -1092,3 +1088,183 @@ test "recursive call of await @asyncCall with struct return type" {
1092 expect(res.y == 2);1088 expect(res.y == 2);
1093 expect(res.z == 3);1089 expect(res.z == 3);
1094}1090}
1091
1092test "noasync function call" {
1093 const S = struct {
1094 fn doTheTest() void {
1095 const result = noasync add(50, 100);
1096 expect(result == 150);
1097 }
1098 fn add(a: i32, b: i32) i32 {
1099 if (a > 100) {
1100 suspend;
1101 }
1102 return a + b;
1103 }
1104 };
1105 S.doTheTest();
1106}
1107
1108test "await used in expression and awaiting fn with no suspend but async calling convention" {
1109 const S = struct {
1110 fn atest() void {
1111 var f1 = async add(1, 2);
1112 var f2 = async add(3, 4);
1113
1114 const sum = (await f1) + (await f2);
1115 expect(sum == 10);
1116 }
1117 async fn add(a: i32, b: i32) i32 {
1118 return a + b;
1119 }
1120 };
1121 _ = async S.atest();
1122}
1123
1124test "await used in expression after a fn call" {
1125 const S = struct {
1126 fn atest() void {
1127 var f1 = async add(3, 4);
1128 var sum: i32 = 0;
1129 sum = foo() + await f1;
1130 expect(sum == 8);
1131 }
1132 async fn add(a: i32, b: i32) i32 {
1133 return a + b;
1134 }
1135 fn foo() i32 { return 1; }
1136 };
1137 _ = async S.atest();
1138}
1139
1140test "async fn call used in expression after a fn call" {
1141 const S = struct {
1142 fn atest() void {
1143 var sum: i32 = 0;
1144 sum = foo() + add(3, 4);
1145 expect(sum == 8);
1146 }
1147 async fn add(a: i32, b: i32) i32 {
1148 return a + b;
1149 }
1150 fn foo() i32 { return 1; }
1151 };
1152 _ = async S.atest();
1153}
1154
1155test "suspend in for loop" {
1156 const S = struct {
1157 var global_frame: ?anyframe = null;
1158
1159 fn doTheTest() void {
1160 _ = async atest();
1161 while (global_frame) |f| resume f;
1162 }
1163
1164 fn atest() void {
1165 expect(func([_]u8{ 1, 2, 3 }) == 6);
1166 }
1167 fn func(stuff: []const u8) u32 {
1168 global_frame = @frame();
1169 var sum: u32 = 0;
1170 for (stuff) |x| {
1171 suspend;
1172 sum += x;
1173 }
1174 global_frame = null;
1175 return sum;
1176 }
1177 };
1178 S.doTheTest();
1179}
1180
1181test "correctly spill when returning the error union result of another async fn" {
1182 const S = struct {
1183 var global_frame: anyframe = undefined;
1184
1185 fn doTheTest() void {
1186 expect((atest() catch unreachable) == 1234);
1187 }
1188
1189 fn atest() !i32 {
1190 return fallible1();
1191 }
1192
1193 fn fallible1() anyerror!i32 {
1194 suspend {
1195 global_frame = @frame();
1196 }
1197 return 1234;
1198 }
1199 };
1200 _ = async S.doTheTest();
1201 resume S.global_frame;
1202}
1203
1204
1205test "spill target expr in a for loop" {
1206 const S = struct {
1207 var global_frame: anyframe = undefined;
1208
1209 fn doTheTest() void {
1210 var foo = Foo{
1211 .slice = [_]i32{1, 2},
1212 };
1213 expect(atest(&foo) == 3);
1214 }
1215
1216 const Foo = struct {
1217 slice: []i32,
1218 };
1219
1220 fn atest(foo: *Foo) i32 {
1221 var sum: i32 = 0;
1222 for (foo.slice) |x| {
1223 suspend {
1224 global_frame = @frame();
1225 }
1226 sum += x;
1227 }
1228 return sum;
1229 }
1230 };
1231 _ = async S.doTheTest();
1232 resume S.global_frame;
1233 resume S.global_frame;
1234}
1235
1236test "spill target expr in a for loop, with a var decl in the loop body" {
1237 const S = struct {
1238 var global_frame: anyframe = undefined;
1239
1240 fn doTheTest() void {
1241 var foo = Foo{
1242 .slice = [_]i32{1, 2},
1243 };
1244 expect(atest(&foo) == 3);
1245 }
1246
1247 const Foo = struct {
1248 slice: []i32,
1249 };
1250
1251 fn atest(foo: *Foo) i32 {
1252 var sum: i32 = 0;
1253 for (foo.slice) |x| {
1254 // Previously this var decl would prevent spills. This test makes sure
1255 // the for loop spills still happen even though there is a VarDecl in scope
1256 // before the suspend.
1257 var anything = true;
1258 _ = anything;
1259 suspend {
1260 global_frame = @frame();
1261 }
1262 sum += x;
1263 }
1264 return sum;
1265 }
1266 };
1267 _ = async S.doTheTest();
1268 resume S.global_frame;
1269 resume S.global_frame;
1270}
test/stage1/behavior/enum.zig+14
...@@ -993,3 +993,17 @@ test "enum with one member and custom tag type" {...@@ -993,3 +993,17 @@ test "enum with one member and custom tag type" {
993 };993 };
994 expect(@enumToInt(E2.One) == 2);994 expect(@enumToInt(E2.One) == 2);
995}995}
996
997test "enum literal casting to optional" {
998 var bar: ?Bar = undefined;
999 bar = .B;
1000
1001 expect(bar.? == Bar.B);
1002}
1003
1004test "enum literal casting to error union with payload enum" {
1005 var bar: error{B}!Bar = undefined;
1006 bar = .B; // should never cast to the error set
1007
1008 expect((try bar) == Bar.B);
1009}
test/stage1/behavior/if.zig+12
...@@ -74,3 +74,15 @@ test "const result loc, runtime if cond, else unreachable" {...@@ -74,3 +74,15 @@ test "const result loc, runtime if cond, else unreachable" {
74 const x = if (t) Num.Two else unreachable;74 const x = if (t) Num.Two else unreachable;
75 if (x != .Two) @compileError("bad");75 if (x != .Two) @compileError("bad");
76}76}
77
78test "if prongs cast to expected type instead of peer type resolution" {
79 const S = struct {
80 fn doTheTest(f: bool) void {
81 var x: i32 = 0;
82 x = if (f) 1 else 2;
83 expect(x == 2);
84 }
85 };
86 S.doTheTest(false);
87 comptime S.doTheTest(false);
88}
test/stage1/behavior/sizeof_and_typeof.zig+9
...@@ -115,3 +115,12 @@ test "branching logic inside @typeOf" {...@@ -115,3 +115,12 @@ test "branching logic inside @typeOf" {
115 comptime expect(T == i32);115 comptime expect(T == i32);
116 expect(S.data == 0);116 expect(S.data == 0);
117}117}
118
119fn fn1(alpha: bool) void {
120 const n: usize = 7;
121 const v = if (alpha) n else @sizeOf(usize);
122}
123
124test "lazy @sizeOf result is checked for definedness" {
125 const f = fn1;
126}
test/stage1/behavior/struct.zig+59
...@@ -599,3 +599,62 @@ test "extern fn returns struct by value" {...@@ -599,3 +599,62 @@ test "extern fn returns struct by value" {
599 S.entry();599 S.entry();
600 comptime S.entry();600 comptime S.entry();
601}601}
602
603test "for loop over pointers to struct, getting field from struct pointer" {
604 const S = struct {
605 const Foo = struct {
606 name: []const u8,
607 };
608
609 var ok = true;
610
611 fn eql(a: []const u8) bool {
612 return true;
613 }
614
615 const ArrayList = struct {
616 fn toSlice(self: *ArrayList) []*Foo {
617 return ([*]*Foo)(undefined)[0..0];
618 }
619 };
620
621 fn doTheTest() void {
622 var objects: ArrayList = undefined;
623
624 for (objects.toSlice()) |obj| {
625 if (eql(obj.name)) {
626 ok = false;
627 }
628 }
629
630 expect(ok);
631 }
632 };
633 S.doTheTest();
634}
635
636test "zero-bit field in packed struct" {
637 const S = packed struct {
638 x: u10,
639 y: void,
640 };
641 var x: S = undefined;
642}
643
644test "struct field init with catch" {
645 const S = struct {
646 fn doTheTest() void {
647 var x: anyerror!isize = 1;
648 var req = Foo{
649 .field = x catch undefined,
650 };
651 expect(req.field == 1);
652 }
653
654 pub const Foo = extern struct {
655 field: isize,
656 };
657 };
658 S.doTheTest();
659 comptime S.doTheTest();
660}
test/stage1/behavior/type.zig created+113
...@@ -0,0 +1,113 @@
1const builtin = @import("builtin");
2const TypeInfo = builtin.TypeInfo;
3
4const std = @import("std");
5const testing = std.testing;
6
7fn testTypes(comptime types: []const type) void {
8 inline for (types) |testType| {
9 testing.expect(testType == @Type(@typeInfo(testType)));
10 }
11}
12
13test "Type.MetaType" {
14 testing.expect(type == @Type(TypeInfo { .Type = undefined }));
15 testTypes([_]type {type});
16}
17
18test "Type.Void" {
19 testing.expect(void == @Type(TypeInfo { .Void = undefined }));
20 testTypes([_]type {void});
21}
22
23test "Type.Bool" {
24 testing.expect(bool == @Type(TypeInfo { .Bool = undefined }));
25 testTypes([_]type {bool});
26}
27
28test "Type.NoReturn" {
29 testing.expect(noreturn == @Type(TypeInfo { .NoReturn = undefined }));
30 testTypes([_]type {noreturn});
31}
32
33test "Type.Int" {
34 testing.expect(u1 == @Type(TypeInfo { .Int = TypeInfo.Int { .is_signed = false, .bits = 1 } }));
35 testing.expect(i1 == @Type(TypeInfo { .Int = TypeInfo.Int { .is_signed = true, .bits = 1 } }));
36 testing.expect(u8 == @Type(TypeInfo { .Int = TypeInfo.Int { .is_signed = false, .bits = 8 } }));
37 testing.expect(i8 == @Type(TypeInfo { .Int = TypeInfo.Int { .is_signed = true, .bits = 8 } }));
38 testing.expect(u64 == @Type(TypeInfo { .Int = TypeInfo.Int { .is_signed = false, .bits = 64 } }));
39 testing.expect(i64 == @Type(TypeInfo { .Int = TypeInfo.Int { .is_signed = true, .bits = 64 } }));
40 testTypes([_]type {u8,u32,i64});
41}
42
43test "Type.Float" {
44 testing.expect(f16 == @Type(TypeInfo { .Float = TypeInfo.Float { .bits = 16 } }));
45 testing.expect(f32 == @Type(TypeInfo { .Float = TypeInfo.Float { .bits = 32 } }));
46 testing.expect(f64 == @Type(TypeInfo { .Float = TypeInfo.Float { .bits = 64 } }));
47 testing.expect(f128 == @Type(TypeInfo { .Float = TypeInfo.Float { .bits = 128 } }));
48 testTypes([_]type {f16, f32, f64, f128});
49}
50
51test "Type.Pointer" {
52 testTypes([_]type {
53 // One Value Pointer Types
54 *u8, *const u8,
55 *volatile u8, *const volatile u8,
56 *align(4) u8, *const align(4) u8,
57 *volatile align(4) u8, *const volatile align(4) u8,
58 *align(8) u8, *const align(8) u8,
59 *volatile align(8) u8, *const volatile align(8) u8,
60 *allowzero u8, *const allowzero u8,
61 *volatile allowzero u8, *const volatile allowzero u8,
62 *align(4) allowzero u8, *const align(4) allowzero u8,
63 *volatile align(4) allowzero u8, *const volatile align(4) allowzero u8,
64 // Many Values Pointer Types
65 [*]u8, [*]const u8,
66 [*]volatile u8, [*]const volatile u8,
67 [*]align(4) u8, [*]const align(4) u8,
68 [*]volatile align(4) u8, [*]const volatile align(4) u8,
69 [*]align(8) u8, [*]const align(8) u8,
70 [*]volatile align(8) u8, [*]const volatile align(8) u8,
71 [*]allowzero u8, [*]const allowzero u8,
72 [*]volatile allowzero u8, [*]const volatile allowzero u8,
73 [*]align(4) allowzero u8, [*]const align(4) allowzero u8,
74 [*]volatile align(4) allowzero u8, [*]const volatile align(4) allowzero u8,
75 // Slice Types
76 []u8, []const u8,
77 []volatile u8, []const volatile u8,
78 []align(4) u8, []const align(4) u8,
79 []volatile align(4) u8, []const volatile align(4) u8,
80 []align(8) u8, []const align(8) u8,
81 []volatile align(8) u8, []const volatile align(8) u8,
82 []allowzero u8, []const allowzero u8,
83 []volatile allowzero u8, []const volatile allowzero u8,
84 []align(4) allowzero u8, []const align(4) allowzero u8,
85 []volatile align(4) allowzero u8, []const volatile align(4) allowzero u8,
86 // C Pointer Types
87 [*c]u8, [*c]const u8,
88 [*c]volatile u8, [*c]const volatile u8,
89 [*c]align(4) u8, [*c]const align(4) u8,
90 [*c]volatile align(4) u8, [*c]const volatile align(4) u8,
91 [*c]align(8) u8, [*c]const align(8) u8,
92 [*c]volatile align(8) u8, [*c]const volatile align(8) u8,
93 });
94}
95
96test "Type.Array" {
97 testing.expect([123]u8 == @Type(TypeInfo { .Array = TypeInfo.Array { .len = 123, .child = u8 } }));
98 testing.expect([2]u32 == @Type(TypeInfo { .Array = TypeInfo.Array { .len = 2, .child = u32 } }));
99 testTypes([_]type {[1]u8, [30]usize, [7]bool});
100}
101
102test "Type.ComptimeFloat" {
103 testTypes([_]type {comptime_float});
104}
105test "Type.ComptimeInt" {
106 testTypes([_]type {comptime_int});
107}
108test "Type.Undefined" {
109 testTypes([_]type {@typeOf(undefined)});
110}
111test "Type.Null" {
112 testTypes([_]type {@typeOf(null)});
113}
test/stage1/behavior/union.zig+37
...@@ -457,3 +457,40 @@ test "@unionInit can modify a pointer value" {...@@ -457,3 +457,40 @@ test "@unionInit can modify a pointer value" {
457 value_ptr.* = @unionInit(UnionInitEnum, "Byte", 2);457 value_ptr.* = @unionInit(UnionInitEnum, "Byte", 2);
458 expect(value.Byte == 2);458 expect(value.Byte == 2);
459}459}
460
461test "union no tag with struct member" {
462 const Struct = struct {};
463 const Union = union {
464 s: Struct,
465 pub fn foo(self: *@This()) void {}
466 };
467 var u = Union{ .s = Struct{} };
468 u.foo();
469}
470
471fn testComparison() void {
472 var x = Payload{.A = 42};
473 expect(x == .A);
474 expect(x != .B);
475 expect(x != .C);
476 expect((x == .B) == false);
477 expect((x == .C) == false);
478 expect((x != .A) == false);
479}
480
481test "comparison between union and enum literal" {
482 testComparison();
483 comptime testComparison();
484}
485
486test "packed union generates correctly aligned LLVM type" {
487 const U = packed union {
488 f1: fn () void,
489 f2: u32,
490 };
491 var foo = [_]U{
492 U{ .f1 = doTest },
493 U{ .f2 = 0 },
494 };
495 foo[0].f1();
496}
test/tests.zig+222-2
...@@ -16,13 +16,14 @@ const LibExeObjStep = build.LibExeObjStep;...@@ -16,13 +16,14 @@ const LibExeObjStep = build.LibExeObjStep;
1616
17const compare_output = @import("compare_output.zig");17const compare_output = @import("compare_output.zig");
18const standalone = @import("standalone.zig");18const standalone = @import("standalone.zig");
19const stack_traces = @import("stack_traces.zig");
19const compile_errors = @import("compile_errors.zig");20const compile_errors = @import("compile_errors.zig");
20const assemble_and_link = @import("assemble_and_link.zig");21const assemble_and_link = @import("assemble_and_link.zig");
21const runtime_safety = @import("runtime_safety.zig");22const runtime_safety = @import("runtime_safety.zig");
22const translate_c = @import("translate_c.zig");23const translate_c = @import("translate_c.zig");
23const gen_h = @import("gen_h.zig");24const gen_h = @import("gen_h.zig");
2425
25const test_targets = [_]CrossTarget{26const cross_targets = [_]CrossTarget{
26 CrossTarget{27 CrossTarget{
27 .os = .linux,28 .os = .linux,
28 .arch = .x86_64,29 .arch = .x86_64,
...@@ -57,6 +58,21 @@ pub fn addCompareOutputTests(b: *build.Builder, test_filter: ?[]const u8, modes:...@@ -57,6 +58,21 @@ pub fn addCompareOutputTests(b: *build.Builder, test_filter: ?[]const u8, modes:
57 return cases.step;58 return cases.step;
58}59}
5960
61pub fn addStackTraceTests(b: *build.Builder, test_filter: ?[]const u8, modes: []const Mode) *build.Step {
62 const cases = b.allocator.create(StackTracesContext) catch unreachable;
63 cases.* = StackTracesContext{
64 .b = b,
65 .step = b.step("test-stack-traces", "Run the stack trace tests"),
66 .test_index = 0,
67 .test_filter = test_filter,
68 .modes = modes,
69 };
70
71 stack_traces.addCases(cases);
72
73 return cases.step;
74}
75
60pub fn addRuntimeSafetyTests(b: *build.Builder, test_filter: ?[]const u8, modes: []const Mode) *build.Step {76pub fn addRuntimeSafetyTests(b: *build.Builder, test_filter: ?[]const u8, modes: []const Mode) *build.Step {
61 const cases = b.allocator.create(CompareOutputContext) catch unreachable;77 const cases = b.allocator.create(CompareOutputContext) catch unreachable;
62 cases.* = CompareOutputContext{78 cases.* = CompareOutputContext{
...@@ -170,7 +186,17 @@ pub fn addPkgTests(...@@ -170,7 +186,17 @@ pub fn addPkgTests(
170 skip_non_native: bool,186 skip_non_native: bool,
171) *build.Step {187) *build.Step {
172 const step = b.step(b.fmt("test-{}", name), desc);188 const step = b.step(b.fmt("test-{}", name), desc);
173 for (test_targets) |test_target| {189
190 var targets = std.ArrayList(*const CrossTarget).init(b.allocator);
191 defer targets.deinit();
192 const host = CrossTarget{ .os = builtin.os, .arch = builtin.arch, .abi = builtin.abi };
193 targets.append(&host) catch unreachable;
194 for (cross_targets) |*t| {
195 if (t.os == builtin.os and t.arch == builtin.arch and t.abi == builtin.abi) continue;
196 targets.append(t) catch unreachable;
197 }
198
199 for (targets.toSliceConst()) |test_target| {
174 const is_native = (test_target.os == builtin.os and test_target.arch == builtin.arch);200 const is_native = (test_target.os == builtin.os and test_target.arch == builtin.arch);
175 if (skip_non_native and !is_native)201 if (skip_non_native and !is_native)
176 continue;202 continue;
...@@ -549,6 +575,200 @@ pub const CompareOutputContext = struct {...@@ -549,6 +575,200 @@ pub const CompareOutputContext = struct {
549 }575 }
550};576};
551577
578pub const StackTracesContext = struct {
579 b: *build.Builder,
580 step: *build.Step,
581 test_index: usize,
582 test_filter: ?[]const u8,
583 modes: []const Mode,
584
585 const Expect = [@typeInfo(Mode).Enum.fields.len][]const u8;
586
587 pub fn addCase(
588 self: *StackTracesContext,
589 name: []const u8,
590 source: []const u8,
591 expect: Expect,
592 ) void {
593 const b = self.b;
594
595 const source_pathname = fs.path.join(
596 b.allocator,
597 [_][]const u8{ b.cache_root, "source.zig" },
598 ) catch unreachable;
599
600 for (self.modes) |mode| {
601 const expect_for_mode = expect[@enumToInt(mode)];
602 if (expect_for_mode.len == 0) continue;
603
604 const annotated_case_name = fmt.allocPrint(self.b.allocator, "{} {} ({})", "stack-trace", name, @tagName(mode)) catch unreachable;
605 if (self.test_filter) |filter| {
606 if (mem.indexOf(u8, annotated_case_name, filter) == null) continue;
607 }
608
609 const exe = b.addExecutable("test", source_pathname);
610 exe.setBuildMode(mode);
611
612 const write_source = b.addWriteFile(source_pathname, source);
613 exe.step.dependOn(&write_source.step);
614
615 const run_and_compare = RunAndCompareStep.create(
616 self,
617 exe,
618 annotated_case_name,
619 mode,
620 expect_for_mode,
621 );
622
623 self.step.dependOn(&run_and_compare.step);
624 }
625 }
626
627 const RunAndCompareStep = struct {
628 step: build.Step,
629 context: *StackTracesContext,
630 exe: *LibExeObjStep,
631 name: []const u8,
632 mode: Mode,
633 expect_output: []const u8,
634 test_index: usize,
635
636 pub fn create(
637 context: *StackTracesContext,
638 exe: *LibExeObjStep,
639 name: []const u8,
640 mode: Mode,
641 expect_output: []const u8,
642 ) *RunAndCompareStep {
643 const allocator = context.b.allocator;
644 const ptr = allocator.create(RunAndCompareStep) catch unreachable;
645 ptr.* = RunAndCompareStep{
646 .step = build.Step.init("StackTraceCompareOutputStep", allocator, make),
647 .context = context,
648 .exe = exe,
649 .name = name,
650 .mode = mode,
651 .expect_output = expect_output,
652 .test_index = context.test_index,
653 };
654 ptr.step.dependOn(&exe.step);
655 context.test_index += 1;
656 return ptr;
657 }
658
659 fn make(step: *build.Step) !void {
660 const self = @fieldParentPtr(RunAndCompareStep, "step", step);
661 const b = self.context.b;
662
663 const full_exe_path = self.exe.getOutputPath();
664 var args = ArrayList([]const u8).init(b.allocator);
665 defer args.deinit();
666 args.append(full_exe_path) catch unreachable;
667
668 warn("Test {}/{} {}...", self.test_index + 1, self.context.test_index, self.name);
669
670 const child = std.ChildProcess.init(args.toSliceConst(), b.allocator) catch unreachable;
671 defer child.deinit();
672
673 child.stdin_behavior = .Ignore;
674 child.stdout_behavior = .Pipe;
675 child.stderr_behavior = .Pipe;
676 child.env_map = b.env_map;
677
678 child.spawn() catch |err| debug.panic("Unable to spawn {}: {}\n", full_exe_path, @errorName(err));
679
680 var stdout = Buffer.initNull(b.allocator);
681 var stderr = Buffer.initNull(b.allocator);
682
683 var stdout_file_in_stream = child.stdout.?.inStream();
684 var stderr_file_in_stream = child.stderr.?.inStream();
685
686 stdout_file_in_stream.stream.readAllBuffer(&stdout, max_stdout_size) catch unreachable;
687 stderr_file_in_stream.stream.readAllBuffer(&stderr, max_stdout_size) catch unreachable;
688
689 const term = child.wait() catch |err| {
690 debug.panic("Unable to spawn {}: {}\n", full_exe_path, @errorName(err));
691 };
692
693 switch (term) {
694 .Exited => |code| {
695 const expect_code: u32 = 1;
696 if (code != expect_code) {
697 warn("Process {} exited with error code {} but expected code {}\n", full_exe_path, code, expect_code);
698 printInvocation(args.toSliceConst());
699 return error.TestFailed;
700 }
701 },
702 .Signal => |signum| {
703 warn("Process {} terminated on signal {}\n", full_exe_path, signum);
704 printInvocation(args.toSliceConst());
705 return error.TestFailed;
706 },
707 .Stopped => |signum| {
708 warn("Process {} stopped on signal {}\n", full_exe_path, signum);
709 printInvocation(args.toSliceConst());
710 return error.TestFailed;
711 },
712 .Unknown => |code| {
713 warn("Process {} terminated unexpectedly with error code {}\n", full_exe_path, code);
714 printInvocation(args.toSliceConst());
715 return error.TestFailed;
716 },
717 }
718
719 // process result
720 // - keep only basename of source file path
721 // - replace address with symbolic string
722 // - skip empty lines
723 const got: []const u8 = got_result: {
724 var buf = try Buffer.initSize(b.allocator, 0);
725 defer buf.deinit();
726 var bytes = stderr.toSliceConst();
727 if (bytes.len != 0 and bytes[bytes.len - 1] == '\n') bytes = bytes[0 .. bytes.len - 1];
728 var it = mem.separate(bytes, "\n");
729 process_lines: while (it.next()) |line| {
730 if (line.len == 0) continue;
731 const delims = [_][]const u8{ ":", ":", ":", " in " };
732 var marks = [_]usize{0} ** 4;
733 // offset search past `[drive]:` on windows
734 var pos: usize = if (builtin.os == .windows) 2 else 0;
735 for (delims) |delim, i| {
736 marks[i] = mem.indexOfPos(u8, line, pos, delim) orelse {
737 try buf.append(line);
738 try buf.append("\n");
739 continue :process_lines;
740 };
741 pos = marks[i] + delim.len;
742 }
743 pos = mem.lastIndexOfScalar(u8, line[0..marks[0]], fs.path.sep) orelse {
744 try buf.append(line);
745 try buf.append("\n");
746 continue :process_lines;
747 };
748 try buf.append(line[pos + 1 .. marks[2] + delims[2].len]);
749 try buf.append(" [address]");
750 try buf.append(line[marks[3]..]);
751 try buf.append("\n");
752 }
753 break :got_result buf.toOwnedSlice();
754 };
755
756 if (!mem.eql(u8, self.expect_output, got)) {
757 warn(
758 \\
759 \\========= Expected this output: =========
760 \\{}
761 \\================================================
762 \\{}
763 \\
764 , self.expect_output, got);
765 return error.TestFailed;
766 }
767 warn("OK\n");
768 }
769 };
770};
771
552pub const CompileErrorContext = struct {772pub const CompileErrorContext = struct {
553 b: *build.Builder,773 b: *build.Builder,
554 step: *build.Step,774 step: *build.Step,
tools/process_headers.zig+70-326
...@@ -20,6 +20,7 @@ const assert = std.debug.assert;...@@ -20,6 +20,7 @@ const assert = std.debug.assert;
20const LibCTarget = struct {20const LibCTarget = struct {
21 name: []const u8,21 name: []const u8,
22 arch: MultiArch,22 arch: MultiArch,
23 abi: MultiAbi,
23};24};
2425
25const MultiArch = union(enum) {26const MultiArch = union(enum) {
...@@ -39,396 +40,129 @@ const MultiArch = union(enum) {...@@ -39,396 +40,129 @@ const MultiArch = union(enum) {
39 }40 }
40};41};
4142
43const MultiAbi = union(enum) {
44 musl,
45 specific: Abi,
46
47 fn eql(a: MultiAbi, b: MultiAbi) bool {
48 if (@enumToInt(a) != @enumToInt(b))
49 return false;
50 if (@TagType(MultiAbi)(a) != .specific)
51 return true;
52 return a.specific == b.specific;
53 }
54};
55
42const glibc_targets = [_]LibCTarget{56const glibc_targets = [_]LibCTarget{
43 LibCTarget{57 LibCTarget{
44 .name = "aarch64_be-linux-gnu",58 .name = "aarch64_be-linux-gnu",
45 .zig_arch = Arch.aarch64_be,59 .arch = MultiArch {.specific = Arch.aarch64_be},
46 .zig_abi = Abi.gnu,60 .abi = MultiAbi {.specific = Abi.gnu},
47 },61 },
48 LibCTarget{62 LibCTarget{
49 .name = "aarch64-linux-gnu",63 .name = "aarch64-linux-gnu",
50 .zig_arch = Arch.aarch64,64 .arch = MultiArch {.specific = Arch.aarch64},
51 .zig_abi = Abi.gnu,65 .abi = MultiAbi {.specific = Abi.gnu},
52 },
53 LibCTarget{
54 .name = "aarch64-linux-gnu-disable-multi-arch",
55 .zig_arch = Arch.aarch64,
56 .zig_abi = null,
57 },
58 LibCTarget{
59 .name = "alpha-linux-gnu",
60 .zig_arch = null,
61 .zig_abi = Abi.gnu,
62 },66 },
63 LibCTarget{67 LibCTarget{
64 .name = "armeb-linux-gnueabi",68 .name = "armeb-linux-gnueabi",
65 .zig_arch = Arch.armeb,69 .arch = MultiArch {.specific = Arch.armeb},
66 .zig_abi = Abi.gnueabi,70 .abi = MultiAbi {.specific = Abi.gnueabi},
67 },
68 LibCTarget{
69 .name = "armeb-linux-gnueabi-be8",
70 .zig_arch = Arch.armeb,
71 .zig_abi = null,
72 },71 },
73 LibCTarget{72 LibCTarget{
74 .name = "armeb-linux-gnueabihf",73 .name = "armeb-linux-gnueabihf",
75 .zig_arch = Arch.armeb,74 .arch = MultiArch {.specific = Arch.armeb},
76 .zig_abi = Abi.gnueabihf,75 .abi = MultiAbi {.specific = Abi.gnueabihf},
77 },
78 LibCTarget{
79 .name = "armeb-linux-gnueabihf-be8",
80 .zig_arch = Arch.armeb,
81 .zig_abi = null,
82 },76 },
83 LibCTarget{77 LibCTarget{
84 .name = "arm-linux-gnueabi",78 .name = "arm-linux-gnueabi",
85 .zig_arch = Arch.arm,79 .arch = MultiArch {.specific = Arch.arm},
86 .zig_abi = Abi.gnueabi,80 .abi = MultiAbi {.specific = Abi.gnueabi},
87 },81 },
88 LibCTarget{82 LibCTarget{
89 .name = "arm-linux-gnueabihf",83 .name = "arm-linux-gnueabihf",
90 .zig_arch = Arch.arm,84 .arch = MultiArch {.specific = Arch.arm},
91 .zig_abi = Abi.gnueabihf,85 .abi = MultiAbi {.specific = Abi.gnueabihf},
92 },
93 LibCTarget{
94 .name = "arm-linux-gnueabihf-v7a",
95 .zig_arch = Arch.arm,
96 .zig_abi = null,
97 },
98 LibCTarget{
99 .name = "arm-linux-gnueabihf-v7a-disable-multi-arch",
100 .zig_arch = null,
101 .zig_abi = null,
102 },
103 LibCTarget{
104 .name = "hppa-linux-gnu",
105 .zig_arch = null,
106 .zig_abi = Abi.gnu,
107 },
108 LibCTarget{
109 .name = "i486-linux-gnu",
110 .zig_arch = null,
111 .zig_abi = Abi.gnu,
112 },
113 LibCTarget{
114 .name = "i586-linux-gnu",
115 .zig_arch = null,
116 .zig_abi = Abi.gnu,
117 },
118 LibCTarget{
119 .name = "i686-gnu",
120 .zig_arch = Arch.i386,
121 .zig_abi = Abi.gnu,
122 },86 },
123 LibCTarget{87 LibCTarget{
124 .name = "i686-linux-gnu",88 .name = "i686-linux-gnu",
125 .zig_arch = Arch.i386,89 .arch = MultiArch {.specific = Arch.i386},
126 .zig_abi = Abi.gnu,90 .abi = MultiAbi {.specific = Abi.gnu},
127 },
128 LibCTarget{
129 .name = "i686-linux-gnu-disable-multi-arch",
130 .zig_arch = null,
131 .zig_abi = null,
132 },
133 LibCTarget{
134 .name = "i686-linux-gnu-enable-obsolete",
135 .zig_arch = Arch.i386,
136 .zig_abi = null,
137 },
138 LibCTarget{
139 .name = "i686-linux-gnu-static-pie",
140 .zig_arch = Arch.i386,
141 .zig_abi = null,
142 },
143 LibCTarget{
144 .name = "ia64-linux-gnu",
145 .zig_arch = null,
146 .zig_abi = null,
147 },
148 LibCTarget{
149 .name = "m68k-linux-gnu",
150 .zig_arch = null,
151 .zig_abi = null,
152 },
153 LibCTarget{
154 .name = "m68k-linux-gnu-coldfire",
155 .zig_arch = null,
156 .zig_abi = null,
157 },
158 LibCTarget{
159 .name = "m68k-linux-gnu-coldfire-soft",
160 .zig_arch = null,
161 .zig_abi = null,
162 },
163 LibCTarget{
164 .name = "microblazeel-linux-gnu",
165 .zig_arch = null,
166 .zig_abi = null,
167 },
168 LibCTarget{
169 .name = "microblaze-linux-gnu",
170 .zig_arch = null,
171 .zig_abi = null,
172 },91 },
173 LibCTarget{92 LibCTarget{
174 .name = "mips64el-linux-gnu-n32",93 .name = "mips64el-linux-gnu-n32",
175 .zig_arch = Arch.mips64el,94 .arch = MultiArch {.specific = Arch.mips64el},
176 .zig_abi = Abi.gnuabin32,95 .abi = MultiAbi {.specific = Abi.gnuabin32},
177 },
178 LibCTarget{
179 .name = "mips64el-linux-gnu-n32-nan2008",
180 .zig_arch = Arch.mips64el,
181 .zig_abi = null,
182 },
183 LibCTarget{
184 .name = "mips64el-linux-gnu-n32-nan2008-soft",
185 .zig_arch = Arch.mips64el,
186 .zig_abi = null,
187 },
188 LibCTarget{
189 .name = "mips64el-linux-gnu-n32-soft",
190 .zig_arch = Arch.mips64el,
191 .zig_abi = null,
192 },96 },
193 LibCTarget{97 LibCTarget{
194 .name = "mips64el-linux-gnu-n64",98 .name = "mips64el-linux-gnu-n64",
195 .zig_arch = Arch.mips64el,99 .arch = MultiArch {.specific = Arch.mips64el},
196 .zig_abi = Abi.gnuabi64,100 .abi = MultiAbi {.specific = Abi.gnuabi64},
197 },
198 LibCTarget{
199 .name = "mips64el-linux-gnu-n64-nan2008",
200 .zig_arch = Arch.mips64el,
201 .zig_abi = null,
202 },
203 LibCTarget{
204 .name = "mips64el-linux-gnu-n64-nan2008-soft",
205 .zig_arch = Arch.mips64el,
206 .zig_abi = null,
207 },
208 LibCTarget{
209 .name = "mips64el-linux-gnu-n64-soft",
210 .zig_arch = Arch.mips64el,
211 .zig_abi = null,
212 },101 },
213 LibCTarget{102 LibCTarget{
214 .name = "mips64-linux-gnu-n32",103 .name = "mips64-linux-gnu-n32",
215 .zig_arch = Arch.mips64,104 .arch = MultiArch {.specific = Arch.mips64},
216 .zig_abi = Abi.gnuabin32,105 .abi = MultiAbi {.specific = Abi.gnuabin32},
217 },
218 LibCTarget{
219 .name = "mips64-linux-gnu-n32-nan2008",
220 .zig_arch = Arch.mips64,
221 .zig_abi = null,
222 },
223 LibCTarget{
224 .name = "mips64-linux-gnu-n32-nan2008-soft",
225 .zig_arch = Arch.mips64,
226 .zig_abi = null,
227 },
228 LibCTarget{
229 .name = "mips64-linux-gnu-n32-soft",
230 .zig_arch = Arch.mips64,
231 .zig_abi = null,
232 },106 },
233 LibCTarget{107 LibCTarget{
234 .name = "mips64-linux-gnu-n64",108 .name = "mips64-linux-gnu-n64",
235 .zig_arch = Arch.mips64,109 .arch = MultiArch {.specific = Arch.mips64},
236 .zig_abi = Abi.gnuabi64,110 .abi = MultiAbi {.specific = Abi.gnuabi64},
237 },
238 LibCTarget{
239 .name = "mips64-linux-gnu-n64-nan2008",
240 .zig_arch = Arch.mips64,
241 .zig_abi = null,
242 },
243 LibCTarget{
244 .name = "mips64-linux-gnu-n64-nan2008-soft",
245 .zig_arch = Arch.mips64,
246 .zig_abi = null,
247 },
248 LibCTarget{
249 .name = "mips64-linux-gnu-n64-soft",
250 .zig_arch = Arch.mips64,
251 .zig_abi = null,
252 },111 },
253 LibCTarget{112 LibCTarget{
254 .name = "mipsel-linux-gnu",113 .name = "mipsel-linux-gnu",
255 .zig_arch = Arch.mipsel,114 .arch = MultiArch {.specific = Arch.mipsel},
256 .zig_abi = Abi.gnu,115 .abi = MultiAbi {.specific = Abi.gnu},
257 },
258 LibCTarget{
259 .name = "mipsel-linux-gnu-nan2008",
260 .zig_arch = Arch.mipsel,
261 .zig_abi = null,
262 },
263 LibCTarget{
264 .name = "mipsel-linux-gnu-nan2008-soft",
265 .zig_arch = Arch.mipsel,
266 .zig_abi = null,
267 },
268 LibCTarget{
269 .name = "mipsel-linux-gnu-soft",
270 .zig_arch = Arch.mipsel,
271 .zig_abi = null,
272 },116 },
273 LibCTarget{117 LibCTarget{
274 .name = "mips-linux-gnu",118 .name = "mips-linux-gnu",
275 .zig_arch = Arch.mips,119 .arch = MultiArch {.specific = Arch.mips},
276 .zig_abi = Abi.gnu,120 .abi = MultiAbi {.specific = Abi.gnu},
277 },
278 LibCTarget{
279 .name = "mips-linux-gnu-nan2008",
280 .zig_arch = Arch.mips,
281 .zig_abi = null,
282 },
283 LibCTarget{
284 .name = "mips-linux-gnu-nan2008-soft",
285 .zig_arch = Arch.mips,
286 .zig_abi = null,
287 },
288 LibCTarget{
289 .name = "mips-linux-gnu-soft",
290 .zig_arch = Arch.mips,
291 .zig_abi = null,
292 },121 },
293 LibCTarget{122 LibCTarget{
294 .name = "powerpc64le-linux-gnu",123 .name = "powerpc64le-linux-gnu",
295 .zig_arch = Arch.powerpc64le,124 .arch = MultiArch {.specific = Arch.powerpc64le},
296 .zig_abi = Abi.gnu,125 .abi = MultiAbi {.specific = Abi.gnu},
297 },126 },
298 LibCTarget{127 LibCTarget{
299 .name = "powerpc64-linux-gnu",128 .name = "powerpc64-linux-gnu",
300 .zig_arch = Arch.powerpc64,129 .arch = MultiArch {.specific = Arch.powerpc64},
301 .zig_abi = Abi.gnu,130 .abi = MultiAbi {.specific = Abi.gnu},
302 },131 },
303 LibCTarget{132 LibCTarget{
304 .name = "powerpc-linux-gnu",133 .name = "powerpc-linux-gnu",
305 .zig_arch = Arch.powerpc,134 .arch = MultiArch {.specific = Arch.powerpc},
306 .zig_abi = Abi.gnu,135 .abi = MultiAbi {.specific = Abi.gnu},
307 },
308 LibCTarget{
309 .name = "powerpc-linux-gnu-power4",
310 .zig_arch = Arch.powerpc,
311 .zig_abi = null,
312 },
313 LibCTarget{
314 .name = "powerpc-linux-gnu-soft",
315 .zig_arch = Arch.powerpc,
316 .zig_abi = null,
317 },
318 LibCTarget{
319 .name = "powerpc-linux-gnuspe",
320 .zig_arch = Arch.powerpc,
321 .zig_abi = null,
322 },
323 LibCTarget{
324 .name = "powerpc-linux-gnuspe-e500v1",
325 .zig_arch = Arch.powerpc,
326 .zig_abi = null,
327 },136 },
328 LibCTarget{137 LibCTarget{
329 .name = "riscv64-linux-gnu-rv64imac-lp64",138 .name = "riscv64-linux-gnu-rv64imac-lp64",
330 .zig_arch = Arch.riscv64,139 .arch = MultiArch {.specific = Arch.riscv64},
331 .zig_abi = Abi.gnu,140 .abi = MultiAbi {.specific = Abi.gnu},
332 },
333 LibCTarget{
334 .name = "riscv64-linux-gnu-rv64imafdc-lp64",
335 .zig_arch = Arch.riscv64,
336 .zig_abi = null,
337 },
338 LibCTarget{
339 .name = "riscv64-linux-gnu-rv64imafdc-lp64d",
340 .zig_arch = Arch.riscv64,
341 .zig_abi = null,
342 },
343 LibCTarget{
344 .name = "s390-linux-gnu",
345 .zig_arch = null,
346 .zig_abi = Abi.gnu,
347 },141 },
348 LibCTarget{142 LibCTarget{
349 .name = "s390x-linux-gnu",143 .name = "s390x-linux-gnu",
350 .zig_arch = Arch.s390x,144 .arch = MultiArch {.specific = Arch.s390x},
351 .zig_abi = Abi.gnu,145 .abi = MultiAbi {.specific = Abi.gnu},
352 },
353 LibCTarget{
354 .name = "sh3eb-linux-gnu",
355 .zig_arch = null,
356 .zig_abi = Abi.gnu,
357 },
358 LibCTarget{
359 .name = "sh3-linux-gnu",
360 .zig_arch = null,
361 .zig_abi = Abi.gnu,
362 },
363 LibCTarget{
364 .name = "sh4eb-linux-gnu",
365 .zig_arch = null,
366 .zig_abi = Abi.gnu,
367 },
368 LibCTarget{
369 .name = "sh4eb-linux-gnu-soft",
370 .zig_arch = null,
371 .zig_abi = null,
372 },
373 LibCTarget{
374 .name = "sh4-linux-gnu",
375 .zig_arch = null,
376 .zig_abi = Abi.gnu,
377 },
378 LibCTarget{
379 .name = "sh4-linux-gnu-soft",
380 .zig_arch = null,
381 .zig_abi = null,
382 },146 },
383 LibCTarget{147 LibCTarget{
384 .name = "sparc64-linux-gnu",148 .name = "sparc64-linux-gnu",
385 .zig_arch = Arch.sparc,149 .arch = MultiArch {.specific = Arch.sparc},
386 .zig_abi = Abi.gnu,150 .abi = MultiAbi {.specific = Abi.gnu},
387 },
388 LibCTarget{
389 .name = "sparc64-linux-gnu-disable-multi-arch",
390 .zig_arch = Arch.sparc,
391 .zig_abi = null,
392 },151 },
393 LibCTarget{152 LibCTarget{
394 .name = "sparcv9-linux-gnu",153 .name = "sparcv9-linux-gnu",
395 .zig_arch = Arch.sparcv9,154 .arch = MultiArch {.specific = Arch.sparcv9},
396 .zig_abi = Abi.gnu,155 .abi = MultiAbi {.specific = Abi.gnu},
397 },
398 LibCTarget{
399 .name = "sparcv9-linux-gnu-disable-multi-arch",
400 .zig_arch = Arch.sparcv9,
401 .zig_abi = null,
402 },156 },
403 LibCTarget{157 LibCTarget{
404 .name = "x86_64-linux-gnu",158 .name = "x86_64-linux-gnu",
405 .zig_arch = Arch.x86_64,159 .arch = MultiArch {.specific = Arch.x86_64},
406 .zig_abi = Abi.gnu,160 .abi = MultiAbi {.specific = Abi.gnu},
407 },
408 LibCTarget{
409 .name = "x86_64-linux-gnu-disable-multi-arch",
410 .zig_arch = Arch.x86_64,
411 .zig_abi = null,
412 },
413 LibCTarget{
414 .name = "x86_64-linux-gnu-enable-obsolete",
415 .zig_arch = Arch.x86_64,
416 .zig_abi = null,
417 },
418 LibCTarget{
419 .name = "x86_64-linux-gnu-static-pie",
420 .zig_arch = Arch.x86_64,
421 .zig_abi = null,
422 },161 },
423 LibCTarget{162 LibCTarget{
424 .name = "x86_64-linux-gnu-x32",163 .name = "x86_64-linux-gnu-x32",
425 .zig_arch = Arch.x86_64,164 .arch = MultiArch {.specific = Arch.x86_64},
426 .zig_abi = Abi.gnux32,165 .abi = MultiAbi {.specific = Abi.gnux32},
427 },
428 LibCTarget{
429 .name = "x86_64-linux-gnu-x32-static-pie",
430 .zig_arch = Arch.x86_64,
431 .zig_abi = null,
432 },166 },
433};167};
434168
...@@ -436,42 +170,52 @@ const musl_targets = [_]LibCTarget{...@@ -436,42 +170,52 @@ const musl_targets = [_]LibCTarget{
436 LibCTarget{170 LibCTarget{
437 .name = "aarch64",171 .name = "aarch64",
438 .arch = MultiArch.aarch64,172 .arch = MultiArch.aarch64,
173 .abi = MultiAbi.musl,
439 },174 },
440 LibCTarget{175 LibCTarget{
441 .name = "arm",176 .name = "arm",
442 .arch = MultiArch.arm,177 .arch = MultiArch.arm,
178 .abi = MultiAbi.musl,
443 },179 },
444 LibCTarget{180 LibCTarget{
445 .name = "i386",181 .name = "i386",
446 .arch = MultiArch{ .specific = .i386 },182 .arch = MultiArch{ .specific = .i386 },
183 .abi = MultiAbi.musl,
447 },184 },
448 LibCTarget{185 LibCTarget{
449 .name = "mips",186 .name = "mips",
450 .arch = MultiArch.mips,187 .arch = MultiArch.mips,
188 .abi = MultiAbi.musl,
451 },189 },
452 LibCTarget{190 LibCTarget{
453 .name = "mips64",191 .name = "mips64",
454 .arch = MultiArch.mips64,192 .arch = MultiArch.mips64,
193 .abi = MultiAbi.musl,
455 },194 },
456 LibCTarget{195 LibCTarget{
457 .name = "powerpc",196 .name = "powerpc",
458 .arch = MultiArch{ .specific = .powerpc },197 .arch = MultiArch{ .specific = .powerpc },
198 .abi = MultiAbi.musl,
459 },199 },
460 LibCTarget{200 LibCTarget{
461 .name = "powerpc64",201 .name = "powerpc64",
462 .arch = MultiArch.powerpc64,202 .arch = MultiArch.powerpc64,
203 .abi = MultiAbi.musl,
463 },204 },
464 LibCTarget{205 LibCTarget{
465 .name = "riscv64",206 .name = "riscv64",
466 .arch = MultiArch{ .specific = .riscv64 },207 .arch = MultiArch{ .specific = .riscv64 },
208 .abi = MultiAbi.musl,
467 },209 },
468 LibCTarget{210 LibCTarget{
469 .name = "s390x",211 .name = "s390x",
470 .arch = MultiArch{ .specific = .s390x },212 .arch = MultiArch{ .specific = .s390x },
213 .abi = MultiAbi.musl,
471 },214 },
472 LibCTarget{215 LibCTarget{
473 .name = "x86_64",216 .name = "x86_64",
474 .arch = MultiArch{ .specific = .x86_64 },217 .arch = MultiArch{ .specific = .x86_64 },
218 .abi = MultiAbi.musl,
475 },219 },
476};220};
477221
...@@ -562,7 +306,7 @@ pub fn main() !void {...@@ -562,7 +306,7 @@ pub fn main() !void {
562 var libc_targets: []const LibCTarget = undefined;306 var libc_targets: []const LibCTarget = undefined;
563 switch (vendor) {307 switch (vendor) {
564 .musl => libc_targets = musl_targets,308 .musl => libc_targets = musl_targets,
565 .glibc => @panic("TODO this regressed"), // glibc_targets,309 .glibc => libc_targets = glibc_targets,
566 }310 }
567311
568 var path_table = PathTable.init(allocator);312 var path_table = PathTable.init(allocator);
...@@ -577,7 +321,7 @@ pub fn main() !void {...@@ -577,7 +321,7 @@ pub fn main() !void {
577 .arch = libc_target.arch,321 .arch = libc_target.arch,
578 .abi = switch (vendor) {322 .abi = switch (vendor) {
579 .musl => .musl,323 .musl => .musl,
580 else => @panic("TODO this regressed"),324 .glibc => libc_target.abi.specific,
581 },325 },
582 .os = .linux,326 .os = .linux,
583 };327 };
tools/update_glibc.zig+1-1
...@@ -135,7 +135,7 @@ pub fn main() !void {...@@ -135,7 +135,7 @@ pub fn main() !void {
135 const allocator = &arena.allocator;135 const allocator = &arena.allocator;
136 const args = try std.process.argsAlloc(allocator);136 const args = try std.process.argsAlloc(allocator);
137 const in_glibc_dir = args[1]; // path to the unzipped tarball of glibc, e.g. ~/downloads/glibc-2.25137 const in_glibc_dir = args[1]; // path to the unzipped tarball of glibc, e.g. ~/downloads/glibc-2.25
138 const zig_src_dir = args[2]; // path to the source checkout of zig138 const zig_src_dir = args[2]; // path to the source checkout of zig, lib dir, e.g. ~/zig-src/lib
139139
140 const prefix = try fs.path.join(allocator, [_][]const u8{ in_glibc_dir, "sysdeps", "unix", "sysv", "linux" });140 const prefix = try fs.path.join(allocator, [_][]const u8{ in_glibc_dir, "sysdeps", "unix", "sysv", "linux" });
141 const glibc_out_dir = try fs.path.join(allocator, [_][]const u8{ zig_src_dir, "libc", "glibc" });141 const glibc_out_dir = try fs.path.join(allocator, [_][]const u8{ zig_src_dir, "libc", "glibc" });