Commit Graph

45 Commits

Author SHA1 Message Date
Jeroen van Rijn 962d599996 Fix reading from /sys/ pseudo fx 2023-10-26 14:30:04 +02:00
jason f9c600a760 add nil check to heap_alloc calls (issue 2530) 2023-05-11 14:04:09 -04:00
Daniel d23d7cf0f2 Add caller location info to os.read_entire_file()
This helps people using the mem.Tracking_Allocator to more easily
pinpoint where they leaked memory in their own code, rather than
having the leaks be reported as if they were in the core library
itself.
2023-01-27 02:42:16 -05:00
Colin Davidson 6ff2db47b4 shuffle to private/public wrapper 2023-01-06 13:33:47 -08:00
gingerBill 7f601c9535 Add Allocator_Mode.Alloc_Non_Zerored 2022-09-22 12:12:57 +01:00
Vitaly Kravchenko d469c2da48 Fix indent 2022-09-21 17:31:37 +01:00
gingerBill 5d190b15d7 Minor improvements to io and os 2022-05-05 15:30:07 +01:00
gingerBill f5697dd7f2 Merge branch 'master' into odin-global-constants-as-enums 2022-02-15 15:47:24 +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- e5868e3205 add zeroing regardless of ODIN_OS 2022-01-20 10:17:47 -05:00
CiD- 29ca6ee420 add zeroing to new region from realloc 2021-12-17 10:41:49 -05:00
gingerBill c9c197ba08 Add os.read_at_least and os_read_full utility procedures. 2021-11-27 14:57:49 +00:00
zhibog c632125d82 Added a read_entire_file proc that only takes a handle and turned it into a proc group with the one, that takes a path 2021-10-16 18:45:25 +02:00
Jeroen van Rijn 72fe1e88a3 Make sure to delete on the right allocator. 2021-09-19 12:19:01 +02:00
gingerBill 251da264ed Remove unneeded semicolons from the core library 2021-08-31 22:21:13 +01:00
gingerBill 4d00c2b800 Allocator_Error.Mode_Not_Implemented; Minor improvement to map runtime procedures 2021-08-08 14:29:45 +01:00
gingerBill e9b1d4f633 Fix #906 2021-04-20 10:34:41 +01:00
gingerBill f98c4d6837 Improve the Allocator interface to support returning Allocator_Error to allow for safer calls
Virtually all code (except for user-written custom allocators) should work as normal. Extra features will need to be added to make the current procedures support the `Allocator_Error` return value (akin to #optional_ok)
2021-04-19 12:31:31 +01:00
gingerBill fc4fdd588e Remove usage of do in core library 2020-09-23 17:17:14 +01:00
gingerBill 9f1f194d18 Merge pull request #727 from JoshuaManton/master-fork
Add allocator parameter to os.read_entire_file()
2020-09-03 08:37:22 +01:00
Joshua Mark Manton 0fe47a2f1b Add allocator parameter to os.read_entire_file() 2020-09-02 18:42:12 -07:00
gingerBill e7f54d25d6 Add mem.Allocator_Query_Info and mem.query_info 2020-08-16 23:05:33 +01:00
gingerBill 033b46def8 Add mem.Allocator_Mode.Query_Features, mem.Allocator_Mode_Set, mem.query_features` 2020-08-16 22:07:40 +01:00
gingerBill 65b9dbe13f Clean-up OS constants; Clean-up procs_wasm32.odin 2020-07-09 17:21:40 +01:00
Hasen Judy 705984f828 Fix darwin open flags and mode 2020-04-19 01:39:22 +09:00
gingerBill a0d0e93475 Fix os.read_entire_file 2020-03-12 23:45:46 +00:00
Tetralux 1181d7cf90 Fix os.read / os.read_entire_file
- DWORDs are NOT i32
- os.read didn't correctly read as much as it could
2020-03-12 22:31:00 +00:00
Tetralux a4b60b78c8 Fix heap allocator alignment on all platforms 2020-01-22 12:03:16 +00:00
Justas Dabrila 38a9a2b7fc Linux: write_entire_file sets 644 permissions on open. 2019-12-23 16:35:10 +02:00
gingerBill ee78374281 Fix typo 2019-12-01 18:57:43 +00:00
gingerBill ebe152a155 Disable aligned heap allocations hack in os.heap_allocator_proc 2019-12-01 18:53:27 +00:00
gingerBill 9db81498d8 Make the string type elements "immutable", akin to char const * in C
Allows for extra security and optimization benefits
2019-12-01 14:10:59 +00:00
gingerBill 7fbe0a6f23 Fix nil comparisons for soa slices and dynamic arrays 2019-12-01 11:56:08 +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 c634d4a96d Using implicit selector expressions in the core library 2019-03-06 19:13:50 +00:00
gingerBill 76a6757ee9 Add os.file_size_from_path 2019-02-25 18:03:44 +00:00
gingerBill 0971a59493 Update runtime printing code 2018-10-11 18:19:29 +01:00
gingerBill aa542980ce Change memory layout of map to be 3 words smaller 2018-08-30 19:14:10 +01:00
gingerBill 0858ae2024 Add utf8_to_ucs2 for package win32 so that the wide procedures can used by default 2018-08-30 10:59:46 +01:00
gingerBill 0718f14774 Reduce number of range and slice operators #239
Replace .. and ... with : and ..
2018-08-01 21:34:59 +01:00
gingerBill 0e91298fd1 Rename free to delete for non pointer types 2018-07-08 11:03:56 +01:00
gingerBill e46662a546 Rename os.default_allocator to os.heap_allocator 2018-06-03 16:40:58 +01:00
gingerBill d556fa2cd8 Remove special shared scope for runtime stuff 2018-06-03 15:06:40 +01:00
gingerBill 5c52ffe24e Reorganize runtime package 2018-05-27 21:22:25 +01:00
gingerBill 5b6770f3d2 Parse directories to be packages 2018-05-21 20:47:52 +01:00