Commit Graph

172 Commits

Author SHA1 Message Date
Andrew Kelley
07e47c058c ptrCast builtin now gives an error for removing const qualifier
closes #384
2018-03-06 16:37:03 -05:00
Andrew Kelley
439621e44a remove signal hanlding stuff from std.os.ChildProcess 2018-02-27 11:14:14 -05:00
Andrew Kelley
bde15cf080 improve std lib linux epoll API 2018-02-17 17:53:07 -05:00
Andrew Kelley
4a4ea92cf3 remove std.heap.IncrementingAllocator
Use std.heap.FixedBufferAllocator combined with
std.heap.DirectAllocator instead.

std.mem.FixedBufferAllocator is moved to std.heap.FixedBufferAllocator
2018-02-12 02:44:31 -05:00
Andrew Kelley
445b03384a introduce std.heap.ArenaAllocator and std.heap.DirectAllocator
* DirectAllocator does the underlying syscall for every allocation.
 * ArenaAllocator takes another allocator as an argument and
   allocates bytes up front, falling back to DirectAllocator with
   increasingly large allocation sizes, to avoid calling it too often.
   Then the entire arena can be freed at once.

The self hosted parser is updated to take advantage of ArenaAllocator
for the AST that it returns. This significantly reduces the complexity
of cleanup code.

docgen and build runner are updated to use the combination of
ArenaAllocator and DirectAllocator instead of IncrementingAllocator,
which is now deprecated in favor of FixedBufferAllocator combined
with DirectAllocator.

The C allocator calls aligned_alloc instead of malloc, in order to
respect the alignment parameter.

Added asserts in Allocator to ensure that implementors of the
interface return slices of the correct size.

Fixed a bug in Allocator when you call realloc to grow the allocation.
2018-02-12 02:14:44 -05:00
Andrew Kelley
e743b30bbf std: refactor posixOpen to be friendlier to error return traces 2018-02-11 05:26:51 -05:00
Andrew Kelley
46aa416c48 std.os and std.io API update
* 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`
2018-02-10 21:02:24 -05:00
Andrew Kelley
a2bd9f8912 std lib: modify allocator idiom
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
2018-02-09 18:27:50 -05:00
Andrew Kelley
32c988a2d7 fix build runner on windows 2018-02-09 00:24:23 -05:00
Andrew Kelley
f9be970375 Merge remote-tracking branch 'origin/master' into error-sets 2018-02-08 20:45:26 -05:00
Andrew Kelley
0d5ff6f462 error sets - most tests passing 2018-02-08 02:08:45 -05:00
Ben Noordhuis
dd20f558f0 implement openSelfExe() on darwin (#753) 2018-02-07 18:14:32 -05:00
Andrew Kelley
917e6fe370 handle linux returning EINVAL for large writes
See #743
2018-02-05 13:21:08 -05:00
Andrew Kelley
40e4e42a66 handle linux returning EINVAL for large reads
see #743
2018-02-05 12:48:29 -05:00
Andrew Kelley
44d8d654a0 fix test failure, organize code, add new compile error 2018-02-05 09:26:39 -05:00
Andrew Kelley
31abef172a fix accidentally linking against kernel32 on non windows 2018-02-04 22:13:21 -05:00
Ben Noordhuis
73ee434c8c Use /dev/urandom and sysctl(RANDOM_UUID) on Linux.
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.
2018-02-04 18:58:36 +01:00
Andrew Kelley
61718742f7 *WIP* error sets - std lib test compile but try to link against windows 2018-02-03 14:42:20 -05:00
Andrew Kelley
ef5e7bb469 *WIP* error sets - an inferred error set can end up being the global one 2018-02-03 14:06:37 -05:00
Andrew Kelley
abf5ae6897 *WIP* error sets - support fns called at comptime 2018-02-03 11:51:29 -05:00
Andrew Kelley
b8f59e14cd *WIP* error sets - correctly resolve inferred error sets 2018-02-02 18:13:32 -05:00
Andrew Kelley
13b36d458f *WIP* error sets - fix implicit cast 2018-02-01 10:23:25 -05:00
Andrew Kelley
5f518dbeb9 *WIP* error sets converting std lib 2018-01-31 22:48:40 -05:00
Andrew Kelley
5161d70620 *WIP* error sets 2018-01-31 01:51:31 -05:00
Andrew Kelley
2b5e0b66a2 std: fix fn return syntax for zen os 2018-01-29 10:57:27 -05:00
Andrew Kelley
3671582c15 syntax: functions require return type. remove ->
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.
2018-01-25 04:10:11 -05:00
Andrew Kelley
b3a6faf13e replace %defer with errdefer
See #632

now we have 1 less sigil
2018-01-23 23:08:09 -05:00
Andrew Kelley
cf39819478 add new kind of test: generating .h files. and more
* 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
2018-01-22 22:24:07 -05:00
Jimmi Holst Christensen
a76023bcd8 Removed PLARGE_INTEGER 2018-01-19 21:49:16 +01:00
Jimmi Holst Christensen
90714a3831 Implemented windows versions of seekTo and getPos 2018-01-19 21:30:57 +01:00
Andrew Kelley
7b57454cc1 clean up error return tracing
* 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
2018-01-15 00:01:02 -05:00
Andrew Kelley
3c094116aa remove %% prefix operator
See #632
closes #545
closes #510

this makes #651 higher priority
2018-01-09 00:51:51 -05:00
Andrea Orru
98a95cc698 exit, createThread for zen 2018-01-08 12:16:23 -05:00
Andrew Kelley
632d143bff replace a %% b with a catch b
See #632

better fits the convention of using keywords for control flow
2018-01-07 17:28:20 -05:00
Andrew Kelley
66717db735 replace %return with try
See #632

better fits the convention of using keywords for control flow
2018-01-07 16:53:13 -05:00
Andrea Orru
3182857224 Adding zen support 2018-01-07 04:43:08 -05:00
Andrea Orru
e932919e68 Darwin -> MacOSX, added Zen. See #438 2018-01-06 23:10:53 -05:00
Andrew Kelley
7e65fe7ac3 fix test regressions on windows from previous commit 2018-01-04 16:36:59 -05:00
Andrew Kelley
d008e209e7 self-hosted compiler works on macos 2018-01-04 15:30:22 -05:00
Andrew Kelley
e1c03d9e8e self-hosted compiler works on windows
* 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
2018-01-04 13:48:45 -05:00
Andrew Kelley
0cd63b28f3 fix self-hosted build on windows 2018-01-03 22:38:13 -05:00
Andrew Kelley
36ff26609b fix self hosted compiler on windows 2018-01-03 04:55:49 -05:00
Andrew Kelley
4183c6f1a5 move std/debug.zig to a subdirectory
self hosted compiler parser tests do some fuzz testing
2017-12-23 22:15:48 -05:00
Andrew Kelley
2031989d98 std.os.path.resolve handles an absolute path that is missing the drive 2017-12-23 22:14:35 -05:00
Andrew Kelley
39c7bd24e4 port most of main.cpp to self hosted compiler 2017-12-23 00:57:56 -05:00
Josh Wolfe
0e7fb69bea bufPrint returns an error 2017-12-22 00:52:01 -07:00
Andrew Kelley
ea805c5fe7 fix darwin and windows from previous commit 2017-12-22 02:33:39 -05:00
Andrew Kelley
d917815d81 explicitly return from blocks
instead of last statement being expression value

closes #629
2017-12-22 00:50:30 -05:00
Andrew Kelley
8bc523219c add labeled loops, labeled break, labeled continue. remove goto
closes #346
closes #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.
2017-12-20 23:00:19 -05:00
Andrew Kelley
1fdebc1dc4 wip export rewrite 2017-12-18 09:59:57 -05:00