Commit Graph

30 Commits (8ce130de3cf38e09cfbcbd1b22da34ae5b27a040)

Author SHA1 Message Date
Andrew Kelley 0a280b6062
update std.os.page_size for WebAssembly 2019-04-15 21:20:41 -04:00
Shritesh Bhattarai 72bcd5a4a5 WIP: hello world 2019-04-13 15:15:39 -05:00
Andrew Kelley fd65cdc55a
fix incorrect Thread.getCurrentId test
Documentation comments copied here:

On Linux, it is possible that the thread spawned with `spawnThread`
finishes executing entirely before the clone syscall completes. In this
case, `std.os.Thread.handle` will return 0 rather than the
no-longer-existing thread's pid.
2019-04-05 16:06:35 -04:00
Andrew Kelley 947c87b558
threads: fix using unmapped memory in some cases
as pointed out in #musl IRC, the memory for the fs register address
value needs to be taken into account in the mmap call.
2019-04-04 01:36:01 -04:00
Andrew Kelley e4d595a8ba
fix thread local variables for non- position independent code
This fixes comes thanks to Rich Felker from the musl libc project,
who gave me this crucial information:

"to satisfy the abi, your init code has to write the same value
to that memory location as the value passed to the [arch_prctl]
syscall"

This commit also changes the rules for when to build statically
by default. When building objects and static libraries, position
independent code is disabled if no libraries will be dynamically
linked and the target does not require position independent code.

closes #2063
2019-04-04 01:08:26 -04:00
Shritesh Bhattarai 85575704a4 Use linux.exit_group if not single threaded 2019-03-26 17:49:20 -04:00
Andrew Kelley 64dddd7afe
add compile error for ignoring error
closes #772
2019-03-23 19:33:00 -04:00
Andrew Kelley 9c13e9b7ed
breaking changes to std.mem.Allocator interface API
Before, allocator implementations had to provide `allocFn`,
`reallocFn`, and `freeFn`.

Now, they must provide only `reallocFn` and `shrinkFn`.
Reallocating from a zero length slice is allocation, and
shrinking to a zero length slice is freeing.

When the new memory size is less than or equal to the
previous allocation size, `reallocFn` now has the option
to return `error.OutOfMemory` to indicate that the allocator
would not be able to take advantage of the new size.

For more details see #1306. This commit closes #1306.

This commit paves the way to solving #2009.

This commit also introduces a memory leak to all coroutines.
There is an issue where a coroutine calls the function and it
frees its own stack frame, but then the return value of `shrinkFn`
is a slice, which is implemented as an sret struct. Writing to
the return pointer causes invalid memory write. We could work
around it by having a global helper function which has a void
return type and calling that instead. But instead this hack will
suffice until I rework coroutines to be non-allocating. Basically
coroutines are not supported right now until they are reworked as
in #1194.
2019-03-15 17:57:21 -04:00
Andrew Kelley e2f4df6065
std.os.changeCurDir no longer needs an allocator 2019-03-05 18:43:39 -05:00
Andrew Kelley e402455704
rename std lib files to new convention 2019-03-02 16:46:04 -05:00
Andrew Kelley 5bc9feb5cb organize std and make import relative to current file
closes #216
2017-03-26 06:39:28 -04:00
Andrew Kelley 451ce09067 new unreachable syntax
* `noreturn` is the primitive type.
 * `unreachable` is a control flow keyword.
 * `@unreachable()` builtin function is deleted.

closes #214
2017-03-26 04:58:48 -04:00
Andrew Kelley d6856859d3 improvements for windows and libc integration
* standard library knows if it is linking against libc and will
   sometimes call libc functions in that case instead of providing
   redundant definitions
 * fix infinite loop bug when resolving use declarations
 * allow calling the same C function from different C imports.
   closes #277
 * push more logic from compiler to std/bootstrap.zig
 * standard library provides way to access errno
   closes #274
 * fix compile error in standard library for windows
 * add implementation of getRandomBytes for windows
2017-03-23 02:59:58 -04:00
Andrew Kelley a665872e88 add compile error for ignoring return value
also introduce the _ identifier which you can assign to
to discard a return value

closes #219
2017-02-24 15:01:19 -05:00
Andrew Kelley 69132bdeda IR: progress toward compiling standard library
* comptime fn call
 * is_comptime doesn't count as an instruction dependency
 * update more std code to latest zig
2016-12-31 17:10:29 -05:00
Andrew Kelley b55efe5fab update more std library to new zig 2016-12-21 23:34:14 -05:00
Andrew Kelley b581da41f8 remove compiler directives
* add `setFnTest`, `setFnVisible`, `setFnStaticEval`,
   `setFnNoInline` builtin functions to replace previous
   directive functionality
 * add `coldcc` and `nakedcc` as keywords which can be used as part
   of a function prototype.
 * `setDebugSafety` builtin can be used to set debug safety features
   at a per block scope level.
 * closes #169
2016-09-28 02:33:32 -04:00
alter cf9b21c09f MacOSX compatibility
- Implemented some syscall for MacOSX
- tested on : El Capitan 10.11 x86_64
- make self hosted test run on macosx
- modified run_test so it does not fail when parseh throws
  warnings (most of them are related to buildin types from
  gcc that arent defined in header files and unions)
- making -mmacosx-version-min and -mios-version-min works like
  gcc (command line paramers have precedence over enviroment variables)
2016-09-14 02:46:02 -04:00
Andrew Kelley 06f2f4d64b change `unreachable{}` to `@unreachable()`
instead of a container init expression, it's a builtin
function call.
2016-09-13 16:46:27 -04:00
Andrew Kelley 768a9780ca rename compileErr builtin to compileError 2016-09-05 17:01:54 -04:00
Andrew Kelley ed50bd1b65 progress toward stack trace printing 2016-08-17 20:11:04 -07:00
Andrew Kelley 37d167f6e0 std: conform to style guidelines 2016-08-16 22:42:50 -07:00
Andrew Kelley bc81ddfea6 unsigned integers for sizes of things
Closes #62.
2016-07-26 20:40:11 -07:00
Andrew Kelley 6ae6b5f5b5 add compile_err builtin 2016-05-14 18:54:37 -07:00
Andrew Kelley 9658c05fd4 std: remove broken windows random implementation 2016-04-19 17:15:23 -07:00
Andrew Kelley f4c7e1bf49 rearrange standard library a bit 2016-04-18 16:42:56 -07:00
Andrew Kelley 9c3d7b628c rename syscall.zig to linux.zig 2016-03-01 14:11:38 -07:00
Andrew Kelley f1d338194e rewrite how importing works
* Introduce the concept of packages. Closes #3
 * Add support for error notes.
 * Introduce `@import` and `@c_import` builtin functions and
   remove the `import` and `c_import` top level declarations.
 * Introduce the `use` top level declaration.
 * Add `--check-unused` parameter to perform semantic
   analysis and codegen on all top level declarations, not
   just exported ones and ones referenced by exported ones.
 * Delete the root export node and add `--library` argument.
2016-03-01 03:13:40 -07:00
Andrew Kelley 01fda6199e dummy implementation of os_get_random_bytes for windows 2016-02-13 22:59:49 -07:00
Andrew Kelley bb4a532785 move os_get_random_bytes to os.zig 2016-02-04 01:00:54 -07:00