authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2022-08-26 14:13:57+02:00
committergravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2022-08-26 16:14:44+02:00
log02e696096633bc588b0931d4dc5aba4be4cd97f1
tree33ec0f151ee3e9bca9968f9b47427a276a888210
parent9038528187932babc86558ec343511c635446a28

coff: do not pull in std.log into coff.zig definitions


2 files changed, 33 insertions(+), 40 deletions(-)

lib/std/coff.zig+1-4
...@@ -841,10 +841,7 @@ pub const Coff = struct {...@@ -841,10 +841,7 @@ pub const Coff = struct {
841 if (self.is_image) {841 if (self.is_image) {
842 self.coff_header_offset = coff_header_offset + 4;842 self.coff_header_offset = coff_header_offset + 4;
843 const coff_header = self.getCoffHeader();843 const coff_header = self.getCoffHeader();
844 if (coff_header.size_of_optional_header == 0) {844 if (coff_header.size_of_optional_header == 0) return error.MissingPEHeader;
845 std.log.err("Required PE header missing for image file", .{});
846 return error.MissingPEHeader;
847 }
848 }845 }
849846
850 // JK: we used to check for architecture here and throw an error if not x86 or derivative.847 // JK: we used to check for architecture here and throw an error if not x86 or derivative.
test/run_translated_c.zig+32-36
...@@ -1,5 +1,4 @@...@@ -1,5 +1,4 @@
1const std = @import("std");1const std = @import("std");
2const builtin = @import("builtin");
3const tests = @import("tests.zig");2const tests = @import("tests.zig");
4const nl = std.cstr.line_sep;3const nl = std.cstr.line_sep;
54
...@@ -1684,41 +1683,38 @@ pub fn addCases(cases: *tests.RunTranslatedCContext) void {...@@ -1684,41 +1683,38 @@ pub fn addCases(cases: *tests.RunTranslatedCContext) void {
1684 // TODO: add isnan check for long double once bitfield support is added1683 // TODO: add isnan check for long double once bitfield support is added
1685 // (needed for x86_64-windows-gnu)1684 // (needed for x86_64-windows-gnu)
1686 // TODO: add isinf check for long double once std.math.isInf supports c_longdouble1685 // TODO: add isinf check for long double once std.math.isInf supports c_longdouble
1687 // TODO https://github.com/ziglang/zig/issues/126301686 cases.add("NAN and INFINITY",
1688 if (!(builtin.zig_backend == .stage2_llvm and builtin.target.os.tag == .windows)) {1687 \\#include <math.h>
1689 cases.add("NAN and INFINITY",1688 \\#include <stdint.h>
1690 \\#include <math.h>1689 \\#include <stdlib.h>
1691 \\#include <stdint.h>1690 \\union uf { uint32_t u; float f; };
1692 \\#include <stdlib.h>1691 \\#define CHECK_NAN(STR, VAL) { \
1693 \\union uf { uint32_t u; float f; };1692 \\ union uf unpack = {.f = __builtin_nanf(STR)}; \
1694 \\#define CHECK_NAN(STR, VAL) { \1693 \\ if (!isnan(unpack.f)) abort(); \
1695 \\ union uf unpack = {.f = __builtin_nanf(STR)}; \1694 \\ if (unpack.u != VAL) abort(); \
1696 \\ if (!isnan(unpack.f)) abort(); \1695 \\}
1697 \\ if (unpack.u != VAL) abort(); \1696 \\int main(void) {
1698 \\}1697 \\ float f_nan = NAN;
1699 \\int main(void) {1698 \\ if (!isnan(f_nan)) abort();
1700 \\ float f_nan = NAN;1699 \\ double d_nan = NAN;
1701 \\ if (!isnan(f_nan)) abort();1700 \\ if (!isnan(d_nan)) abort();
1702 \\ double d_nan = NAN;1701 \\ CHECK_NAN("0", 0x7FC00000);
1703 \\ if (!isnan(d_nan)) abort();1702 \\ CHECK_NAN("", 0x7FC00000);
1704 \\ CHECK_NAN("0", 0x7FC00000);1703 \\ CHECK_NAN("1", 0x7FC00001);
1705 \\ CHECK_NAN("", 0x7FC00000);1704 \\ CHECK_NAN("0x7FC00000", 0x7FC00000);
1706 \\ CHECK_NAN("1", 0x7FC00001);1705 \\ CHECK_NAN("0x7FC0000F", 0x7FC0000F);
1707 \\ CHECK_NAN("0x7FC00000", 0x7FC00000);1706 \\ CHECK_NAN("0x7FC000F0", 0x7FC000F0);
1708 \\ CHECK_NAN("0x7FC0000F", 0x7FC0000F);1707 \\ CHECK_NAN("0x7FC00F00", 0x7FC00F00);
1709 \\ CHECK_NAN("0x7FC000F0", 0x7FC000F0);1708 \\ CHECK_NAN("0x7FC0F000", 0x7FC0F000);
1710 \\ CHECK_NAN("0x7FC00F00", 0x7FC00F00);1709 \\ CHECK_NAN("0x7FCF0000", 0x7FCF0000);
1711 \\ CHECK_NAN("0x7FC0F000", 0x7FC0F000);1710 \\ CHECK_NAN("0xFFFFFFFF", 0x7FFFFFFF);
1712 \\ CHECK_NAN("0x7FCF0000", 0x7FCF0000);1711 \\ float f_inf = INFINITY;
1713 \\ CHECK_NAN("0xFFFFFFFF", 0x7FFFFFFF);1712 \\ if (!isinf(f_inf)) abort();
1714 \\ float f_inf = INFINITY;1713 \\ double d_inf = INFINITY;
1715 \\ if (!isinf(f_inf)) abort();1714 \\ if (!isinf(d_inf)) abort();
1716 \\ double d_inf = INFINITY;1715 \\ return 0;
1717 \\ if (!isinf(d_inf)) abort();1716 \\}
1718 \\ return 0;1717 , "");
1719 \\}
1720 , "");
1721 }
17221718
1723 cases.add("signed array subscript. Issue #8556",1719 cases.add("signed array subscript. Issue #8556",
1724 \\#include <stdint.h>1720 \\#include <stdint.h>