Commit Graph

60 Commits

Author SHA1 Message Date
LemonBoy 594366a482 Fix os.mprotect signature 2019-05-28 18:25:48 +02:00
Andrew Kelley 3640303ce1 freebsd fixes 2019-05-27 17:28:59 -04:00
Andrew Kelley af4b8eb6c0 windows does not integrate cleanly with libc 2019-05-27 15:55:15 -04:00
Andrew Kelley 86bb7e5984 fixes for windows to build self hosted compiler 2019-05-27 15:55:15 -04:00
Andrew Kelley b3dc1c380d use close$NOCANCEL on darwin 2019-05-27 14:41:13 -04:00
Andrew Kelley 06435535d3 fixes for darwin 2019-05-27 14:12:50 -04:00
Andrew Kelley f1610f6c1d nanosleep: move windows logic to std.time 2019-05-27 12:16:32 -04:00
Andrew Kelley fda7e0bb01 std lib fixes for zig build on windows 2019-05-27 02:00:39 -04:00
Andrew Kelley 129714d077 more fixes for windows and wasi 2019-05-27 01:35:58 -04:00
Andrew Kelley 6be79d79aa fixes for Windows and WASI 2019-05-27 00:48:56 -04:00
Andrew Kelley 0c6ab61b22 tests passing on linux 2019-05-26 23:35:26 -04:00
Andrew Kelley 2b42e910bf behavior tests passing on Linux 2019-05-26 19:56:37 -04:00
Andrew Kelley 44a049e01e more cleanup. down to just the @hasDecl builtin 2019-05-26 18:32:45 -04:00
Andrew Kelley 2f040a23c8 clean up references to os 2019-05-26 18:32:44 -04:00
Andrew Kelley 7cb6279ac0 clean up references to posix 2019-05-26 18:32:44 -04:00
Andrew Kelley ca6debcaf4 starting to fix the regressions 2019-05-26 18:32:44 -04:00
Andrew Kelley 3d61e42282 rename "posix" to "bits" 2019-05-26 18:32:44 -04:00
Andrew Kelley 17b0166e00 do Jay's suggestion with posix/os API naming & layout 2019-05-26 18:32:44 -04:00
Andrew Kelley 2def23063f more progress. moving windows API layer to its own file 2019-05-26 18:32:44 -04:00
Andrew Kelley daae7e1f5a more progress on posix API layer
see #2380
2019-05-26 18:32:43 -04:00
Andrew Kelley 67726e36b0 extract posix functions from std/os.zig to std/os/posix.zig
See #2380
2019-05-26 18:32:40 -04:00
Shawn Landden 1fdb24827f breaking changes to all bit manipulation intrinsics
* `@clz`, `@ctz`, `@popCount`, `@bswap`, `@bitreverse` now
   have a type parameter
 * rename @bitreverse to @bitReverse
 * rename @bswap to @byteSwap

Closes #2119
Closes #2120
2019-05-16 16:37:58 -04:00
Andrew Kelley 72899da44b fix std.os.copyFile
closes #2454
2019-05-09 13:05:06 -04:00
LemonBoy d8ab301aa8 std: Implement TLS support for Linux
Tested on x86_64, i386, ARM, AARCH64
2019-05-07 13:09:18 +02:00
Shritesh Bhattarai 84682eb862 wasi: implement os.exit 2019-05-02 11:26:33 -05:00
Shritesh Bhattarai 6fb677c4f6 wasi: native os.abort 2019-05-02 11:25:25 -05:00
Shritesh Bhattarai 1fabd6bbf3 wasi: implement getRandomBytes 2019-04-30 20:50:41 -04:00
Shritesh Bhattarai 0a693b70e4 wasi: use mem.separate instead 2019-04-30 18:43:43 -05:00
Shritesh Bhattarai 20458f56d8 wasi: add getEnvMap 2019-04-30 18:18:20 -05:00
Shritesh Bhattarai 01365be82f WASI: implement argsAlloc and argsFree (#2364)
* wasi: change URL to canon WASI-core.md

* wasi: import args_get and args_sizes_get

* wasi: Implement argsAlloc and argsFree

* test return value for wasi arg syscalls

* wasi: return unexpectedErrorPosix in argsAlloc

* wasi: Add TODO for ArgIterator
2019-04-29 21:54:30 -04:00
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