Commit Graph

58 Commits

Author SHA1 Message Date
gingerBill 7f601c9535 Add Allocator_Mode.Alloc_Non_Zerored 2022-09-22 12:12:57 +01:00
gingerBill cb9e16f4df Correct syscalls for linux_i386 2022-08-24 12:37:56 +01:00
Tetralux 57167be2a6 [os] Linux: os.unset_env() 2022-05-18 07:12:30 +00:00
Tetralux b5b329378f [os] Linux: Add os.exists(), os.get_env(), os.lookup_env(), os.set_env()
exists() does the access() syscall.

Renames getenv() to get_env() to match Windows.
2022-05-14 20:14:10 +00:00
gingerBill 5d190b15d7 Minor improvements to io and os 2022-05-05 15:30:07 +01:00
Sébastien Marie 8982ae34e3 fix linux_arm64
- SYS_fork doesn't exist, uses SYS_clone
- properly cast AT_FDCWD to uintptr
2022-03-12 09:19:52 +00:00
gingerBill 17eebf338c Fix #1606 (Call runtime._cleanup_runtime_contextless() for os.exit) 2022-03-09 15:05:51 +00:00
Sébastien Marie 14f1793b3e use context.temp_allocator instead of general allocation + delete()
where clone_to_cstring is used with foreign code, it is prefered to use `context.temp_allocator` instead of using the general allocator and manually delete the memory after use.
2022-02-24 11:28:42 +00:00
Colin Davidson 54a6637d38 Use the _unix_fstat pointer to avoid 144B copies on fileIO 2022-02-18 20:50:49 -08:00
Colin Davidson 536bf61323 avoid memset on stats 2022-02-16 08:14:11 -08:00
Jeroen van Rijn 855e7beab1 Merge pull request #1488 from colrdavidson/master
Add fork and personality
2022-02-15 21:04:09 +01:00
gingerBill f5697dd7f2 Merge branch 'master' into odin-global-constants-as-enums 2022-02-15 15:47:24 +00:00
Colin Davidson f77cd5533d Add fork and personality 2022-02-11 08:10:48 -08:00
gingerBill fb710f8cbf Merge pull request #1376 from jasonKercher/master
Added zeroing to new memory regions from _unix_realloc
2022-02-05 12:26:10 +00:00
gingerBill 3d7d347192 Convert ODIN_OS and ODIN_ARCH to use enums rather than use strings 2022-01-20 19:56:05 +00:00
CiD- 8eaafd5242 check correct errno in _readlink 2022-01-12 14:51:49 -05:00
CiD- 774951e8c0 os_linux additions + libc to syscalls 2022-01-12 14:36:18 -05:00
CiD- ebdb3ab43a added notes about _unix_alloc 2021-12-17 12:04:05 -05:00
Yawning Angel 61c581baeb core/sys/unix: Add syscalls_linux.odin
Linux is in the unfortunate situation where the system call number is
architecture specific.  This consolidates the system call number
definitions in a single location, adds some wrappers, and hopefully
fixes the existing non-portable invocations of the syscall intrinsic.
2021-11-17 14:00:00 +00:00
gingerBill ca33cb990b Strip semicolons in core which were missing 2021-09-08 13:12:38 +01:00
gingerBill 5f29288254 Remove Syscall type 2021-08-29 15:00:35 +01:00
gingerBill 7c108dbf48 Update usage of syscall to use the intrinsics 2021-08-29 14:56:47 +01:00
gingerBill 19aefa6a40 Add assignment statement to #no_bounds_check etc rules. Correct os_linux.odin usage. 2021-08-15 11:14:34 +01:00
gingerBill 465b6139d5 Temporarily fix syscall in Linux and Freebsd (eventually to be replaced with a proper implementation) 2021-05-13 12:05:23 +01:00
gingerBill 359ae29d98 Minor fixes 2021-03-18 13:25:41 +00:00
gingerBill a2557142cc Update package os for package path/filepath support on macOS 2021-02-27 11:30:43 +00:00
gingerBill aa93305015 Replace usage of inline proc with #force_inline proc in the core library 2021-02-23 16:14:47 +00:00
gingerBill d5dfa14f18 Clear up fmt.wprint* length logic 2021-02-11 10:44:38 +00:00
Luka Aleksić ac184957db Fix CI 2021-01-21 20:55:58 +01:00
Luka Aleksić 92e23ec397 * Add some procedures to path_unix to mirror the path_windows API
* Add files stat_linux and dir_linux to mirror the stat/dir_windows API
* Add helper functions to os_linux that are used by the above
2021-01-21 20:20:38 +01:00
kennethmaples 6d5bd8bead Fix layout of Stat for linux and make usage consistent across unix variants 2020-12-29 17:45:19 +08:00
gingerBill fc4fdd588e Remove usage of do in core library 2020-09-23 17:17:14 +01:00
gingerBill 65b9dbe13f Clean-up OS constants; Clean-up procs_wasm32.odin 2020-07-09 17:21:40 +01:00
gingerBill a89633e3ed Remove return after unreachable 2020-06-06 15:22:22 +01:00
Tyler Erickson f6f2ab2f25 Fixed bad merge 2020-03-05 19:29:32 -08:00
Tyler Erickson bb026c99a9 Merged with master 2020-03-05 16:49:53 -08:00
Tyler Erickson 2817bab494 Fix os_linux stat 2020-03-05 12:13:22 -08:00
Tetralux 66d1656367 Add os.get_current_directory / os.set_current_directory 2020-01-20 14:28:31 +00:00
Justas Dabrila 005c6af302 Fix improper _unix_open binding that was ignoring the mode arg 2019-12-23 16:34:20 +02:00
Tetralux 99121d6ff2 Implement core:thread and core:sync on Unix using pthreads
Also do some cleanup and refactoring of the thread, sync and time APIs.

- remove 'semaphore_release' because 'post' and 'wait' is easier to understand

- change 'semaphore_wait' to '*_wait_for' to match Condition

- pthreads can be given a stack, but doing so requires the user to set up the guard
  pages manually. BE WARNED. The alignment requirements of the stack are also
  platform-dependant; it may need to be page size aligned on some systems.
  Unclear which systems, however. See 'os.get_page_size', and 'mem.make_aligned'.
  HOWEVER: I was unable to get custom stacks with guard pages working reliably,
  so while you can do it, the API does not support it.

- add 'os.get_page_size', 'mem.make_aligned', and 'mem.new_aligned'.

- removed thread return values because windows and linux are not consistent; windows returns 'i32'
  and pthreads return 'void*'; besides which, if you really wanted to communicate how the
  thread exited, you probably wouldn't do it with the thread's exit code.

- fixed 'thread.is_done' on Windows; it didn't report true immediately after calling 'thread.join'.

- moved time related stuff out of 'core:os' to 'core:time'.

- add 'mem.align_backward'

- fixed default allocator alignment
  The heap on Windows, and calloc on Linux, both have no facility to request alignment.
  It's a bit of hack, but the heap_allocator now overallocates; `size + alignment` bytes,
  and aligns things to at least 2.
  It does both of these things to ensure that there is at least two bytes before the payload,
  which it uses to store how much padding it needed to insert in order to fulfil the alignment
  requested.

- make conditions more sane by matching the Windows behaviour.
  The fact that they were signalled now lingers until a thread tries to wait,
  causing them to just pass by uninterrupted, without sleeping or locking the
  underlying mutex, as it would otherwise need to do.
  This means that a thread no longer has to be waiting in order to be signalled, which
  avoids timing bugs that causes deadlocks that are hard to debug and fix.
  See the comment on the `sync.Condition.flag` field.

- add thread priority: `thread.create(worker_proc, .High)`
2019-12-01 00:46:23 +00:00
gingerBill 902d313c6a Fix issue with os.write on *nix with writing nothing 2019-11-24 10:08:08 +00:00
gingerBill 980890ee8a Make -vet happy on *nix 2019-08-13 22:39:53 +01:00
matt 314d5a778e Replace calls to deprecated string functions on linux 2019-03-18 07:13:52 -07:00
gingerBill 594238a86c Reorganize fmt and strings; Replace fmt.String_Buffer with strings.Builder 2019-01-06 14:41:42 +00:00
matt e084799b31 Fix bugs and inconsistencies with linux versions of os package 2018-12-30 02:06:41 -07:00
matt 0bcf53b513 Fix os.open on linux/osx 2018-12-26 04:31:12 -07:00
CaptainKraft cfcb0514bf Add the missing INVALID_HANDLE so that the demo will build and run on Linux. 2018-12-09 20:52:03 -06:00
Jeroen van Rijn 1584260886 Add Linux support for core:time
In addition to sleep() and now(), it also defines nanosleep(), boot_time() and seconds_since_boot()
2018-12-08 20:39:33 +01:00
gingerBill ce2e23849e Fix context initialization 2018-10-20 16:34:56 +01:00
gingerBill 307c58d908 Fix compilation error #272 2018-10-17 15:27:36 +01:00