Skip to content

Commit 02e6960

Browse files
committed
coff: do not pull in std.log into coff.zig definitions
1 parent 9038528 commit 02e6960

File tree

2 files changed

+33
-40
lines changed

2 files changed

+33
-40
lines changed

lib/std/coff.zig

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -841,10 +841,7 @@ pub const Coff = struct {
841841
if (self.is_image) {
842842
self.coff_header_offset = coff_header_offset + 4;
843843
const coff_header = self.getCoffHeader();
844-
if (coff_header.size_of_optional_header == 0) {
845-
std.log.err("Required PE header missing for image file", .{});
846-
return error.MissingPEHeader;
847-
}
844+
if (coff_header.size_of_optional_header == 0) return error.MissingPEHeader;
848845
}
849846

850847
// JK: we used to check for architecture here and throw an error if not x86 or derivative.

test/run_translated_c.zig

Lines changed: 32 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
const std = @import("std");
2-
const builtin = @import("builtin");
32
const tests = @import("tests.zig");
43
const nl = std.cstr.line_sep;
54

@@ -1684,41 +1683,38 @@ pub fn addCases(cases: *tests.RunTranslatedCContext) void {
16841683
// TODO: add isnan check for long double once bitfield support is added
16851684
// (needed for x86_64-windows-gnu)
16861685
// TODO: add isinf check for long double once std.math.isInf supports c_longdouble
1687-
// TODO https://github.com/ziglang/zig/issues/12630
1688-
if (!(builtin.zig_backend == .stage2_llvm and builtin.target.os.tag == .windows)) {
1689-
cases.add("NAN and INFINITY",
1690-
\\#include <math.h>
1691-
\\#include <stdint.h>
1692-
\\#include <stdlib.h>
1693-
\\union uf { uint32_t u; float f; };
1694-
\\#define CHECK_NAN(STR, VAL) { \
1695-
\\ union uf unpack = {.f = __builtin_nanf(STR)}; \
1696-
\\ if (!isnan(unpack.f)) abort(); \
1697-
\\ if (unpack.u != VAL) abort(); \
1698-
\\}
1699-
\\int main(void) {
1700-
\\ float f_nan = NAN;
1701-
\\ if (!isnan(f_nan)) abort();
1702-
\\ double d_nan = NAN;
1703-
\\ if (!isnan(d_nan)) abort();
1704-
\\ CHECK_NAN("0", 0x7FC00000);
1705-
\\ CHECK_NAN("", 0x7FC00000);
1706-
\\ CHECK_NAN("1", 0x7FC00001);
1707-
\\ CHECK_NAN("0x7FC00000", 0x7FC00000);
1708-
\\ CHECK_NAN("0x7FC0000F", 0x7FC0000F);
1709-
\\ CHECK_NAN("0x7FC000F0", 0x7FC000F0);
1710-
\\ CHECK_NAN("0x7FC00F00", 0x7FC00F00);
1711-
\\ CHECK_NAN("0x7FC0F000", 0x7FC0F000);
1712-
\\ CHECK_NAN("0x7FCF0000", 0x7FCF0000);
1713-
\\ CHECK_NAN("0xFFFFFFFF", 0x7FFFFFFF);
1714-
\\ float f_inf = INFINITY;
1715-
\\ if (!isinf(f_inf)) abort();
1716-
\\ double d_inf = INFINITY;
1717-
\\ if (!isinf(d_inf)) abort();
1718-
\\ return 0;
1719-
\\}
1720-
, "");
1721-
}
1686+
cases.add("NAN and INFINITY",
1687+
\\#include <math.h>
1688+
\\#include <stdint.h>
1689+
\\#include <stdlib.h>
1690+
\\union uf { uint32_t u; float f; };
1691+
\\#define CHECK_NAN(STR, VAL) { \
1692+
\\ union uf unpack = {.f = __builtin_nanf(STR)}; \
1693+
\\ if (!isnan(unpack.f)) abort(); \
1694+
\\ if (unpack.u != VAL) abort(); \
1695+
\\}
1696+
\\int main(void) {
1697+
\\ float f_nan = NAN;
1698+
\\ if (!isnan(f_nan)) abort();
1699+
\\ double d_nan = NAN;
1700+
\\ if (!isnan(d_nan)) abort();
1701+
\\ CHECK_NAN("0", 0x7FC00000);
1702+
\\ CHECK_NAN("", 0x7FC00000);
1703+
\\ CHECK_NAN("1", 0x7FC00001);
1704+
\\ CHECK_NAN("0x7FC00000", 0x7FC00000);
1705+
\\ CHECK_NAN("0x7FC0000F", 0x7FC0000F);
1706+
\\ CHECK_NAN("0x7FC000F0", 0x7FC000F0);
1707+
\\ CHECK_NAN("0x7FC00F00", 0x7FC00F00);
1708+
\\ CHECK_NAN("0x7FC0F000", 0x7FC0F000);
1709+
\\ CHECK_NAN("0x7FCF0000", 0x7FCF0000);
1710+
\\ CHECK_NAN("0xFFFFFFFF", 0x7FFFFFFF);
1711+
\\ float f_inf = INFINITY;
1712+
\\ if (!isinf(f_inf)) abort();
1713+
\\ double d_inf = INFINITY;
1714+
\\ if (!isinf(d_inf)) abort();
1715+
\\ return 0;
1716+
\\}
1717+
, "");
17221718

17231719
cases.add("signed array subscript. Issue #8556",
17241720
\\#include <stdint.h>

0 commit comments

Comments
 (0)