Use std.heap.FixedBufferAllocator combined with
std.heap.DirectAllocator instead.
std.mem.FixedBufferAllocator is moved to std.heap.FixedBufferAllocator
* move std.io.File to std.os.File
* add `zig fmt` to self hosted compiler
* introduce std.io.BufferedAtomicFile API
* introduce std.os.AtomicFile API
* add `std.os.default_file_mode`
* change FileMode on posix from being a usize to a u32
* add std.os.File.mode to return mode of an open file
* std.os.copyFile copies the mode from the source file instead of
using the default file mode for the dest file
* move `std.os.line_sep` to `std.cstr.line_sep`
Before we accepted a nullable allocator for some stuff like
opening files. Now we require an allocator.
Use the mem.FixedBufferAllocator pattern if a bound on the amount
to allocate is known.
This also establishes the pattern that usually an allocator is the
first argument to a function (possibly after "self").
fix docs for std.cstr.addNullByte
self hosted compiler:
* only build docs when explicitly asked to
* clean up main
* stub out zig fmt
Add fallback paths for when the getrandom(2) system call is not
available. Try /dev/urandom first and sysctl(RANDOM_UUID) second.
The sysctl issues a warning in the system logs with some kernels but
that seems like an acceptable tradeoff for the fallback of a fallback.
The purpose of this is:
* Only one way to do things
* Changing a function with void return type to return a possible
error becomes a 1 character change, subtly encouraging
people to use errors.
See #632
Here are some imperfect sed commands for performing this update:
remove arrow:
```
sed -i 's/\(\bfn\b.*\)-> /\1/g' $(find . -name "*.zig")
```
add void:
```
sed -i 's/\(\bfn\b.*\))\s*{/\1) void {/g' $(find ../ -name "*.zig")
```
Some cleanup may be necessary, but this should do the bulk of the work.
* docgen supports obj_err code kind for demonstrating
errors without explicit test cases
* add documentation for `extern enum`. See #367
* remove coldcc keyword and add @setIsCold. See #661
* add compile errors for non-extern struct, enum, unions
in function signatures
* add .h file generation for extern struct, enum, unions
* error return tracing is disabled in release-fast mode
* add @errorReturnTrace
* zig build API changes build return type from `void` to `%void`
* allow `void`, `noreturn`, and `u8` from main. closes#535
* better error message for realpath failing
* fix bug in std.io.readFileAllocExtra incorrectly returning
error.EndOfStream
* implement std.os.selfExePath and std.os.selfExeDirPath for windows
closes#346closes#630
regression: translate-c can no longer translate switch statements.
after #629 we can ressurect and modify the code to utilize arbitrarily
returning from blocks.
* add @noInlineCall - see #640
This fixes a crash in --release-safe and --release-fast modes
where the optimizer inlines everything into _start and
clobbers the command line argument data.
If we were able to verify that the user's code never reads
command line args, we could leave off this "no inline"
attribute.
* add i29 and u29 primitive types. u29 is the type of alignment,
so it makes sense to be a primitive.
probably in the future we'll make any `i` or `u` followed by
digits into a primitive.
* add `aligned` functions to Allocator interface
* add `os.argsAlloc` and `os.argsFree` so that you can get
a `[]const []u8`, do whatever arg parsing you want, and then free
it. For now this uses the other API under the hood, but it could
be reimplemented to do a single allocation.
* add tests to make sure command line argument parsing works.
* rename decode to decodeExactUnsafe.
* add decodeExact, which checks for invalid chars and padding.
* add decodeWithIgnore, which also allows ignoring chars.
* alphabets are supplied to the decoders with their
char-to-index mapping already built, which enables it to be
done at comptime.
* all decode/encode apis except decodeWithIgnore require dest
to be the exactly correct length. This is calculated by a
calc function corresponding to each api. These apis no longer
return the dest parameter.
* for decodeWithIgnore, an exact size cannot be known a priori.
Instead, a calc function gives an upperbound, and a runtime
error is returned in case of overflow. decodeWithIgnore
returns the number of bytes written to dest.
closes#611
* fix fstat wrong on darwin
* move std.debug.global_allocator to std.debug.global_allocator_state and make it private
* add std.debug.global_allocator as a pointer (to upgrade your zig code remove
the '&')
I started working on #465 and made some corresponding std.io
API changes.
New structs:
* std.io.FileInStream
* std.io.FileOutStream
* std.io.BufferedOutStream
* std.io.BufferedInStream
Removed:
* std.io.File.in_stream
* std.io.File.out_stream
Now instead of &file.out_stream or &file.in_stream to get access to
the stream API for a file, you get it like this:
var file_in_stream = io.FileInStream.init(&file);
const in_stream = &file_in_stream.stream;
var file_out_stream = io.FileOutStream.init(&file);
const out_stream = &file_out_stream.stream;
This is evidence that we might not need any OOP features -
See #130.