Commit Graph
100 Commits
Author SHA1 Message Date
Feoramund b0d050dd90 Print timings to stderr instead of stdout
This is in line with other diagnostic messages.

Fixes #4642
2025-06-04 13:59:31 -04:00
Feoramund 68ed631582 Forbid multiple uses of -sanitize
`clang` does not allow this.

Fixes #4354
2025-06-03 21:23:24 -04:00
Feoramund 09ddf121e3 Fix typo 2025-06-03 21:15:20 -04:00
Feoramund 8cde9dce47 Rewrite Atomic_RW_Mutex
This patch simplifies the implementation and fixes #5254.

Previously, the mutex was set up as if there could be multiple writers,
and there seemed to be some confusion as to which `Writer` bits to
check, as not all were checked or set at the same time.

This could also result in the mutex being left in a non-zero state even
after unlocking all locks.

All unneeded state has been removed and extra checks have been put in
place.
2025-06-03 09:07:38 -04:00
Feoramund 16b8da6a79 Let -test-all-packages work with -build-mode:test
Fixes #3930
2025-06-02 07:47:19 -04:00
Feoramund 7996f89410 Show quaternion arguments in wxyz order, instead of xyzw, in mismatched type error
This is in accordance with the other error and makes sense with how
quaternions are printed with `real`/`w` coming first, then the
imaginaries, which are the `ijk`/`xyz` parts.
2025-06-01 14:36:38 -04:00
Feoramund b70d2b156a Make quaternion untyped values convert to first typed value found
This fixes an issue (#2079) where a typed argument could cause the
construction to fail on the basis of failed untyped -> typed conversion.
2025-06-01 14:35:53 -04:00
Feoramund 705ae3f343 Fix quaternion construction causing compiler crash
Previously, a construction of `quaternion(real=0, real=1, real=2,
real=3)` could crash the compiler.
2025-06-01 13:35:22 -04:00
Feoramund 57019f199c Add suggestions for quaternionN or complexN conversions
Quaternions and complex numbers are constructed with `quaternion` and
`complex`, but their types are of the `*N` form.

These suggestions should point the user in the right direction.
2025-05-31 07:09:29 -04:00
Feoramund 598c1a1f19 Allow overriding object extension in -build-mode:obj 2025-05-30 08:01:23 -04:00
Feoramund 73866b6b3d Remove trailing whitespace 2025-05-30 07:31:03 -04:00
Feoramund ee8234c792 Don't double-append module name when building separate objects
`m->module_name` will already have the `BuildPath_Output` name
prepended.
2025-05-30 07:15:34 -04:00
Feoramund 3c1201fb2c Error on unterminated multi-line comment 2025-05-29 18:28:54 -04:00
Feoramund 45219f240e Rename SIMD_IS_EMULATED to capability-affirmative HAS_HARDWARE_SIMD 2025-05-29 17:17:51 -04:00
Feoramund edbd247972 Use time.Stopwatch in core:bytes benchmark
This should result in a clearer idea of how fast the procedures are
running, as the loop can run without going back and forth to the system
for the time.
2025-05-29 16:35:26 -04:00
Feoramund 4e49fb4f82 Add benchmarks for runtime.memory_* comparison procedures 2025-05-29 16:35:26 -04:00
Feoramund b15a665898 Add tests for runtime.memory_* comparison procedures 2025-05-29 16:34:07 -04:00
Feoramund 34698288b8 Vectorize runtime.memory_* comparison procedures 2025-05-29 16:29:13 -04:00
Feoramund 827a6f9045 Move simd.IS_EMULATED to runtime.SIMD_IS_EMULATED 2025-05-29 15:12:01 -04:00
Feoramund b5bc0fdcda Remove commented block of code 2025-05-27 15:25:30 -04:00
Feoramund 35b157ac83 Fix multiline RegEx iteration
In `.Multiline` mode:

- `^` is now defined to assert the start of the string or that a "\n" or
  "\r" rune was parsed on last VM dispatch.

- `$` is now defined to consume a newline sequence of "\n", "\r", or
  "\r\n" or to assert the end of the string.
2025-05-26 14:48:45 -04:00
Feoramund 5d01acc04f Add more RegEx tests 2025-05-24 07:42:04 -04:00
Feoramund 37d6491300 Remove Global RegEx flag, default to unanchored patterns 2025-05-24 07:42:04 -04:00
Feoramund fedb9efb41 Make RegEx VM restartable and fix iterator infinite loop 2025-05-24 07:23:04 -04:00
Feoramund 6c5b96948e Enable all sanitizers on FreeBSD 2025-05-22 21:39:35 -04:00
Feoramund 5b5822effc Delete test executable after running, add -keep-test-executable 2025-05-22 17:58:51 -04:00
Feoramund 0536f86268 Add -build-only for odin test command
This allows test executables to be only built, not run too.
2025-05-22 17:33:24 -04:00
Feoramund 713360a792 Keep shared libraries from calling main program's startup/cleanup procs on Linux 2025-05-22 09:40:37 -04:00
Feoramund e35e1dcc7b Only trim .odin from build filenames 2025-05-22 08:23:06 -04:00
Feoramund 1662ab10af Fix off-by-one error in priority_queue.remove 2025-05-21 09:33:39 -04:00
Feoramund 899cfe9c37 Also use ENABLE_PROCESSED_OUTPUT on Windows terminals
This is specified to be necessary when using
`ENABLE_VIRTUAL_TERMINAL_PROCESSING`.
2025-05-21 08:40:19 -04:00
Feoramund e659df1a3f Restructure core:terminal for better Windows support 2025-05-21 07:49:08 -04:00
Feoramund b6f1821bba Fix terminal detection on Windows 2025-05-21 05:20:58 -04:00
Feoramund 1b407ef207 Add animation detection support to test runner 2025-05-20 19:28:07 -04:00
Feoramund 3c40a54dcd Add terminal color detection to logging in core:testing 2025-05-20 19:28:06 -04:00
Feoramund a9df1b1cde Rename core:encoding/ansi to core:terminal/ansi 2025-05-20 19:28:06 -04:00
Feoramund df5e64beeb Add terminal color detection to core:log 2025-05-20 19:28:06 -04:00
Feoramund 30c1b88741 Add core:terminal 2025-05-20 19:27:58 -04:00
Feoramund c090a28b9d Add /usr/local/lib to FreeBSD linker path 2025-05-20 18:56:18 -04:00
Feoramund b018528833 Do not call disabled deferred procedures 2025-05-19 20:50:43 -04:00
Feoramund 2c25a72b45 Make certain commands fail if passed excess arguments 2025-05-19 09:28:17 -04:00
Feoramund 4495a4c58e Check for -help sooner and show it immediately 2025-05-19 09:28:17 -04:00
Feoramund a5926532a2 Sync command descriptions between odin help and usage 2025-05-19 09:28:17 -04:00
Feoramund fa63d351ac Add missing commands to odin help 2025-05-19 09:28:17 -04:00
Feoramund e8d52ac2bc Make odin help more precise about what it accepts 2025-05-19 09:28:17 -04:00
Feoramund eb051a2d7c Re-enable static map calls on AMD64 SysV 2025-05-18 17:13:39 -04:00
Feoramund 591118c688 Use --sysroot instead of -Wl,-syslibroot on Darwin
This keeps the linker from using the wrong SDK and mirrors how we build
the Odin compiler itself in `build_odin.sh`.
2025-05-18 11:11:02 -04:00
Feoramund 840c863786 Fix Darwin version reporting for older macOS 2025-04-10 16:25:08 -04:00
Feoramund e13b05168c Fix syscall_bsd on NetBSD ARM64 2025-04-06 19:58:23 -04:00
Feoramund 649376fcfe Add require_results to getters in os2 path API 2025-03-21 19:14:15 -04:00
Feoramund cfa3e97968 Make os2 Linux _is_path_separator compare against _Path_Separator 2025-03-21 19:14:15 -04:00
Feoramund 6a6980fda8 Remove if ODIN_OS == .Windows in file that can only be built on Windows 2025-03-21 19:14:15 -04:00
Feoramund 3525e71739 Add tests for new os2 path API 2025-03-21 19:14:15 -04:00
Feoramund 4e7f54c565 Decouple usage of filepath from os2 2025-03-21 19:14:15 -04:00
Feoramund abe0c30837 Add new path API for os2 2025-03-21 19:14:15 -04:00
Feoramund d1d86234aa Add missing documentation to os2/path 2025-03-20 18:36:26 -04:00
Feoramund a495cd581c Assert that _Path_Separator is 7-bit ASCII
There are several places where this is assumed to be true, most visibly
in `is_path_separator`, as it takes a `byte` argument.

Note that the data type of `_Path_Separator` is a rune, which allows any
Unicode value.
2025-03-20 14:43:54 -04:00
Feoramund fef5f526f3 Remove unneeded slicing in strings.clone 2025-03-05 13:54:31 -05:00
Feoramund 2ab1ca29e6 Fix data races in os2/env_linux.odin
Switched to a recursive mutex so that procedures which need to perform
lookups can do so while also maintaining the lock across their entire
body in order to guarantee atomicity for each environment operation.
2025-03-04 19:32:05 -05:00
Feoramund 179e5b9266 Fix typo 2025-03-04 19:12:45 -05:00
Feoramund 266f15b672 Fix indentation 2025-03-04 19:11:32 -05:00
Feoramund 2d0dc44636 Shorten buffers used for os2.random_string results
This is needed now that `os2.random_string` fills the whole slice.
2025-03-03 19:18:54 -05:00
Feoramund d6002d68a2 Make os2.random_string use context.random_generator
This removes the data race caused by multiple threads using the
unprotected global `random_string_seed`, so long as no two threads share
the same random generator; this is the default case.

Additionally, `os2.random_string` now takes into account the full buffer
slice given to it.
2025-03-03 19:17:29 -05:00
Feoramund 675bffce88 Add missing allocator in os2.file_info_clone 2025-03-02 17:22:43 -05:00
Feoramund 7d1fcfa09b Fix wrong path in os2.user_config_dir 2025-03-02 17:22:40 -05:00
Feoramund 6054b921db Add tests for new safe to_cstring 2025-02-27 18:54:38 -05:00
Feoramund b2e3b34ce0 Fix #4890
`strings.to_cstring` previously would not check if the buffer could
handle the extra null byte and could lead to segmentation violations
when using the resulting string in an API expecting the terminator.
2025-02-27 18:54:38 -05:00
Feoramund 84700e09c9 Forbid parsing more fields if no separator was found
Fixes #4278
2024-09-20 19:02:00 -04:00
Feoramund acbf5c8d97 Forbid labelled or-branch expressions within defer 2024-09-19 05:59:37 -04:00
Feoramund 9456c36684 Specify integer-like only for some atomic_* intrinsics
Fixes #4256
2024-09-18 17:18:48 -04:00
Feoramund 16ef59700b Check for EINTR in sys/posix test 2024-09-15 23:58:03 -04:00
Feoramund d38f5ffb49 Remove unneeded synchronizations in Chan
Everything was already guarded by `c.mutex`.
2024-09-15 22:59:30 -04:00
Feoramund 7f7cfebc91 Add tests for core:sync and core:sync/chan 2024-09-11 08:39:38 -04:00
Feoramund 16cd16b91e Fix comments 2024-09-11 08:39:23 -04:00
Feoramund 2938655a3d Fix CPU count detection in FreeBSD & NetBSD 2024-09-11 08:39:23 -04:00
Feoramund b1db33b519 Add cpu_relax to sync.auto_reset_event_signal 2024-09-11 08:39:23 -04:00
Feoramund a1435a6a90 Fix deadlock in Auto_Reset_Event 2024-09-11 08:39:23 -04:00
Feoramund fec1ccd7a3 Fix data races in sync.Recursive_Benaphore 2024-09-11 08:39:23 -04:00
Feoramund b2c2235e58 Fix recursive_benaphore_try_lock
Previously, if the owner called this, it would fail.
2024-09-10 14:52:20 -04:00
Feoramund 3a60109180 Fix signalling test child threads crashing test 0
A thread made inside a test does not share the test index of its parent,
so any time one of those threads failed an assert, it would tell the
runner to shutdown test index zero.
2024-09-10 14:52:20 -04:00
Feoramund 074314b887 Fix data race in test_core_flags 2024-09-10 14:52:20 -04:00
Feoramund 8a14a656fb Fix chan.can_send for unbuffered channels
`w_waiting` is the signal that says a caller is waiting to be able to
send something. It is incremented upon send and - in the case of an
unbuffered channel - it can only hold one message.

Therefore, check that `w_waiting` is zero instead.
2024-09-10 14:52:20 -04:00
Feoramund e9a6a34480 Forbid chan.try_send on closed buffered channels 2024-09-10 14:52:20 -04:00
Feoramund 026aef69e3 Fix deadlock on sending to full, buffered, closed Chan
This will also keep messages from being sent to closed, buffered
channels in general.
2024-09-10 14:52:20 -04:00
Feoramund 73f5ab473c Keep chan.can_recv from deadlocking 2024-09-10 14:52:20 -04:00
Feoramund 0a594147af Use contextless procs in core:sync instead 2024-09-10 14:52:20 -04:00
Feoramund c3f363cfbc Fix data race when pool_stop_task is called 2024-09-09 16:19:15 -04:00
Feoramund dbb783fbf2 Fix atomic memory order for sync.ticket_mutex_unlock 2024-09-09 16:19:15 -04:00
Feoramund 45da009377 Use more atomic handling of thread flags
This can prevent a data race on Linux with `Self_Cleanup`.
2024-09-09 16:19:15 -04:00
Feoramund 4d14b4257e Convert POSIX Thread to use semaphore instead
One less value to store, and it should be less of a hack too.

Semaphores will not wait around if they have the go-ahead; they depend
on an internal value being non-zero, instead of whatever was loaded when
they started waiting, which is the case with a `Cond`.
2024-09-09 16:19:14 -04:00
Feoramund cbd4d5e765 Fix data race in atomic_sema_wait_with_timeout 2024-09-09 16:19:14 -04:00
Feoramund 74b28f1ff9 Fix rare double-join possibility in POSIX thread._join
This was occuring about 1/100 times with the test runner's thread pool.
2024-09-09 16:19:14 -04:00
Feoramund 9d6f71fd2e Fix sync.Benaphore
The calls to `atomic_add*` return the value before adding, not after, so
the previous code was causing the occasional data race.
2024-09-09 16:19:14 -04:00
Feoramund 2f1228baa0 Add tests for Bit_Array 2024-09-03 17:23:42 -04:00
Feoramund c3bd94a27e Change Bit_Array.max_index to length
This will allow correct iteration of empty `bit_array`s.
2024-09-03 16:56:02 -04:00
Feoramund d86e56089a Fix iteration of biased Bit_Array 2024-09-03 15:34:38 -04:00
Feoramund b8f8cb9582 Add bit_array.shrink 2024-09-03 13:33:15 -04:00
Feoramund 001b2b9d8f Let bit_array.create make zero-length arrays 2024-09-03 13:33:11 -04:00
Feoramund 806c87d71d Check for zero-length slices in slice.equal 2024-09-03 02:48:26 -04:00
Feoramund 309953e0f2 Return false if Small_Array can't append multiple elements
Fixes #4177
2024-09-03 01:14:17 -04:00