Templates from 64 KiB up to 1 MiB were staged in a second buffer and
copied again into the thread block. Proving those bytes readable, then
copying them into the block that is already zeroed, avoids that buffer
and still maps nothing when the template cannot be read. Smaller
templates and templates of 1 MiB or more keep the single staged read,
which measured as fast or faster.
Signed-off-by: devil8blade <360741796+devil8blade@users.noreply.github.com>
fopen created a missing file before it allocated the FILE object, so a
failed allocation left an empty file behind. The FILE object is now
allocated first and released again if the drive cannot take the file.
A test fills the heap and checks that neither a new file appears nor an
existing one loses its contents.
Signed-off-by: zachdoxsee <zachdoxsee36@gmail.com>
A program built with the mingw-w64 runtime imports fopen, fclose, fgets
and perror, and writes to the stream fopen returns with fprintf, fwrite
and fputs. The four did not resolve, and the output functions accepted
only stdout and stderr.
Adds the four services and file streams for the output functions. The
files are the ones on the in-memory C: drive behind CreateFileW, so a
file written through a C stream is the file ReadFile reads. Text mode,
the default, translates line ends as the fopen documentation describes.
Built on the standard streams from #400. Part of Gate A2.
Signed-off-by: zachdoxsee <zachdoxsee36@gmail.com>
A program built with the mingw-w64 runtime prints through
__stdio_common_vfprintf on the stream __acrt_iob_func(1) returns, and
through fwrite, fputs, fflush and setvbuf. None resolved, and there was
nowhere for standard output to go that a host or a test could read.
Adds a formatting engine for the narrow printf family (d, i, u, o, x, X,
c, s, p and %% with their flags, width, precision and size prefixes), the
three standard streams, those six services, and capture of stdout and
stderr through ServicesState. Floating-point and wide conversions, a
locale, files and input are not modelled and stop the guest.
The engine is compared with the host C library's snprintf on 2,600
generated cases whose result ISO C defines.
Part of Gate A2.
Signed-off-by: zachdoxsee <zachdoxsee36@gmail.com>
Both engines refused SHLD and SHRD (0F A4/A5, 0F AC/AD) as illegal
instructions. They are now declared in the x86 registry and run on the
shared semantics for 16-, 32- and 64-bit register and memory
destinations, with the count in an 8-bit immediate or in CL.
- instructions.toml, x86_table.rs (generated), generate_x86.py,
x86_decode.rs: the two operations and two operand encodings,
rm_reg_imm and rm_reg_cl (ModRM destination, reg source, count).
- x86_exec.rs: the destination is shifted with the vacated bits filled
from the source register. The count is masked to five bits (six for
64-bit operands), a masked count of zero changes nothing, CF takes the
last bit shifted out, ZF/SF/PF follow the result and OF is set only
for a count of one. A 16-bit count above 16 is undefined in the SDM;
the flags are kept and no test relies on the result.
- cpu_known_answers.rs: eight SDM-derived cases move from refused to
verified.
- tests/x86: 72 assembled SHLD and SHRD instructions, with a
bit-at-a-time reference in x86_integer.rs. A destination the
reference marks undefined now skips the memory operand check too.
- docs/cpu/instruction-registry.md, CHANGELOG.md.
Nothing is lowered to ARM64.
Signed-off-by: maridogolpeador <354308468+maridogolpeador@users.noreply.github.com>