Commit Graph

794 Commits

Author SHA1 Message Date
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
b75d59d6e0 Make sort.merge_sort in place; Add sort.heap_sort 2019-11-27 16:06:07 +00:00
gingerBill
71c8a3456e Update package odin/parser for #soa and #vector 2019-11-27 15:23:54 +00:00
Mikkel Hjortshøj
53f65224f6 Merge pull request #459 from zhibog/master
Base32 added for core:encoding
2019-11-26 19:45:52 +01:00
gingerBill
902d313c6a Fix issue with os.write on *nix with writing nothing 2019-11-24 10:08:08 +00:00
gingerBill
9b58781122 #soa[dynamic]Type (Experimental) 2019-11-21 19:36:07 +00:00
gingerBill
321dcc60e3 Update fmt.odin 2019-11-21 14:41:12 +00:00
gingerBill
2c5a84bb78 #soa[]Type (Experimental) 2019-11-21 00:07:21 +00:00
gingerBill
44e0e96612 Prepare SOA Struct code for slices and dynamic arrays *to be implemented* 2019-11-19 23:54:36 +00:00
zhibog
2484f4d04b Removed CSV stuff. 2019-11-17 20:09:00 +01:00
gingerBill
d22e5b697d Add new #soa and #vector syntax 2019-11-17 10:30:37 -08:00
gingerBill
9b4d4a2c61 Minor fix to os.write on darwin 2019-11-16 06:59:14 -08:00
Hasen Judy
c35762528c fix string reversal 2019-11-13 23:36:52 +09:00
gingerBill
536cceeef9 Add intrinsics.type_is_unsigned 2019-11-10 18:51:21 +00:00
gingerBill
098684a6fe Add 128-bit random procedures to package math/rand 2019-11-10 18:47:16 +00:00
zhibog
694ee02247 Missed one 2019-11-09 18:06:33 +01:00
zhibog
0451c88ab6 Fixed indenting 2019-11-09 18:04:30 +01:00
zhibog
803f6a6651 Added procs to read and write just the data, without any file loading / writing 2019-11-08 22:17:24 +01:00
zhibog
672cfd51c3 Added names to return values 2019-11-08 20:21:18 +01:00
zhibog
80cdf8b6a8 Should be row_count obviously 2019-11-08 20:16:56 +01:00
zhibog
dc2d5239c5 Removed comments regarding RFC test vectors 2019-11-08 20:06:58 +01:00
vassvik
04a25b11ad Fix incorrect math.linalg.cross3 indices. 2019-11-04 17:39:26 +01:00
gingerBill
40546fbde2 Use runtime.mem_copy in package me 2019-11-03 19:59:41 +00:00
gingerBill
013b3b9fb3 Fix for -vet 2019-11-03 11:42:00 +00:00
gingerBill
dc0f04e53b Fix typo in fmt 2019-11-03 00:50:47 +00:00
gingerBill
40606d9272 Fix fmt printing of anonymous SOA structs 2019-11-03 00:47:27 +00:00
gingerBill
ebf7926fa4 SOA support of Structures and Arrays; Runtime information for SOA structs; fmt printing support for SOA structs 2019-11-03 00:32:22 +00:00
gingerBill
f9aaff99c6 Fix linalg.mul; add linalg.Matrix1xN 2019-11-02 10:30:11 +00:00
zhibog
4b718aae75 Added an implementation for reading and writing csv files 2019-11-01 22:35:46 +01:00
zhibog
20db0e7f09 Added Base32 + official test vectors from the RFC 2019-11-01 22:35:09 +01:00
zhibog
614ea5c168 Added official test vectors from the RFC 2019-11-01 22:34:19 +01:00
gingerBill
b5b085914a Merge pull request #404 from hazeycode/master
Impl time for macOS
2019-11-01 19:44:50 +00:00
Chris Heyes
044e64beb0 Add missing foreign import to time_darwin 2019-11-01 19:39:26 +00:00
Chris Heyes
adca5b57cd Move time code from os to time package 2019-11-01 19:33:48 +00:00
gingerBill
3b898e5224 Add @force to foreign import 2019-11-01 19:26:22 +00:00
Chris Heyes
153e7525b5 Merge remote-tracking branch 'upstream/master' 2019-11-01 19:18:33 +00:00
gingerBill
44a303e577 Add dummy packages purely for documentation of builtin and intrinsics 2019-11-01 19:00:23 +00:00
gingerBill
d63878d0dd Merge pull request #437 from nakst/master
updated os_essence.odin
2019-11-01 10:20:29 +00:00
gingerBill
4aad45e3e7 Merge pull request #453 from kevinw/master
Remove unused variables in utf8.odin.
2019-10-29 11:47:37 +00:00
gingerBill
fe5c642d9f Fix runtime.cstring_len 2019-10-29 08:47:05 +00:00
Kevin Watters
b5fdb3f855 Remove unused variables in utf8.odin. 2019-10-28 11:13:47 -04:00
gingerBill
416ff149bd Fix procedure group "best fit" algorithm for polymorphic procedures 2019-10-27 19:42:21 +00:00
gingerBill
a29a6d9285 Fix typos in package linalg; Fix norm_float64 in package rand 2019-10-27 18:43:40 +00:00
gingerBill
5e81fc72b9 New package math and package math/linalg 2019-10-27 10:35:35 +00:00
gingerBill
0977ac111a Fix typo in package utf8; add wchar_t to package c 2019-10-27 08:34:20 +00:00
gingerBill
2db16d6a32 Add for package utf8: rune_at_pos, rune_string_at_pos, rune_at, rune_offset 2019-10-26 15:05:36 +01:00
gingerBill
5aa46d31b2 Move package decimal to be a subpackage of package strconv 2019-10-26 14:46:21 +01:00
gingerBill
1734eb949f Update utf8.accept_sizes to use ranged fields 2019-10-26 14:18:38 +01:00
gingerBill
7fae890ef9 Allow ranges for array-like compound literals 2019-10-26 14:06:29 +01:00
gingerBill
1da0668653 Add utf8.rune_index 2019-10-26 11:50:01 +01:00