Commit Graph

47 Commits

Author SHA1 Message Date
William Roe bb4329711c [os] Darwin: Add os.exists() 2022-05-28 15:21:07 +01:00
William Roe 54a326f046 [os] Darwin,FreeBSD,OpenBSD: Rename os.getenv to os.get_env
Make os.get_env consistent across Unixes

This matches the function name and API from env_windows.odin and os_linux.odin, which should be the same everywhere. Meaning:

* named get_env and not getenv
* return a string (empty if the environment variable is not found)
* accept a default value parameter for the allocator (defaulting to context.allocator)
* calls lookup_env which returns an extra found boolean value

This is so that you don't have to write platform/OS conditionals when getting environment variable values from the stdlib os.get_env/getenv function.
2022-05-23 13:48:55 +01:00
Vitaly Kravchenko 9e2a847ebc Typo fix 2022-05-13 09:32:04 +01:00
Vitaly Kravchenko daef39a206 os_darwin.odin fixes 2022-05-13 09:27:15 +01:00
gingerBill 5d190b15d7 Minor improvements to io and os 2022-05-05 15:30:07 +01:00
Sébastien Marie 036900da51 fix mode_t on darwin
- fix mkdir() prototype (mode_t is u16)
- remove explicit cast
2022-03-13 12:41:03 +00:00
gingerBill 17eebf338c Fix #1606 (Call runtime._cleanup_runtime_contextless() for os.exit) 2022-03-09 15:05:51 +00:00
Jeroen van Rijn 3a469dc13e Merge pull request #1549 from semarie/clone_to_cstring-leak
delete allocated memory with clone_to_cstring
2022-02-24 12:42:15 +01: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 aeaf1199ec Add make_directory so darwin can build html docs 2022-02-24 01:13:51 -08:00
gingerBill d695a8a526 Update os_darwin.odin 2022-02-15 16:02:14 +00:00
gingerBill f5697dd7f2 Merge branch 'master' into odin-global-constants-as-enums 2022-02-15 15:47:24 +00:00
Platin21 a724573bb3 Fixes fopendir and readdir_r for arm64 or seemingly doing so 2022-02-05 21:16:58 +01:00
Platin21 3edf638cc6 Fixed Typo 2022-02-05 20:54:27 +01:00
Platin21 a571153458 Adds missing calls for os 2022-02-05 20:45:32 +01: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 da1edac56d Enforce -strict-style in CI 2022-01-31 11:29:05 +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
Platin21 8ff6f95571 Removes the default create flag 2022-01-03 20:40:56 +01:00
Platin21 68e5f57e27 Fixes open system call (Thanks TIM!) 2022-01-03 20:34:57 +01:00
CiD- ebdb3ab43a added notes about _unix_alloc 2021-12-17 12:04:05 -05:00
gingerBill 94a27224b2 Deprecate strings.write_quoted_* in favour of io.write_quoted_*; make reflect.write_type a little more robust with io.Error handling 2021-09-29 13:42:58 +01:00
Ricardo Silva 01aa0c4151 Fix read_dir on OSX 2021-09-13 12:34:36 +01:00
Ricardo Silva 87408aedb5 replace lstat/fstat with lstat64/fstat64 since they return the correct values 2021-09-10 14:18:08 +01:00
Ricardo Silva 43c578d8b7 Fix absolute_path_from_handle on OSX 2021-09-09 17:12:26 +01:00
gingerBill ca33cb990b Strip semicolons in core which were missing 2021-09-08 13:12:38 +01:00
gingerBill af95381bf8 Add missing -> ! annotation 2021-06-16 12:12:24 +01:00
gingerBill 9f8a63cb43 More minor stylization changes (remove unneeded parentheses) 2021-06-14 11:34:31 +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
kennethmaples 6d5bd8bead Fix layout of Stat for linux and make usage consistent across unix variants 2020-12-29 17:45:19 +08:00
Platin21 a71cbd4087 Changed foreign imports to now use the System Framework 2020-09-27 21:57:27 +03:00
gingerBill fc4fdd588e Remove usage of do in core library 2020-09-23 17:17:14 +01:00
Oskar Nordquist a7e38dc063 Implement os.current_thread_id() for Darwin (assumes OSX 10.6 / iOS 3.2 and later) 2020-07-22 17:38:13 +02:00
gingerBill 65b9dbe13f Clean-up OS constants; Clean-up procs_wasm32.odin 2020-07-09 17:21:40 +01:00
gingerBill 86448ee044 Add raw_data to replace cases in which &x[0] was used 2020-06-29 15:58:24 +01:00
gingerBill a89633e3ed Remove return after unreachable 2020-06-06 15:22:22 +01:00
Hasen Judy 705984f828 Fix darwin open flags and mode 2020-04-19 01:39:22 +09:00
Clay Murray 85f2f4aa88 Fix issues with stat struct.
The stat struct was the format for the 64 bit version of stat. So we need to call stat64 to get the proper data.
Also we need to use _File_Time instead of File_Time because it is a compound value. 

These changes were tested and work on my computer, MacOS 64 bit.
2020-03-03 19:42:20 -07:00
Tetralux 66d1656367 Add os.get_current_directory / os.set_current_directory 2020-01-20 14:28:31 +00: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 9b4d4a2c61 Minor fix to os.write on darwin 2019-11-16 06:59:14 -08:00
Chris Heyes adca5b57cd Move time code from os to time package 2019-11-01 19:33:48 +00:00
Chris Heyes 153e7525b5 Merge remote-tracking branch 'upstream/master' 2019-11-01 19:18:33 +00:00
gingerBill 66ae4e5afc Change ODIN_OS string for osx from "osx" to "darwin" to allow for other platforms 2019-10-01 20:38:50 +01:00